@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,13 +3,29 @@
|
|
|
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');
|
|
10
12
|
var utils = require('@lexical/utils');
|
|
11
13
|
var lexical = require('lexical');
|
|
12
14
|
var React = require('react');
|
|
15
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
16
|
+
|
|
17
|
+
function _interopNamespaceDefault(e) {
|
|
18
|
+
var n = Object.create(null);
|
|
19
|
+
if (e) {
|
|
20
|
+
for (var k in e) {
|
|
21
|
+
n[k] = e[k];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
n.default = e;
|
|
25
|
+
return n;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
13
29
|
|
|
14
30
|
/**
|
|
15
31
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -28,8 +44,12 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
28
44
|
* LICENSE file in the root directory of this source tree.
|
|
29
45
|
*
|
|
30
46
|
*/
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// This workaround is no longer necessary in React 19,
|
|
50
|
+
// but we currently support React >=17.x
|
|
51
|
+
// https://github.com/facebook/react/pull/26395
|
|
31
52
|
const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
|
|
32
|
-
var useLayoutEffect = useLayoutEffectImpl;
|
|
33
53
|
|
|
34
54
|
/**
|
|
35
55
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -38,6 +58,7 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
38
58
|
* LICENSE file in the root directory of this source tree.
|
|
39
59
|
*
|
|
40
60
|
*/
|
|
61
|
+
|
|
41
62
|
class MenuOption {
|
|
42
63
|
constructor(key) {
|
|
43
64
|
this.key = key;
|
|
@@ -125,7 +146,7 @@ function $splitNodeContainingQuery(match) {
|
|
|
125
146
|
function getScrollParent(element, includeHidden) {
|
|
126
147
|
let style = getComputedStyle(element);
|
|
127
148
|
const excludeStaticParent = style.position === 'absolute';
|
|
128
|
-
const overflowRegex =
|
|
149
|
+
const overflowRegex = /(auto|scroll)/;
|
|
129
150
|
if (style.position === 'fixed') {
|
|
130
151
|
return document.body;
|
|
131
152
|
}
|
|
@@ -152,7 +173,7 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
|
|
|
152
173
|
React.useEffect(() => {
|
|
153
174
|
if (targetElement != null && resolution != null) {
|
|
154
175
|
const rootElement = editor.getRootElement();
|
|
155
|
-
const rootScrollParent = rootElement != null ? getScrollParent(rootElement
|
|
176
|
+
const rootScrollParent = rootElement != null ? getScrollParent(rootElement) : document.body;
|
|
156
177
|
let ticking = false;
|
|
157
178
|
let previousIsInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent);
|
|
158
179
|
const handleScroll = function () {
|
|
@@ -224,7 +245,7 @@ function LexicalMenu({
|
|
|
224
245
|
}
|
|
225
246
|
};
|
|
226
247
|
}, [editor]);
|
|
227
|
-
|
|
248
|
+
useLayoutEffectImpl(() => {
|
|
228
249
|
if (options === null) {
|
|
229
250
|
setHighlightedIndex(null);
|
|
230
251
|
} else if (selectedIndex === null) {
|
|
@@ -336,7 +357,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
336
357
|
if (left + menuWidth > rootElementRect.right) {
|
|
337
358
|
containerDiv.style.left = `${rootElementRect.right - menuWidth + window.pageXOffset}px`;
|
|
338
359
|
}
|
|
339
|
-
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight) {
|
|
360
|
+
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight + height) {
|
|
340
361
|
containerDiv.style.top = `${top - menuHeight + window.pageYOffset - height}px`;
|
|
341
362
|
}
|
|
342
363
|
}
|
|
@@ -388,6 +409,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
388
409
|
* LICENSE file in the root directory of this source tree.
|
|
389
410
|
*
|
|
390
411
|
*/
|
|
412
|
+
|
|
391
413
|
const PRE_PORTAL_DIV_SIZE = 1;
|
|
392
414
|
function LexicalContextMenuPlugin({
|
|
393
415
|
options,
|
|
@@ -402,7 +424,7 @@ function LexicalContextMenuPlugin({
|
|
|
402
424
|
}) {
|
|
403
425
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
404
426
|
const [resolution, setResolution] = React.useState(null);
|
|
405
|
-
const menuRef =
|
|
427
|
+
const menuRef = React__namespace.useRef(null);
|
|
406
428
|
const anchorElementRef = useMenuAnchorRef(resolution, setResolution, anchorClassName, parent);
|
|
407
429
|
const closeNodeMenu = React.useCallback(() => {
|
|
408
430
|
setResolution(null);
|
|
@@ -442,7 +464,7 @@ function LexicalContextMenuPlugin({
|
|
|
442
464
|
document.addEventListener('click', handleClick);
|
|
443
465
|
return () => document.removeEventListener('click', handleClick);
|
|
444
466
|
}, [editor, handleClick]);
|
|
445
|
-
return resolution === null || editor === null ? null : /*#__PURE__*/
|
|
467
|
+
return resolution === null || editor === null ? null : /*#__PURE__*/jsxRuntime.jsx(LexicalMenu, {
|
|
446
468
|
close: closeNodeMenu,
|
|
447
469
|
resolution: resolution,
|
|
448
470
|
editor: editor,
|
|
@@ -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 { mergeRegister, calculateZoomLevel } from '@lexical/utils';
|
|
9
11
|
import { createCommand, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW, $getSelection, $isRangeSelection } from 'lexical';
|
|
10
12
|
import * as React from 'react';
|
|
11
|
-
import { useLayoutEffect
|
|
13
|
+
import { useLayoutEffect, useEffect, useState, useCallback, useMemo, useRef } from 'react';
|
|
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(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(rootElement
|
|
162
|
+
const rootScrollParent = rootElement != null ? getScrollParent(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 PRE_PORTAL_DIV_SIZE = 1;
|
|
391
400
|
function LexicalContextMenuPlugin({
|
|
392
401
|
options,
|
|
@@ -441,7 +450,7 @@ function LexicalContextMenuPlugin({
|
|
|
441
450
|
document.addEventListener('click', handleClick);
|
|
442
451
|
return () => document.removeEventListener('click', handleClick);
|
|
443
452
|
}, [editor, handleClick]);
|
|
444
|
-
return resolution === null || editor === null ? null : /*#__PURE__*/
|
|
453
|
+
return resolution === null || editor === null ? null : /*#__PURE__*/jsx(LexicalMenu, {
|
|
445
454
|
close: closeNodeMenu,
|
|
446
455
|
resolution: resolution,
|
|
447
456
|
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 LexicalContextMenuPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalContextMenuPlugin.dev.js') : require('./LexicalContextMenuPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalContextMenuPlugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* LexicalContextMenuPlugin
|
|
12
|
+
*/
|
|
@@ -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 './LexicalContextMenuPlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalContextMenuPlugin.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('./LexicalContextMenuPlugin.dev.mjs') : import('./LexicalContextMenuPlugin.prod.mjs'));
|
|
8
10
|
export const LexicalContextMenuPlugin = mod.LexicalContextMenuPlugin;
|
|
9
11
|
export const MenuOption = mod.MenuOption;
|
|
@@ -3,20 +3,22 @@
|
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
g=
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
|
|
9
|
+
'use strict';var g=require("@lexical/react/LexicalComposerContext"),w=require("@lexical/utils"),z=require("lexical"),A=require("react"),B=require("react/jsx-runtime"),C=Object.create(null);if(A)for(var D in A)C[D]=A[D];C.default=A;let E="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?A.useLayoutEffect:A.useEffect;
|
|
10
|
+
class F{constructor(c){this.key=c;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(c){this.ref={current:c}}}let G=c=>{const a=document.getElementById("typeahead-menu");if(a){var f=a.getBoundingClientRect();f.top+f.height>window.innerHeight&&a.scrollIntoView({block:"center"});0>f.top&&a.scrollIntoView({block:"center"});c.scrollIntoView({block:"nearest"})}};
|
|
11
|
+
function H(c){var a=z.$getSelection();if(!z.$isRangeSelection(a)||!a.isCollapsed())return null;var f=a.anchor;if("text"!==f.type)return null;a=f.getNode();if(!a.isSimpleText())return null;f=f.offset;let k=a.getTextContent().slice(0,f);var d=c.matchingString;c=c.replaceableString.length;for(let n=c;n<=d.length;n++)k.substr(-n)===d.substr(0,n)&&(c=n);c=f-c;if(0>c)return null;let p;0===c?[p]=a.splitText(f):[,p]=a.splitText(c,f);return p}
|
|
12
|
+
function I(c){let a=getComputedStyle(c),f="absolute"===a.position,k=/(auto|scroll)/;if("fixed"===a.position)return document.body;for(;c=c.parentElement;)if(a=getComputedStyle(c),(!f||"static"!==a.position)&&k.test(a.overflow+a.overflowY+a.overflowX))return c;return document.body}function J(c,a){c=c.getBoundingClientRect();a=a.getBoundingClientRect();return c.top>a.top&&c.top<a.bottom}
|
|
13
|
+
function K(c,a,f,k){let [d]=g.useLexicalComposerContext();A.useEffect(()=>{if(null!=a&&null!=c){let p=d.getRootElement(),n=null!=p?I(p):document.body,x=!1,m=J(a,n),b=function(){x||(window.requestAnimationFrame(function(){f();x=!1}),x=!0);const q=J(a,n);q!==m&&(m=q,null!=k&&k(q))},h=new ResizeObserver(f);window.addEventListener("resize",f);document.addEventListener("scroll",b,{capture:!0,passive:!0});h.observe(a);return()=>{h.unobserve(a);window.removeEventListener("resize",f);document.removeEventListener("scroll",
|
|
14
|
+
b,!0)}}},[a,d,k,f,c])}let L=z.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
|
|
15
|
+
function M({close:c,editor:a,anchorElementRef:f,resolution:k,options:d,menuRenderFn:p,onSelectOption:n,shouldSplitNodeWithQuery:x=!1,commandPriority:m=z.COMMAND_PRIORITY_LOW}){let [b,h]=A.useState(null);A.useEffect(()=>{h(0)},[k.match&&k.match.matchingString]);let q=A.useCallback(e=>{a.update(()=>{const l=null!=k.match&&x?H(k.match):null;n(e,l,c,k.match?k.match.matchingString:"")})},[a,x,k.match,n,c]),t=A.useCallback(e=>{const l=a.getRootElement();null!==l&&(l.setAttribute("aria-activedescendant",
|
|
16
|
+
"typeahead-item-"+e),h(e))},[a]);A.useEffect(()=>()=>{let e=a.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")},[a]);E(()=>{null===d?h(null):null===b&&t(0)},[d,b,t]);A.useEffect(()=>w.mergeRegister(a.registerCommand(L,({option:e})=>e.ref&&null!=e.ref.current?(G(e.ref.current),!0):!1,m)),[a,t,m]);A.useEffect(()=>w.mergeRegister(a.registerCommand(z.KEY_ARROW_DOWN_COMMAND,e=>{if(null!==d&&d.length&&null!==b){let l=b!==d.length-1?b+1:0;t(l);let u=d[l];null!=u.ref&&u.ref.current&&
|
|
17
|
+
a.dispatchCommand(L,{index:l,option:u});e.preventDefault();e.stopImmediatePropagation()}return!0},m),a.registerCommand(z.KEY_ARROW_UP_COMMAND,e=>{if(null!==d&&d.length&&null!==b){var l=0!==b?b-1:d.length-1;t(l);l=d[l];null!=l.ref&&l.ref.current&&G(l.ref.current);e.preventDefault();e.stopImmediatePropagation()}return!0},m),a.registerCommand(z.KEY_ESCAPE_COMMAND,e=>{e.preventDefault();e.stopImmediatePropagation();c();return!0},m),a.registerCommand(z.KEY_TAB_COMMAND,e=>{if(null===d||null===b||null==
|
|
18
|
+
d[b])return!1;e.preventDefault();e.stopImmediatePropagation();q(d[b]);return!0},m),a.registerCommand(z.KEY_ENTER_COMMAND,e=>{if(null===d||null===b||null==d[b])return!1;null!==e&&(e.preventDefault(),e.stopImmediatePropagation());q(d[b]);return!0},m)),[q,c,a,d,b,t,m]);let v=A.useMemo(()=>({options:d,selectOptionAndCleanUp:q,selectedIndex:b,setHighlightedIndex:h}),[q,b,d]);return p(f,v,k.match?k.match.matchingString:"")}
|
|
19
|
+
function N(c,a,f,k=document.body){let [d]=g.useLexicalComposerContext(),p=A.useRef(document.createElement("div")),n=A.useCallback(()=>{p.current.style.top=p.current.style.bottom;const m=d.getRootElement(),b=p.current;var h=b.firstChild;if(null!==m&&null!==c){const {left:t,top:v,width:e,height:l}=c.getRect();b.style.top=`${v+window.pageYOffset+p.current.offsetHeight+3}px`;b.style.left=`${t+window.pageXOffset}px`;b.style.height=`${l}px`;b.style.width=`${e}px`;if(null!==h){h.style.top=`${v}`;var q=h.getBoundingClientRect();
|
|
20
|
+
h=q.height;q=q.width;const u=m.getBoundingClientRect();t+q>u.right&&(b.style.left=`${u.right-q+window.pageXOffset}px`);(v+h>window.innerHeight||v+h>u.bottom)&&v-u.top>h+l&&(b.style.top=`${v-h+window.pageYOffset-l}px`)}b.isConnected||(null!=f&&(b.className=f),b.setAttribute("aria-label","Typeahead menu"),b.setAttribute("id","typeahead-menu"),b.setAttribute("role","listbox"),b.style.display="block",b.style.position="absolute",k.append(b));p.current=b;m.setAttribute("aria-controls","typeahead-menu")}},
|
|
21
|
+
[d,c,f,k]);A.useEffect(()=>{let m=d.getRootElement();if(null!==c)return n(),()=>{null!==m&&m.removeAttribute("aria-controls");let b=p.current;null!==b&&b.isConnected&&b.remove()}},[d,n,c]);let x=A.useCallback(m=>{null!==c&&(m||a(null))},[c,a]);K(c,p.current,n,x);return p}
|
|
22
|
+
exports.LexicalContextMenuPlugin=function({options:c,onWillOpen:a,onClose:f,onOpen:k,onSelectOption:d,menuRenderFn:p,anchorClassName:n,commandPriority:x=z.COMMAND_PRIORITY_LOW,parent:m}){let [b]=g.useLexicalComposerContext(),[h,q]=A.useState(null),t=C.useRef(null);n=N(h,q,n,m);let v=A.useCallback(()=>{q(null);null!=f&&null!==h&&f()},[f,h]),e=A.useCallback(r=>{q(r);null!=k&&null===h&&k(r)},[k,h]),l=A.useCallback(r=>{r.preventDefault();null!=a&&a(r);const y=w.calculateZoomLevel(r.target);e({getRect:()=>
|
|
23
|
+
new DOMRect(r.clientX/y,r.clientY/y,1,1)})},[e,a]),u=A.useCallback(r=>{null===h||null==t.current||null==r.target||t.current.contains(r.target)||v()},[v,h]);A.useEffect(()=>{let r=b.getRootElement();if(r)return r.addEventListener("contextmenu",l),()=>r.removeEventListener("contextmenu",l)},[b,l]);A.useEffect(()=>{document.addEventListener("click",u);return()=>document.removeEventListener("click",u)},[b,u]);return null===h||null===b?null:B.jsx(M,{close:v,resolution:h,editor:b,anchorElementRef:n,options:c,
|
|
24
|
+
menuRenderFn:(r,y)=>p(r,y,{setMenuRef:O=>{t.current=O}}),onSelectOption:d,commandPriority:x})};exports.MenuOption=F
|
|
@@ -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{mergeRegister as e,calculateZoomLevel as n}from"@lexical/utils";import{createCommand as o,KEY_ARROW_DOWN_COMMAND as l,KEY_ARROW_UP_COMMAND as r,KEY_ESCAPE_COMMAND as i,KEY_TAB_COMMAND as u,KEY_ENTER_COMMAND as c,COMMAND_PRIORITY_LOW as s,$getSelection as a,$isRangeSelection as m}from"lexical";import*as d from"react";import{useLayoutEffect as p,useEffect as f,useState as g,useCallback as h,useMemo as w,useRef as v}from"react";import{jsx as y}from"react/jsx-runtime";const b="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?p:f;class C{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const E=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 R(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>o.top&&n.top<o.bottom}function x(e,n,o,l){const[r]=t();f((()=>{if(null!=n&&null!=e){const t=r.getRootElement(),e=null!=t?function(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,l=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&l.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t):document.body;let i=!1,u=R(n,e);const c=function(){i||(window.requestAnimationFrame((function(){o(),i=!1})),i=!0);const t=R(n,e);t!==u&&(u=t,null!=l&&l(t))},s=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",c,{capture:!0,passive:!0}),s.observe(n),()=>{s.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",c,!0)}}}),[n,r,l,o,e])}const O=o("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function I({close:t,editor:n,anchorElementRef:o,resolution:d,options:p,menuRenderFn:v,onSelectOption:y,shouldSplitNodeWithQuery:C=!1,commandPriority:R=s}){const[x,I]=g(null),S=d.match&&d.match.matchingString;f((()=>{I(0)}),[S]);const A=h((e=>{n.update((()=>{const n=null!=d.match&&C?function(t){const e=a();if(!m(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 l=n.offset,r=o.getTextContent().slice(0,l),i=t.replaceableString.length,u=l-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}(r,t.matchingString,i);if(u<0)return null;let c;return 0===u?[c]=o.splitText(l):[,c]=o.splitText(u,l),c}(d.match):null;y(e,n,t,d.match?d.match.matchingString:"")}))}),[n,C,d.match,y,t]),L=h((t=>{const e=n.getRootElement();null!==e&&(e.setAttribute("aria-activedescendant","typeahead-item-"+t),I(t))}),[n]);f((()=>()=>{const t=n.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[n]),b((()=>{null===p?I(null):null===x&&L(0)}),[p,x,L]),f((()=>e(n.registerCommand(O,(({option:t})=>!(!t.ref||null==t.ref.current)&&(E(t.ref.current),!0)),R))),[n,L,R]),f((()=>e(n.registerCommand(l,(t=>{const e=t;if(null!==p&&p.length&&null!==x){const t=x!==p.length-1?x+1:0;L(t);const o=p[t];null!=o.ref&&o.ref.current&&n.dispatchCommand(O,{index:t,option:o}),e.preventDefault(),e.stopImmediatePropagation()}return!0}),R),n.registerCommand(r,(t=>{const e=t;if(null!==p&&p.length&&null!==x){const t=0!==x?x-1:p.length-1;L(t);const n=p[t];null!=n.ref&&n.ref.current&&E(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),R),n.registerCommand(i,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),R),n.registerCommand(u,(t=>{const e=t;return null!==p&&null!==x&&null!=p[x]&&(e.preventDefault(),e.stopImmediatePropagation(),A(p[x]),!0)}),R),n.registerCommand(c,(t=>null!==p&&null!==x&&null!=p[x]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),A(p[x]),!0)),R))),[A,t,n,p,x,L,R]);return v(o,w((()=>({options:p,selectOptionAndCleanUp:A,selectedIndex:x,setHighlightedIndex:I})),[A,x,p]),d.match?d.match.matchingString:"")}function S({options:e,onWillOpen:o,onClose:l,onOpen:r,onSelectOption:i,menuRenderFn:u,anchorClassName:c,commandPriority:a=s,parent:m}){const[p]=t(),[w,b]=g(null),C=d.useRef(null),E=function(e,n,o,l=document.body){const[r]=t(),i=v(document.createElement("div")),u=h((()=>{i.current.style.top=i.current.style.bottom;const t=r.getRootElement(),n=i.current,u=n.firstChild;if(null!==t&&null!==e){const{left:r,top:c,width:s,height:a}=e.getRect(),m=i.current.offsetHeight;if(n.style.top=`${c+window.pageYOffset+m+3}px`,n.style.left=`${r+window.pageXOffset}px`,n.style.height=`${a}px`,n.style.width=`${s}px`,null!==u){u.style.top=`${c}`;const e=u.getBoundingClientRect(),o=e.height,l=e.width,i=t.getBoundingClientRect();r+l>i.right&&(n.style.left=`${i.right-l+window.pageXOffset}px`),(c+o>window.innerHeight||c+o>i.bottom)&&c-i.top>o+a&&(n.style.top=c-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",l.append(n)),i.current=n,t.setAttribute("aria-controls","typeahead-menu")}}),[r,e,o,l]);f((()=>{const t=r.getRootElement();if(null!==e)return u(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=i.current;null!==e&&e.isConnected&&e.remove()}}),[r,u,e]);const c=h((t=>{null!==e&&(t||n(null))}),[e,n]);return x(e,i.current,u,c),i}(w,b,c,m),R=h((()=>{b(null),null!=l&&null!==w&&l()}),[l,w]),O=h((t=>{b(t),null!=r&&null===w&&r(t)}),[r,w]),S=h((t=>{t.preventDefault(),null!=o&&o(t);const e=n(t.target);O({getRect:()=>new DOMRect(t.clientX/e,t.clientY/e,1,1)})}),[O,o]),A=h((t=>{null===w||null==C.current||null==t.target||C.current.contains(t.target)||R()}),[R,w]);return f((()=>{const t=p.getRootElement();if(t)return t.addEventListener("contextmenu",S),()=>t.removeEventListener("contextmenu",S)}),[p,S]),f((()=>(document.addEventListener("click",A),()=>document.removeEventListener("click",A))),[p,A]),null===w||null===p?null:y(I,{close:R,resolution:w,editor:p,anchorElementRef:E,options:e,menuRenderFn:(t,e)=>u(t,e,{setMenuRef:t=>{C.current=t}}),onSelectOption:i,commandPriority:a})}export{S as LexicalContextMenuPlugin,C as MenuOption};
|
|
@@ -15,6 +15,7 @@ export declare class DecoratorBlockNode extends DecoratorNode<JSX.Element> {
|
|
|
15
15
|
__format: ElementFormatType;
|
|
16
16
|
constructor(format?: ElementFormatType, key?: NodeKey);
|
|
17
17
|
exportJSON(): SerializedDecoratorBlockNode;
|
|
18
|
+
canIndent(): false;
|
|
18
19
|
createDOM(): HTMLElement;
|
|
19
20
|
updateDOM(): false;
|
|
20
21
|
setFormat(format: ElementFormatType): void;
|
|
@@ -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 lexical = require('lexical');
|
|
@@ -15,6 +17,7 @@ var lexical = require('lexical');
|
|
|
15
17
|
* LICENSE file in the root directory of this source tree.
|
|
16
18
|
*
|
|
17
19
|
*/
|
|
20
|
+
|
|
18
21
|
class DecoratorBlockNode extends lexical.DecoratorNode {
|
|
19
22
|
constructor(format, key) {
|
|
20
23
|
super(key);
|
|
@@ -27,6 +30,9 @@ class DecoratorBlockNode extends lexical.DecoratorNode {
|
|
|
27
30
|
version: 1
|
|
28
31
|
};
|
|
29
32
|
}
|
|
33
|
+
canIndent() {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
30
36
|
createDOM() {
|
|
31
37
|
return document.createElement('div');
|
|
32
38
|
}
|
|
@@ -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 { DecoratorNode } from 'lexical';
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -13,6 +15,7 @@ import { DecoratorNode } from 'lexical';
|
|
|
13
15
|
* LICENSE file in the root directory of this source tree.
|
|
14
16
|
*
|
|
15
17
|
*/
|
|
18
|
+
|
|
16
19
|
class DecoratorBlockNode extends DecoratorNode {
|
|
17
20
|
constructor(format, key) {
|
|
18
21
|
super(key);
|
|
@@ -25,6 +28,9 @@ class DecoratorBlockNode extends DecoratorNode {
|
|
|
25
28
|
version: 1
|
|
26
29
|
};
|
|
27
30
|
}
|
|
31
|
+
canIndent() {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
28
34
|
createDOM() {
|
|
29
35
|
return document.createElement('div');
|
|
30
36
|
}
|
|
@@ -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 LexicalDecoratorBlockNode = process.env.NODE_ENV === 'development' ? require('./LexicalDecoratorBlockNode.dev.js') : require('./LexicalDecoratorBlockNode.prod.js');
|
|
9
11
|
module.exports = LexicalDecoratorBlockNode;
|
|
@@ -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 './LexicalDecoratorBlockNode.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalDecoratorBlockNode.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('./LexicalDecoratorBlockNode.dev.mjs') : import('./LexicalDecoratorBlockNode.prod.mjs'));
|
|
8
10
|
export const $isDecoratorBlockNode = mod.$isDecoratorBlockNode;
|
|
9
11
|
export const DecoratorBlockNode = mod.DecoratorBlockNode;
|
|
@@ -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
|
+
'use strict';var b=require("lexical");class c extends b.DecoratorNode{constructor(a,d){super(d);this.__format=a||""}exportJSON(){return{format:this.__format||"",type:"decorator-block",version:1}}canIndent(){return!1}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(a){this.getWritable().__format=a}isInline(){return!1}}exports.$isDecoratorBlockNode=function(a){return a instanceof c};exports.DecoratorBlockNode=c
|
|
@@ -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{DecoratorNode as t}from"lexical";class r extends t{constructor(t,r){super(r),this.__format=t||""}exportJSON(){return{format:this.__format||"",type:"decorator-block",version:1}}canIndent(){return!1}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(t){this.getWritable().__format=t}isInline(){return!1}}function e(t){return t instanceof r}export{e as $isDecoratorBlockNode,r as DecoratorBlockNode};
|
|
@@ -3,12 +3,27 @@
|
|
|
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');
|
|
10
12
|
var React = require('react');
|
|
11
13
|
|
|
14
|
+
function _interopNamespaceDefault(e) {
|
|
15
|
+
var n = Object.create(null);
|
|
16
|
+
if (e) {
|
|
17
|
+
for (var k in e) {
|
|
18
|
+
n[k] = e[k];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return n;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
26
|
+
|
|
12
27
|
/**
|
|
13
28
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
29
|
*
|
|
@@ -17,6 +32,7 @@ var React = require('react');
|
|
|
17
32
|
*
|
|
18
33
|
*/
|
|
19
34
|
|
|
35
|
+
|
|
20
36
|
/**
|
|
21
37
|
*
|
|
22
38
|
* Use this plugin to access the editor instance outside of the
|
|
@@ -28,7 +44,7 @@ function EditorRefPlugin({
|
|
|
28
44
|
editorRef
|
|
29
45
|
}) {
|
|
30
46
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
31
|
-
|
|
47
|
+
React__namespace.useEffect(() => {
|
|
32
48
|
if (typeof editorRef === 'function') {
|
|
33
49
|
editorRef(editor);
|
|
34
50
|
} else if (typeof editorRef === 'object') {
|
|
@@ -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 { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
8
10
|
import * as React from 'react';
|
|
9
11
|
|
|
@@ -15,6 +17,7 @@ import * as React from 'react';
|
|
|
15
17
|
*
|
|
16
18
|
*/
|
|
17
19
|
|
|
20
|
+
|
|
18
21
|
/**
|
|
19
22
|
*
|
|
20
23
|
* Use this plugin to access the editor instance outside of the
|
|
@@ -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 LexicalEditorRefPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalEditorRefPlugin.dev.js') : require('./LexicalEditorRefPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalEditorRefPlugin;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type {LexicalEditor} from 'lexical';
|
|
11
|
+
// $FlowFixMe - Not able to type this with a flow extension
|
|
12
|
+
import type {TRefFor} from 'CoreTypes.flow';
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
type Props = $ReadOnly<{
|
|
16
|
+
editorRef: TRefFor<LexicalEditor>,
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
declare export function EditorRefPlugin(props: Props): null;
|
|
@@ -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 './LexicalEditorRefPlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalEditorRefPlugin.prod.mjs';
|
|
9
11
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
@@ -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
|
*/
|
|
8
|
+
|
|
7
9
|
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalEditorRefPlugin.dev.mjs') : import('./LexicalEditorRefPlugin.prod.mjs'));
|
|
8
10
|
export const EditorRefPlugin = mod.EditorRefPlugin;
|
|
@@ -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
|
+
'use strict';var a=require("@lexical/react/LexicalComposerContext"),c=require("react"),e=Object.create(null);if(c)for(var f in c)e[f]=c[f];e.default=c;exports.EditorRefPlugin=function({editorRef:b}){let [d]=a.useLexicalComposerContext();e.useEffect(()=>{"function"===typeof b?b(d):"object"===typeof b&&(b.current=d)},[d]);return null}
|
|
@@ -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
|
*/
|
|
8
|
+
|
|
7
9
|
import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import*as e from"react";function o({editorRef:o}){const[r]=t();return e.useEffect((()=>{"function"==typeof o?o(r):"object"==typeof o&&(o.current=r)}),[r]),null}export{o as EditorRefPlugin};
|
|
@@ -10,4 +10,6 @@ export type LexicalErrorBoundaryProps = {
|
|
|
10
10
|
children: JSX.Element;
|
|
11
11
|
onError: (error: Error) => void;
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export declare function LexicalErrorBoundary({ children, onError, }: LexicalErrorBoundaryProps): JSX.Element;
|
|
14
|
+
/** @deprecated use the named export {@link LexicalErrorBoundary} */
|
|
15
|
+
export default LexicalErrorBoundary;
|