@lexical/react 0.14.5 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LexicalAutoEmbedPlugin.dev.js +15 -11
- package/LexicalAutoEmbedPlugin.dev.mjs +5 -2
- package/LexicalAutoEmbedPlugin.js +2 -0
- package/LexicalAutoEmbedPlugin.mjs +2 -0
- package/LexicalAutoEmbedPlugin.node.mjs +2 -0
- package/LexicalAutoEmbedPlugin.prod.js +6 -5
- package/LexicalAutoEmbedPlugin.prod.mjs +3 -1
- package/LexicalAutoFocusPlugin.dev.js +3 -0
- package/LexicalAutoFocusPlugin.dev.mjs +3 -0
- package/LexicalAutoFocusPlugin.js +2 -0
- package/LexicalAutoFocusPlugin.mjs +2 -0
- package/LexicalAutoFocusPlugin.node.mjs +2 -0
- package/LexicalAutoFocusPlugin.prod.js +2 -0
- package/LexicalAutoFocusPlugin.prod.mjs +2 -0
- package/LexicalAutoLinkPlugin.dev.js +9 -4
- package/LexicalAutoLinkPlugin.dev.mjs +10 -5
- package/LexicalAutoLinkPlugin.js +2 -0
- package/LexicalAutoLinkPlugin.mjs +2 -0
- package/LexicalAutoLinkPlugin.node.mjs +2 -0
- package/LexicalAutoLinkPlugin.prod.js +12 -10
- package/LexicalAutoLinkPlugin.prod.mjs +3 -1
- package/LexicalBlockWithAlignableContents.dev.js +14 -9
- package/LexicalBlockWithAlignableContents.dev.mjs +11 -7
- package/LexicalBlockWithAlignableContents.js +2 -0
- package/LexicalBlockWithAlignableContents.mjs +2 -0
- package/LexicalBlockWithAlignableContents.node.mjs +2 -0
- package/LexicalBlockWithAlignableContents.prod.js +6 -4
- package/LexicalBlockWithAlignableContents.prod.mjs +3 -1
- package/LexicalCharacterLimitPlugin.dev.js +17 -12
- package/LexicalCharacterLimitPlugin.dev.mjs +12 -8
- package/LexicalCharacterLimitPlugin.js +2 -0
- package/LexicalCharacterLimitPlugin.mjs +2 -0
- package/LexicalCharacterLimitPlugin.node.mjs +2 -0
- package/LexicalCharacterLimitPlugin.prod.js +11 -9
- package/LexicalCharacterLimitPlugin.prod.mjs +3 -1
- package/LexicalCheckListPlugin.dev.js +5 -0
- package/LexicalCheckListPlugin.dev.mjs +5 -0
- package/LexicalCheckListPlugin.js +2 -0
- package/LexicalCheckListPlugin.mjs +2 -0
- package/LexicalCheckListPlugin.node.mjs +2 -0
- package/LexicalCheckListPlugin.prod.js +4 -2
- package/LexicalCheckListPlugin.prod.mjs +3 -1
- package/LexicalClearEditorPlugin.dev.js +9 -2
- package/LexicalClearEditorPlugin.dev.mjs +11 -4
- package/LexicalClearEditorPlugin.js +2 -0
- package/LexicalClearEditorPlugin.mjs +2 -0
- package/LexicalClearEditorPlugin.node.mjs +2 -0
- package/LexicalClearEditorPlugin.prod.js +3 -1
- package/LexicalClearEditorPlugin.prod.mjs +3 -1
- package/LexicalClickableLinkPlugin.d.ts +3 -1
- package/LexicalClickableLinkPlugin.dev.js +17 -15
- package/LexicalClickableLinkPlugin.dev.mjs +16 -15
- package/LexicalClickableLinkPlugin.js +2 -0
- package/LexicalClickableLinkPlugin.js.flow +3 -1
- package/LexicalClickableLinkPlugin.mjs +3 -0
- package/LexicalClickableLinkPlugin.node.mjs +3 -0
- package/LexicalClickableLinkPlugin.prod.js +6 -4
- package/LexicalClickableLinkPlugin.prod.mjs +3 -1
- package/LexicalCollaborationContext.dev.js +3 -0
- package/LexicalCollaborationContext.dev.mjs +3 -0
- package/LexicalCollaborationContext.js +2 -0
- package/LexicalCollaborationContext.mjs +2 -0
- package/LexicalCollaborationContext.node.mjs +2 -0
- package/LexicalCollaborationContext.prod.js +2 -0
- package/LexicalCollaborationContext.prod.mjs +2 -0
- package/LexicalCollaborationPlugin.dev.js +20 -2
- package/LexicalCollaborationPlugin.dev.mjs +6 -1
- package/LexicalCollaborationPlugin.js +2 -0
- package/LexicalCollaborationPlugin.mjs +2 -0
- package/LexicalCollaborationPlugin.node.mjs +2 -0
- package/LexicalCollaborationPlugin.prod.js +12 -10
- package/LexicalCollaborationPlugin.prod.mjs +3 -1
- package/LexicalComposer.dev.js +17 -8
- package/LexicalComposer.dev.mjs +16 -8
- package/LexicalComposer.js +2 -0
- package/LexicalComposer.mjs +2 -0
- package/LexicalComposer.node.mjs +2 -0
- package/LexicalComposer.prod.js +5 -4
- package/LexicalComposer.prod.mjs +3 -1
- package/LexicalComposerContext.dev.js +3 -0
- package/LexicalComposerContext.dev.mjs +3 -0
- package/LexicalComposerContext.js +2 -0
- package/LexicalComposerContext.mjs +2 -0
- package/LexicalComposerContext.node.mjs +2 -0
- package/LexicalComposerContext.prod.js +4 -2
- package/LexicalComposerContext.prod.mjs +3 -1
- package/LexicalContentEditable.dev.js +24 -23
- package/LexicalContentEditable.dev.mjs +22 -22
- package/LexicalContentEditable.js +2 -0
- package/LexicalContentEditable.mjs +2 -0
- package/LexicalContentEditable.node.mjs +2 -0
- package/LexicalContentEditable.prod.js +5 -3
- package/LexicalContentEditable.prod.mjs +3 -1
- package/LexicalContextMenuPlugin.dev.js +29 -7
- package/LexicalContextMenuPlugin.dev.mjs +17 -8
- package/LexicalContextMenuPlugin.js +2 -0
- package/LexicalContextMenuPlugin.js.flow +12 -0
- package/LexicalContextMenuPlugin.mjs +2 -0
- package/LexicalContextMenuPlugin.node.mjs +2 -0
- package/LexicalContextMenuPlugin.prod.js +18 -16
- package/LexicalContextMenuPlugin.prod.mjs +3 -1
- package/LexicalDecoratorBlockNode.d.ts +1 -0
- package/LexicalDecoratorBlockNode.dev.js +6 -0
- package/LexicalDecoratorBlockNode.dev.mjs +6 -0
- package/LexicalDecoratorBlockNode.js +2 -0
- package/LexicalDecoratorBlockNode.mjs +2 -0
- package/LexicalDecoratorBlockNode.node.mjs +2 -0
- package/LexicalDecoratorBlockNode.prod.js +3 -1
- package/LexicalDecoratorBlockNode.prod.mjs +3 -1
- package/LexicalEditorRefPlugin.dev.js +17 -1
- package/LexicalEditorRefPlugin.dev.mjs +3 -0
- package/LexicalEditorRefPlugin.js +2 -0
- package/LexicalEditorRefPlugin.js.flow +19 -0
- package/LexicalEditorRefPlugin.mjs +2 -0
- package/LexicalEditorRefPlugin.node.mjs +2 -0
- package/LexicalEditorRefPlugin.prod.js +3 -1
- package/LexicalEditorRefPlugin.prod.mjs +2 -0
- package/LexicalErrorBoundary.d.ts +3 -1
- package/LexicalErrorBoundary.dev.js +30 -10
- package/LexicalErrorBoundary.dev.mjs +13 -7
- package/LexicalErrorBoundary.js +2 -0
- package/LexicalErrorBoundary.js.flow +4 -1
- package/LexicalErrorBoundary.mjs +3 -0
- package/LexicalErrorBoundary.node.mjs +3 -0
- package/LexicalErrorBoundary.prod.js +6 -4
- package/LexicalErrorBoundary.prod.mjs +3 -1
- package/LexicalHashtagPlugin.dev.js +5 -2
- package/LexicalHashtagPlugin.dev.mjs +5 -2
- package/LexicalHashtagPlugin.js +2 -0
- package/LexicalHashtagPlugin.mjs +2 -0
- package/LexicalHashtagPlugin.node.mjs +2 -0
- package/LexicalHashtagPlugin.prod.js +2 -0
- package/LexicalHashtagPlugin.prod.mjs +2 -0
- package/LexicalHistoryPlugin.dev.js +4 -0
- package/LexicalHistoryPlugin.dev.mjs +4 -0
- package/LexicalHistoryPlugin.js +2 -0
- package/LexicalHistoryPlugin.mjs +2 -0
- package/LexicalHistoryPlugin.node.mjs +2 -0
- package/LexicalHistoryPlugin.prod.js +2 -0
- package/LexicalHistoryPlugin.prod.mjs +2 -0
- package/LexicalHorizontalRuleNode.d.ts +2 -2
- package/LexicalHorizontalRuleNode.dev.js +23 -12
- package/LexicalHorizontalRuleNode.dev.mjs +21 -11
- package/LexicalHorizontalRuleNode.js +2 -0
- package/LexicalHorizontalRuleNode.mjs +2 -0
- package/LexicalHorizontalRuleNode.node.mjs +2 -0
- package/LexicalHorizontalRuleNode.prod.js +7 -5
- package/LexicalHorizontalRuleNode.prod.mjs +3 -1
- package/LexicalHorizontalRulePlugin.dev.js +3 -0
- package/LexicalHorizontalRulePlugin.dev.mjs +3 -0
- package/LexicalHorizontalRulePlugin.js +2 -0
- package/LexicalHorizontalRulePlugin.mjs +2 -0
- package/LexicalHorizontalRulePlugin.node.mjs +2 -0
- package/LexicalHorizontalRulePlugin.prod.js +2 -0
- package/LexicalHorizontalRulePlugin.prod.mjs +2 -0
- package/LexicalLinkPlugin.dev.js +6 -3
- package/LexicalLinkPlugin.dev.mjs +7 -4
- package/LexicalLinkPlugin.js +2 -0
- package/LexicalLinkPlugin.mjs +2 -0
- package/LexicalLinkPlugin.node.mjs +2 -0
- package/LexicalLinkPlugin.prod.js +3 -1
- package/LexicalLinkPlugin.prod.mjs +3 -1
- package/LexicalListPlugin.dev.js +4 -0
- package/LexicalListPlugin.dev.mjs +4 -0
- package/LexicalListPlugin.js +2 -0
- package/LexicalListPlugin.mjs +2 -0
- package/LexicalListPlugin.node.mjs +2 -0
- package/LexicalListPlugin.prod.js +2 -0
- package/LexicalListPlugin.prod.mjs +2 -0
- package/LexicalMarkdownShortcutPlugin.dev.js +3 -0
- package/LexicalMarkdownShortcutPlugin.dev.mjs +3 -0
- package/LexicalMarkdownShortcutPlugin.js +2 -0
- package/LexicalMarkdownShortcutPlugin.mjs +2 -0
- package/LexicalMarkdownShortcutPlugin.node.mjs +2 -0
- package/LexicalMarkdownShortcutPlugin.prod.js +2 -0
- package/LexicalMarkdownShortcutPlugin.prod.mjs +2 -0
- package/LexicalNestedComposer.dev.js +14 -9
- package/LexicalNestedComposer.dev.mjs +8 -4
- package/LexicalNestedComposer.js +2 -0
- package/LexicalNestedComposer.mjs +2 -0
- package/LexicalNestedComposer.node.mjs +2 -0
- package/LexicalNestedComposer.prod.js +7 -5
- package/LexicalNestedComposer.prod.mjs +3 -1
- package/LexicalNodeEventPlugin.dev.js +3 -0
- package/LexicalNodeEventPlugin.dev.mjs +3 -0
- package/LexicalNodeEventPlugin.js +2 -0
- package/LexicalNodeEventPlugin.js.flow +12 -0
- package/LexicalNodeEventPlugin.mjs +2 -0
- package/LexicalNodeEventPlugin.node.mjs +2 -0
- package/LexicalNodeEventPlugin.prod.js +2 -0
- package/LexicalNodeEventPlugin.prod.mjs +2 -0
- package/LexicalNodeMenuPlugin.dev.js +30 -8
- package/LexicalNodeMenuPlugin.dev.mjs +17 -8
- package/LexicalNodeMenuPlugin.js +2 -0
- package/LexicalNodeMenuPlugin.mjs +2 -0
- package/LexicalNodeMenuPlugin.node.mjs +2 -0
- package/LexicalNodeMenuPlugin.prod.js +17 -15
- package/LexicalNodeMenuPlugin.prod.mjs +3 -1
- package/LexicalOnChangePlugin.dev.js +9 -2
- package/LexicalOnChangePlugin.dev.mjs +11 -4
- package/LexicalOnChangePlugin.js +2 -0
- package/LexicalOnChangePlugin.mjs +2 -0
- package/LexicalOnChangePlugin.node.mjs +2 -0
- package/LexicalOnChangePlugin.prod.js +3 -1
- package/LexicalOnChangePlugin.prod.mjs +3 -1
- package/LexicalPlainTextPlugin.dev.js +34 -19
- package/LexicalPlainTextPlugin.dev.mjs +31 -17
- package/LexicalPlainTextPlugin.js +2 -0
- package/LexicalPlainTextPlugin.js.flow +1 -1
- package/LexicalPlainTextPlugin.mjs +2 -0
- package/LexicalPlainTextPlugin.node.mjs +2 -0
- package/LexicalPlainTextPlugin.prod.js +6 -4
- package/LexicalPlainTextPlugin.prod.mjs +3 -1
- package/LexicalRichTextPlugin.dev.js +34 -19
- package/LexicalRichTextPlugin.dev.mjs +31 -17
- package/LexicalRichTextPlugin.js +2 -0
- package/LexicalRichTextPlugin.js.flow +1 -1
- package/LexicalRichTextPlugin.mjs +2 -0
- package/LexicalRichTextPlugin.node.mjs +2 -0
- package/LexicalRichTextPlugin.prod.js +6 -4
- package/LexicalRichTextPlugin.prod.mjs +3 -1
- package/LexicalTabIndentationPlugin.dev.js +5 -2
- package/LexicalTabIndentationPlugin.dev.mjs +5 -2
- package/LexicalTabIndentationPlugin.js +2 -0
- package/LexicalTabIndentationPlugin.mjs +2 -0
- package/LexicalTabIndentationPlugin.node.mjs +2 -0
- package/LexicalTabIndentationPlugin.prod.js +2 -0
- package/LexicalTabIndentationPlugin.prod.mjs +2 -0
- package/LexicalTableOfContents.d.ts +6 -13
- package/LexicalTableOfContents.dev.js +57 -10
- package/LexicalTableOfContents.dev.mjs +58 -11
- package/LexicalTableOfContents.js +2 -0
- package/LexicalTableOfContents.js.flow +3 -7
- package/LexicalTableOfContents.mjs +2 -0
- package/LexicalTableOfContents.node.mjs +2 -0
- package/LexicalTableOfContents.prod.js +6 -4
- package/LexicalTableOfContents.prod.mjs +3 -1
- package/LexicalTableOfContentsPlugin.d.ts +20 -0
- package/LexicalTableOfContentsPlugin.dev.js +198 -0
- package/LexicalTableOfContentsPlugin.dev.mjs +196 -0
- package/LexicalTableOfContentsPlugin.js +11 -0
- package/LexicalTableOfContentsPlugin.js.flow +18 -0
- package/LexicalTableOfContentsPlugin.mjs +12 -0
- package/LexicalTableOfContentsPlugin.node.mjs +10 -0
- package/LexicalTableOfContentsPlugin.prod.js +12 -0
- package/LexicalTableOfContentsPlugin.prod.mjs +9 -0
- package/LexicalTablePlugin.dev.js +28 -2
- package/LexicalTablePlugin.dev.mjs +31 -5
- package/LexicalTablePlugin.js +2 -0
- package/LexicalTablePlugin.mjs +2 -0
- package/LexicalTablePlugin.node.mjs +2 -0
- package/LexicalTablePlugin.prod.js +9 -5
- package/LexicalTablePlugin.prod.mjs +3 -1
- package/LexicalTreeView.d.ts +3 -1
- package/LexicalTreeView.dev.js +22 -4
- package/LexicalTreeView.dev.mjs +8 -3
- package/LexicalTreeView.js +2 -0
- package/LexicalTreeView.js.flow +2 -0
- package/LexicalTreeView.mjs +2 -0
- package/LexicalTreeView.node.mjs +2 -0
- package/LexicalTreeView.prod.js +5 -3
- package/LexicalTreeView.prod.mjs +3 -1
- package/LexicalTypeaheadMenuPlugin.dev.js +30 -8
- package/LexicalTypeaheadMenuPlugin.dev.mjs +17 -8
- package/LexicalTypeaheadMenuPlugin.js +2 -0
- package/LexicalTypeaheadMenuPlugin.mjs +2 -0
- package/LexicalTypeaheadMenuPlugin.node.mjs +2 -0
- package/LexicalTypeaheadMenuPlugin.prod.js +21 -19
- package/LexicalTypeaheadMenuPlugin.prod.mjs +3 -1
- package/package.json +50 -20
- package/shared/useCharacterLimit.d.ts +1 -1
- package/useLexicalEditable.d.ts +11 -1
- package/useLexicalEditable.dev.js +22 -3
- package/useLexicalEditable.dev.mjs +23 -5
- package/useLexicalEditable.js +2 -0
- package/useLexicalEditable.js.flow +4 -1
- package/useLexicalEditable.mjs +4 -1
- package/useLexicalEditable.node.mjs +4 -1
- package/useLexicalEditable.prod.js +4 -2
- package/useLexicalEditable.prod.mjs +3 -1
- package/useLexicalIsTextContentEmpty.dev.js +9 -2
- package/useLexicalIsTextContentEmpty.dev.mjs +11 -4
- package/useLexicalIsTextContentEmpty.js +2 -0
- package/useLexicalIsTextContentEmpty.mjs +2 -0
- package/useLexicalIsTextContentEmpty.node.mjs +2 -0
- package/useLexicalIsTextContentEmpty.prod.js +3 -1
- package/useLexicalIsTextContentEmpty.prod.mjs +3 -1
- package/useLexicalNodeSelection.dev.js +3 -0
- package/useLexicalNodeSelection.dev.mjs +4 -1
- package/useLexicalNodeSelection.js +2 -0
- package/useLexicalNodeSelection.mjs +2 -0
- package/useLexicalNodeSelection.node.mjs +2 -0
- package/useLexicalNodeSelection.prod.js +2 -0
- package/useLexicalNodeSelection.prod.mjs +3 -1
- package/useLexicalSubscription.d.ts +4 -1
- package/useLexicalSubscription.dev.js +12 -3
- package/useLexicalSubscription.dev.mjs +13 -5
- package/useLexicalSubscription.js +2 -0
- package/useLexicalSubscription.js.flow +4 -1
- package/useLexicalSubscription.mjs +4 -1
- package/useLexicalSubscription.node.mjs +4 -1
- package/useLexicalSubscription.prod.js +4 -2
- package/useLexicalSubscription.prod.mjs +3 -1
- package/useLexicalTextEntity.dev.js +3 -0
- package/useLexicalTextEntity.dev.mjs +3 -0
- package/useLexicalTextEntity.js +2 -0
- package/useLexicalTextEntity.mjs +2 -0
- package/useLexicalTextEntity.node.mjs +2 -0
- package/useLexicalTextEntity.prod.js +2 -0
- package/useLexicalTextEntity.prod.mjs +2 -0
|
@@ -3,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 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";import{jsx as b}from"react/jsx-runtime";const v="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?d:p;class C{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const x=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function E(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>o.top&&n.top<o.bottom}function 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=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&l.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t):document.body;let i=!1,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 O=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function I({close:t,editor:e,anchorElementRef:a,resolution:m,options:d,menuRenderFn:y,onSelectOption:b,shouldSplitNodeWithQuery:C=!1,commandPriority:E=s}){const[R,I]=f(null),S=m.match&&m.match.matchingString;p((()=>{I(0)}),[S]);const A=g((n=>{e.update((()=>{const e=null!=m.match&&C?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;b(n,e,t,m.match?m.match.matchingString:"")}))}),[e,C,m.match,b,t]),P=g((t=>{const n=e.getRootElement();null!==n&&(n.setAttribute("aria-activedescendant","typeahead-item-"+t),I(t))}),[e]);p((()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[e]),v((()=>{null===d?I(null):null===R&&P(0)}),[d,R,P]),p((()=>w(e.registerCommand(O,(({option:t})=>!(!t.ref||null==t.ref.current)&&(x(t.ref.current),!0)),E))),[e,P,E]),p((()=>w(e.registerCommand(n,(t=>{const n=t;if(null!==d&&d.length&&null!==R){const t=R!==d.length-1?R+1:0;P(t);const o=d[t];null!=o.ref&&o.ref.current&&e.dispatchCommand(O,{index:t,option:o}),n.preventDefault(),n.stopImmediatePropagation()}return!0}),E),e.registerCommand(o,(t=>{const e=t;if(null!==d&&d.length&&null!==R){const t=0!==R?R-1:d.length-1;P(t);const n=d[t];null!=n.ref&&n.ref.current&&x(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),E),e.registerCommand(l,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),E),e.registerCommand(r,(t=>{const e=t;return null!==d&&null!==R&&null!=d[R]&&(e.preventDefault(),e.stopImmediatePropagation(),A(d[R]),!0)}),E),e.registerCommand(i,(t=>null!==d&&null!==R&&null!=d[R]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),A(d[R]),!0)),E))),[A,t,e,d,R,P,E]);return y(a,h((()=>({options:d,selectOptionAndCleanUp:A,selectedIndex:R,setHighlightedIndex:I})),[A,R,d]),m.match?m.match.matchingString:"")}function S({options:e,nodeKey:n,onClose:o,onOpen:l,onSelectOption:r,menuRenderFn:i,anchorClassName:u,commandPriority:c=s,parent:d}){const[h]=t(),[w,v]=f(null),C=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+window.pageYOffset+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+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",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,v,u,d),x=g((()=>{v(null),null!=o&&null!==w&&o()}),[o,w]),E=g((t=>{v(t),null!=l&&null===w&&l(t)}),[l,w]),O=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&&x()}),[x,h,n,E,w]);return p((()=>{O()}),[O,n]),p((()=>{if(null!=n)return h.registerUpdateListener((({dirtyElements:t})=>{t.get(n)&&O()}))}),[h,O,n]),null===w||null===h?null:b(I,{close:x,resolution:w,editor:h,anchorElementRef:C,options:e,menuRenderFn:i,onSelectOption:r,commandPriority:c})}export{S as LexicalNodeMenuPlugin,C as MenuOption};
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';
|
|
8
10
|
|
|
9
11
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
@@ -26,8 +28,12 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
26
28
|
* LICENSE file in the root directory of this source tree.
|
|
27
29
|
*
|
|
28
30
|
*/
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// This workaround is no longer necessary in React 19,
|
|
34
|
+
// but we currently support React >=17.x
|
|
35
|
+
// https://github.com/facebook/react/pull/26395
|
|
29
36
|
const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
|
|
30
|
-
var useLayoutEffect = useLayoutEffectImpl;
|
|
31
37
|
|
|
32
38
|
/**
|
|
33
39
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -36,13 +42,14 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
36
42
|
* LICENSE file in the root directory of this source tree.
|
|
37
43
|
*
|
|
38
44
|
*/
|
|
45
|
+
|
|
39
46
|
function OnChangePlugin({
|
|
40
47
|
ignoreHistoryMergeTagChange = true,
|
|
41
48
|
ignoreSelectionChange = false,
|
|
42
49
|
onChange
|
|
43
50
|
}) {
|
|
44
51
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
45
|
-
|
|
52
|
+
useLayoutEffectImpl(() => {
|
|
46
53
|
if (onChange) {
|
|
47
54
|
return editor.registerUpdateListener(({
|
|
48
55
|
editorState,
|
|
@@ -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 } from 'react';
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -24,8 +26,12 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
24
26
|
* LICENSE file in the root directory of this source tree.
|
|
25
27
|
*
|
|
26
28
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// This workaround is no longer necessary in React 19,
|
|
32
|
+
// but we currently support React >=17.x
|
|
33
|
+
// https://github.com/facebook/react/pull/26395
|
|
34
|
+
const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
|
|
29
35
|
|
|
30
36
|
/**
|
|
31
37
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -34,13 +40,14 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
34
40
|
* LICENSE file in the root directory of this source tree.
|
|
35
41
|
*
|
|
36
42
|
*/
|
|
43
|
+
|
|
37
44
|
function OnChangePlugin({
|
|
38
45
|
ignoreHistoryMergeTagChange = true,
|
|
39
46
|
ignoreSelectionChange = false,
|
|
40
47
|
onChange
|
|
41
48
|
}) {
|
|
42
49
|
const [editor] = useLexicalComposerContext();
|
|
43
|
-
|
|
50
|
+
useLayoutEffectImpl(() => {
|
|
44
51
|
if (onChange) {
|
|
45
52
|
return editor.registerUpdateListener(({
|
|
46
53
|
editorState,
|
package/LexicalOnChangePlugin.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 LexicalOnChangePlugin = process.env.NODE_ENV === 'development' ? require('./LexicalOnChangePlugin.dev.js') : require('./LexicalOnChangePlugin.prod.js');
|
|
9
11
|
module.exports = LexicalOnChangePlugin;
|
|
@@ -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 './LexicalOnChangePlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalOnChangePlugin.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('./LexicalOnChangePlugin.dev.mjs') : import('./LexicalOnChangePlugin.prod.mjs'));
|
|
8
10
|
export const OnChangePlugin = mod.OnChangePlugin;
|
|
@@ -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 c=require("@lexical/react/LexicalComposerContext"),g=require("react");let h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?g.useLayoutEffect:g.useEffect;
|
|
8
10
|
exports.OnChangePlugin=function({ignoreHistoryMergeTagChange:d=!0,ignoreSelectionChange:e=!1,onChange:a}){let [b]=c.useLexicalComposerContext();h(()=>{if(a)return b.registerUpdateListener(({editorState:k,dirtyElements:l,dirtyLeaves:m,prevEditorState:n,tags:f})=>{e&&0===l.size&&0===m.size||d&&f.has("history-merge")||n.isEmpty()||a(k,b,f)})},[b,d,e,a]);return null}
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useLayoutEffect as t,useEffect as o}from"react";const r="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t:o;function i({ignoreHistoryMergeTagChange:t=!0,ignoreSelectionChange:o=!1,onChange:i}){const[n]=e();return r((()=>{if(i)return n.registerUpdateListener((({editorState:e,dirtyElements:r,dirtyLeaves:a,prevEditorState:d,tags:s})=>{o&&0===r.size&&0===a.size||t&&s.has("history-merge")||d.isEmpty()||i(e,n,s)}))}),[n,t,o,i]),null}export{i as OnChangePlugin};
|
|
@@ -3,15 +3,18 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';
|
|
8
10
|
|
|
9
11
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
10
12
|
var useLexicalEditable = require('@lexical/react/useLexicalEditable');
|
|
11
|
-
var React = require('react');
|
|
12
13
|
var text = require('@lexical/text');
|
|
13
14
|
var utils = require('@lexical/utils');
|
|
15
|
+
var react = require('react');
|
|
14
16
|
var reactDom = require('react-dom');
|
|
17
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
15
18
|
var dragon = require('@lexical/dragon');
|
|
16
19
|
var plainText = require('@lexical/plain-text');
|
|
17
20
|
|
|
@@ -32,8 +35,12 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
32
35
|
* LICENSE file in the root directory of this source tree.
|
|
33
36
|
*
|
|
34
37
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// This workaround is no longer necessary in React 19,
|
|
41
|
+
// but we currently support React >=17.x
|
|
42
|
+
// https://github.com/facebook/react/pull/26395
|
|
43
|
+
const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
|
|
37
44
|
|
|
38
45
|
/**
|
|
39
46
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -42,13 +49,14 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
42
49
|
* LICENSE file in the root directory of this source tree.
|
|
43
50
|
*
|
|
44
51
|
*/
|
|
52
|
+
|
|
45
53
|
function canShowPlaceholderFromCurrentEditorState(editor) {
|
|
46
54
|
const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing()));
|
|
47
55
|
return currentCanShowPlaceholder;
|
|
48
56
|
}
|
|
49
57
|
function useCanShowPlaceholder(editor) {
|
|
50
|
-
const [canShowPlaceholder, setCanShowPlaceholder] =
|
|
51
|
-
|
|
58
|
+
const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
|
|
59
|
+
useLayoutEffectImpl(() => {
|
|
52
60
|
function resetCanShowPlaceholder() {
|
|
53
61
|
const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
|
|
54
62
|
setCanShowPlaceholder(currentCanShowPlaceholder);
|
|
@@ -70,18 +78,19 @@ function useCanShowPlaceholder(editor) {
|
|
|
70
78
|
* LICENSE file in the root directory of this source tree.
|
|
71
79
|
*
|
|
72
80
|
*/
|
|
81
|
+
|
|
73
82
|
function useDecorators(editor, ErrorBoundary) {
|
|
74
|
-
const [decorators, setDecorators] =
|
|
83
|
+
const [decorators, setDecorators] = react.useState(() => editor.getDecorators());
|
|
75
84
|
|
|
76
85
|
// Subscribe to changes
|
|
77
|
-
|
|
86
|
+
useLayoutEffectImpl(() => {
|
|
78
87
|
return editor.registerDecoratorListener(nextDecorators => {
|
|
79
88
|
reactDom.flushSync(() => {
|
|
80
89
|
setDecorators(nextDecorators);
|
|
81
90
|
});
|
|
82
91
|
});
|
|
83
92
|
}, [editor]);
|
|
84
|
-
|
|
93
|
+
react.useEffect(() => {
|
|
85
94
|
// If the content editable mounts before the subscription is added, then
|
|
86
95
|
// nothing will be rendered on initial pass. We can get around that by
|
|
87
96
|
// ensuring that we set the value.
|
|
@@ -89,16 +98,18 @@ function useDecorators(editor, ErrorBoundary) {
|
|
|
89
98
|
}, [editor]);
|
|
90
99
|
|
|
91
100
|
// Return decorators defined as React Portals
|
|
92
|
-
return
|
|
101
|
+
return react.useMemo(() => {
|
|
93
102
|
const decoratedPortals = [];
|
|
94
103
|
const decoratorKeys = Object.keys(decorators);
|
|
95
104
|
for (let i = 0; i < decoratorKeys.length; i++) {
|
|
96
105
|
const nodeKey = decoratorKeys[i];
|
|
97
|
-
const reactDecorator = /*#__PURE__*/
|
|
98
|
-
onError: e => editor._onError(e)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
const reactDecorator = /*#__PURE__*/jsxRuntime.jsx(ErrorBoundary, {
|
|
107
|
+
onError: e => editor._onError(e),
|
|
108
|
+
children: /*#__PURE__*/jsxRuntime.jsx(react.Suspense, {
|
|
109
|
+
fallback: null,
|
|
110
|
+
children: decorators[nodeKey]
|
|
111
|
+
})
|
|
112
|
+
});
|
|
102
113
|
const element = editor.getElementByKey(nodeKey);
|
|
103
114
|
if (element !== null) {
|
|
104
115
|
decoratedPortals.push( /*#__PURE__*/reactDom.createPortal(reactDecorator, element, nodeKey));
|
|
@@ -115,8 +126,9 @@ function useDecorators(editor, ErrorBoundary) {
|
|
|
115
126
|
* LICENSE file in the root directory of this source tree.
|
|
116
127
|
*
|
|
117
128
|
*/
|
|
129
|
+
|
|
118
130
|
function usePlainTextSetup(editor) {
|
|
119
|
-
|
|
131
|
+
useLayoutEffectImpl(() => {
|
|
120
132
|
return utils.mergeRegister(plainText.registerPlainText(editor), dragon.registerDragonSupport(editor));
|
|
121
133
|
|
|
122
134
|
// We only do this for init
|
|
@@ -131,6 +143,7 @@ function usePlainTextSetup(editor) {
|
|
|
131
143
|
* LICENSE file in the root directory of this source tree.
|
|
132
144
|
*
|
|
133
145
|
*/
|
|
146
|
+
|
|
134
147
|
function PlainTextPlugin({
|
|
135
148
|
contentEditable,
|
|
136
149
|
placeholder,
|
|
@@ -139,16 +152,18 @@ function PlainTextPlugin({
|
|
|
139
152
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
140
153
|
const decorators = useDecorators(editor, ErrorBoundary);
|
|
141
154
|
usePlainTextSetup(editor);
|
|
142
|
-
return /*#__PURE__*/
|
|
143
|
-
|
|
144
|
-
|
|
155
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
156
|
+
children: [contentEditable, /*#__PURE__*/jsxRuntime.jsx(Placeholder, {
|
|
157
|
+
content: placeholder
|
|
158
|
+
}), decorators]
|
|
159
|
+
});
|
|
145
160
|
}
|
|
146
161
|
function Placeholder({
|
|
147
162
|
content
|
|
148
163
|
}) {
|
|
149
164
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
150
165
|
const showPlaceholder = useCanShowPlaceholder(editor);
|
|
151
|
-
const editable = useLexicalEditable();
|
|
166
|
+
const editable = useLexicalEditable.useLexicalEditable();
|
|
152
167
|
if (!showPlaceholder) {
|
|
153
168
|
return null;
|
|
154
169
|
}
|
|
@@ -3,14 +3,16 @@
|
|
|
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 useLexicalEditable from '@lexical/react/useLexicalEditable';
|
|
9
|
-
import * as React from 'react';
|
|
10
|
-
import { useLayoutEffect as useLayoutEffect$1, useEffect, useState, useMemo, Suspense } from 'react';
|
|
10
|
+
import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
|
|
11
11
|
import { $canShowPlaceholderCurry } from '@lexical/text';
|
|
12
12
|
import { mergeRegister } from '@lexical/utils';
|
|
13
|
-
import {
|
|
13
|
+
import { useLayoutEffect, useEffect, useState, useMemo, Suspense } from 'react';
|
|
14
|
+
import { flushSync, createPortal } from 'react-dom';
|
|
15
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
14
16
|
import { registerDragonSupport } from '@lexical/dragon';
|
|
15
17
|
import { registerPlainText } from '@lexical/plain-text';
|
|
16
18
|
|
|
@@ -31,8 +33,12 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
31
33
|
* LICENSE file in the root directory of this source tree.
|
|
32
34
|
*
|
|
33
35
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// This workaround is no longer necessary in React 19,
|
|
39
|
+
// but we currently support React >=17.x
|
|
40
|
+
// https://github.com/facebook/react/pull/26395
|
|
41
|
+
const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
|
|
36
42
|
|
|
37
43
|
/**
|
|
38
44
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -41,13 +47,14 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
41
47
|
* LICENSE file in the root directory of this source tree.
|
|
42
48
|
*
|
|
43
49
|
*/
|
|
50
|
+
|
|
44
51
|
function canShowPlaceholderFromCurrentEditorState(editor) {
|
|
45
52
|
const currentCanShowPlaceholder = editor.getEditorState().read($canShowPlaceholderCurry(editor.isComposing()));
|
|
46
53
|
return currentCanShowPlaceholder;
|
|
47
54
|
}
|
|
48
55
|
function useCanShowPlaceholder(editor) {
|
|
49
56
|
const [canShowPlaceholder, setCanShowPlaceholder] = useState(() => canShowPlaceholderFromCurrentEditorState(editor));
|
|
50
|
-
|
|
57
|
+
useLayoutEffectImpl(() => {
|
|
51
58
|
function resetCanShowPlaceholder() {
|
|
52
59
|
const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
|
|
53
60
|
setCanShowPlaceholder(currentCanShowPlaceholder);
|
|
@@ -69,11 +76,12 @@ function useCanShowPlaceholder(editor) {
|
|
|
69
76
|
* LICENSE file in the root directory of this source tree.
|
|
70
77
|
*
|
|
71
78
|
*/
|
|
79
|
+
|
|
72
80
|
function useDecorators(editor, ErrorBoundary) {
|
|
73
81
|
const [decorators, setDecorators] = useState(() => editor.getDecorators());
|
|
74
82
|
|
|
75
83
|
// Subscribe to changes
|
|
76
|
-
|
|
84
|
+
useLayoutEffectImpl(() => {
|
|
77
85
|
return editor.registerDecoratorListener(nextDecorators => {
|
|
78
86
|
flushSync(() => {
|
|
79
87
|
setDecorators(nextDecorators);
|
|
@@ -93,11 +101,13 @@ function useDecorators(editor, ErrorBoundary) {
|
|
|
93
101
|
const decoratorKeys = Object.keys(decorators);
|
|
94
102
|
for (let i = 0; i < decoratorKeys.length; i++) {
|
|
95
103
|
const nodeKey = decoratorKeys[i];
|
|
96
|
-
const reactDecorator = /*#__PURE__*/
|
|
97
|
-
onError: e => editor._onError(e)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
104
|
+
const reactDecorator = /*#__PURE__*/jsx(ErrorBoundary, {
|
|
105
|
+
onError: e => editor._onError(e),
|
|
106
|
+
children: /*#__PURE__*/jsx(Suspense, {
|
|
107
|
+
fallback: null,
|
|
108
|
+
children: decorators[nodeKey]
|
|
109
|
+
})
|
|
110
|
+
});
|
|
101
111
|
const element = editor.getElementByKey(nodeKey);
|
|
102
112
|
if (element !== null) {
|
|
103
113
|
decoratedPortals.push( /*#__PURE__*/createPortal(reactDecorator, element, nodeKey));
|
|
@@ -114,8 +124,9 @@ function useDecorators(editor, ErrorBoundary) {
|
|
|
114
124
|
* LICENSE file in the root directory of this source tree.
|
|
115
125
|
*
|
|
116
126
|
*/
|
|
127
|
+
|
|
117
128
|
function usePlainTextSetup(editor) {
|
|
118
|
-
|
|
129
|
+
useLayoutEffectImpl(() => {
|
|
119
130
|
return mergeRegister(registerPlainText(editor), registerDragonSupport(editor));
|
|
120
131
|
|
|
121
132
|
// We only do this for init
|
|
@@ -130,6 +141,7 @@ function usePlainTextSetup(editor) {
|
|
|
130
141
|
* LICENSE file in the root directory of this source tree.
|
|
131
142
|
*
|
|
132
143
|
*/
|
|
144
|
+
|
|
133
145
|
function PlainTextPlugin({
|
|
134
146
|
contentEditable,
|
|
135
147
|
placeholder,
|
|
@@ -138,9 +150,11 @@ function PlainTextPlugin({
|
|
|
138
150
|
const [editor] = useLexicalComposerContext();
|
|
139
151
|
const decorators = useDecorators(editor, ErrorBoundary);
|
|
140
152
|
usePlainTextSetup(editor);
|
|
141
|
-
return /*#__PURE__*/
|
|
142
|
-
|
|
143
|
-
|
|
153
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
154
|
+
children: [contentEditable, /*#__PURE__*/jsx(Placeholder, {
|
|
155
|
+
content: placeholder
|
|
156
|
+
}), decorators]
|
|
157
|
+
});
|
|
144
158
|
}
|
|
145
159
|
function Placeholder({
|
|
146
160
|
content
|
|
@@ -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 LexicalPlainTextPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalPlainTextPlugin.dev.js') : require('./LexicalPlainTextPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalPlainTextPlugin;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import type {EditorState, LexicalEditor} from 'lexical';
|
|
11
11
|
|
|
12
|
-
import typeof LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary';
|
|
12
|
+
import {typeof LexicalErrorBoundary} from '@lexical/react/LexicalErrorBoundary';
|
|
13
13
|
|
|
14
14
|
import * as React from 'react';
|
|
15
15
|
|
|
@@ -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 './LexicalPlainTextPlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalPlainTextPlugin.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('./LexicalPlainTextPlugin.dev.mjs') : import('./LexicalPlainTextPlugin.prod.mjs'));
|
|
8
10
|
export const PlainTextPlugin = mod.PlainTextPlugin;
|
|
@@ -3,8 +3,10 @@
|
|
|
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
|
-
function
|
|
10
|
-
function
|
|
8
|
+
|
|
9
|
+
'use strict';var e=require("@lexical/react/LexicalComposerContext"),g=require("@lexical/react/useLexicalEditable"),h=require("@lexical/text"),m=require("@lexical/utils"),n=require("react"),p=require("react-dom"),q=require("react/jsx-runtime"),u=require("@lexical/dragon"),v=require("@lexical/plain-text");let w="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?n.useLayoutEffect:n.useEffect;
|
|
10
|
+
function x(a){return a.getEditorState().read(h.$canShowPlaceholderCurry(a.isComposing()))}function y(a){let [c,b]=n.useState(()=>x(a));w(()=>{function d(){let f=x(a);b(f)}d();return m.mergeRegister(a.registerUpdateListener(()=>{d()}),a.registerEditableListener(()=>{d()}))},[a]);return c}
|
|
11
|
+
function z(a,c){let [b,d]=n.useState(()=>a.getDecorators());w(()=>a.registerDecoratorListener(f=>{p.flushSync(()=>{d(f)})}),[a]);n.useEffect(()=>{d(a.getDecorators())},[a]);return n.useMemo(()=>{let f=[],r=Object.keys(b);for(let k=0;k<r.length;k++){let l=r[k],B=q.jsx(c,{onError:A=>a._onError(A),children:q.jsx(n.Suspense,{fallback:null,children:b[l]})}),t=a.getElementByKey(l);null!==t&&f.push(p.createPortal(B,t,l))}return f},[c,b,a])}
|
|
12
|
+
function C(a){w(()=>m.mergeRegister(v.registerPlainText(a),u.registerDragonSupport(a)),[a])}function D({content:a}){var [c]=e.useLexicalComposerContext();c=y(c);let b=g.useLexicalEditable();return c?"function"===typeof a?a(b):a:null}exports.PlainTextPlugin=function({contentEditable:a,placeholder:c,ErrorBoundary:b}){let [d]=e.useLexicalComposerContext();b=z(d,b);C(d);return q.jsxs(q.Fragment,{children:[a,q.jsx(D,{content:c}),b]})}
|
|
@@ -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{useLexicalEditable as e}from"@lexical/react/useLexicalEditable";import{$canShowPlaceholderCurry as r}from"@lexical/text";import{mergeRegister as o}from"@lexical/utils";import{useLayoutEffect as n,useEffect as i,useState as c,useMemo as l,Suspense as a}from"react";import{flushSync as m,createPortal as u}from"react-dom";import{jsx as s,jsxs as d,Fragment as f}from"react/jsx-runtime";import{registerDragonSupport as p}from"@lexical/dragon";import{registerPlainText as x}from"@lexical/plain-text";const g="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?n:i;function E(t){return t.getEditorState().read(r(t.isComposing()))}function h({contentEditable:e,placeholder:r,ErrorBoundary:n}){const[E]=t(),h=function(t,e){const[r,o]=c((()=>t.getDecorators()));return g((()=>t.registerDecoratorListener((t=>{m((()=>{o(t)}))}))),[t]),i((()=>{o(t.getDecorators())}),[t]),l((()=>{const o=[],n=Object.keys(r);for(let i=0;i<n.length;i++){const c=n[i],l=s(e,{onError:e=>t._onError(e),children:s(a,{fallback:null,children:r[c]})}),m=t.getElementByKey(c);null!==m&&o.push(u(l,m,c))}return o}),[e,r,t])}(E,n);return function(t){g((()=>o(x(t),p(t))),[t])}(E),d(f,{children:[e,s(w,{content:r}),h]})}function w({content:r}){const[n]=t(),i=function(t){const[e,r]=c((()=>E(t)));return g((()=>{function e(){const e=E(t);r(e)}return e(),o(t.registerUpdateListener((()=>{e()})),t.registerEditableListener((()=>{e()})))}),[t]),e}(n),l=e();return i?"function"==typeof r?r(l):r:null}export{h as PlainTextPlugin};
|