@lexical/react 0.14.4 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LexicalAutoEmbedPlugin.dev.js +17 -1
- package/LexicalAutoEmbedPlugin.dev.mjs +3 -0
- package/LexicalAutoEmbedPlugin.js +2 -0
- package/LexicalAutoEmbedPlugin.mjs +2 -0
- package/LexicalAutoEmbedPlugin.node.mjs +2 -0
- package/LexicalAutoEmbedPlugin.prod.js +6 -4
- package/LexicalAutoEmbedPlugin.prod.mjs +2 -0
- package/LexicalAutoFocusPlugin.dev.js +3 -0
- package/LexicalAutoFocusPlugin.dev.mjs +3 -0
- package/LexicalAutoFocusPlugin.js +2 -0
- package/LexicalAutoFocusPlugin.mjs +2 -0
- package/LexicalAutoFocusPlugin.node.mjs +2 -0
- package/LexicalAutoFocusPlugin.prod.js +2 -0
- package/LexicalAutoFocusPlugin.prod.mjs +2 -0
- package/LexicalAutoLinkPlugin.dev.js +9 -4
- package/LexicalAutoLinkPlugin.dev.mjs +10 -5
- package/LexicalAutoLinkPlugin.js +2 -0
- package/LexicalAutoLinkPlugin.mjs +2 -0
- package/LexicalAutoLinkPlugin.node.mjs +2 -0
- package/LexicalAutoLinkPlugin.prod.js +12 -10
- package/LexicalAutoLinkPlugin.prod.mjs +3 -1
- package/LexicalBlockWithAlignableContents.dev.js +20 -4
- package/LexicalBlockWithAlignableContents.dev.mjs +6 -3
- package/LexicalBlockWithAlignableContents.js +2 -0
- package/LexicalBlockWithAlignableContents.mjs +2 -0
- package/LexicalBlockWithAlignableContents.node.mjs +2 -0
- package/LexicalBlockWithAlignableContents.prod.js +6 -4
- package/LexicalBlockWithAlignableContents.prod.mjs +2 -0
- package/LexicalCharacterLimitPlugin.dev.js +21 -4
- package/LexicalCharacterLimitPlugin.dev.mjs +7 -3
- package/LexicalCharacterLimitPlugin.js +2 -0
- package/LexicalCharacterLimitPlugin.mjs +2 -0
- package/LexicalCharacterLimitPlugin.node.mjs +2 -0
- package/LexicalCharacterLimitPlugin.prod.js +11 -9
- package/LexicalCharacterLimitPlugin.prod.mjs +3 -1
- package/LexicalCheckListPlugin.dev.js +3 -0
- package/LexicalCheckListPlugin.dev.mjs +3 -0
- package/LexicalCheckListPlugin.js +2 -0
- package/LexicalCheckListPlugin.mjs +2 -0
- package/LexicalCheckListPlugin.node.mjs +2 -0
- package/LexicalCheckListPlugin.prod.js +2 -0
- package/LexicalCheckListPlugin.prod.mjs +2 -0
- package/LexicalClearEditorPlugin.dev.js +5 -2
- package/LexicalClearEditorPlugin.dev.mjs +7 -4
- package/LexicalClearEditorPlugin.js +2 -0
- package/LexicalClearEditorPlugin.mjs +2 -0
- package/LexicalClearEditorPlugin.node.mjs +2 -0
- package/LexicalClearEditorPlugin.prod.js +3 -1
- package/LexicalClearEditorPlugin.prod.mjs +3 -1
- package/LexicalClickableLinkPlugin.dev.js +14 -13
- package/LexicalClickableLinkPlugin.dev.mjs +14 -13
- package/LexicalClickableLinkPlugin.js +2 -0
- package/LexicalClickableLinkPlugin.mjs +2 -0
- package/LexicalClickableLinkPlugin.node.mjs +2 -0
- package/LexicalClickableLinkPlugin.prod.js +5 -4
- package/LexicalClickableLinkPlugin.prod.mjs +3 -1
- package/LexicalCollaborationContext.dev.js +3 -0
- package/LexicalCollaborationContext.dev.mjs +3 -0
- package/LexicalCollaborationContext.js +2 -0
- package/LexicalCollaborationContext.mjs +2 -0
- package/LexicalCollaborationContext.node.mjs +2 -0
- package/LexicalCollaborationContext.prod.js +2 -0
- package/LexicalCollaborationContext.prod.mjs +2 -0
- package/LexicalCollaborationPlugin.dev.js +19 -2
- package/LexicalCollaborationPlugin.dev.mjs +4 -0
- package/LexicalCollaborationPlugin.js +2 -0
- package/LexicalCollaborationPlugin.mjs +2 -0
- package/LexicalCollaborationPlugin.node.mjs +2 -0
- package/LexicalCollaborationPlugin.prod.js +12 -10
- package/LexicalCollaborationPlugin.prod.mjs +2 -0
- package/LexicalComposer.dev.js +19 -3
- package/LexicalComposer.dev.mjs +7 -4
- package/LexicalComposer.js +2 -0
- package/LexicalComposer.mjs +2 -0
- package/LexicalComposer.node.mjs +2 -0
- package/LexicalComposer.prod.js +5 -3
- package/LexicalComposer.prod.mjs +3 -1
- package/LexicalComposerContext.dev.js +3 -0
- package/LexicalComposerContext.dev.mjs +3 -0
- package/LexicalComposerContext.js +2 -0
- package/LexicalComposerContext.mjs +2 -0
- package/LexicalComposerContext.node.mjs +2 -0
- package/LexicalComposerContext.prod.js +4 -2
- package/LexicalComposerContext.prod.mjs +3 -1
- package/LexicalContentEditable.dev.js +18 -3
- package/LexicalContentEditable.dev.mjs +6 -4
- package/LexicalContentEditable.js +2 -0
- package/LexicalContentEditable.mjs +2 -0
- package/LexicalContentEditable.node.mjs +2 -0
- package/LexicalContentEditable.prod.js +6 -3
- package/LexicalContentEditable.prod.mjs +3 -1
- package/LexicalContextMenuPlugin.dev.js +24 -7
- package/LexicalContextMenuPlugin.dev.mjs +11 -7
- package/LexicalContextMenuPlugin.js +2 -0
- package/LexicalContextMenuPlugin.js.flow +12 -0
- package/LexicalContextMenuPlugin.mjs +2 -0
- package/LexicalContextMenuPlugin.node.mjs +2 -0
- package/LexicalContextMenuPlugin.prod.js +18 -16
- package/LexicalContextMenuPlugin.prod.mjs +3 -1
- package/LexicalDecoratorBlockNode.d.ts +1 -0
- package/LexicalDecoratorBlockNode.dev.js +6 -0
- package/LexicalDecoratorBlockNode.dev.mjs +6 -0
- package/LexicalDecoratorBlockNode.js +2 -0
- package/LexicalDecoratorBlockNode.mjs +2 -0
- package/LexicalDecoratorBlockNode.node.mjs +2 -0
- package/LexicalDecoratorBlockNode.prod.js +3 -1
- package/LexicalDecoratorBlockNode.prod.mjs +3 -1
- package/LexicalEditorRefPlugin.dev.js +17 -1
- package/LexicalEditorRefPlugin.dev.mjs +3 -0
- package/LexicalEditorRefPlugin.js +2 -0
- package/LexicalEditorRefPlugin.js.flow +19 -0
- package/LexicalEditorRefPlugin.mjs +2 -0
- package/LexicalEditorRefPlugin.node.mjs +2 -0
- package/LexicalEditorRefPlugin.prod.js +3 -1
- package/LexicalEditorRefPlugin.prod.mjs +2 -0
- package/LexicalErrorBoundary.dev.js +21 -5
- package/LexicalErrorBoundary.dev.mjs +3 -0
- package/LexicalErrorBoundary.js +2 -0
- package/LexicalErrorBoundary.mjs +2 -0
- package/LexicalErrorBoundary.node.mjs +2 -0
- package/LexicalErrorBoundary.prod.js +6 -4
- package/LexicalErrorBoundary.prod.mjs +2 -0
- package/LexicalHashtagPlugin.dev.js +5 -2
- package/LexicalHashtagPlugin.dev.mjs +5 -2
- package/LexicalHashtagPlugin.js +2 -0
- package/LexicalHashtagPlugin.mjs +2 -0
- package/LexicalHashtagPlugin.node.mjs +2 -0
- package/LexicalHashtagPlugin.prod.js +2 -0
- package/LexicalHashtagPlugin.prod.mjs +2 -0
- package/LexicalHistoryPlugin.dev.js +4 -0
- package/LexicalHistoryPlugin.dev.mjs +4 -0
- package/LexicalHistoryPlugin.js +2 -0
- package/LexicalHistoryPlugin.mjs +2 -0
- package/LexicalHistoryPlugin.node.mjs +2 -0
- package/LexicalHistoryPlugin.prod.js +2 -0
- package/LexicalHistoryPlugin.prod.mjs +2 -0
- package/LexicalHorizontalRuleNode.dev.js +22 -6
- package/LexicalHorizontalRuleNode.dev.mjs +8 -5
- package/LexicalHorizontalRuleNode.js +2 -0
- package/LexicalHorizontalRuleNode.mjs +2 -0
- package/LexicalHorizontalRuleNode.node.mjs +2 -0
- package/LexicalHorizontalRuleNode.prod.js +7 -5
- package/LexicalHorizontalRuleNode.prod.mjs +2 -0
- package/LexicalHorizontalRulePlugin.dev.js +3 -0
- package/LexicalHorizontalRulePlugin.dev.mjs +3 -0
- package/LexicalHorizontalRulePlugin.js +2 -0
- package/LexicalHorizontalRulePlugin.mjs +2 -0
- package/LexicalHorizontalRulePlugin.node.mjs +2 -0
- package/LexicalHorizontalRulePlugin.prod.js +2 -0
- package/LexicalHorizontalRulePlugin.prod.mjs +2 -0
- package/LexicalLinkPlugin.dev.js +6 -3
- package/LexicalLinkPlugin.dev.mjs +7 -4
- package/LexicalLinkPlugin.js +2 -0
- package/LexicalLinkPlugin.mjs +2 -0
- package/LexicalLinkPlugin.node.mjs +2 -0
- package/LexicalLinkPlugin.prod.js +3 -1
- package/LexicalLinkPlugin.prod.mjs +3 -1
- package/LexicalListPlugin.dev.js +4 -0
- package/LexicalListPlugin.dev.mjs +4 -0
- package/LexicalListPlugin.js +2 -0
- package/LexicalListPlugin.mjs +2 -0
- package/LexicalListPlugin.node.mjs +2 -0
- package/LexicalListPlugin.prod.js +2 -0
- package/LexicalListPlugin.prod.mjs +2 -0
- package/LexicalMarkdownShortcutPlugin.dev.js +3 -0
- package/LexicalMarkdownShortcutPlugin.dev.mjs +3 -0
- package/LexicalMarkdownShortcutPlugin.js +2 -0
- package/LexicalMarkdownShortcutPlugin.mjs +2 -0
- package/LexicalMarkdownShortcutPlugin.node.mjs +2 -0
- package/LexicalMarkdownShortcutPlugin.prod.js +2 -0
- package/LexicalMarkdownShortcutPlugin.prod.mjs +2 -0
- package/LexicalNestedComposer.dev.js +17 -1
- package/LexicalNestedComposer.dev.mjs +3 -0
- package/LexicalNestedComposer.js +2 -0
- package/LexicalNestedComposer.mjs +2 -0
- package/LexicalNestedComposer.node.mjs +2 -0
- package/LexicalNestedComposer.prod.js +7 -5
- package/LexicalNestedComposer.prod.mjs +3 -1
- package/LexicalNodeEventPlugin.dev.js +3 -0
- package/LexicalNodeEventPlugin.dev.mjs +3 -0
- package/LexicalNodeEventPlugin.js +2 -0
- package/LexicalNodeEventPlugin.js.flow +12 -0
- package/LexicalNodeEventPlugin.mjs +2 -0
- package/LexicalNodeEventPlugin.node.mjs +2 -0
- package/LexicalNodeEventPlugin.prod.js +2 -0
- package/LexicalNodeEventPlugin.prod.mjs +2 -0
- package/LexicalNodeMenuPlugin.dev.js +25 -8
- package/LexicalNodeMenuPlugin.dev.mjs +11 -7
- package/LexicalNodeMenuPlugin.js +2 -0
- package/LexicalNodeMenuPlugin.mjs +2 -0
- package/LexicalNodeMenuPlugin.node.mjs +2 -0
- package/LexicalNodeMenuPlugin.prod.js +17 -15
- package/LexicalNodeMenuPlugin.prod.mjs +3 -1
- package/LexicalOnChangePlugin.dev.js +5 -2
- package/LexicalOnChangePlugin.dev.mjs +7 -4
- package/LexicalOnChangePlugin.js +2 -0
- package/LexicalOnChangePlugin.mjs +2 -0
- package/LexicalOnChangePlugin.node.mjs +2 -0
- package/LexicalOnChangePlugin.prod.js +3 -1
- package/LexicalOnChangePlugin.prod.mjs +3 -1
- package/LexicalPlainTextPlugin.dev.js +26 -7
- package/LexicalPlainTextPlugin.dev.mjs +13 -7
- package/LexicalPlainTextPlugin.js +2 -0
- package/LexicalPlainTextPlugin.mjs +2 -0
- package/LexicalPlainTextPlugin.node.mjs +2 -0
- package/LexicalPlainTextPlugin.prod.js +6 -4
- package/LexicalPlainTextPlugin.prod.mjs +3 -1
- package/LexicalRichTextPlugin.dev.js +26 -7
- package/LexicalRichTextPlugin.dev.mjs +13 -7
- package/LexicalRichTextPlugin.js +2 -0
- package/LexicalRichTextPlugin.mjs +2 -0
- package/LexicalRichTextPlugin.node.mjs +2 -0
- package/LexicalRichTextPlugin.prod.js +6 -4
- package/LexicalRichTextPlugin.prod.mjs +3 -1
- package/LexicalTabIndentationPlugin.dev.js +5 -2
- package/LexicalTabIndentationPlugin.dev.mjs +5 -2
- package/LexicalTabIndentationPlugin.js +2 -0
- package/LexicalTabIndentationPlugin.mjs +2 -0
- package/LexicalTabIndentationPlugin.node.mjs +2 -0
- package/LexicalTabIndentationPlugin.prod.js +2 -0
- package/LexicalTabIndentationPlugin.prod.mjs +2 -0
- package/LexicalTableOfContents.d.ts +1 -1
- package/LexicalTableOfContents.dev.js +47 -8
- package/LexicalTableOfContents.dev.mjs +48 -9
- package/LexicalTableOfContents.js +2 -0
- package/LexicalTableOfContents.mjs +2 -0
- package/LexicalTableOfContents.node.mjs +2 -0
- package/LexicalTableOfContents.prod.js +6 -4
- package/LexicalTableOfContents.prod.mjs +3 -1
- package/LexicalTablePlugin.dev.js +28 -2
- package/LexicalTablePlugin.dev.mjs +31 -5
- package/LexicalTablePlugin.js +2 -0
- package/LexicalTablePlugin.mjs +2 -0
- package/LexicalTablePlugin.node.mjs +2 -0
- package/LexicalTablePlugin.prod.js +9 -5
- package/LexicalTablePlugin.prod.mjs +3 -1
- package/LexicalTreeView.dev.js +18 -2
- package/LexicalTreeView.dev.mjs +3 -0
- package/LexicalTreeView.js +2 -0
- package/LexicalTreeView.mjs +2 -0
- package/LexicalTreeView.node.mjs +2 -0
- package/LexicalTreeView.prod.js +5 -3
- package/LexicalTreeView.prod.mjs +2 -0
- package/LexicalTypeaheadMenuPlugin.dev.js +25 -8
- package/LexicalTypeaheadMenuPlugin.dev.mjs +11 -7
- package/LexicalTypeaheadMenuPlugin.js +2 -0
- package/LexicalTypeaheadMenuPlugin.mjs +2 -0
- package/LexicalTypeaheadMenuPlugin.node.mjs +2 -0
- package/LexicalTypeaheadMenuPlugin.prod.js +21 -19
- package/LexicalTypeaheadMenuPlugin.prod.mjs +3 -1
- package/package.json +20 -19
- package/shared/useCharacterLimit.d.ts +1 -1
- package/useLexicalEditable.dev.js +6 -2
- package/useLexicalEditable.dev.mjs +8 -4
- package/useLexicalEditable.js +2 -0
- package/useLexicalEditable.mjs +2 -0
- package/useLexicalEditable.node.mjs +2 -0
- package/useLexicalEditable.prod.js +3 -1
- package/useLexicalEditable.prod.mjs +3 -1
- package/useLexicalIsTextContentEmpty.dev.js +5 -2
- package/useLexicalIsTextContentEmpty.dev.mjs +7 -4
- package/useLexicalIsTextContentEmpty.js +2 -0
- package/useLexicalIsTextContentEmpty.mjs +2 -0
- package/useLexicalIsTextContentEmpty.node.mjs +2 -0
- package/useLexicalIsTextContentEmpty.prod.js +3 -1
- package/useLexicalIsTextContentEmpty.prod.mjs +3 -1
- package/useLexicalNodeSelection.dev.js +3 -0
- package/useLexicalNodeSelection.dev.mjs +4 -1
- package/useLexicalNodeSelection.js +2 -0
- package/useLexicalNodeSelection.mjs +2 -0
- package/useLexicalNodeSelection.node.mjs +2 -0
- package/useLexicalNodeSelection.prod.js +2 -0
- package/useLexicalNodeSelection.prod.mjs +3 -1
- package/useLexicalSubscription.dev.js +5 -2
- package/useLexicalSubscription.dev.mjs +7 -4
- package/useLexicalSubscription.js +2 -0
- package/useLexicalSubscription.mjs +2 -0
- package/useLexicalSubscription.node.mjs +2 -0
- package/useLexicalSubscription.prod.js +3 -1
- package/useLexicalSubscription.prod.mjs +3 -1
- package/useLexicalTextEntity.dev.js +3 -0
- package/useLexicalTextEntity.dev.mjs +3 -0
- package/useLexicalTextEntity.js +2 -0
- package/useLexicalTextEntity.mjs +2 -0
- package/useLexicalTextEntity.node.mjs +2 -0
- package/useLexicalTextEntity.prod.js +2 -0
- package/useLexicalTextEntity.prod.mjs +2 -0
|
@@ -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('./LexicalNestedComposer.dev.mjs') : import('./LexicalNestedComposer.prod.mjs'));
|
|
8
10
|
export const LexicalNestedComposer = mod.LexicalNestedComposer;
|
|
@@ -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
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
|
|
8
|
+
|
|
9
|
+
'use strict';var b=require("@lexical/react/LexicalCollaborationContext"),h=require("@lexical/react/LexicalComposerContext"),n=require("react"),p=Object.create(null);if(n)for(var t in n)p[t]=n[t];p.default=n;var u;
|
|
10
|
+
function v(a){let k=new URLSearchParams;k.append("code",a);for(let e=1;e<arguments.length;e++)k.append("v",arguments[e]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${k} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}u=v&&v.__esModule&&Object.prototype.hasOwnProperty.call(v,"default")?v["default"]:v;function x(a){a=a.transform();return null!==a?new Set([a]):new Set}
|
|
11
|
+
exports.LexicalNestedComposer=function({initialEditor:a,children:k,initialNodes:e,initialTheme:y,skipCollabChecks:z}){let w=n.useRef(!1),q=n.useContext(h.LexicalComposerContext);null==q&&u(9);let [f,{getTheme:A}]=q,C=n.useMemo(()=>{var d=y||A()||void 0;const B=h.createLexicalComposerContext(q,d);void 0!==d&&(a._config.theme=d);a._parentEditor=f;if(e)for(var c of e){var g=d=null;"function"!==typeof c&&(g=c,c=g.replace,d=g.with,g=g.withKlass||null);const m=a._nodes.get(c.getType());a._nodes.set(c.getType(),
|
|
12
|
+
{exportDOM:m?m.exportDOM:void 0,klass:c,replace:d,replaceWithKlass:g,transforms:x(c)})}else{c=a._nodes=new Map(f._nodes);for(const [m,l]of c)a._nodes.set(m,{exportDOM:l.exportDOM,klass:l.klass,replace:l.replace,replaceWithKlass:l.replaceWithKlass,transforms:x(l.klass)})}a._config.namespace=f._config.namespace;a._editable=f._editable;return[a,B]},[]),{isCollabActive:D,yjsDocMap:E}=b.useCollaborationContext(),r=z||w.current||E.has(a.getKey());n.useEffect(()=>{r&&(w.current=!0)},[r]);n.useEffect(()=>
|
|
13
|
+
f.registerEditableListener(d=>{a.setEditable(d)}),[a,f]);return p.createElement(h.LexicalComposerContext.Provider,{value:C},!D||r?k: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{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 a,useEffect as i}from"react";function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var c=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 p(e){const t=e.transform();return null!==t?new Set([t]):new Set}function f({initialEditor:s,children:f,initialNodes:d,initialTheme:u,skipCollabChecks:m}){const h=n(!1),x=l(t);null==x&&c(9);const[_,{getTheme:g}]=x,v=a((()=>{const e=u||g()||void 0,t=r(x,e);if(void 0!==e&&(s._config.theme=e),s._parentEditor=_,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=s._nodes.get(e.getType());s._nodes.set(e.getType(),{exportDOM:o?o.exportDOM:void 0,klass:e,replace:t,replaceWithKlass:r,transforms:p(e)})}else{const e=s._nodes=new Map(_._nodes);for(const[t,r]of e)s._nodes.set(t,{exportDOM:r.exportDOM,klass:r.klass,replace:r.replace,replaceWithKlass:r.replaceWithKlass,transforms:p(r.klass)})}return s._config.namespace=_._config.namespace,s._editable=_._editable,[s,t]}),[]),{isCollabActive:w,yjsDocMap:b}=e(),M=m||h.current||b.has(s.getKey());return i((()=>{M&&(h.current=!0)}),[M]),i((()=>_.registerEditableListener((e=>{s.setEditable(e)}))),[s,_]),o.createElement(t.Provider,{value:v},!w||M?f:null)}export{f as LexicalNestedComposer};
|
|
@@ -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');
|
|
@@ -18,6 +20,7 @@ var react = require('react');
|
|
|
18
20
|
* LICENSE file in the root directory of this source tree.
|
|
19
21
|
*
|
|
20
22
|
*/
|
|
23
|
+
|
|
21
24
|
const capturedEvents = new Set(['mouseenter', 'mouseleave']);
|
|
22
25
|
function NodeEventPlugin({
|
|
23
26
|
nodeType,
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
8
10
|
import { $findMatchingParent } from '@lexical/utils';
|
|
9
11
|
import { $getNearestNodeFromDOMNode } from 'lexical';
|
|
@@ -16,6 +18,7 @@ import { useRef, useEffect } from 'react';
|
|
|
16
18
|
* LICENSE file in the root directory of this source tree.
|
|
17
19
|
*
|
|
18
20
|
*/
|
|
21
|
+
|
|
19
22
|
const capturedEvents = new Set(['mouseenter', 'mouseleave']);
|
|
20
23
|
function NodeEventPlugin({
|
|
21
24
|
nodeType,
|
|
@@ -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 LexicalNodeEventPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalNodeEventPlugin.dev.js') : require('./LexicalNodeEventPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalNodeEventPlugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* LexicalNodeEventPlugin
|
|
12
|
+
*/
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import * as modDev from './LexicalNodeEventPlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalNodeEventPlugin.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('./LexicalNodeEventPlugin.dev.mjs') : import('./LexicalNodeEventPlugin.prod.mjs'));
|
|
8
10
|
export const NodeEventPlugin = mod.NodeEventPlugin;
|
|
@@ -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
|
'use strict';var g=require("@lexical/react/LexicalComposerContext"),m=require("@lexical/utils"),n=require("lexical"),p=require("react");let q=new Set(["mouseenter","mouseleave"]);
|
|
8
10
|
exports.NodeEventPlugin=function({nodeType:d,eventType:e,eventListener:h}){let [c]=g.useLexicalComposerContext(),k=p.useRef(h);k.current=h;p.useEffect(()=>{let f=q.has(e),l=b=>{c.update(()=>{var a=n.$getNearestNodeFromDOMNode(b.target);null!==a&&(a=f?a instanceof d?a:null:m.$findMatchingParent(a,r=>r instanceof d),null!==a&&k.current(b,c,a.getKey()))})};return c.registerRootListener((b,a)=>{b&&b.addEventListener(e,l,f);a&&a.removeEventListener(e,l,f)})},[c,d]);return null}
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as t}from"@lexical/utils";import{$getNearestNodeFromDOMNode as n}from"lexical";import{useRef as r,useEffect as o}from"react";const i=new Set(["mouseenter","mouseleave"]);function l({nodeType:l,eventType:s,eventListener:c}){const[u]=e(),a=r(c);return a.current=c,o((()=>{const e=i.has(s),r=r=>{u.update((()=>{const o=n(r.target);if(null!==o){const n=e?o instanceof l?o:null:t(o,(e=>e instanceof l));if(null!==n)return void a.current(r,u,n.getKey())}}))};return u.registerRootListener(((t,n)=>{t&&t.addEventListener(s,r,e),n&&n.removeEventListener(s,r,e)}))}),[u,l]),null}export{l as NodeEventPlugin};
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';
|
|
8
10
|
|
|
9
11
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
@@ -11,6 +13,19 @@ var lexical = require('lexical');
|
|
|
11
13
|
var React = require('react');
|
|
12
14
|
var utils = require('@lexical/utils');
|
|
13
15
|
|
|
16
|
+
function _interopNamespaceDefault(e) {
|
|
17
|
+
var n = Object.create(null);
|
|
18
|
+
if (e) {
|
|
19
|
+
for (var k in e) {
|
|
20
|
+
n[k] = e[k];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return n;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
28
|
+
|
|
14
29
|
/**
|
|
15
30
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
16
31
|
*
|
|
@@ -28,8 +43,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
28
43
|
* LICENSE file in the root directory of this source tree.
|
|
29
44
|
*
|
|
30
45
|
*/
|
|
46
|
+
|
|
31
47
|
const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
|
|
32
|
-
var useLayoutEffect = useLayoutEffectImpl;
|
|
33
48
|
|
|
34
49
|
/**
|
|
35
50
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -38,6 +53,7 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
38
53
|
* LICENSE file in the root directory of this source tree.
|
|
39
54
|
*
|
|
40
55
|
*/
|
|
56
|
+
|
|
41
57
|
class MenuOption {
|
|
42
58
|
constructor(key) {
|
|
43
59
|
this.key = key;
|
|
@@ -125,7 +141,7 @@ function $splitNodeContainingQuery(match) {
|
|
|
125
141
|
function getScrollParent(element, includeHidden) {
|
|
126
142
|
let style = getComputedStyle(element);
|
|
127
143
|
const excludeStaticParent = style.position === 'absolute';
|
|
128
|
-
const overflowRegex =
|
|
144
|
+
const overflowRegex = /(auto|scroll)/;
|
|
129
145
|
if (style.position === 'fixed') {
|
|
130
146
|
return document.body;
|
|
131
147
|
}
|
|
@@ -152,7 +168,7 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
|
|
|
152
168
|
React.useEffect(() => {
|
|
153
169
|
if (targetElement != null && resolution != null) {
|
|
154
170
|
const rootElement = editor.getRootElement();
|
|
155
|
-
const rootScrollParent = rootElement != null ? getScrollParent(rootElement
|
|
171
|
+
const rootScrollParent = rootElement != null ? getScrollParent(rootElement) : document.body;
|
|
156
172
|
let ticking = false;
|
|
157
173
|
let previousIsInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent);
|
|
158
174
|
const handleScroll = function () {
|
|
@@ -224,7 +240,7 @@ function LexicalMenu({
|
|
|
224
240
|
}
|
|
225
241
|
};
|
|
226
242
|
}, [editor]);
|
|
227
|
-
|
|
243
|
+
useLayoutEffectImpl(() => {
|
|
228
244
|
if (options === null) {
|
|
229
245
|
setHighlightedIndex(null);
|
|
230
246
|
} else if (selectedIndex === null) {
|
|
@@ -336,7 +352,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
336
352
|
if (left + menuWidth > rootElementRect.right) {
|
|
337
353
|
containerDiv.style.left = `${rootElementRect.right - menuWidth + window.pageXOffset}px`;
|
|
338
354
|
}
|
|
339
|
-
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight) {
|
|
355
|
+
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight + height) {
|
|
340
356
|
containerDiv.style.top = `${top - menuHeight + window.pageYOffset - height}px`;
|
|
341
357
|
}
|
|
342
358
|
}
|
|
@@ -388,9 +404,10 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
388
404
|
* LICENSE file in the root directory of this source tree.
|
|
389
405
|
*
|
|
390
406
|
*/
|
|
407
|
+
|
|
391
408
|
function startTransition(callback) {
|
|
392
|
-
if (
|
|
393
|
-
|
|
409
|
+
if (React__namespace.startTransition) {
|
|
410
|
+
React__namespace.startTransition(callback);
|
|
394
411
|
} else {
|
|
395
412
|
callback();
|
|
396
413
|
}
|
|
@@ -452,7 +469,7 @@ function LexicalNodeMenuPlugin({
|
|
|
452
469
|
});
|
|
453
470
|
}
|
|
454
471
|
}, [editor, positionOrCloseMenu, nodeKey]);
|
|
455
|
-
return resolution === null || editor === null ? null : /*#__PURE__*/
|
|
472
|
+
return resolution === null || editor === null ? null : /*#__PURE__*/React__namespace.createElement(LexicalMenu, {
|
|
456
473
|
close: closeNodeMenu,
|
|
457
474
|
resolution: resolution,
|
|
458
475
|
editor: editor,
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
8
10
|
import { createCommand, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW, $getSelection, $isRangeSelection, $getNodeByKey } from 'lexical';
|
|
9
11
|
import * as React from 'react';
|
|
10
|
-
import { useLayoutEffect
|
|
12
|
+
import { useLayoutEffect, useEffect, useState, useCallback, useMemo, useRef } from 'react';
|
|
11
13
|
import { mergeRegister } from '@lexical/utils';
|
|
12
14
|
|
|
13
15
|
/**
|
|
@@ -27,8 +29,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
27
29
|
* LICENSE file in the root directory of this source tree.
|
|
28
30
|
*
|
|
29
31
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
|
|
33
|
+
const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
36
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -37,6 +39,7 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
37
39
|
* LICENSE file in the root directory of this source tree.
|
|
38
40
|
*
|
|
39
41
|
*/
|
|
42
|
+
|
|
40
43
|
class MenuOption {
|
|
41
44
|
constructor(key) {
|
|
42
45
|
this.key = key;
|
|
@@ -124,7 +127,7 @@ function $splitNodeContainingQuery(match) {
|
|
|
124
127
|
function getScrollParent(element, includeHidden) {
|
|
125
128
|
let style = getComputedStyle(element);
|
|
126
129
|
const excludeStaticParent = style.position === 'absolute';
|
|
127
|
-
const overflowRegex =
|
|
130
|
+
const overflowRegex = /(auto|scroll)/;
|
|
128
131
|
if (style.position === 'fixed') {
|
|
129
132
|
return document.body;
|
|
130
133
|
}
|
|
@@ -151,7 +154,7 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
|
|
|
151
154
|
useEffect(() => {
|
|
152
155
|
if (targetElement != null && resolution != null) {
|
|
153
156
|
const rootElement = editor.getRootElement();
|
|
154
|
-
const rootScrollParent = rootElement != null ? getScrollParent(rootElement
|
|
157
|
+
const rootScrollParent = rootElement != null ? getScrollParent(rootElement) : document.body;
|
|
155
158
|
let ticking = false;
|
|
156
159
|
let previousIsInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent);
|
|
157
160
|
const handleScroll = function () {
|
|
@@ -223,7 +226,7 @@ function LexicalMenu({
|
|
|
223
226
|
}
|
|
224
227
|
};
|
|
225
228
|
}, [editor]);
|
|
226
|
-
|
|
229
|
+
useLayoutEffectImpl(() => {
|
|
227
230
|
if (options === null) {
|
|
228
231
|
setHighlightedIndex(null);
|
|
229
232
|
} else if (selectedIndex === null) {
|
|
@@ -335,7 +338,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
335
338
|
if (left + menuWidth > rootElementRect.right) {
|
|
336
339
|
containerDiv.style.left = `${rootElementRect.right - menuWidth + window.pageXOffset}px`;
|
|
337
340
|
}
|
|
338
|
-
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight) {
|
|
341
|
+
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight + height) {
|
|
339
342
|
containerDiv.style.top = `${top - menuHeight + window.pageYOffset - height}px`;
|
|
340
343
|
}
|
|
341
344
|
}
|
|
@@ -387,6 +390,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
387
390
|
* LICENSE file in the root directory of this source tree.
|
|
388
391
|
*
|
|
389
392
|
*/
|
|
393
|
+
|
|
390
394
|
function startTransition(callback) {
|
|
391
395
|
if (React.startTransition) {
|
|
392
396
|
React.startTransition(callback);
|
package/LexicalNodeMenuPlugin.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 LexicalNodeMenuPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalNodeMenuPlugin.dev.js') : require('./LexicalNodeMenuPlugin.prod.js');
|
|
9
11
|
module.exports = LexicalNodeMenuPlugin;
|
|
@@ -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 './LexicalNodeMenuPlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalNodeMenuPlugin.prod.mjs';
|
|
9
11
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalNodeMenuPlugin.dev.mjs') : import('./LexicalNodeMenuPlugin.prod.mjs'));
|
|
8
10
|
export const LexicalNodeMenuPlugin = mod.LexicalNodeMenuPlugin;
|
|
9
11
|
export const MenuOption = mod.MenuOption;
|
|
@@ -3,19 +3,21 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
function F(b
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
a.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
|
|
9
|
+
'use strict';var k=require("@lexical/react/LexicalComposerContext"),t=require("lexical"),x=require("react"),y=require("@lexical/utils"),z=Object.create(null);if(x)for(var A in x)z[A]=x[A];z.default=x;let B="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?x.useLayoutEffect:x.useEffect;class C{constructor(b){this.key=b;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(b){this.ref={current:b}}}
|
|
10
|
+
let D=b=>{const a=document.getElementById("typeahead-menu");if(a){var f=a.getBoundingClientRect();f.top+f.height>window.innerHeight&&a.scrollIntoView({block:"center"});0>f.top&&a.scrollIntoView({block:"center"});b.scrollIntoView({block:"nearest"})}};
|
|
11
|
+
function E(b){var a=t.$getSelection();if(!t.$isRangeSelection(a)||!a.isCollapsed())return null;var f=a.anchor;if("text"!==f.type)return null;a=f.getNode();if(!a.isSimpleText())return null;f=f.offset;let l=a.getTextContent().slice(0,f);var e=b.matchingString;b=b.replaceableString.length;for(let n=b;n<=e.length;n++)l.substr(-n)===e.substr(0,n)&&(b=n);b=f-b;if(0>b)return null;let p;0===b?[p]=a.splitText(f):[,p]=a.splitText(b,f);return p}
|
|
12
|
+
function F(b){let a=getComputedStyle(b),f="absolute"===a.position,l=/(auto|scroll)/;if("fixed"===a.position)return document.body;for(;b=b.parentElement;)if(a=getComputedStyle(b),(!f||"static"!==a.position)&&l.test(a.overflow+a.overflowY+a.overflowX))return b;return document.body}function G(b,a){b=b.getBoundingClientRect();a=a.getBoundingClientRect();return b.top>a.top&&b.top<a.bottom}
|
|
13
|
+
function H(b,a,f,l){let [e]=k.useLexicalComposerContext();x.useEffect(()=>{if(null!=a&&null!=b){let p=e.getRootElement(),n=null!=p?F(p):document.body,w=!1,m=G(a,n),c=function(){w||(window.requestAnimationFrame(function(){f();w=!1}),w=!0);const q=G(a,n);q!==m&&(m=q,null!=l&&l(q))},g=new ResizeObserver(f);window.addEventListener("resize",f);document.addEventListener("scroll",c,{capture:!0,passive:!0});g.observe(a);return()=>{g.unobserve(a);window.removeEventListener("resize",f);document.removeEventListener("scroll",
|
|
14
|
+
c,!0)}}},[a,e,l,f,b])}let I=t.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
|
|
15
|
+
function J({close:b,editor:a,anchorElementRef:f,resolution:l,options:e,menuRenderFn:p,onSelectOption:n,shouldSplitNodeWithQuery:w=!1,commandPriority:m=t.COMMAND_PRIORITY_LOW}){let [c,g]=x.useState(null);x.useEffect(()=>{g(0)},[l.match&&l.match.matchingString]);let q=x.useCallback(d=>{a.update(()=>{const h=null!=l.match&&w?E(l.match):null;n(d,h,b,l.match?l.match.matchingString:"")})},[a,w,l.match,n,b]),r=x.useCallback(d=>{const h=a.getRootElement();null!==h&&(h.setAttribute("aria-activedescendant",
|
|
16
|
+
"typeahead-item-"+d),g(d))},[a]);x.useEffect(()=>()=>{let d=a.getRootElement();null!==d&&d.removeAttribute("aria-activedescendant")},[a]);B(()=>{null===e?g(null):null===c&&r(0)},[e,c,r]);x.useEffect(()=>y.mergeRegister(a.registerCommand(I,({option:d})=>d.ref&&null!=d.ref.current?(D(d.ref.current),!0):!1,m)),[a,r,m]);x.useEffect(()=>y.mergeRegister(a.registerCommand(t.KEY_ARROW_DOWN_COMMAND,d=>{if(null!==e&&e.length&&null!==c){let h=c!==e.length-1?c+1:0;r(h);let u=e[h];null!=u.ref&&u.ref.current&&
|
|
17
|
+
a.dispatchCommand(I,{index:h,option:u});d.preventDefault();d.stopImmediatePropagation()}return!0},m),a.registerCommand(t.KEY_ARROW_UP_COMMAND,d=>{if(null!==e&&e.length&&null!==c){var h=0!==c?c-1:e.length-1;r(h);h=e[h];null!=h.ref&&h.ref.current&&D(h.ref.current);d.preventDefault();d.stopImmediatePropagation()}return!0},m),a.registerCommand(t.KEY_ESCAPE_COMMAND,d=>{d.preventDefault();d.stopImmediatePropagation();b();return!0},m),a.registerCommand(t.KEY_TAB_COMMAND,d=>{if(null===e||null===c||null==
|
|
18
|
+
e[c])return!1;d.preventDefault();d.stopImmediatePropagation();q(e[c]);return!0},m),a.registerCommand(t.KEY_ENTER_COMMAND,d=>{if(null===e||null===c||null==e[c])return!1;null!==d&&(d.preventDefault(),d.stopImmediatePropagation());q(e[c]);return!0},m)),[q,b,a,e,c,r,m]);let v=x.useMemo(()=>({options:e,selectOptionAndCleanUp:q,selectedIndex:c,setHighlightedIndex:g}),[q,c,e]);return p(f,v,l.match?l.match.matchingString:"")}
|
|
19
|
+
function K(b,a,f,l=document.body){let [e]=k.useLexicalComposerContext(),p=x.useRef(document.createElement("div")),n=x.useCallback(()=>{p.current.style.top=p.current.style.bottom;const m=e.getRootElement(),c=p.current;var g=c.firstChild;if(null!==m&&null!==b){const {left:r,top:v,width:d,height:h}=b.getRect();c.style.top=`${v+window.pageYOffset+p.current.offsetHeight+3}px`;c.style.left=`${r+window.pageXOffset}px`;c.style.height=`${h}px`;c.style.width=`${d}px`;if(null!==g){g.style.top=`${v}`;var q=g.getBoundingClientRect();
|
|
20
|
+
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+h&&(c.style.top=`${v-g+window.pageYOffset-h}px`)}c.isConnected||(null!=f&&(c.className=f),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")}},
|
|
21
|
+
[e,b,f,l]);x.useEffect(()=>{let m=e.getRootElement();if(null!==b)return n(),()=>{null!==m&&m.removeAttribute("aria-controls");let c=p.current;null!==c&&c.isConnected&&c.remove()}},[e,n,b]);let w=x.useCallback(m=>{null!==b&&(m||a(null))},[b,a]);H(b,p.current,n,w);return p}function L(b){z.startTransition?z.startTransition(b):b()}
|
|
22
|
+
exports.LexicalNodeMenuPlugin=function({options:b,nodeKey:a,onClose:f,onOpen:l,onSelectOption:e,menuRenderFn:p,anchorClassName:n,commandPriority:w=t.COMMAND_PRIORITY_LOW,parent:m}){let [c]=k.useLexicalComposerContext(),[g,q]=x.useState(null);n=K(g,q,n,m);let r=x.useCallback(()=>{q(null);null!=f&&null!==g&&f()},[f,g]),v=x.useCallback(h=>{q(h);null!=l&&null===g&&l(h)},[l,g]),d=x.useCallback(()=>{a?c.update(()=>{const h=t.$getNodeByKey(a),u=c.getElementByKey(a);null!=h&&null!=u&&null==g&&L(()=>v({getRect:()=>
|
|
23
|
+
u.getBoundingClientRect()}))}):null==a&&null!=g&&r()},[r,c,a,v,g]);x.useEffect(()=>{d()},[d,a]);x.useEffect(()=>{if(null!=a)return c.registerUpdateListener(({dirtyElements:h})=>{h.get(a)&&d()})},[c,d,a]);return null===g||null===c?null:z.createElement(J,{close:r,resolution:g,editor:c,anchorElementRef:n,options:b,menuRenderFn:p,onSelectOption:e,commandPriority:w})};exports.MenuOption=C
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
import{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";const 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=/(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 x=e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function O({close:t,editor:e,anchorElementRef:a,resolution:m,options:d,menuRenderFn:y,onSelectOption:v,shouldSplitNodeWithQuery:E=!1,commandPriority:R=s}){const[O,I]=f(null),S=m.match&&m.match.matchingString;p((()=>{I(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),I(t))}),[e]);p((()=>()=>{const t=e.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[e]),b((()=>{null===d?I(null):null===O&&P(0)}),[d,O,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!==O){const t=O!==d.length-1?O+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!==O){const t=0!==O?O-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!==O&&null!=d[O]&&(e.preventDefault(),e.stopImmediatePropagation(),A(d[O]),!0)}),R),e.registerCommand(i,(t=>null!==d&&null!==O&&null!=d[O]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),A(d[O]),!0)),R))),[A,t,e,d,O,P,R]);return y(a,h((()=>({options:d,selectOptionAndCleanUp:A,selectedIndex:O,setHighlightedIndex:I})),[A,O,d]),m.match?m.match.matchingString:"")}function I({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+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,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(O,{close:C,resolution:w,editor:h,anchorElementRef:v,options:e,menuRenderFn:i,onSelectOption:r,commandPriority:c})}export{I as LexicalNodeMenuPlugin,v 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,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
26
28
|
* LICENSE file in the root directory of this source tree.
|
|
27
29
|
*
|
|
28
30
|
*/
|
|
31
|
+
|
|
29
32
|
const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
|
|
30
|
-
var useLayoutEffect = useLayoutEffectImpl;
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -36,13 +38,14 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
36
38
|
* LICENSE file in the root directory of this source tree.
|
|
37
39
|
*
|
|
38
40
|
*/
|
|
41
|
+
|
|
39
42
|
function OnChangePlugin({
|
|
40
43
|
ignoreHistoryMergeTagChange = true,
|
|
41
44
|
ignoreSelectionChange = false,
|
|
42
45
|
onChange
|
|
43
46
|
}) {
|
|
44
47
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
45
|
-
|
|
48
|
+
useLayoutEffectImpl(() => {
|
|
46
49
|
if (onChange) {
|
|
47
50
|
return editor.registerUpdateListener(({
|
|
48
51
|
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,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
24
26
|
* LICENSE file in the root directory of this source tree.
|
|
25
27
|
*
|
|
26
28
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
|
|
30
|
+
const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect : useEffect;
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -34,13 +36,14 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
34
36
|
* LICENSE file in the root directory of this source tree.
|
|
35
37
|
*
|
|
36
38
|
*/
|
|
39
|
+
|
|
37
40
|
function OnChangePlugin({
|
|
38
41
|
ignoreHistoryMergeTagChange = true,
|
|
39
42
|
ignoreSelectionChange = false,
|
|
40
43
|
onChange
|
|
41
44
|
}) {
|
|
42
45
|
const [editor] = useLexicalComposerContext();
|
|
43
|
-
|
|
46
|
+
useLayoutEffectImpl(() => {
|
|
44
47
|
if (onChange) {
|
|
45
48
|
return editor.registerUpdateListener(({
|
|
46
49
|
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};
|