Holds the current temporary horizontal alignment for the cell style. If this is modified then the current text alignment is changed and the cell style is updated when the value is applied.
Specifies if the textarea should be resized while the text is being edited. Default is true.
If
Reference to the
Text to be displayed for empty labels. Default is '' or '
' in Firefox as
a workaround for the missing cursor bug for empty content editable. This can
be set to eg. "[Type Here]" to easier visualize editing of empty labels. The
value is only displayed before the first keystroke and is never used as the
actual editing value.
If true, pressing the escape key will stop editing and not accept the new value. Change this to false to accept the new value on escape, and cancel editing on Shift+Escape instead. Default is true.
Reference to the enclosing Graph.
Holds the initial editing value to check if the current value was modified.
Defines the minimum width and height to be used in
Specifies if the label has been modified.
Specifies if the text should be selected when editing starts. Default is true.
Holds the DIV that is used for text editing. Note that this may be null before the first
edit. Instantiated in
Reference to the label DOM node that has been hidden.
Reference to the event that was used to start editing.
Correction factor for word wrapping width. Default is 2 in quirks, 0 in IE 11 and 1 in all other browsers and modes.
Specifies the zIndex for the textarea. Default is 5.
Static
pluginCalled in
Returns the background color for the in-place editor. This implementation always returns NONE.
Returns the current editing value.
Returns the initial label value to be used of the label of the given
cell is empty. This label is displayed and cleared on the first keystroke.
This implementation returns
Gets the initial editing value for the given cell.
Returns true if the label should be hidden while the cell is being edited.
Returns true if the given keydown event should stop cell editing. This returns true if F2 is pressed of if Graph#enterStopsCellEditing is true and enter is pressed without control or shift.
Starts the editor for the given cell.
Optional mouse event that triggered the editor.
clearSelection() { const selection = window.getSelection();
if (selection) { if (selection.empty) { selection.empty(); } else if (selection.removeAllRanges) { selection.removeAllRanges(); } } }
/**
In-place editor for the graph. To control this editor, use Graph#invokesStopCellEditing, Graph#enterStopsCellEditing and Graph#escapeEnabled. If Graph#enterStopsCellEditing is true then ctrl-enter or shift-enter can be used to create a linefeed. The F2 and escape keys can always be used to stop editing.
To customize the location of the textbox in the graph, override as follows:
Note that this hook is only called if is false. If is true,
then Shape#getLabelBounds is used to compute the current bounds of the textbox.
The textarea uses the mxCellEditor CSS class. You can modify this class in your custom CSS. Note: You should modify the CSS after loading the client in the page.
Example:
To only allow numeric input in the in-place editor, use the following code.
Placeholder:
To implement a placeholder for cells without a label, use the variable.
Resize in Chrome:
Resize of the textarea is disabled by default. If you want to enable this feature extend and set this.textarea.style.resize = ''.
To start editing on a key press event, the container of the graph should have focus or a focusable parent should be used to add the key press handler as follows.
To allow focus for a DIV, and hence to receive key press events, some browsers require it to have a valid tabindex attribute. In this case the following code may be used to keep the container focused.