Type Editor / @type-editor/dom-change-util / browser-hacks/should-handle-mobile-enter-key / shouldHandleMobileEnterKey
Function: shouldHandleMobileEnterKey()
function shouldHandleMobileEnterKey(view, addedNodes, change): boolean;Defined in: browser-hacks/should-handle-mobile-enter-key.ts:40
Checks if a mobile Enter key should be handled instead of processing the DOM change.
Mobile browsers (iOS and Android) sometimes handle Enter key presses in ways that are better processed through the key handler than as DOM changes. This function detects such cases by checking:
- The platform is iOS (with recent Enter) or Android
- Block-level nodes (DIV, P, etc.) were added to the DOM
- No content change was detected, or content was deleted
When all conditions are met, the Enter key is dispatched through the handleKeyDown plugin system instead of processing the DOM change directly.
Parameters
| Parameter | Type | Description |
|---|---|---|
view | PmEditorView | The editor view containing input state and plugin handlers |
addedNodes | readonly Node[] | Nodes that were added to the DOM during the mutation. Used to detect if block-level elements were created. |
change | DocumentChange | The detected document change, if any. Null if no change detected. |
Returns
boolean
True if the Enter key handler was invoked and the event should be handled that way, false if the DOM change should be processed normally
Remarks
Uses a regex to detect inline vs block-level HTML elements