@lexical/mark 0.51.0 → 0.51.1-nightly.20260921.0

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.
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{getterTableOf as t,setterTableOf as e,setterDefaultOf as n,ElementNode as r,$getDocument as i,addClassNamesToElement as s,removeClassNamesFromElement as o,$isRangeSelection as c,$applyNodeReplacement as f,nodeSchema as l,withAccessors as d,arrayValue as u,stringValue as a,$isTextNode as _,$createRangeSelection as m,$isElementNode as h,$isDecoratorNode as g}from"lexical";const y=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function x(t,e){if("number"==typeof t)return Number.isFinite(t)?t:e;if("string"!=typeof t||!y.test(t))return e;const n=Number(t);return Number.isFinite(n)?n:e}function p(t,e){t.__ids=e.__ids}const I=r=>{const i=t(r,"format"),s=e(r,"format"),o=n(r,"format");return{exportJSON:function(t){const e=t.__textFormat,n=t.__textStyle,r=(0!==e||""!==n)&&t.shouldSerializeTextStyles();return{children:[],ids:t.getIDs(),direction:t.__dir,format:i[t.__format],indent:t.__indent,textFormat:0!==e&&r?e:void 0,textStyle:""!==n&&r?n:void 0,type:t.__type,version:1}},exportCompactJSON:function(t){const e=t.__textFormat,n=t.__textStyle,r=(0!==e||""!==n)&&t.shouldSerializeTextStyles(),s={type:t.__type,children:[]},o=t.getIDs();void 0===o||Array.isArray(o)&&0===o.length||(s.ids=o);const c=t.__dir;null!=c&&(s.direction=c);const f=i[t.__format];void 0!==f&&""!==f&&(s.format=f);const l=t.__indent;return void 0!==l&&0!==l&&(s.indent=l),void 0!==e&&0!==e&&r&&(s.textFormat=e),void 0!==n&&""!==n&&r&&(s.textStyle=n),s},updateFromJSON:function(t,e){const n=e.direction;t.__dir=null===n||"ltr"===n||"rtl"===n?n:null;const r=e.format;t.__format="string"==typeof r&&r in s?s[r]:o,t.__indent=function(t,e,n,r){const i=x(t,e);return i>=n&&i<=r&&Number.isInteger(i)?i:e}(e.indent,0,0,Infinity),t.__textFormat=x(e.textFormat,0);const i=e.textStyle;t.__textStyle="string"==typeof i?i:"";const c=e.ids;return t.__ids=Array.isArray(c)?Array.from(c,t=>"string"==typeof t?t:""):[],t},afterCloneFrom:p}},D=/* @__PURE__ */l()({ids:/* @__PURE__ */d(/* @__PURE__ */u(/* @__PURE__ */a()),{getter:"getIDs",setter:{field:"__ids",method:"setIDs"}})}),S=[];class v extends r{__ids;$config(){return this.config("mark",{extends:r,generated:I,json:D})}constructor(t=S,e){super(e),this.__ids=t}createDOM(t){const e=i().createElement("mark");return s(e,t.theme.mark),this.__ids.length>1&&s(e,t.theme.markOverlap),e}updateDOM(t,e,n){const r=t.__ids,i=this.__ids,c=r.length,f=i.length,l=n.theme.markOverlap,d=f>1;return c>1!==d&&(d?s(e,l):o(e,l)),!1}hasID(t){return this.getIDs().includes(t)}getIDs(){return Array.from(this.getLatest().__ids)}setIDs(t){const e=this.getWritable();return e.__ids=t,e}addID(t){const e=this.getWritable();return e.__ids.includes(t)?e:e.setIDs([...e.__ids,t])}deleteID(t){const e=this.getWritable(),n=e.__ids.indexOf(t);if(-1===n)return e;const r=Array.from(e.__ids);return r.splice(n,1),e.setIDs(r)}insertNewAfter(t,e=!0){const n=A(this.__ids);return this.insertAfter(n,e),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(t,e,n){if(!c(e)||"html"===n)return!1;const r=e.anchor,i=e.focus,s=r.getNode(),o=i.getNode(),f=e.isBackward()?r.offset-i.offset:i.offset-r.offset;return this.isParentOf(s)&&this.isParentOf(o)&&this.getTextContent().length===f}excludeFromCopy(t){return"clone"!==t}}function A(t=S){return f(new v(t))}function F(t){return t instanceof v}function N(t){const e=t.getChildren();let n=null;for(let r=0;r<e.length;r++){const i=e[r];null===n?t.insertBefore(i):n.insertAfter(i),n=i}t.remove()}function O(t,e,n,r){const i=m(),[s,o]=t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];let c,f;i.anchor.set(s.key,s.offset,s.type),i.focus.set(o.key,o.offset,o.type);const l=i.extract();for(const t of l){if(h(f)&&f.isParentOf(t))continue;let e=null;if(_(t))e=t;else{if(F(t))continue;(h(t)||g(t))&&t.isInline()&&(e=t)}if(null!==e){if(e&&e.is(c))continue;const t=e.getParent();if(null!=t&&t.is(c)||(f=void 0),c=t,void 0===f){f=(r||A)([n]),e.insertBefore(f)}f.append(e)}else c=void 0,f=void 0}h(f)&&(e?f.selectStart():f.selectEnd())}function k(t,e){let n=t;for(;null!==n;){if(F(n))return n.getIDs();if(_(n)&&e===n.getTextContentSize()){const t=n.getNextSibling();if(F(t))return t.getIDs()}n=n.getParent()}return null}const b={name:"@lexical/mark",nodes:()=>[v]};export{A as $createMarkNode,k as $getMarkIDs,F as $isMarkNode,N as $unwrapMarkNode,O as $wrapSelectionInMarkNode,b as MarkExtension,v as MarkNode};
9
+ import{getterTableOf as t,setterTableOf as e,setterDefaultOf as n,ElementNode as r,$getDocument as i,addClassNamesToElement as s,removeClassNamesFromElement as o,$isRangeSelection as c,$applyNodeReplacement as f,nodeSchema as l,withAccessors as d,arrayValue as u,stringValue as a,$isTextNode as _,$createRangeSelection as m,$isElementNode as h,$isDecoratorNode as g}from"lexical";const y=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function x(t,e){if("number"==typeof t)return Number.isFinite(t)?t:e;if("string"!=typeof t||!y.test(t))return e;const n=Number(t);return Number.isFinite(n)?n:e}function p(t,e){t.__ids=e.__ids}const I=r=>{const i=t(r,"format"),s=e(r,"format"),o=n(r,"format");return{exportJSON:function(t){const e=t.__textFormat,n=t.__textStyle,r=(0!==e||""!==n)&&t.shouldSerializeTextStyles();return{children:[],ids:t.getIDs(),direction:t.__dir,format:i[t.__format],indent:t.__indent,textFormat:0!==e&&r?e:void 0,textStyle:""!==n&&r?n:void 0,type:t.__type,version:1}},exportCompactJSON:function(t){const e=t.__textFormat,n=t.__textStyle,r=(0!==e||""!==n)&&t.shouldSerializeTextStyles(),s={type:t.__type,children:[]},o=t.getIDs();void 0===o||Array.isArray(o)&&0===o.length||(s.ids=o);const c=t.__dir;null!=c&&(s.direction=c);const f=i[t.__format];void 0!==f&&""!==f&&(s.format=f);const l=t.__indent;return void 0!==l&&0!==l&&(s.indent=l),void 0!==e&&0!==e&&r&&(s.textFormat=e),void 0!==n&&""!==n&&r&&(s.textStyle=n),s},updateFromJSON:function(t,e){const n=e.direction;t.__dir=null===n||"ltr"===n||"rtl"===n?n:null;const r=e.format;t.__format="string"==typeof r&&r in s?s[r]:o,t.__indent=function(t){const e=x(t,0);return e>=0&&e<=Infinity&&Number.isInteger(e)?e:0}(e.indent),t.__textFormat=x(e.textFormat,0);const i=e.textStyle;t.__textStyle="string"==typeof i?i:"";const c=e.ids;return t.__ids=Array.isArray(c)?Array.from(c,t=>"string"==typeof t?t:""):[],t},afterCloneFrom:p}},D=/* @__PURE__ */l()({ids:/* @__PURE__ */d(/* @__PURE__ */u(/* @__PURE__ */a()),{getter:"getIDs",setter:{field:"__ids",method:"setIDs"}})}),S=[];class v extends r{__ids;$config(){return this.config("mark",{extends:r,generated:I,json:D})}constructor(t=S,e){super(e),this.__ids=t}createDOM(t){const e=i().createElement("mark");return s(e,t.theme.mark),this.__ids.length>1&&s(e,t.theme.markOverlap),e}updateDOM(t,e,n){const r=t.__ids,i=this.__ids,c=r.length,f=i.length,l=n.theme.markOverlap,d=f>1;return c>1!==d&&(d?s(e,l):o(e,l)),!1}hasID(t){return this.getIDs().includes(t)}getIDs(){return Array.from(this.getLatest().__ids)}setIDs(t){const e=this.getWritable();return e.__ids=t,e}addID(t){const e=this.getWritable();return e.__ids.includes(t)?e:e.setIDs([...e.__ids,t])}deleteID(t){const e=this.getWritable(),n=e.__ids.indexOf(t);if(-1===n)return e;const r=Array.from(e.__ids);return r.splice(n,1),e.setIDs(r)}insertNewAfter(t,e=!0){const n=A(this.__ids);return this.insertAfter(n,e),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(t,e,n){if(!c(e)||"html"===n)return!1;const r=e.anchor,i=e.focus,s=r.getNode(),o=i.getNode(),f=e.isBackward()?r.offset-i.offset:i.offset-r.offset;return this.isParentOf(s)&&this.isParentOf(o)&&this.getTextContent().length===f}excludeFromCopy(t){return"clone"!==t}}function A(t=S){return f(new v(t))}function F(t){return t instanceof v}function N(t){const e=t.getChildren();let n=null;for(let r=0;r<e.length;r++){const i=e[r];null===n?t.insertBefore(i):n.insertAfter(i),n=i}t.remove()}function O(t,e,n,r){const i=m(),[s,o]=t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];let c,f;i.anchor.set(s.key,s.offset,s.type),i.focus.set(o.key,o.offset,o.type);const l=i.extract();for(const t of l){if(h(f)&&f.isParentOf(t))continue;let e=null;if(_(t))e=t;else{if(F(t))continue;(h(t)||g(t))&&t.isInline()&&(e=t)}if(null!==e){if(e&&e.is(c))continue;const t=e.getParent();null!=t&&t.is(c)||(f=void 0),c=t,void 0===f&&(f=(r||A)([n]),e.insertBefore(f)),f.append(e)}else c=void 0,f=void 0}h(f)&&(e?f.selectStart():f.selectEnd())}function k(t,e){let n=t;for(;null!==n;){if(F(n))return n.getIDs();if(_(n)&&e===n.getTextContentSize()){const t=n.getNextSibling();if(F(t))return t.getIDs()}n=n.getParent()}return null}const b={name:"@lexical/mark",nodes:()=>[v]};export{A as $createMarkNode,k as $getMarkIDs,F as $isMarkNode,N as $unwrapMarkNode,O as $wrapSelectionInMarkNode,b as MarkExtension,v as MarkNode};
package/package.json CHANGED
@@ -8,12 +8,12 @@
8
8
  "mark"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.51.0",
11
+ "version": "0.51.1-nightly.20260921.0",
12
12
  "main": "./dist/LexicalMark.js",
13
13
  "types": "./dist/typescript-too-old.d.ts",
14
14
  "dependencies": {
15
- "@lexical/utils": "0.51.0",
16
- "lexical": "0.51.0"
15
+ "@lexical/utils": "0.51.1-nightly.20260921.0",
16
+ "lexical": "0.51.1-nightly.20260921.0"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",