@lexical/react 0.13.1 → 0.14.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.
Files changed (179) hide show
  1. package/LexicalAutoEmbedPlugin.dev.esm.js +131 -0
  2. package/LexicalAutoEmbedPlugin.esm.js +13 -0
  3. package/LexicalAutoEmbedPlugin.js +1 -1
  4. package/LexicalAutoEmbedPlugin.prod.esm.js +7 -0
  5. package/LexicalAutoFocusPlugin.dev.esm.js +42 -0
  6. package/LexicalAutoFocusPlugin.esm.js +10 -0
  7. package/LexicalAutoFocusPlugin.js +1 -1
  8. package/LexicalAutoFocusPlugin.prod.esm.js +7 -0
  9. package/LexicalAutoLinkPlugin.dev.esm.js +312 -0
  10. package/LexicalAutoLinkPlugin.dev.js +3 -1
  11. package/LexicalAutoLinkPlugin.esm.js +11 -0
  12. package/LexicalAutoLinkPlugin.js +1 -1
  13. package/LexicalAutoLinkPlugin.prod.esm.js +7 -0
  14. package/LexicalBlockWithAlignableContents.dev.esm.js +86 -0
  15. package/LexicalBlockWithAlignableContents.dev.js +1 -0
  16. package/LexicalBlockWithAlignableContents.esm.js +10 -0
  17. package/LexicalBlockWithAlignableContents.js +1 -1
  18. package/LexicalBlockWithAlignableContents.prod.esm.js +7 -0
  19. package/LexicalBlockWithAlignableContents.prod.js +1 -1
  20. package/LexicalCharacterLimitPlugin.d.ts +4 -1
  21. package/LexicalCharacterLimitPlugin.dev.esm.js +272 -0
  22. package/LexicalCharacterLimitPlugin.dev.js +12 -4
  23. package/LexicalCharacterLimitPlugin.esm.js +10 -0
  24. package/LexicalCharacterLimitPlugin.js +1 -1
  25. package/LexicalCharacterLimitPlugin.prod.esm.js +7 -0
  26. package/LexicalCharacterLimitPlugin.prod.js +9 -9
  27. package/LexicalCheckListPlugin.dev.esm.js +203 -0
  28. package/LexicalCheckListPlugin.esm.js +10 -0
  29. package/LexicalCheckListPlugin.js +1 -1
  30. package/LexicalCheckListPlugin.prod.esm.js +7 -0
  31. package/LexicalClearEditorPlugin.dev.esm.js +64 -0
  32. package/LexicalClearEditorPlugin.esm.js +10 -0
  33. package/LexicalClearEditorPlugin.js +1 -1
  34. package/LexicalClearEditorPlugin.prod.esm.js +7 -0
  35. package/LexicalClickableLinkPlugin.dev.esm.js +95 -0
  36. package/LexicalClickableLinkPlugin.esm.js +10 -0
  37. package/LexicalClickableLinkPlugin.js +1 -1
  38. package/LexicalClickableLinkPlugin.prod.esm.js +7 -0
  39. package/LexicalCollaborationContext.dev.esm.js +36 -0
  40. package/LexicalCollaborationContext.esm.js +11 -0
  41. package/LexicalCollaborationContext.js +1 -1
  42. package/LexicalCollaborationContext.prod.esm.js +7 -0
  43. package/LexicalCollaborationPlugin.dev.esm.js +308 -0
  44. package/LexicalCollaborationPlugin.esm.js +10 -0
  45. package/LexicalCollaborationPlugin.js +1 -1
  46. package/LexicalCollaborationPlugin.prod.esm.js +7 -0
  47. package/LexicalComposer.dev.esm.js +129 -0
  48. package/LexicalComposer.esm.js +10 -0
  49. package/LexicalComposer.js +1 -1
  50. package/LexicalComposer.prod.esm.js +7 -0
  51. package/LexicalComposerContext.dev.esm.js +42 -0
  52. package/LexicalComposerContext.esm.js +12 -0
  53. package/LexicalComposerContext.js +1 -1
  54. package/LexicalComposerContext.prod.esm.js +7 -0
  55. package/LexicalContentEditable.dev.esm.js +107 -0
  56. package/LexicalContentEditable.dev.js +5 -1
  57. package/LexicalContentEditable.esm.js +10 -0
  58. package/LexicalContentEditable.js +1 -1
  59. package/LexicalContentEditable.prod.esm.js +7 -0
  60. package/LexicalContentEditable.prod.js +3 -3
  61. package/LexicalContextMenuPlugin.dev.esm.js +455 -0
  62. package/LexicalContextMenuPlugin.dev.js +3 -1
  63. package/LexicalContextMenuPlugin.esm.js +11 -0
  64. package/LexicalContextMenuPlugin.js +1 -1
  65. package/LexicalContextMenuPlugin.prod.esm.js +7 -0
  66. package/LexicalDecoratorBlockNode.dev.esm.js +46 -0
  67. package/LexicalDecoratorBlockNode.esm.js +11 -0
  68. package/LexicalDecoratorBlockNode.js +1 -1
  69. package/LexicalDecoratorBlockNode.prod.esm.js +7 -0
  70. package/LexicalEditorRefPlugin.dev.esm.js +40 -0
  71. package/LexicalEditorRefPlugin.dev.js +10 -5
  72. package/LexicalEditorRefPlugin.esm.js +10 -0
  73. package/LexicalEditorRefPlugin.js +1 -1
  74. package/LexicalEditorRefPlugin.prod.esm.js +7 -0
  75. package/LexicalEditorRefPlugin.prod.js +1 -1
  76. package/LexicalErrorBoundary.dev.esm.js +157 -0
  77. package/LexicalErrorBoundary.esm.js +10 -0
  78. package/LexicalErrorBoundary.js +1 -1
  79. package/LexicalErrorBoundary.prod.esm.js +7 -0
  80. package/LexicalHashtagPlugin.dev.esm.js +163 -0
  81. package/LexicalHashtagPlugin.esm.js +10 -0
  82. package/LexicalHashtagPlugin.js +1 -1
  83. package/LexicalHashtagPlugin.prod.esm.js +7 -0
  84. package/LexicalHistoryPlugin.dev.esm.js +41 -0
  85. package/LexicalHistoryPlugin.esm.js +11 -0
  86. package/LexicalHistoryPlugin.js +1 -1
  87. package/LexicalHistoryPlugin.prod.esm.js +7 -0
  88. package/LexicalHorizontalRuleNode.dev.esm.js +118 -0
  89. package/LexicalHorizontalRuleNode.dev.js +1 -0
  90. package/LexicalHorizontalRuleNode.esm.js +13 -0
  91. package/LexicalHorizontalRuleNode.js +1 -1
  92. package/LexicalHorizontalRuleNode.prod.esm.js +7 -0
  93. package/LexicalHorizontalRuleNode.prod.js +1 -1
  94. package/LexicalHorizontalRulePlugin.dev.esm.js +39 -0
  95. package/LexicalHorizontalRulePlugin.esm.js +10 -0
  96. package/LexicalHorizontalRulePlugin.js +1 -1
  97. package/LexicalHorizontalRulePlugin.prod.esm.js +7 -0
  98. package/LexicalLinkPlugin.dev.esm.js +79 -0
  99. package/LexicalLinkPlugin.dev.js +6 -2
  100. package/LexicalLinkPlugin.esm.js +10 -0
  101. package/LexicalLinkPlugin.js +1 -1
  102. package/LexicalLinkPlugin.prod.esm.js +7 -0
  103. package/LexicalLinkPlugin.prod.js +1 -1
  104. package/LexicalListPlugin.dev.esm.js +59 -0
  105. package/LexicalListPlugin.esm.js +10 -0
  106. package/LexicalListPlugin.js +1 -1
  107. package/LexicalListPlugin.prod.esm.js +7 -0
  108. package/LexicalMarkdownShortcutPlugin.dev.esm.js +49 -0
  109. package/LexicalMarkdownShortcutPlugin.esm.js +11 -0
  110. package/LexicalMarkdownShortcutPlugin.js +1 -1
  111. package/LexicalMarkdownShortcutPlugin.prod.esm.js +7 -0
  112. package/LexicalNestedComposer.dev.esm.js +105 -0
  113. package/LexicalNestedComposer.esm.js +10 -0
  114. package/LexicalNestedComposer.js +1 -1
  115. package/LexicalNestedComposer.prod.esm.js +7 -0
  116. package/LexicalNodeEventPlugin.dev.esm.js +56 -0
  117. package/LexicalNodeEventPlugin.esm.js +10 -0
  118. package/LexicalNodeEventPlugin.js +1 -1
  119. package/LexicalNodeEventPlugin.prod.esm.js +7 -0
  120. package/LexicalNodeMenuPlugin.dev.esm.js +466 -0
  121. package/LexicalNodeMenuPlugin.dev.js +3 -1
  122. package/LexicalNodeMenuPlugin.esm.js +11 -0
  123. package/LexicalNodeMenuPlugin.js +1 -1
  124. package/LexicalNodeMenuPlugin.prod.esm.js +7 -0
  125. package/LexicalOnChangePlugin.dev.esm.js +62 -0
  126. package/LexicalOnChangePlugin.esm.js +10 -0
  127. package/LexicalOnChangePlugin.js +1 -1
  128. package/LexicalOnChangePlugin.prod.esm.js +7 -0
  129. package/LexicalPlainTextPlugin.dev.esm.js +161 -0
  130. package/LexicalPlainTextPlugin.esm.js +10 -0
  131. package/LexicalPlainTextPlugin.js +1 -1
  132. package/LexicalPlainTextPlugin.prod.esm.js +7 -0
  133. package/LexicalRichTextPlugin.dev.esm.js +161 -0
  134. package/LexicalRichTextPlugin.esm.js +10 -0
  135. package/LexicalRichTextPlugin.js +1 -1
  136. package/LexicalRichTextPlugin.prod.esm.js +7 -0
  137. package/LexicalTabIndentationPlugin.dev.esm.js +76 -0
  138. package/LexicalTabIndentationPlugin.esm.js +11 -0
  139. package/LexicalTabIndentationPlugin.js +1 -1
  140. package/LexicalTabIndentationPlugin.prod.esm.js +7 -0
  141. package/LexicalTableOfContents.dev.esm.js +157 -0
  142. package/LexicalTableOfContents.esm.js +10 -0
  143. package/LexicalTableOfContents.js +1 -1
  144. package/LexicalTableOfContents.prod.esm.js +7 -0
  145. package/LexicalTablePlugin.dev.esm.js +163 -0
  146. package/LexicalTablePlugin.esm.js +10 -0
  147. package/LexicalTablePlugin.js +1 -1
  148. package/LexicalTablePlugin.prod.esm.js +7 -0
  149. package/LexicalTreeView.dev.esm.js +483 -0
  150. package/LexicalTreeView.dev.js +3 -1
  151. package/LexicalTreeView.esm.js +10 -0
  152. package/LexicalTreeView.js +1 -1
  153. package/LexicalTreeView.prod.esm.js +7 -0
  154. package/LexicalTypeaheadMenuPlugin.dev.esm.js +569 -0
  155. package/LexicalTypeaheadMenuPlugin.dev.js +3 -1
  156. package/LexicalTypeaheadMenuPlugin.esm.js +16 -0
  157. package/LexicalTypeaheadMenuPlugin.js +1 -1
  158. package/LexicalTypeaheadMenuPlugin.prod.esm.js +7 -0
  159. package/package.json +583 -20
  160. package/useLexicalEditable.dev.esm.js +82 -0
  161. package/useLexicalEditable.esm.js +10 -0
  162. package/useLexicalEditable.js +1 -1
  163. package/useLexicalEditable.prod.esm.js +7 -0
  164. package/useLexicalIsTextContentEmpty.dev.esm.js +51 -0
  165. package/useLexicalIsTextContentEmpty.esm.js +10 -0
  166. package/useLexicalIsTextContentEmpty.js +1 -1
  167. package/useLexicalIsTextContentEmpty.prod.esm.js +7 -0
  168. package/useLexicalNodeSelection.dev.esm.js +69 -0
  169. package/useLexicalNodeSelection.esm.js +10 -0
  170. package/useLexicalNodeSelection.js +1 -1
  171. package/useLexicalNodeSelection.prod.esm.js +7 -0
  172. package/useLexicalSubscription.dev.esm.js +63 -0
  173. package/useLexicalSubscription.esm.js +10 -0
  174. package/useLexicalSubscription.js +1 -1
  175. package/useLexicalSubscription.prod.esm.js +7 -0
  176. package/useLexicalTextEntity.dev.esm.js +26 -0
  177. package/useLexicalTextEntity.esm.js +10 -0
  178. package/useLexicalTextEntity.js +1 -1
  179. package/useLexicalTextEntity.prod.esm.js +7 -0
@@ -0,0 +1,203 @@
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 { INSERT_CHECK_LIST_COMMAND, insertList, $isListItemNode, $isListNode } from '@lexical/list';
8
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
9
+ import { mergeRegister, $findMatchingParent, isHTMLElement } from '@lexical/utils';
10
+ import { COMMAND_PRIORITY_LOW, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_SPACE_COMMAND, $getNearestNodeFromDOMNode, KEY_ARROW_LEFT_COMMAND, $getSelection, $isRangeSelection, $isElementNode } from 'lexical';
11
+ import { useEffect } from 'react';
12
+
13
+ /**
14
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
15
+ *
16
+ * This source code is licensed under the MIT license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ *
19
+ */
20
+ function CheckListPlugin() {
21
+ const [editor] = useLexicalComposerContext();
22
+ useEffect(() => {
23
+ return mergeRegister(editor.registerCommand(INSERT_CHECK_LIST_COMMAND, () => {
24
+ insertList(editor, 'check');
25
+ return true;
26
+ }, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_ARROW_DOWN_COMMAND, event => {
27
+ return handleArrownUpOrDown(event, editor, false);
28
+ }, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_ARROW_UP_COMMAND, event => {
29
+ return handleArrownUpOrDown(event, editor, true);
30
+ }, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_ESCAPE_COMMAND, event => {
31
+ const activeItem = getActiveCheckListItem();
32
+ if (activeItem != null) {
33
+ const rootElement = editor.getRootElement();
34
+ if (rootElement != null) {
35
+ rootElement.focus();
36
+ }
37
+ return true;
38
+ }
39
+ return false;
40
+ }, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_SPACE_COMMAND, event => {
41
+ const activeItem = getActiveCheckListItem();
42
+ if (activeItem != null && editor.isEditable()) {
43
+ editor.update(() => {
44
+ const listItemNode = $getNearestNodeFromDOMNode(activeItem);
45
+ if ($isListItemNode(listItemNode)) {
46
+ event.preventDefault();
47
+ listItemNode.toggleChecked();
48
+ }
49
+ });
50
+ return true;
51
+ }
52
+ return false;
53
+ }, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_ARROW_LEFT_COMMAND, event => {
54
+ return editor.getEditorState().read(() => {
55
+ const selection = $getSelection();
56
+ if ($isRangeSelection(selection) && selection.isCollapsed()) {
57
+ const {
58
+ anchor
59
+ } = selection;
60
+ const isElement = anchor.type === 'element';
61
+ if (isElement || anchor.offset === 0) {
62
+ const anchorNode = anchor.getNode();
63
+ const elementNode = $findMatchingParent(anchorNode, node => $isElementNode(node) && !node.isInline());
64
+ if ($isListItemNode(elementNode)) {
65
+ const parent = elementNode.getParent();
66
+ if ($isListNode(parent) && parent.getListType() === 'check' && (isElement || elementNode.getFirstDescendant() === anchorNode)) {
67
+ const domNode = editor.getElementByKey(elementNode.__key);
68
+ if (domNode != null && document.activeElement !== domNode) {
69
+ domNode.focus();
70
+ event.preventDefault();
71
+ return true;
72
+ }
73
+ }
74
+ }
75
+ }
76
+ }
77
+ return false;
78
+ });
79
+ }, COMMAND_PRIORITY_LOW), editor.registerRootListener((rootElement, prevElement) => {
80
+ if (rootElement !== null) {
81
+ rootElement.addEventListener('click', handleClick);
82
+ rootElement.addEventListener('pointerdown', handlePointerDown);
83
+ }
84
+ if (prevElement !== null) {
85
+ prevElement.removeEventListener('click', handleClick);
86
+ prevElement.removeEventListener('pointerdown', handlePointerDown);
87
+ }
88
+ }));
89
+ });
90
+ return null;
91
+ }
92
+ function handleCheckItemEvent(event, callback) {
93
+ const target = event.target;
94
+ if (target === null || !isHTMLElement(target)) {
95
+ return;
96
+ }
97
+
98
+ // Ignore clicks on LI that have nested lists
99
+ const firstChild = target.firstChild;
100
+ if (firstChild != null && isHTMLElement(firstChild) && (firstChild.tagName === 'UL' || firstChild.tagName === 'OL')) {
101
+ return;
102
+ }
103
+ const parentNode = target.parentNode;
104
+
105
+ // @ts-ignore internal field
106
+ if (!parentNode || parentNode.__lexicalListType !== 'check') {
107
+ return;
108
+ }
109
+ const pageX = event.pageX;
110
+ const rect = target.getBoundingClientRect();
111
+ if (target.dir === 'rtl' ? pageX < rect.right && pageX > rect.right - 20 : pageX > rect.left && pageX < rect.left + 20) {
112
+ callback();
113
+ }
114
+ }
115
+ function handleClick(event) {
116
+ handleCheckItemEvent(event, () => {
117
+ const domNode = event.target;
118
+ const editor = findEditor(domNode);
119
+ if (editor != null && editor.isEditable()) {
120
+ editor.update(() => {
121
+ if (event.target) {
122
+ const node = $getNearestNodeFromDOMNode(domNode);
123
+ if ($isListItemNode(node)) {
124
+ domNode.focus();
125
+ node.toggleChecked();
126
+ }
127
+ }
128
+ });
129
+ }
130
+ });
131
+ }
132
+ function handlePointerDown(event) {
133
+ handleCheckItemEvent(event, () => {
134
+ // Prevents caret moving when clicking on check mark
135
+ event.preventDefault();
136
+ });
137
+ }
138
+ function findEditor(target) {
139
+ let node = target;
140
+ while (node) {
141
+ // @ts-ignore internal field
142
+ if (node.__lexicalEditor) {
143
+ // @ts-ignore internal field
144
+ return node.__lexicalEditor;
145
+ }
146
+ node = node.parentNode;
147
+ }
148
+ return null;
149
+ }
150
+ function getActiveCheckListItem() {
151
+ const activeElement = document.activeElement;
152
+ return activeElement != null && activeElement.tagName === 'LI' && activeElement.parentNode != null &&
153
+ // @ts-ignore internal field
154
+ activeElement.parentNode.__lexicalListType === 'check' ? activeElement : null;
155
+ }
156
+ function findCheckListItemSibling(node, backward) {
157
+ let sibling = backward ? node.getPreviousSibling() : node.getNextSibling();
158
+ let parent = node;
159
+
160
+ // Going up in a tree to get non-null sibling
161
+ while (sibling == null && $isListItemNode(parent)) {
162
+ // Get li -> parent ul/ol -> parent li
163
+ parent = parent.getParentOrThrow().getParent();
164
+ if (parent != null) {
165
+ sibling = backward ? parent.getPreviousSibling() : parent.getNextSibling();
166
+ }
167
+ }
168
+
169
+ // Going down in a tree to get first non-nested list item
170
+ while ($isListItemNode(sibling)) {
171
+ const firstChild = backward ? sibling.getLastChild() : sibling.getFirstChild();
172
+ if (!$isListNode(firstChild)) {
173
+ return sibling;
174
+ }
175
+ sibling = backward ? firstChild.getLastChild() : firstChild.getFirstChild();
176
+ }
177
+ return null;
178
+ }
179
+ function handleArrownUpOrDown(event, editor, backward) {
180
+ const activeItem = getActiveCheckListItem();
181
+ if (activeItem != null) {
182
+ editor.update(() => {
183
+ const listItem = $getNearestNodeFromDOMNode(activeItem);
184
+ if (!$isListItemNode(listItem)) {
185
+ return;
186
+ }
187
+ const nextListItem = findCheckListItemSibling(listItem, backward);
188
+ if (nextListItem != null) {
189
+ nextListItem.selectStart();
190
+ const dom = editor.getElementByKey(nextListItem.__key);
191
+ if (dom != null) {
192
+ event.preventDefault();
193
+ setTimeout(() => {
194
+ dom.focus();
195
+ }, 0);
196
+ }
197
+ }
198
+ });
199
+ }
200
+ return false;
201
+ }
202
+
203
+ export { CheckListPlugin };
@@ -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 './LexicalCheckListPlugin.dev.esm.js';
8
+ import * as modProd from './LexicalCheckListPlugin.prod.esm.js';
9
+ const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
10
+ export const CheckListPlugin = mod.CheckListPlugin;
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict'
8
- const LexicalCheckListPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalCheckListPlugin.dev.js') : require('./LexicalCheckListPlugin.prod.js')
8
+ const LexicalCheckListPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalCheckListPlugin.dev.js') : require('./LexicalCheckListPlugin.prod.js');
9
9
  module.exports = LexicalCheckListPlugin;
@@ -0,0 +1,7 @@
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{INSERT_CHECK_LIST_COMMAND as e,insertList as t,$isListItemNode as n,$isListNode as r}from"@lexical/list";import{useLexicalComposerContext as i}from"@lexical/react/LexicalComposerContext";import{mergeRegister as l,$findMatchingParent as o,isHTMLElement as c}from"@lexical/utils";import{COMMAND_PRIORITY_LOW as u,KEY_ARROW_DOWN_COMMAND as s,KEY_ARROW_UP_COMMAND as a,KEY_ESCAPE_COMMAND as g,KEY_SPACE_COMMAND as f,$getNearestNodeFromDOMNode as d,KEY_ARROW_LEFT_COMMAND as m,$getSelection as p,$isRangeSelection as C,$isElementNode as h}from"lexical";import{useEffect as v}from"react";function E(){const[c]=i();return v((()=>l(c.registerCommand(e,(()=>(t(c,"check"),!0)),u),c.registerCommand(s,(e=>y(e,c,!1)),u),c.registerCommand(a,(e=>y(e,c,!0)),u),c.registerCommand(g,(e=>{if(null!=k()){const e=c.getRootElement();return null!=e&&e.focus(),!0}return!1}),u),c.registerCommand(f,(e=>{const t=k();return!(null==t||!c.isEditable())&&(c.update((()=>{const r=d(t);n(r)&&(e.preventDefault(),r.toggleChecked())})),!0)}),u),c.registerCommand(m,(e=>c.getEditorState().read((()=>{const t=p();if(C(t)&&t.isCollapsed()){const{anchor:i}=t,l="element"===i.type;if(l||0===i.offset){const t=i.getNode(),u=o(t,(e=>h(e)&&!e.isInline()));if(n(u)){const n=u.getParent();if(r(n)&&"check"===n.getListType()&&(l||u.getFirstDescendant()===t)){const t=c.getElementByKey(u.__key);if(null!=t&&document.activeElement!==t)return t.focus(),e.preventDefault(),!0}}}}return!1}))),u),c.registerRootListener(((e,t)=>{null!==e&&(e.addEventListener("click",x),e.addEventListener("pointerdown",_)),null!==t&&(t.removeEventListener("click",x),t.removeEventListener("pointerdown",_))}))))),null}function L(e,t){const n=e.target;if(null===n||!c(n))return;const r=n.firstChild;if(null!=r&&c(r)&&("UL"===r.tagName||"OL"===r.tagName))return;const i=n.parentNode;if(!i||"check"!==i.__lexicalListType)return;const l=e.pageX,o=n.getBoundingClientRect();("rtl"===n.dir?l<o.right&&l>o.right-20:l>o.left&&l<o.left+20)&&t()}function x(e){L(e,(()=>{const t=e.target,r=function(e){let t=e;for(;t;){if(t.__lexicalEditor)return t.__lexicalEditor;t=t.parentNode}return null}(t);null!=r&&r.isEditable()&&r.update((()=>{if(e.target){const e=d(t);n(e)&&(t.focus(),e.toggleChecked())}}))}))}function _(e){L(e,(()=>{e.preventDefault()}))}function k(){const e=document.activeElement;return null!=e&&"LI"===e.tagName&&null!=e.parentNode&&"check"===e.parentNode.__lexicalListType?e:null}function y(e,t,i){const l=k();return null!=l&&t.update((()=>{const o=d(l);if(!n(o))return;const c=function(e,t){let i=t?e.getPreviousSibling():e.getNextSibling(),l=e;for(;null==i&&n(l);)l=l.getParentOrThrow().getParent(),null!=l&&(i=t?l.getPreviousSibling():l.getNextSibling());for(;n(i);){const e=t?i.getLastChild():i.getFirstChild();if(!r(e))return i;i=t?e.getLastChild():e.getFirstChild()}return null}(o,i);if(null!=c){c.selectStart();const n=t.getElementByKey(c.__key);null!=n&&(e.preventDefault(),setTimeout((()=>{n.focus()}),0))}})),!1}export{E as CheckListPlugin};
@@ -0,0 +1,64 @@
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 { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
8
+ import { CLEAR_EDITOR_COMMAND, $getRoot, $getSelection, $createParagraphNode, COMMAND_PRIORITY_EDITOR } from 'lexical';
9
+ import { useLayoutEffect as useLayoutEffect$1, useEffect } from 'react';
10
+
11
+ /**
12
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
13
+ *
14
+ * This source code is licensed under the MIT license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ *
17
+ */
18
+
19
+ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
20
+
21
+ /**
22
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
23
+ *
24
+ * This source code is licensed under the MIT license found in the
25
+ * LICENSE file in the root directory of this source tree.
26
+ *
27
+ */
28
+ const useLayoutEffectImpl = CAN_USE_DOM ? useLayoutEffect$1 : useEffect;
29
+ var useLayoutEffect = useLayoutEffectImpl;
30
+
31
+ /**
32
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
33
+ *
34
+ * This source code is licensed under the MIT license found in the
35
+ * LICENSE file in the root directory of this source tree.
36
+ *
37
+ */
38
+ function ClearEditorPlugin({
39
+ onClear
40
+ }) {
41
+ const [editor] = useLexicalComposerContext();
42
+ useLayoutEffect(() => {
43
+ return editor.registerCommand(CLEAR_EDITOR_COMMAND, payload => {
44
+ editor.update(() => {
45
+ if (onClear == null) {
46
+ const root = $getRoot();
47
+ const selection = $getSelection();
48
+ const paragraph = $createParagraphNode();
49
+ root.clear();
50
+ root.append(paragraph);
51
+ if (selection !== null) {
52
+ paragraph.select();
53
+ }
54
+ } else {
55
+ onClear();
56
+ }
57
+ });
58
+ return true;
59
+ }, COMMAND_PRIORITY_EDITOR);
60
+ }, [editor, onClear]);
61
+ return null;
62
+ }
63
+
64
+ export { ClearEditorPlugin };
@@ -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 './LexicalClearEditorPlugin.dev.esm.js';
8
+ import * as modProd from './LexicalClearEditorPlugin.prod.esm.js';
9
+ const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
10
+ export const ClearEditorPlugin = mod.ClearEditorPlugin;
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict'
8
- const LexicalClearEditorPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalClearEditorPlugin.dev.js') : require('./LexicalClearEditorPlugin.prod.js')
8
+ const LexicalClearEditorPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalClearEditorPlugin.dev.js') : require('./LexicalClearEditorPlugin.prod.js');
9
9
  module.exports = LexicalClearEditorPlugin;
@@ -0,0 +1,7 @@
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{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{CLEAR_EDITOR_COMMAND as o,$getRoot as t,$getSelection as n,$createParagraphNode as r,COMMAND_PRIORITY_EDITOR as l}from"lexical";import{useLayoutEffect as i,useEffect as a}from"react";var c="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?i:a;function d({onClear:i}){const[a]=e();return c((()=>a.registerCommand(o,(e=>(a.update((()=>{if(null==i){const e=t(),o=n(),l=r();e.clear(),e.append(l),null!==o&&l.select()}else i()})),!0)),l)),[a,i]),null}export{d as ClearEditorPlugin};
@@ -0,0 +1,95 @@
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 { $isLinkNode } from '@lexical/link';
8
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
9
+ import { $findMatchingParent, isHTMLAnchorElement } from '@lexical/utils';
10
+ import { getNearestEditorFromDOMNode, $getNearestNodeFromDOMNode, $isElementNode, $getSelection, $isRangeSelection } from 'lexical';
11
+ import { useEffect } from 'react';
12
+
13
+ /**
14
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
15
+ *
16
+ * This source code is licensed under the MIT license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ *
19
+ */
20
+ function findMatchingDOM(startNode, predicate) {
21
+ let node = startNode;
22
+ while (node != null) {
23
+ if (predicate(node)) {
24
+ return node;
25
+ }
26
+ node = node.parentNode;
27
+ }
28
+ return null;
29
+ }
30
+ function LexicalClickableLinkPlugin({
31
+ newTab = true
32
+ }) {
33
+ const [editor] = useLexicalComposerContext();
34
+ useEffect(() => {
35
+ const onClick = event => {
36
+ const target = event.target;
37
+ if (!(target instanceof Node)) {
38
+ return;
39
+ }
40
+ const nearestEditor = getNearestEditorFromDOMNode(target);
41
+ if (nearestEditor === null) {
42
+ return;
43
+ }
44
+ let url = null;
45
+ let urlTarget = null;
46
+ nearestEditor.update(() => {
47
+ const clickedNode = $getNearestNodeFromDOMNode(target);
48
+ if (clickedNode !== null) {
49
+ const maybeLinkNode = $findMatchingParent(clickedNode, $isElementNode);
50
+ if ($isLinkNode(maybeLinkNode)) {
51
+ url = maybeLinkNode.sanitizeUrl(maybeLinkNode.getURL());
52
+ urlTarget = maybeLinkNode.getTarget();
53
+ } else {
54
+ const a = findMatchingDOM(target, isHTMLAnchorElement);
55
+ if (a !== null) {
56
+ url = a.href;
57
+ urlTarget = a.target;
58
+ }
59
+ }
60
+ }
61
+ });
62
+ if (url === null || url === '') {
63
+ return;
64
+ }
65
+
66
+ // Allow user to select link text without follwing url
67
+ const selection = editor.getEditorState().read($getSelection);
68
+ if ($isRangeSelection(selection) && !selection.isCollapsed()) {
69
+ event.preventDefault();
70
+ return;
71
+ }
72
+ const isMiddle = event.type === 'auxclick' && event.button === 1;
73
+ window.open(url, newTab || isMiddle || event.metaKey || event.ctrlKey || urlTarget === '_blank' ? '_blank' : '_self');
74
+ event.preventDefault();
75
+ };
76
+ const onMouseUp = event => {
77
+ if (event.button === 1 && editor.isEditable()) {
78
+ onClick(event);
79
+ }
80
+ };
81
+ return editor.registerRootListener((rootElement, prevRootElement) => {
82
+ if (prevRootElement !== null) {
83
+ prevRootElement.removeEventListener('click', onClick);
84
+ prevRootElement.removeEventListener('mouseup', onMouseUp);
85
+ }
86
+ if (rootElement !== null) {
87
+ rootElement.addEventListener('click', onClick);
88
+ rootElement.addEventListener('mouseup', onMouseUp);
89
+ }
90
+ });
91
+ }, [editor, newTab]);
92
+ return null;
93
+ }
94
+
95
+ export { LexicalClickableLinkPlugin as 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 './LexicalClickableLinkPlugin.dev.esm.js';
8
+ import * as modProd from './LexicalClickableLinkPlugin.prod.esm.js';
9
+ const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
10
+ export default mod.default;
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict'
8
- const LexicalClickableLinkPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalClickableLinkPlugin.dev.js') : require('./LexicalClickableLinkPlugin.prod.js')
8
+ const LexicalClickableLinkPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalClickableLinkPlugin.dev.js') : require('./LexicalClickableLinkPlugin.prod.js');
9
9
  module.exports = LexicalClickableLinkPlugin;
@@ -0,0 +1,7 @@
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{$isLinkNode as e}from"@lexical/link";import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as n,isHTMLAnchorElement as r}from"@lexical/utils";import{getNearestEditorFromDOMNode as l,$getNearestNodeFromDOMNode as o,$isElementNode as i,$getSelection as u,$isRangeSelection as a}from"lexical";import{useEffect as s}from"react";function c({newTab:c=!0}){const[f]=t();return s((()=>{const t=t=>{const s=t.target;if(!(s instanceof Node))return;const m=l(s);if(null===m)return;let p=null,d=null;if(m.update((()=>{const t=o(s);if(null!==t){const l=n(t,i);if(e(l))p=l.sanitizeUrl(l.getURL()),d=l.getTarget();else{const e=function(e,t){let n=e;for(;null!=n;){if(t(n))return n;n=n.parentNode}return null}(s,r);null!==e&&(p=e.href,d=e.target)}}})),null===p||""===p)return;const v=f.getEditorState().read(u);if(a(v)&&!v.isCollapsed())return void t.preventDefault();const x="auxclick"===t.type&&1===t.button;window.open(p,c||x||t.metaKey||t.ctrlKey||"_blank"===d?"_blank":"_self"),t.preventDefault()},s=e=>{1===e.button&&f.isEditable()&&t(e)};return f.registerRootListener(((e,n)=>{null!==n&&(n.removeEventListener("click",t),n.removeEventListener("mouseup",s)),null!==e&&(e.addEventListener("click",t),e.addEventListener("mouseup",s))}))}),[f,c]),null}export{c as default};
@@ -0,0 +1,36 @@
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 { createContext, useContext } from 'react';
8
+
9
+ /**
10
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
11
+ *
12
+ * This source code is licensed under the MIT license found in the
13
+ * LICENSE file in the root directory of this source tree.
14
+ *
15
+ */
16
+ const entries = [['Cat', 'rgb(125, 50, 0)'], ['Dog', 'rgb(100, 0, 0)'], ['Rabbit', 'rgb(150, 0, 0)'], ['Frog', 'rgb(200, 0, 0)'], ['Fox', 'rgb(200, 75, 0)'], ['Hedgehog', 'rgb(0, 75, 0)'], ['Pigeon', 'rgb(0, 125, 0)'], ['Squirrel', 'rgb(75, 100, 0)'], ['Bear', 'rgb(125, 100, 0)'], ['Tiger', 'rgb(0, 0, 150)'], ['Leopard', 'rgb(0, 0, 200)'], ['Zebra', 'rgb(0, 0, 250)'], ['Wolf', 'rgb(0, 100, 150)'], ['Owl', 'rgb(0, 100, 100)'], ['Gull', 'rgb(100, 0, 100)'], ['Squid', 'rgb(150, 0, 150)']];
17
+ const randomEntry = entries[Math.floor(Math.random() * entries.length)];
18
+ const CollaborationContext = /*#__PURE__*/createContext({
19
+ clientID: 0,
20
+ color: randomEntry[1],
21
+ isCollabActive: false,
22
+ name: randomEntry[0],
23
+ yjsDocMap: new Map()
24
+ });
25
+ function useCollaborationContext(username, color) {
26
+ const collabContext = useContext(CollaborationContext);
27
+ if (username != null) {
28
+ collabContext.name = username;
29
+ }
30
+ if (color != null) {
31
+ collabContext.color = color;
32
+ }
33
+ return collabContext;
34
+ }
35
+
36
+ export { CollaborationContext, useCollaborationContext };
@@ -0,0 +1,11 @@
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 './LexicalCollaborationContext.dev.esm.js';
8
+ import * as modProd from './LexicalCollaborationContext.prod.esm.js';
9
+ const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
10
+ export const CollaborationContext = mod.CollaborationContext;
11
+ export const useCollaborationContext = mod.useCollaborationContext;
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict'
8
- const LexicalCollaborationContext = process.env.NODE_ENV === 'development' ? require('./LexicalCollaborationContext.dev.js') : require('./LexicalCollaborationContext.prod.js')
8
+ const LexicalCollaborationContext = process.env.NODE_ENV === 'development' ? require('./LexicalCollaborationContext.dev.js') : require('./LexicalCollaborationContext.prod.js');
9
9
  module.exports = LexicalCollaborationContext;
@@ -0,0 +1,7 @@
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{createContext as r,useContext as g}from"react";const o=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],b=o[Math.floor(Math.random()*o.length)],e=r({clientID:0,color:b[1],isCollabActive:!1,name:b[0],yjsDocMap:new Map});function l(r,o){const b=g(e);return null!=r&&(b.name=r),null!=o&&(b.color=o),b}export{e as CollaborationContext,l as useCollaborationContext};