* Open editor with initial value. * * @param {null|string} newInitialValue New value from which editor will start if handled property it's not the `null`. * @param {Event} event The event object. * @param {boolean} [enableFullEditMode=false] When true, an editor works in full editing mod
(newInitialValue: string | null, event: Event, enableFullEditMode = false)
| 167 | * when arrow keys are pressed. |
| 168 | */ |
| 169 | openEditor(newInitialValue: string | null, event: Event, enableFullEditMode = false) { |
| 170 | if (!this.isCellEditable()) { |
| 171 | this.clearActiveEditor(); |
| 172 | |
| 173 | return; |
| 174 | } |
| 175 | |
| 176 | const selection = this.hot.getSelectedRangeActive(); |
| 177 | let allowOpening = this.hot.runHooks( |
| 178 | 'beforeBeginEditing', |
| 179 | selection!.highlight.row, |
| 180 | selection!.highlight.col, |
| 181 | newInitialValue, |
| 182 | event, |
| 183 | enableFullEditMode, |
| 184 | ); |
| 185 | |
| 186 | // If the above hook does not return boolean then the default behavior is applied which disallows opening |
| 187 | // an editor after double mouse click for non-contiguous selection (while pressing Ctrl/Cmd) and |
| 188 | // for multiple selected cells (while pressing SHIFT). |
| 189 | if (event instanceof MouseEvent && typeof allowOpening !== 'boolean') { |
| 190 | allowOpening = this.hot.selection.getLayerLevel() === 0 && selection!.isSingle(); |
| 191 | } |
| 192 | |
| 193 | if (allowOpening === false) { |
| 194 | this.clearActiveEditor(); |
| 195 | |
| 196 | return; |
| 197 | } |
| 198 | |
| 199 | if (!this.activeEditor) { |
| 200 | this.hot.scrollToFocusedCell(); |
| 201 | this.prepareEditor(); |
| 202 | } |
| 203 | |
| 204 | if (this.activeEditor) { |
| 205 | if (enableFullEditMode) { |
| 206 | this.activeEditor.enableFullEditMode(); |
| 207 | } |
| 208 | |
| 209 | this.activeEditor.beginEditing(newInitialValue, event); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | /** |
| 214 | * Close editor, finish editing cell. |
no test coverage detected