@lexical/selection 0.5.1-next.0 → 0.5.1-next.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/LexicalSelection.dev.js
CHANGED
|
@@ -990,7 +990,7 @@ function $patchStyleText(selection, patch) {
|
|
|
990
990
|
} // multiple nodes selected.
|
|
991
991
|
|
|
992
992
|
} else {
|
|
993
|
-
if (lexical.$isTextNode(firstNode)) {
|
|
993
|
+
if (lexical.$isTextNode(firstNode) && startOffset < firstNode.getTextContentSize()) {
|
|
994
994
|
if (startOffset !== 0) {
|
|
995
995
|
// the entire first node isn't selected, so split it
|
|
996
996
|
firstNode = firstNode.splitText(startOffset)[1];
|
package/LexicalSelection.prod.js
CHANGED
|
@@ -17,8 +17,8 @@ exports.$cloneContents=function(a){var b={nodeMap:[],range:[]};if(l.$isRangeSele
|
|
|
17
17
|
c?p:m:void 0,!0,h,g);for(d=0;d<a;d++){k=b[d];let n=k.getKey();if(!(g.has(n)||l.$isElementNode(k)&&k.excludeFromCopy("clone"))){let x=v(k);l.$isRootNode(k.getParent())&&h.push(k.getKey());"root"!==n&&g.set(n,x)}}G(e,f?void 0:c?p:m,void 0,!1,h,g);b={nodeMap:Array.from(g.entries()),range:h}}}}else if(l.DEPRECATED_$isGridSelection(a))b=u(a);else if(l.$isNodeSelection(a))throw Error("Minified Lexical error #1; visit https://lexical.dev/docs/error?code=1 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");
|
|
18
18
|
return b};exports.$cloneWithProperties=v;exports.$getSelectionStyleValueForProperty=function(a,b,c=""){let g=null,d=a.getNodes();var e=a.anchor,h=a.focus,f=a.isBackward();a=f?h.offset:e.offset;e=f?h.getNode():e.getNode();for(h=0;h<d.length;h++){var k=d[h];if((0===h||0!==a||!k.is(e))&&l.$isTextNode(k)){f=b;var m=c;k=k.getStyle();k=A(k);f=null!==k?k[f]||m:m;if(null===g)g=f;else if(g!==f){g="";break}}}return null===g?c:g};
|
|
19
19
|
exports.$isAtNodeEnd=function(a){return"text"===a.type?a.offset===a.getNode().getTextContentSize():a.offset===a.getNode().getChildrenSize()};exports.$isParentElementRTL=F;exports.$moveCaretSelection=E;exports.$moveCharacter=function(a,b,c){let g=F(a);E(a,b,c?!g:g,"character")};
|
|
20
|
-
exports.$patchStyleText=function(a,b){var c=a.getNodes();let g=c.length-1,d=c[0],e=c[g];if(!a.isCollapsed()){var h=a.anchor,f=a.focus;a=d.getTextContent().length;var k=f.offset,m=h.offset;h=(f=h.isBefore(f))?m:k;f=f?k:m;if(h===d.getTextContentSize()){let p=d.getNextSibling();l.$isTextNode(p)&&(h=m=0,d=p)}if(d.is(e))l.$isTextNode(d)&&(h=m>k?k:m,f=m>k?m:k,h!==f&&(0===h&&f===a?(H(d,b),d.select(h,f)):(c=d.splitText(h,f),c=0===h?c[0]:c[1],H(c,b),c.select(0,f-h))));else for(l.$isTextNode(d)&&(
|
|
21
|
-
d.splitText(h)[1]),H(d,b)),l.$isTextNode(e)&&(a=e.getTextContent().length,f!==a&&([e]=e.splitText(f)),0!==f&&H(e,b)),a=1;a<g;a++)k=c[a],m=k.getKey(),l.$isTextNode(k)&&m!==d.getKey()&&m!==e.getKey()&&!k.isToken()&&H(k,b)}};
|
|
20
|
+
exports.$patchStyleText=function(a,b){var c=a.getNodes();let g=c.length-1,d=c[0],e=c[g];if(!a.isCollapsed()){var h=a.anchor,f=a.focus;a=d.getTextContent().length;var k=f.offset,m=h.offset;h=(f=h.isBefore(f))?m:k;f=f?k:m;if(h===d.getTextContentSize()){let p=d.getNextSibling();l.$isTextNode(p)&&(h=m=0,d=p)}if(d.is(e))l.$isTextNode(d)&&(h=m>k?k:m,f=m>k?m:k,h!==f&&(0===h&&f===a?(H(d,b),d.select(h,f)):(c=d.splitText(h,f),c=0===h?c[0]:c[1],H(c,b),c.select(0,f-h))));else for(l.$isTextNode(d)&&h<d.getTextContentSize()&&
|
|
21
|
+
(0!==h&&(d=d.splitText(h)[1]),H(d,b)),l.$isTextNode(e)&&(a=e.getTextContent().length,f!==a&&([e]=e.splitText(f)),0!==f&&H(e,b)),a=1;a<g;a++)k=c[a],m=k.getKey(),l.$isTextNode(k)&&m!==d.getKey()&&m!==e.getKey()&&!k.isToken()&&H(k,b)}};
|
|
22
22
|
exports.$selectAll=function(a){let b=a.anchor;a=a.focus;var c=b.getNode().getTopLevelElementOrThrow().getParentOrThrow();let g=c.getFirstDescendant();c=c.getLastDescendant();let d="element",e="element",h=0;l.$isTextNode(g)?d="text":l.$isElementNode(g)||null===g||(g=g.getParentOrThrow());l.$isTextNode(c)?(e="text",h=c.getTextContentSize()):l.$isElementNode(c)||null===c||(c=c.getParentOrThrow());g&&c&&(b.set(g.getKey(),0,d),a.set(c.getKey(),h,e))};
|
|
23
23
|
exports.$shouldOverrideDefaultCharacterSelection=function(a,b){a=l.$getDecoratorNode(a.focus,b);return l.$isDecoratorNode(a)&&!a.isIsolated()};
|
|
24
24
|
exports.$sliceSelectedTextNodeContent=function(a,b){if(b.isSelected()&&!b.isSegmented()&&!b.isToken()&&(l.$isRangeSelection(a)||l.DEPRECATED_$isGridSelection(a))){var c=a.anchor.getNode(),g=a.focus.getNode(),d=b.is(c),e=b.is(g);if(d||e){d=a.isBackward();let [h,f]=a.getCharacterOffsets();a=c.is(g);e=b.is(d?g:c);g=b.is(d?c:g);c=0;let k=void 0;a?(c=h>f?f:h,k=h>f?h:f):e?(c=d?f:h,k=void 0):g&&(d=d?h:f,c=0,k=d);b.__text=b.__text.slice(c,k)}}return b};
|
package/package.json
CHANGED
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"selection"
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"version": "0.5.1-next.
|
|
12
|
+
"version": "0.5.1-next.1",
|
|
13
13
|
"main": "LexicalSelection.js",
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"lexical": "0.5.1-next.
|
|
15
|
+
"lexical": "0.5.1-next.1"
|
|
16
16
|
},
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|