@lexical/selection
Advanced tools
Comparing version 0.3.5 to 0.3.6
@@ -233,7 +233,9 @@ /** | ||
const styleObject = {}; | ||
const styles = css.split(';').slice(0, -1); | ||
const styles = css.split(';'); | ||
for (const style of styles) { | ||
const patch = style.split(': '); | ||
styleObject[patch[0]] = patch[1]; | ||
if (style !== '') { | ||
const patch = style.split(':'); | ||
styleObject[patch[0].trim()] = patch[1].trim(); | ||
} | ||
} | ||
@@ -799,3 +801,3 @@ | ||
if (parent.getChildrenSize() === 0) { | ||
if (parent != null && parent.getChildrenSize() === 0) { | ||
parent.remove(); | ||
@@ -802,0 +804,0 @@ } |
@@ -13,3 +13,3 @@ /** | ||
}function y(a){return t.get(a)||null}function z(a,c){var b=y(a.getStyle());c=b?{...b,...c}:c;b="";for(d in c)d&&(b+=`${d}: ${c[d]};`);var d=b;a.setStyle(d);t.set(d,c)}function A(a,c,b,d){a.modify(c?"extend":"move",b,d)}function B(a){a=a.anchor.getNode();return"rtl"===(l.$isRootNode(a)?a:a.getParentOrThrow()).getDirection()}function C(a){for(;null!==a&&!l.$isRootNode(a);){let c=a.getLatest(),b=a.getParent();0===c.__children.length&&a.remove(!0);a=b}} | ||
function D(a){for(;null!=a;){if(a.nodeType===Node.TEXT_NODE)return a;a=a.firstChild}return null}function E(a){let c=a.parentNode;if(null==c)throw Error("Should never happen");return[c,Array.from(c.childNodes).indexOf(a)]}exports.$addNodeStyle=function(a){a=a.getStyle();let c={};var b=a.split(";").slice(0,-1);for(let d of b)b=d.split(": "),c[b[0]]=b[1];t.set(a,c)};exports.$cloneContents=function(a){return x(a)};exports.$cloneWithProperties=u; | ||
function D(a){for(;null!=a;){if(a.nodeType===Node.TEXT_NODE)return a;a=a.firstChild}return null}function E(a){let c=a.parentNode;if(null==c)throw Error("Should never happen");return[c,Array.from(c.childNodes).indexOf(a)]}exports.$addNodeStyle=function(a){a=a.getStyle();let c={};var b=a.split(";");for(let d of b)""!==d&&(b=d.split(":"),c[b[0].trim()]=b[1].trim());t.set(a,c)};exports.$cloneContents=function(a){return x(a)};exports.$cloneWithProperties=u; | ||
exports.$getSelectionStyleValueForProperty=function(a,c,b=""){let d=null,f=a.getNodes();var g=a.anchor,e=a.focus,h=a.isBackward();a=h?e.offset:g.offset;g=h?e.getNode():g.getNode();for(e=0;e<f.length;e++){var k=f[e];if((0===e||0!==a||!k.is(g))&&l.$isTextNode(k)){h=c;var m=b;k=k.getStyle();k=y(k);h=null!==k?k[h]||m:m;if(null===d)d=h;else if(d!==h){d="";break}}}return null===d?b:d};exports.$isAtNodeEnd=function(a){return"text"===a.type?a.offset===a.getNode().getTextContentSize():a.offset===a.getNode().getChildrenSize()}; | ||
@@ -28,3 +28,3 @@ exports.$isParentElementRTL=B;exports.$moveCaretSelection=A;exports.$moveCharacter=function(a,c,b){let d=B(a);A(a,c,b?!d:d,"character")}; | ||
exports.trimTextContentFromAnchor=function(a,c,b){let d=c.getNode();if(l.$isElementNode(d)){var f=d.getDescendantByIndex(c.offset);null!==f&&(d=f)}for(;0<b&&null!==d;){var g=d.getPreviousSibling(),e=0;if(null===g){f=d.getParentOrThrow();for(var h=f.getPreviousSibling();null===h;){f=f.getParent();if(null===f){g=null;break}h=f.getPreviousSibling()}null!==f&&(e=f.isInline()?0:2,g=l.$isElementNode(h)?h.getLastDescendant():h)}let k=d.getTextContent();""===k&&l.$isElementNode(d)&&!d.isInline()&&(k="\n\n"); | ||
f=k.length;h=f-b;let m=k.slice(0,h);if(!l.$isTextNode(d)||b>=f)h=d.getParent(),d.remove(),0===h.getChildrenSize()&&h.remove(),b-=f+e,d=g;else{let n=d.getKey();g=a.getEditorState().read(()=>{const p=l.$getNodeByKey(n);return l.$isTextNode(p)&&p.isSimpleText()?p.getTextContent():null});null!==g&&g!==k?(b=l.$getPreviousSelection(),f=d,d.isSimpleText()?d.setTextContent(g):(f=l.$createTextNode(g),d.replace(f)),l.$isRangeSelection(b)&&b.isCollapsed()&&(b=b.anchor.offset,f.select(b,b))):d.isSimpleText()? | ||
f=k.length;h=f-b;let m=k.slice(0,h);if(!l.$isTextNode(d)||b>=f)h=d.getParent(),d.remove(),null!=h&&0===h.getChildrenSize()&&h.remove(),b-=f+e,d=g;else{let n=d.getKey();g=a.getEditorState().read(()=>{const p=l.$getNodeByKey(n);return l.$isTextNode(p)&&p.isSimpleText()?p.getTextContent():null});null!==g&&g!==k?(b=l.$getPreviousSelection(),f=d,d.isSimpleText()?d.setTextContent(g):(f=l.$createTextNode(g),d.replace(f)),l.$isRangeSelection(b)&&b.isCollapsed()&&(b=b.anchor.offset,f.select(b,b))):d.isSimpleText()? | ||
(g=c.key===n,e=c.offset,e<b&&(e=f),b=g?e-b:0,f=g?e:h,g&&0===b?([b]=d.splitText(b,f),b.remove()):([,b]=d.splitText(b,f),b.remove())):(b=l.$createTextNode(m),d.replace(b));b=0}}} |
@@ -12,6 +12,6 @@ { | ||
"license": "MIT", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"main": "LexicalSelection.js", | ||
"peerDependencies": { | ||
"lexical": "0.3.5" | ||
"lexical": "0.3.6" | ||
}, | ||
@@ -18,0 +18,0 @@ "repository": { |
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
47351
826