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