lexical 0.3.9 → 0.3.10

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/Lexical.dev.js CHANGED
@@ -4524,7 +4524,18 @@ class RangeSelection {
4524
4524
 
4525
4525
  deleteLine(isBackward) {
4526
4526
  if (this.isCollapsed()) {
4527
- this.modify('extend', isBackward, 'lineboundary');
4527
+ if (this.anchor.type === 'text') {
4528
+ this.modify('extend', isBackward, 'lineboundary');
4529
+ } // If selection is extended to cover text edge then extend it one character more
4530
+ // to delete its parent element. Otherwise text content will be deleted but empty
4531
+ // parent node will remain
4532
+
4533
+
4534
+ const endPoint = isBackward ? this.focus : this.anchor;
4535
+
4536
+ if (endPoint.offset === 0) {
4537
+ this.modify('extend', isBackward, 'character');
4538
+ }
4528
4539
  }
4529
4540
 
4530
4541
  this.removeText();
@@ -8970,7 +8981,7 @@ class LexicalEditor {
8970
8981
  * LICENSE file in the root directory of this source tree.
8971
8982
  *
8972
8983
  */
8973
- const VERSION = '0.3.9';
8984
+ const VERSION = '0.3.10';
8974
8985
 
8975
8986
  /**
8976
8987
  * Copyright (c) Meta Platforms, Inc. and affiliates.
package/Lexical.prod.js CHANGED
@@ -87,8 +87,8 @@ e=0;e<c.length;e++)f.append(c[e])}else if(g=e.insertNewAfter(this),null===g)this
87
87
  e.splitText(d),a[0]=e));B(g)&&(e=g.getTextContent().length,b=b?k:h,0===b?a.pop():b!==e&&([g]=g.splitText(b),a[c]=g));return a}modify(a,b,c){var d=this.focus,f=this.anchor,e="move"===a,g=Sb(d,b);if(A(g)&&!g.isIsolated())a=b?g.getPreviousSibling():g.getNextSibling(),B(a)?(g=a.__key,b=b?a.getTextContent().length:0,d.set(g,b,"text"),e&&f.set(g,b,"text")):(c=g.getParentOrThrow(),E(a)?(c=a.__key,g=b?a.getChildrenSize():0):(g=g.getIndexWithinParent(),c=c.__key,b||g++),d.set(c,g,"element"),e&&f.set(c,g,"element"));
88
88
  else if(d=window.getSelection())d.modify(a,b?"backward":"forward",c),0<d.rangeCount&&(b=d.getRangeAt(0),this.applyDOMRange(b),this.dirty=!0,e||d.anchorNode===b.startContainer&&d.anchorOffset===b.startOffset||(e=this.focus,b=this.anchor,d=b.key,f=b.offset,g=b.type,fd(b,e.key,e.offset,e.type),fd(e,d,f,g),this._cachedNodes=null))}deleteCharacter(a){if(this.isCollapsed()){var b=this.anchor,c=this.focus,d=b.getNode();if(!a&&("element"===b.type&&E(d)&&b.offset===d.getChildrenSize()||"text"===b.type&&b.offset===
89
89
  d.getTextContentSize())&&(d=d.getNextSibling()||d.getParentOrThrow().getNextSibling(),E(d)&&!d.canExtractContents()))return;this.modify("extend",a,"character");if(!this.isCollapsed()){var f="text"===c.type?c.getNode():null;d="text"===b.type?b.getNode():null;if(null!==f&&f.isSegmented()){if(b=c.offset,c=f.getTextContentSize(),f.is(d)||a&&b!==c||!a&&0!==b){sd(f,a,b);return}}else if(null!==d&&d.isSegmented()&&(b=b.offset,c=d.getTextContentSize(),d.is(f)||a&&0!==b||!a&&b!==c)){sd(d,a,b);return}d=this.anchor;
90
- f=this.focus;b=d.getNode();c=f.getNode();if(b===c&&"text"===d.type&&"text"===f.type){var e=d.offset,g=f.offset;let h=e<g;c=h?e:g;g=h?g:e;e=g-1;c!==e&&(b=b.getTextContent().slice(c,g),/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(b)||(a?f.offset=e:d.offset=e))}}else if(a&&0===b.offset&&("element"===b.type?b.getNode():b.getNode().getParentOrThrow()).collapseAtStart(this))return}this.removeText()}deleteLine(a){this.isCollapsed()&&this.modify("extend",a,"lineboundary");this.removeText()}deleteWord(a){this.isCollapsed()&&
91
- this.modify("extend",a,"word");this.removeText()}}function Tc(a){return a instanceof gd}function td(a){let b=a.offset;if("text"===a.type)return b;a=a.getNode();return b===a.getChildrenSize()?a.getTextContent().length:0}function kd(a){let b=a.anchor;a=a.focus;return"element"===b.type&&"element"===a.type&&b.key===a.key&&b.offset===a.offset?[0,0]:[td(b),td(a)]}
90
+ f=this.focus;b=d.getNode();c=f.getNode();if(b===c&&"text"===d.type&&"text"===f.type){var e=d.offset,g=f.offset;let h=e<g;c=h?e:g;g=h?g:e;e=g-1;c!==e&&(b=b.getTextContent().slice(c,g),/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(b)||(a?f.offset=e:d.offset=e))}}else if(a&&0===b.offset&&("element"===b.type?b.getNode():b.getNode().getParentOrThrow()).collapseAtStart(this))return}this.removeText()}deleteLine(a){this.isCollapsed()&&("text"===this.anchor.type&&this.modify("extend",a,"lineboundary"),0===(a?this.focus:
91
+ this.anchor).offset&&this.modify("extend",a,"character"));this.removeText()}deleteWord(a){this.isCollapsed()&&this.modify("extend",a,"word");this.removeText()}}function Tc(a){return a instanceof gd}function td(a){let b=a.offset;if("text"===a.type)return b;a=a.getNode();return b===a.getChildrenSize()?a.getTextContent().length:0}function kd(a){let b=a.anchor;a=a.focus;return"element"===b.type&&"element"===a.type&&b.key===a.key&&b.offset===a.offset?[0,0]:[td(b),td(a)]}
92
92
  function sd(a,b,c){let d=a.getTextContent().split(/(?=\s)/g),f=d.length,e=0,g=0;for(let h=0;h<f;h++){let k=d[h],m=h===f-1;g=e;e+=k.length;if(b&&e===c||e>c||m){d.splice(h,1);m&&(g=void 0);break}}b=d.join("").trim();""===b?a.remove():(a.setTextContent(b),a.select(g,g))}
93
93
  function ud(a,b,c){var d=b;if(1===a.nodeType){let g=!1;var f=a.childNodes;var e=f.length;d===e&&(g=!0,d=e-1);f=Jb(f[d]);if(B(f))d=g?f.getTextContentSize():0;else{e=Jb(a);if(null===e)return null;if(E(e)){a=e.getChildAtIndex(d);if(b=E(a))b=a.getParent(),b=null===c||null===b||!b.canBeEmpty()||b!==c.getNode();b&&(c=g?a.getLastDescendant():a.getFirstDescendant(),null===c?(e=a,d=0):(a=c,e=a.getParentOrThrow()));B(a)?(f=a,e=null,d=g?a.getTextContentSize():0):a!==e&&g&&d++}else d=e.getIndexWithinParent(),
94
94
  d=0===b&&A(e)&&Jb(a)===e?d:d+1,e=e.getParentOrThrow();if(E(e))return new V(e.__key,d,"element")}}else f=Jb(a);return B(f)?new V(f.__key,d,"text"):null}
@@ -177,7 +177,7 @@ exports.$getPreviousSelection=Nb;exports.$getRoot=Hb;exports.$getSelection=v;exp
177
177
  exports.$nodesOfType=function(a){var b=H();let c=b._readOnly,d=a.getType();b=b._nodeMap;let f=[];for(let [,e]of b)e instanceof a&&e.__type===d&&(c||e.isAttached())&&f.push(e);return f};exports.$parseSerializedNode=function(a){return Nd(a,I()._nodes)};exports.$setCompositionKey=J;exports.$setSelection=ob;exports.BLUR_COMMAND=La;exports.CAN_REDO_COMMAND={};exports.CAN_UNDO_COMMAND={};exports.CLEAR_EDITOR_COMMAND={};exports.CLEAR_HISTORY_COMMAND={};exports.CLICK_COMMAND=ba;
178
178
  exports.COMMAND_PRIORITY_CRITICAL=4;exports.COMMAND_PRIORITY_EDITOR=0;exports.COMMAND_PRIORITY_HIGH=3;exports.COMMAND_PRIORITY_LOW=1;exports.COMMAND_PRIORITY_NORMAL=2;exports.CONTROLLED_TEXT_INSERTION_COMMAND=ha;exports.COPY_COMMAND=Ia;exports.CUT_COMMAND=Ja;exports.DELETE_CHARACTER_COMMAND=ca;exports.DELETE_LINE_COMMAND=ma;exports.DELETE_WORD_COMMAND=la;exports.DRAGEND_COMMAND=Ha;exports.DRAGOVER_COMMAND=Ga;exports.DRAGSTART_COMMAND=Fa;exports.DROP_COMMAND=Ea;exports.DecoratorNode=Zd;
179
179
  exports.ElementNode=$d;exports.FOCUS_COMMAND=Ka;exports.FORMAT_ELEMENT_COMMAND={};exports.FORMAT_TEXT_COMMAND=q;exports.GridCellNode=we;exports.GridNode=xe;exports.GridRowNode=ye;exports.INDENT_CONTENT_COMMAND={};exports.INSERT_LINE_BREAK_COMMAND=ea;exports.INSERT_PARAGRAPH_COMMAND=fa;exports.KEY_ARROW_DOWN_COMMAND=xa;exports.KEY_ARROW_LEFT_COMMAND=ra;exports.KEY_ARROW_RIGHT_COMMAND=pa;exports.KEY_ARROW_UP_COMMAND=wa;exports.KEY_BACKSPACE_COMMAND=Aa;exports.KEY_DELETE_COMMAND=Ca;
180
- exports.KEY_ENTER_COMMAND=ya;exports.KEY_ESCAPE_COMMAND=Ba;exports.KEY_MODIFIER_COMMAND=Ma;exports.KEY_SPACE_COMMAND=za;exports.KEY_TAB_COMMAND=Da;exports.LineBreakNode=de;exports.MOVE_TO_END=qa;exports.MOVE_TO_START=sa;exports.OUTDENT_CONTENT_COMMAND={};exports.PASTE_COMMAND=ja;exports.ParagraphNode=se;exports.REDO_COMMAND=oa;exports.REMOVE_TEXT_COMMAND=ka;exports.RootNode=ae;exports.SELECTION_CHANGE_COMMAND=aa;exports.TextNode=je;exports.UNDO_COMMAND=na;exports.VERSION="0.3.9";
180
+ exports.KEY_ENTER_COMMAND=ya;exports.KEY_ESCAPE_COMMAND=Ba;exports.KEY_MODIFIER_COMMAND=Ma;exports.KEY_SPACE_COMMAND=za;exports.KEY_TAB_COMMAND=Da;exports.LineBreakNode=de;exports.MOVE_TO_END=qa;exports.MOVE_TO_START=sa;exports.OUTDENT_CONTENT_COMMAND={};exports.PASTE_COMMAND=ja;exports.ParagraphNode=se;exports.REDO_COMMAND=oa;exports.REMOVE_TEXT_COMMAND=ka;exports.RootNode=ae;exports.SELECTION_CHANGE_COMMAND=aa;exports.TextNode=je;exports.UNDO_COMMAND=na;exports.VERSION="0.3.10";
181
181
  exports.createCommand=function(){return{}};
182
182
  exports.createEditor=function(a){var b=a||{},c=Z,d=b.theme||{};let f=void 0===a?c:b.parentEditor||null,e=b.disableEvents||!1,g=be(),h=b.namespace||(null!==f?f._config.namespace:Lb()),k=b.editorState,m=[ae,je,de,se,...(b.nodes||[])],l=b.onError;b=b.readOnly||!1;if(void 0===a&&null!==c)a=c._nodes;else for(a=new Map,c=0;c<m.length;c++){let n=m[c],r=n.getType();a.set(r,{klass:n,transforms:new Set})}d=new ve(g,f,a,{disableEvents:e,namespace:h,theme:d},l?l:console.error,ue(a),b);void 0!==k&&(d._pendingEditorState=
183
183
  k,d._dirtyType=2);return d}
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export declare const VERSION = "0.3.9";
8
+ export declare const VERSION = "0.3.10";
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "rich-text"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "0.3.9",
12
+ "version": "0.3.10",
13
13
  "main": "Lexical.js",
14
14
  "repository": {
15
15
  "type": "git",