@lexical/mark 0.48.0 → 0.48.1-nightly.20260720.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.
@@ -24,22 +24,15 @@ const NO_IDS = [];
24
24
  class MarkNode extends lexical.ElementNode {
25
25
  /** @internal */
26
26
  __ids;
27
- static getType() {
28
- return 'mark';
29
- }
30
- static clone(node) {
31
- return new MarkNode(node.__ids, node.__key);
27
+ $config() {
28
+ return this.config('mark', {
29
+ extends: lexical.ElementNode
30
+ });
32
31
  }
33
32
  afterCloneFrom(prevNode) {
34
33
  super.afterCloneFrom(prevNode);
35
34
  this.__ids = prevNode.__ids;
36
35
  }
37
- static importDOM() {
38
- return null;
39
- }
40
- static importJSON(serializedNode) {
41
- return $createMarkNode().updateFromJSON(serializedNode);
42
- }
43
36
  updateFromJSON(serializedNode) {
44
37
  return super.updateFromJSON(serializedNode).setIDs(serializedNode.ids);
45
38
  }
@@ -22,22 +22,15 @@ const NO_IDS = [];
22
22
  class MarkNode extends ElementNode {
23
23
  /** @internal */
24
24
  __ids;
25
- static getType() {
26
- return 'mark';
27
- }
28
- static clone(node) {
29
- return new MarkNode(node.__ids, node.__key);
25
+ $config() {
26
+ return this.config('mark', {
27
+ extends: ElementNode
28
+ });
30
29
  }
31
30
  afterCloneFrom(prevNode) {
32
31
  super.afterCloneFrom(prevNode);
33
32
  this.__ids = prevNode.__ids;
34
33
  }
35
- static importDOM() {
36
- return null;
37
- }
38
- static importJSON(serializedNode) {
39
- return $createMarkNode().updateFromJSON(serializedNode);
40
- }
41
34
  updateFromJSON(serializedNode) {
42
35
  return super.updateFromJSON(serializedNode).setIDs(serializedNode.ids);
43
36
  }
@@ -24,9 +24,7 @@ export type SerializedMarkNode = SerializedElementNode & {
24
24
  declare export class MarkNode extends ElementNode {
25
25
  __ids: string[];
26
26
 
27
- // $FlowFixMe[incompatible-variance]
28
- static clone(node: this): MarkNode;
29
- constructor(ids: string[], key?: NodeKey): void;
27
+ constructor(ids?: string[], key?: NodeKey): void;
30
28
 
31
29
  hasID(id: string): boolean;
32
30
  getIDs(): string[];
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("lexical");const t=[];class r extends e.ElementNode{__ids;static getType(){return"mark"}static clone(e){return new r(e.__ids,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__ids=e.__ids}static importDOM(){return null}static importJSON(e){return s().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setIDs(e.ids)}exportJSON(){return{...super.exportJSON(),ids:this.getIDs()}}constructor(e=t,r){super(r),this.__ids=e}createDOM(t){const r=e.$getDocument().createElement("mark");return e.addClassNamesToElement(r,t.theme.mark),this.__ids.length>1&&e.addClassNamesToElement(r,t.theme.markOverlap),r}updateDOM(t,r,s){const n=t.__ids,i=this.__ids,o=n.length,a=i.length,l=s.theme.markOverlap;return o!==a&&(1===o?2===a&&e.addClassNamesToElement(r,l):1===a&&e.removeClassNamesFromElement(r,l)),!1}hasID(e){return this.getIDs().includes(e)}getIDs(){return Array.from(this.getLatest().__ids)}setIDs(e){const t=this.getWritable();return t.__ids=e,t}addID(e){const t=this.getWritable();return t.__ids.includes(e)?t:t.setIDs([...t.__ids,e])}deleteID(e){const t=this.getWritable(),r=t.__ids.indexOf(e);if(-1===r)return t;const s=Array.from(t.__ids);return s.splice(r,1),t.setIDs(s)}insertNewAfter(e,t=!0){const r=s(this.__ids);return this.insertAfter(r,t),r}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(t,r,s){if(!e.$isRangeSelection(r)||"html"===s)return!1;const n=r.anchor,i=r.focus,o=n.getNode(),a=i.getNode(),l=r.isBackward()?n.offset-i.offset:i.offset-n.offset;return this.isParentOf(o)&&this.isParentOf(a)&&this.getTextContent().length===l}excludeFromCopy(e){return"clone"!==e}}function s(s=t){return e.$applyNodeReplacement(new r(s))}function n(e){return e instanceof r}const i=/* @__PURE__ */e.defineExtension({name:"@lexical/mark",nodes:()=>[r]});exports.$createMarkNode=s,exports.$getMarkIDs=function(t,r){let s=t;for(;null!==s;){if(n(s))return s.getIDs();if(e.$isTextNode(s)&&r===s.getTextContentSize()){const e=s.getNextSibling();if(n(e))return e.getIDs()}s=s.getParent()}return null},exports.$isMarkNode=n,exports.$unwrapMarkNode=function(e){const t=e.getChildren();let r=null;for(let s=0;s<t.length;s++){const n=t[s];null===r?e.insertBefore(n):r.insertAfter(n),r=n}e.remove()},exports.$wrapSelectionInMarkNode=function(t,r,i,o){const a=e.$createRangeSelection(),[l,c]=t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];let u,d;a.anchor.set(l.key,l.offset,l.type),a.focus.set(c.key,c.offset,c.type);const f=a.extract();for(const t of f){if(e.$isElementNode(d)&&d.isParentOf(t))continue;let r=null;if(e.$isTextNode(t))r=t;else{if(n(t))continue;(e.$isElementNode(t)||e.$isDecoratorNode(t))&&t.isInline()&&(r=t)}if(null!==r){if(r&&r.is(u))continue;const e=r.getParent();if(null!=e&&e.is(u)||(d=void 0),u=e,void 0===d){d=(o||s)([i]),r.insertBefore(d)}d.append(r)}else u=void 0,d=void 0}e.$isElementNode(d)&&(r?d.selectStart():d.selectEnd())},exports.MarkExtension=i,exports.MarkNode=r;
9
+ "use strict";var e=require("lexical");const t=[];class s extends e.ElementNode{__ids;$config(){return this.config("mark",{extends:e.ElementNode})}afterCloneFrom(e){super.afterCloneFrom(e),this.__ids=e.__ids}updateFromJSON(e){return super.updateFromJSON(e).setIDs(e.ids)}exportJSON(){return{...super.exportJSON(),ids:this.getIDs()}}constructor(e=t,s){super(s),this.__ids=e}createDOM(t){const s=e.$getDocument().createElement("mark");return e.addClassNamesToElement(s,t.theme.mark),this.__ids.length>1&&e.addClassNamesToElement(s,t.theme.markOverlap),s}updateDOM(t,s,r){const n=t.__ids,o=this.__ids,i=n.length,a=o.length,l=r.theme.markOverlap;return i!==a&&(1===i?2===a&&e.addClassNamesToElement(s,l):1===a&&e.removeClassNamesFromElement(s,l)),!1}hasID(e){return this.getIDs().includes(e)}getIDs(){return Array.from(this.getLatest().__ids)}setIDs(e){const t=this.getWritable();return t.__ids=e,t}addID(e){const t=this.getWritable();return t.__ids.includes(e)?t:t.setIDs([...t.__ids,e])}deleteID(e){const t=this.getWritable(),s=t.__ids.indexOf(e);if(-1===s)return t;const r=Array.from(t.__ids);return r.splice(s,1),t.setIDs(r)}insertNewAfter(e,t=!0){const s=r(this.__ids);return this.insertAfter(s,t),s}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(t,s,r){if(!e.$isRangeSelection(s)||"html"===r)return!1;const n=s.anchor,o=s.focus,i=n.getNode(),a=o.getNode(),l=s.isBackward()?n.offset-o.offset:o.offset-n.offset;return this.isParentOf(i)&&this.isParentOf(a)&&this.getTextContent().length===l}excludeFromCopy(e){return"clone"!==e}}function r(r=t){return e.$applyNodeReplacement(new s(r))}function n(e){return e instanceof s}const o=/* @__PURE__ */e.defineExtension({name:"@lexical/mark",nodes:()=>[s]});exports.$createMarkNode=r,exports.$getMarkIDs=function(t,s){let r=t;for(;null!==r;){if(n(r))return r.getIDs();if(e.$isTextNode(r)&&s===r.getTextContentSize()){const e=r.getNextSibling();if(n(e))return e.getIDs()}r=r.getParent()}return null},exports.$isMarkNode=n,exports.$unwrapMarkNode=function(e){const t=e.getChildren();let s=null;for(let r=0;r<t.length;r++){const n=t[r];null===s?e.insertBefore(n):s.insertAfter(n),s=n}e.remove()},exports.$wrapSelectionInMarkNode=function(t,s,o,i){const a=e.$createRangeSelection(),[l,c]=t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];let d,u;a.anchor.set(l.key,l.offset,l.type),a.focus.set(c.key,c.offset,c.type);const f=a.extract();for(const t of f){if(e.$isElementNode(u)&&u.isParentOf(t))continue;let s=null;if(e.$isTextNode(t))s=t;else{if(n(t))continue;(e.$isElementNode(t)||e.$isDecoratorNode(t))&&t.isInline()&&(s=t)}if(null!==s){if(s&&s.is(d))continue;const e=s.getParent();if(null!=e&&e.is(d)||(u=void 0),d=e,void 0===u){u=(i||r)([o]),s.insertBefore(u)}u.append(s)}else d=void 0,u=void 0}e.$isElementNode(u)&&(s?u.selectStart():u.selectEnd())},exports.MarkExtension=o,exports.MarkNode=s;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{ElementNode as t,$getDocument as e,addClassNamesToElement as r,removeClassNamesFromElement as n,$isRangeSelection as s,$applyNodeReplacement as i,$isTextNode as o,$createRangeSelection as c,$isElementNode as u,$isDecoratorNode as l,defineExtension as a}from"lexical";const f=[];class d extends t{__ids;static getType(){return"mark"}static clone(t){return new d(t.__ids,t.__key)}afterCloneFrom(t){super.afterCloneFrom(t),this.__ids=t.__ids}static importDOM(){return null}static importJSON(t){return h().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setIDs(t.ids)}exportJSON(){return{...super.exportJSON(),ids:this.getIDs()}}constructor(t=f,e){super(e),this.__ids=t}createDOM(t){const n=e().createElement("mark");return r(n,t.theme.mark),this.__ids.length>1&&r(n,t.theme.markOverlap),n}updateDOM(t,e,s){const i=t.__ids,o=this.__ids,c=i.length,u=o.length,l=s.theme.markOverlap;return c!==u&&(1===c?2===u&&r(e,l):1===u&&n(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(),r=e.__ids.indexOf(t);if(-1===r)return e;const n=Array.from(e.__ids);return n.splice(r,1),e.setIDs(n)}insertNewAfter(t,e=!0){const r=h(this.__ids);return this.insertAfter(r,e),r}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(t,e,r){if(!s(e)||"html"===r)return!1;const n=e.anchor,i=e.focus,o=n.getNode(),c=i.getNode(),u=e.isBackward()?n.offset-i.offset:i.offset-n.offset;return this.isParentOf(o)&&this.isParentOf(c)&&this.getTextContent().length===u}excludeFromCopy(t){return"clone"!==t}}function h(t=f){return i(new d(t))}function _(t){return t instanceof d}function m(t){const e=t.getChildren();let r=null;for(let n=0;n<e.length;n++){const s=e[n];null===r?t.insertBefore(s):r.insertAfter(s),r=s}t.remove()}function g(t,e,r,n){const s=c(),[i,a]=t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];let f,d;s.anchor.set(i.key,i.offset,i.type),s.focus.set(a.key,a.offset,a.type);const m=s.extract();for(const t of m){if(u(d)&&d.isParentOf(t))continue;let e=null;if(o(t))e=t;else{if(_(t))continue;(u(t)||l(t))&&t.isInline()&&(e=t)}if(null!==e){if(e&&e.is(f))continue;const t=e.getParent();if(null!=t&&t.is(f)||(d=void 0),f=t,void 0===d){d=(n||h)([r]),e.insertBefore(d)}d.append(e)}else f=void 0,d=void 0}u(d)&&(e?d.selectStart():d.selectEnd())}function p(t,e){let r=t;for(;null!==r;){if(_(r))return r.getIDs();if(o(r)&&e===r.getTextContentSize()){const t=r.getNextSibling();if(_(t))return t.getIDs()}r=r.getParent()}return null}const I=/* @__PURE__ */a({name:"@lexical/mark",nodes:()=>[d]});export{h as $createMarkNode,p as $getMarkIDs,_ as $isMarkNode,m as $unwrapMarkNode,g as $wrapSelectionInMarkNode,I as MarkExtension,d as MarkNode};
9
+ import{ElementNode as e,$getDocument as t,addClassNamesToElement as r,removeClassNamesFromElement as n,$isRangeSelection as s,$applyNodeReplacement as i,$isTextNode as o,$createRangeSelection as c,$isElementNode as f,$isDecoratorNode as u,defineExtension as l}from"lexical";const a=[];class d extends e{__ids;$config(){return this.config("mark",{extends:e})}afterCloneFrom(e){super.afterCloneFrom(e),this.__ids=e.__ids}updateFromJSON(e){return super.updateFromJSON(e).setIDs(e.ids)}exportJSON(){return{...super.exportJSON(),ids:this.getIDs()}}constructor(e=a,t){super(t),this.__ids=e}createDOM(e){const n=t().createElement("mark");return r(n,e.theme.mark),this.__ids.length>1&&r(n,e.theme.markOverlap),n}updateDOM(e,t,s){const i=e.__ids,o=this.__ids,c=i.length,f=o.length,u=s.theme.markOverlap;return c!==f&&(1===c?2===f&&r(t,u):1===f&&n(t,u)),!1}hasID(e){return this.getIDs().includes(e)}getIDs(){return Array.from(this.getLatest().__ids)}setIDs(e){const t=this.getWritable();return t.__ids=e,t}addID(e){const t=this.getWritable();return t.__ids.includes(e)?t:t.setIDs([...t.__ids,e])}deleteID(e){const t=this.getWritable(),r=t.__ids.indexOf(e);if(-1===r)return t;const n=Array.from(t.__ids);return n.splice(r,1),t.setIDs(n)}insertNewAfter(e,t=!0){const r=h(this.__ids);return this.insertAfter(r,t),r}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,r){if(!s(t)||"html"===r)return!1;const n=t.anchor,i=t.focus,o=n.getNode(),c=i.getNode(),f=t.isBackward()?n.offset-i.offset:i.offset-n.offset;return this.isParentOf(o)&&this.isParentOf(c)&&this.getTextContent().length===f}excludeFromCopy(e){return"clone"!==e}}function h(e=a){return i(new d(e))}function _(e){return e instanceof d}function g(e){const t=e.getChildren();let r=null;for(let n=0;n<t.length;n++){const s=t[n];null===r?e.insertBefore(s):r.insertAfter(s),r=s}e.remove()}function m(e,t,r,n){const s=c(),[i,l]=e.isBackward()?[e.focus,e.anchor]:[e.anchor,e.focus];let a,d;s.anchor.set(i.key,i.offset,i.type),s.focus.set(l.key,l.offset,l.type);const g=s.extract();for(const e of g){if(f(d)&&d.isParentOf(e))continue;let t=null;if(o(e))t=e;else{if(_(e))continue;(f(e)||u(e))&&e.isInline()&&(t=e)}if(null!==t){if(t&&t.is(a))continue;const e=t.getParent();if(null!=e&&e.is(a)||(d=void 0),a=e,void 0===d){d=(n||h)([r]),t.insertBefore(d)}d.append(t)}else a=void 0,d=void 0}f(d)&&(t?d.selectStart():d.selectEnd())}function p(e,t){let r=e;for(;null!==r;){if(_(r))return r.getIDs();if(o(r)&&t===r.getTextContentSize()){const e=r.getNextSibling();if(_(e))return e.getIDs()}r=r.getParent()}return null}const x=/* @__PURE__ */l({name:"@lexical/mark",nodes:()=>[d]});export{h as $createMarkNode,p as $getMarkIDs,_ as $isMarkNode,g as $unwrapMarkNode,m as $wrapSelectionInMarkNode,x as MarkExtension,d as MarkNode};
@@ -13,11 +13,14 @@ export type SerializedMarkNode = Spread<{
13
13
  export declare class MarkNode extends ElementNode {
14
14
  /** @internal */
15
15
  __ids: readonly string[];
16
- static getType(): string;
17
- static clone(node: MarkNode): MarkNode;
16
+ $config(): import("lexical").BaseStaticNodeConfig & {
17
+ readonly mark?: {
18
+ readonly extends: typeof ElementNode;
19
+ } | undefined;
20
+ } & import("lexical").StaticNodeTypeAccessor<"mark"> & import("lexical").StaticNodeConfigAccessor<{
21
+ readonly extends: typeof ElementNode;
22
+ }>;
18
23
  afterCloneFrom(prevNode: this): void;
19
- static importDOM(): null;
20
- static importJSON(serializedNode: SerializedMarkNode): MarkNode;
21
24
  updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedMarkNode>): this;
22
25
  exportJSON(): SerializedMarkNode;
23
26
  constructor(ids?: readonly string[], key?: NodeKey);
package/package.json CHANGED
@@ -8,12 +8,12 @@
8
8
  "mark"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.48.0",
11
+ "version": "0.48.1-nightly.20260720.0",
12
12
  "main": "./dist/LexicalMark.js",
13
13
  "types": "./dist/typescript-too-old.d.ts",
14
14
  "dependencies": {
15
- "@lexical/utils": "0.48.0",
16
- "lexical": "0.48.0"
15
+ "lexical": "0.48.1-nightly.20260720.0",
16
+ "@lexical/utils": "0.48.1-nightly.20260720.0"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
package/src/MarkNode.ts CHANGED
@@ -37,12 +37,8 @@ export class MarkNode extends ElementNode {
37
37
  /** @internal */
38
38
  __ids: readonly string[];
39
39
 
40
- static getType(): string {
41
- return 'mark';
42
- }
43
-
44
- static clone(node: MarkNode): MarkNode {
45
- return new MarkNode(node.__ids, node.__key);
40
+ $config() {
41
+ return this.config('mark', {extends: ElementNode});
46
42
  }
47
43
 
48
44
  afterCloneFrom(prevNode: this): void {
@@ -50,14 +46,6 @@ export class MarkNode extends ElementNode {
50
46
  this.__ids = prevNode.__ids;
51
47
  }
52
48
 
53
- static importDOM(): null {
54
- return null;
55
- }
56
-
57
- static importJSON(serializedNode: SerializedMarkNode): MarkNode {
58
- return $createMarkNode().updateFromJSON(serializedNode);
59
- }
60
-
61
49
  updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedMarkNode>): this {
62
50
  return super.updateFromJSON(serializedNode).setIDs(serializedNode.ids);
63
51
  }