@lexical/clipboard 0.1.12 → 0.1.13
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 +12 -1
- package/LexicalClipboard.prod.js +5 -5
- package/package.json +5 -3
package/LexicalClipboard.dev.js
CHANGED
|
@@ -199,6 +199,17 @@ function $cloneContents(selection) {
|
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
204
|
+
*
|
|
205
|
+
* This source code is licensed under the MIT license found in the
|
|
206
|
+
* LICENSE file in the root directory of this source tree.
|
|
207
|
+
*
|
|
208
|
+
*
|
|
209
|
+
*/
|
|
210
|
+
const getSelection = window.getSelection;
|
|
211
|
+
var getDOMSelection = getSelection;
|
|
212
|
+
|
|
202
213
|
/**
|
|
203
214
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
204
215
|
*
|
|
@@ -208,7 +219,7 @@ function $cloneContents(selection) {
|
|
|
208
219
|
*
|
|
209
220
|
*/
|
|
210
221
|
function getHtmlContent(editor) {
|
|
211
|
-
const domSelection =
|
|
222
|
+
const domSelection = getDOMSelection(); // If we haven't selected a range, then don't copy anything
|
|
212
223
|
|
|
213
224
|
if (domSelection.isCollapsed) {
|
|
214
225
|
return null;
|
package/LexicalClipboard.prod.js
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
var h=require("lexical");function r(a){a=a.getLatest();const b=a.constructor.clone(a);b.__parent=a.__parent;h.$isElementNode(a)&&h.$isElementNode(b)?(b.__children=Array.from(a.__children),b.__format=a.__format,b.__indent=a.__indent,b.__dir=a.__dir):h.$isTextNode(a)&&h.$isTextNode(b)?(b.__format=a.__format,b.__style=a.__style,b.__mode=a.__mode,b.__detail=a.__detail):h.$isDecoratorNode(a)&&h.$isDecoratorNode(b)&&(b.__state=a.__state);return b}
|
|
8
8
|
function t(a,b,l,g,f){for(var c=b;null!==a;){for(b=a.getParent();null!==b&&b.excludeFromCopy();)b=b.getParent();if(null===b)break;if(!h.$isElementNode(a)||!a.excludeFromCopy()){const e=a.getKey();let d=f.get(e);const k=void 0===d;k&&(d=r(a),f.set(e,d));!h.$isTextNode(d)||d.isSegmented()||d.isToken()?h.$isElementNode(d)&&(d.__children=d.__children.slice(l?c:0,l?void 0:c+1)):d.__text=d.__text.slice(l?c:0,l?void 0:c);if(h.$isRootNode(b)){k&&g.push(e);break}}c=f.get(b.getKey());c=h.$isElementNode(c)?
|
|
9
|
-
c.__children.indexOf(a.getKey()):a.getIndexWithinParent();a=b}}function
|
|
10
|
-
function
|
|
11
|
-
exports.$getLexicalContent=function(a){var b=h.$getSelection();if(null!==b){const
|
|
9
|
+
c.__children.indexOf(a.getKey()):a.getIndexWithinParent();a=b}}var u=window.getSelection;function v(a,b){a=a.getData("text/plain");null!=a&&b.insertRawText(a)}function w(a,b){const {nodeName:l}=a;b=b._htmlConversions.get(l.toLowerCase());let g=null;void 0!==b&&b.forEach(f=>{f=f(a);null!==f&&(null===g||g.priority<f.priority)&&(g=f)});return null!==g?g.conversion:null}
|
|
10
|
+
function x(a,b,l=new Map){let g=[],f=null;var c=w(a,b),e=c?c(a):null;c=null;if(null!==e){c=e.after;f=e.node;if(null!==f){g.push(f);var d=Array.from(l.values());for(let k=0;k<d.length;k++)d[k](f)}null!=e.forChild&&l.set(a.nodeName,e.forChild)}a=a.childNodes;e=[];for(d=0;d<a.length;d++)e.push(...x(a[d],b,l));null!=c&&(e=c(e));null==f?g=g.concat(e):h.$isElementNode(f)&&f.append(...e);return g}
|
|
11
|
+
exports.$getLexicalContent=function(a){var b=h.$getSelection();if(null!==b){const y=a._config.namespace;a=JSON;var l=a.stringify;{if(!h.$isRangeSelection(b))throw Error("Minified Lexical error #68; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");var g=b.anchor,f=b.focus;var c=g.getCharacterOffset();const q=f.getCharacterOffset();var e=g.getNode(),d=f.getNode(),k=e.getParentOrThrow();if(e===d&&h.$isTextNode(e)&&(k.canBeEmpty()||
|
|
12
12
|
1<k.getChildrenSize()))b=r(e),e=q>c,b.__text=b.__text.slice(e?c:q,e?q:c),c=b.getKey(),c={nodeMap:[[c,b]],range:[c]};else if(b=b.getNodes(),0===b.length)c={nodeMap:[],range:[]};else{e=b.length;d=b[0];k=d.getParent();if(null!==k&&(!k.canBeEmpty()||h.$isRootNode(k))){var m=k.__children;if(m.length===e){var n=!0;for(var p=0;p<m.length;p++)if(m[p]!==b[p].__key){n=!1;break}n&&(e++,b.push(k))}}k=b[e-1];g=g.isBefore(f);f=new Map;m=[];t(d,g?c:q,!0,m,f);for(d=0;d<e;d++)if(n=b[d],p=n.getKey(),!(f.has(p)||h.$isElementNode(n)&&
|
|
13
|
-
n.excludeFromCopy())){const
|
|
13
|
+
n.excludeFromCopy())){const z=r(n);h.$isRootNode(n.getParent())&&m.push(n.getKey());f.set(p,z)}t(k,g?q:c,!1,m,f);c={nodeMap:Array.from(f.entries()),range:m}}}return l.call(a,{namespace:y,state:c})}return null};exports.$insertDataTransferForPlainText=v;
|
|
14
14
|
exports.$insertDataTransferForRichText=function(a,b,l){var g=a.getData("application/x-lexical-editor");if(g){var f=l._config.namespace;try{const k=JSON.parse(g);if(k.namespace===f){const {range:m,nodeMap:n}=k.state;var c=new Map(n);g=[];for(f=0;f<m.length;f++){var e=c.get(m[f]);if(void 0!==e){var d=h.$createNodeFromParse(e,c);g.push(d)}}b.insertNodes(g);return}}catch(k){}}if(c=a.getData("text/html")){c=(new DOMParser).parseFromString(c,"text/html");a=[];c=c.body?Array.from(c.body.childNodes):[];e=
|
|
15
|
-
c.length;for(d=0;d<e;d++)g=
|
|
15
|
+
c.length;for(d=0;d<e;d++)g=x(c[d],l),null!==g&&(a=a.concat(g));l=a;a=[];c=null;for(e=0;e<l.length;e++)d=l[e],!h.$isElementNode(d)||d.isInline()?(null===c&&(c=h.$createParagraphNode(),a.push(c)),null!==c&&c.append(d)):(a.push(d),c=null);b.insertNodes(a)}else v(a,b)};exports.getHtmlContent=function(){var a=u();if(a.isCollapsed)return null;var b=a.getRangeAt(0);return b?(a=document.createElement("div"),b=b.cloneContents(),a.appendChild(b),a.innerHTML):null};
|
package/package.json
CHANGED
|
@@ -13,11 +13,13 @@
|
|
|
13
13
|
"paste"
|
|
14
14
|
],
|
|
15
15
|
"license": "MIT",
|
|
16
|
-
"version": "0.1.
|
|
16
|
+
"version": "0.1.13",
|
|
17
17
|
"main": "LexicalClipboard.js",
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"lexical": "0.1.
|
|
20
|
-
|
|
19
|
+
"lexical": "0.1.13"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@lexical/helpers": "0.1.13"
|
|
21
23
|
},
|
|
22
24
|
"repository": {
|
|
23
25
|
"type": "git",
|