@lexical/react 0.14.2 → 0.14.4
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 +2 -2
- package/{LexicalAutoEmbedPlugin.dev.esm.js → LexicalAutoEmbedPlugin.dev.mjs} +2 -2
- package/{LexicalAutoEmbedPlugin.esm.js → LexicalAutoEmbedPlugin.mjs} +2 -2
- package/LexicalAutoEmbedPlugin.node.mjs +11 -0
- package/LexicalAutoEmbedPlugin.prod.js +2 -2
- package/{LexicalAutoEmbedPlugin.prod.esm.js → LexicalAutoEmbedPlugin.prod.mjs} +1 -1
- package/{LexicalHashtagPlugin.esm.js → LexicalAutoFocusPlugin.mjs} +3 -3
- package/LexicalAutoFocusPlugin.node.mjs +8 -0
- package/{LexicalAutoLinkPlugin.esm.js → LexicalAutoLinkPlugin.mjs} +2 -2
- package/LexicalAutoLinkPlugin.node.mjs +9 -0
- package/{LexicalBlockWithAlignableContents.esm.js → LexicalBlockWithAlignableContents.mjs} +2 -2
- package/LexicalBlockWithAlignableContents.node.mjs +8 -0
- package/{LexicalClearEditorPlugin.esm.js → LexicalCharacterLimitPlugin.mjs} +3 -3
- package/LexicalCharacterLimitPlugin.node.mjs +8 -0
- package/LexicalCheckListPlugin.dev.js +1 -1
- package/{LexicalCheckListPlugin.dev.esm.js → LexicalCheckListPlugin.dev.mjs} +2 -2
- package/LexicalCheckListPlugin.mjs +10 -0
- package/LexicalCheckListPlugin.node.mjs +8 -0
- package/LexicalCheckListPlugin.prod.js +1 -1
- package/LexicalCheckListPlugin.prod.mjs +7 -0
- package/LexicalClearEditorPlugin.dev.js +3 -0
- package/{LexicalClearEditorPlugin.dev.esm.js → LexicalClearEditorPlugin.dev.mjs} +4 -1
- package/{LexicalCheckListPlugin.esm.js → LexicalClearEditorPlugin.mjs} +3 -3
- package/LexicalClearEditorPlugin.node.mjs +8 -0
- package/LexicalClearEditorPlugin.prod.js +2 -2
- package/LexicalClearEditorPlugin.prod.mjs +7 -0
- package/LexicalClickableLinkPlugin.d.ts +2 -1
- package/LexicalClickableLinkPlugin.dev.js +8 -3
- package/{LexicalClickableLinkPlugin.dev.esm.js → LexicalClickableLinkPlugin.dev.mjs} +8 -3
- package/LexicalClickableLinkPlugin.mjs +10 -0
- package/LexicalClickableLinkPlugin.node.mjs +8 -0
- package/LexicalClickableLinkPlugin.prod.js +4 -3
- package/LexicalClickableLinkPlugin.prod.mjs +7 -0
- package/{LexicalCollaborationContext.esm.js → LexicalCollaborationContext.mjs} +2 -2
- package/LexicalCollaborationContext.node.mjs +9 -0
- package/LexicalCollaborationPlugin.mjs +10 -0
- package/LexicalCollaborationPlugin.node.mjs +8 -0
- package/{LexicalListPlugin.esm.js → LexicalComposer.mjs} +3 -3
- package/LexicalComposer.node.mjs +8 -0
- package/{LexicalComposerContext.esm.js → LexicalComposerContext.mjs} +2 -2
- package/LexicalComposerContext.node.mjs +10 -0
- package/LexicalContentEditable.mjs +10 -0
- package/LexicalContentEditable.node.mjs +8 -0
- package/LexicalContextMenuPlugin.d.ts +2 -1
- package/LexicalContextMenuPlugin.dev.js +8 -3
- package/{LexicalContextMenuPlugin.dev.esm.js → LexicalContextMenuPlugin.dev.mjs} +8 -3
- package/{LexicalContextMenuPlugin.esm.js → LexicalContextMenuPlugin.mjs} +2 -2
- package/LexicalContextMenuPlugin.node.mjs +9 -0
- package/LexicalContextMenuPlugin.prod.js +16 -16
- package/LexicalContextMenuPlugin.prod.mjs +7 -0
- package/{LexicalDecoratorBlockNode.esm.js → LexicalDecoratorBlockNode.mjs} +2 -2
- package/LexicalDecoratorBlockNode.node.mjs +9 -0
- package/LexicalEditorRefPlugin.mjs +10 -0
- package/LexicalEditorRefPlugin.node.mjs +8 -0
- package/{useLexicalEditable.esm.js → LexicalErrorBoundary.mjs} +2 -2
- package/LexicalErrorBoundary.node.mjs +8 -0
- package/{LexicalClickableLinkPlugin.esm.js → LexicalHashtagPlugin.mjs} +3 -3
- package/LexicalHashtagPlugin.node.mjs +8 -0
- package/{LexicalHistoryPlugin.esm.js → LexicalHistoryPlugin.mjs} +2 -2
- package/LexicalHistoryPlugin.node.mjs +9 -0
- package/{LexicalHorizontalRuleNode.esm.js → LexicalHorizontalRuleNode.mjs} +2 -2
- package/LexicalHorizontalRuleNode.node.mjs +11 -0
- package/{LexicalCollaborationPlugin.esm.js → LexicalHorizontalRulePlugin.mjs} +3 -3
- package/LexicalHorizontalRulePlugin.node.mjs +8 -0
- package/{LexicalTableOfContents.esm.js → LexicalLinkPlugin.mjs} +3 -3
- package/LexicalLinkPlugin.node.mjs +8 -0
- package/LexicalListPlugin.mjs +10 -0
- package/LexicalListPlugin.node.mjs +8 -0
- package/{LexicalMarkdownShortcutPlugin.esm.js → LexicalMarkdownShortcutPlugin.mjs} +2 -2
- package/LexicalMarkdownShortcutPlugin.node.mjs +9 -0
- package/LexicalNestedComposer.dev.js +6 -2
- package/{LexicalNestedComposer.dev.esm.js → LexicalNestedComposer.dev.mjs} +6 -2
- package/LexicalNestedComposer.mjs +10 -0
- package/LexicalNestedComposer.node.mjs +8 -0
- package/LexicalNestedComposer.prod.js +5 -4
- package/LexicalNestedComposer.prod.mjs +7 -0
- package/LexicalNodeEventPlugin.mjs +10 -0
- package/LexicalNodeEventPlugin.node.mjs +8 -0
- package/{LexicalNodeMenuPlugin.esm.js → LexicalNodeMenuPlugin.mjs} +2 -2
- package/LexicalNodeMenuPlugin.node.mjs +9 -0
- package/{LexicalComposer.esm.js → LexicalOnChangePlugin.mjs} +3 -3
- package/LexicalOnChangePlugin.node.mjs +8 -0
- package/LexicalPlainTextPlugin.mjs +10 -0
- package/LexicalPlainTextPlugin.node.mjs +8 -0
- package/{LexicalLinkPlugin.esm.js → LexicalRichTextPlugin.mjs} +3 -3
- package/LexicalRichTextPlugin.node.mjs +8 -0
- package/{LexicalTabIndentationPlugin.esm.js → LexicalTabIndentationPlugin.mjs} +2 -2
- package/LexicalTabIndentationPlugin.node.mjs +9 -0
- package/{LexicalErrorBoundary.esm.js → LexicalTableOfContents.mjs} +2 -2
- package/LexicalTableOfContents.node.mjs +8 -0
- package/LexicalTablePlugin.mjs +10 -0
- package/LexicalTablePlugin.node.mjs +8 -0
- package/LexicalTreeView.dev.js +26 -434
- package/LexicalTreeView.dev.mjs +75 -0
- package/{LexicalTreeView.esm.js → LexicalTreeView.mjs} +2 -2
- package/LexicalTreeView.node.mjs +8 -0
- package/LexicalTreeView.prod.js +3 -17
- package/LexicalTreeView.prod.mjs +7 -0
- package/{LexicalTypeaheadMenuPlugin.esm.js → LexicalTypeaheadMenuPlugin.mjs} +2 -2
- package/LexicalTypeaheadMenuPlugin.node.mjs +14 -0
- package/package.json +819 -179
- package/useLexicalEditable.mjs +10 -0
- package/useLexicalEditable.node.mjs +8 -0
- package/{useLexicalIsTextContentEmpty.esm.js → useLexicalIsTextContentEmpty.mjs} +2 -2
- package/useLexicalIsTextContentEmpty.node.mjs +8 -0
- package/{useLexicalNodeSelection.esm.js → useLexicalNodeSelection.mjs} +2 -2
- package/useLexicalNodeSelection.node.mjs +8 -0
- package/useLexicalSubscription.mjs +10 -0
- package/useLexicalSubscription.node.mjs +8 -0
- package/{LexicalAutoFocusPlugin.esm.js → useLexicalTextEntity.mjs} +3 -3
- package/useLexicalTextEntity.node.mjs +8 -0
- package/LexicalCharacterLimitPlugin.esm.js +0 -10
- package/LexicalCheckListPlugin.prod.esm.js +0 -7
- package/LexicalClearEditorPlugin.prod.esm.js +0 -7
- package/LexicalClickableLinkPlugin.prod.esm.js +0 -7
- package/LexicalContentEditable.esm.js +0 -10
- package/LexicalContextMenuPlugin.prod.esm.js +0 -7
- package/LexicalEditorRefPlugin.esm.js +0 -10
- package/LexicalHorizontalRulePlugin.esm.js +0 -10
- package/LexicalNestedComposer.esm.js +0 -10
- package/LexicalNestedComposer.prod.esm.js +0 -7
- package/LexicalNodeEventPlugin.esm.js +0 -10
- package/LexicalOnChangePlugin.esm.js +0 -10
- package/LexicalPlainTextPlugin.esm.js +0 -10
- package/LexicalRichTextPlugin.esm.js +0 -10
- package/LexicalTablePlugin.esm.js +0 -10
- package/LexicalTreeView.dev.esm.js +0 -483
- package/LexicalTreeView.prod.esm.js +0 -7
- package/useLexicalSubscription.esm.js +0 -10
- package/useLexicalTextEntity.esm.js +0 -10
- /package/{LexicalAutoFocusPlugin.dev.esm.js → LexicalAutoFocusPlugin.dev.mjs} +0 -0
- /package/{LexicalAutoFocusPlugin.prod.esm.js → LexicalAutoFocusPlugin.prod.mjs} +0 -0
- /package/{LexicalAutoLinkPlugin.dev.esm.js → LexicalAutoLinkPlugin.dev.mjs} +0 -0
- /package/{LexicalAutoLinkPlugin.prod.esm.js → LexicalAutoLinkPlugin.prod.mjs} +0 -0
- /package/{LexicalBlockWithAlignableContents.dev.esm.js → LexicalBlockWithAlignableContents.dev.mjs} +0 -0
- /package/{LexicalBlockWithAlignableContents.prod.esm.js → LexicalBlockWithAlignableContents.prod.mjs} +0 -0
- /package/{LexicalCharacterLimitPlugin.dev.esm.js → LexicalCharacterLimitPlugin.dev.mjs} +0 -0
- /package/{LexicalCharacterLimitPlugin.prod.esm.js → LexicalCharacterLimitPlugin.prod.mjs} +0 -0
- /package/{LexicalCollaborationContext.dev.esm.js → LexicalCollaborationContext.dev.mjs} +0 -0
- /package/{LexicalCollaborationContext.prod.esm.js → LexicalCollaborationContext.prod.mjs} +0 -0
- /package/{LexicalCollaborationPlugin.dev.esm.js → LexicalCollaborationPlugin.dev.mjs} +0 -0
- /package/{LexicalCollaborationPlugin.prod.esm.js → LexicalCollaborationPlugin.prod.mjs} +0 -0
- /package/{LexicalComposer.dev.esm.js → LexicalComposer.dev.mjs} +0 -0
- /package/{LexicalComposer.prod.esm.js → LexicalComposer.prod.mjs} +0 -0
- /package/{LexicalComposerContext.dev.esm.js → LexicalComposerContext.dev.mjs} +0 -0
- /package/{LexicalComposerContext.prod.esm.js → LexicalComposerContext.prod.mjs} +0 -0
- /package/{LexicalContentEditable.dev.esm.js → LexicalContentEditable.dev.mjs} +0 -0
- /package/{LexicalContentEditable.prod.esm.js → LexicalContentEditable.prod.mjs} +0 -0
- /package/{LexicalDecoratorBlockNode.dev.esm.js → LexicalDecoratorBlockNode.dev.mjs} +0 -0
- /package/{LexicalDecoratorBlockNode.prod.esm.js → LexicalDecoratorBlockNode.prod.mjs} +0 -0
- /package/{LexicalEditorRefPlugin.dev.esm.js → LexicalEditorRefPlugin.dev.mjs} +0 -0
- /package/{LexicalEditorRefPlugin.prod.esm.js → LexicalEditorRefPlugin.prod.mjs} +0 -0
- /package/{LexicalErrorBoundary.dev.esm.js → LexicalErrorBoundary.dev.mjs} +0 -0
- /package/{LexicalErrorBoundary.prod.esm.js → LexicalErrorBoundary.prod.mjs} +0 -0
- /package/{LexicalHashtagPlugin.dev.esm.js → LexicalHashtagPlugin.dev.mjs} +0 -0
- /package/{LexicalHashtagPlugin.prod.esm.js → LexicalHashtagPlugin.prod.mjs} +0 -0
- /package/{LexicalHistoryPlugin.dev.esm.js → LexicalHistoryPlugin.dev.mjs} +0 -0
- /package/{LexicalHistoryPlugin.prod.esm.js → LexicalHistoryPlugin.prod.mjs} +0 -0
- /package/{LexicalHorizontalRuleNode.dev.esm.js → LexicalHorizontalRuleNode.dev.mjs} +0 -0
- /package/{LexicalHorizontalRuleNode.prod.esm.js → LexicalHorizontalRuleNode.prod.mjs} +0 -0
- /package/{LexicalHorizontalRulePlugin.dev.esm.js → LexicalHorizontalRulePlugin.dev.mjs} +0 -0
- /package/{LexicalHorizontalRulePlugin.prod.esm.js → LexicalHorizontalRulePlugin.prod.mjs} +0 -0
- /package/{LexicalLinkPlugin.dev.esm.js → LexicalLinkPlugin.dev.mjs} +0 -0
- /package/{LexicalLinkPlugin.prod.esm.js → LexicalLinkPlugin.prod.mjs} +0 -0
- /package/{LexicalListPlugin.dev.esm.js → LexicalListPlugin.dev.mjs} +0 -0
- /package/{LexicalListPlugin.prod.esm.js → LexicalListPlugin.prod.mjs} +0 -0
- /package/{LexicalMarkdownShortcutPlugin.dev.esm.js → LexicalMarkdownShortcutPlugin.dev.mjs} +0 -0
- /package/{LexicalMarkdownShortcutPlugin.prod.esm.js → LexicalMarkdownShortcutPlugin.prod.mjs} +0 -0
- /package/{LexicalNodeEventPlugin.dev.esm.js → LexicalNodeEventPlugin.dev.mjs} +0 -0
- /package/{LexicalNodeEventPlugin.prod.esm.js → LexicalNodeEventPlugin.prod.mjs} +0 -0
- /package/{LexicalNodeMenuPlugin.dev.esm.js → LexicalNodeMenuPlugin.dev.mjs} +0 -0
- /package/{LexicalNodeMenuPlugin.prod.esm.js → LexicalNodeMenuPlugin.prod.mjs} +0 -0
- /package/{LexicalOnChangePlugin.dev.esm.js → LexicalOnChangePlugin.dev.mjs} +0 -0
- /package/{LexicalOnChangePlugin.prod.esm.js → LexicalOnChangePlugin.prod.mjs} +0 -0
- /package/{LexicalPlainTextPlugin.dev.esm.js → LexicalPlainTextPlugin.dev.mjs} +0 -0
- /package/{LexicalPlainTextPlugin.prod.esm.js → LexicalPlainTextPlugin.prod.mjs} +0 -0
- /package/{LexicalRichTextPlugin.dev.esm.js → LexicalRichTextPlugin.dev.mjs} +0 -0
- /package/{LexicalRichTextPlugin.prod.esm.js → LexicalRichTextPlugin.prod.mjs} +0 -0
- /package/{LexicalTabIndentationPlugin.dev.esm.js → LexicalTabIndentationPlugin.dev.mjs} +0 -0
- /package/{LexicalTabIndentationPlugin.prod.esm.js → LexicalTabIndentationPlugin.prod.mjs} +0 -0
- /package/{LexicalTableOfContents.dev.esm.js → LexicalTableOfContents.dev.mjs} +0 -0
- /package/{LexicalTableOfContents.prod.esm.js → LexicalTableOfContents.prod.mjs} +0 -0
- /package/{LexicalTablePlugin.dev.esm.js → LexicalTablePlugin.dev.mjs} +0 -0
- /package/{LexicalTablePlugin.prod.esm.js → LexicalTablePlugin.prod.mjs} +0 -0
- /package/{LexicalTypeaheadMenuPlugin.dev.esm.js → LexicalTypeaheadMenuPlugin.dev.mjs} +0 -0
- /package/{LexicalTypeaheadMenuPlugin.prod.esm.js → LexicalTypeaheadMenuPlugin.prod.mjs} +0 -0
- /package/{useLexicalEditable.dev.esm.js → useLexicalEditable.dev.mjs} +0 -0
- /package/{useLexicalEditable.prod.esm.js → useLexicalEditable.prod.mjs} +0 -0
- /package/{useLexicalIsTextContentEmpty.dev.esm.js → useLexicalIsTextContentEmpty.dev.mjs} +0 -0
- /package/{useLexicalIsTextContentEmpty.prod.esm.js → useLexicalIsTextContentEmpty.prod.mjs} +0 -0
- /package/{useLexicalNodeSelection.dev.esm.js → useLexicalNodeSelection.dev.mjs} +0 -0
- /package/{useLexicalNodeSelection.prod.esm.js → useLexicalNodeSelection.prod.mjs} +0 -0
- /package/{useLexicalSubscription.dev.esm.js → useLexicalSubscription.dev.mjs} +0 -0
- /package/{useLexicalSubscription.prod.esm.js → useLexicalSubscription.prod.mjs} +0 -0
- /package/{useLexicalTextEntity.dev.esm.js → useLexicalTextEntity.dev.mjs} +0 -0
- /package/{useLexicalTextEntity.prod.esm.js → useLexicalTextEntity.prod.mjs} +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalPlainTextPlugin.dev.mjs') : import('./LexicalPlainTextPlugin.prod.mjs'));
|
|
8
|
+
export const PlainTextPlugin = mod.PlainTextPlugin;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import * as modDev from './
|
|
8
|
-
import * as modProd from './
|
|
7
|
+
import * as modDev from './LexicalRichTextPlugin.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalRichTextPlugin.prod.mjs';
|
|
9
9
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
|
-
export const
|
|
10
|
+
export const RichTextPlugin = mod.RichTextPlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalRichTextPlugin.dev.mjs') : import('./LexicalRichTextPlugin.prod.mjs'));
|
|
8
|
+
export const RichTextPlugin = mod.RichTextPlugin;
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import * as modDev from './LexicalTabIndentationPlugin.dev.
|
|
8
|
-
import * as modProd from './LexicalTabIndentationPlugin.prod.
|
|
7
|
+
import * as modDev from './LexicalTabIndentationPlugin.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalTabIndentationPlugin.prod.mjs';
|
|
9
9
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
10
|
export const TabIndentationPlugin = mod.TabIndentationPlugin;
|
|
11
11
|
export const registerTabIndentation = mod.registerTabIndentation;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalTabIndentationPlugin.dev.mjs') : import('./LexicalTabIndentationPlugin.prod.mjs'));
|
|
8
|
+
export const TabIndentationPlugin = mod.TabIndentationPlugin;
|
|
9
|
+
export const registerTabIndentation = mod.registerTabIndentation;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import * as modDev from './
|
|
8
|
-
import * as modProd from './
|
|
7
|
+
import * as modDev from './LexicalTableOfContents.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalTableOfContents.prod.mjs';
|
|
9
9
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
10
|
export default mod.default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalTableOfContents.dev.mjs') : import('./LexicalTableOfContents.prod.mjs'));
|
|
8
|
+
export default mod.default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import * as modDev from './LexicalTablePlugin.dev.mjs';
|
|
8
|
+
import * as modProd from './LexicalTablePlugin.prod.mjs';
|
|
9
|
+
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
|
10
|
+
export const TablePlugin = mod.TablePlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalTablePlugin.dev.mjs') : import('./LexicalTablePlugin.prod.mjs'));
|
|
8
|
+
export const TablePlugin = mod.TablePlugin;
|
package/LexicalTreeView.dev.js
CHANGED
|
@@ -6,12 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
var
|
|
10
|
-
var link = require('@lexical/link');
|
|
11
|
-
var mark = require('@lexical/mark');
|
|
12
|
-
var table = require('@lexical/table');
|
|
9
|
+
var devtoolsCore = require('@lexical/devtools-core');
|
|
13
10
|
var utils = require('@lexical/utils');
|
|
14
|
-
var lexical = require('lexical');
|
|
15
11
|
var React = require('react');
|
|
16
12
|
|
|
17
13
|
/**
|
|
@@ -21,19 +17,6 @@ var React = require('react');
|
|
|
21
17
|
* LICENSE file in the root directory of this source tree.
|
|
22
18
|
*
|
|
23
19
|
*/
|
|
24
|
-
const NON_SINGLE_WIDTH_CHARS_REPLACEMENT = Object.freeze({
|
|
25
|
-
'\t': '\\t',
|
|
26
|
-
'\n': '\\n'
|
|
27
|
-
});
|
|
28
|
-
const NON_SINGLE_WIDTH_CHARS_REGEX = new RegExp(Object.keys(NON_SINGLE_WIDTH_CHARS_REPLACEMENT).join('|'), 'g');
|
|
29
|
-
const SYMBOLS = Object.freeze({
|
|
30
|
-
ancestorHasNextSibling: '|',
|
|
31
|
-
ancestorIsLastChild: ' ',
|
|
32
|
-
hasNextSibling: '├',
|
|
33
|
-
isLastChild: '└',
|
|
34
|
-
selectedChar: '^',
|
|
35
|
-
selectedLine: '>'
|
|
36
|
-
});
|
|
37
20
|
function TreeView({
|
|
38
21
|
treeTypeButtonClassName,
|
|
39
22
|
timeTravelButtonClassName,
|
|
@@ -43,78 +26,18 @@ function TreeView({
|
|
|
43
26
|
timeTravelPanelClassName,
|
|
44
27
|
editor
|
|
45
28
|
}) {
|
|
46
|
-
const
|
|
47
|
-
const [
|
|
48
|
-
const
|
|
49
|
-
const [showExportDOM, setShowExportDOM] = React.useState(false);
|
|
50
|
-
const playingIndexRef = React.useRef(0);
|
|
51
|
-
const treeElementRef = React.useRef(null);
|
|
52
|
-
const inputRef = React.useRef(null);
|
|
53
|
-
const [isPlaying, setIsPlaying] = React.useState(false);
|
|
54
|
-
const [isLimited, setIsLimited] = React.useState(false);
|
|
55
|
-
const [showLimited, setShowLimited] = React.useState(false);
|
|
56
|
-
const lastEditorStateRef = React.useRef(null);
|
|
57
|
-
const commandsLog = useLexicalCommandsLog(editor);
|
|
58
|
-
const generateTree = React.useCallback(editorState => {
|
|
59
|
-
const treeText = generateContent(editor, commandsLog, showExportDOM);
|
|
60
|
-
setContent(treeText);
|
|
61
|
-
if (!timeTravelEnabled) {
|
|
62
|
-
setTimeStampedEditorStates(currentEditorStates => [...currentEditorStates, [Date.now(), editorState]]);
|
|
63
|
-
}
|
|
64
|
-
}, [commandsLog, editor, timeTravelEnabled, showExportDOM]);
|
|
65
|
-
React.useEffect(() => {
|
|
66
|
-
const editorState = editor.getEditorState();
|
|
67
|
-
if (!showLimited && editorState._nodeMap.size < 1000) {
|
|
68
|
-
setContent(generateContent(editor, commandsLog, showExportDOM));
|
|
69
|
-
}
|
|
70
|
-
}, [commandsLog, editor, showLimited, showExportDOM]);
|
|
29
|
+
const treeElementRef = /*#__PURE__*/React.createRef();
|
|
30
|
+
const [editorCurrentState, setEditorCurrentState] = React.useState(editor.getEditorState());
|
|
31
|
+
const commandsLog = devtoolsCore.useLexicalCommandsLog(editor);
|
|
71
32
|
React.useEffect(() => {
|
|
72
33
|
return utils.mergeRegister(editor.registerUpdateListener(({
|
|
73
34
|
editorState
|
|
74
35
|
}) => {
|
|
75
|
-
|
|
76
|
-
lastEditorStateRef.current = editorState;
|
|
77
|
-
setIsLimited(true);
|
|
78
|
-
if (!showLimited) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
generateTree(editorState);
|
|
36
|
+
setEditorCurrentState(editorState);
|
|
83
37
|
}), editor.registerEditableListener(() => {
|
|
84
|
-
|
|
85
|
-
setContent(treeText);
|
|
38
|
+
setEditorCurrentState(editor.getEditorState());
|
|
86
39
|
}));
|
|
87
|
-
}, [
|
|
88
|
-
const totalEditorStates = timeStampedEditorStates.length;
|
|
89
|
-
React.useEffect(() => {
|
|
90
|
-
if (isPlaying) {
|
|
91
|
-
let timeoutId;
|
|
92
|
-
const play = () => {
|
|
93
|
-
const currentIndex = playingIndexRef.current;
|
|
94
|
-
if (currentIndex === totalEditorStates - 1) {
|
|
95
|
-
setIsPlaying(false);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const currentTime = timeStampedEditorStates[currentIndex][0];
|
|
99
|
-
const nextTime = timeStampedEditorStates[currentIndex + 1][0];
|
|
100
|
-
const timeDiff = nextTime - currentTime;
|
|
101
|
-
timeoutId = setTimeout(() => {
|
|
102
|
-
playingIndexRef.current++;
|
|
103
|
-
const index = playingIndexRef.current;
|
|
104
|
-
const input = inputRef.current;
|
|
105
|
-
if (input !== null) {
|
|
106
|
-
input.value = String(index);
|
|
107
|
-
}
|
|
108
|
-
editor.setEditorState(timeStampedEditorStates[index][1]);
|
|
109
|
-
play();
|
|
110
|
-
}, timeDiff);
|
|
111
|
-
};
|
|
112
|
-
play();
|
|
113
|
-
return () => {
|
|
114
|
-
clearTimeout(timeoutId);
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}, [timeStampedEditorStates, isPlaying, editor, totalEditorStates]);
|
|
40
|
+
}, [editor]);
|
|
118
41
|
React.useEffect(() => {
|
|
119
42
|
const element = treeElementRef.current;
|
|
120
43
|
if (element !== null) {
|
|
@@ -125,360 +48,29 @@ function TreeView({
|
|
|
125
48
|
element.__lexicalEditor = null;
|
|
126
49
|
};
|
|
127
50
|
}
|
|
128
|
-
}, [editor]);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
padding: 20
|
|
134
|
-
}
|
|
135
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
136
|
-
style: {
|
|
137
|
-
marginRight: 20
|
|
138
|
-
}
|
|
139
|
-
}, "Detected large EditorState, this can impact debugging performance."), /*#__PURE__*/React.createElement("button", {
|
|
140
|
-
onClick: () => {
|
|
141
|
-
setShowLimited(true);
|
|
142
|
-
const editorState = lastEditorStateRef.current;
|
|
143
|
-
if (editorState !== null) {
|
|
144
|
-
lastEditorStateRef.current = null;
|
|
145
|
-
generateTree(editorState);
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
style: {
|
|
149
|
-
background: 'transparent',
|
|
150
|
-
border: '1px solid white',
|
|
151
|
-
color: 'white',
|
|
152
|
-
cursor: 'pointer',
|
|
153
|
-
padding: 5
|
|
51
|
+
}, [editor, treeElementRef]);
|
|
52
|
+
const handleEditorReadOnly = isReadonly => {
|
|
53
|
+
const rootElement = editor.getRootElement();
|
|
54
|
+
if (rootElement == null) {
|
|
55
|
+
return;
|
|
154
56
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
57
|
+
rootElement.contentEditable = isReadonly ? 'false' : 'true';
|
|
58
|
+
};
|
|
59
|
+
return /*#__PURE__*/React.createElement(devtoolsCore.TreeView, {
|
|
60
|
+
treeTypeButtonClassName: treeTypeButtonClassName,
|
|
61
|
+
timeTravelButtonClassName: timeTravelButtonClassName,
|
|
62
|
+
timeTravelPanelSliderClassName: timeTravelPanelSliderClassName,
|
|
63
|
+
timeTravelPanelButtonClassName: timeTravelPanelButtonClassName,
|
|
64
|
+
viewClassName: viewClassName,
|
|
65
|
+
timeTravelPanelClassName: timeTravelPanelClassName,
|
|
66
|
+
setEditorReadOnly: handleEditorReadOnly,
|
|
67
|
+
editorState: editorCurrentState,
|
|
68
|
+
setEditorState: state => editor.setEditorState(state),
|
|
69
|
+
generateContent: async function (exportDOM) {
|
|
70
|
+
return devtoolsCore.generateContent(editor, commandsLog, exportDOM);
|
|
167
71
|
},
|
|
168
|
-
className: timeTravelButtonClassName,
|
|
169
|
-
type: "button"
|
|
170
|
-
}, "Time Travel"), (showLimited || !isLimited) && /*#__PURE__*/React.createElement("pre", {
|
|
171
72
|
ref: treeElementRef
|
|
172
|
-
}, content), timeTravelEnabled && (showLimited || !isLimited) && /*#__PURE__*/React.createElement("div", {
|
|
173
|
-
className: timeTravelPanelClassName
|
|
174
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
175
|
-
className: timeTravelPanelButtonClassName,
|
|
176
|
-
onClick: () => {
|
|
177
|
-
if (playingIndexRef.current === totalEditorStates - 1) {
|
|
178
|
-
playingIndexRef.current = 1;
|
|
179
|
-
}
|
|
180
|
-
setIsPlaying(!isPlaying);
|
|
181
|
-
},
|
|
182
|
-
type: "button"
|
|
183
|
-
}, isPlaying ? 'Pause' : 'Play'), /*#__PURE__*/React.createElement("input", {
|
|
184
|
-
className: timeTravelPanelSliderClassName,
|
|
185
|
-
ref: inputRef,
|
|
186
|
-
onChange: event => {
|
|
187
|
-
const editorStateIndex = Number(event.target.value);
|
|
188
|
-
const timeStampedEditorState = timeStampedEditorStates[editorStateIndex];
|
|
189
|
-
if (timeStampedEditorState) {
|
|
190
|
-
playingIndexRef.current = editorStateIndex;
|
|
191
|
-
editor.setEditorState(timeStampedEditorState[1]);
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
type: "range",
|
|
195
|
-
min: "1",
|
|
196
|
-
max: totalEditorStates - 1
|
|
197
|
-
}), /*#__PURE__*/React.createElement("button", {
|
|
198
|
-
className: timeTravelPanelButtonClassName,
|
|
199
|
-
onClick: () => {
|
|
200
|
-
const rootElement = editor.getRootElement();
|
|
201
|
-
if (rootElement !== null) {
|
|
202
|
-
rootElement.contentEditable = 'true';
|
|
203
|
-
const index = timeStampedEditorStates.length - 1;
|
|
204
|
-
const timeStampedEditorState = timeStampedEditorStates[index];
|
|
205
|
-
editor.setEditorState(timeStampedEditorState[1]);
|
|
206
|
-
const input = inputRef.current;
|
|
207
|
-
if (input !== null) {
|
|
208
|
-
input.value = String(index);
|
|
209
|
-
}
|
|
210
|
-
setTimeTravelEnabled(false);
|
|
211
|
-
setIsPlaying(false);
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
type: "button"
|
|
215
|
-
}, "Exit")));
|
|
216
|
-
}
|
|
217
|
-
function useLexicalCommandsLog(editor) {
|
|
218
|
-
const [loggedCommands, setLoggedCommands] = React.useState([]);
|
|
219
|
-
React.useEffect(() => {
|
|
220
|
-
const unregisterCommandListeners = new Set();
|
|
221
|
-
for (const [command] of editor._commands) {
|
|
222
|
-
unregisterCommandListeners.add(editor.registerCommand(command, payload => {
|
|
223
|
-
setLoggedCommands(state => {
|
|
224
|
-
const newState = [...state];
|
|
225
|
-
newState.push({
|
|
226
|
-
payload,
|
|
227
|
-
type: command.type ? command.type : 'UNKNOWN'
|
|
228
|
-
});
|
|
229
|
-
if (newState.length > 10) {
|
|
230
|
-
newState.shift();
|
|
231
|
-
}
|
|
232
|
-
return newState;
|
|
233
|
-
});
|
|
234
|
-
return false;
|
|
235
|
-
}, lexical.COMMAND_PRIORITY_HIGH));
|
|
236
|
-
}
|
|
237
|
-
return () => unregisterCommandListeners.forEach(unregister => unregister());
|
|
238
|
-
}, [editor]);
|
|
239
|
-
return React.useMemo(() => loggedCommands, [loggedCommands]);
|
|
240
|
-
}
|
|
241
|
-
function printRangeSelection(selection) {
|
|
242
|
-
let res = '';
|
|
243
|
-
const formatText = printFormatProperties(selection);
|
|
244
|
-
res += `: range ${formatText !== '' ? `{ ${formatText} }` : ''} ${selection.style !== '' ? `{ style: ${selection.style} } ` : ''}`;
|
|
245
|
-
const anchor = selection.anchor;
|
|
246
|
-
const focus = selection.focus;
|
|
247
|
-
const anchorOffset = anchor.offset;
|
|
248
|
-
const focusOffset = focus.offset;
|
|
249
|
-
res += `\n ├ anchor { key: ${anchor.key}, offset: ${anchorOffset === null ? 'null' : anchorOffset}, type: ${anchor.type} }`;
|
|
250
|
-
res += `\n └ focus { key: ${focus.key}, offset: ${focusOffset === null ? 'null' : focusOffset}, type: ${focus.type} }`;
|
|
251
|
-
return res;
|
|
252
|
-
}
|
|
253
|
-
function printNodeSelection(selection) {
|
|
254
|
-
if (!lexical.$isNodeSelection(selection)) {
|
|
255
|
-
return '';
|
|
256
|
-
}
|
|
257
|
-
return `: node\n └ [${Array.from(selection._nodes).join(', ')}]`;
|
|
258
|
-
}
|
|
259
|
-
function printTableSelection(selection) {
|
|
260
|
-
return `: table\n └ { table: ${selection.tableKey}, anchorCell: ${selection.anchor.key}, focusCell: ${selection.focus.key} }`;
|
|
261
|
-
}
|
|
262
|
-
function generateContent(editor, commandsLog, exportDOM) {
|
|
263
|
-
const editorState = editor.getEditorState();
|
|
264
|
-
const editorConfig = editor._config;
|
|
265
|
-
const compositionKey = editor._compositionKey;
|
|
266
|
-
const editable = editor._editable;
|
|
267
|
-
if (exportDOM) {
|
|
268
|
-
let htmlString = '';
|
|
269
|
-
editorState.read(() => {
|
|
270
|
-
htmlString = printPrettyHTML(html.$generateHtmlFromNodes(editor));
|
|
271
|
-
});
|
|
272
|
-
return htmlString;
|
|
273
|
-
}
|
|
274
|
-
let res = ' root\n';
|
|
275
|
-
const selectionString = editorState.read(() => {
|
|
276
|
-
const selection = lexical.$getSelection();
|
|
277
|
-
visitTree(lexical.$getRoot(), (node, indent) => {
|
|
278
|
-
const nodeKey = node.getKey();
|
|
279
|
-
const nodeKeyDisplay = `(${nodeKey})`;
|
|
280
|
-
const typeDisplay = node.getType() || '';
|
|
281
|
-
const isSelected = node.isSelected();
|
|
282
|
-
const idsDisplay = mark.$isMarkNode(node) ? ` id: [ ${node.getIDs().join(', ')} ] ` : '';
|
|
283
|
-
res += `${isSelected ? SYMBOLS.selectedLine : ' '} ${indent.join(' ')} ${nodeKeyDisplay} ${typeDisplay} ${idsDisplay} ${printNode(node)}\n`;
|
|
284
|
-
res += printSelectedCharsLine({
|
|
285
|
-
indent,
|
|
286
|
-
isSelected,
|
|
287
|
-
node,
|
|
288
|
-
nodeKeyDisplay,
|
|
289
|
-
selection,
|
|
290
|
-
typeDisplay
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
return selection === null ? ': null' : lexical.$isRangeSelection(selection) ? printRangeSelection(selection) : table.$isTableSelection(selection) ? printTableSelection(selection) : printNodeSelection(selection);
|
|
294
|
-
});
|
|
295
|
-
res += '\n selection' + selectionString;
|
|
296
|
-
res += '\n\n commands:';
|
|
297
|
-
if (commandsLog.length) {
|
|
298
|
-
for (const {
|
|
299
|
-
type,
|
|
300
|
-
payload
|
|
301
|
-
} of commandsLog) {
|
|
302
|
-
res += `\n └ { type: ${type}, payload: ${payload instanceof Event ? payload.constructor.name : payload} }`;
|
|
303
|
-
}
|
|
304
|
-
} else {
|
|
305
|
-
res += '\n └ None dispatched.';
|
|
306
|
-
}
|
|
307
|
-
res += '\n\n editor:';
|
|
308
|
-
res += `\n └ namespace ${editorConfig.namespace}`;
|
|
309
|
-
if (compositionKey !== null) {
|
|
310
|
-
res += `\n └ compositionKey ${compositionKey}`;
|
|
311
|
-
}
|
|
312
|
-
res += `\n └ editable ${String(editable)}`;
|
|
313
|
-
return res;
|
|
314
|
-
}
|
|
315
|
-
function visitTree(currentNode, visitor, indent = []) {
|
|
316
|
-
const childNodes = currentNode.getChildren();
|
|
317
|
-
const childNodesLength = childNodes.length;
|
|
318
|
-
childNodes.forEach((childNode, i) => {
|
|
319
|
-
visitor(childNode, indent.concat(i === childNodesLength - 1 ? SYMBOLS.isLastChild : SYMBOLS.hasNextSibling));
|
|
320
|
-
if (lexical.$isElementNode(childNode)) {
|
|
321
|
-
visitTree(childNode, visitor, indent.concat(i === childNodesLength - 1 ? SYMBOLS.ancestorIsLastChild : SYMBOLS.ancestorHasNextSibling));
|
|
322
|
-
}
|
|
323
73
|
});
|
|
324
74
|
}
|
|
325
|
-
function normalize(text) {
|
|
326
|
-
return Object.entries(NON_SINGLE_WIDTH_CHARS_REPLACEMENT).reduce((acc, [key, value]) => acc.replace(new RegExp(key, 'g'), String(value)), text);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// TODO Pass via props to allow customizability
|
|
330
|
-
function printNode(node) {
|
|
331
|
-
if (lexical.$isTextNode(node)) {
|
|
332
|
-
const text = node.getTextContent();
|
|
333
|
-
const title = text.length === 0 ? '(empty)' : `"${normalize(text)}"`;
|
|
334
|
-
const properties = printAllTextNodeProperties(node);
|
|
335
|
-
return [title, properties.length !== 0 ? `{ ${properties} }` : null].filter(Boolean).join(' ').trim();
|
|
336
|
-
} else if (link.$isLinkNode(node)) {
|
|
337
|
-
const link = node.getURL();
|
|
338
|
-
const title = link.length === 0 ? '(empty)' : `"${normalize(link)}"`;
|
|
339
|
-
const properties = printAllLinkNodeProperties(node);
|
|
340
|
-
return [title, properties.length !== 0 ? `{ ${properties} }` : null].filter(Boolean).join(' ').trim();
|
|
341
|
-
} else {
|
|
342
|
-
return '';
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
const FORMAT_PREDICATES = [node => node.hasFormat('bold') && 'Bold', node => node.hasFormat('code') && 'Code', node => node.hasFormat('italic') && 'Italic', node => node.hasFormat('strikethrough') && 'Strikethrough', node => node.hasFormat('subscript') && 'Subscript', node => node.hasFormat('superscript') && 'Superscript', node => node.hasFormat('underline') && 'Underline'];
|
|
346
|
-
const DETAIL_PREDICATES = [node => node.isDirectionless() && 'Directionless', node => node.isUnmergeable() && 'Unmergeable'];
|
|
347
|
-
const MODE_PREDICATES = [node => node.isToken() && 'Token', node => node.isSegmented() && 'Segmented'];
|
|
348
|
-
function printAllTextNodeProperties(node) {
|
|
349
|
-
return [printFormatProperties(node), printDetailProperties(node), printModeProperties(node)].filter(Boolean).join(', ');
|
|
350
|
-
}
|
|
351
|
-
function printAllLinkNodeProperties(node) {
|
|
352
|
-
return [printTargetProperties(node), printRelProperties(node), printTitleProperties(node)].filter(Boolean).join(', ');
|
|
353
|
-
}
|
|
354
|
-
function printDetailProperties(nodeOrSelection) {
|
|
355
|
-
let str = DETAIL_PREDICATES.map(predicate => predicate(nodeOrSelection)).filter(Boolean).join(', ').toLocaleLowerCase();
|
|
356
|
-
if (str !== '') {
|
|
357
|
-
str = 'detail: ' + str;
|
|
358
|
-
}
|
|
359
|
-
return str;
|
|
360
|
-
}
|
|
361
|
-
function printModeProperties(nodeOrSelection) {
|
|
362
|
-
let str = MODE_PREDICATES.map(predicate => predicate(nodeOrSelection)).filter(Boolean).join(', ').toLocaleLowerCase();
|
|
363
|
-
if (str !== '') {
|
|
364
|
-
str = 'mode: ' + str;
|
|
365
|
-
}
|
|
366
|
-
return str;
|
|
367
|
-
}
|
|
368
|
-
function printFormatProperties(nodeOrSelection) {
|
|
369
|
-
let str = FORMAT_PREDICATES.map(predicate => predicate(nodeOrSelection)).filter(Boolean).join(', ').toLocaleLowerCase();
|
|
370
|
-
if (str !== '') {
|
|
371
|
-
str = 'format: ' + str;
|
|
372
|
-
}
|
|
373
|
-
return str;
|
|
374
|
-
}
|
|
375
|
-
function printTargetProperties(node) {
|
|
376
|
-
let str = node.getTarget();
|
|
377
|
-
// TODO Fix nullish on LinkNode
|
|
378
|
-
if (str != null) {
|
|
379
|
-
str = 'target: ' + str;
|
|
380
|
-
}
|
|
381
|
-
return str;
|
|
382
|
-
}
|
|
383
|
-
function printRelProperties(node) {
|
|
384
|
-
let str = node.getRel();
|
|
385
|
-
// TODO Fix nullish on LinkNode
|
|
386
|
-
if (str != null) {
|
|
387
|
-
str = 'rel: ' + str;
|
|
388
|
-
}
|
|
389
|
-
return str;
|
|
390
|
-
}
|
|
391
|
-
function printTitleProperties(node) {
|
|
392
|
-
let str = node.getTitle();
|
|
393
|
-
// TODO Fix nullish on LinkNode
|
|
394
|
-
if (str != null) {
|
|
395
|
-
str = 'title: ' + str;
|
|
396
|
-
}
|
|
397
|
-
return str;
|
|
398
|
-
}
|
|
399
|
-
function printSelectedCharsLine({
|
|
400
|
-
indent,
|
|
401
|
-
isSelected,
|
|
402
|
-
node,
|
|
403
|
-
nodeKeyDisplay,
|
|
404
|
-
selection,
|
|
405
|
-
typeDisplay
|
|
406
|
-
}) {
|
|
407
|
-
// No selection or node is not selected.
|
|
408
|
-
if (!lexical.$isTextNode(node) || !lexical.$isRangeSelection(selection) || !isSelected || lexical.$isElementNode(node)) {
|
|
409
|
-
return '';
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// No selected characters.
|
|
413
|
-
const anchor = selection.anchor;
|
|
414
|
-
const focus = selection.focus;
|
|
415
|
-
if (node.getTextContent() === '' || anchor.getNode() === selection.focus.getNode() && anchor.offset === focus.offset) {
|
|
416
|
-
return '';
|
|
417
|
-
}
|
|
418
|
-
const [start, end] = $getSelectionStartEnd(node, selection);
|
|
419
|
-
if (start === end) {
|
|
420
|
-
return '';
|
|
421
|
-
}
|
|
422
|
-
const selectionLastIndent = indent[indent.length - 1] === SYMBOLS.hasNextSibling ? SYMBOLS.ancestorHasNextSibling : SYMBOLS.ancestorIsLastChild;
|
|
423
|
-
const indentionChars = [...indent.slice(0, indent.length - 1), selectionLastIndent];
|
|
424
|
-
const unselectedChars = Array(start + 1).fill(' ');
|
|
425
|
-
const selectedChars = Array(end - start).fill(SYMBOLS.selectedChar);
|
|
426
|
-
const paddingLength = typeDisplay.length + 3; // 2 for the spaces around + 1 for the double quote.
|
|
427
|
-
|
|
428
|
-
const nodePrintSpaces = Array(nodeKeyDisplay.length + paddingLength).fill(' ');
|
|
429
|
-
return [SYMBOLS.selectedLine, indentionChars.join(' '), [...nodePrintSpaces, ...unselectedChars, ...selectedChars].join('')].join(' ') + '\n';
|
|
430
|
-
}
|
|
431
|
-
function printPrettyHTML(str) {
|
|
432
|
-
const div = document.createElement('div');
|
|
433
|
-
div.innerHTML = str.trim();
|
|
434
|
-
return prettifyHTML(div, 0).innerHTML;
|
|
435
|
-
}
|
|
436
|
-
function prettifyHTML(node, level) {
|
|
437
|
-
const indentBefore = new Array(level++ + 1).join(' ');
|
|
438
|
-
const indentAfter = new Array(level - 1).join(' ');
|
|
439
|
-
let textNode;
|
|
440
|
-
for (let i = 0; i < node.children.length; i++) {
|
|
441
|
-
textNode = document.createTextNode('\n' + indentBefore);
|
|
442
|
-
node.insertBefore(textNode, node.children[i]);
|
|
443
|
-
prettifyHTML(node.children[i], level);
|
|
444
|
-
if (node.lastElementChild === node.children[i]) {
|
|
445
|
-
textNode = document.createTextNode('\n' + indentAfter);
|
|
446
|
-
node.appendChild(textNode);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
return node;
|
|
450
|
-
}
|
|
451
|
-
function $getSelectionStartEnd(node, selection) {
|
|
452
|
-
const anchorAndFocus = selection.getStartEndPoints();
|
|
453
|
-
if (lexical.$isNodeSelection(selection) || anchorAndFocus === null) {
|
|
454
|
-
return [-1, -1];
|
|
455
|
-
}
|
|
456
|
-
const [anchor, focus] = anchorAndFocus;
|
|
457
|
-
const textContent = node.getTextContent();
|
|
458
|
-
const textLength = textContent.length;
|
|
459
|
-
let start = -1;
|
|
460
|
-
let end = -1;
|
|
461
|
-
|
|
462
|
-
// Only one node is being selected.
|
|
463
|
-
if (anchor.type === 'text' && focus.type === 'text') {
|
|
464
|
-
const anchorNode = anchor.getNode();
|
|
465
|
-
const focusNode = focus.getNode();
|
|
466
|
-
if (anchorNode === focusNode && node === anchorNode && anchor.offset !== focus.offset) {
|
|
467
|
-
[start, end] = anchor.offset < focus.offset ? [anchor.offset, focus.offset] : [focus.offset, anchor.offset];
|
|
468
|
-
} else if (node === anchorNode) {
|
|
469
|
-
[start, end] = anchorNode.isBefore(focusNode) ? [anchor.offset, textLength] : [0, anchor.offset];
|
|
470
|
-
} else if (node === focusNode) {
|
|
471
|
-
[start, end] = focusNode.isBefore(anchorNode) ? [focus.offset, textLength] : [0, focus.offset];
|
|
472
|
-
} else {
|
|
473
|
-
// Node is within selection but not the anchor nor focus.
|
|
474
|
-
[start, end] = [0, textLength];
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
// Account for non-single width characters.
|
|
479
|
-
const numNonSingleWidthCharBeforeSelection = (textContent.slice(0, start).match(NON_SINGLE_WIDTH_CHARS_REGEX) || []).length;
|
|
480
|
-
const numNonSingleWidthCharInSelection = (textContent.slice(start, end).match(NON_SINGLE_WIDTH_CHARS_REGEX) || []).length;
|
|
481
|
-
return [start + numNonSingleWidthCharBeforeSelection, end + numNonSingleWidthCharBeforeSelection + numNonSingleWidthCharInSelection];
|
|
482
|
-
}
|
|
483
75
|
|
|
484
76
|
exports.TreeView = TreeView;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { useLexicalCommandsLog, TreeView as TreeView$1, generateContent } from '@lexical/devtools-core';
|
|
8
|
+
import { mergeRegister } from '@lexical/utils';
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { useState, useEffect } from 'react';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
function TreeView({
|
|
20
|
+
treeTypeButtonClassName,
|
|
21
|
+
timeTravelButtonClassName,
|
|
22
|
+
timeTravelPanelSliderClassName,
|
|
23
|
+
timeTravelPanelButtonClassName,
|
|
24
|
+
viewClassName,
|
|
25
|
+
timeTravelPanelClassName,
|
|
26
|
+
editor
|
|
27
|
+
}) {
|
|
28
|
+
const treeElementRef = /*#__PURE__*/React.createRef();
|
|
29
|
+
const [editorCurrentState, setEditorCurrentState] = useState(editor.getEditorState());
|
|
30
|
+
const commandsLog = useLexicalCommandsLog(editor);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
return mergeRegister(editor.registerUpdateListener(({
|
|
33
|
+
editorState
|
|
34
|
+
}) => {
|
|
35
|
+
setEditorCurrentState(editorState);
|
|
36
|
+
}), editor.registerEditableListener(() => {
|
|
37
|
+
setEditorCurrentState(editor.getEditorState());
|
|
38
|
+
}));
|
|
39
|
+
}, [editor]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const element = treeElementRef.current;
|
|
42
|
+
if (element !== null) {
|
|
43
|
+
// @ts-ignore Internal field
|
|
44
|
+
element.__lexicalEditor = editor;
|
|
45
|
+
return () => {
|
|
46
|
+
// @ts-ignore Internal field
|
|
47
|
+
element.__lexicalEditor = null;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}, [editor, treeElementRef]);
|
|
51
|
+
const handleEditorReadOnly = isReadonly => {
|
|
52
|
+
const rootElement = editor.getRootElement();
|
|
53
|
+
if (rootElement == null) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
rootElement.contentEditable = isReadonly ? 'false' : 'true';
|
|
57
|
+
};
|
|
58
|
+
return /*#__PURE__*/React.createElement(TreeView$1, {
|
|
59
|
+
treeTypeButtonClassName: treeTypeButtonClassName,
|
|
60
|
+
timeTravelButtonClassName: timeTravelButtonClassName,
|
|
61
|
+
timeTravelPanelSliderClassName: timeTravelPanelSliderClassName,
|
|
62
|
+
timeTravelPanelButtonClassName: timeTravelPanelButtonClassName,
|
|
63
|
+
viewClassName: viewClassName,
|
|
64
|
+
timeTravelPanelClassName: timeTravelPanelClassName,
|
|
65
|
+
setEditorReadOnly: handleEditorReadOnly,
|
|
66
|
+
editorState: editorCurrentState,
|
|
67
|
+
setEditorState: state => editor.setEditorState(state),
|
|
68
|
+
generateContent: async function (exportDOM) {
|
|
69
|
+
return generateContent(editor, commandsLog, exportDOM);
|
|
70
|
+
},
|
|
71
|
+
ref: treeElementRef
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { TreeView };
|