@lexical/react 0.1.14 → 0.1.15

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 (33) hide show
  1. package/DEPRECATED_useLexicalAutoFormatter.dev.js +283 -295
  2. package/DEPRECATED_useLexicalAutoFormatter.prod.js +19 -21
  3. package/DEPRECATED_useLexicalCanShowPlaceholder.dev.js +3 -72
  4. package/DEPRECATED_useLexicalCanShowPlaceholder.prod.js +1 -2
  5. package/DEPRECATED_useLexicalCharacterLimit.dev.js +11 -63
  6. package/DEPRECATED_useLexicalCharacterLimit.prod.js +6 -7
  7. package/DEPRECATED_useLexicalPlainText.dev.js +16 -41
  8. package/DEPRECATED_useLexicalPlainText.prod.js +13 -14
  9. package/DEPRECATED_useLexicalRichText.dev.js +24 -49
  10. package/DEPRECATED_useLexicalRichText.prod.js +15 -15
  11. package/LexicalAutoFormatterPlugin.dev.js +283 -295
  12. package/LexicalAutoFormatterPlugin.prod.js +19 -21
  13. package/LexicalAutoLinkPlugin.dev.js +2 -2
  14. package/LexicalAutoLinkPlugin.prod.js +2 -2
  15. package/LexicalCharacterLimitPlugin.dev.js +11 -63
  16. package/LexicalCharacterLimitPlugin.prod.js +8 -9
  17. package/LexicalCollaborationPlugin.d.ts +3 -1
  18. package/LexicalCollaborationPlugin.dev.js +40 -6
  19. package/LexicalCollaborationPlugin.js.flow +4 -1
  20. package/LexicalCollaborationPlugin.prod.js +8 -7
  21. package/LexicalHashtagPlugin.dev.js +16 -13
  22. package/LexicalHashtagPlugin.prod.js +7 -7
  23. package/LexicalOnChangePlugin.dev.js +15 -2
  24. package/LexicalOnChangePlugin.prod.js +2 -1
  25. package/LexicalPlainTextPlugin.dev.js +20 -113
  26. package/LexicalPlainTextPlugin.prod.js +11 -12
  27. package/LexicalRichTextPlugin.dev.js +28 -121
  28. package/LexicalRichTextPlugin.prod.js +12 -13
  29. package/LexicalTablePlugin.dev.js +9 -5
  30. package/LexicalTablePlugin.prod.js +2 -2
  31. package/package.json +9 -7
  32. package/useLexicalIsTextContentEmpty.dev.js +3 -32
  33. package/useLexicalIsTextContentEmpty.prod.js +1 -2
@@ -72,7 +72,7 @@ function TablePlugin() {
72
72
  }, EditorPriority);
73
73
  }, [editor]);
74
74
  react.useEffect(() => {
75
- const listeners = new Map();
75
+ const tableSelections = new Map();
76
76
  return editor.addListener('mutation', table.TableNode, nodeMutations => {
77
77
  // eslint-disable-next-line no-for-of-loops/no-for-of-loops
78
78
  for (const [nodeKey, mutation] of nodeMutations) {
@@ -82,13 +82,17 @@ function TablePlugin() {
82
82
  const tableNode = lexical.$getNodeByKey(nodeKey);
83
83
 
84
84
  if (tableElement && tableNode) {
85
- const removeListeners = table.$applyCustomTableHandlers(tableNode, tableElement, editor);
86
- listeners.set(nodeKey, removeListeners);
85
+ const tableSelection = table.applyTableHandlers(tableNode, tableElement, editor);
86
+ tableSelections.set(nodeKey, tableSelection);
87
87
  }
88
88
  });
89
89
  } else if (mutation === 'destroyed') {
90
- const cleanup = listeners.get(nodeKey);
91
- if (cleanup) cleanup();
90
+ const tableSelection = tableSelections.get(nodeKey);
91
+
92
+ if (tableSelection) {
93
+ tableSelection.removeListeners();
94
+ tableSelections.delete(nodeKey);
95
+ }
92
96
  }
93
97
  }
94
98
  });
@@ -6,5 +6,5 @@
6
6
  */
7
7
  var e=require("@lexical/react/LexicalComposerContext"),g=require("@lexical/table"),k=require("lexical"),m=require("react");
8
8
  module.exports=function(){const [d]=e.useLexicalComposerContext();m.useEffect(()=>{if(!d.hasNodes([g.TableNode,g.TableCellNode,g.TableRowNode]))throw Error("Minified Lexical error #54; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return d.addListener("command",(a,b)=>{if("insertTable"===a){const {columns:h,rows:f}=b;a=k.$getSelection();if(!k.$isRangeSelection(a))return!0;var c=a.focus;a=c.getNode();null!==a&&(b=g.$createTableNodeWithDimensions(f,
9
- h),k.$isRootNode(a)?(c=a.getChildAtIndex(c.offset),null!==c?c.insertBefore(b):a.append(b)):a.getTopLevelElementOrThrow().insertAfter(b),b.insertAfter(k.$createParagraphNode()),b.getFirstChildOrThrow().getFirstChildOrThrow().select());return!0}return!1},0)},[d]);m.useEffect(()=>{const a=new Map;return d.addListener("mutation",g.TableNode,b=>{for(const [c,h]of b)"created"===h?d.update(()=>{var f=d.getElementByKey(c);const l=k.$getNodeByKey(c);f&&l&&(f=g.$applyCustomTableHandlers(l,f,d),a.set(c,f))}):
10
- "destroyed"===h&&(b=a.get(c))&&b()})},[d]);return null};
9
+ h),k.$isRootNode(a)?(c=a.getChildAtIndex(c.offset),null!==c?c.insertBefore(b):a.append(b)):a.getTopLevelElementOrThrow().insertAfter(b),b.insertAfter(k.$createParagraphNode()),b.getFirstChildOrThrow().getFirstChildOrThrow().select());return!0}return!1},0)},[d]);m.useEffect(()=>{const a=new Map;return d.addListener("mutation",g.TableNode,b=>{for(const [c,h]of b)"created"===h?d.update(()=>{var f=d.getElementByKey(c);const l=k.$getNodeByKey(c);f&&l&&(f=g.applyTableHandlers(l,f,d),a.set(c,f))}):"destroyed"===
10
+ h&&(b=a.get(c))&&(b.removeListeners(),a.delete(c))})},[d]);return null};
package/package.json CHANGED
@@ -12,16 +12,18 @@
12
12
  "rich-text"
13
13
  ],
14
14
  "license": "MIT",
15
- "version": "0.1.14",
15
+ "version": "0.1.15",
16
16
  "dependencies": {
17
- "@lexical/helpers": "0.1.14",
18
- "@lexical/clipboard": "0.1.14",
19
- "@lexical/list": "0.1.14",
20
- "@lexical/table": "0.1.14",
21
- "@lexical/yjs": "0.1.14"
17
+ "@lexical/clipboard": "0.1.15",
18
+ "@lexical/list": "0.1.15",
19
+ "@lexical/table": "0.1.15",
20
+ "@lexical/yjs": "0.1.15",
21
+ "@lexical/hashtag": "0.1.15",
22
+ "@lexical/selection": "0.1.15",
23
+ "@lexical/utils": "0.1.15"
22
24
  },
23
25
  "peerDependencies": {
24
- "lexical": "0.1.14",
26
+ "lexical": "0.1.15",
25
27
  "react": ">=17.x",
26
28
  "react-dom": ">=17.x"
27
29
  },
@@ -6,38 +6,9 @@
6
6
  */
7
7
  'use strict';
8
8
 
9
- var lexical = require('lexical');
9
+ var text = require('@lexical/text');
10
10
  var react = require('react');
11
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
- */
20
- function $textContent() {
21
- const root = lexical.$getRoot();
22
- return root.getTextContent();
23
- }
24
- function $isTextContentEmpty(isEditorComposing, trim = true) {
25
- if (isEditorComposing) {
26
- return false;
27
- }
28
-
29
- let text = $textContent();
30
-
31
- if (trim) {
32
- text = text.trim();
33
- }
34
-
35
- return text === '';
36
- }
37
- function $isTextContentEmptyCurry(isEditorComposing, trim) {
38
- return () => $isTextContentEmpty(isEditorComposing, trim);
39
- }
40
-
41
12
  /**
42
13
  * Copyright (c) Meta Platforms, Inc. and affiliates.
43
14
  *
@@ -68,13 +39,13 @@ var useLayoutEffect = useLayoutEffectImpl;
68
39
  *
69
40
  */
70
41
  function useLexicalIsTextContentEmpty(editor, trim) {
71
- const [isEmpty, setIsEmpty] = react.useState(editor.getEditorState().read($isTextContentEmptyCurry(editor.isComposing(), trim)));
42
+ const [isEmpty, setIsEmpty] = react.useState(editor.getEditorState().read(text.$isRootTextContentEmptyCurry(editor.isComposing(), trim)));
72
43
  useLayoutEffect(() => {
73
44
  return editor.addListener('update', ({
74
45
  editorState
75
46
  }) => {
76
47
  const isComposing = editor.isComposing();
77
- const currentIsEmpty = editorState.read($isTextContentEmptyCurry(isComposing, trim));
48
+ const currentIsEmpty = editorState.read(text.$isRootTextContentEmptyCurry(isComposing, trim));
78
49
  setIsEmpty(currentIsEmpty);
79
50
  });
80
51
  }, [editor, trim]);
@@ -4,5 +4,4 @@
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
- var c=require("lexical"),e=require("react");function f(a,b=!0){if(a)return!1;a=c.$getRoot().getTextContent();b&&(a=a.trim());return""===a}function g(a,b){return()=>f(a,b)}var h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?e.useLayoutEffect:e.useEffect;
8
- module.exports=function(a,b){const [k,l]=e.useState(a.getEditorState().read(g(a.isComposing(),b)));h(()=>a.addListener("update",({editorState:d})=>{const m=a.isComposing();d=d.read(g(m,b));l(d)}),[a,b]);return k};
7
+ var b=require("@lexical/text"),e=require("react"),f="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?e.useLayoutEffect:e.useEffect;module.exports=function(a,c){const [g,h]=e.useState(a.getEditorState().read(b.$isRootTextContentEmptyCurry(a.isComposing(),c)));f(()=>a.addListener("update",({editorState:d})=>{const k=a.isComposing();d=d.read(b.$isRootTextContentEmptyCurry(k,c));h(d)}),[a,c]);return g};