@lexical/mark 0.6.0 → 0.6.2

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.
@@ -181,7 +181,7 @@ class MarkNode extends lexical.ElementNode {
181
181
 
182
182
  }
183
183
  function $createMarkNode(ids) {
184
- return new MarkNode(ids);
184
+ return lexical.$applyNodeReplacement(new MarkNode(ids));
185
185
  }
186
186
  function $isMarkNode(node) {
187
187
  return node instanceof MarkNode;
@@ -4,11 +4,11 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- 'use strict';var m=require("lexical"),n=require("@lexical/utils");
8
- class p extends m.ElementNode{static getType(){return"mark"}static clone(a){return new p(Array.from(a.__ids),a.__key)}static importDOM(){return null}static importJSON(a){let b=q(a.ids);b.setFormat(a.format);b.setIndent(a.indent);b.setDirection(a.direction);return b}exportJSON(){return{...super.exportJSON(),ids:this.getIDs(),type:"mark",version:1}}constructor(a,b){super(b);this.__ids=a||[]}createDOM(a){let b=document.createElement("mark");n.addClassNamesToElement(b,a.theme.mark);1<this.__ids.length&&
7
+ 'use strict';var k=require("lexical"),n=require("@lexical/utils");
8
+ class p extends k.ElementNode{static getType(){return"mark"}static clone(a){return new p(Array.from(a.__ids),a.__key)}static importDOM(){return null}static importJSON(a){let b=q(a.ids);b.setFormat(a.format);b.setIndent(a.indent);b.setDirection(a.direction);return b}exportJSON(){return{...super.exportJSON(),ids:this.getIDs(),type:"mark",version:1}}constructor(a,b){super(b);this.__ids=a||[]}createDOM(a){let b=document.createElement("mark");n.addClassNamesToElement(b,a.theme.mark);1<this.__ids.length&&
9
9
  n.addClassNamesToElement(b,a.theme.markOverlap);return b}updateDOM(a,b,c){a=a.__ids.length;let d=this.__ids.length;c=c.theme.markOverlap;a!==d&&(1===a?2===d&&n.addClassNamesToElement(b,c):1===d&&n.removeClassNamesFromElement(b,c));return!1}hasID(a){let b=this.getIDs();for(let c=0;c<b.length;c++)if(a===b[c])return!0;return!1}getIDs(){let a=this.getLatest();return r(a)?a.__ids:[]}addID(a){var b=this.getWritable();if(r(b)){let c=b.__ids;b.__ids=c;for(b=0;b<c.length;b++)if(a===c[b])return;c.push(a)}}deleteID(a){var b=
10
- this.getWritable();if(r(b)){let c=b.__ids;b.__ids=c;for(b=0;b<c.length;b++)if(a===c[b]){c.splice(b,1);break}}}insertNewAfter(a){a=this.getParentOrThrow().insertNewAfter(a);if(m.$isElementNode(a)){let b=q(this.__ids);a.append(b);return b}return null}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(a,b,c){if(!m.$isRangeSelection(b)||"html"===c)return!1;let d=b.anchor,g=b.focus;a=d.getNode();c=g.getNode();b=b.isBackward()?d.offset-
11
- g.offset:g.offset-d.offset;return this.isParentOf(a)&&this.isParentOf(c)&&this.getTextContent().length===b}excludeFromCopy(a){return"clone"!==a}}function q(a){return new p(a)}function r(a){return a instanceof p}exports.$createMarkNode=q;exports.$getMarkIDs=function(a,b){for(;null!==a;){if(r(a))return a.getIDs();if(m.$isTextNode(a)&&b===a.getTextContentSize()){let c=a.getNextSibling();if(r(c))return c.getIDs()}a=a.getParent()}return null};exports.$isMarkNode=r;
10
+ this.getWritable();if(r(b)){let c=b.__ids;b.__ids=c;for(b=0;b<c.length;b++)if(a===c[b]){c.splice(b,1);break}}}insertNewAfter(a){a=this.getParentOrThrow().insertNewAfter(a);if(k.$isElementNode(a)){let b=q(this.__ids);a.append(b);return b}return null}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(a,b,c){if(!k.$isRangeSelection(b)||"html"===c)return!1;let d=b.anchor,g=b.focus;a=d.getNode();c=g.getNode();b=b.isBackward()?d.offset-
11
+ g.offset:g.offset-d.offset;return this.isParentOf(a)&&this.isParentOf(c)&&this.getTextContent().length===b}excludeFromCopy(a){return"clone"!==a}}function q(a){return k.$applyNodeReplacement(new p(a))}function r(a){return a instanceof p}exports.$createMarkNode=q;exports.$getMarkIDs=function(a,b){for(;null!==a;){if(r(a))return a.getIDs();if(k.$isTextNode(a)&&b===a.getTextContentSize()){let c=a.getNextSibling();if(r(c))return c.getIDs()}a=a.getParent()}return null};exports.$isMarkNode=r;
12
12
  exports.$unwrapMarkNode=function(a){let b=a.getChildren(),c=null;for(let d=0;d<b.length;d++){let g=b[d];null===c?a.insertBefore(g):c.insertAfter(g);c=g}a.remove()};
13
- exports.$wrapSelectionInMarkNode=function(a,b,c,d){let g=a.getNodes();var k=a.anchor.offset,h=a.focus.offset;a=g.length;let x=b?h:k;b=b?k:h;let t,l;for(k=0;k<a;k++){var e=g[k];if(m.$isElementNode(l)&&l.isParentOf(e))continue;h=0===k;let v=k===a-1;var f=null;if(m.$isTextNode(e)){f=e.getTextContentSize();let w=h?x:0,u=v?b:f;if(0===w&&0===u)continue;e=e.splitText(w,u);f=1<e.length&&(3===e.length||h&&!v||u===f)?e[1]:e[0]}else if(r(e))continue;else m.$isElementNode(e)&&e.isInline()&&(f=e);null!==f?f&&
14
- f.is(t)||(h=f.getParent(),null!=h&&h.is(t)||(l=void 0),t=h,void 0===l&&(l=(d||q)([c]),f.insertBefore(l)),l.append(f)):l=t=void 0}};exports.MarkNode=p
13
+ exports.$wrapSelectionInMarkNode=function(a,b,c,d){let g=a.getNodes();var l=a.anchor.offset,h=a.focus.offset;a=g.length;let x=b?h:l;b=b?l:h;let t,m;for(l=0;l<a;l++){var e=g[l];if(k.$isElementNode(m)&&m.isParentOf(e))continue;h=0===l;let v=l===a-1;var f=null;if(k.$isTextNode(e)){f=e.getTextContentSize();let w=h?x:0,u=v?b:f;if(0===w&&0===u)continue;e=e.splitText(w,u);f=1<e.length&&(3===e.length||h&&!v||u===f)?e[1]:e[0]}else if(r(e))continue;else k.$isElementNode(e)&&e.isInline()&&(f=e);null!==f?f&&
14
+ f.is(t)||(h=f.getParent(),null!=h&&h.is(t)||(m=void 0),t=h,void 0===m&&(m=(d||q)([c]),f.insertBefore(m)),m.append(f)):m=t=void 0}};exports.MarkNode=p
package/package.json CHANGED
@@ -8,13 +8,13 @@
8
8
  "mark"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.6.0",
11
+ "version": "0.6.2",
12
12
  "main": "LexicalMark.js",
13
13
  "peerDependencies": {
14
- "lexical": "0.6.0"
14
+ "lexical": "0.6.2"
15
15
  },
16
16
  "dependencies": {
17
- "@lexical/utils": "0.6.0"
17
+ "@lexical/utils": "0.6.2"
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",