@lexical/react 0.7.0 → 0.7.1

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.
@@ -62,11 +62,16 @@ function LinkPlugin({
62
62
 
63
63
  if (!validateUrl(clipboardText)) {
64
64
  return false;
65
+ } // If we select nodes that are elements then avoid applying the link.
66
+
67
+
68
+ if (!selection.getNodes().some(node => lexical.$isElementNode(node))) {
69
+ editor.dispatchCommand(link.TOGGLE_LINK_COMMAND, clipboardText);
70
+ event.preventDefault();
71
+ return true;
65
72
  }
66
73
 
67
- editor.dispatchCommand(link.TOGGLE_LINK_COMMAND, clipboardText);
68
- event.preventDefault();
69
- return true;
74
+ return false;
70
75
  }, lexical.COMMAND_PRIORITY_LOW) : () => {// Don't paste arbritrary text as a link when there's no validate function
71
76
  });
72
77
  }, [editor, validateUrl]);
@@ -4,6 +4,6 @@
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
- 'use strict';var c=require("@lexical/link"),d=require("@lexical/react/LexicalComposerContext"),g=require("@lexical/utils"),h=require("lexical"),k=require("react");
8
- exports.LinkPlugin=function({validateUrl:e}){let [f]=d.useLexicalComposerContext();k.useEffect(()=>{if(!f.hasNodes([c.LinkNode]))throw Error("LinkPlugin: LinkNode not registered on editor");return g.mergeRegister(f.registerCommand(c.TOGGLE_LINK_COMMAND,a=>{if(null===a)return c.toggleLink(a),!0;if("string"===typeof a)return void 0===e||e(a)?(c.toggleLink(a),!0):!1;let {url:b,target:l,rel:m}=a;c.toggleLink(b,{rel:m,target:l});return!0},h.COMMAND_PRIORITY_LOW),void 0!==e?f.registerCommand(h.PASTE_COMMAND,
9
- a=>{var b=h.$getSelection();if(!h.$isRangeSelection(b)||b.isCollapsed()||!(a instanceof ClipboardEvent)||null==a.clipboardData)return!1;b=a.clipboardData.getData("text");if(!e(b))return!1;f.dispatchCommand(c.TOGGLE_LINK_COMMAND,b);a.preventDefault();return!0},h.COMMAND_PRIORITY_LOW):()=>{})},[f,e]);return null}
7
+ 'use strict';var b=require("@lexical/link"),c=require("@lexical/react/LexicalComposerContext"),k=require("@lexical/utils"),l=require("lexical"),m=require("react");
8
+ exports.LinkPlugin=function({validateUrl:d}){let [e]=c.useLexicalComposerContext();m.useEffect(()=>{if(!e.hasNodes([b.LinkNode]))throw Error("LinkPlugin: LinkNode not registered on editor");return k.mergeRegister(e.registerCommand(b.TOGGLE_LINK_COMMAND,a=>{if(null===a)return b.toggleLink(a),!0;if("string"===typeof a)return void 0===d||d(a)?(b.toggleLink(a),!0):!1;let {url:f,target:g,rel:h}=a;b.toggleLink(f,{rel:h,target:g});return!0},l.COMMAND_PRIORITY_LOW),void 0!==d?e.registerCommand(l.PASTE_COMMAND,
9
+ a=>{let f=l.$getSelection();if(!l.$isRangeSelection(f)||f.isCollapsed()||!(a instanceof ClipboardEvent)||null==a.clipboardData)return!1;let g=a.clipboardData.getData("text");return d(g)?f.getNodes().some(h=>l.$isElementNode(h))?!1:(e.dispatchCommand(b.TOGGLE_LINK_COMMAND,g),a.preventDefault(),!0):!1},l.COMMAND_PRIORITY_LOW):()=>{})},[e,d]);return null}
@@ -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
+ * @flow strict
8
+ */
9
+
10
+ declare export function TabIndentationPlugin(): null;
package/package.json CHANGED
@@ -8,29 +8,29 @@
8
8
  "rich-text"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.7.0",
11
+ "version": "0.7.1",
12
12
  "dependencies": {
13
- "@lexical/clipboard": "0.7.0",
14
- "@lexical/code": "0.7.0",
15
- "@lexical/dragon": "0.7.0",
16
- "@lexical/hashtag": "0.7.0",
17
- "@lexical/history": "0.7.0",
18
- "@lexical/link": "0.7.0",
19
- "@lexical/list": "0.7.0",
20
- "@lexical/mark": "0.7.0",
21
- "@lexical/markdown": "0.7.0",
22
- "@lexical/overflow": "0.7.0",
23
- "@lexical/plain-text": "0.7.0",
24
- "@lexical/rich-text": "0.7.0",
25
- "@lexical/selection": "0.7.0",
26
- "@lexical/table": "0.7.0",
27
- "@lexical/text": "0.7.0",
28
- "@lexical/utils": "0.7.0",
29
- "@lexical/yjs": "0.7.0",
13
+ "@lexical/clipboard": "0.7.1",
14
+ "@lexical/code": "0.7.1",
15
+ "@lexical/dragon": "0.7.1",
16
+ "@lexical/hashtag": "0.7.1",
17
+ "@lexical/history": "0.7.1",
18
+ "@lexical/link": "0.7.1",
19
+ "@lexical/list": "0.7.1",
20
+ "@lexical/mark": "0.7.1",
21
+ "@lexical/markdown": "0.7.1",
22
+ "@lexical/overflow": "0.7.1",
23
+ "@lexical/plain-text": "0.7.1",
24
+ "@lexical/rich-text": "0.7.1",
25
+ "@lexical/selection": "0.7.1",
26
+ "@lexical/table": "0.7.1",
27
+ "@lexical/text": "0.7.1",
28
+ "@lexical/utils": "0.7.1",
29
+ "@lexical/yjs": "0.7.1",
30
30
  "react-error-boundary": "^3.1.4"
31
31
  },
32
32
  "peerDependencies": {
33
- "lexical": "0.7.0",
33
+ "lexical": "0.7.1",
34
34
  "react": ">=17.x",
35
35
  "react-dom": ">=17.x"
36
36
  },