@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
|
@@ -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
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as modDev from './LexicalTableOfContentsPlugin.dev.mjs';
|
|
10
|
+
import * as modProd from './LexicalTableOfContentsPlugin.prod.mjs';
|
|
11
|
+
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
12
|
+
export const TableOfContentsPlugin = mod.TableOfContentsPlugin;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalTableOfContentsPlugin.dev.mjs') : import('./LexicalTableOfContentsPlugin.prod.mjs'));
|
|
10
|
+
export const TableOfContentsPlugin = mod.TableOfContentsPlugin;
|
|
@@ -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
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';var h=require("@lexical/react/LexicalComposerContext"),q=require("@lexical/rich-text"),v=require("@lexical/utils"),w=require("lexical"),x=require("react");function y(d){return[d.getKey(),d.getTextContent(),d.getTag()]}function z(d,t,n){let e=[],c=y(t);d||e.push(c);for(let r of n)r[0]!==t.getKey()&&(e.push(r),d&&r[0]===d.getKey()&&e.push(c));return e}function B(d){for(d=v.$getNextRightPreorderNode(d);null!==d&&!q.$isHeadingNode(d);)d=v.$getNextRightPreorderNode(d);return d}
|
|
10
|
+
exports.TableOfContentsPlugin=function({children:d}){let [t,n]=x.useState([]),[e]=h.useLexicalComposerContext();x.useEffect(()=>{let c=[];e.getEditorState().read(()=>{let l=w.$getRoot().getChildren();for(let a of l)q.$isHeadingNode(a)&&c.push([a.getKey(),a.getTextContent(),a.getTag()]);n(c)});let r=e.registerUpdateListener(({editorState:l,dirtyElements:a})=>{l.read(()=>{const f=b=>{for(const g of b.getChildren())q.$isHeadingNode(g)?(b=B(g),c=z(b,g,c),n(c)):w.$isElementNode(g)&&f(g)};w.$getRoot().getChildren().forEach(b=>
|
|
11
|
+
{w.$isElementNode(b)&&a.get(b.__key)&&f(b)})})}),C=e.registerMutationListener(q.HeadingNode,l=>{e.getEditorState().read(()=>{for(const [g,m]of l)if("created"===m){var a=w.$getNodeByKey(g);if(null!==a)a:{var f=B(a),b=c;if(null===a){c=b;break a}let k=y(a),u=[];if(null===f){if(0<b.length&&b[0][0]===a.__key){c=b;break a}u=[k,...b]}else for(let p=0;p<b.length;p++){let A=b[p][0];u.push(b[p]);if(A===f.getKey()&&A!==a.getKey()){if(p+1<b.length&&b[p+1][0]===a.__key){c=b;break a}u.push(k)}}c=u}}else if("destroyed"===
|
|
12
|
+
m){f=g;a=c;b=[];for(let k of a)k[0]!==f&&b.push(k);c=b}else"updated"===m&&(f=w.$getNodeByKey(g),null!==f&&(a=B(f),c=z(a,f,c)));n(c)})}),D=e.registerMutationListener(w.TextNode,l=>{e.getEditorState().read(()=>{for(const [b,g]of l)if("updated"===g){var a=w.$getNodeByKey(b);if(null!==a&&(a=a.getParentOrThrow(),q.$isHeadingNode(a))){var f=c;let m=[];for(let k of f)k[0]===a.getKey()?m.push(y(a)):m.push(k);c=m;n(c)}}})});return()=>{C();D();r()}},[e]);return d(t,e)}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{$isHeadingNode as e,HeadingNode as r}from"@lexical/rich-text";import{$getNextRightPreorderNode as n}from"@lexical/utils";import{$getRoot as o,$isElementNode as i,$getNodeByKey as s,TextNode as f}from"lexical";import{useState as c,useEffect as l}from"react";function u(t){return[t.getKey(),t.getTextContent(),t.getTag()]}function g(t,e,r){if(null===e)return r;const n=u(e);let o=[];if(null===t){if(r.length>0&&r[0][0]===e.__key)return r;o=[n,...r]}else for(let i=0;i<r.length;i++){const s=r[i][0];if(o.push(r[i]),s===t.getKey()&&s!==e.getKey()){if(i+1<r.length&&r[i+1][0]===e.__key)return r;o.push(n)}}return o}function a(t,e){const r=[];for(const n of e)n[0]!==t&&r.push(n);return r}function d(t,e){const r=[];for(const n of e)n[0]===t.getKey()?r.push(u(t)):r.push(n);return r}function h(t,e,r){const n=[],o=u(e);t||n.push(o);for(const i of r)i[0]!==e.getKey()&&(n.push(i),t&&i[0]===t.getKey()&&n.push(o));return n}function p(t){let r=n(t);for(;null!==r&&!e(r);)r=n(r);return r}function m({children:n}){const[u,m]=c([]),[y]=t();return l((()=>{let t=[];y.getEditorState().read((()=>{const r=o().getChildren();for(const n of r)e(n)&&t.push([n.getKey(),n.getTextContent(),n.getTag()]);m(t)}));const n=y.registerUpdateListener((({editorState:r,dirtyElements:n})=>{r.read((()=>{const r=n=>{for(const o of n.getChildren())if(e(o)){const e=p(o);t=h(e,o,t),m(t)}else i(o)&&r(o)};o().getChildren().forEach((t=>{i(t)&&n.get(t.__key)&&r(t)}))}))})),c=y.registerMutationListener(r,(e=>{y.getEditorState().read((()=>{for(const[r,n]of e)if("created"===n){const e=s(r);if(null!==e){const r=p(e);t=g(r,e,t)}}else if("destroyed"===n)t=a(r,t);else if("updated"===n){const e=s(r);if(null!==e){const r=p(e);t=h(r,e,t)}}m(t)}))})),l=y.registerMutationListener(f,(r=>{y.getEditorState().read((()=>{for(const[n,o]of r)if("updated"===o){const r=s(n);if(null!==r){const n=r.getParentOrThrow();e(n)&&(t=d(n,t),m(t))}}}))}));return()=>{c(),l(),n()}}),[y]),n(u,y)}export{m as TableOfContentsPlugin};
|
|
@@ -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');
|
|
@@ -19,6 +21,7 @@ var react = require('react');
|
|
|
19
21
|
* LICENSE file in the root directory of this source tree.
|
|
20
22
|
*
|
|
21
23
|
*/
|
|
24
|
+
|
|
22
25
|
function TablePlugin({
|
|
23
26
|
hasCellMerge = true,
|
|
24
27
|
hasCellBackgroundColor = true,
|
|
@@ -31,7 +34,7 @@ function TablePlugin({
|
|
|
31
34
|
throw Error(`TablePlugin: TableNode, TableCellNode or TableRowNode not registered on editor`);
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
|
-
return editor.registerCommand(table.INSERT_TABLE_COMMAND, ({
|
|
37
|
+
return utils.mergeRegister(editor.registerCommand(table.INSERT_TABLE_COMMAND, ({
|
|
35
38
|
columns,
|
|
36
39
|
rows,
|
|
37
40
|
includeHeaders
|
|
@@ -43,7 +46,30 @@ function TablePlugin({
|
|
|
43
46
|
firstDescendant.select();
|
|
44
47
|
}
|
|
45
48
|
return true;
|
|
46
|
-
}, lexical.COMMAND_PRIORITY_EDITOR)
|
|
49
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerNodeTransform(table.TableNode, node => {
|
|
50
|
+
const [gridMap] = table.$computeTableMapSkipCellCheck(node, null, null);
|
|
51
|
+
const maxRowLength = gridMap.reduce((curLength, row) => {
|
|
52
|
+
return Math.max(curLength, row.length);
|
|
53
|
+
}, 0);
|
|
54
|
+
for (let i = 0; i < gridMap.length; ++i) {
|
|
55
|
+
const rowLength = gridMap[i].length;
|
|
56
|
+
if (rowLength === maxRowLength) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const lastCellMap = gridMap[i][rowLength - 1];
|
|
60
|
+
const lastRowCell = lastCellMap.cell;
|
|
61
|
+
for (let j = rowLength; j < maxRowLength; ++j) {
|
|
62
|
+
// TODO: inherit header state from another header or body
|
|
63
|
+
const newCell = table.$createTableCellNode(0);
|
|
64
|
+
newCell.append(lexical.$createParagraphNode());
|
|
65
|
+
if (lastRowCell !== null) {
|
|
66
|
+
lastRowCell.insertAfter(newCell);
|
|
67
|
+
} else {
|
|
68
|
+
utils.$insertFirst(lastRowCell, newCell);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
47
73
|
}, [editor]);
|
|
48
74
|
react.useEffect(() => {
|
|
49
75
|
const tableSelections = new Map();
|
|
@@ -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
|
-
import { TableNode, TableCellNode, TableRowNode, INSERT_TABLE_COMMAND, $createTableNodeWithDimensions, $isTableNode, $getNodeTriplet, $computeTableMap, $isTableRowNode, $isTableCellNode,
|
|
9
|
-
import { $insertNodeToNearestRoot, $insertFirst } from '@lexical/utils';
|
|
10
|
-
import { $isTextNode, COMMAND_PRIORITY_EDITOR, $nodesOfType, $getNodeByKey } from 'lexical';
|
|
10
|
+
import { TableNode, TableCellNode, TableRowNode, INSERT_TABLE_COMMAND, $createTableNodeWithDimensions, $computeTableMapSkipCellCheck, $createTableCellNode, $isTableNode, $getNodeTriplet, $computeTableMap, $isTableRowNode, $isTableCellNode, applyTableHandlers } from '@lexical/table';
|
|
11
|
+
import { mergeRegister, $insertNodeToNearestRoot, $insertFirst } from '@lexical/utils';
|
|
12
|
+
import { $isTextNode, COMMAND_PRIORITY_EDITOR, $createParagraphNode, $nodesOfType, $getNodeByKey } from 'lexical';
|
|
11
13
|
import { useEffect } from 'react';
|
|
12
14
|
|
|
13
15
|
/**
|
|
@@ -17,6 +19,7 @@ import { useEffect } from 'react';
|
|
|
17
19
|
* LICENSE file in the root directory of this source tree.
|
|
18
20
|
*
|
|
19
21
|
*/
|
|
22
|
+
|
|
20
23
|
function TablePlugin({
|
|
21
24
|
hasCellMerge = true,
|
|
22
25
|
hasCellBackgroundColor = true,
|
|
@@ -29,7 +32,7 @@ function TablePlugin({
|
|
|
29
32
|
throw Error(`TablePlugin: TableNode, TableCellNode or TableRowNode not registered on editor`);
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
|
-
return editor.registerCommand(INSERT_TABLE_COMMAND, ({
|
|
35
|
+
return mergeRegister(editor.registerCommand(INSERT_TABLE_COMMAND, ({
|
|
33
36
|
columns,
|
|
34
37
|
rows,
|
|
35
38
|
includeHeaders
|
|
@@ -41,7 +44,30 @@ function TablePlugin({
|
|
|
41
44
|
firstDescendant.select();
|
|
42
45
|
}
|
|
43
46
|
return true;
|
|
44
|
-
}, COMMAND_PRIORITY_EDITOR)
|
|
47
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerNodeTransform(TableNode, node => {
|
|
48
|
+
const [gridMap] = $computeTableMapSkipCellCheck(node, null, null);
|
|
49
|
+
const maxRowLength = gridMap.reduce((curLength, row) => {
|
|
50
|
+
return Math.max(curLength, row.length);
|
|
51
|
+
}, 0);
|
|
52
|
+
for (let i = 0; i < gridMap.length; ++i) {
|
|
53
|
+
const rowLength = gridMap[i].length;
|
|
54
|
+
if (rowLength === maxRowLength) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const lastCellMap = gridMap[i][rowLength - 1];
|
|
58
|
+
const lastRowCell = lastCellMap.cell;
|
|
59
|
+
for (let j = rowLength; j < maxRowLength; ++j) {
|
|
60
|
+
// TODO: inherit header state from another header or body
|
|
61
|
+
const newCell = $createTableCellNode(0);
|
|
62
|
+
newCell.append($createParagraphNode());
|
|
63
|
+
if (lastRowCell !== null) {
|
|
64
|
+
lastRowCell.insertAfter(newCell);
|
|
65
|
+
} else {
|
|
66
|
+
$insertFirst(lastRowCell, newCell);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
45
71
|
}, [editor]);
|
|
46
72
|
useEffect(() => {
|
|
47
73
|
const tableSelections = new Map();
|
package/LexicalTablePlugin.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 LexicalTablePlugin = process.env.NODE_ENV === 'development' ? require('./LexicalTablePlugin.dev.js') : require('./LexicalTablePlugin.prod.js');
|
|
9
11
|
module.exports = LexicalTablePlugin;
|
package/LexicalTablePlugin.mjs
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import * as modDev from './LexicalTablePlugin.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalTablePlugin.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('./LexicalTablePlugin.dev.mjs') : import('./LexicalTablePlugin.prod.mjs'));
|
|
8
10
|
export const TablePlugin = mod.TablePlugin;
|
|
@@ -3,9 +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
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
a[
|
|
8
|
+
|
|
9
|
+
'use strict';var c=require("@lexical/react/LexicalComposerContext"),q=require("@lexical/table"),r=require("@lexical/utils"),t=require("lexical"),u=require("react"),v;function y(l){let m=new URLSearchParams;m.append("code",l);for(let n=1;n<arguments.length;n++)m.append("v",arguments[n]);throw Error(`Minified Lexical error #${l}; visit https://lexical.dev/docs/error?${m} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
|
|
10
|
+
v=y&&y.__esModule&&Object.prototype.hasOwnProperty.call(y,"default")?y["default"]:y;
|
|
11
|
+
exports.TablePlugin=function({hasCellMerge:l=!0,hasCellBackgroundColor:m=!0,hasTabHandler:n=!0}){let [g]=c.useLexicalComposerContext();u.useEffect(()=>{g.hasNodes([q.TableNode,q.TableCellNode,q.TableRowNode])||v(10);return r.mergeRegister(g.registerCommand(q.INSERT_TABLE_COMMAND,({columns:a,rows:e,includeHeaders:f})=>{a=q.$createTableNodeWithDimensions(Number(e),Number(a),f);r.$insertNodeToNearestRoot(a);a=a.getFirstDescendant();t.$isTextNode(a)&&a.select();return!0},t.COMMAND_PRIORITY_EDITOR),g.registerNodeTransform(q.TableNode,
|
|
12
|
+
a=>{[a]=q.$computeTableMapSkipCellCheck(a,null,null);let e=a.reduce((b,d)=>Math.max(b,d.length),0);for(let b=0;b<a.length;++b){var f=a[b].length;if(f===e)continue;let d=a[b][f-1].cell;for(;f<e;++f){let h=q.$createTableCellNode(0);h.append(t.$createParagraphNode());null!==d?d.insertAfter(h):r.$insertFirst(d,h)}}}))},[g]);u.useEffect(()=>{let a=new Map,e=b=>{const d=b.getKey(),h=g.getElementByKey(d);h&&!a.has(d)&&(b=q.applyTableHandlers(b,h,g,n),a.set(d,b))};g.getEditorState().read(()=>{let b=t.$nodesOfType(q.TableNode);
|
|
13
|
+
for(let d of b)q.$isTableNode(d)&&e(d)});let f=g.registerMutationListener(q.TableNode,b=>{for(const [d,h]of b)"created"===h?g.getEditorState().read(()=>{const k=t.$getNodeByKey(d);q.$isTableNode(k)&&e(k)}):"destroyed"===h&&(b=a.get(d),void 0!==b&&(b.removeListeners(),a.delete(d)))});return()=>{f();for(let [,b]of a)b.removeListeners()}},[g,n]);u.useEffect(()=>{if(!l)return g.registerNodeTransform(q.TableCellNode,a=>{if(1<a.getColSpan()||1<a.getRowSpan()){var [,,e]=q.$getNodeTriplet(a);[a]=q.$computeTableMap(e,
|
|
14
|
+
a,a);let b=a.length,d=a[0].length;e=e.getFirstChild();q.$isTableRowNode(e)||v(175);let h=[];for(let k=0;k<b;k++){0!==k&&(e=e.getNextSibling(),q.$isTableRowNode(e)||v(175));let x=null;for(let w=0;w<d;w++){var f=a[k][w];let p=f.cell;if(f.startRow===k&&f.startColumn===w)x=p,h.push(p);else if(1<p.getColSpan()||1<p.getRowSpan())q.$isTableCellNode(p)||v(176),f=q.$createTableCellNode(p.__headerState),null!==x?x.insertAfter(f):r.$insertFirst(e,f)}}for(let k of h)k.setColSpan(1),k.setRowSpan(1)}})},[g,l]);
|
|
15
|
+
u.useEffect(()=>{if(!m)return g.registerNodeTransform(q.TableCellNode,a=>{null!==a.getBackgroundColor()&&a.setBackgroundColor(null)})},[g,m,l]);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{TableNode as t,TableCellNode as r,TableRowNode as o,INSERT_TABLE_COMMAND as n,$createTableNodeWithDimensions as l,$computeTableMapSkipCellCheck as s,$createTableCellNode as a,$isTableNode as i,$getNodeTriplet as c,$computeTableMap as f,$isTableRowNode as d,$isTableCellNode as u,applyTableHandlers as g}from"@lexical/table";import{mergeRegister as m,$insertNodeToNearestRoot as p,$insertFirst as h}from"@lexical/utils";import{$isTextNode as C,COMMAND_PRIORITY_EDITOR as x,$createParagraphNode as S,$nodesOfType as w,$getNodeByKey as v}from"lexical";import{useEffect as N}from"react";function b(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var y=b((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 L({hasCellMerge:b=!0,hasCellBackgroundColor:L=!0,hasTabHandler:M=!0}){const[R]=e();return N((()=>(R.hasNodes([t,r,o])||y(10),m(R.registerCommand(n,(({columns:e,rows:t,includeHeaders:r})=>{const o=l(Number(t),Number(e),r);p(o);const n=o.getFirstDescendant();return C(n)&&n.select(),!0}),x),R.registerNodeTransform(t,(e=>{const[t]=s(e,null,null),r=t.reduce(((e,t)=>Math.max(e,t.length)),0);for(let e=0;e<t.length;++e){const o=t[e].length;if(o===r)continue;const n=t[e][o-1].cell;for(let e=o;e<r;++e){const e=a(0);e.append(S()),null!==n?n.insertAfter(e):h(n,e)}}}))))),[R]),N((()=>{const e=new Map,r=t=>{const r=t.getKey(),o=R.getElementByKey(r);if(o&&!e.has(r)){const n=g(t,o,R,M);e.set(r,n)}};R.getEditorState().read((()=>{const e=w(t);for(const t of e)i(t)&&r(t)}));const o=R.registerMutationListener(t,(t=>{for(const[o,n]of t)if("created"===n)R.getEditorState().read((()=>{const e=v(o);i(e)&&r(e)}));else if("destroyed"===n){const t=e.get(o);void 0!==t&&(t.removeListeners(),e.delete(o))}}));return()=>{o();for(const[,t]of e)t.removeListeners()}}),[R,M]),N((()=>{if(!b)return R.registerNodeTransform(r,(e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=c(e),[r]=f(t,e,e),o=r.length,n=r[0].length;let l=t.getFirstChild();d(l)||y(175);const s=[];for(let e=0;e<o;e++){0!==e&&(l=l.getNextSibling(),d(l)||y(175));let t=null;for(let o=0;o<n;o++){const n=r[e][o],i=n.cell;if(n.startRow===e&&n.startColumn===o)t=i,s.push(i);else if(i.getColSpan()>1||i.getRowSpan()>1){u(i)||y(176);const e=a(i.__headerState);null!==t?t.insertAfter(e):h(l,e)}}}for(const e of s)e.setColSpan(1),e.setRowSpan(1)}}))}),[R,b]),N((()=>{if(!L)return R.registerNodeTransform(r,(e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)}))}),[R,L,b]),null}export{L as TablePlugin};
|
package/LexicalTreeView.d.ts
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
/// <reference types="react" />
|
|
9
9
|
import type { LexicalEditor } from 'lexical';
|
|
10
|
-
|
|
10
|
+
import { CustomPrintNodeFn } from '@lexical/devtools-core';
|
|
11
|
+
export declare function TreeView({ treeTypeButtonClassName, timeTravelButtonClassName, timeTravelPanelSliderClassName, timeTravelPanelButtonClassName, viewClassName, timeTravelPanelClassName, editor, customPrintNode, }: {
|
|
11
12
|
editor: LexicalEditor;
|
|
12
13
|
treeTypeButtonClassName: string;
|
|
13
14
|
timeTravelButtonClassName: string;
|
|
@@ -15,4 +16,5 @@ export declare function TreeView({ treeTypeButtonClassName, timeTravelButtonClas
|
|
|
15
16
|
timeTravelPanelClassName: string;
|
|
16
17
|
timeTravelPanelSliderClassName: string;
|
|
17
18
|
viewClassName: string;
|
|
19
|
+
customPrintNode?: CustomPrintNodeFn;
|
|
18
20
|
}): JSX.Element;
|
package/LexicalTreeView.dev.js
CHANGED
|
@@ -3,12 +3,28 @@
|
|
|
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 devtoolsCore = require('@lexical/devtools-core');
|
|
10
12
|
var utils = require('@lexical/utils');
|
|
11
13
|
var React = require('react');
|
|
14
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
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);
|
|
12
28
|
|
|
13
29
|
/**
|
|
14
30
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -17,6 +33,7 @@ var React = require('react');
|
|
|
17
33
|
* LICENSE file in the root directory of this source tree.
|
|
18
34
|
*
|
|
19
35
|
*/
|
|
36
|
+
|
|
20
37
|
function TreeView({
|
|
21
38
|
treeTypeButtonClassName,
|
|
22
39
|
timeTravelButtonClassName,
|
|
@@ -24,9 +41,10 @@ function TreeView({
|
|
|
24
41
|
timeTravelPanelButtonClassName,
|
|
25
42
|
viewClassName,
|
|
26
43
|
timeTravelPanelClassName,
|
|
27
|
-
editor
|
|
44
|
+
editor,
|
|
45
|
+
customPrintNode
|
|
28
46
|
}) {
|
|
29
|
-
const treeElementRef = /*#__PURE__*/
|
|
47
|
+
const treeElementRef = /*#__PURE__*/React__namespace.createRef();
|
|
30
48
|
const [editorCurrentState, setEditorCurrentState] = React.useState(editor.getEditorState());
|
|
31
49
|
const commandsLog = devtoolsCore.useLexicalCommandsLog(editor);
|
|
32
50
|
React.useEffect(() => {
|
|
@@ -56,7 +74,7 @@ function TreeView({
|
|
|
56
74
|
}
|
|
57
75
|
rootElement.contentEditable = isReadonly ? 'false' : 'true';
|
|
58
76
|
};
|
|
59
|
-
return /*#__PURE__*/
|
|
77
|
+
return /*#__PURE__*/jsxRuntime.jsx(devtoolsCore.TreeView, {
|
|
60
78
|
treeTypeButtonClassName: treeTypeButtonClassName,
|
|
61
79
|
timeTravelButtonClassName: timeTravelButtonClassName,
|
|
62
80
|
timeTravelPanelSliderClassName: timeTravelPanelSliderClassName,
|
|
@@ -67,7 +85,7 @@ function TreeView({
|
|
|
67
85
|
editorState: editorCurrentState,
|
|
68
86
|
setEditorState: state => editor.setEditorState(state),
|
|
69
87
|
generateContent: async function (exportDOM) {
|
|
70
|
-
return devtoolsCore.generateContent(editor, commandsLog, exportDOM);
|
|
88
|
+
return devtoolsCore.generateContent(editor, commandsLog, exportDOM, customPrintNode);
|
|
71
89
|
},
|
|
72
90
|
ref: treeElementRef
|
|
73
91
|
});
|
package/LexicalTreeView.dev.mjs
CHANGED
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import { useLexicalCommandsLog, TreeView as TreeView$1, generateContent } from '@lexical/devtools-core';
|
|
8
10
|
import { mergeRegister } from '@lexical/utils';
|
|
9
11
|
import * as React from 'react';
|
|
10
12
|
import { useState, useEffect } from 'react';
|
|
13
|
+
import { jsx } from 'react/jsx-runtime';
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -16,6 +19,7 @@ import { useState, useEffect } from 'react';
|
|
|
16
19
|
* LICENSE file in the root directory of this source tree.
|
|
17
20
|
*
|
|
18
21
|
*/
|
|
22
|
+
|
|
19
23
|
function TreeView({
|
|
20
24
|
treeTypeButtonClassName,
|
|
21
25
|
timeTravelButtonClassName,
|
|
@@ -23,7 +27,8 @@ function TreeView({
|
|
|
23
27
|
timeTravelPanelButtonClassName,
|
|
24
28
|
viewClassName,
|
|
25
29
|
timeTravelPanelClassName,
|
|
26
|
-
editor
|
|
30
|
+
editor,
|
|
31
|
+
customPrintNode
|
|
27
32
|
}) {
|
|
28
33
|
const treeElementRef = /*#__PURE__*/React.createRef();
|
|
29
34
|
const [editorCurrentState, setEditorCurrentState] = useState(editor.getEditorState());
|
|
@@ -55,7 +60,7 @@ function TreeView({
|
|
|
55
60
|
}
|
|
56
61
|
rootElement.contentEditable = isReadonly ? 'false' : 'true';
|
|
57
62
|
};
|
|
58
|
-
return /*#__PURE__*/
|
|
63
|
+
return /*#__PURE__*/jsx(TreeView$1, {
|
|
59
64
|
treeTypeButtonClassName: treeTypeButtonClassName,
|
|
60
65
|
timeTravelButtonClassName: timeTravelButtonClassName,
|
|
61
66
|
timeTravelPanelSliderClassName: timeTravelPanelSliderClassName,
|
|
@@ -66,7 +71,7 @@ function TreeView({
|
|
|
66
71
|
editorState: editorCurrentState,
|
|
67
72
|
setEditorState: state => editor.setEditorState(state),
|
|
68
73
|
generateContent: async function (exportDOM) {
|
|
69
|
-
return generateContent(editor, commandsLog, exportDOM);
|
|
74
|
+
return generateContent(editor, commandsLog, exportDOM, customPrintNode);
|
|
70
75
|
},
|
|
71
76
|
ref: treeElementRef
|
|
72
77
|
});
|
package/LexicalTreeView.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 LexicalTreeView = process.env.NODE_ENV === 'development' ? require('./LexicalTreeView.dev.js') : require('./LexicalTreeView.prod.js');
|
|
9
11
|
module.exports = LexicalTreeView;
|
package/LexicalTreeView.js.flow
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import type {CustomPrintNodeFn} from '@lexical/devtools-core';
|
|
10
11
|
import type {LexicalEditor} from 'lexical';
|
|
11
12
|
|
|
12
13
|
declare export function TreeView(props: {
|
|
@@ -16,4 +17,5 @@ declare export function TreeView(props: {
|
|
|
16
17
|
timeTravelButtonClassName: string,
|
|
17
18
|
viewClassName: string,
|
|
18
19
|
editor: LexicalEditor,
|
|
20
|
+
customPrintNode?: CustomPrintNodeFn,
|
|
19
21
|
}): React$Node;
|
package/LexicalTreeView.mjs
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import * as modDev from './LexicalTreeView.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalTreeView.prod.mjs';
|
|
9
11
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
package/LexicalTreeView.node.mjs
CHANGED
|
@@ -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('./LexicalTreeView.dev.mjs') : import('./LexicalTreeView.prod.mjs'));
|
|
8
10
|
export const TreeView = mod.TreeView;
|
package/LexicalTreeView.prod.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
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
'use strict';var c=require("@lexical/devtools-core"),d=require("@lexical/utils"),e=require("react"),g=require("react/jsx-runtime"),l=Object.create(null);if(e)for(var m in e)l[m]=e[m];l.default=e;
|
|
10
|
+
exports.TreeView=function({treeTypeButtonClassName:n,timeTravelButtonClassName:p,timeTravelPanelSliderClassName:q,timeTravelPanelButtonClassName:r,viewClassName:t,timeTravelPanelClassName:u,editor:a,customPrintNode:v}){let f=l.createRef(),[w,h]=e.useState(a.getEditorState()),x=c.useLexicalCommandsLog(a);e.useEffect(()=>d.mergeRegister(a.registerUpdateListener(({editorState:b})=>{h(b)}),a.registerEditableListener(()=>{h(a.getEditorState())})),[a]);e.useEffect(()=>{let b=f.current;if(null!==b)return b.__lexicalEditor=
|
|
11
|
+
a,()=>{b.__lexicalEditor=null}},[a,f]);return g.jsx(c.TreeView,{treeTypeButtonClassName:n,timeTravelButtonClassName:p,timeTravelPanelSliderClassName:q,timeTravelPanelButtonClassName:r,viewClassName:t,timeTravelPanelClassName:u,setEditorReadOnly:b=>{const k=a.getRootElement();null!=k&&(k.contentEditable=b?"false":"true")},editorState:w,setEditorState:b=>a.setEditorState(b),generateContent:async function(b){return c.generateContent(a,x,b,v)},ref:f})}
|
package/LexicalTreeView.prod.mjs
CHANGED
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
import{useLexicalCommandsLog as e,TreeView as t,generateContent as a}from"@lexical/devtools-core";import{mergeRegister as r}from"@lexical/utils";import*as l from"react";import{useState as i,useEffect as s}from"react";import{jsx as o}from"react/jsx-runtime";function n({treeTypeButtonClassName:n,timeTravelButtonClassName:m,timeTravelPanelSliderClassName:u,timeTravelPanelButtonClassName:c,viewClassName:d,timeTravelPanelClassName:C,editor:N,customPrintNode:f}){const v=l.createRef(),[T,E]=i(N.getEditorState()),p=e(N);s((()=>r(N.registerUpdateListener((({editorState:e})=>{E(e)})),N.registerEditableListener((()=>{E(N.getEditorState())})))),[N]),s((()=>{const e=v.current;if(null!==e)return e.__lexicalEditor=N,()=>{e.__lexicalEditor=null}}),[N,v]);return o(t,{treeTypeButtonClassName:n,timeTravelButtonClassName:m,timeTravelPanelSliderClassName:u,timeTravelPanelButtonClassName:c,viewClassName:d,timeTravelPanelClassName:C,setEditorReadOnly:e=>{const t=N.getRootElement();null!=t&&(t.contentEditable=e?"false":"true")},editorState:T,setEditorState:e=>N.setEditorState(e),generateContent:async function(e){return a(N,p,e,f)},ref:v})}export{n as TreeView};
|
|
@@ -3,13 +3,29 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';
|
|
8
10
|
|
|
9
11
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
10
12
|
var lexical = require('lexical');
|
|
11
13
|
var React = require('react');
|
|
12
14
|
var utils = require('@lexical/utils');
|
|
15
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
16
|
+
|
|
17
|
+
function _interopNamespaceDefault(e) {
|
|
18
|
+
var n = Object.create(null);
|
|
19
|
+
if (e) {
|
|
20
|
+
for (var k in e) {
|
|
21
|
+
n[k] = e[k];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
n.default = e;
|
|
25
|
+
return n;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
13
29
|
|
|
14
30
|
/**
|
|
15
31
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -28,8 +44,12 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
28
44
|
* LICENSE file in the root directory of this source tree.
|
|
29
45
|
*
|
|
30
46
|
*/
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// This workaround is no longer necessary in React 19,
|
|
50
|
+
// but we currently support React >=17.x
|
|
51
|
+
// https://github.com/facebook/react/pull/26395
|
|
31
52
|
const useLayoutEffectImpl = CAN_USE_DOM ? React.useLayoutEffect : React.useEffect;
|
|
32
|
-
var useLayoutEffect = useLayoutEffectImpl;
|
|
33
53
|
|
|
34
54
|
/**
|
|
35
55
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -38,6 +58,7 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
38
58
|
* LICENSE file in the root directory of this source tree.
|
|
39
59
|
*
|
|
40
60
|
*/
|
|
61
|
+
|
|
41
62
|
class MenuOption {
|
|
42
63
|
constructor(key) {
|
|
43
64
|
this.key = key;
|
|
@@ -125,7 +146,7 @@ function $splitNodeContainingQuery(match) {
|
|
|
125
146
|
function getScrollParent$1(element, includeHidden) {
|
|
126
147
|
let style = getComputedStyle(element);
|
|
127
148
|
const excludeStaticParent = style.position === 'absolute';
|
|
128
|
-
const overflowRegex =
|
|
149
|
+
const overflowRegex = /(auto|scroll)/;
|
|
129
150
|
if (style.position === 'fixed') {
|
|
130
151
|
return document.body;
|
|
131
152
|
}
|
|
@@ -152,7 +173,7 @@ function useDynamicPositioning(resolution, targetElement, onReposition, onVisibi
|
|
|
152
173
|
React.useEffect(() => {
|
|
153
174
|
if (targetElement != null && resolution != null) {
|
|
154
175
|
const rootElement = editor.getRootElement();
|
|
155
|
-
const rootScrollParent = rootElement != null ? getScrollParent$1(rootElement
|
|
176
|
+
const rootScrollParent = rootElement != null ? getScrollParent$1(rootElement) : document.body;
|
|
156
177
|
let ticking = false;
|
|
157
178
|
let previousIsInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent);
|
|
158
179
|
const handleScroll = function () {
|
|
@@ -224,7 +245,7 @@ function LexicalMenu({
|
|
|
224
245
|
}
|
|
225
246
|
};
|
|
226
247
|
}, [editor]);
|
|
227
|
-
|
|
248
|
+
useLayoutEffectImpl(() => {
|
|
228
249
|
if (options === null) {
|
|
229
250
|
setHighlightedIndex(null);
|
|
230
251
|
} else if (selectedIndex === null) {
|
|
@@ -336,7 +357,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
336
357
|
if (left + menuWidth > rootElementRect.right) {
|
|
337
358
|
containerDiv.style.left = `${rootElementRect.right - menuWidth + window.pageXOffset}px`;
|
|
338
359
|
}
|
|
339
|
-
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight) {
|
|
360
|
+
if ((top + menuHeight > window.innerHeight || top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight + height) {
|
|
340
361
|
containerDiv.style.top = `${top - menuHeight + window.pageYOffset - height}px`;
|
|
341
362
|
}
|
|
342
363
|
}
|
|
@@ -388,6 +409,7 @@ function useMenuAnchorRef(resolution, setResolution, className, parent = documen
|
|
|
388
409
|
* LICENSE file in the root directory of this source tree.
|
|
389
410
|
*
|
|
390
411
|
*/
|
|
412
|
+
|
|
391
413
|
const PUNCTUATION = '\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%\'"~=<>_:;';
|
|
392
414
|
function getTextUpToAnchor(selection) {
|
|
393
415
|
const anchor = selection.anchor;
|
|
@@ -447,8 +469,8 @@ function isSelectionOnEntityBoundary(editor, offset) {
|
|
|
447
469
|
});
|
|
448
470
|
}
|
|
449
471
|
function startTransition(callback) {
|
|
450
|
-
if (
|
|
451
|
-
|
|
472
|
+
if (React__namespace.startTransition) {
|
|
473
|
+
React__namespace.startTransition(callback);
|
|
452
474
|
} else {
|
|
453
475
|
callback();
|
|
454
476
|
}
|
|
@@ -554,7 +576,7 @@ function LexicalTypeaheadMenuPlugin({
|
|
|
554
576
|
removeUpdateListener();
|
|
555
577
|
};
|
|
556
578
|
}, [editor, triggerFn, onQueryChange, resolution, closeTypeahead, openTypeahead]);
|
|
557
|
-
return resolution === null || editor === null ? null : /*#__PURE__*/
|
|
579
|
+
return resolution === null || editor === null ? null : /*#__PURE__*/jsxRuntime.jsx(LexicalMenu, {
|
|
558
580
|
close: closeTypeahead,
|
|
559
581
|
resolution: resolution,
|
|
560
582
|
editor: editor,
|