@lexical/react 0.14.5 → 0.16.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/LexicalAutoEmbedPlugin.dev.js +15 -11
- package/LexicalAutoEmbedPlugin.dev.mjs +5 -2
- package/LexicalAutoEmbedPlugin.js +2 -0
- package/LexicalAutoEmbedPlugin.mjs +2 -0
- package/LexicalAutoEmbedPlugin.node.mjs +2 -0
- package/LexicalAutoEmbedPlugin.prod.js +6 -5
- package/LexicalAutoEmbedPlugin.prod.mjs +3 -1
- package/LexicalAutoFocusPlugin.dev.js +3 -0
- package/LexicalAutoFocusPlugin.dev.mjs +3 -0
- package/LexicalAutoFocusPlugin.js +2 -0
- package/LexicalAutoFocusPlugin.mjs +2 -0
- package/LexicalAutoFocusPlugin.node.mjs +2 -0
- package/LexicalAutoFocusPlugin.prod.js +2 -0
- package/LexicalAutoFocusPlugin.prod.mjs +2 -0
- package/LexicalAutoLinkPlugin.dev.js +9 -4
- package/LexicalAutoLinkPlugin.dev.mjs +10 -5
- package/LexicalAutoLinkPlugin.js +2 -0
- package/LexicalAutoLinkPlugin.mjs +2 -0
- package/LexicalAutoLinkPlugin.node.mjs +2 -0
- package/LexicalAutoLinkPlugin.prod.js +12 -10
- package/LexicalAutoLinkPlugin.prod.mjs +3 -1
- package/LexicalBlockWithAlignableContents.dev.js +14 -9
- package/LexicalBlockWithAlignableContents.dev.mjs +11 -7
- package/LexicalBlockWithAlignableContents.js +2 -0
- package/LexicalBlockWithAlignableContents.mjs +2 -0
- package/LexicalBlockWithAlignableContents.node.mjs +2 -0
- package/LexicalBlockWithAlignableContents.prod.js +6 -4
- package/LexicalBlockWithAlignableContents.prod.mjs +3 -1
- package/LexicalCharacterLimitPlugin.dev.js +17 -12
- package/LexicalCharacterLimitPlugin.dev.mjs +12 -8
- package/LexicalCharacterLimitPlugin.js +2 -0
- package/LexicalCharacterLimitPlugin.mjs +2 -0
- package/LexicalCharacterLimitPlugin.node.mjs +2 -0
- package/LexicalCharacterLimitPlugin.prod.js +11 -9
- package/LexicalCharacterLimitPlugin.prod.mjs +3 -1
- package/LexicalCheckListPlugin.dev.js +5 -0
- package/LexicalCheckListPlugin.dev.mjs +5 -0
- package/LexicalCheckListPlugin.js +2 -0
- package/LexicalCheckListPlugin.mjs +2 -0
- package/LexicalCheckListPlugin.node.mjs +2 -0
- package/LexicalCheckListPlugin.prod.js +4 -2
- package/LexicalCheckListPlugin.prod.mjs +3 -1
- package/LexicalClearEditorPlugin.dev.js +9 -2
- package/LexicalClearEditorPlugin.dev.mjs +11 -4
- package/LexicalClearEditorPlugin.js +2 -0
- package/LexicalClearEditorPlugin.mjs +2 -0
- package/LexicalClearEditorPlugin.node.mjs +2 -0
- package/LexicalClearEditorPlugin.prod.js +3 -1
- package/LexicalClearEditorPlugin.prod.mjs +3 -1
- package/LexicalClickableLinkPlugin.d.ts +3 -1
- package/LexicalClickableLinkPlugin.dev.js +17 -15
- package/LexicalClickableLinkPlugin.dev.mjs +16 -15
- package/LexicalClickableLinkPlugin.js +2 -0
- package/LexicalClickableLinkPlugin.js.flow +3 -1
- package/LexicalClickableLinkPlugin.mjs +3 -0
- package/LexicalClickableLinkPlugin.node.mjs +3 -0
- package/LexicalClickableLinkPlugin.prod.js +6 -4
- package/LexicalClickableLinkPlugin.prod.mjs +3 -1
- package/LexicalCollaborationContext.dev.js +3 -0
- package/LexicalCollaborationContext.dev.mjs +3 -0
- package/LexicalCollaborationContext.js +2 -0
- package/LexicalCollaborationContext.mjs +2 -0
- package/LexicalCollaborationContext.node.mjs +2 -0
- package/LexicalCollaborationContext.prod.js +2 -0
- package/LexicalCollaborationContext.prod.mjs +2 -0
- package/LexicalCollaborationPlugin.dev.js +20 -2
- package/LexicalCollaborationPlugin.dev.mjs +6 -1
- package/LexicalCollaborationPlugin.js +2 -0
- package/LexicalCollaborationPlugin.mjs +2 -0
- package/LexicalCollaborationPlugin.node.mjs +2 -0
- package/LexicalCollaborationPlugin.prod.js +12 -10
- package/LexicalCollaborationPlugin.prod.mjs +3 -1
- package/LexicalComposer.dev.js +17 -8
- package/LexicalComposer.dev.mjs +16 -8
- package/LexicalComposer.js +2 -0
- package/LexicalComposer.mjs +2 -0
- package/LexicalComposer.node.mjs +2 -0
- package/LexicalComposer.prod.js +5 -4
- package/LexicalComposer.prod.mjs +3 -1
- package/LexicalComposerContext.dev.js +3 -0
- package/LexicalComposerContext.dev.mjs +3 -0
- package/LexicalComposerContext.js +2 -0
- package/LexicalComposerContext.mjs +2 -0
- package/LexicalComposerContext.node.mjs +2 -0
- package/LexicalComposerContext.prod.js +4 -2
- package/LexicalComposerContext.prod.mjs +3 -1
- package/LexicalContentEditable.dev.js +24 -23
- package/LexicalContentEditable.dev.mjs +22 -22
- package/LexicalContentEditable.js +2 -0
- package/LexicalContentEditable.mjs +2 -0
- package/LexicalContentEditable.node.mjs +2 -0
- package/LexicalContentEditable.prod.js +5 -3
- package/LexicalContentEditable.prod.mjs +3 -1
- package/LexicalContextMenuPlugin.dev.js +29 -7
- package/LexicalContextMenuPlugin.dev.mjs +17 -8
- package/LexicalContextMenuPlugin.js +2 -0
- package/LexicalContextMenuPlugin.js.flow +12 -0
- package/LexicalContextMenuPlugin.mjs +2 -0
- package/LexicalContextMenuPlugin.node.mjs +2 -0
- package/LexicalContextMenuPlugin.prod.js +18 -16
- package/LexicalContextMenuPlugin.prod.mjs +3 -1
- package/LexicalDecoratorBlockNode.d.ts +1 -0
- package/LexicalDecoratorBlockNode.dev.js +6 -0
- package/LexicalDecoratorBlockNode.dev.mjs +6 -0
- package/LexicalDecoratorBlockNode.js +2 -0
- package/LexicalDecoratorBlockNode.mjs +2 -0
- package/LexicalDecoratorBlockNode.node.mjs +2 -0
- package/LexicalDecoratorBlockNode.prod.js +3 -1
- package/LexicalDecoratorBlockNode.prod.mjs +3 -1
- package/LexicalEditorRefPlugin.dev.js +17 -1
- package/LexicalEditorRefPlugin.dev.mjs +3 -0
- package/LexicalEditorRefPlugin.js +2 -0
- package/LexicalEditorRefPlugin.js.flow +19 -0
- package/LexicalEditorRefPlugin.mjs +2 -0
- package/LexicalEditorRefPlugin.node.mjs +2 -0
- package/LexicalEditorRefPlugin.prod.js +3 -1
- package/LexicalEditorRefPlugin.prod.mjs +2 -0
- package/LexicalErrorBoundary.d.ts +3 -1
- package/LexicalErrorBoundary.dev.js +30 -10
- package/LexicalErrorBoundary.dev.mjs +13 -7
- package/LexicalErrorBoundary.js +2 -0
- package/LexicalErrorBoundary.js.flow +4 -1
- package/LexicalErrorBoundary.mjs +3 -0
- package/LexicalErrorBoundary.node.mjs +3 -0
- package/LexicalErrorBoundary.prod.js +6 -4
- package/LexicalErrorBoundary.prod.mjs +3 -1
- package/LexicalHashtagPlugin.dev.js +5 -2
- package/LexicalHashtagPlugin.dev.mjs +5 -2
- package/LexicalHashtagPlugin.js +2 -0
- package/LexicalHashtagPlugin.mjs +2 -0
- package/LexicalHashtagPlugin.node.mjs +2 -0
- package/LexicalHashtagPlugin.prod.js +2 -0
- package/LexicalHashtagPlugin.prod.mjs +2 -0
- package/LexicalHistoryPlugin.dev.js +4 -0
- package/LexicalHistoryPlugin.dev.mjs +4 -0
- package/LexicalHistoryPlugin.js +2 -0
- package/LexicalHistoryPlugin.mjs +2 -0
- package/LexicalHistoryPlugin.node.mjs +2 -0
- package/LexicalHistoryPlugin.prod.js +2 -0
- package/LexicalHistoryPlugin.prod.mjs +2 -0
- package/LexicalHorizontalRuleNode.d.ts +2 -2
- package/LexicalHorizontalRuleNode.dev.js +23 -12
- package/LexicalHorizontalRuleNode.dev.mjs +21 -11
- package/LexicalHorizontalRuleNode.js +2 -0
- package/LexicalHorizontalRuleNode.mjs +2 -0
- package/LexicalHorizontalRuleNode.node.mjs +2 -0
- package/LexicalHorizontalRuleNode.prod.js +7 -5
- package/LexicalHorizontalRuleNode.prod.mjs +3 -1
- package/LexicalHorizontalRulePlugin.dev.js +3 -0
- package/LexicalHorizontalRulePlugin.dev.mjs +3 -0
- package/LexicalHorizontalRulePlugin.js +2 -0
- package/LexicalHorizontalRulePlugin.mjs +2 -0
- package/LexicalHorizontalRulePlugin.node.mjs +2 -0
- package/LexicalHorizontalRulePlugin.prod.js +2 -0
- package/LexicalHorizontalRulePlugin.prod.mjs +2 -0
- package/LexicalLinkPlugin.dev.js +6 -3
- package/LexicalLinkPlugin.dev.mjs +7 -4
- package/LexicalLinkPlugin.js +2 -0
- package/LexicalLinkPlugin.mjs +2 -0
- package/LexicalLinkPlugin.node.mjs +2 -0
- package/LexicalLinkPlugin.prod.js +3 -1
- package/LexicalLinkPlugin.prod.mjs +3 -1
- package/LexicalListPlugin.dev.js +4 -0
- package/LexicalListPlugin.dev.mjs +4 -0
- package/LexicalListPlugin.js +2 -0
- package/LexicalListPlugin.mjs +2 -0
- package/LexicalListPlugin.node.mjs +2 -0
- package/LexicalListPlugin.prod.js +2 -0
- package/LexicalListPlugin.prod.mjs +2 -0
- package/LexicalMarkdownShortcutPlugin.dev.js +3 -0
- package/LexicalMarkdownShortcutPlugin.dev.mjs +3 -0
- package/LexicalMarkdownShortcutPlugin.js +2 -0
- package/LexicalMarkdownShortcutPlugin.mjs +2 -0
- package/LexicalMarkdownShortcutPlugin.node.mjs +2 -0
- package/LexicalMarkdownShortcutPlugin.prod.js +2 -0
- package/LexicalMarkdownShortcutPlugin.prod.mjs +2 -0
- package/LexicalNestedComposer.dev.js +14 -9
- package/LexicalNestedComposer.dev.mjs +8 -4
- package/LexicalNestedComposer.js +2 -0
- package/LexicalNestedComposer.mjs +2 -0
- package/LexicalNestedComposer.node.mjs +2 -0
- package/LexicalNestedComposer.prod.js +7 -5
- package/LexicalNestedComposer.prod.mjs +3 -1
- package/LexicalNodeEventPlugin.dev.js +3 -0
- package/LexicalNodeEventPlugin.dev.mjs +3 -0
- package/LexicalNodeEventPlugin.js +2 -0
- package/LexicalNodeEventPlugin.js.flow +12 -0
- package/LexicalNodeEventPlugin.mjs +2 -0
- package/LexicalNodeEventPlugin.node.mjs +2 -0
- package/LexicalNodeEventPlugin.prod.js +2 -0
- package/LexicalNodeEventPlugin.prod.mjs +2 -0
- package/LexicalNodeMenuPlugin.dev.js +30 -8
- package/LexicalNodeMenuPlugin.dev.mjs +17 -8
- package/LexicalNodeMenuPlugin.js +2 -0
- package/LexicalNodeMenuPlugin.mjs +2 -0
- package/LexicalNodeMenuPlugin.node.mjs +2 -0
- package/LexicalNodeMenuPlugin.prod.js +17 -15
- package/LexicalNodeMenuPlugin.prod.mjs +3 -1
- package/LexicalOnChangePlugin.dev.js +9 -2
- package/LexicalOnChangePlugin.dev.mjs +11 -4
- package/LexicalOnChangePlugin.js +2 -0
- package/LexicalOnChangePlugin.mjs +2 -0
- package/LexicalOnChangePlugin.node.mjs +2 -0
- package/LexicalOnChangePlugin.prod.js +3 -1
- package/LexicalOnChangePlugin.prod.mjs +3 -1
- package/LexicalPlainTextPlugin.dev.js +34 -19
- package/LexicalPlainTextPlugin.dev.mjs +31 -17
- package/LexicalPlainTextPlugin.js +2 -0
- package/LexicalPlainTextPlugin.js.flow +1 -1
- package/LexicalPlainTextPlugin.mjs +2 -0
- package/LexicalPlainTextPlugin.node.mjs +2 -0
- package/LexicalPlainTextPlugin.prod.js +6 -4
- package/LexicalPlainTextPlugin.prod.mjs +3 -1
- package/LexicalRichTextPlugin.dev.js +34 -19
- package/LexicalRichTextPlugin.dev.mjs +31 -17
- package/LexicalRichTextPlugin.js +2 -0
- package/LexicalRichTextPlugin.js.flow +1 -1
- package/LexicalRichTextPlugin.mjs +2 -0
- package/LexicalRichTextPlugin.node.mjs +2 -0
- package/LexicalRichTextPlugin.prod.js +6 -4
- package/LexicalRichTextPlugin.prod.mjs +3 -1
- package/LexicalTabIndentationPlugin.dev.js +5 -2
- package/LexicalTabIndentationPlugin.dev.mjs +5 -2
- package/LexicalTabIndentationPlugin.js +2 -0
- package/LexicalTabIndentationPlugin.mjs +2 -0
- package/LexicalTabIndentationPlugin.node.mjs +2 -0
- package/LexicalTabIndentationPlugin.prod.js +2 -0
- package/LexicalTabIndentationPlugin.prod.mjs +2 -0
- package/LexicalTableOfContents.d.ts +6 -13
- package/LexicalTableOfContents.dev.js +57 -10
- package/LexicalTableOfContents.dev.mjs +58 -11
- package/LexicalTableOfContents.js +2 -0
- package/LexicalTableOfContents.js.flow +3 -7
- package/LexicalTableOfContents.mjs +2 -0
- package/LexicalTableOfContents.node.mjs +2 -0
- package/LexicalTableOfContents.prod.js +6 -4
- package/LexicalTableOfContents.prod.mjs +3 -1
- package/LexicalTableOfContentsPlugin.d.ts +20 -0
- package/LexicalTableOfContentsPlugin.dev.js +198 -0
- package/LexicalTableOfContentsPlugin.dev.mjs +196 -0
- package/LexicalTableOfContentsPlugin.js +11 -0
- package/LexicalTableOfContentsPlugin.js.flow +18 -0
- package/LexicalTableOfContentsPlugin.mjs +12 -0
- package/LexicalTableOfContentsPlugin.node.mjs +10 -0
- package/LexicalTableOfContentsPlugin.prod.js +12 -0
- package/LexicalTableOfContentsPlugin.prod.mjs +9 -0
- package/LexicalTablePlugin.dev.js +28 -2
- package/LexicalTablePlugin.dev.mjs +31 -5
- package/LexicalTablePlugin.js +2 -0
- package/LexicalTablePlugin.mjs +2 -0
- package/LexicalTablePlugin.node.mjs +2 -0
- package/LexicalTablePlugin.prod.js +9 -5
- package/LexicalTablePlugin.prod.mjs +3 -1
- package/LexicalTreeView.d.ts +3 -1
- package/LexicalTreeView.dev.js +22 -4
- package/LexicalTreeView.dev.mjs +8 -3
- package/LexicalTreeView.js +2 -0
- package/LexicalTreeView.js.flow +2 -0
- package/LexicalTreeView.mjs +2 -0
- package/LexicalTreeView.node.mjs +2 -0
- package/LexicalTreeView.prod.js +5 -3
- package/LexicalTreeView.prod.mjs +3 -1
- package/LexicalTypeaheadMenuPlugin.dev.js +30 -8
- package/LexicalTypeaheadMenuPlugin.dev.mjs +17 -8
- package/LexicalTypeaheadMenuPlugin.js +2 -0
- package/LexicalTypeaheadMenuPlugin.mjs +2 -0
- package/LexicalTypeaheadMenuPlugin.node.mjs +2 -0
- package/LexicalTypeaheadMenuPlugin.prod.js +21 -19
- package/LexicalTypeaheadMenuPlugin.prod.mjs +3 -1
- package/package.json +50 -20
- package/shared/useCharacterLimit.d.ts +1 -1
- package/useLexicalEditable.d.ts +11 -1
- package/useLexicalEditable.dev.js +22 -3
- package/useLexicalEditable.dev.mjs +23 -5
- package/useLexicalEditable.js +2 -0
- package/useLexicalEditable.js.flow +4 -1
- package/useLexicalEditable.mjs +4 -1
- package/useLexicalEditable.node.mjs +4 -1
- package/useLexicalEditable.prod.js +4 -2
- package/useLexicalEditable.prod.mjs +3 -1
- package/useLexicalIsTextContentEmpty.dev.js +9 -2
- package/useLexicalIsTextContentEmpty.dev.mjs +11 -4
- package/useLexicalIsTextContentEmpty.js +2 -0
- package/useLexicalIsTextContentEmpty.mjs +2 -0
- package/useLexicalIsTextContentEmpty.node.mjs +2 -0
- package/useLexicalIsTextContentEmpty.prod.js +3 -1
- package/useLexicalIsTextContentEmpty.prod.mjs +3 -1
- package/useLexicalNodeSelection.dev.js +3 -0
- package/useLexicalNodeSelection.dev.mjs +4 -1
- package/useLexicalNodeSelection.js +2 -0
- package/useLexicalNodeSelection.mjs +2 -0
- package/useLexicalNodeSelection.node.mjs +2 -0
- package/useLexicalNodeSelection.prod.js +2 -0
- package/useLexicalNodeSelection.prod.mjs +3 -1
- package/useLexicalSubscription.d.ts +4 -1
- package/useLexicalSubscription.dev.js +12 -3
- package/useLexicalSubscription.dev.mjs +13 -5
- package/useLexicalSubscription.js +2 -0
- package/useLexicalSubscription.js.flow +4 -1
- package/useLexicalSubscription.mjs +4 -1
- package/useLexicalSubscription.node.mjs +4 -1
- package/useLexicalSubscription.prod.js +4 -2
- package/useLexicalSubscription.prod.mjs +3 -1
- package/useLexicalTextEntity.dev.js +3 -0
- package/useLexicalTextEntity.dev.mjs +3 -0
- package/useLexicalTextEntity.js +2 -0
- package/useLexicalTextEntity.mjs +2 -0
- package/useLexicalTextEntity.node.mjs +2 -0
- package/useLexicalTextEntity.prod.js +2 -0
- package/useLexicalTextEntity.prod.mjs +2 -0
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
8
10
|
import { createCommand, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW, $getSelection, $isRangeSelection, $isTextNode } from 'lexical';
|
|
9
11
|
import * as React from 'react';
|
|
10
|
-
import { useLayoutEffect
|
|
12
|
+
import { useLayoutEffect, useEffect, useState, useCallback, useMemo, useRef } from 'react';
|
|
11
13
|
import { mergeRegister } from '@lexical/utils';
|
|
14
|
+
import { jsx } from 'react/jsx-runtime';
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
17
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -27,8 +30,12 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
27
30
|
* LICENSE file in the root directory of this source tree.
|
|
28
31
|
*
|
|
29
32
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
// This workaround is no longer necessary in React 19,
|
|
36
|
+
// but we currently support React >=17.x
|
|
37
|
+
// https://github.com/facebook/react/pull/26395
|
|
38
|
+
const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
|
|
32
39
|
|
|
33
40
|
/**
|
|
34
41
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -37,6 +44,7 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
37
44
|
* LICENSE file in the root directory of this source tree.
|
|
38
45
|
*
|
|
39
46
|
*/
|
|
47
|
+
|
|
40
48
|
class MenuOption {
|
|
41
49
|
constructor(key) {
|
|
42
50
|
this.key = key;
|
|
@@ -124,7 +132,7 @@ function $splitNodeContainingQuery(match) {
|
|
|
124
132
|
function getScrollParent$1(element, includeHidden) {
|
|
125
133
|
let style = getComputedStyle(element);
|
|
126
134
|
const excludeStaticParent = style.position === 'absolute';
|
|
127
|
-
const overflowRegex =
|
|
135
|
+
const overflowRegex = /(auto|scroll)/;
|
|
128
136
|
if (style.position === 'fixed') {
|
|
129
137
|
return document.body;
|
|
130
138
|
}
|
|
@@ -151,7 +159,7 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
|
|
|
151
159
|
useEffect(() => {
|
|
152
160
|
if (targetElement != null && resolution != null) {
|
|
153
161
|
const rootElement = editor.getRootElement();
|
|
154
|
-
const rootScrollParent = rootElement != null ? getScrollParent$1(rootElement
|
|
162
|
+
const rootScrollParent = rootElement != null ? getScrollParent$1(rootElement) : document.body;
|
|
155
163
|
let ticking = false;
|
|
156
164
|
let previousIsInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent);
|
|
157
165
|
const handleScroll = function () {
|
|
@@ -223,7 +231,7 @@ function LexicalMenu({
|
|
|
223
231
|
}
|
|
224
232
|
};
|
|
225
233
|
}, [editor]);
|
|
226
|
-
|
|
234
|
+
useLayoutEffectImpl(() => {
|
|
227
235
|
if (options === null) {
|
|
228
236
|
setHighlightedIndex(null);
|
|
229
237
|
} else if (selectedIndex === null) {
|
|
@@ -335,7 +343,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
335
343
|
if (left + menuWidth > rootElementRect.right) {
|
|
336
344
|
containerDiv.style.left = `${rootElementRect.right - menuWidth + window.pageXOffset}px`;
|
|
337
345
|
}
|
|
338
|
-
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight) {
|
|
346
|
+
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight + height) {
|
|
339
347
|
containerDiv.style.top = `${top - menuHeight + window.pageYOffset - height}px`;
|
|
340
348
|
}
|
|
341
349
|
}
|
|
@@ -387,6 +395,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
387
395
|
* LICENSE file in the root directory of this source tree.
|
|
388
396
|
*
|
|
389
397
|
*/
|
|
398
|
+
|
|
390
399
|
const PUNCTUATION = '\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%\'"~=<>_:;';
|
|
391
400
|
function getTextUpToAnchor(selection) {
|
|
392
401
|
const anchor = selection.anchor;
|
|
@@ -553,7 +562,7 @@ function LexicalTypeaheadMenuPlugin({
|
|
|
553
562
|
removeUpdateListener();
|
|
554
563
|
};
|
|
555
564
|
}, [editor, triggerFn, onQueryChange, resolution, closeTypeahead, openTypeahead]);
|
|
556
|
-
return resolution === null || editor === null ? null : /*#__PURE__*/
|
|
565
|
+
return resolution === null || editor === null ? null : /*#__PURE__*/jsx(LexicalMenu, {
|
|
557
566
|
close: closeTypeahead,
|
|
558
567
|
resolution: resolution,
|
|
559
568
|
editor: editor,
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict'
|
|
8
10
|
const LexicalTypeaheadMenuPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalTypeaheadMenuPlugin.dev.js') : require('./LexicalTypeaheadMenuPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalTypeaheadMenuPlugin;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import * as modDev from './LexicalTypeaheadMenuPlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalTypeaheadMenuPlugin.prod.mjs';
|
|
9
11
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalTypeaheadMenuPlugin.dev.mjs') : import('./LexicalTypeaheadMenuPlugin.prod.mjs'));
|
|
8
10
|
export const LexicalTypeaheadMenuPlugin = mod.LexicalTypeaheadMenuPlugin;
|
|
9
11
|
export const MenuOption = mod.MenuOption;
|
|
@@ -3,23 +3,25 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
function
|
|
12
|
-
e
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
a.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
let
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
exports.
|
|
8
|
+
|
|
9
|
+
'use strict';var k=require("@lexical/react/LexicalComposerContext"),q=require("lexical"),y=require("react"),z=require("@lexical/utils"),B=require("react/jsx-runtime"),C=Object.create(null);if(y)for(var D in y)C[D]=y[D];C.default=y;let E="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?y.useLayoutEffect:y.useEffect;
|
|
10
|
+
class F{constructor(b){this.key=b;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(b){this.ref={current:b}}}let G=b=>{const a=document.getElementById("typeahead-menu");if(a){var c=a.getBoundingClientRect();c.top+c.height>window.innerHeight&&a.scrollIntoView({block:"center"});0>c.top&&a.scrollIntoView({block:"center"});b.scrollIntoView({block:"nearest"})}};
|
|
11
|
+
function J(b){var a=q.$getSelection();if(!q.$isRangeSelection(a)||!a.isCollapsed())return null;var c=a.anchor;if("text"!==c.type)return null;a=c.getNode();if(!a.isSimpleText())return null;c=c.offset;let d=a.getTextContent().slice(0,c);var f=b.matchingString;b=b.replaceableString.length;for(let r=b;r<=f.length;r++)d.substr(-r)===f.substr(0,r)&&(b=r);b=c-b;if(0>b)return null;let n;0===b?[n]=a.splitText(c):[,n]=a.splitText(b,c);return n}
|
|
12
|
+
function K(b){let a=getComputedStyle(b),c="absolute"===a.position,d=/(auto|scroll)/;if("fixed"===a.position)return document.body;for(;b=b.parentElement;)if(a=getComputedStyle(b),(!c||"static"!==a.position)&&d.test(a.overflow+a.overflowY+a.overflowX))return b;return document.body}function L(b,a){b=b.getBoundingClientRect();a=a.getBoundingClientRect();return b.top>a.top&&b.top<a.bottom}
|
|
13
|
+
function M(b,a,c,d){let [f]=k.useLexicalComposerContext();y.useEffect(()=>{if(null!=a&&null!=b){let n=f.getRootElement(),r=null!=n?K(n):document.body,v=!1,p=L(a,r),e=function(){v||(window.requestAnimationFrame(function(){c();v=!1}),v=!0);const l=L(a,r);l!==p&&(p=l,null!=d&&d(l))},h=new ResizeObserver(c);window.addEventListener("resize",c);document.addEventListener("scroll",e,{capture:!0,passive:!0});h.observe(a);return()=>{h.unobserve(a);window.removeEventListener("resize",c);document.removeEventListener("scroll",
|
|
14
|
+
e,!0)}}},[a,f,d,c,b])}let N=q.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
|
|
15
|
+
function O({close:b,editor:a,anchorElementRef:c,resolution:d,options:f,menuRenderFn:n,onSelectOption:r,shouldSplitNodeWithQuery:v=!1,commandPriority:p=q.COMMAND_PRIORITY_LOW}){let [e,h]=y.useState(null);y.useEffect(()=>{h(0)},[d.match&&d.match.matchingString]);let l=y.useCallback(g=>{a.update(()=>{const m=null!=d.match&&v?J(d.match):null;r(g,m,b,d.match?d.match.matchingString:"")})},[a,v,d.match,r,b]),t=y.useCallback(g=>{const m=a.getRootElement();null!==m&&(m.setAttribute("aria-activedescendant",
|
|
16
|
+
"typeahead-item-"+g),h(g))},[a]);y.useEffect(()=>()=>{let g=a.getRootElement();null!==g&&g.removeAttribute("aria-activedescendant")},[a]);E(()=>{null===f?h(null):null===e&&t(0)},[f,e,t]);y.useEffect(()=>z.mergeRegister(a.registerCommand(N,({option:g})=>g.ref&&null!=g.ref.current?(G(g.ref.current),!0):!1,p)),[a,t,p]);y.useEffect(()=>z.mergeRegister(a.registerCommand(q.KEY_ARROW_DOWN_COMMAND,g=>{if(null!==f&&f.length&&null!==e){let m=e!==f.length-1?e+1:0;t(m);let w=f[m];null!=w.ref&&w.ref.current&&
|
|
17
|
+
a.dispatchCommand(N,{index:m,option:w});g.preventDefault();g.stopImmediatePropagation()}return!0},p),a.registerCommand(q.KEY_ARROW_UP_COMMAND,g=>{if(null!==f&&f.length&&null!==e){var m=0!==e?e-1:f.length-1;t(m);m=f[m];null!=m.ref&&m.ref.current&&G(m.ref.current);g.preventDefault();g.stopImmediatePropagation()}return!0},p),a.registerCommand(q.KEY_ESCAPE_COMMAND,g=>{g.preventDefault();g.stopImmediatePropagation();b();return!0},p),a.registerCommand(q.KEY_TAB_COMMAND,g=>{if(null===f||null===e||null==
|
|
18
|
+
f[e])return!1;g.preventDefault();g.stopImmediatePropagation();l(f[e]);return!0},p),a.registerCommand(q.KEY_ENTER_COMMAND,g=>{if(null===f||null===e||null==f[e])return!1;null!==g&&(g.preventDefault(),g.stopImmediatePropagation());l(f[e]);return!0},p)),[l,b,a,f,e,t,p]);let u=y.useMemo(()=>({options:f,selectOptionAndCleanUp:l,selectedIndex:e,setHighlightedIndex:h}),[l,e,f]);return n(c,u,d.match?d.match.matchingString:"")}
|
|
19
|
+
function P(b,a,c,d=document.body){let [f]=k.useLexicalComposerContext(),n=y.useRef(document.createElement("div")),r=y.useCallback(()=>{n.current.style.top=n.current.style.bottom;const p=f.getRootElement(),e=n.current;var h=e.firstChild;if(null!==p&&null!==b){const {left:t,top:u,width:g,height:m}=b.getRect();e.style.top=`${u+window.pageYOffset+n.current.offsetHeight+3}px`;e.style.left=`${t+window.pageXOffset}px`;e.style.height=`${m}px`;e.style.width=`${g}px`;if(null!==h){h.style.top=`${u}`;var l=h.getBoundingClientRect();
|
|
20
|
+
h=l.height;l=l.width;const w=p.getBoundingClientRect();t+l>w.right&&(e.style.left=`${w.right-l+window.pageXOffset}px`);(u+h>window.innerHeight||u+h>w.bottom)&&u-w.top>h+m&&(e.style.top=`${u-h+window.pageYOffset-m}px`)}e.isConnected||(null!=c&&(e.className=c),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("id","typeahead-menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute",d.append(e));n.current=e;p.setAttribute("aria-controls","typeahead-menu")}},
|
|
21
|
+
[f,b,c,d]);y.useEffect(()=>{let p=f.getRootElement();if(null!==b)return r(),()=>{null!==p&&p.removeAttribute("aria-controls");let e=n.current;null!==e&&e.isConnected&&e.remove()}},[f,r,b]);let v=y.useCallback(p=>{null!==b&&(p||a(null))},[b,a]);M(b,n.current,r,v);return n}function Q(b,a,c){var d=c.getSelection();if(null===d||!d.isCollapsed)return!1;c=d.anchorNode;d=d.anchorOffset;if(null==c||null==d)return!1;try{a.setStart(c,b),a.setEnd(c,d)}catch(f){return!1}return!0}
|
|
22
|
+
function R(b){let a=null;b.getEditorState().read(()=>{var c=q.$getSelection();if(q.$isRangeSelection(c)){var d=c.anchor;"text"!==d.type?a=null:(c=d.getNode(),c.isSimpleText()?(d=d.offset,a=c.getTextContent().slice(0,d)):a=null)}});return a}function S(b,a){return 0!==a?!1:b.getEditorState().read(()=>{var c=q.$getSelection();return q.$isRangeSelection(c)?(c=c.anchor.getNode().getPreviousSibling(),q.$isTextNode(c)&&c.isTextEntity()):!1})}function T(b){C.startTransition?C.startTransition(b):b()}
|
|
23
|
+
let U=q.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
|
|
24
|
+
exports.LexicalTypeaheadMenuPlugin=function({options:b,onQueryChange:a,onSelectOption:c,onOpen:d,onClose:f,menuRenderFn:n,triggerFn:r,anchorClassName:v,commandPriority:p=q.COMMAND_PRIORITY_LOW,parent:e}){let [h]=k.useLexicalComposerContext(),[l,t]=y.useState(null);v=P(l,t,v,e);let u=y.useCallback(()=>{t(null);null!=f&&null!==l&&f()},[f,l]),g=y.useCallback(m=>{t(m);null!=d&&null===l&&d(m)},[d,l]);y.useEffect(()=>{let m=h.registerUpdateListener(()=>{h.getEditorState().read(()=>{const w=h._window||window,
|
|
25
|
+
A=w.document.createRange(),H=q.$getSelection(),I=R(h);if(q.$isRangeSelection(H)&&H.isCollapsed()&&null!==I&&null!==A){var x=r(I,h);a(x?x.matchingString:null);null===x||S(h,x.leadOffset)||null===Q(x.leadOffset,A,w)?u():T(()=>g({getRect:()=>A.getBoundingClientRect(),match:x}))}else u()})});return()=>{m()}},[h,r,a,l,u,g]);return null===l||null===h?null:B.jsx(O,{close:u,resolution:l,editor:h,anchorElementRef:v,options:b,menuRenderFn:n,shouldSplitNodeWithQuery:!0,onSelectOption:c,commandPriority:p})};
|
|
26
|
+
exports.MenuOption=F;exports.PUNCTUATION="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";exports.SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND=U;exports.getScrollParent=function(b,a){let c=getComputedStyle(b),d="absolute"===c.position;a=a?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===c.position)return document.body;for(;b=b.parentElement;)if(c=getComputedStyle(b),(!d||"static"!==c.position)&&a.test(c.overflow+c.overflowY+c.overflowX))return b;return document.body};
|
|
27
|
+
exports.useBasicTypeaheadTriggerMatch=function(b,{minLength:a=1,maxLength:c=75}){return y.useCallback(d=>{d=(new RegExp("(^|\\s|\\()(["+b+"]((?:[^"+(b+"\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;\\s]){0,")+c+"}))$")).exec(d);if(null!==d){let f=d[1],n=d[3];if(n.length>=a)return{leadOffset:d.index+f.length,matchingString:n,replaceableString:d[2]}}return null},[c,a,b])};exports.useDynamicPositioning=M
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{createCommand as e,KEY_ARROW_DOWN_COMMAND as n,KEY_ARROW_UP_COMMAND as o,KEY_ESCAPE_COMMAND as r,KEY_TAB_COMMAND as l,KEY_ENTER_COMMAND as i,COMMAND_PRIORITY_LOW as s,$getSelection as u,$isRangeSelection as c,$isTextNode as a}from"lexical";import*as d from"react";import{useLayoutEffect as m,useEffect as f,useState as p,useCallback as g,useMemo as h,useRef as w}from"react";import{mergeRegister as y}from"@lexical/utils";import{jsx as C}from"react/jsx-runtime";const b="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?m:f;class v{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const x=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function E(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>o.top&&n.top<o.bottom}function S(e,n,o,r){const[l]=t();f((()=>{if(null!=n&&null!=e){const t=l.getRootElement(),e=null!=t?function(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,r=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t):document.body;let i=!1,s=E(n,e);const u=function(){i||(window.requestAnimationFrame((function(){o(),i=!1})),i=!0);const t=E(n,e);t!==s&&(s=t,null!=r&&r(t))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",u,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",u,!0)}}}),[n,l,r,o,e])}const R=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function O({close:t,editor:e,anchorElementRef:a,resolution:d,options:m,menuRenderFn:w,onSelectOption:C,shouldSplitNodeWithQuery:v=!1,commandPriority:E=s}){const[S,O]=p(null),I=d.match&&d.match.matchingString;f((()=>{O(0)}),[I]);const T=g((n=>{e.update((()=>{const e=null!=d.match&&v?function(t){const e=u();if(!c(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const r=n.offset,l=o.getTextContent().slice(0,r),i=t.replaceableString.length,s=r-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.substr(-n)===e.substr(0,n)&&(o=n);return o}(l,t.matchingString,i);if(s<0)return null;let a;return 0===s?[a]=o.splitText(r):[,a]=o.splitText(s,r),a}(d.match):null;C(n,e,t,d.match?d.match.matchingString:"")}))}),[e,v,d.match,C,t]),A=g((t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),O(t))}),[e]);f((()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[e]),b((()=>{null===m?O(null):null===S&&A(0)}),[m,S,A]),f((()=>y(e.registerCommand(R,(({option:t})=>!(!t.ref||null==t.ref.current)&&(x(t.ref.current),!0)),E))),[e,A,E]),f((()=>y(e.registerCommand(n,(t=>{const n=t;if(null!==m&&m.length&&null!==S){const t=S!==m.length-1?S+1:0;A(t);const o=m[t];null!=o.ref&&o.ref.current&&e.dispatchCommand(R,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0}),E),e.registerCommand(o,(t=>{const e=t;if(null!==m&&m.length&&null!==S){const t=0!==S?S-1:m.length-1;A(t);const n=m[t];null!=n.ref&&n.ref.current&&x(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),E),e.registerCommand(r,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),E),e.registerCommand(l,(t=>{const e=t;return null!==m&&null!==S&&null!=m[S]&&(e.preventDefault(),e.stopImmediatePropagation(),T(m[S]),!0)}),E),e.registerCommand(i,(t=>null!==m&&null!==S&&null!=m[S]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),T(m[S]),!0)),E))),[T,t,e,m,S,A,E]);return w(a,h((()=>({options:m,selectOptionAndCleanUp:T,selectedIndex:S,setHighlightedIndex:O})),[T,S,m]),d.match?d.match.matchingString:"")}const I="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";function T(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,r=e?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&r.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}const A=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function N(t,{minLength:e=1,maxLength:n=75}){return g((o=>{const r=new RegExp("(^|\\s|\\()(["+t+"]((?:"+("[^"+t+I+"\\s]")+"){0,"+n+"}))$").exec(o);if(null!==r){const t=r[1],n=r[3];if(n.length>=e)return{leadOffset:r.index+t.length,matchingString:n,replaceableString:r[2]}}return null}),[n,e,t])}function P({options:e,onQueryChange:n,onSelectOption:o,onOpen:r,onClose:l,menuRenderFn:i,triggerFn:m,anchorClassName:h,commandPriority:y=s,parent:b}){const[v]=t(),[x,E]=p(null),R=function(e,n,o,r=document.body){const[l]=t(),i=w(document.createElement("div")),s=g((()=>{i.current.style.top=i.current.style.bottom;const t=l.getRootElement(),n=i.current,s=n.firstChild;if(null!==t&&null!==e){const{left:l,top:u,width:c,height:a}=e.getRect(),d=i.current.offsetHeight;if(n.style.top=`${u+window.pageYOffset+d+3}px`,n.style.left=`${l+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${c}px`,null!==s){s.style.top=`${u}`;const e=s.getBoundingClientRect(),o=e.height,r=e.width,i=t.getBoundingClientRect();l+r>i.right&&(n.style.left=`${i.right-r+window.pageXOffset}px`),(u+o>window.innerHeight||u+o>i.bottom)&&u-i.top>o+a&&(n.style.top=u-o+window.pageYOffset-a+"px")}n.isConnected||(null!=o&&(n.className=o),n.setAttribute("aria-label","Typeahead menu"),n.setAttribute("id","typeahead-menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute",r.append(n)),i.current=n,t.setAttribute("aria-controls","typeahead-menu")}}),[l,e,o,r]);f((()=>{const t=l.getRootElement();if(null!==e)return s(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=i.current;null!==e&&e.isConnected&&e.remove()}}),[l,s,e]);const u=g((t=>{null!==e&&(t||n(null))}),[e,n]);return S(e,i.current,s,u),i}(x,E,h,b),I=g((()=>{E(null),null!=l&&null!==x&&l()}),[l,x]),T=g((t=>{E(t),null!=r&&null===x&&r(t)}),[r,x]);return f((()=>{const t=v.registerUpdateListener((()=>{v.getEditorState().read((()=>{const t=v._window||window,e=t.document.createRange(),o=u(),r=function(t){let e=null;return t.getEditorState().read((()=>{const t=u();c(t)&&(e=function(t){const e=t.anchor;if("text"!==e.type)return null;const n=e.getNode();if(!n.isSimpleText())return null;const o=e.offset;return n.getTextContent().slice(0,o)}(t))})),e}(v);if(!c(o)||!o.isCollapsed()||null===r||null===e)return void I();const l=m(r,v);if(n(l?l.matchingString:null),null!==l&&!function(t,e){return 0===e&&t.getEditorState().read((()=>{const t=u();if(c(t)){const e=t.anchor.getNode().getPreviousSibling();return a(e)&&e.isTextEntity()}return!1}))}(v,l.leadOffset)){const n=function(t,e,n){const o=n.getSelection();if(null===o||!o.isCollapsed)return!1;const r=o.anchorNode,l=t,i=o.anchorOffset;if(null==r||null==i)return!1;try{e.setStart(r,l),e.setEnd(r,i)}catch(t){return!1}return!0}(l.leadOffset,e,t);if(null!==n)return i=()=>T({getRect:()=>e.getBoundingClientRect(),match:l}),void(d.startTransition?d.startTransition(i):i())}var i;I()}))}));return()=>{t()}}),[v,m,n,x,I,T]),null===x||null===v?null:C(O,{close:I,resolution:x,editor:v,anchorElementRef:R,options:e,menuRenderFn:i,shouldSplitNodeWithQuery:!0,onSelectOption:o,commandPriority:y})}export{P as LexicalTypeaheadMenuPlugin,v as MenuOption,I as PUNCTUATION,A as SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,T as getScrollParent,N as useBasicTypeaheadTriggerMatch,S as useDynamicPositioning};
|
package/package.json
CHANGED
|
@@ -8,27 +8,27 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.16.0",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@lexical/clipboard": "0.
|
|
14
|
-
"@lexical/code": "0.
|
|
15
|
-
"@lexical/devtools-core": "0.
|
|
16
|
-
"@lexical/dragon": "0.
|
|
17
|
-
"@lexical/hashtag": "0.
|
|
18
|
-
"@lexical/history": "0.
|
|
19
|
-
"@lexical/link": "0.
|
|
20
|
-
"@lexical/list": "0.
|
|
21
|
-
"@lexical/mark": "0.
|
|
22
|
-
"@lexical/markdown": "0.
|
|
23
|
-
"@lexical/overflow": "0.
|
|
24
|
-
"@lexical/plain-text": "0.
|
|
25
|
-
"@lexical/rich-text": "0.
|
|
26
|
-
"@lexical/selection": "0.
|
|
27
|
-
"@lexical/table": "0.
|
|
28
|
-
"@lexical/text": "0.
|
|
29
|
-
"@lexical/utils": "0.
|
|
30
|
-
"@lexical/yjs": "0.
|
|
31
|
-
"lexical": "0.
|
|
13
|
+
"@lexical/clipboard": "0.16.0",
|
|
14
|
+
"@lexical/code": "0.16.0",
|
|
15
|
+
"@lexical/devtools-core": "0.16.0",
|
|
16
|
+
"@lexical/dragon": "0.16.0",
|
|
17
|
+
"@lexical/hashtag": "0.16.0",
|
|
18
|
+
"@lexical/history": "0.16.0",
|
|
19
|
+
"@lexical/link": "0.16.0",
|
|
20
|
+
"@lexical/list": "0.16.0",
|
|
21
|
+
"@lexical/mark": "0.16.0",
|
|
22
|
+
"@lexical/markdown": "0.16.0",
|
|
23
|
+
"@lexical/overflow": "0.16.0",
|
|
24
|
+
"@lexical/plain-text": "0.16.0",
|
|
25
|
+
"@lexical/rich-text": "0.16.0",
|
|
26
|
+
"@lexical/selection": "0.16.0",
|
|
27
|
+
"@lexical/table": "0.16.0",
|
|
28
|
+
"@lexical/text": "0.16.0",
|
|
29
|
+
"@lexical/utils": "0.16.0",
|
|
30
|
+
"@lexical/yjs": "0.16.0",
|
|
31
|
+
"lexical": "0.16.0",
|
|
32
32
|
"react-error-boundary": "^3.1.4"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
@@ -1001,6 +1001,36 @@
|
|
|
1001
1001
|
"default": "./LexicalTableOfContents.js"
|
|
1002
1002
|
}
|
|
1003
1003
|
},
|
|
1004
|
+
"./LexicalTableOfContentsPlugin": {
|
|
1005
|
+
"import": {
|
|
1006
|
+
"types": "./LexicalTableOfContentsPlugin.d.ts",
|
|
1007
|
+
"development": "./LexicalTableOfContentsPlugin.dev.mjs",
|
|
1008
|
+
"production": "./LexicalTableOfContentsPlugin.prod.mjs",
|
|
1009
|
+
"node": "./LexicalTableOfContentsPlugin.node.mjs",
|
|
1010
|
+
"default": "./LexicalTableOfContentsPlugin.mjs"
|
|
1011
|
+
},
|
|
1012
|
+
"require": {
|
|
1013
|
+
"types": "./LexicalTableOfContentsPlugin.d.ts",
|
|
1014
|
+
"development": "./LexicalTableOfContentsPlugin.dev.js",
|
|
1015
|
+
"production": "./LexicalTableOfContentsPlugin.prod.js",
|
|
1016
|
+
"default": "./LexicalTableOfContentsPlugin.js"
|
|
1017
|
+
}
|
|
1018
|
+
},
|
|
1019
|
+
"./LexicalTableOfContentsPlugin.js": {
|
|
1020
|
+
"import": {
|
|
1021
|
+
"types": "./LexicalTableOfContentsPlugin.d.ts",
|
|
1022
|
+
"development": "./LexicalTableOfContentsPlugin.dev.mjs",
|
|
1023
|
+
"production": "./LexicalTableOfContentsPlugin.prod.mjs",
|
|
1024
|
+
"node": "./LexicalTableOfContentsPlugin.node.mjs",
|
|
1025
|
+
"default": "./LexicalTableOfContentsPlugin.mjs"
|
|
1026
|
+
},
|
|
1027
|
+
"require": {
|
|
1028
|
+
"types": "./LexicalTableOfContentsPlugin.d.ts",
|
|
1029
|
+
"development": "./LexicalTableOfContentsPlugin.dev.js",
|
|
1030
|
+
"production": "./LexicalTableOfContentsPlugin.prod.js",
|
|
1031
|
+
"default": "./LexicalTableOfContentsPlugin.js"
|
|
1032
|
+
}
|
|
1033
|
+
},
|
|
1004
1034
|
"./LexicalTablePlugin": {
|
|
1005
1035
|
"import": {
|
|
1006
1036
|
"types": "./LexicalTablePlugin.d.ts",
|
|
@@ -12,5 +12,5 @@ type OptionalProps = {
|
|
|
12
12
|
strlen?: (input: string) => number;
|
|
13
13
|
};
|
|
14
14
|
export declare function useCharacterLimit(editor: LexicalEditor, maxCharacters: number, optional?: OptionalProps): void;
|
|
15
|
-
export declare function mergePrevious(overflowNode: OverflowNode): void;
|
|
15
|
+
export declare function $mergePrevious(overflowNode: OverflowNode): void;
|
|
16
16
|
export {};
|
package/useLexicalEditable.d.ts
CHANGED
|
@@ -5,4 +5,14 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Get the current value for {@link LexicalEditor.isEditable}
|
|
10
|
+
* using {@link useLexicalSubscription}.
|
|
11
|
+
* You should prefer this over manually observing the value with
|
|
12
|
+
* {@link LexicalEditor.registerEditableListener},
|
|
13
|
+
* which is a bit tricky to do correctly, particularly when using
|
|
14
|
+
* React StrictMode (the default for development) or concurrency.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useLexicalEditable(): boolean;
|
|
17
|
+
/** @deprecated use the named export {@link useLexicalEditable} */
|
|
18
|
+
export default useLexicalEditable;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';
|
|
8
10
|
|
|
9
11
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
@@ -26,8 +28,12 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
26
28
|
* LICENSE file in the root directory of this source tree.
|
|
27
29
|
*
|
|
28
30
|
*/
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// This workaround is no longer necessary in React 19,
|
|
34
|
+
// but we currently support React >=17.x
|
|
35
|
+
// https://github.com/facebook/react/pull/26395
|
|
29
36
|
const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
|
|
30
|
-
var useLayoutEffect = useLayoutEffectImpl;
|
|
31
37
|
|
|
32
38
|
/**
|
|
33
39
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -36,15 +42,17 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
36
42
|
* LICENSE file in the root directory of this source tree.
|
|
37
43
|
*
|
|
38
44
|
*/
|
|
45
|
+
|
|
39
46
|
/**
|
|
40
47
|
* Shortcut to Lexical subscriptions when values are used for render.
|
|
48
|
+
* @param subscription - The function to create the {@link LexicalSubscription}. This function's identity must be stable (e.g. defined at module scope or with useCallback).
|
|
41
49
|
*/
|
|
42
50
|
function useLexicalSubscription(subscription) {
|
|
43
51
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
44
52
|
const initializedSubscription = react.useMemo(() => subscription(editor), [editor, subscription]);
|
|
45
53
|
const valueRef = react.useRef(initializedSubscription.initialValueFn());
|
|
46
54
|
const [value, setValue] = react.useState(valueRef.current);
|
|
47
|
-
|
|
55
|
+
useLayoutEffectImpl(() => {
|
|
48
56
|
const {
|
|
49
57
|
initialValueFn,
|
|
50
58
|
subscribe
|
|
@@ -69,6 +77,7 @@ function useLexicalSubscription(subscription) {
|
|
|
69
77
|
* LICENSE file in the root directory of this source tree.
|
|
70
78
|
*
|
|
71
79
|
*/
|
|
80
|
+
|
|
72
81
|
function subscription(editor) {
|
|
73
82
|
return {
|
|
74
83
|
initialValueFn: () => editor.isEditable(),
|
|
@@ -77,8 +86,18 @@ function subscription(editor) {
|
|
|
77
86
|
}
|
|
78
87
|
};
|
|
79
88
|
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get the current value for {@link LexicalEditor.isEditable}
|
|
92
|
+
* using {@link useLexicalSubscription}.
|
|
93
|
+
* You should prefer this over manually observing the value with
|
|
94
|
+
* {@link LexicalEditor.registerEditableListener},
|
|
95
|
+
* which is a bit tricky to do correctly, particularly when using
|
|
96
|
+
* React StrictMode (the default for development) or concurrency.
|
|
97
|
+
*/
|
|
80
98
|
function useLexicalEditable() {
|
|
81
99
|
return useLexicalSubscription(subscription);
|
|
82
100
|
}
|
|
83
101
|
|
|
84
|
-
|
|
102
|
+
exports.default = useLexicalEditable;
|
|
103
|
+
exports.useLexicalEditable = useLexicalEditable;
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
8
|
-
import { useLayoutEffect
|
|
10
|
+
import { useLayoutEffect, useEffect, useMemo, useRef, useState } from 'react';
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -24,8 +26,12 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
24
26
|
* LICENSE file in the root directory of this source tree.
|
|
25
27
|
*
|
|
26
28
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// This workaround is no longer necessary in React 19,
|
|
32
|
+
// but we currently support React >=17.x
|
|
33
|
+
// https://github.com/facebook/react/pull/26395
|
|
34
|
+
const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
|
|
29
35
|
|
|
30
36
|
/**
|
|
31
37
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -34,15 +40,17 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
34
40
|
* LICENSE file in the root directory of this source tree.
|
|
35
41
|
*
|
|
36
42
|
*/
|
|
43
|
+
|
|
37
44
|
/**
|
|
38
45
|
* Shortcut to Lexical subscriptions when values are used for render.
|
|
46
|
+
* @param subscription - The function to create the {@link LexicalSubscription}. This function's identity must be stable (e.g. defined at module scope or with useCallback).
|
|
39
47
|
*/
|
|
40
48
|
function useLexicalSubscription(subscription) {
|
|
41
49
|
const [editor] = useLexicalComposerContext();
|
|
42
50
|
const initializedSubscription = useMemo(() => subscription(editor), [editor, subscription]);
|
|
43
51
|
const valueRef = useRef(initializedSubscription.initialValueFn());
|
|
44
52
|
const [value, setValue] = useState(valueRef.current);
|
|
45
|
-
|
|
53
|
+
useLayoutEffectImpl(() => {
|
|
46
54
|
const {
|
|
47
55
|
initialValueFn,
|
|
48
56
|
subscribe
|
|
@@ -67,6 +75,7 @@ function useLexicalSubscription(subscription) {
|
|
|
67
75
|
* LICENSE file in the root directory of this source tree.
|
|
68
76
|
*
|
|
69
77
|
*/
|
|
78
|
+
|
|
70
79
|
function subscription(editor) {
|
|
71
80
|
return {
|
|
72
81
|
initialValueFn: () => editor.isEditable(),
|
|
@@ -75,8 +84,17 @@ function subscription(editor) {
|
|
|
75
84
|
}
|
|
76
85
|
};
|
|
77
86
|
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get the current value for {@link LexicalEditor.isEditable}
|
|
90
|
+
* using {@link useLexicalSubscription}.
|
|
91
|
+
* You should prefer this over manually observing the value with
|
|
92
|
+
* {@link LexicalEditor.registerEditableListener},
|
|
93
|
+
* which is a bit tricky to do correctly, particularly when using
|
|
94
|
+
* React StrictMode (the default for development) or concurrency.
|
|
95
|
+
*/
|
|
78
96
|
function useLexicalEditable() {
|
|
79
97
|
return useLexicalSubscription(subscription);
|
|
80
98
|
}
|
|
81
99
|
|
|
82
|
-
export { useLexicalEditable as default };
|
|
100
|
+
export { useLexicalEditable as default, useLexicalEditable };
|
package/useLexicalEditable.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict'
|
|
8
10
|
const useLexicalEditable = process.env.NODE_ENV === 'development' ? require('./useLexicalEditable.dev.js') : require('./useLexicalEditable.prod.js');
|
|
9
11
|
module.exports = useLexicalEditable;
|
|
@@ -9,4 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import type {LexicalEditor} from 'lexical';
|
|
11
11
|
|
|
12
|
-
declare export
|
|
12
|
+
declare export function useLexicalEditable(): boolean;
|
|
13
|
+
|
|
14
|
+
/** @deprecated use the named export {@link useLexicalEditable} */
|
|
15
|
+
declare export default typeof useLexicalEditable;
|
package/useLexicalEditable.mjs
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import * as modDev from './useLexicalEditable.dev.mjs';
|
|
8
10
|
import * as modProd from './useLexicalEditable.prod.mjs';
|
|
9
11
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
|
-
export default mod.default;
|
|
12
|
+
export default mod.default;
|
|
13
|
+
export const useLexicalEditable = mod.useLexicalEditable;
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
const mod = await (process.env.NODE_ENV === 'development' ? import('./useLexicalEditable.dev.mjs') : import('./useLexicalEditable.prod.mjs'));
|
|
8
|
-
export default mod.default;
|
|
10
|
+
export default mod.default;
|
|
11
|
+
export const useLexicalEditable = mod.useLexicalEditable;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
'use strict';var b=require("@lexical/react/LexicalComposerContext"),k=require("react");let l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?k.useLayoutEffect:k.useEffect;
|
|
10
|
+
function m(a){let [c]=b.useLexicalComposerContext(),e=k.useMemo(()=>a(c),[c,a]),d=k.useRef(e.initialValueFn()),[p,g]=k.useState(d.current);l(()=>{let {initialValueFn:q,subscribe:r}=e,f=q();d.current!==f&&(d.current=f,g(f));return r(h=>{d.current=h;g(h)})},[e,a]);return p}function n(a){return{initialValueFn:()=>a.isEditable(),subscribe:c=>a.registerEditableListener(c)}}function t(){return m(n)}exports.default=t;exports.useLexicalEditable=t
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useLayoutEffect as t,useEffect as n,useMemo as r,useRef as i,useState as o}from"react";const u="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:n;function c(e){return{initialValueFn:()=>e.isEditable(),subscribe:t=>e.registerEditableListener(t)}}function a(){return function(t){const[n]=e(),c=r((()=>t(n)),[n,t]),a=i(c.initialValueFn()),[l,d]=o(a.current);return u((()=>{const{initialValueFn:e,subscribe:t}=c,n=e();return a.current!==n&&(a.current=n,d(n)),t((e=>{a.current=e,d(e)}))}),[c,t]),l}(c)}export{a as default,a as useLexicalEditable};
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';
|
|
8
10
|
|
|
9
11
|
var text = require('@lexical/text');
|
|
@@ -26,8 +28,12 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
26
28
|
* LICENSE file in the root directory of this source tree.
|
|
27
29
|
*
|
|
28
30
|
*/
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// This workaround is no longer necessary in React 19,
|
|
34
|
+
// but we currently support React >=17.x
|
|
35
|
+
// https://github.com/facebook/react/pull/26395
|
|
29
36
|
const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
|
|
30
|
-
var useLayoutEffect = useLayoutEffectImpl;
|
|
31
37
|
|
|
32
38
|
/**
|
|
33
39
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -36,9 +42,10 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
36
42
|
* LICENSE file in the root directory of this source tree.
|
|
37
43
|
*
|
|
38
44
|
*/
|
|
45
|
+
|
|
39
46
|
function useLexicalIsTextContentEmpty(editor, trim) {
|
|
40
47
|
const [isEmpty, setIsEmpty] = react.useState(editor.getEditorState().read(text.$isRootTextContentEmptyCurry(editor.isComposing(), trim)));
|
|
41
|
-
|
|
48
|
+
useLayoutEffectImpl(() => {
|
|
42
49
|
return editor.registerUpdateListener(({
|
|
43
50
|
editorState
|
|
44
51
|
}) => {
|