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 AbstractGraph.
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
Called if the textarea has lost focus.
Returns the background color for the in-place editor. This implementation always returns NONE.
Returns the cell that is currently being edited or null if no cell is being edited.
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.
Creates the
Installs listeners for focus, change and standard key event handling.
Returns true if
Returns true if this editor is the source for the given native event.
Returns true if the label should be hidden while the cell is being edited.
Returns
Returns true if the given keydown event should stop cell editing. This returns true if F2 is pressed of if AbstractGraph.enterStopsCellEditing is true and enter is pressed without control or shift.
Destroys the editor and removes all associated resources.
Prepares the textarea for getting its value in
Returns odified.
Sets the temporary horizontal alignment for the current editing session.
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:
If AbstractGraph.enterStopsCellEditing is
true
then ctrl-enter or shift-enter can be used to create a linefeed.The F2 (accept change) and escape keys (undo change) can always be used to stop editing.
To customize the location of the textbox in the graph, override getEditorBounds as follows:
Note that this hook is only called if autoSize is
false
. If autoSize istrue
, 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.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 emptyLabelText variable.
Resize the textarea
Resize of the textarea is disabled by default. If you want to enable this feature extend init and set
this.textarea.style.resize = ''
.Editing on key press
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.