lexical 0.37.1-nightly.20251015.0 → 0.37.1-nightly.20251017.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Lexical.dev.js CHANGED
@@ -140,6 +140,13 @@ const DOUBLE_LINE_BREAK = '\n\n';
140
140
  // For FF, we need to use a non-breaking space, or it gets composition
141
141
  // in a stuck state.
142
142
  const COMPOSITION_START_CHAR = IS_FIREFOX ? NON_BREAKING_SPACE : COMPOSITION_SUFFIX;
143
+ const RTL = '\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC';
144
+ const LTR = 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6' + '\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C' + '\uFE00-\uFE6F\uFEFD-\uFFFF';
145
+
146
+ // eslint-disable-next-line no-misleading-character-class
147
+ const RTL_REGEX = new RegExp('^[^' + LTR + ']*[' + RTL + ']');
148
+ // eslint-disable-next-line no-misleading-character-class
149
+ const LTR_REGEX = new RegExp('^[^' + RTL + ']*[' + LTR + ']');
143
150
  const TEXT_TYPE_TO_FORMAT = {
144
151
  bold: IS_BOLD,
145
152
  capitalize: IS_CAPITALIZE,
@@ -10828,7 +10835,7 @@ class LexicalEditor {
10828
10835
  };
10829
10836
  }
10830
10837
  }
10831
- LexicalEditor.version = "0.37.1-nightly.20251015.0+dev.cjs";
10838
+ LexicalEditor.version = "0.37.1-nightly.20251017.0+dev.cjs";
10832
10839
 
10833
10840
  let pendingNodeToClone = null;
10834
10841
  function setPendingNodeToClone(pendingNode) {
@@ -10918,6 +10925,15 @@ function getEditorPropertyFromDOMNode(node) {
10918
10925
  // @ts-expect-error: internal field
10919
10926
  return node ? node.__lexicalEditor : null;
10920
10927
  }
10928
+ function getTextDirection(text) {
10929
+ if (RTL_REGEX.test(text)) {
10930
+ return 'rtl';
10931
+ }
10932
+ if (LTR_REGEX.test(text)) {
10933
+ return 'ltr';
10934
+ }
10935
+ return null;
10936
+ }
10921
10937
 
10922
10938
  /**
10923
10939
  * Return true if the TextNode is a TabNode or is in token mode.
@@ -14128,6 +14144,7 @@ exports.getNearestEditorFromDOMNode = getNearestEditorFromDOMNode;
14128
14144
  exports.getRegisteredNode = getRegisteredNode;
14129
14145
  exports.getRegisteredNodeOrThrow = getRegisteredNodeOrThrow;
14130
14146
  exports.getStaticNodeConfig = getStaticNodeConfig;
14147
+ exports.getTextDirection = getTextDirection;
14131
14148
  exports.isBlockDomNode = isBlockDomNode;
14132
14149
  exports.isCurrentlyReadOnlyMode = isCurrentlyReadOnlyMode;
14133
14150
  exports.isDOMDocumentNode = isDOMDocumentNode;
package/Lexical.dev.mjs CHANGED
@@ -138,6 +138,13 @@ const DOUBLE_LINE_BREAK = '\n\n';
138
138
  // For FF, we need to use a non-breaking space, or it gets composition
139
139
  // in a stuck state.
140
140
  const COMPOSITION_START_CHAR = IS_FIREFOX ? NON_BREAKING_SPACE : COMPOSITION_SUFFIX;
141
+ const RTL = '\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC';
142
+ const LTR = 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6' + '\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C' + '\uFE00-\uFE6F\uFEFD-\uFFFF';
143
+
144
+ // eslint-disable-next-line no-misleading-character-class
145
+ const RTL_REGEX = new RegExp('^[^' + LTR + ']*[' + RTL + ']');
146
+ // eslint-disable-next-line no-misleading-character-class
147
+ const LTR_REGEX = new RegExp('^[^' + RTL + ']*[' + LTR + ']');
141
148
  const TEXT_TYPE_TO_FORMAT = {
142
149
  bold: IS_BOLD,
143
150
  capitalize: IS_CAPITALIZE,
@@ -10826,7 +10833,7 @@ class LexicalEditor {
10826
10833
  };
10827
10834
  }
10828
10835
  }
10829
- LexicalEditor.version = "0.37.1-nightly.20251015.0+dev.esm";
10836
+ LexicalEditor.version = "0.37.1-nightly.20251017.0+dev.esm";
10830
10837
 
10831
10838
  let pendingNodeToClone = null;
10832
10839
  function setPendingNodeToClone(pendingNode) {
@@ -10916,6 +10923,15 @@ function getEditorPropertyFromDOMNode(node) {
10916
10923
  // @ts-expect-error: internal field
10917
10924
  return node ? node.__lexicalEditor : null;
10918
10925
  }
10926
+ function getTextDirection(text) {
10927
+ if (RTL_REGEX.test(text)) {
10928
+ return 'rtl';
10929
+ }
10930
+ if (LTR_REGEX.test(text)) {
10931
+ return 'ltr';
10932
+ }
10933
+ return null;
10934
+ }
10919
10935
 
10920
10936
  /**
10921
10937
  * Return true if the TextNode is a TabNode or is in token mode.
@@ -13939,4 +13955,4 @@ function shallowMergeConfig(config, overrides) {
13939
13955
  return config;
13940
13956
  }
13941
13957
 
13942
- export { $addUpdateTag, $applyNodeReplacement, $caretFromPoint, $caretRangeFromSelection, $cloneWithProperties, $cloneWithPropertiesEphemeral, $comparePointCaretNext, $copyNode, $create, $createLineBreakNode, $createNodeSelection, $createParagraphNode, $createPoint, $createRangeSelection, $createRangeSelectionFromDom, $createTabNode, $createTextNode, $extendCaretToRange, $findMatchingParent, $getAdjacentChildCaret, $getAdjacentNode, $getAdjacentSiblingOrParentSiblingCaret, $getCaretInDirection, $getCaretRange, $getCaretRangeInDirection, $getCharacterOffsets, $getChildCaret, $getChildCaretAtIndex, $getChildCaretOrSelf, $getCollapsedCaretRange, $getCommonAncestor, $getCommonAncestorResultBranchOrder, $getEditor, $getNearestNodeFromDOMNode, $getNearestRootOrShadowRoot, $getNodeByKey, $getNodeByKeyOrThrow, $getNodeFromDOMNode, $getPreviousSelection, $getRoot, $getSelection, $getSiblingCaret, $getState, $getStateChange, $getTextContent, $getTextNodeOffset, $getTextPointCaret, $getTextPointCaretSlice, $getWritableNodeState, $hasAncestor, $hasUpdateTag, $insertNodes, $isBlockElementNode, $isChildCaret, $isDecoratorNode, $isEditorState, $isElementNode, $isExtendableTextPointCaret, $isInlineElementOrDecoratorNode, $isLeafNode, $isLineBreakNode, $isNodeCaret, $isNodeSelection, $isParagraphNode, $isRangeSelection, $isRootNode, $isRootOrShadowRoot, $isSiblingCaret, $isTabNode, $isTextNode, $isTextPointCaret, $isTextPointCaretSlice, $isTokenOrSegmented, $isTokenOrTab, $nodesOfType, $normalizeCaret, $normalizeSelection as $normalizeSelection__EXPERIMENTAL, $onUpdate, $parseSerializedNode, $removeTextFromCaretRange, $rewindSiblingCaret, $selectAll, $setCompositionKey, $setPointFromCaret, $setSelection, $setSelectionFromCaretRange, $setState, $splitAtPointCaretNext, $splitNode, $updateRangeSelectionFromCaretRange, ArtificialNode__DO_NOT_USE, BLUR_COMMAND, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, CLEAR_EDITOR_COMMAND, CLEAR_HISTORY_COMMAND, CLICK_COMMAND, COLLABORATION_TAG, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, CONTROLLED_TEXT_INSERTION_COMMAND, COPY_COMMAND, CUT_COMMAND, DELETE_CHARACTER_COMMAND, DELETE_LINE_COMMAND, DELETE_WORD_COMMAND, DRAGEND_COMMAND, DRAGOVER_COMMAND, DRAGSTART_COMMAND, DROP_COMMAND, DecoratorNode, ElementNode, FOCUS_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, HISTORIC_TAG, HISTORY_MERGE_TAG, HISTORY_PUSH_TAG, INDENT_CONTENT_COMMAND, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, INSERT_TAB_COMMAND, INTERNAL_$isBlock, IS_ALL_FORMATTING, IS_BOLD, IS_CODE, IS_HIGHLIGHT, IS_ITALIC, IS_STRIKETHROUGH, IS_SUBSCRIPT, IS_SUPERSCRIPT, IS_UNDERLINE, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_DOWN_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_MODIFIER_COMMAND, KEY_SPACE_COMMAND, KEY_TAB_COMMAND, LineBreakNode, MOVE_TO_END, MOVE_TO_START, NODE_STATE_KEY, OUTDENT_CONTENT_COMMAND, PASTE_COMMAND, PASTE_TAG, ParagraphNode, REDO_COMMAND, REMOVE_TEXT_COMMAND, RootNode, SELECTION_CHANGE_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, SELECT_ALL_COMMAND, SKIP_COLLAB_TAG, SKIP_DOM_SELECTION_TAG, SKIP_SCROLL_INTO_VIEW_TAG, SKIP_SELECTION_FOCUS_TAG, TEXT_TYPE_TO_FORMAT, TabNode, TextNode, UNDO_COMMAND, buildImportMap, configExtension, createCommand, createEditor, createSharedNodeState, createState, declarePeerDependency, defineExtension, flipDirection, getDOMOwnerDocument, getDOMSelection, getDOMSelectionFromTarget, getDOMTextNode, getEditorPropertyFromDOMNode, getNearestEditorFromDOMNode, getRegisteredNode, getRegisteredNodeOrThrow, getStaticNodeConfig, isBlockDomNode, isCurrentlyReadOnlyMode, isDOMDocumentNode, isDOMNode, isDOMTextNode, isDOMUnmanaged, isDocumentFragment, isExactShortcutMatch, isHTMLAnchorElement, isHTMLElement, isInlineDomNode, isLexicalEditor, isModifierMatch, isSelectionCapturedInDecoratorInput, isSelectionWithinEditor, makeStepwiseIterator, removeFromParent, resetRandomKey, safeCast, setDOMUnmanaged, setNodeIndentFromDOM, shallowMergeConfig };
13958
+ export { $addUpdateTag, $applyNodeReplacement, $caretFromPoint, $caretRangeFromSelection, $cloneWithProperties, $cloneWithPropertiesEphemeral, $comparePointCaretNext, $copyNode, $create, $createLineBreakNode, $createNodeSelection, $createParagraphNode, $createPoint, $createRangeSelection, $createRangeSelectionFromDom, $createTabNode, $createTextNode, $extendCaretToRange, $findMatchingParent, $getAdjacentChildCaret, $getAdjacentNode, $getAdjacentSiblingOrParentSiblingCaret, $getCaretInDirection, $getCaretRange, $getCaretRangeInDirection, $getCharacterOffsets, $getChildCaret, $getChildCaretAtIndex, $getChildCaretOrSelf, $getCollapsedCaretRange, $getCommonAncestor, $getCommonAncestorResultBranchOrder, $getEditor, $getNearestNodeFromDOMNode, $getNearestRootOrShadowRoot, $getNodeByKey, $getNodeByKeyOrThrow, $getNodeFromDOMNode, $getPreviousSelection, $getRoot, $getSelection, $getSiblingCaret, $getState, $getStateChange, $getTextContent, $getTextNodeOffset, $getTextPointCaret, $getTextPointCaretSlice, $getWritableNodeState, $hasAncestor, $hasUpdateTag, $insertNodes, $isBlockElementNode, $isChildCaret, $isDecoratorNode, $isEditorState, $isElementNode, $isExtendableTextPointCaret, $isInlineElementOrDecoratorNode, $isLeafNode, $isLineBreakNode, $isNodeCaret, $isNodeSelection, $isParagraphNode, $isRangeSelection, $isRootNode, $isRootOrShadowRoot, $isSiblingCaret, $isTabNode, $isTextNode, $isTextPointCaret, $isTextPointCaretSlice, $isTokenOrSegmented, $isTokenOrTab, $nodesOfType, $normalizeCaret, $normalizeSelection as $normalizeSelection__EXPERIMENTAL, $onUpdate, $parseSerializedNode, $removeTextFromCaretRange, $rewindSiblingCaret, $selectAll, $setCompositionKey, $setPointFromCaret, $setSelection, $setSelectionFromCaretRange, $setState, $splitAtPointCaretNext, $splitNode, $updateRangeSelectionFromCaretRange, ArtificialNode__DO_NOT_USE, BLUR_COMMAND, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, CLEAR_EDITOR_COMMAND, CLEAR_HISTORY_COMMAND, CLICK_COMMAND, COLLABORATION_TAG, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, CONTROLLED_TEXT_INSERTION_COMMAND, COPY_COMMAND, CUT_COMMAND, DELETE_CHARACTER_COMMAND, DELETE_LINE_COMMAND, DELETE_WORD_COMMAND, DRAGEND_COMMAND, DRAGOVER_COMMAND, DRAGSTART_COMMAND, DROP_COMMAND, DecoratorNode, ElementNode, FOCUS_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, HISTORIC_TAG, HISTORY_MERGE_TAG, HISTORY_PUSH_TAG, INDENT_CONTENT_COMMAND, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, INSERT_TAB_COMMAND, INTERNAL_$isBlock, IS_ALL_FORMATTING, IS_BOLD, IS_CODE, IS_HIGHLIGHT, IS_ITALIC, IS_STRIKETHROUGH, IS_SUBSCRIPT, IS_SUPERSCRIPT, IS_UNDERLINE, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_DOWN_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_MODIFIER_COMMAND, KEY_SPACE_COMMAND, KEY_TAB_COMMAND, LineBreakNode, MOVE_TO_END, MOVE_TO_START, NODE_STATE_KEY, OUTDENT_CONTENT_COMMAND, PASTE_COMMAND, PASTE_TAG, ParagraphNode, REDO_COMMAND, REMOVE_TEXT_COMMAND, RootNode, SELECTION_CHANGE_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, SELECT_ALL_COMMAND, SKIP_COLLAB_TAG, SKIP_DOM_SELECTION_TAG, SKIP_SCROLL_INTO_VIEW_TAG, SKIP_SELECTION_FOCUS_TAG, TEXT_TYPE_TO_FORMAT, TabNode, TextNode, UNDO_COMMAND, buildImportMap, configExtension, createCommand, createEditor, createSharedNodeState, createState, declarePeerDependency, defineExtension, flipDirection, getDOMOwnerDocument, getDOMSelection, getDOMSelectionFromTarget, getDOMTextNode, getEditorPropertyFromDOMNode, getNearestEditorFromDOMNode, getRegisteredNode, getRegisteredNodeOrThrow, getStaticNodeConfig, getTextDirection, isBlockDomNode, isCurrentlyReadOnlyMode, isDOMDocumentNode, isDOMNode, isDOMTextNode, isDOMUnmanaged, isDocumentFragment, isExactShortcutMatch, isHTMLAnchorElement, isHTMLElement, isInlineDomNode, isLexicalEditor, isModifierMatch, isSelectionCapturedInDecoratorInput, isSelectionWithinEditor, makeStepwiseIterator, removeFromParent, resetRandomKey, safeCast, setDOMUnmanaged, setNodeIndentFromDOM, shallowMergeConfig };
package/Lexical.mjs CHANGED
@@ -196,6 +196,7 @@ export const getNearestEditorFromDOMNode = mod.getNearestEditorFromDOMNode;
196
196
  export const getRegisteredNode = mod.getRegisteredNode;
197
197
  export const getRegisteredNodeOrThrow = mod.getRegisteredNodeOrThrow;
198
198
  export const getStaticNodeConfig = mod.getStaticNodeConfig;
199
+ export const getTextDirection = mod.getTextDirection;
199
200
  export const isBlockDomNode = mod.isBlockDomNode;
200
201
  export const isCurrentlyReadOnlyMode = mod.isCurrentlyReadOnlyMode;
201
202
  export const isDOMDocumentNode = mod.isDOMDocumentNode;
package/Lexical.node.mjs CHANGED
@@ -194,6 +194,7 @@ export const getNearestEditorFromDOMNode = mod.getNearestEditorFromDOMNode;
194
194
  export const getRegisteredNode = mod.getRegisteredNode;
195
195
  export const getRegisteredNodeOrThrow = mod.getRegisteredNodeOrThrow;
196
196
  export const getStaticNodeConfig = mod.getStaticNodeConfig;
197
+ export const getTextDirection = mod.getTextDirection;
197
198
  export const isBlockDomNode = mod.isBlockDomNode;
198
199
  export const isCurrentlyReadOnlyMode = mod.isCurrentlyReadOnlyMode;
199
200
  export const isDOMDocumentNode = mod.isDOMDocumentNode;