@lexical/react 0.14.4 → 0.15.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 +17 -1
- package/LexicalAutoEmbedPlugin.dev.mjs +3 -0
- package/LexicalAutoEmbedPlugin.js +2 -0
- package/LexicalAutoEmbedPlugin.mjs +2 -0
- package/LexicalAutoEmbedPlugin.node.mjs +2 -0
- package/LexicalAutoEmbedPlugin.prod.js +6 -4
- package/LexicalAutoEmbedPlugin.prod.mjs +2 -0
- 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 +20 -4
- package/LexicalBlockWithAlignableContents.dev.mjs +6 -3
- 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 +2 -0
- package/LexicalCharacterLimitPlugin.dev.js +21 -4
- package/LexicalCharacterLimitPlugin.dev.mjs +7 -3
- 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 +3 -0
- package/LexicalCheckListPlugin.dev.mjs +3 -0
- package/LexicalCheckListPlugin.js +2 -0
- package/LexicalCheckListPlugin.mjs +2 -0
- package/LexicalCheckListPlugin.node.mjs +2 -0
- package/LexicalCheckListPlugin.prod.js +2 -0
- package/LexicalCheckListPlugin.prod.mjs +2 -0
- package/LexicalClearEditorPlugin.dev.js +5 -2
- package/LexicalClearEditorPlugin.dev.mjs +7 -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.dev.js +14 -13
- package/LexicalClickableLinkPlugin.dev.mjs +14 -13
- package/LexicalClickableLinkPlugin.js +2 -0
- package/LexicalClickableLinkPlugin.mjs +2 -0
- package/LexicalClickableLinkPlugin.node.mjs +2 -0
- package/LexicalClickableLinkPlugin.prod.js +5 -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 +19 -2
- package/LexicalCollaborationPlugin.dev.mjs +4 -0
- 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 +2 -0
- package/LexicalComposer.dev.js +19 -3
- package/LexicalComposer.dev.mjs +7 -4
- package/LexicalComposer.js +2 -0
- package/LexicalComposer.mjs +2 -0
- package/LexicalComposer.node.mjs +2 -0
- package/LexicalComposer.prod.js +5 -3
- 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 +18 -3
- package/LexicalContentEditable.dev.mjs +6 -4
- package/LexicalContentEditable.js +2 -0
- package/LexicalContentEditable.mjs +2 -0
- package/LexicalContentEditable.node.mjs +2 -0
- package/LexicalContentEditable.prod.js +6 -3
- package/LexicalContentEditable.prod.mjs +3 -1
- package/LexicalContextMenuPlugin.dev.js +24 -7
- package/LexicalContextMenuPlugin.dev.mjs +11 -7
- 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.dev.js +21 -5
- package/LexicalErrorBoundary.dev.mjs +3 -0
- package/LexicalErrorBoundary.js +2 -0
- package/LexicalErrorBoundary.mjs +2 -0
- package/LexicalErrorBoundary.node.mjs +2 -0
- package/LexicalErrorBoundary.prod.js +6 -4
- package/LexicalErrorBoundary.prod.mjs +2 -0
- 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.dev.js +22 -6
- package/LexicalHorizontalRuleNode.dev.mjs +8 -5
- 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 +2 -0
- 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 +17 -1
- package/LexicalNestedComposer.dev.mjs +3 -0
- 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 +25 -8
- package/LexicalNodeMenuPlugin.dev.mjs +11 -7
- 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 +5 -2
- package/LexicalOnChangePlugin.dev.mjs +7 -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 +26 -7
- package/LexicalPlainTextPlugin.dev.mjs +13 -7
- package/LexicalPlainTextPlugin.js +2 -0
- 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 +26 -7
- package/LexicalRichTextPlugin.dev.mjs +13 -7
- package/LexicalRichTextPlugin.js +2 -0
- 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 +1 -1
- package/LexicalTableOfContents.dev.js +47 -8
- package/LexicalTableOfContents.dev.mjs +48 -9
- package/LexicalTableOfContents.js +2 -0
- package/LexicalTableOfContents.mjs +2 -0
- package/LexicalTableOfContents.node.mjs +2 -0
- package/LexicalTableOfContents.prod.js +6 -4
- package/LexicalTableOfContents.prod.mjs +3 -1
- 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.dev.js +18 -2
- package/LexicalTreeView.dev.mjs +3 -0
- package/LexicalTreeView.js +2 -0
- package/LexicalTreeView.mjs +2 -0
- package/LexicalTreeView.node.mjs +2 -0
- package/LexicalTreeView.prod.js +5 -3
- package/LexicalTreeView.prod.mjs +2 -0
- package/LexicalTypeaheadMenuPlugin.dev.js +25 -8
- package/LexicalTypeaheadMenuPlugin.dev.mjs +11 -7
- 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 +20 -19
- package/shared/useCharacterLimit.d.ts +1 -1
- package/useLexicalEditable.dev.js +6 -2
- package/useLexicalEditable.dev.mjs +8 -4
- package/useLexicalEditable.js +2 -0
- package/useLexicalEditable.mjs +2 -0
- package/useLexicalEditable.node.mjs +2 -0
- package/useLexicalEditable.prod.js +3 -1
- package/useLexicalEditable.prod.mjs +3 -1
- package/useLexicalIsTextContentEmpty.dev.js +5 -2
- package/useLexicalIsTextContentEmpty.dev.mjs +7 -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.dev.js +5 -2
- package/useLexicalSubscription.dev.mjs +7 -4
- package/useLexicalSubscription.js +2 -0
- package/useLexicalSubscription.mjs +2 -0
- package/useLexicalSubscription.node.mjs +2 -0
- package/useLexicalSubscription.prod.js +3 -1
- 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
package/LexicalTreeView.prod.mjs
CHANGED
|
@@ -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{useLexicalCommandsLog as e,TreeView as t,generateContent as a}from"@lexical/devtools-core";import{mergeRegister as r}from"@lexical/utils";import*as l from"react";import{useState as i,useEffect as s}from"react";function n({treeTypeButtonClassName:n,timeTravelButtonClassName:o,timeTravelPanelSliderClassName:m,timeTravelPanelButtonClassName:c,viewClassName:d,timeTravelPanelClassName:u,editor:C}){const N=l.createRef(),[v,E]=i(C.getEditorState()),T=e(C);s((()=>r(C.registerUpdateListener((({editorState:e})=>{E(e)})),C.registerEditableListener((()=>{E(C.getEditorState())})))),[C]),s((()=>{const e=N.current;if(null!==e)return e.__lexicalEditor=C,()=>{e.__lexicalEditor=null}}),[C,N]);return l.createElement(t,{treeTypeButtonClassName:n,timeTravelButtonClassName:o,timeTravelPanelSliderClassName:m,timeTravelPanelButtonClassName:c,viewClassName:d,timeTravelPanelClassName:u,setEditorReadOnly:e=>{const t=C.getRootElement();null!=t&&(t.contentEditable=e?"false":"true")},editorState:v,setEditorState:e=>C.setEditorState(e),generateContent:async function(e){return a(C,T,e)},ref:N})}export{n as TreeView};
|
|
@@ -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');
|
|
@@ -11,6 +13,19 @@ var lexical = require('lexical');
|
|
|
11
13
|
var React = require('react');
|
|
12
14
|
var utils = require('@lexical/utils');
|
|
13
15
|
|
|
16
|
+
function _interopNamespaceDefault(e) {
|
|
17
|
+
var n = Object.create(null);
|
|
18
|
+
if (e) {
|
|
19
|
+
for (var k in e) {
|
|
20
|
+
n[k] = e[k];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return n;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
28
|
+
|
|
14
29
|
/**
|
|
15
30
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
16
31
|
*
|
|
@@ -28,8 +43,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
28
43
|
* LICENSE file in the root directory of this source tree.
|
|
29
44
|
*
|
|
30
45
|
*/
|
|
46
|
+
|
|
31
47
|
const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
|
|
32
|
-
var useLayoutEffect = useLayoutEffectImpl;
|
|
33
48
|
|
|
34
49
|
/**
|
|
35
50
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -38,6 +53,7 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
38
53
|
* LICENSE file in the root directory of this source tree.
|
|
39
54
|
*
|
|
40
55
|
*/
|
|
56
|
+
|
|
41
57
|
class MenuOption {
|
|
42
58
|
constructor(key) {
|
|
43
59
|
this.key = key;
|
|
@@ -125,7 +141,7 @@ function $splitNodeContainingQuery(match) {
|
|
|
125
141
|
function getScrollParent$1(element, includeHidden) {
|
|
126
142
|
let style = getComputedStyle(element);
|
|
127
143
|
const excludeStaticParent = style.position === 'absolute';
|
|
128
|
-
const overflowRegex =
|
|
144
|
+
const overflowRegex = /(auto|scroll)/;
|
|
129
145
|
if (style.position === 'fixed') {
|
|
130
146
|
return document.body;
|
|
131
147
|
}
|
|
@@ -152,7 +168,7 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
|
|
|
152
168
|
React.useEffect(() => {
|
|
153
169
|
if (targetElement != null && resolution != null) {
|
|
154
170
|
const rootElement = editor.getRootElement();
|
|
155
|
-
const rootScrollParent = rootElement != null ? getScrollParent$1(rootElement
|
|
171
|
+
const rootScrollParent = rootElement != null ? getScrollParent$1(rootElement) : document.body;
|
|
156
172
|
let ticking = false;
|
|
157
173
|
let previousIsInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent);
|
|
158
174
|
const handleScroll = function () {
|
|
@@ -224,7 +240,7 @@ function LexicalMenu({
|
|
|
224
240
|
}
|
|
225
241
|
};
|
|
226
242
|
}, [editor]);
|
|
227
|
-
|
|
243
|
+
useLayoutEffectImpl(() => {
|
|
228
244
|
if (options === null) {
|
|
229
245
|
setHighlightedIndex(null);
|
|
230
246
|
} else if (selectedIndex === null) {
|
|
@@ -336,7 +352,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
336
352
|
if (left + menuWidth > rootElementRect.right) {
|
|
337
353
|
containerDiv.style.left = `${rootElementRect.right - menuWidth + window.pageXOffset}px`;
|
|
338
354
|
}
|
|
339
|
-
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight) {
|
|
355
|
+
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight + height) {
|
|
340
356
|
containerDiv.style.top = `${top - menuHeight + window.pageYOffset - height}px`;
|
|
341
357
|
}
|
|
342
358
|
}
|
|
@@ -388,6 +404,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
388
404
|
* LICENSE file in the root directory of this source tree.
|
|
389
405
|
*
|
|
390
406
|
*/
|
|
407
|
+
|
|
391
408
|
const PUNCTUATION = '\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%\'"~=<>_:;';
|
|
392
409
|
function getTextUpToAnchor(selection) {
|
|
393
410
|
const anchor = selection.anchor;
|
|
@@ -447,8 +464,8 @@ function isSelectionOnEntityBoundary(editor, offset) {
|
|
|
447
464
|
});
|
|
448
465
|
}
|
|
449
466
|
function startTransition(callback) {
|
|
450
|
-
if (
|
|
451
|
-
|
|
467
|
+
if (React__namespace.startTransition) {
|
|
468
|
+
React__namespace.startTransition(callback);
|
|
452
469
|
} else {
|
|
453
470
|
callback();
|
|
454
471
|
}
|
|
@@ -554,7 +571,7 @@ function LexicalTypeaheadMenuPlugin({
|
|
|
554
571
|
removeUpdateListener();
|
|
555
572
|
};
|
|
556
573
|
}, [editor, triggerFn, onQueryChange, resolution, closeTypeahead, openTypeahead]);
|
|
557
|
-
return resolution === null || editor === null ? null : /*#__PURE__*/
|
|
574
|
+
return resolution === null || editor === null ? null : /*#__PURE__*/React__namespace.createElement(LexicalMenu, {
|
|
558
575
|
close: closeTypeahead,
|
|
559
576
|
resolution: resolution,
|
|
560
577
|
editor: editor,
|
|
@@ -3,11 +3,13 @@
|
|
|
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';
|
|
12
14
|
|
|
13
15
|
/**
|
|
@@ -27,8 +29,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
27
29
|
* LICENSE file in the root directory of this source tree.
|
|
28
30
|
*
|
|
29
31
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
|
|
33
|
+
const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
36
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -37,6 +39,7 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
37
39
|
* LICENSE file in the root directory of this source tree.
|
|
38
40
|
*
|
|
39
41
|
*/
|
|
42
|
+
|
|
40
43
|
class MenuOption {
|
|
41
44
|
constructor(key) {
|
|
42
45
|
this.key = key;
|
|
@@ -124,7 +127,7 @@ function $splitNodeContainingQuery(match) {
|
|
|
124
127
|
function getScrollParent$1(element, includeHidden) {
|
|
125
128
|
let style = getComputedStyle(element);
|
|
126
129
|
const excludeStaticParent = style.position === 'absolute';
|
|
127
|
-
const overflowRegex =
|
|
130
|
+
const overflowRegex = /(auto|scroll)/;
|
|
128
131
|
if (style.position === 'fixed') {
|
|
129
132
|
return document.body;
|
|
130
133
|
}
|
|
@@ -151,7 +154,7 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
|
|
|
151
154
|
useEffect(() => {
|
|
152
155
|
if (targetElement != null && resolution != null) {
|
|
153
156
|
const rootElement = editor.getRootElement();
|
|
154
|
-
const rootScrollParent = rootElement != null ? getScrollParent$1(rootElement
|
|
157
|
+
const rootScrollParent = rootElement != null ? getScrollParent$1(rootElement) : document.body;
|
|
155
158
|
let ticking = false;
|
|
156
159
|
let previousIsInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent);
|
|
157
160
|
const handleScroll = function () {
|
|
@@ -223,7 +226,7 @@ function LexicalMenu({
|
|
|
223
226
|
}
|
|
224
227
|
};
|
|
225
228
|
}, [editor]);
|
|
226
|
-
|
|
229
|
+
useLayoutEffectImpl(() => {
|
|
227
230
|
if (options === null) {
|
|
228
231
|
setHighlightedIndex(null);
|
|
229
232
|
} else if (selectedIndex === null) {
|
|
@@ -335,7 +338,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
335
338
|
if (left + menuWidth > rootElementRect.right) {
|
|
336
339
|
containerDiv.style.left = `${rootElementRect.right - menuWidth + window.pageXOffset}px`;
|
|
337
340
|
}
|
|
338
|
-
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight) {
|
|
341
|
+
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight + height) {
|
|
339
342
|
containerDiv.style.top = `${top - menuHeight + window.pageYOffset - height}px`;
|
|
340
343
|
}
|
|
341
344
|
}
|
|
@@ -387,6 +390,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
387
390
|
* LICENSE file in the root directory of this source tree.
|
|
388
391
|
*
|
|
389
392
|
*/
|
|
393
|
+
|
|
390
394
|
const PUNCTUATION = '\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%\'"~=<>_:;';
|
|
391
395
|
function getTextUpToAnchor(selection) {
|
|
392
396
|
const anchor = selection.anchor;
|
|
@@ -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 J(b
|
|
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=Object.create(null);if(y)for(var C in y)B[C]=y[C];B.default=y;let D="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?y.useLayoutEffect:y.useEffect;class E{constructor(b){this.key=b;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(b){this.ref={current:b}}}
|
|
10
|
+
let F=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 G(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 J(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 K(b,a){b=b.getBoundingClientRect();a=a.getBoundingClientRect();return b.top>a.top&&b.top<a.bottom}
|
|
13
|
+
function L(b,a,c,d){let [f]=k.useLexicalComposerContext();y.useEffect(()=>{if(null!=a&&null!=b){let n=f.getRootElement(),r=null!=n?J(n):document.body,v=!1,p=K(a,r),e=function(){v||(window.requestAnimationFrame(function(){c();v=!1}),v=!0);const l=K(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 M=q.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
|
|
15
|
+
function N({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?G(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]);D(()=>{null===f?h(null):null===e&&t(0)},[f,e,t]);y.useEffect(()=>z.mergeRegister(a.registerCommand(M,({option:g})=>g.ref&&null!=g.ref.current?(F(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(M,{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&&F(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 O(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]);L(b,n.current,r,v);return n}function P(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 Q(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 R(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 S(b){B.startTransition?B.startTransition(b):b()}
|
|
23
|
+
let T=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=O(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=Q(h);if(q.$isRangeSelection(H)&&H.isCollapsed()&&null!==I&&null!==A){var x=r(I,h);a(x?x.matchingString:null);null===x||R(h,x.leadOffset)||null===P(x.leadOffset,A,w)?u():S(()=>g({getRect:()=>A.getBoundingClientRect(),match:x}))}else u()})});return()=>{m()}},[h,r,a,l,u,g]);return null===l||null===h?null:B.createElement(N,{close:u,resolution:l,editor:h,anchorElementRef:v,options:b,menuRenderFn:n,shouldSplitNodeWithQuery:!0,onSelectOption:c,commandPriority:p})};
|
|
26
|
+
exports.MenuOption=E;exports.PUNCTUATION="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";exports.SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND=T;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=L
|
|
@@ -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";const C="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?m:f;class b{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const v=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 x(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 S=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function R({close:t,editor:e,anchorElementRef:a,resolution:d,options:m,menuRenderFn:w,onSelectOption:b,shouldSplitNodeWithQuery:E=!1,commandPriority:x=s}){const[R,O]=p(null),I=d.match&&d.match.matchingString;f((()=>{O(0)}),[I]);const T=g((n=>{e.update((()=>{const e=null!=d.match&&E?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;b(n,e,t,d.match?d.match.matchingString:"")}))}),[e,E,d.match,b,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]),C((()=>{null===m?O(null):null===R&&A(0)}),[m,R,A]),f((()=>y(e.registerCommand(S,(({option:t})=>!(!t.ref||null==t.ref.current)&&(v(t.ref.current),!0)),x))),[e,A,x]),f((()=>y(e.registerCommand(n,(t=>{const n=t;if(null!==m&&m.length&&null!==R){const t=R!==m.length-1?R+1:0;A(t);const o=m[t];null!=o.ref&&o.ref.current&&e.dispatchCommand(S,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0}),x),e.registerCommand(o,(t=>{const e=t;if(null!==m&&m.length&&null!==R){const t=0!==R?R-1:m.length-1;A(t);const n=m[t];null!=n.ref&&n.ref.current&&v(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),x),e.registerCommand(r,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),x),e.registerCommand(l,(t=>{const e=t;return null!==m&&null!==R&&null!=m[R]&&(e.preventDefault(),e.stopImmediatePropagation(),T(m[R]),!0)}),x),e.registerCommand(i,(t=>null!==m&&null!==R&&null!=m[R]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),T(m[R]),!0)),x))),[T,t,e,m,R,A,x]);return w(a,h((()=>({options:m,selectOptionAndCleanUp:T,selectedIndex:R,setHighlightedIndex:O})),[T,R,m]),d.match?d.match.matchingString:"")}const O="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";function I(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 T=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function A(t,{minLength:e=1,maxLength:n=75}){return g((o=>{const r=new RegExp("(^|\\s|\\()(["+t+"]((?:"+("[^"+t+O+"\\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 N({options:e,onQueryChange:n,onSelectOption:o,onOpen:r,onClose:l,menuRenderFn:i,triggerFn:m,anchorClassName:h,commandPriority:y=s,parent:C}){const[b]=t(),[v,E]=p(null),S=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 x(e,i.current,s,u),i}(v,E,h,C),O=g((()=>{E(null),null!=l&&null!==v&&l()}),[l,v]),I=g((t=>{E(t),null!=r&&null===v&&r(t)}),[r,v]);return f((()=>{const t=b.registerUpdateListener((()=>{b.getEditorState().read((()=>{const t=b._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}(b);if(!c(o)||!o.isCollapsed()||null===r||null===e)return void O();const l=m(r,b);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}))}(b,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=()=>I({getRect:()=>e.getBoundingClientRect(),match:l}),void(d.startTransition?d.startTransition(i):i())}var i;O()}))}));return()=>{t()}}),[b,m,n,v,O,I]),null===v||null===b?null:d.createElement(R,{close:O,resolution:v,editor:b,anchorElementRef:S,options:e,menuRenderFn:i,shouldSplitNodeWithQuery:!0,onSelectOption:o,commandPriority:y})}export{N as LexicalTypeaheadMenuPlugin,b as MenuOption,O as PUNCTUATION,T as SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,I as getScrollParent,A as useBasicTypeaheadTriggerMatch,x as useDynamicPositioning};
|
package/package.json
CHANGED
|
@@ -8,26 +8,27 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.15.0",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@lexical/clipboard": "0.
|
|
14
|
-
"@lexical/code": "0.
|
|
15
|
-
"@lexical/
|
|
16
|
-
"@lexical/
|
|
17
|
-
"@lexical/
|
|
18
|
-
"@lexical/
|
|
19
|
-
"@lexical/
|
|
20
|
-
"@lexical/
|
|
21
|
-
"@lexical/
|
|
22
|
-
"@lexical/
|
|
23
|
-
"@lexical/
|
|
24
|
-
"@lexical/
|
|
25
|
-
"@lexical/
|
|
26
|
-
"@lexical/
|
|
27
|
-
"@lexical/
|
|
28
|
-
"@lexical/
|
|
29
|
-
"@lexical/
|
|
30
|
-
"lexical": "0.
|
|
13
|
+
"@lexical/clipboard": "0.15.0",
|
|
14
|
+
"@lexical/code": "0.15.0",
|
|
15
|
+
"@lexical/devtools-core": "0.15.0",
|
|
16
|
+
"@lexical/dragon": "0.15.0",
|
|
17
|
+
"@lexical/hashtag": "0.15.0",
|
|
18
|
+
"@lexical/history": "0.15.0",
|
|
19
|
+
"@lexical/link": "0.15.0",
|
|
20
|
+
"@lexical/list": "0.15.0",
|
|
21
|
+
"@lexical/mark": "0.15.0",
|
|
22
|
+
"@lexical/markdown": "0.15.0",
|
|
23
|
+
"@lexical/overflow": "0.15.0",
|
|
24
|
+
"@lexical/plain-text": "0.15.0",
|
|
25
|
+
"@lexical/rich-text": "0.15.0",
|
|
26
|
+
"@lexical/selection": "0.15.0",
|
|
27
|
+
"@lexical/table": "0.15.0",
|
|
28
|
+
"@lexical/text": "0.15.0",
|
|
29
|
+
"@lexical/utils": "0.15.0",
|
|
30
|
+
"@lexical/yjs": "0.15.0",
|
|
31
|
+
"lexical": "0.15.0",
|
|
31
32
|
"react-error-boundary": "^3.1.4"
|
|
32
33
|
},
|
|
33
34
|
"peerDependencies": {
|
|
@@ -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 {};
|
|
@@ -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,8 @@ 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
|
+
|
|
29
32
|
const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
|
|
30
|
-
var useLayoutEffect = useLayoutEffectImpl;
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -36,6 +38,7 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
36
38
|
* LICENSE file in the root directory of this source tree.
|
|
37
39
|
*
|
|
38
40
|
*/
|
|
41
|
+
|
|
39
42
|
/**
|
|
40
43
|
* Shortcut to Lexical subscriptions when values are used for render.
|
|
41
44
|
*/
|
|
@@ -44,7 +47,7 @@ function useLexicalSubscription(subscription) {
|
|
|
44
47
|
const initializedSubscription = react.useMemo(() => subscription(editor), [editor, subscription]);
|
|
45
48
|
const valueRef = react.useRef(initializedSubscription.initialValueFn());
|
|
46
49
|
const [value, setValue] = react.useState(valueRef.current);
|
|
47
|
-
|
|
50
|
+
useLayoutEffectImpl(() => {
|
|
48
51
|
const {
|
|
49
52
|
initialValueFn,
|
|
50
53
|
subscribe
|
|
@@ -69,6 +72,7 @@ function useLexicalSubscription(subscription) {
|
|
|
69
72
|
* LICENSE file in the root directory of this source tree.
|
|
70
73
|
*
|
|
71
74
|
*/
|
|
75
|
+
|
|
72
76
|
function subscription(editor) {
|
|
73
77
|
return {
|
|
74
78
|
initialValueFn: () => editor.isEditable(),
|
|
@@ -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,8 @@ 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
|
+
const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -34,6 +36,7 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
34
36
|
* LICENSE file in the root directory of this source tree.
|
|
35
37
|
*
|
|
36
38
|
*/
|
|
39
|
+
|
|
37
40
|
/**
|
|
38
41
|
* Shortcut to Lexical subscriptions when values are used for render.
|
|
39
42
|
*/
|
|
@@ -42,7 +45,7 @@ function useLexicalSubscription(subscription) {
|
|
|
42
45
|
const initializedSubscription = useMemo(() => subscription(editor), [editor, subscription]);
|
|
43
46
|
const valueRef = useRef(initializedSubscription.initialValueFn());
|
|
44
47
|
const [value, setValue] = useState(valueRef.current);
|
|
45
|
-
|
|
48
|
+
useLayoutEffectImpl(() => {
|
|
46
49
|
const {
|
|
47
50
|
initialValueFn,
|
|
48
51
|
subscribe
|
|
@@ -67,6 +70,7 @@ function useLexicalSubscription(subscription) {
|
|
|
67
70
|
* LICENSE file in the root directory of this source tree.
|
|
68
71
|
*
|
|
69
72
|
*/
|
|
73
|
+
|
|
70
74
|
function subscription(editor) {
|
|
71
75
|
return {
|
|
72
76
|
initialValueFn: () => editor.isEditable(),
|
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;
|
package/useLexicalEditable.mjs
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
|
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;
|
|
@@ -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('./useLexicalEditable.dev.mjs') : import('./useLexicalEditable.prod.mjs'));
|
|
8
10
|
export default mod.default;
|
|
@@ -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
|
+
|
|
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;
|
|
8
10
|
function m(a){let [c]=b.useLexicalComposerContext(),e=k.useMemo(()=>a(c),[c,a]),d=k.useRef(e.initialValueFn()),[n,g]=k.useState(d.current);l(()=>{let {initialValueFn:p,subscribe:q}=e,f=p();d.current!==f&&(d.current=f,g(f));return q(h=>{d.current=h;g(h)})},[e,a]);return n}function r(a){return{initialValueFn:()=>a.isEditable(),subscribe:c=>a.registerEditableListener(c)}}module.exports=function(){return m(r)}
|
|
@@ -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};
|
|
@@ -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,8 @@ 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
|
+
|
|
29
32
|
const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
|
|
30
|
-
var useLayoutEffect = useLayoutEffectImpl;
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -36,9 +38,10 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
36
38
|
* LICENSE file in the root directory of this source tree.
|
|
37
39
|
*
|
|
38
40
|
*/
|
|
41
|
+
|
|
39
42
|
function useLexicalIsTextContentEmpty(editor, trim) {
|
|
40
43
|
const [isEmpty, setIsEmpty] = react.useState(editor.getEditorState().read(text.$isRootTextContentEmptyCurry(editor.isComposing(), trim)));
|
|
41
|
-
|
|
44
|
+
useLayoutEffectImpl(() => {
|
|
42
45
|
return editor.registerUpdateListener(({
|
|
43
46
|
editorState
|
|
44
47
|
}) => {
|