Interface ICodeeditor

All Superinterfaces:
IAnyGroup<ICodeeditor>, IComponent<ICodeeditor>, IDisable<ICodeeditor>, IHtmlBasedComponent<ICodeeditor>, IReadonly<ICodeeditor>, IXulElement<ICodeeditor>

Immutable Codeeditor component.

A code editor that loads and edits source code with syntax highlighting.

Support @Action

Name Action Type
onChange ActionData: InputData
Denotes the editor content has been modified by the user.
onChanging ActionData: InputData
Denotes that the user is changing the editor content.

Reading the edited content

There is no server-side copy of the editor content to read back: the content travels with an action. Take it from InputData.getValue() on an onChange/onChanging handler, or pull it into any other action with

 @Action(type = Events.ON_CLICK)
 public void save(@ActionVariable(targetId = ActionTarget.SELF, field = "value") String value) {
 }
 
value is the only editor state the client reports.
Since:
11.0.0
Author:
peaker
See Also:
  • Codeeditor
  • Field Details

    • DEFAULT

      static final ICodeeditor DEFAULT
      Constant for default attributes of this immutable component.
  • Method Details

    • getWidgetClass

      default String getWidgetClass()
      Returns the client widget class.

      Default: "zul.code.Codeeditor"

      Specified by:
      getWidgetClass in interface IComponent<ICodeeditor>
    • getValue

      @Nullable default String getValue()
      Returns the editor content, or null when it was reset to the default.

      Default: an empty string.

    • withValue

      ICodeeditor withValue(@Nullable String value)
      Returns a copy of this immutable component with the specified value.

      Sets the editor content.

      Parameters:
      value - the source code, or null to reset to the default, as Codeeditor.setValue(String) does.

      Default: "".

      Returns:
      A modified copy of the this object
    • getLanguage

      @Nullable default String getLanguage()
      Returns the syntax-highlight language, or null when it was reset to the default.

      Default: "plain".

    • withLanguage

      ICodeeditor withLanguage(@Nullable String language)
      Returns a copy of this immutable component with the specified language.

      Sets the syntax-highlight language.

      Parameters:
      language - one of plain, html, xml, java, javascript, css, json, sql, markdown.

      Default: "plain".

      Returns:
      A modified copy of the this object
      Throws:
      org.zkoss.zk.ui.WrongValueException - if language is not an accepted token.
    • isLineNumbers

      default boolean isLineNumbers()
      Returns whether the gutter line numbers are shown.

      Default: true.

    • withLineNumbers

      ICodeeditor withLineNumbers(boolean lineNumbers)
      Returns a copy of this immutable component with the specified lineNumbers.

      Sets whether the gutter line numbers are shown.

      Parameters:
      lineNumbers - whether to show the line-number gutter.

      Default: true.

      Returns:
      A modified copy of the this object
    • getTabSize

      default int getTabSize()
      Returns the number of columns a tab character is rendered as.

      Default: 4.

    • withTabSize

      ICodeeditor withTabSize(int tabSize)
      Returns a copy of this immutable component with the specified tabSize.

      Sets how many columns a tab character is rendered as. The indent character itself is always a tab; this only changes its displayed width.

      Parameters:
      tabSize - a positive column count.

      Default: 4.

      Returns:
      A modified copy of the this object
      Throws:
      org.zkoss.zk.ui.WrongValueException - if tabSize is less than 1.
    • getColorScheme

      @Nullable default String getColorScheme()
      Returns the editor color scheme, or null when it was reset to the default.

      Default: "light".

    • withColorScheme

      ICodeeditor withColorScheme(@Nullable String colorScheme)
      Returns a copy of this immutable component with the specified colorScheme.

      Sets the editor color scheme. This is the editor's own light/dark surface, not the page theme selected through Themes.

      Parameters:
      colorScheme - either "light" or "dark".

      Default: "light".

      Returns:
      A modified copy of the this object
      Throws:
      org.zkoss.zk.ui.WrongValueException - if colorScheme is neither.
    • of

      static ICodeeditor of(String value)
      Returns the instance with the given content.
      Parameters:
      value - The source code to edit
    • ofId

      static ICodeeditor ofId(String id)
      Returns the instance with the given id.
      Parameters:
      id - The id to identify this component