@lexical/clipboard 0.3.6 → 0.3.9
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 +3 -2
- package/LexicalClipboard.prod.js +12 -12
- package/package.json +6 -5
package/LexicalClipboard.dev.js
CHANGED
|
@@ -75,9 +75,10 @@ function $insertDataTransferForRichText(dataTransfer, selection, editor) {
|
|
|
75
75
|
try {
|
|
76
76
|
const parser = new DOMParser();
|
|
77
77
|
const dom = parser.parseFromString(htmlString, 'text/html');
|
|
78
|
-
|
|
78
|
+
const nodes = html.$generateNodesFromDOM(editor, dom);
|
|
79
|
+
return $insertGeneratedNodes(editor, nodes, selection); // eslint-disable-next-line no-empty
|
|
79
80
|
} catch {}
|
|
80
|
-
} // Multi-line plain text in rich text mode pasted as separate
|
|
81
|
+
} // Multi-line plain text in rich text mode pasted as separate paragraphs
|
|
81
82
|
// instead of single paragraph with linebreaks.
|
|
82
83
|
|
|
83
84
|
|
package/LexicalClipboard.prod.js
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
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 d=require("@lexical/html"),p=require("@lexical/list"),r=require("@lexical/selection"),y=require("@lexical/utils"),z=require("lexical");function A(
|
|
8
|
-
function B(
|
|
9
|
-
function F(
|
|
10
|
-
|
|
11
|
-
function E(
|
|
12
|
-
1,h+e-1);e=Math.min(h,
|
|
13
|
-
u.append(v)});H.forEach(v=>v.remove());C++}
|
|
14
|
-
function G(
|
|
15
|
-
c,"clone")&&(f=!0);if(f&&!h)g.push(l);else if(Array.isArray(l.children))for(
|
|
16
|
-
exports.$getLexicalContent=function(
|
|
17
|
-
exports.$insertDataTransferForRichText=function(
|
|
18
|
-
if(null!=
|
|
7
|
+
'use strict';var d=require("@lexical/html"),p=require("@lexical/list"),r=require("@lexical/selection"),y=require("@lexical/utils"),z=require("lexical");function A(a){throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?code=${a} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
|
|
8
|
+
function B(a,c,e){(z.$isGridSelection(e)||null!==y.$findMatchingParent(e.anchor.getNode(),g=>z.$isGridCellNode(g))&&null!==y.$findMatchingParent(e.focus.getNode(),g=>z.$isGridCellNode(g)))&&1===c.length&&z.$isGridNode(c[0])?E(c,e,!1,a):F(c,e)}
|
|
9
|
+
function F(a,c){let e=[],g=null,f=null;for(let h=0;h<a.length;h++){let b=a[h];p.$isListItemNode(b)?(null==f&&(f=p.$createListNode("bullet"),e.push(f)),f.append(b)):(null!=f&&(f=null),z.$isDecoratorNode(b)&&!b.isTopLevel()||z.$isElementNode(b)&&b.isInline()||z.$isTextNode(b)||z.$isLineBreakNode(b)?(null===g&&(g=z.$createParagraphNode(),e.push(g)),null!==g&&g.append(b)):(e.push(b),g=null))}z.$isRangeSelection(c)?c.insertNodes(e):z.$isGridSelection(c)&&(a=c.anchor.getNode(),z.$isGridCellNode(a)||A(41),
|
|
10
|
+
a.append(...e))}
|
|
11
|
+
function E(a,c,e,g){1===a.length&&z.$isGridNode(a[0])||A(42);var f=a[0];a=f.getChildren();e=f.getFirstChildOrThrow().getChildrenSize();var h=f.getChildrenSize(),b=y.$findMatchingParent(c.anchor.getNode(),m=>z.$isGridCellNode(m));c=(f=b&&y.$findMatchingParent(b,m=>z.$isGridRowNode(m)))&&y.$findMatchingParent(f,m=>z.$isGridNode(m));z.$isGridCellNode(b)&&z.$isGridRowNode(f)&&z.$isGridNode(c)||A(43);var k=f.getIndexWithinParent(),n=Math.min(c.getChildrenSize()-1,k+h-1);h=b.getIndexWithinParent();b=Math.min(f.getChildrenSize()-
|
|
12
|
+
1,h+e-1);e=Math.min(h,b);f=Math.min(k,n);h=Math.max(h,b);k=Math.max(k,n);n=c.getChildren();b=0;let l,q;for(let m=f;m<=k;m++){var w=n[m];z.$isGridRowNode(w)||A(24);var x=a[b];z.$isGridRowNode(x)||A(24);w=w.getChildren();x=x.getChildren();let C=0;for(let t=e;t<=h;t++){let u=w[t];z.$isGridCellNode(u)||A(25);let D=x[C];z.$isGridCellNode(D)||A(25);m===f&&t===e?l=u.getKey():m===k&&t===h&&(q=u.getKey());let H=u.getChildren();D.getChildren().forEach(v=>{z.$isTextNode(v)&&z.$createParagraphNode().append(v);
|
|
13
|
+
u.append(v)});H.forEach(v=>v.remove());C++}b++}l&&q&&(a=z.$createGridSelection(),a.set(c.getKey(),l,q),z.$setSelection(a),g.dispatchCommand(z.SELECTION_CHANGE_COMMAND,void 0))}
|
|
14
|
+
function G(a,c,e,g=[]){let f=null!=c?e.isSelected():!0,h=z.$isElementNode(e)&&e.excludeFromCopy("html");var b=r.$cloneWithProperties(e);b=z.$isTextNode(b)&&null!=c?r.$sliceSelectedTextNodeContent(c,b):b;let k=z.$isElementNode(b)?b.getChildren():[];var n=b;let l=n.exportJSON();l.type!==n.constructor.getType()&&A(58);var q=l.children;z.$isElementNode(n)&&(Array.isArray(q)||A(59));z.$isTextNode(b)&&(l.text=b.__text);for(b=0;b<k.length;b++)n=k[b],q=G(a,c,n,l.children),!f&&z.$isElementNode(e)&&q&&e.extractWithChild(n,
|
|
15
|
+
c,"clone")&&(f=!0);if(f&&!h)g.push(l);else if(Array.isArray(l.children))for(a=0;a<l.children.length;a++)g.push(l.children[a]);return f}exports.$getHtmlContent=function(a){let c=z.$getSelection();if(null==c)throw Error("Expected valid LexicalSelection");return z.$isRangeSelection(c)&&c.isCollapsed()||0===c.getNodes().length?null:d.$generateHtmlFromNodes(a,c)};
|
|
16
|
+
exports.$getLexicalContent=function(a){let c=z.$getSelection();if(null==c)throw Error("Expected valid LexicalSelection");if(z.$isRangeSelection(c)&&c.isCollapsed()||0===c.getNodes().length)return null;var e=JSON,g=e.stringify;let f=[],h=z.$getRoot().getChildren();for(let b=0;b<h.length;b++)G(a,c,h[b],f);return g.call(e,{namespace:a._config.namespace,nodes:f})};exports.$insertDataTransferForPlainText=function(a,c){a=a.getData("text/plain");null!=a&&c.insertRawText(a)};
|
|
17
|
+
exports.$insertDataTransferForRichText=function(a,c,e){var g=a.getData("application/x-lexical-editor");if(g)try{var f=JSON.parse(g);if(f.namespace===e._config.namespace&&Array.isArray(f.nodes)){var h=f.nodes;g=[];for(f=0;f<h.length;f++){let k=z.$parseSerializedNode(h[f]);z.$isTextNode(k)&&r.$addNodeStyle(k);g.push(k)}return B(e,g,c)}}catch{}if(h=a.getData("text/html"))try{var b=(new DOMParser).parseFromString(h,"text/html");let k=d.$generateNodesFromDOM(e,b);return B(e,k,c)}catch{}a=a.getData("text/plain");
|
|
18
|
+
if(null!=a)if(z.$isRangeSelection(c))for(a=a.split(/\r?\n/),e=a.length,b=0;b<e;b++)c.insertText(a[b]),b<e-1&&c.insertParagraph();else c.insertRawText(a)}
|
package/package.json
CHANGED
|
@@ -9,15 +9,16 @@
|
|
|
9
9
|
"paste"
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"version": "0.3.
|
|
12
|
+
"version": "0.3.9",
|
|
13
13
|
"main": "LexicalClipboard.js",
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"lexical": "0.3.
|
|
15
|
+
"lexical": "0.3.9"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@lexical/utils": "0.3.
|
|
19
|
-
"@lexical/
|
|
20
|
-
"@lexical/
|
|
18
|
+
"@lexical/utils": "0.3.9",
|
|
19
|
+
"@lexical/list": "0.3.9",
|
|
20
|
+
"@lexical/selection": "0.3.9",
|
|
21
|
+
"@lexical/html": "0.3.9"
|
|
21
22
|
},
|
|
22
23
|
"repository": {
|
|
23
24
|
"type": "git",
|