@lexical/mark 0.35.1-nightly.20250924.0 → 0.36.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,7 +24,7 @@ const NO_IDS = [];
24
24
  /** @noInheritDoc */
25
25
  class MarkNode extends lexical.ElementNode {
26
26
  /** @internal */
27
-
27
+ __ids;
28
28
  static getType() {
29
29
  return 'mark';
30
30
  }
@@ -256,9 +256,18 @@ function $getMarkIDs(node, offset) {
256
256
  return null;
257
257
  }
258
258
 
259
+ /**
260
+ * Configures {@link MarkNode}
261
+ */
262
+ const MarkExtension = lexical.defineExtension({
263
+ name: '@lexical/mark',
264
+ nodes: [MarkNode]
265
+ });
266
+
259
267
  exports.$createMarkNode = $createMarkNode;
260
268
  exports.$getMarkIDs = $getMarkIDs;
261
269
  exports.$isMarkNode = $isMarkNode;
262
270
  exports.$unwrapMarkNode = $unwrapMarkNode;
263
271
  exports.$wrapSelectionInMarkNode = $wrapSelectionInMarkNode;
272
+ exports.MarkExtension = MarkExtension;
264
273
  exports.MarkNode = MarkNode;
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- import { ElementNode, $isRangeSelection, $applyNodeReplacement, $createRangeSelection, $isElementNode, $isTextNode, $isDecoratorNode } from 'lexical';
9
+ import { ElementNode, $isRangeSelection, $applyNodeReplacement, defineExtension, $createRangeSelection, $isElementNode, $isTextNode, $isDecoratorNode } from 'lexical';
10
10
  import { addClassNamesToElement, removeClassNamesFromElement } from '@lexical/utils';
11
11
 
12
12
  /**
@@ -22,7 +22,7 @@ const NO_IDS = [];
22
22
  /** @noInheritDoc */
23
23
  class MarkNode extends ElementNode {
24
24
  /** @internal */
25
-
25
+ __ids;
26
26
  static getType() {
27
27
  return 'mark';
28
28
  }
@@ -254,4 +254,12 @@ function $getMarkIDs(node, offset) {
254
254
  return null;
255
255
  }
256
256
 
257
- export { $createMarkNode, $getMarkIDs, $isMarkNode, $unwrapMarkNode, $wrapSelectionInMarkNode, MarkNode };
257
+ /**
258
+ * Configures {@link MarkNode}
259
+ */
260
+ const MarkExtension = defineExtension({
261
+ name: '@lexical/mark',
262
+ nodes: [MarkNode]
263
+ });
264
+
265
+ export { $createMarkNode, $getMarkIDs, $isMarkNode, $unwrapMarkNode, $wrapSelectionInMarkNode, MarkExtension, MarkNode };
@@ -12,6 +12,8 @@ import type {
12
12
  RangeSelection,
13
13
  TextNode,
14
14
  SerializedElementNode,
15
+ LexicalExtension,
16
+ ExtensionConfigBase,
15
17
  } from 'lexical';
16
18
  import {ElementNode, LexicalNode} from 'lexical';
17
19
 
@@ -53,3 +55,5 @@ declare export function $wrapSelectionInMarkNode(
53
55
  ): void;
54
56
 
55
57
  declare export function $unwrapMarkNode(node: MarkNode): void;
58
+
59
+ declare export var MarkExtension: LexicalExtension<ExtensionConfigBase, "@lexical/mark", void, void>;
package/LexicalMark.mjs CHANGED
@@ -14,4 +14,5 @@ export const $getMarkIDs = mod.$getMarkIDs;
14
14
  export const $isMarkNode = mod.$isMarkNode;
15
15
  export const $unwrapMarkNode = mod.$unwrapMarkNode;
16
16
  export const $wrapSelectionInMarkNode = mod.$wrapSelectionInMarkNode;
17
+ export const MarkExtension = mod.MarkExtension;
17
18
  export const MarkNode = mod.MarkNode;
@@ -12,4 +12,5 @@ export const $getMarkIDs = mod.$getMarkIDs;
12
12
  export const $isMarkNode = mod.$isMarkNode;
13
13
  export const $unwrapMarkNode = mod.$unwrapMarkNode;
14
14
  export const $wrapSelectionInMarkNode = mod.$wrapSelectionInMarkNode;
15
+ export const MarkExtension = mod.MarkExtension;
15
16
  export const MarkNode = mod.MarkNode;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("lexical"),t=require("@lexical/utils");const r=[];class s extends e.ElementNode{static getType(){return"mark"}static clone(e){return new s(e.__ids,e.__key)}static importDOM(){return null}static importJSON(e){return n().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setIDs(e.ids)}exportJSON(){return{...super.exportJSON(),ids:this.getIDs()}}constructor(e=r,t){super(t),this.__ids=e}createDOM(e){const r=document.createElement("mark");return t.addClassNamesToElement(r,e.theme.mark),this.__ids.length>1&&t.addClassNamesToElement(r,e.theme.markOverlap),r}updateDOM(e,r,s){const n=e.__ids,i=this.__ids,o=n.length,a=i.length,l=s.theme.markOverlap;return o!==a&&(1===o?2===a&&t.addClassNamesToElement(r,l):1===a&&t.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=n(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 n(t=r){return e.$applyNodeReplacement(new s(t))}function i(e){return e instanceof s}exports.$createMarkNode=n,exports.$getMarkIDs=function(t,r){let s=t;for(;null!==s;){if(i(s))return s.getIDs();if(e.$isTextNode(s)&&r===s.getTextContentSize()){const e=s.getNextSibling();if(i(e))return e.getIDs()}s=s.getParent()}return null},exports.$isMarkNode=i,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,s,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(i(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||n)([s]),r.insertBefore(d)}d.append(r)}else u=void 0,d=void 0}e.$isElementNode(d)&&(r?d.selectStart():d.selectEnd())},exports.MarkNode=s;
9
+ "use strict";var e=require("lexical"),t=require("@lexical/utils");const r=[];class s extends e.ElementNode{__ids;static getType(){return"mark"}static clone(e){return new s(e.__ids,e.__key)}static importDOM(){return null}static importJSON(e){return n().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setIDs(e.ids)}exportJSON(){return{...super.exportJSON(),ids:this.getIDs()}}constructor(e=r,t){super(t),this.__ids=e}createDOM(e){const r=document.createElement("mark");return t.addClassNamesToElement(r,e.theme.mark),this.__ids.length>1&&t.addClassNamesToElement(r,e.theme.markOverlap),r}updateDOM(e,r,s){const n=e.__ids,i=this.__ids,o=n.length,a=i.length,l=s.theme.markOverlap;return o!==a&&(1===o?2===a&&t.addClassNamesToElement(r,l):1===a&&t.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=n(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 n(t=r){return e.$applyNodeReplacement(new s(t))}function i(e){return e instanceof s}const o=e.defineExtension({name:"@lexical/mark",nodes:[s]});exports.$createMarkNode=n,exports.$getMarkIDs=function(t,r){let s=t;for(;null!==s;){if(i(s))return s.getIDs();if(e.$isTextNode(s)&&r===s.getTextContentSize()){const e=s.getNextSibling();if(i(e))return e.getIDs()}s=s.getParent()}return null},exports.$isMarkNode=i,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,s,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(i(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||n)([s]),r.insertBefore(d)}d.append(r)}else u=void 0,d=void 0}e.$isElementNode(d)&&(r?d.selectStart():d.selectEnd())},exports.MarkExtension=o,exports.MarkNode=s;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{ElementNode as t,$isRangeSelection as e,$applyNodeReplacement as r,$createRangeSelection as n,$isElementNode as s,$isTextNode as i,$isDecoratorNode as o}from"lexical";import{addClassNamesToElement as c,removeClassNamesFromElement as u}from"@lexical/utils";const l=[];class f extends t{static getType(){return"mark"}static clone(t){return new f(t.__ids,t.__key)}static importDOM(){return null}static importJSON(t){return a().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setIDs(t.ids)}exportJSON(){return{...super.exportJSON(),ids:this.getIDs()}}constructor(t=l,e){super(e),this.__ids=t}createDOM(t){const e=document.createElement("mark");return c(e,t.theme.mark),this.__ids.length>1&&c(e,t.theme.markOverlap),e}updateDOM(t,e,r){const n=t.__ids,s=this.__ids,i=n.length,o=s.length,l=r.theme.markOverlap;return i!==o&&(1===i?2===o&&c(e,l):1===o&&u(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=a(this.__ids);return this.insertAfter(r,e),r}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(t,r,n){if(!e(r)||"html"===n)return!1;const s=r.anchor,i=r.focus,o=s.getNode(),c=i.getNode(),u=r.isBackward()?s.offset-i.offset:i.offset-s.offset;return this.isParentOf(o)&&this.isParentOf(c)&&this.getTextContent().length===u}excludeFromCopy(t){return"clone"!==t}}function a(t=l){return r(new f(t))}function d(t){return t instanceof f}function h(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 _(t,e,r,c){const u=n(),[l,f]=t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];let h,_;u.anchor.set(l.key,l.offset,l.type),u.focus.set(f.key,f.offset,f.type);const m=u.extract();for(const t of m){if(s(_)&&_.isParentOf(t))continue;let e=null;if(i(t))e=t;else{if(d(t))continue;(s(t)||o(t))&&t.isInline()&&(e=t)}if(null!==e){if(e&&e.is(h))continue;const t=e.getParent();if(null!=t&&t.is(h)||(_=void 0),h=t,void 0===_){_=(c||a)([r]),e.insertBefore(_)}_.append(e)}else h=void 0,_=void 0}s(_)&&(e?_.selectStart():_.selectEnd())}function m(t,e){let r=t;for(;null!==r;){if(d(r))return r.getIDs();if(i(r)&&e===r.getTextContentSize()){const t=r.getNextSibling();if(d(t))return t.getIDs()}r=r.getParent()}return null}export{a as $createMarkNode,m as $getMarkIDs,d as $isMarkNode,h as $unwrapMarkNode,_ as $wrapSelectionInMarkNode,f as MarkNode};
9
+ import{ElementNode as t,$isRangeSelection as e,$applyNodeReplacement as r,defineExtension as n,$createRangeSelection as s,$isElementNode as i,$isTextNode as o,$isDecoratorNode as c}from"lexical";import{addClassNamesToElement as u,removeClassNamesFromElement as l}from"@lexical/utils";const a=[];class f extends t{__ids;static getType(){return"mark"}static clone(t){return new f(t.__ids,t.__key)}static importDOM(){return null}static importJSON(t){return d().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setIDs(t.ids)}exportJSON(){return{...super.exportJSON(),ids:this.getIDs()}}constructor(t=a,e){super(e),this.__ids=t}createDOM(t){const e=document.createElement("mark");return u(e,t.theme.mark),this.__ids.length>1&&u(e,t.theme.markOverlap),e}updateDOM(t,e,r){const n=t.__ids,s=this.__ids,i=n.length,o=s.length,c=r.theme.markOverlap;return i!==o&&(1===i?2===o&&u(e,c):1===o&&l(e,c)),!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=d(this.__ids);return this.insertAfter(r,e),r}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(t,r,n){if(!e(r)||"html"===n)return!1;const s=r.anchor,i=r.focus,o=s.getNode(),c=i.getNode(),u=r.isBackward()?s.offset-i.offset:i.offset-s.offset;return this.isParentOf(o)&&this.isParentOf(c)&&this.getTextContent().length===u}excludeFromCopy(t){return"clone"!==t}}function d(t=a){return r(new f(t))}function h(t){return t instanceof f}function _(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 m(t,e,r,n){const u=s(),[l,a]=t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];let f,_;u.anchor.set(l.key,l.offset,l.type),u.focus.set(a.key,a.offset,a.type);const m=u.extract();for(const t of m){if(i(_)&&_.isParentOf(t))continue;let e=null;if(o(t))e=t;else{if(h(t))continue;(i(t)||c(t))&&t.isInline()&&(e=t)}if(null!==e){if(e&&e.is(f))continue;const t=e.getParent();if(null!=t&&t.is(f)||(_=void 0),f=t,void 0===_){_=(n||d)([r]),e.insertBefore(_)}_.append(e)}else f=void 0,_=void 0}i(_)&&(e?_.selectStart():_.selectEnd())}function g(t,e){let r=t;for(;null!==r;){if(h(r))return r.getIDs();if(o(r)&&e===r.getTextContentSize()){const t=r.getNextSibling();if(h(t))return t.getIDs()}r=r.getParent()}return null}const p=n({name:"@lexical/mark",nodes:[f]});export{d as $createMarkNode,g as $getMarkIDs,h as $isMarkNode,_ as $unwrapMarkNode,m as $wrapSelectionInMarkNode,p as MarkExtension,f as MarkNode};
package/index.d.ts CHANGED
@@ -11,4 +11,8 @@ import { $createMarkNode, $isMarkNode, MarkNode } from './MarkNode';
11
11
  export declare function $unwrapMarkNode(node: MarkNode): void;
12
12
  export declare function $wrapSelectionInMarkNode(selection: RangeSelection, isBackward: boolean, id: string, createNode?: (ids: Array<string>) => MarkNode): void;
13
13
  export declare function $getMarkIDs(node: TextNode, offset: number): null | Array<string>;
14
+ /**
15
+ * Configures {@link MarkNode}
16
+ */
17
+ export declare const MarkExtension: import("lexical").LexicalExtension<import("lexical").ExtensionConfigBase, "@lexical/mark", unknown, unknown>;
14
18
  export { $createMarkNode, $isMarkNode, MarkNode, SerializedMarkNode };
package/package.json CHANGED
@@ -8,12 +8,12 @@
8
8
  "mark"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.35.1-nightly.20250924.0",
11
+ "version": "0.36.0",
12
12
  "main": "LexicalMark.js",
13
13
  "types": "index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/utils": "0.35.1-nightly.20250924.0",
16
- "lexical": "0.35.1-nightly.20250924.0"
15
+ "@lexical/utils": "0.36.0",
16
+ "lexical": "0.36.0"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",