@lexical/helpers
Advanced tools
Comparing version 0.1.1 to 0.1.2
'use strict';var g=require("lexical"),p=require("lexical/ListNode"),t=require("lexical/ListItemNode"),x=require("lexical/ParagraphNode"),z=require("lexical/HeadingNode"),A=require("lexical/LinkNode");function B(a){return a.isToken()||a.isInert()} | ||
function C(a){a=a.getLatest();const b=a.constructor.clone(a);b.__parent=a.__parent;g.$isElementNode(a)&&g.$isElementNode(b)?(b.__children=Array.from(a.__children),b.__format=a.__format,b.__indent=a.__indent,b.__dir=a.__dir):g.$isTextNode(a)&&g.$isTextNode(b)?(b.__format=a.__format,b.__style=a.__style,b.__mode=a.__mode,b.__detail=a.__detail):g.$isDecoratorNode(a)&&g.$isDecoratorNode(b)&&(b.__ref=a.__ref);return b} | ||
function C(a){a=a.getLatest();const b=a.constructor.clone(a);b.__parent=a.__parent;g.$isElementNode(a)&&g.$isElementNode(b)?(b.__children=Array.from(a.__children),b.__format=a.__format,b.__indent=a.__indent,b.__dir=a.__dir):g.$isTextNode(a)&&g.$isTextNode(b)?(b.__format=a.__format,b.__style=a.__style,b.__mode=a.__mode,b.__detail=a.__detail):g.$isDecoratorNode(a)&&g.$isDecoratorNode(b)&&(b.__state=a.__state);return b} | ||
function D(a,b,c,d,e){for(var f=b;null!==a;){for(b=a.getParent();null!==b&&b.excludeFromCopy();)b=b.getParent();if(null===b)break;if(!g.$isElementNode(a)||!a.excludeFromCopy()){const h=a.getKey();let k=e.get(h);const l=void 0===k;l&&(k=C(a),e.set(h,k));!g.$isTextNode(k)||k.isSegmented()||k.isToken()?g.$isElementNode(k)&&(k.__children=k.__children.slice(c?f:0,c?void 0:f+1)):k.__text=k.__text.slice(c?f:0,c?void 0:f);if(g.$isRootNode(b)){l&&d.push(h);break}}f=e.get(b.getKey());f=g.$isElementNode(f)? | ||
@@ -26,7 +26,7 @@ f.__children.indexOf(a.getKey()):a.getIndexWithinParent();a=b}}function E(a,b){const c=b.split(/\r?\n/);if(1===c.length)a.insertText(b);else{b=[];const d=c.length;for(let e=0;e<d;e++){const f=c[e];""!==f&&b.push(g.$createTextNode(f));e!==d-1&&b.push(g.$createLineBreakNode())}a.insertNodes(b)}}const F="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,G=F&&"documentMode"in document?document.documentMode:null;F&&/Win/.test(navigator.platform); | ||
exports.onKeyDown=function(a,b){K="Unidentified"===a.key&&229===a.keyCode;b.isComposing()||b.update(()=>{g.$log("onKeyDown");if(null!==g.$getSelection()){var {keyCode:c,shiftKey:d,ctrlKey:e,metaKey:f,altKey:h}=a;if(39!==c||e||f||h)if(37!==c||e||f||h)if(38!==c||e||f||h)if(40!==c||e||f||h)if(13===c&&d)b.execCommand("keyEnter",a);else if(H&&e&&79===c)a.preventDefault(),b.execCommand("insertLineBreak",!0);else if(13!==c||d){var k=H?h||f?!1:8===c||72===c&&e:e||h||f?!1:8===c;k?8===c?b.execCommand("keyBackspace", | ||
a):b.execCommand("deleteCharacter",!0):(k=H?d||h||f?!1:46===c||68===c&&e:e||h||f?!1:46===c,k?46===c?b.execCommand("keyDelete",a):b.execCommand("deleteCharacter",!1):8===c&&(H?h:e)?(a.preventDefault(),b.execCommand("deleteWord",!0)):46===c&&(H?h:e)?(a.preventDefault(),b.execCommand("deleteWord",!1)):H&&f&&8===c?(a.preventDefault(),b.execCommand("deleteLine",!0)):H&&f&&46===c?(a.preventDefault(),b.execCommand("deleteLine",!1)):66===c&&(H?f:e)?(a.preventDefault(),b.execCommand("formatText","bold")): | ||
85===c&&(H?f:e)?(a.preventDefault(),b.execCommand("formatText","underline")):73===c&&(H?f:e)?(a.preventDefault(),b.execCommand("formatText","italic")):9!==c||h||e||f?90===c&&!d&&(H?f:e)?(a.preventDefault(),b.execCommand("undo")):(k=H?90===c&&f&&d:89===c&&e||90===c&&e&&d,k&&(a.preventDefault(),b.execCommand("redo"))):b.execCommand("keyTab",a))}else b.execCommand("keyEnter",a);else b.execCommand("keyArrowDown",a);else b.execCommand("keyArrowUp",a);else b.execCommand("keyArrowLeft",a);else b.execCommand("keyArrowRight", | ||
a)}})};exports.onPasteForPlainText=function(a,b){a.preventDefault();b.update(()=>{g.$log("onPasteForPlainText");const c=g.$getSelection(),d=a.clipboardData;null!=d&&null!==c&&N(d,c)})}; | ||
a):b.execCommand("deleteCharacter",!0):27===c?b.execCommand("keyEscape",a):(k=H?d||h||f?!1:46===c||68===c&&e:e||h||f?!1:46===c,k?46===c?b.execCommand("keyDelete",a):b.execCommand("deleteCharacter",!1):8===c&&(H?h:e)?(a.preventDefault(),b.execCommand("deleteWord",!0)):46===c&&(H?h:e)?(a.preventDefault(),b.execCommand("deleteWord",!1)):H&&f&&8===c?(a.preventDefault(),b.execCommand("deleteLine",!0)):H&&f&&46===c?(a.preventDefault(),b.execCommand("deleteLine",!1)):66===c&&(H?f:e)?(a.preventDefault(), | ||
b.execCommand("formatText","bold")):85===c&&(H?f:e)?(a.preventDefault(),b.execCommand("formatText","underline")):73===c&&(H?f:e)?(a.preventDefault(),b.execCommand("formatText","italic")):9!==c||h||e||f?90===c&&!d&&(H?f:e)?(a.preventDefault(),b.execCommand("undo")):(k=H?90===c&&f&&d:89===c&&e||90===c&&e&&d,k&&(a.preventDefault(),b.execCommand("redo"))):b.execCommand("keyTab",a))}else b.execCommand("keyEnter",a);else b.execCommand("keyArrowDown",a);else b.execCommand("keyArrowUp",a);else b.execCommand("keyArrowLeft", | ||
a);else b.execCommand("keyArrowRight",a)}})};exports.onPasteForPlainText=function(a,b){a.preventDefault();b.update(()=>{g.$log("onPasteForPlainText");const c=g.$getSelection(),d=a.clipboardData;null!=d&&null!==c&&N(d,c)})}; | ||
exports.onPasteForRichText=function(a,b){a.preventDefault();b.update(()=>{g.$log("onPasteForRichText");const c=g.$getSelection();var d=a.clipboardData;if(null!=d&&null!==c)a:{var e=d.getData("application/x-lexical-nodes");if(e)try{var f=JSON.parse(e);const {range:m,nodeMap:n}=f;var h=new Map(n);e=[];for(f=0;f<m.length;f++){var k=h.get(m[f]);if(void 0!==k){var l=g.$createNodeFromParse(k,h);e.push(l)}}c.insertNodes(e);break a}catch(m){}if(h=d.getData("text/html")){h=(new DOMParser).parseFromString(h, | ||
"text/html");d=[];h=h.body?Array.from(h.body.childNodes):[];k=h.length;for(l=0;l<k;l++)e=M(h[l],L,b),null!==e&&(d=d.concat(e));h=[];k=null;for(l=0;l<d.length;l++)e=d[l],!g.$isElementNode(e)||e.isInline()?(null===k&&(k=x.$createParagraphNode(),h.push(k)),null!==k&&k.append(e)):(h.push(e),k=null);c.insertNodes(h)}else N(d,c)}})}; | ||
exports.onSelectionChange=function(a,b){a=window.getSelection();const c=b.getRootElement();c&&!c.contains(a.anchorNode)||b.update(()=>{g.$log("onSelectionChange");const d=g.$getSelection();if(null!==d&&d.isCollapsed()){var e=d.anchor;"text"===e.type?(e=e.getNode(),d.format=e.getFormat()):"element"===e.type&&(d.format=0)}b.execCommand("selectionChange")})}; |
@@ -16,5 +16,5 @@ { | ||
"license": "MIT", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"dependencies": { | ||
"lexical": "0.1.1" | ||
"lexical": "0.1.2" | ||
}, | ||
@@ -21,0 +21,0 @@ "peerDependencies": { |
@@ -1,2 +0,2 @@ | ||
'use strict';var l=require("lexical");const r=new Map;function v(a){a=a.getLatest();const c=a.constructor.clone(a);c.__parent=a.__parent;l.$isElementNode(a)&&l.$isElementNode(c)?(c.__children=Array.from(a.__children),c.__format=a.__format,c.__indent=a.__indent,c.__dir=a.__dir):l.$isTextNode(a)&&l.$isTextNode(c)?(c.__format=a.__format,c.__style=a.__style,c.__mode=a.__mode,c.__detail=a.__detail):l.$isDecoratorNode(a)&&l.$isDecoratorNode(c)&&(c.__ref=a.__ref);return c} | ||
'use strict';var l=require("lexical");const r=new Map;function v(a){a=a.getLatest();const c=a.constructor.clone(a);c.__parent=a.__parent;l.$isElementNode(a)&&l.$isElementNode(c)?(c.__children=Array.from(a.__children),c.__format=a.__format,c.__indent=a.__indent,c.__dir=a.__dir):l.$isTextNode(a)&&l.$isTextNode(c)?(c.__format=a.__format,c.__style=a.__style,c.__mode=a.__mode,c.__detail=a.__detail):l.$isDecoratorNode(a)&&l.$isDecoratorNode(c)&&(c.__state=a.__state);return c} | ||
function w(a,c,b,f,h){for(var e=c;null!==a;){for(c=a.getParent();null!==c&&c.excludeFromCopy();)c=c.getParent();if(null===c)break;if(!l.$isElementNode(a)||!a.excludeFromCopy()){const d=a.getKey();let g=h.get(d);const k=void 0===g;k&&(g=v(a),h.set(d,g));!l.$isTextNode(g)||g.isSegmented()||g.isToken()?l.$isElementNode(g)&&(g.__children=g.__children.slice(b?e:0,b?void 0:e+1)):g.__text=g.__text.slice(b?e:0,b?void 0:e);if(l.$isRootNode(c)){k&&f.push(d);break}}e=h.get(c.getKey());e=l.$isElementNode(e)? | ||
@@ -3,0 +3,0 @@ e.__children.indexOf(a.getKey()):a.getIndexWithinParent();a=c}}function x(a){return r.get(a)||null}function y(a,c){var b=x(a.getStyle());c=b?{...b,...c}:c;b="";for(f in c)f&&(b+=`${f}: ${c[f]};`);var f=b;a.setStyle(f);r.set(f,c)}function z(a,c,b,f){a.modify(c?"extend":"move",b,f)}function A(a){for(;null!==a&&!l.$isRootNode(a);){const c=a.getLatest(),b=a.getParent();0===c.__children.length&&a.remove();a=b}} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29042
+ Addedlexical@0.1.2(transitive)
- Removedlexical@0.1.1(transitive)
Updatedlexical@0.1.2