@lexical/clipboard 0.12.6 → 0.13.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.
package/LexicalClipboard.dev.js
CHANGED
|
@@ -191,12 +191,12 @@ function exportNodeToJSON(node) {
|
|
|
191
191
|
return serializedNode;
|
|
192
192
|
}
|
|
193
193
|
function $appendNodesToJSON(editor, selection$1, currentNode, targetArray = []) {
|
|
194
|
-
let shouldInclude = selection$1
|
|
194
|
+
let shouldInclude = selection$1 !== null ? currentNode.isSelected(selection$1) : true;
|
|
195
195
|
const shouldExclude = lexical.$isElementNode(currentNode) && currentNode.excludeFromCopy('html');
|
|
196
196
|
let target = currentNode;
|
|
197
197
|
if (selection$1 !== null) {
|
|
198
198
|
let clone = selection.$cloneWithProperties(currentNode);
|
|
199
|
-
clone = lexical.$isTextNode(clone) && selection$1
|
|
199
|
+
clone = lexical.$isTextNode(clone) && selection$1 !== null ? selection.$sliceSelectedTextNodeContent(selection$1, clone) : clone;
|
|
200
200
|
target = clone;
|
|
201
201
|
}
|
|
202
202
|
const children = lexical.$isElementNode(target) ? target.getChildren() : [];
|
package/LexicalClipboard.js.flow
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
import type {
|
|
11
11
|
BaseSelection,
|
|
12
12
|
LexicalEditor,
|
|
13
|
-
INTERNAL_PointSelection,
|
|
14
13
|
RangeSelection,
|
|
15
14
|
LexicalNode,
|
|
16
15
|
} from 'lexical';
|
|
@@ -21,7 +20,7 @@ import type {
|
|
|
21
20
|
|
|
22
21
|
declare export function $insertDataTransferForRichText(
|
|
23
22
|
dataTransfer: DataTransfer,
|
|
24
|
-
selection:
|
|
23
|
+
selection: BaseSelection,
|
|
25
24
|
editor: LexicalEditor,
|
|
26
25
|
): void;
|
|
27
26
|
|
|
@@ -33,7 +32,7 @@ declare export function $getLexicalContent(
|
|
|
33
32
|
declare export function $insertGeneratedNodes(
|
|
34
33
|
editor: LexicalEditor,
|
|
35
34
|
nodes: Array<LexicalNode>,
|
|
36
|
-
selection:
|
|
35
|
+
selection: BaseSelection,
|
|
37
36
|
): void;
|
|
38
37
|
/*
|
|
39
38
|
* Plain Text
|
package/LexicalClipboard.prod.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
'use strict';var f=require("@lexical/html"),m=require("@lexical/selection"),q=require("@lexical/utils"),r=require("lexical");function t(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c<arguments.length;c++)b.append("v",arguments[c]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${b} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
|
|
8
8
|
let u="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement;function v(a){let b=r.$getSelection();if(null==b)throw Error("Expected valid LexicalSelection");return r.$isRangeSelection(b)&&b.isCollapsed()||0===b.getNodes().length?"":f.$generateHtmlFromNodes(a,b)}
|
|
9
9
|
function w(a){let b=r.$getSelection();if(null==b)throw Error("Expected valid LexicalSelection");return r.$isRangeSelection(b)&&b.isCollapsed()||0===b.getNodes().length?null:JSON.stringify(x(a,b))}function y(a,b,c){a.dispatchCommand(r.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:b,selection:c})||c.insertNodes(b)}
|
|
10
|
-
function z(a,b,c,d=[]){let e=null
|
|
10
|
+
function z(a,b,c,d=[]){let e=null!==b?c.isSelected(b):!0,h=r.$isElementNode(c)&&c.excludeFromCopy("html");var g=c;if(null!==b){var k=m.$cloneWithProperties(c);g=k=r.$isTextNode(k)&&null!==b?m.$sliceSelectedTextNodeContent(b,k):k}let n=r.$isElementNode(g)?g.getChildren():[];var l=g;k=l.exportJSON();var p=l.constructor;k.type!==p.getType()&&t(58,p.name);r.$isElementNode(l)&&(Array.isArray(k.children)||t(59,p.name));r.$isTextNode(g)&&(g=g.__text,0<g.length?k.text=g:e=!1);for(g=0;g<n.length;g++)l=n[g],
|
|
11
11
|
p=z(a,b,l,k.children),!e&&r.$isElementNode(c)&&p&&c.extractWithChild(l,b,"clone")&&(e=!0);if(e&&!h)d.push(k);else if(Array.isArray(k.children))for(a=0;a<k.children.length;a++)d.push(k.children[a]);return e}function x(a,b){let c=[],d=r.$getRoot().getChildren();for(let e=0;e<d.length;e++)z(a,b,d[e],c);return{namespace:a._config.namespace,nodes:c}}function A(a){let b=[];for(let c=0;c<a.length;c++){let d=r.$parseSerializedNode(a[c]);r.$isTextNode(d)&&m.$addNodeStyle(d);b.push(d)}return b}let B=null;
|
|
12
12
|
function C(a,b){var c=u?(a._window||window).getSelection():null;if(!c)return!1;var d=c.anchorNode;c=c.focusNode;if(null!==d&&null!==c&&!r.isSelectionWithinEditor(a,d,c))return!1;b.preventDefault();b=b.clipboardData;d=r.$getSelection();if(null===b||null===d)return!1;c=v(a);a=w(a);let e="";null!==d&&(e=d.getTextContent());null!==c&&b.setData("text/html",c);null!==a&&b.setData("application/x-lexical-editor",a);b.setData("text/plain",e);return!0}exports.$generateJSONFromSelectedNodes=x;
|
|
13
13
|
exports.$generateNodesFromSerializedNodes=A;exports.$getHtmlContent=v;exports.$getLexicalContent=w;exports.$insertDataTransferForPlainText=function(a,b){a=a.getData("text/plain")||a.getData("text/uri-list");null!=a&&b.insertRawText(a)};
|
package/package.json
CHANGED
|
@@ -9,16 +9,16 @@
|
|
|
9
9
|
"paste"
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"version": "0.
|
|
12
|
+
"version": "0.13.1",
|
|
13
13
|
"main": "LexicalClipboard.js",
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"lexical": "0.
|
|
15
|
+
"lexical": "0.13.1"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@lexical/utils": "0.
|
|
19
|
-
"@lexical/list": "0.
|
|
20
|
-
"@lexical/selection": "0.
|
|
21
|
-
"@lexical/html": "0.
|
|
18
|
+
"@lexical/utils": "0.13.1",
|
|
19
|
+
"@lexical/list": "0.13.1",
|
|
20
|
+
"@lexical/selection": "0.13.1",
|
|
21
|
+
"@lexical/html": "0.13.1"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|