@lexical/react 0.14.2 → 0.14.3
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.esm.js → LexicalAutoEmbedPlugin.mjs} +2 -2
- package/LexicalAutoEmbedPlugin.node.mjs +11 -0
- package/{LexicalHashtagPlugin.esm.js → LexicalAutoFocusPlugin.mjs} +3 -3
- package/LexicalAutoFocusPlugin.node.mjs +8 -0
- package/{LexicalAutoLinkPlugin.esm.js → LexicalAutoLinkPlugin.mjs} +2 -2
- package/LexicalAutoLinkPlugin.node.mjs +9 -0
- package/{LexicalBlockWithAlignableContents.esm.js → LexicalBlockWithAlignableContents.mjs} +2 -2
- package/LexicalBlockWithAlignableContents.node.mjs +8 -0
- package/{LexicalClearEditorPlugin.esm.js → LexicalCharacterLimitPlugin.mjs} +3 -3
- package/LexicalCharacterLimitPlugin.node.mjs +8 -0
- package/LexicalCheckListPlugin.dev.js +1 -1
- package/{LexicalCheckListPlugin.dev.esm.js → LexicalCheckListPlugin.dev.mjs} +2 -2
- package/LexicalCheckListPlugin.mjs +10 -0
- package/LexicalCheckListPlugin.node.mjs +8 -0
- package/LexicalCheckListPlugin.prod.js +1 -1
- package/LexicalCheckListPlugin.prod.mjs +7 -0
- package/{LexicalCheckListPlugin.esm.js → LexicalClearEditorPlugin.mjs} +3 -3
- package/LexicalClearEditorPlugin.node.mjs +8 -0
- package/LexicalClickableLinkPlugin.d.ts +2 -1
- package/LexicalClickableLinkPlugin.dev.js +8 -3
- package/{LexicalClickableLinkPlugin.dev.esm.js → LexicalClickableLinkPlugin.dev.mjs} +8 -3
- package/LexicalClickableLinkPlugin.mjs +10 -0
- package/LexicalClickableLinkPlugin.node.mjs +8 -0
- package/LexicalClickableLinkPlugin.prod.js +4 -3
- package/LexicalClickableLinkPlugin.prod.mjs +7 -0
- package/{LexicalCollaborationContext.esm.js → LexicalCollaborationContext.mjs} +2 -2
- package/LexicalCollaborationContext.node.mjs +9 -0
- package/LexicalCollaborationPlugin.mjs +10 -0
- package/LexicalCollaborationPlugin.node.mjs +8 -0
- package/{LexicalListPlugin.esm.js → LexicalComposer.mjs} +3 -3
- package/LexicalComposer.node.mjs +8 -0
- package/{LexicalComposerContext.esm.js → LexicalComposerContext.mjs} +2 -2
- package/LexicalComposerContext.node.mjs +10 -0
- package/LexicalContentEditable.mjs +10 -0
- package/LexicalContentEditable.node.mjs +8 -0
- package/LexicalContextMenuPlugin.d.ts +2 -1
- package/LexicalContextMenuPlugin.dev.js +9 -4
- package/{LexicalContextMenuPlugin.dev.esm.js → LexicalContextMenuPlugin.dev.mjs} +9 -4
- package/{LexicalContextMenuPlugin.esm.js → LexicalContextMenuPlugin.mjs} +2 -2
- package/LexicalContextMenuPlugin.node.mjs +9 -0
- package/LexicalContextMenuPlugin.prod.js +16 -16
- package/LexicalContextMenuPlugin.prod.mjs +7 -0
- package/{LexicalDecoratorBlockNode.esm.js → LexicalDecoratorBlockNode.mjs} +2 -2
- package/LexicalDecoratorBlockNode.node.mjs +9 -0
- package/LexicalEditorRefPlugin.mjs +10 -0
- package/LexicalEditorRefPlugin.node.mjs +8 -0
- package/{useLexicalEditable.esm.js → LexicalErrorBoundary.mjs} +2 -2
- package/LexicalErrorBoundary.node.mjs +8 -0
- package/{LexicalClickableLinkPlugin.esm.js → LexicalHashtagPlugin.mjs} +3 -3
- package/LexicalHashtagPlugin.node.mjs +8 -0
- package/{LexicalHistoryPlugin.esm.js → LexicalHistoryPlugin.mjs} +2 -2
- package/LexicalHistoryPlugin.node.mjs +9 -0
- package/{LexicalHorizontalRuleNode.esm.js → LexicalHorizontalRuleNode.mjs} +2 -2
- package/LexicalHorizontalRuleNode.node.mjs +11 -0
- package/{LexicalCollaborationPlugin.esm.js → LexicalHorizontalRulePlugin.mjs} +3 -3
- package/LexicalHorizontalRulePlugin.node.mjs +8 -0
- package/{LexicalTableOfContents.esm.js → LexicalLinkPlugin.mjs} +3 -3
- package/LexicalLinkPlugin.node.mjs +8 -0
- package/LexicalListPlugin.mjs +10 -0
- package/LexicalListPlugin.node.mjs +8 -0
- package/{LexicalMarkdownShortcutPlugin.esm.js → LexicalMarkdownShortcutPlugin.mjs} +2 -2
- package/LexicalMarkdownShortcutPlugin.node.mjs +9 -0
- package/LexicalNestedComposer.dev.js +6 -2
- package/{LexicalNestedComposer.dev.esm.js → LexicalNestedComposer.dev.mjs} +6 -2
- package/LexicalNestedComposer.mjs +10 -0
- package/LexicalNestedComposer.node.mjs +8 -0
- package/LexicalNestedComposer.prod.js +5 -4
- package/LexicalNestedComposer.prod.mjs +7 -0
- package/LexicalNodeEventPlugin.mjs +10 -0
- package/LexicalNodeEventPlugin.node.mjs +8 -0
- package/LexicalNodeMenuPlugin.dev.js +1 -1
- package/{LexicalNodeMenuPlugin.dev.esm.js → LexicalNodeMenuPlugin.dev.mjs} +1 -1
- package/{LexicalNodeMenuPlugin.esm.js → LexicalNodeMenuPlugin.mjs} +2 -2
- package/LexicalNodeMenuPlugin.node.mjs +9 -0
- package/LexicalNodeMenuPlugin.prod.js +1 -1
- package/{LexicalNodeMenuPlugin.prod.esm.js → LexicalNodeMenuPlugin.prod.mjs} +1 -1
- package/{LexicalComposer.esm.js → LexicalOnChangePlugin.mjs} +3 -3
- package/LexicalOnChangePlugin.node.mjs +8 -0
- package/LexicalPlainTextPlugin.mjs +10 -0
- package/LexicalPlainTextPlugin.node.mjs +8 -0
- package/{LexicalLinkPlugin.esm.js → LexicalRichTextPlugin.mjs} +3 -3
- package/LexicalRichTextPlugin.node.mjs +8 -0
- package/{LexicalTabIndentationPlugin.esm.js → LexicalTabIndentationPlugin.mjs} +2 -2
- package/LexicalTabIndentationPlugin.node.mjs +9 -0
- package/{LexicalErrorBoundary.esm.js → LexicalTableOfContents.mjs} +2 -2
- package/LexicalTableOfContents.node.mjs +8 -0
- package/LexicalTablePlugin.mjs +10 -0
- package/LexicalTablePlugin.node.mjs +8 -0
- package/{LexicalTreeView.esm.js → LexicalTreeView.mjs} +2 -2
- package/LexicalTreeView.node.mjs +8 -0
- package/LexicalTypeaheadMenuPlugin.dev.js +1 -1
- package/{LexicalTypeaheadMenuPlugin.dev.esm.js → LexicalTypeaheadMenuPlugin.dev.mjs} +1 -1
- package/{LexicalTypeaheadMenuPlugin.esm.js → LexicalTypeaheadMenuPlugin.mjs} +2 -2
- package/LexicalTypeaheadMenuPlugin.node.mjs +14 -0
- package/LexicalTypeaheadMenuPlugin.prod.js +1 -1
- package/{LexicalTypeaheadMenuPlugin.prod.esm.js → LexicalTypeaheadMenuPlugin.prod.mjs} +1 -1
- package/package.json +499 -179
- package/useLexicalEditable.mjs +10 -0
- package/useLexicalEditable.node.mjs +8 -0
- package/{useLexicalIsTextContentEmpty.esm.js → useLexicalIsTextContentEmpty.mjs} +2 -2
- package/useLexicalIsTextContentEmpty.node.mjs +8 -0
- package/{useLexicalNodeSelection.esm.js → useLexicalNodeSelection.mjs} +2 -2
- package/useLexicalNodeSelection.node.mjs +8 -0
- package/useLexicalSubscription.mjs +10 -0
- package/useLexicalSubscription.node.mjs +8 -0
- package/{LexicalAutoFocusPlugin.esm.js → useLexicalTextEntity.mjs} +3 -3
- package/useLexicalTextEntity.node.mjs +8 -0
- package/LexicalCharacterLimitPlugin.esm.js +0 -10
- package/LexicalCheckListPlugin.prod.esm.js +0 -7
- package/LexicalClickableLinkPlugin.prod.esm.js +0 -7
- package/LexicalContentEditable.esm.js +0 -10
- package/LexicalContextMenuPlugin.prod.esm.js +0 -7
- package/LexicalEditorRefPlugin.esm.js +0 -10
- package/LexicalHorizontalRulePlugin.esm.js +0 -10
- package/LexicalNestedComposer.esm.js +0 -10
- package/LexicalNestedComposer.prod.esm.js +0 -7
- package/LexicalNodeEventPlugin.esm.js +0 -10
- package/LexicalOnChangePlugin.esm.js +0 -10
- package/LexicalPlainTextPlugin.esm.js +0 -10
- package/LexicalRichTextPlugin.esm.js +0 -10
- package/LexicalTablePlugin.esm.js +0 -10
- package/useLexicalSubscription.esm.js +0 -10
- package/useLexicalTextEntity.esm.js +0 -10
- /package/{LexicalAutoEmbedPlugin.dev.esm.js → LexicalAutoEmbedPlugin.dev.mjs} +0 -0
- /package/{LexicalAutoEmbedPlugin.prod.esm.js → LexicalAutoEmbedPlugin.prod.mjs} +0 -0
- /package/{LexicalAutoFocusPlugin.dev.esm.js → LexicalAutoFocusPlugin.dev.mjs} +0 -0
- /package/{LexicalAutoFocusPlugin.prod.esm.js → LexicalAutoFocusPlugin.prod.mjs} +0 -0
- /package/{LexicalAutoLinkPlugin.dev.esm.js → LexicalAutoLinkPlugin.dev.mjs} +0 -0
- /package/{LexicalAutoLinkPlugin.prod.esm.js → LexicalAutoLinkPlugin.prod.mjs} +0 -0
- /package/{LexicalBlockWithAlignableContents.dev.esm.js → LexicalBlockWithAlignableContents.dev.mjs} +0 -0
- /package/{LexicalBlockWithAlignableContents.prod.esm.js → LexicalBlockWithAlignableContents.prod.mjs} +0 -0
- /package/{LexicalCharacterLimitPlugin.dev.esm.js → LexicalCharacterLimitPlugin.dev.mjs} +0 -0
- /package/{LexicalCharacterLimitPlugin.prod.esm.js → LexicalCharacterLimitPlugin.prod.mjs} +0 -0
- /package/{LexicalClearEditorPlugin.dev.esm.js → LexicalClearEditorPlugin.dev.mjs} +0 -0
- /package/{LexicalClearEditorPlugin.prod.esm.js → LexicalClearEditorPlugin.prod.mjs} +0 -0
- /package/{LexicalCollaborationContext.dev.esm.js → LexicalCollaborationContext.dev.mjs} +0 -0
- /package/{LexicalCollaborationContext.prod.esm.js → LexicalCollaborationContext.prod.mjs} +0 -0
- /package/{LexicalCollaborationPlugin.dev.esm.js → LexicalCollaborationPlugin.dev.mjs} +0 -0
- /package/{LexicalCollaborationPlugin.prod.esm.js → LexicalCollaborationPlugin.prod.mjs} +0 -0
- /package/{LexicalComposer.dev.esm.js → LexicalComposer.dev.mjs} +0 -0
- /package/{LexicalComposer.prod.esm.js → LexicalComposer.prod.mjs} +0 -0
- /package/{LexicalComposerContext.dev.esm.js → LexicalComposerContext.dev.mjs} +0 -0
- /package/{LexicalComposerContext.prod.esm.js → LexicalComposerContext.prod.mjs} +0 -0
- /package/{LexicalContentEditable.dev.esm.js → LexicalContentEditable.dev.mjs} +0 -0
- /package/{LexicalContentEditable.prod.esm.js → LexicalContentEditable.prod.mjs} +0 -0
- /package/{LexicalDecoratorBlockNode.dev.esm.js → LexicalDecoratorBlockNode.dev.mjs} +0 -0
- /package/{LexicalDecoratorBlockNode.prod.esm.js → LexicalDecoratorBlockNode.prod.mjs} +0 -0
- /package/{LexicalEditorRefPlugin.dev.esm.js → LexicalEditorRefPlugin.dev.mjs} +0 -0
- /package/{LexicalEditorRefPlugin.prod.esm.js → LexicalEditorRefPlugin.prod.mjs} +0 -0
- /package/{LexicalErrorBoundary.dev.esm.js → LexicalErrorBoundary.dev.mjs} +0 -0
- /package/{LexicalErrorBoundary.prod.esm.js → LexicalErrorBoundary.prod.mjs} +0 -0
- /package/{LexicalHashtagPlugin.dev.esm.js → LexicalHashtagPlugin.dev.mjs} +0 -0
- /package/{LexicalHashtagPlugin.prod.esm.js → LexicalHashtagPlugin.prod.mjs} +0 -0
- /package/{LexicalHistoryPlugin.dev.esm.js → LexicalHistoryPlugin.dev.mjs} +0 -0
- /package/{LexicalHistoryPlugin.prod.esm.js → LexicalHistoryPlugin.prod.mjs} +0 -0
- /package/{LexicalHorizontalRuleNode.dev.esm.js → LexicalHorizontalRuleNode.dev.mjs} +0 -0
- /package/{LexicalHorizontalRuleNode.prod.esm.js → LexicalHorizontalRuleNode.prod.mjs} +0 -0
- /package/{LexicalHorizontalRulePlugin.dev.esm.js → LexicalHorizontalRulePlugin.dev.mjs} +0 -0
- /package/{LexicalHorizontalRulePlugin.prod.esm.js → LexicalHorizontalRulePlugin.prod.mjs} +0 -0
- /package/{LexicalLinkPlugin.dev.esm.js → LexicalLinkPlugin.dev.mjs} +0 -0
- /package/{LexicalLinkPlugin.prod.esm.js → LexicalLinkPlugin.prod.mjs} +0 -0
- /package/{LexicalListPlugin.dev.esm.js → LexicalListPlugin.dev.mjs} +0 -0
- /package/{LexicalListPlugin.prod.esm.js → LexicalListPlugin.prod.mjs} +0 -0
- /package/{LexicalMarkdownShortcutPlugin.dev.esm.js → LexicalMarkdownShortcutPlugin.dev.mjs} +0 -0
- /package/{LexicalMarkdownShortcutPlugin.prod.esm.js → LexicalMarkdownShortcutPlugin.prod.mjs} +0 -0
- /package/{LexicalNodeEventPlugin.dev.esm.js → LexicalNodeEventPlugin.dev.mjs} +0 -0
- /package/{LexicalNodeEventPlugin.prod.esm.js → LexicalNodeEventPlugin.prod.mjs} +0 -0
- /package/{LexicalOnChangePlugin.dev.esm.js → LexicalOnChangePlugin.dev.mjs} +0 -0
- /package/{LexicalOnChangePlugin.prod.esm.js → LexicalOnChangePlugin.prod.mjs} +0 -0
- /package/{LexicalPlainTextPlugin.dev.esm.js → LexicalPlainTextPlugin.dev.mjs} +0 -0
- /package/{LexicalPlainTextPlugin.prod.esm.js → LexicalPlainTextPlugin.prod.mjs} +0 -0
- /package/{LexicalRichTextPlugin.dev.esm.js → LexicalRichTextPlugin.dev.mjs} +0 -0
- /package/{LexicalRichTextPlugin.prod.esm.js → LexicalRichTextPlugin.prod.mjs} +0 -0
- /package/{LexicalTabIndentationPlugin.dev.esm.js → LexicalTabIndentationPlugin.dev.mjs} +0 -0
- /package/{LexicalTabIndentationPlugin.prod.esm.js → LexicalTabIndentationPlugin.prod.mjs} +0 -0
- /package/{LexicalTableOfContents.dev.esm.js → LexicalTableOfContents.dev.mjs} +0 -0
- /package/{LexicalTableOfContents.prod.esm.js → LexicalTableOfContents.prod.mjs} +0 -0
- /package/{LexicalTablePlugin.dev.esm.js → LexicalTablePlugin.dev.mjs} +0 -0
- /package/{LexicalTablePlugin.prod.esm.js → LexicalTablePlugin.prod.mjs} +0 -0
- /package/{LexicalTreeView.dev.esm.js → LexicalTreeView.dev.mjs} +0 -0
- /package/{LexicalTreeView.prod.esm.js → LexicalTreeView.prod.mjs} +0 -0
- /package/{useLexicalEditable.dev.esm.js → useLexicalEditable.dev.mjs} +0 -0
- /package/{useLexicalEditable.prod.esm.js → useLexicalEditable.prod.mjs} +0 -0
- /package/{useLexicalIsTextContentEmpty.dev.esm.js → useLexicalIsTextContentEmpty.dev.mjs} +0 -0
- /package/{useLexicalIsTextContentEmpty.prod.esm.js → useLexicalIsTextContentEmpty.prod.mjs} +0 -0
- /package/{useLexicalNodeSelection.dev.esm.js → useLexicalNodeSelection.dev.mjs} +0 -0
- /package/{useLexicalNodeSelection.prod.esm.js → useLexicalNodeSelection.prod.mjs} +0 -0
- /package/{useLexicalSubscription.dev.esm.js → useLexicalSubscription.dev.mjs} +0 -0
- /package/{useLexicalSubscription.prod.esm.js → useLexicalSubscription.prod.mjs} +0 -0
- /package/{useLexicalTextEntity.dev.esm.js → useLexicalTextEntity.dev.mjs} +0 -0
- /package/{useLexicalTextEntity.prod.esm.js → useLexicalTextEntity.prod.mjs} +0 -0
|
@@ -4,19 +4,19 @@
|
|
|
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
|
-
'use strict';var h=require("@lexical/react/LexicalComposerContext"),
|
|
8
|
-
let
|
|
9
|
-
function
|
|
10
|
-
function
|
|
11
|
-
function
|
|
12
|
-
b,!0)}}},[a,
|
|
13
|
-
function
|
|
14
|
-
"typeahead-item-"+
|
|
15
|
-
a.dispatchCommand(
|
|
16
|
-
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
[
|
|
20
|
-
exports.LexicalContextMenuPlugin=function({options:c,
|
|
21
|
-
{null===
|
|
22
|
-
onSelectOption:
|
|
7
|
+
'use strict';var h=require("@lexical/react/LexicalComposerContext"),w=require("@lexical/utils"),z=require("lexical"),A=require("react"),B="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?A.useLayoutEffect:A.useEffect;class C{constructor(c){this.key=c;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(c){this.ref={current:c}}}
|
|
8
|
+
let D=c=>{const a=document.getElementById("typeahead-menu");if(a){var d=a.getBoundingClientRect();d.top+d.height>window.innerHeight&&a.scrollIntoView({block:"center"});0>d.top&&a.scrollIntoView({block:"center"});c.scrollIntoView({block:"nearest"})}};
|
|
9
|
+
function E(c){var a=z.$getSelection();if(!z.$isRangeSelection(a)||!a.isCollapsed())return null;var d=a.anchor;if("text"!==d.type)return null;a=d.getNode();if(!a.isSimpleText())return null;d=d.offset;let k=a.getTextContent().slice(0,d);var e=c.matchingString;c=c.replaceableString.length;for(let n=c;n<=e.length;n++)k.substr(-n)===e.substr(0,n)&&(c=n);c=d-c;if(0>c)return null;let p;0===c?[p]=a.splitText(d):[,p]=a.splitText(c,d);return p}
|
|
10
|
+
function F(c,a){let d=getComputedStyle(c),k="absolute"===d.position;a=a?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===d.position)return document.body;for(;c=c.parentElement;)if(d=getComputedStyle(c),(!k||"static"!==d.position)&&a.test(d.overflow+d.overflowY+d.overflowX))return c;return document.body}function G(c,a){c=c.getBoundingClientRect();a=a.getBoundingClientRect();return c.top>a.top&&c.top<a.bottom}
|
|
11
|
+
function H(c,a,d,k){let [e]=h.useLexicalComposerContext();A.useEffect(()=>{if(null!=a&&null!=c){let p=e.getRootElement(),n=null!=p?F(p,!1):document.body,x=!1,l=G(a,n),b=function(){x||(window.requestAnimationFrame(function(){d();x=!1}),x=!0);const q=G(a,n);q!==l&&(l=q,null!=k&&k(q))},g=new ResizeObserver(d);window.addEventListener("resize",d);document.addEventListener("scroll",b,{capture:!0,passive:!0});g.observe(a);return()=>{g.unobserve(a);window.removeEventListener("resize",d);document.removeEventListener("scroll",
|
|
12
|
+
b,!0)}}},[a,e,k,d,c])}let I=z.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
|
|
13
|
+
function J({close:c,editor:a,anchorElementRef:d,resolution:k,options:e,menuRenderFn:p,onSelectOption:n,shouldSplitNodeWithQuery:x=!1,commandPriority:l=z.COMMAND_PRIORITY_LOW}){let [b,g]=A.useState(null);A.useEffect(()=>{g(0)},[k.match&&k.match.matchingString]);let q=A.useCallback(f=>{a.update(()=>{const m=null!=k.match&&x?E(k.match):null;n(f,m,c,k.match?k.match.matchingString:"")})},[a,x,k.match,n,c]),t=A.useCallback(f=>{const m=a.getRootElement();null!==m&&(m.setAttribute("aria-activedescendant",
|
|
14
|
+
"typeahead-item-"+f),g(f))},[a]);A.useEffect(()=>()=>{let f=a.getRootElement();null!==f&&f.removeAttribute("aria-activedescendant")},[a]);B(()=>{null===e?g(null):null===b&&t(0)},[e,b,t]);A.useEffect(()=>w.mergeRegister(a.registerCommand(I,({option:f})=>f.ref&&null!=f.ref.current?(D(f.ref.current),!0):!1,l)),[a,t,l]);A.useEffect(()=>w.mergeRegister(a.registerCommand(z.KEY_ARROW_DOWN_COMMAND,f=>{if(null!==e&&e.length&&null!==b){let m=b!==e.length-1?b+1:0;t(m);let u=e[m];null!=u.ref&&u.ref.current&&
|
|
15
|
+
a.dispatchCommand(I,{index:m,option:u});f.preventDefault();f.stopImmediatePropagation()}return!0},l),a.registerCommand(z.KEY_ARROW_UP_COMMAND,f=>{if(null!==e&&e.length&&null!==b){var m=0!==b?b-1:e.length-1;t(m);m=e[m];null!=m.ref&&m.ref.current&&D(m.ref.current);f.preventDefault();f.stopImmediatePropagation()}return!0},l),a.registerCommand(z.KEY_ESCAPE_COMMAND,f=>{f.preventDefault();f.stopImmediatePropagation();c();return!0},l),a.registerCommand(z.KEY_TAB_COMMAND,f=>{if(null===e||null===b||null==
|
|
16
|
+
e[b])return!1;f.preventDefault();f.stopImmediatePropagation();q(e[b]);return!0},l),a.registerCommand(z.KEY_ENTER_COMMAND,f=>{if(null===e||null===b||null==e[b])return!1;null!==f&&(f.preventDefault(),f.stopImmediatePropagation());q(e[b]);return!0},l)),[q,c,a,e,b,t,l]);let v=A.useMemo(()=>({options:e,selectOptionAndCleanUp:q,selectedIndex:b,setHighlightedIndex:g}),[q,b,e]);return p(d,v,k.match?k.match.matchingString:"")}
|
|
17
|
+
function K(c,a,d,k=document.body){let [e]=h.useLexicalComposerContext(),p=A.useRef(document.createElement("div")),n=A.useCallback(()=>{p.current.style.top=p.current.style.bottom;const l=e.getRootElement(),b=p.current;var g=b.firstChild;if(null!==l&&null!==c){const {left:t,top:v,width:f,height:m}=c.getRect();b.style.top=`${v+p.current.offsetHeight+3}px`;b.style.left=`${t+window.pageXOffset}px`;b.style.height=`${m}px`;b.style.width=`${f}px`;if(null!==g){g.style.top=`${v}`;var q=g.getBoundingClientRect();
|
|
18
|
+
g=q.height;q=q.width;const u=l.getBoundingClientRect();t+q>u.right&&(b.style.left=`${u.right-q+window.pageXOffset}px`);(v+g>window.innerHeight||v+g>u.bottom)&&v-u.top>g&&(b.style.top=`${v-g+window.pageYOffset-m}px`)}b.isConnected||(null!=d&&(b.className=d),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;l.setAttribute("aria-controls","typeahead-menu")}},
|
|
19
|
+
[e,c,d,k]);A.useEffect(()=>{let l=e.getRootElement();if(null!==c)return n(),()=>{null!==l&&l.removeAttribute("aria-controls");let b=p.current;null!==b&&b.isConnected&&b.remove()}},[e,n,c]);let x=A.useCallback(l=>{null!==c&&(l||a(null))},[c,a]);H(c,p.current,n,x);return p}
|
|
20
|
+
exports.LexicalContextMenuPlugin=function({options:c,onWillOpen:a,onClose:d,onOpen:k,onSelectOption:e,menuRenderFn:p,anchorClassName:n,commandPriority:x=z.COMMAND_PRIORITY_LOW,parent:l}){let [b]=h.useLexicalComposerContext(),[g,q]=A.useState(null),t=A.useRef(null);n=K(g,q,n,l);let v=A.useCallback(()=>{q(null);null!=d&&null!==g&&d()},[d,g]),f=A.useCallback(r=>{q(r);null!=k&&null===g&&k(r)},[k,g]),m=A.useCallback(r=>{r.preventDefault();null!=a&&a(r);const y=w.calculateZoomLevel(r.target);f({getRect:()=>
|
|
21
|
+
new DOMRect(r.clientX/y,r.clientY/y,1,1)})},[f,a]),u=A.useCallback(r=>{null===g||null==t.current||null==r.target||t.current.contains(r.target)||v()},[v,g]);A.useEffect(()=>{let r=b.getRootElement();if(r)return r.addEventListener("contextmenu",m),()=>r.removeEventListener("contextmenu",m)},[b,m]);A.useEffect(()=>{document.addEventListener("click",u);return()=>document.removeEventListener("click",u)},[b,u]);return null===g||null===b?null:A.createElement(J,{close:v,resolution:g,editor:b,anchorElementRef:n,
|
|
22
|
+
options:c,menuRenderFn:(r,y)=>p(r,y,{setMenuRef:L=>{t.current=L}}),onSelectOption:e,commandPriority:x})};exports.MenuOption=C
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
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 v,useRef as w}from"react";var y="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?p: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 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 C(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>o.top&&n.top<o.bottom}function R(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=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)&&l.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t,!1):document.body;let i=!1,u=C(n,e);const c=function(){i||(window.requestAnimationFrame((function(){o(),i=!1})),i=!0);const t=C(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 x=o("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function O({close:t,editor:n,anchorElementRef:o,resolution:d,options:p,menuRenderFn:w,onSelectOption:b,shouldSplitNodeWithQuery:C=!1,commandPriority:R=s}){const[O,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;b(e,n,t,d.match?d.match.matchingString:"")}))}),[n,C,d.match,b,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]),y((()=>{null===p?I(null):null===O&&L(0)}),[p,O,L]),f((()=>e(n.registerCommand(x,(({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!==O){const t=O!==p.length-1?O+1:0;L(t);const o=p[t];null!=o.ref&&o.ref.current&&n.dispatchCommand(x,{index:t,option:o}),e.preventDefault(),e.stopImmediatePropagation()}return!0}),R),n.registerCommand(r,(t=>{const e=t;if(null!==p&&p.length&&null!==O){const t=0!==O?O-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!==O&&null!=p[O]&&(e.preventDefault(),e.stopImmediatePropagation(),A(p[O]),!0)}),R),n.registerCommand(c,(t=>null!==p&&null!==O&&null!=p[O]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),A(p[O]),!0)),R))),[A,t,n,p,O,L,R]);return w(o,v((()=>({options:p,selectOptionAndCleanUp:A,selectedIndex:O,setHighlightedIndex:I})),[A,O,p]),d.match?d.match.matchingString:"")}function I({options:e,onWillOpen:o,onClose:l,onOpen:r,onSelectOption:i,menuRenderFn:u,anchorClassName:c,commandPriority:a=s,parent:m}){const[p]=t(),[v,y]=g(null),b=d.useRef(null),E=function(e,n,o,l=document.body){const[r]=t(),i=w(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+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&&(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 R(e,i.current,u,c),i}(v,y,c,m),C=h((()=>{y(null),null!=l&&null!==v&&l()}),[l,v]),x=h((t=>{y(t),null!=r&&null===v&&r(t)}),[r,v]),I=h((t=>{t.preventDefault(),null!=o&&o(t);const e=n(t.target);x({getRect:()=>new DOMRect(t.clientX/e,t.clientY/e,1,1)})}),[x,o]),S=h((t=>{null===v||null==b.current||null==t.target||b.current.contains(t.target)||C()}),[C,v]);return f((()=>{const t=p.getRootElement();if(t)return t.addEventListener("contextmenu",I),()=>t.removeEventListener("contextmenu",I)}),[p,I]),f((()=>(document.addEventListener("click",S),()=>document.removeEventListener("click",S))),[p,S]),null===v||null===p?null:d.createElement(O,{close:C,resolution:v,editor:p,anchorElementRef:E,options:e,menuRenderFn:(t,e)=>u(t,e,{setMenuRef:t=>{b.current=t}}),onSelectOption:i,commandPriority:a})}export{I as LexicalContextMenuPlugin,b as MenuOption};
|
|
@@ -4,8 +4,8 @@
|
|
|
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
|
-
import * as modDev from './LexicalDecoratorBlockNode.dev.
|
|
8
|
-
import * as modProd from './LexicalDecoratorBlockNode.prod.
|
|
7
|
+
import * as modDev from './LexicalDecoratorBlockNode.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalDecoratorBlockNode.prod.mjs';
|
|
9
9
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
10
|
export const $isDecoratorBlockNode = mod.$isDecoratorBlockNode;
|
|
11
11
|
export const DecoratorBlockNode = mod.DecoratorBlockNode;
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalDecoratorBlockNode.dev.mjs') : import('./LexicalDecoratorBlockNode.prod.mjs'));
|
|
8
|
+
export const $isDecoratorBlockNode = mod.$isDecoratorBlockNode;
|
|
9
|
+
export const DecoratorBlockNode = mod.DecoratorBlockNode;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
import * as modDev from './LexicalEditorRefPlugin.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalEditorRefPlugin.prod.mjs';
|
|
9
|
+
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
|
+
export const EditorRefPlugin = mod.EditorRefPlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalEditorRefPlugin.dev.mjs') : import('./LexicalEditorRefPlugin.prod.mjs'));
|
|
8
|
+
export const EditorRefPlugin = mod.EditorRefPlugin;
|
|
@@ -4,7 +4,7 @@
|
|
|
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
|
-
import * as modDev from './
|
|
8
|
-
import * as modProd from './
|
|
7
|
+
import * as modDev from './LexicalErrorBoundary.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalErrorBoundary.prod.mjs';
|
|
9
9
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
10
|
export default mod.default;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalErrorBoundary.dev.mjs') : import('./LexicalErrorBoundary.prod.mjs'));
|
|
8
|
+
export default mod.default;
|
|
@@ -4,7 +4,7 @@
|
|
|
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
|
-
import * as modDev from './
|
|
8
|
-
import * as modProd from './
|
|
7
|
+
import * as modDev from './LexicalHashtagPlugin.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalHashtagPlugin.prod.mjs';
|
|
9
9
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
|
-
export
|
|
10
|
+
export const HashtagPlugin = mod.HashtagPlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalHashtagPlugin.dev.mjs') : import('./LexicalHashtagPlugin.prod.mjs'));
|
|
8
|
+
export const HashtagPlugin = mod.HashtagPlugin;
|
|
@@ -4,8 +4,8 @@
|
|
|
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
|
-
import * as modDev from './LexicalHistoryPlugin.dev.
|
|
8
|
-
import * as modProd from './LexicalHistoryPlugin.prod.
|
|
7
|
+
import * as modDev from './LexicalHistoryPlugin.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalHistoryPlugin.prod.mjs';
|
|
9
9
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
10
|
export const HistoryPlugin = mod.HistoryPlugin;
|
|
11
11
|
export const createEmptyHistoryState = mod.createEmptyHistoryState;
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalHistoryPlugin.dev.mjs') : import('./LexicalHistoryPlugin.prod.mjs'));
|
|
8
|
+
export const HistoryPlugin = mod.HistoryPlugin;
|
|
9
|
+
export const createEmptyHistoryState = mod.createEmptyHistoryState;
|
|
@@ -4,8 +4,8 @@
|
|
|
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
|
-
import * as modDev from './LexicalHorizontalRuleNode.dev.
|
|
8
|
-
import * as modProd from './LexicalHorizontalRuleNode.prod.
|
|
7
|
+
import * as modDev from './LexicalHorizontalRuleNode.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalHorizontalRuleNode.prod.mjs';
|
|
9
9
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
10
|
export const $createHorizontalRuleNode = mod.$createHorizontalRuleNode;
|
|
11
11
|
export const $isHorizontalRuleNode = mod.$isHorizontalRuleNode;
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalHorizontalRuleNode.dev.mjs') : import('./LexicalHorizontalRuleNode.prod.mjs'));
|
|
8
|
+
export const $createHorizontalRuleNode = mod.$createHorizontalRuleNode;
|
|
9
|
+
export const $isHorizontalRuleNode = mod.$isHorizontalRuleNode;
|
|
10
|
+
export const HorizontalRuleNode = mod.HorizontalRuleNode;
|
|
11
|
+
export const INSERT_HORIZONTAL_RULE_COMMAND = mod.INSERT_HORIZONTAL_RULE_COMMAND;
|
|
@@ -4,7 +4,7 @@
|
|
|
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
|
-
import * as modDev from './
|
|
8
|
-
import * as modProd from './
|
|
7
|
+
import * as modDev from './LexicalHorizontalRulePlugin.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalHorizontalRulePlugin.prod.mjs';
|
|
9
9
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
|
-
export const
|
|
10
|
+
export const HorizontalRulePlugin = mod.HorizontalRulePlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalHorizontalRulePlugin.dev.mjs') : import('./LexicalHorizontalRulePlugin.prod.mjs'));
|
|
8
|
+
export const HorizontalRulePlugin = mod.HorizontalRulePlugin;
|
|
@@ -4,7 +4,7 @@
|
|
|
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
|
-
import * as modDev from './
|
|
8
|
-
import * as modProd from './
|
|
7
|
+
import * as modDev from './LexicalLinkPlugin.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalLinkPlugin.prod.mjs';
|
|
9
9
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
|
-
export
|
|
10
|
+
export const LinkPlugin = mod.LinkPlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalLinkPlugin.dev.mjs') : import('./LexicalLinkPlugin.prod.mjs'));
|
|
8
|
+
export const LinkPlugin = mod.LinkPlugin;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
import * as modDev from './LexicalListPlugin.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalListPlugin.prod.mjs';
|
|
9
|
+
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
|
+
export const ListPlugin = mod.ListPlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalListPlugin.dev.mjs') : import('./LexicalListPlugin.prod.mjs'));
|
|
8
|
+
export const ListPlugin = mod.ListPlugin;
|
|
@@ -4,8 +4,8 @@
|
|
|
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
|
-
import * as modDev from './LexicalMarkdownShortcutPlugin.dev.
|
|
8
|
-
import * as modProd from './LexicalMarkdownShortcutPlugin.prod.
|
|
7
|
+
import * as modDev from './LexicalMarkdownShortcutPlugin.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalMarkdownShortcutPlugin.prod.mjs';
|
|
9
9
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
10
|
export const DEFAULT_TRANSFORMERS = mod.DEFAULT_TRANSFORMERS;
|
|
11
11
|
export const MarkdownShortcutPlugin = mod.MarkdownShortcutPlugin;
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalMarkdownShortcutPlugin.dev.mjs') : import('./LexicalMarkdownShortcutPlugin.prod.mjs'));
|
|
8
|
+
export const DEFAULT_TRANSFORMERS = mod.DEFAULT_TRANSFORMERS;
|
|
9
|
+
export const MarkdownShortcutPlugin = mod.MarkdownShortcutPlugin;
|
|
@@ -17,6 +17,10 @@ var React = require('react');
|
|
|
17
17
|
* LICENSE file in the root directory of this source tree.
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
|
+
function getTransformSetFromKlass(klass) {
|
|
21
|
+
const transform = klass.transform();
|
|
22
|
+
return transform !== null ? new Set([transform]) : new Set();
|
|
23
|
+
}
|
|
20
24
|
function LexicalNestedComposer({
|
|
21
25
|
initialEditor,
|
|
22
26
|
children,
|
|
@@ -49,7 +53,7 @@ function LexicalNestedComposer({
|
|
|
49
53
|
klass: entry.klass,
|
|
50
54
|
replace: entry.replace,
|
|
51
55
|
replaceWithKlass: entry.replaceWithKlass,
|
|
52
|
-
transforms:
|
|
56
|
+
transforms: getTransformSetFromKlass(entry.klass)
|
|
53
57
|
});
|
|
54
58
|
}
|
|
55
59
|
} else {
|
|
@@ -68,7 +72,7 @@ function LexicalNestedComposer({
|
|
|
68
72
|
klass,
|
|
69
73
|
replace,
|
|
70
74
|
replaceWithKlass,
|
|
71
|
-
transforms:
|
|
75
|
+
transforms: getTransformSetFromKlass(klass)
|
|
72
76
|
});
|
|
73
77
|
}
|
|
74
78
|
}
|
|
@@ -16,6 +16,10 @@ import { useRef, useContext, useMemo, useEffect } from 'react';
|
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
17
|
*
|
|
18
18
|
*/
|
|
19
|
+
function getTransformSetFromKlass(klass) {
|
|
20
|
+
const transform = klass.transform();
|
|
21
|
+
return transform !== null ? new Set([transform]) : new Set();
|
|
22
|
+
}
|
|
19
23
|
function LexicalNestedComposer({
|
|
20
24
|
initialEditor,
|
|
21
25
|
children,
|
|
@@ -48,7 +52,7 @@ function LexicalNestedComposer({
|
|
|
48
52
|
klass: entry.klass,
|
|
49
53
|
replace: entry.replace,
|
|
50
54
|
replaceWithKlass: entry.replaceWithKlass,
|
|
51
|
-
transforms:
|
|
55
|
+
transforms: getTransformSetFromKlass(entry.klass)
|
|
52
56
|
});
|
|
53
57
|
}
|
|
54
58
|
} else {
|
|
@@ -67,7 +71,7 @@ function LexicalNestedComposer({
|
|
|
67
71
|
klass,
|
|
68
72
|
replace,
|
|
69
73
|
replaceWithKlass,
|
|
70
|
-
transforms:
|
|
74
|
+
transforms: getTransformSetFromKlass(klass)
|
|
71
75
|
});
|
|
72
76
|
}
|
|
73
77
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
import * as modDev from './LexicalNestedComposer.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalNestedComposer.prod.mjs';
|
|
9
|
+
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
|
+
export const LexicalNestedComposer = mod.LexicalNestedComposer;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalNestedComposer.dev.mjs') : import('./LexicalNestedComposer.prod.mjs'));
|
|
8
|
+
export const LexicalNestedComposer = mod.LexicalNestedComposer;
|
|
@@ -4,7 +4,8 @@
|
|
|
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
|
-
'use strict';var d=require("@lexical/react/LexicalCollaborationContext"),m=require("@lexical/react/LexicalComposerContext"),
|
|
8
|
-
|
|
9
|
-
{
|
|
10
|
-
|
|
7
|
+
'use strict';var d=require("@lexical/react/LexicalCollaborationContext"),m=require("@lexical/react/LexicalComposerContext"),q=require("react");function t(a){let h=new URLSearchParams;h.append("code",a);for(let e=1;e<arguments.length;e++)h.append("v",arguments[e]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${h} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
|
|
8
|
+
function u(a){a=a.transform();return null!==a?new Set([a]):new Set}
|
|
9
|
+
exports.LexicalNestedComposer=function({initialEditor:a,children:h,initialNodes:e,initialTheme:v,skipCollabChecks:w}){let r=q.useRef(!1),n=q.useContext(m.LexicalComposerContext);null==n&&t(9);let [f,{getTheme:x}]=n,z=q.useMemo(()=>{var c=v||x()||void 0;const y=m.createLexicalComposerContext(n,c);void 0!==c&&(a._config.theme=c);a._parentEditor=f;if(e)for(var b of e){var g=c=null;"function"!==typeof b&&(g=b,b=g.replace,c=g.with,g=g.withKlass||null);const l=a._nodes.get(b.getType());a._nodes.set(b.getType(),
|
|
10
|
+
{exportDOM:l?l.exportDOM:void 0,klass:b,replace:c,replaceWithKlass:g,transforms:u(b)})}else{b=a._nodes=new Map(f._nodes);for(const [l,k]of b)a._nodes.set(l,{exportDOM:k.exportDOM,klass:k.klass,replace:k.replace,replaceWithKlass:k.replaceWithKlass,transforms:u(k.klass)})}a._config.namespace=f._config.namespace;a._editable=f._editable;return[a,y]},[]),{isCollabActive:A,yjsDocMap:B}=d.useCollaborationContext(),p=w||r.current||B.has(a.getKey());q.useEffect(()=>{p&&(r.current=!0)},[p]);q.useEffect(()=>
|
|
11
|
+
f.registerEditableListener(c=>{a.setEditable(c)}),[a,f]);return q.createElement(m.LexicalComposerContext.Provider,{value:z},!A||p?h:null)}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
import{useCollaborationContext as e}from"@lexical/react/LexicalCollaborationContext";import{LexicalComposerContext as t,createLexicalComposerContext as r}from"@lexical/react/LexicalComposerContext";import*as o from"react";import{useRef as n,useContext as l,useMemo as i,useEffect as a}from"react";var s=function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)};function c(e){const t=e.transform();return null!==t?new Set([t]):new Set}function p({initialEditor:p,children:f,initialNodes:d,initialTheme:m,skipCollabChecks:u}){const h=n(!1),x=l(t);null==x&&s(9);const[g,{getTheme:v}]=x,_=i((()=>{const e=m||v()||void 0,t=r(x,e);if(void 0!==e&&(p._config.theme=e),p._parentEditor=g,d)for(let e of d){let t=null,r=null;if("function"!=typeof e){const o=e;e=o.replace,t=o.with,r=o.withKlass||null}const o=p._nodes.get(e.getType());p._nodes.set(e.getType(),{exportDOM:o?o.exportDOM:void 0,klass:e,replace:t,replaceWithKlass:r,transforms:c(e)})}else{const e=p._nodes=new Map(g._nodes);for(const[t,r]of e)p._nodes.set(t,{exportDOM:r.exportDOM,klass:r.klass,replace:r.replace,replaceWithKlass:r.replaceWithKlass,transforms:c(r.klass)})}return p._config.namespace=g._config.namespace,p._editable=g._editable,[p,t]}),[]),{isCollabActive:w,yjsDocMap:b}=e(),C=u||h.current||b.has(p.getKey());return a((()=>{C&&(h.current=!0)}),[C]),a((()=>g.registerEditableListener((e=>{p.setEditable(e)}))),[p,g]),o.createElement(t.Provider,{value:_},!w||C?f:null)}export{p as LexicalNestedComposer};
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
import * as modDev from './LexicalNodeEventPlugin.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalNodeEventPlugin.prod.mjs';
|
|
9
|
+
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
|
+
export const NodeEventPlugin = mod.NodeEventPlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalNodeEventPlugin.dev.mjs') : import('./LexicalNodeEventPlugin.prod.mjs'));
|
|
8
|
+
export const NodeEventPlugin = mod.NodeEventPlugin;
|
|
@@ -323,7 +323,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
323
323
|
height
|
|
324
324
|
} = resolution.getRect();
|
|
325
325
|
const anchorHeight = anchorElementRef.current.offsetHeight; // use to position under anchor
|
|
326
|
-
containerDiv.style.top = `${top +
|
|
326
|
+
containerDiv.style.top = `${top + anchorHeight + 3}px`;
|
|
327
327
|
containerDiv.style.left = `${left + window.pageXOffset}px`;
|
|
328
328
|
containerDiv.style.height = `${height}px`;
|
|
329
329
|
containerDiv.style.width = `${width}px`;
|
|
@@ -322,7 +322,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
322
322
|
height
|
|
323
323
|
} = resolution.getRect();
|
|
324
324
|
const anchorHeight = anchorElementRef.current.offsetHeight; // use to position under anchor
|
|
325
|
-
containerDiv.style.top = `${top +
|
|
325
|
+
containerDiv.style.top = `${top + anchorHeight + 3}px`;
|
|
326
326
|
containerDiv.style.left = `${left + window.pageXOffset}px`;
|
|
327
327
|
containerDiv.style.height = `${height}px`;
|
|
328
328
|
containerDiv.style.width = `${width}px`;
|
|
@@ -4,8 +4,8 @@
|
|
|
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
|
-
import * as modDev from './LexicalNodeMenuPlugin.dev.
|
|
8
|
-
import * as modProd from './LexicalNodeMenuPlugin.prod.
|
|
7
|
+
import * as modDev from './LexicalNodeMenuPlugin.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalNodeMenuPlugin.prod.mjs';
|
|
9
9
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
10
|
export const LexicalNodeMenuPlugin = mod.LexicalNodeMenuPlugin;
|
|
11
11
|
export const MenuOption = mod.MenuOption;
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalNodeMenuPlugin.dev.mjs') : import('./LexicalNodeMenuPlugin.prod.mjs'));
|
|
8
|
+
export const LexicalNodeMenuPlugin = mod.LexicalNodeMenuPlugin;
|
|
9
|
+
export const MenuOption = mod.MenuOption;
|
|
@@ -14,7 +14,7 @@ function H({close:b,editor:a,anchorElementRef:d,resolution:l,options:f,menuRende
|
|
|
14
14
|
"typeahead-item-"+e),g(e))},[a]);x.useEffect(()=>()=>{let e=a.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")},[a]);z(()=>{null===f?g(null):null===c&&r(0)},[f,c,r]);x.useEffect(()=>y.mergeRegister(a.registerCommand(G,({option:e})=>e.ref&&null!=e.ref.current?(B(e.ref.current),!0):!1,m)),[a,r,m]);x.useEffect(()=>y.mergeRegister(a.registerCommand(t.KEY_ARROW_DOWN_COMMAND,e=>{if(null!==f&&f.length&&null!==c){let h=c!==f.length-1?c+1:0;r(h);let u=f[h];null!=u.ref&&u.ref.current&&
|
|
15
15
|
a.dispatchCommand(G,{index:h,option:u});e.preventDefault();e.stopImmediatePropagation()}return!0},m),a.registerCommand(t.KEY_ARROW_UP_COMMAND,e=>{if(null!==f&&f.length&&null!==c){var h=0!==c?c-1:f.length-1;r(h);h=f[h];null!=h.ref&&h.ref.current&&B(h.ref.current);e.preventDefault();e.stopImmediatePropagation()}return!0},m),a.registerCommand(t.KEY_ESCAPE_COMMAND,e=>{e.preventDefault();e.stopImmediatePropagation();b();return!0},m),a.registerCommand(t.KEY_TAB_COMMAND,e=>{if(null===f||null===c||null==
|
|
16
16
|
f[c])return!1;e.preventDefault();e.stopImmediatePropagation();q(f[c]);return!0},m),a.registerCommand(t.KEY_ENTER_COMMAND,e=>{if(null===f||null===c||null==f[c])return!1;null!==e&&(e.preventDefault(),e.stopImmediatePropagation());q(f[c]);return!0},m)),[q,b,a,f,c,r,m]);let v=x.useMemo(()=>({options:f,selectOptionAndCleanUp:q,selectedIndex:c,setHighlightedIndex:g}),[q,c,f]);return p(d,v,l.match?l.match.matchingString:"")}
|
|
17
|
-
function I(b,a,d,l=document.body){let [f]=k.useLexicalComposerContext(),p=x.useRef(document.createElement("div")),n=x.useCallback(()=>{p.current.style.top=p.current.style.bottom;const m=f.getRootElement(),c=p.current;var g=c.firstChild;if(null!==m&&null!==b){const {left:r,top:v,width:e,height:h}=b.getRect();c.style.top=`${v+
|
|
17
|
+
function I(b,a,d,l=document.body){let [f]=k.useLexicalComposerContext(),p=x.useRef(document.createElement("div")),n=x.useCallback(()=>{p.current.style.top=p.current.style.bottom;const m=f.getRootElement(),c=p.current;var g=c.firstChild;if(null!==m&&null!==b){const {left:r,top:v,width:e,height:h}=b.getRect();c.style.top=`${v+p.current.offsetHeight+3}px`;c.style.left=`${r+window.pageXOffset}px`;c.style.height=`${h}px`;c.style.width=`${e}px`;if(null!==g){g.style.top=`${v}`;var q=g.getBoundingClientRect();
|
|
18
18
|
g=q.height;q=q.width;const u=m.getBoundingClientRect();r+q>u.right&&(c.style.left=`${u.right-q+window.pageXOffset}px`);(v+g>window.innerHeight||v+g>u.bottom)&&v-u.top>g&&(c.style.top=`${v-g+window.pageYOffset-h}px`)}c.isConnected||(null!=d&&(c.className=d),c.setAttribute("aria-label","Typeahead menu"),c.setAttribute("id","typeahead-menu"),c.setAttribute("role","listbox"),c.style.display="block",c.style.position="absolute",l.append(c));p.current=c;m.setAttribute("aria-controls","typeahead-menu")}},
|
|
19
19
|
[f,b,d,l]);x.useEffect(()=>{let m=f.getRootElement();if(null!==b)return n(),()=>{null!==m&&m.removeAttribute("aria-controls");let c=p.current;null!==c&&c.isConnected&&c.remove()}},[f,n,b]);let w=x.useCallback(m=>{null!==b&&(m||a(null))},[b,a]);F(b,p.current,n,w);return p}function J(b){x.startTransition?x.startTransition(b):b()}
|
|
20
20
|
exports.LexicalNodeMenuPlugin=function({options:b,nodeKey:a,onClose:d,onOpen:l,onSelectOption:f,menuRenderFn:p,anchorClassName:n,commandPriority:w=t.COMMAND_PRIORITY_LOW,parent:m}){let [c]=k.useLexicalComposerContext(),[g,q]=x.useState(null);n=I(g,q,n,m);let r=x.useCallback(()=>{q(null);null!=d&&null!==g&&d()},[d,g]),v=x.useCallback(h=>{q(h);null!=l&&null===g&&l(h)},[l,g]),e=x.useCallback(()=>{a?c.update(()=>{const h=t.$getNodeByKey(a),u=c.getElementByKey(a);null!=h&&null!=u&&null==g&&J(()=>v({getRect:()=>
|
|
@@ -4,4 +4,4 @@
|
|
|
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
|
-
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 l,KEY_TAB_COMMAND as r,KEY_ENTER_COMMAND as i,COMMAND_PRIORITY_LOW as s,$getSelection as u,$isRangeSelection as c,$getNodeByKey as a}from"lexical";import*as m from"react";import{useLayoutEffect as d,useEffect as p,useState as f,useCallback as g,useMemo as h,useRef as y}from"react";import{mergeRegister as w}from"@lexical/utils";var b="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?d:p;class v{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const C=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 R(e,n,o,l){const[r]=t();p((()=>{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=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)&&l.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t,!1):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!=l&&l(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,r,l,o,e])}const x=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function
|
|
7
|
+
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 l,KEY_TAB_COMMAND as r,KEY_ENTER_COMMAND as i,COMMAND_PRIORITY_LOW as s,$getSelection as u,$isRangeSelection as c,$getNodeByKey as a}from"lexical";import*as m from"react";import{useLayoutEffect as d,useEffect as p,useState as f,useCallback as g,useMemo as h,useRef as y}from"react";import{mergeRegister as w}from"@lexical/utils";var b="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?d:p;class v{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const C=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 R(e,n,o,l){const[r]=t();p((()=>{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=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)&&l.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t,!1):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!=l&&l(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,r,l,o,e])}const x=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function I({close:t,editor:e,anchorElementRef:a,resolution:m,options:d,menuRenderFn:y,onSelectOption:v,shouldSplitNodeWithQuery:E=!1,commandPriority:R=s}){const[I,O]=f(null),S=m.match&&m.match.matchingString;p((()=>{O(0)}),[S]);const A=g((n=>{e.update((()=>{const e=null!=m.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 l=n.offset,r=o.getTextContent().slice(0,l),i=t.replaceableString.length,s=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(s<0)return null;let a;return 0===s?[a]=o.splitText(l):[,a]=o.splitText(s,l),a}(m.match):null;v(n,e,t,m.match?m.match.matchingString:"")}))}),[e,E,m.match,v,t]),P=g((t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),O(t))}),[e]);p((()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[e]),b((()=>{null===d?O(null):null===I&&P(0)}),[d,I,P]),p((()=>w(e.registerCommand(x,(({option:t})=>!(!t.ref||null==t.ref.current)&&(C(t.ref.current),!0)),R))),[e,P,R]),p((()=>w(e.registerCommand(n,(t=>{const n=t;if(null!==d&&d.length&&null!==I){const t=I!==d.length-1?I+1:0;P(t);const o=d[t];null!=o.ref&&o.ref.current&&e.dispatchCommand(x,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0}),R),e.registerCommand(o,(t=>{const e=t;if(null!==d&&d.length&&null!==I){const t=0!==I?I-1:d.length-1;P(t);const n=d[t];null!=n.ref&&n.ref.current&&C(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),R),e.registerCommand(l,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),R),e.registerCommand(r,(t=>{const e=t;return null!==d&&null!==I&&null!=d[I]&&(e.preventDefault(),e.stopImmediatePropagation(),A(d[I]),!0)}),R),e.registerCommand(i,(t=>null!==d&&null!==I&&null!=d[I]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),A(d[I]),!0)),R))),[A,t,e,d,I,P,R]);return y(a,h((()=>({options:d,selectOptionAndCleanUp:A,selectedIndex:I,setHighlightedIndex:O})),[A,I,d]),m.match?m.match.matchingString:"")}function O({options:e,nodeKey:n,onClose:o,onOpen:l,onSelectOption:r,menuRenderFn:i,anchorClassName:u,commandPriority:c=s,parent:d}){const[h]=t(),[w,b]=f(null),v=function(e,n,o,l=document.body){const[r]=t(),i=y(document.createElement("div")),s=g((()=>{i.current.style.top=i.current.style.bottom;const t=r.getRootElement(),n=i.current,s=n.firstChild;if(null!==t&&null!==e){const{left:r,top:u,width:c,height:a}=e.getRect(),m=i.current.offsetHeight;if(n.style.top=`${u+m+3}px`,n.style.left=`${r+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,l=e.width,i=t.getBoundingClientRect();r+l>i.right&&(n.style.left=`${i.right-l+window.pageXOffset}px`),(u+o>window.innerHeight||u+o>i.bottom)&&u-i.top>o&&(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",l.append(n)),i.current=n,t.setAttribute("aria-controls","typeahead-menu")}}),[r,e,o,l]);p((()=>{const t=r.getRootElement();if(null!==e)return s(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=i.current;null!==e&&e.isConnected&&e.remove()}}),[r,s,e]);const u=g((t=>{null!==e&&(t||n(null))}),[e,n]);return R(e,i.current,s,u),i}(w,b,u,d),C=g((()=>{b(null),null!=o&&null!==w&&o()}),[o,w]),E=g((t=>{b(t),null!=l&&null===w&&l(t)}),[l,w]),x=g((()=>{n?h.update((()=>{const t=a(n),e=h.getElementByKey(n);var o;null!=t&&null!=e&&null==w&&(o=()=>E({getRect:()=>e.getBoundingClientRect()}),m.startTransition?m.startTransition(o):o())})):null==n&&null!=w&&C()}),[C,h,n,E,w]);return p((()=>{x()}),[x,n]),p((()=>{if(null!=n)return h.registerUpdateListener((({dirtyElements:t})=>{t.get(n)&&x()}))}),[h,x,n]),null===w||null===h?null:m.createElement(I,{close:C,resolution:w,editor:h,anchorElementRef:v,options:e,menuRenderFn:i,onSelectOption:r,commandPriority:c})}export{O as LexicalNodeMenuPlugin,v as MenuOption};
|
|
@@ -4,7 +4,7 @@
|
|
|
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
|
-
import * as modDev from './
|
|
8
|
-
import * as modProd from './
|
|
7
|
+
import * as modDev from './LexicalOnChangePlugin.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalOnChangePlugin.prod.mjs';
|
|
9
9
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
|
-
export const
|
|
10
|
+
export const OnChangePlugin = mod.OnChangePlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalOnChangePlugin.dev.mjs') : import('./LexicalOnChangePlugin.prod.mjs'));
|
|
8
|
+
export const OnChangePlugin = mod.OnChangePlugin;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
import * as modDev from './LexicalPlainTextPlugin.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalPlainTextPlugin.prod.mjs';
|
|
9
|
+
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
|
+
export const PlainTextPlugin = mod.PlainTextPlugin;
|