@tiny-codes/react-easy 1.4.1 → 1.4.3

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/es/components/Lexical/helpers/index.d.ts +1 -0
  3. package/es/components/Lexical/helpers/index.js +22 -0
  4. package/es/components/Lexical/helpers/index.js.map +1 -1
  5. package/es/components/Lexical/nodes/CloseIcon.d.ts +0 -2
  6. package/es/components/Lexical/nodes/CloseIcon.js +0 -12
  7. package/es/components/Lexical/nodes/CloseIcon.js.map +1 -1
  8. package/es/components/Lexical/nodes/DivNode.d.ts +1 -3
  9. package/es/components/Lexical/nodes/DivNode.js +4 -32
  10. package/es/components/Lexical/nodes/DivNode.js.map +1 -1
  11. package/es/components/Lexical/nodes/SelectNode.d.ts +3 -3
  12. package/es/components/Lexical/nodes/SelectNode.js +13 -12
  13. package/es/components/Lexical/nodes/SelectNode.js.map +1 -1
  14. package/es/components/Lexical/nodes/base.d.ts +4 -0
  15. package/es/components/Lexical/nodes/base.js +33 -7
  16. package/es/components/Lexical/nodes/base.js.map +1 -1
  17. package/lib/components/Lexical/helpers/index.d.ts +1 -0
  18. package/lib/components/Lexical/helpers/index.js +23 -0
  19. package/lib/components/Lexical/helpers/index.js.map +2 -2
  20. package/lib/components/Lexical/nodes/CloseIcon.d.ts +0 -2
  21. package/lib/components/Lexical/nodes/CloseIcon.js +0 -11
  22. package/lib/components/Lexical/nodes/CloseIcon.js.map +2 -2
  23. package/lib/components/Lexical/nodes/DivNode.d.ts +1 -3
  24. package/lib/components/Lexical/nodes/DivNode.js +2 -26
  25. package/lib/components/Lexical/nodes/DivNode.js.map +2 -2
  26. package/lib/components/Lexical/nodes/SelectNode.d.ts +3 -3
  27. package/lib/components/Lexical/nodes/SelectNode.js +7 -5
  28. package/lib/components/Lexical/nodes/SelectNode.js.map +2 -2
  29. package/lib/components/Lexical/nodes/base.d.ts +4 -0
  30. package/lib/components/Lexical/nodes/base.js +22 -0
  31. package/lib/components/Lexical/nodes/base.js.map +2 -2
  32. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["DecoratorNode","ElementNode","BaseNodeHelper","props","superMethods","_this","_classCallCheck","_defineProperty","remove","preserveEmptyParent","_this$__props","__props","canBeRemoved","__superMethods","replace","replaceWith","includeChildren","_this$__props2","canBeReplaced","_createClass","key","value","getUnderlyingProps","restProps","_objectWithoutProperties","_excluded","BaseElementNode","_ElementNode","_inherits","_super","_createSuper","_thisSuper","_thisSuper2","_this2","_ref","_excluded2","call","_assertThisInitialized","__base","_get","_getPrototypeOf","prototype","Object","keys","hooks","forEach","method","bind","canBeEmpty","_this$__props$canBeEm","_this$__props3","canInsertTextBefore","_this$__props$canInse","_this$__props4","canInsertTextAfter","_this$__props$canInse2","_this$__props5","baseProps","_excluded3","BaseDecoratorNode","_DecoratorNode","_super2","_thisSuper3","_thisSuper4","_this3","_ref2","_excluded4","assign","_objectDestructuringEmpty"],"sources":["../../../../src/components/Lexical/nodes/base.ts"],"sourcesContent":["import type { LexicalNode } from 'lexical';\nimport { DecoratorNode, ElementNode } from 'lexical';\n\n/**\n * - EN: Common behavior flags for custom nodes.\n * - CN: 自定义节点的通用行为标记。\n */\nexport interface BaseNodeProps {\n /**\n * - EN: Whether the node can be removed. Default `true`.\n * - CN: 是否可被删除,默认 `true`。\n */\n canBeRemoved?: boolean;\n /**\n * - EN: Whether the node can be replaced. Default `true`.\n * - CN: 是否可被替换,默认 `true`。\n */\n canBeReplaced?: boolean;\n}\n/**\n * - EN: Extra behavior flags for element nodes.\n * - CN: 元素节点的附加行为标记。\n */\nexport interface BaseElementProps extends BaseNodeProps {\n /**\n * - EN: Whether an element is allowed to be empty. Default `false`.\n * - CN: 是否允许节点为空,默认 `false`。\n */\n canBeEmpty?: boolean;\n /**\n * - EN: Allow inserting text at the start of the element. Default `true`.\n * - CN: 是否允许在节点内的起始位置插入文本,默认 `true`。\n */\n canInsertTextBefore?: boolean;\n /**\n * - EN: Allow inserting text at the end of the element. Default `true`.\n * - CN: 是否允许在节点内的结束位置插入文本,默认 `true`。\n */\n canInsertTextAfter?: boolean;\n}\n\nexport type BaseDecoratorNodeProps = BaseNodeProps;\n\n/**\n * - EN: A helper wrapping base behaviors (remove/replace) with guard flags.\n * - CN: 封装基础行为(删除/替换)并根据标记进行限制的帮助器。\n *\n * @param props Node behavior flags | 节点行为标记\n * @param superMethods Methods delegated to the underlying node | 委托给底层节点的方法\n */\nexport class BaseNodeHelper<P extends BaseNodeProps> {\n __props: (P & BaseNodeProps) | undefined;\n __superMethods: Pick<LexicalNode, 'replace' | 'remove'>;\n\n constructor(props: P | undefined, superMethods: Pick<LexicalNode, 'replace' | 'remove'>) {\n this.__props = props as P & BaseNodeProps;\n this.__superMethods = superMethods;\n }\n\n hooks = {\n remove: (preserveEmptyParent?: boolean): void => {\n if (this.__props?.canBeRemoved === false) {\n return;\n }\n this.__superMethods.remove(preserveEmptyParent);\n },\n\n replace: <N extends LexicalNode>(replaceWith: N, includeChildren?: boolean): N => {\n if (this.__props?.canBeReplaced === false) {\n return this as unknown as N;\n }\n return this.__superMethods.replace(replaceWith, includeChildren);\n },\n };\n /**\n * - EN: Strip helper-only flags from props for DOM usage.\n * - CN: 去除仅用于帮助器的标记属性,得到用于 DOM 的纯属性。\n *\n * @param props Props including helper flags | 含帮助标记的属性\n */\n getUnderlyingProps(props: P & BaseNodeProps): Omit<P, keyof BaseNodeProps> {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { canBeRemoved, canBeReplaced, ...restProps } = props;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n\n/**\n * - EN: Base element node with behavior flags.\n * - CN: 带行为标记的基础元素节点。\n */\nexport class BaseElementNode<P extends BaseElementProps> extends ElementNode {\n __props: P | undefined;\n __base: BaseNodeHelper<P>;\n\n constructor(props?: P & { key?: string }) {\n const { key, ...restProps } = props || {};\n super(key);\n this.__props = restProps as P;\n this.__base = new BaseNodeHelper<P>(this.__props, {\n remove: () => super.remove(),\n replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren),\n });\n Object.keys(this.__base.hooks).forEach((key) => {\n const method = this.__base.hooks[key as keyof typeof this.__base.hooks];\n if (typeof method === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this[key as keyof this] = method.bind(this.__base) as any;\n }\n });\n }\n\n canBeEmpty(): boolean {\n return this.__props?.canBeEmpty ?? false;\n }\n\n canInsertTextBefore(): boolean {\n return this.__props?.canInsertTextBefore ?? true;\n }\n\n canInsertTextAfter(): boolean {\n return this.__props?.canInsertTextAfter ?? true;\n }\n\n /**\n * - EN: Strip element-specific flags and return DOM props.\n * - CN: 去除元素特有的标记并返回 DOM 属性。\n *\n * @param props Element props including flags | 含标记的元素属性\n */\n getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseElementProps> {\n const baseProps = this.__base.getUnderlyingProps(props ?? ({} as P));\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { canBeEmpty, canInsertTextBefore, canInsertTextAfter, ...restProps } = baseProps;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n\n/**\n * - EN: Base decorator node with behavior flags.\n * - CN: 带行为标记的基础装饰器节点。\n */\nexport class BaseDecoratorNode<T, P extends BaseDecoratorNodeProps> extends DecoratorNode<T> {\n __props: P | undefined;\n __base: BaseNodeHelper<P>;\n\n constructor(props?: P & { key?: string }) {\n const { key, ...restProps } = props || {};\n super(key);\n this.__props = restProps as P;\n\n this.__base = new BaseNodeHelper<P>(this.__props, {\n remove: () => super.remove(),\n replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren),\n });\n Object.keys(this.__base.hooks).forEach((key) => {\n const method = this.__base.hooks[key as keyof typeof this.__base.hooks];\n if (typeof method === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this[key as keyof this] = method.bind(this.__base) as any;\n }\n });\n }\n\n /**\n * - EN: Strip decorator-specific flags and return DOM props.\n * - CN: 去除装饰器特有的标记并返回 DOM 属性。\n *\n * @param props Decorator props including flags | 含标记的装饰器属性\n */\n getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseDecoratorNodeProps> {\n const baseProps = this.__base.getUnderlyingProps(props ?? ({} as P));\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { ...restProps } = baseProps;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,SAASA,aAAa,EAAEC,WAAW,QAAQ,SAAS;;AAEpD;AACA;AACA;AACA;;AAaA;AACA;AACA;AACA;;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAaC,cAAc;EAIzB,SAAAA,eAAYC,KAAoB,EAAEC,YAAqD,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAJ,cAAA;IAAAK,eAAA;IAAAA,eAAA;IAAAA,eAAA,gBAKjF;MACNC,MAAM,EAAE,SAAAA,OAACC,mBAA6B,EAAW;QAAA,IAAAC,aAAA;QAC/C,IAAI,EAAAA,aAAA,GAAAL,KAAI,CAACM,OAAO,cAAAD,aAAA,uBAAZA,aAAA,CAAcE,YAAY,MAAK,KAAK,EAAE;UACxC;QACF;QACAP,KAAI,CAACQ,cAAc,CAACL,MAAM,CAACC,mBAAmB,CAAC;MACjD,CAAC;MAEDK,OAAO,EAAE,SAAAA,QAAwBC,WAAc,EAAEC,eAAyB,EAAQ;QAAA,IAAAC,cAAA;QAChF,IAAI,EAAAA,cAAA,GAAAZ,KAAI,CAACM,OAAO,cAAAM,cAAA,uBAAZA,cAAA,CAAcC,aAAa,MAAK,KAAK,EAAE;UACzC,OAAOb,KAAI;QACb;QACA,OAAOA,KAAI,CAACQ,cAAc,CAACC,OAAO,CAACC,WAAW,EAAEC,eAAe,CAAC;MAClE;IACF,CAAC;IAlBC,IAAI,CAACL,OAAO,GAAGR,KAA0B;IACzC,IAA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GAAAmB,MAAA,CAAAyB,MAAA,MAAAC,yBAAA,CAAKX,SAAS,GAATA,SAAS;MAClC;MACA,OAAOlC,SAAS;IAClB;EAAC;EAAA,OAAAoC,iBAAA;AAAA,EAlCyE3D,aAAa"}
1
+ {"version":3,"names":["DecoratorNode","ElementNode","BaseNodeHelper","props","superMethods","_this","_classCallCheck","_defineProperty","remove","preserveEmptyParent","_this$__props","__props","canBeRemoved","__superMethods","replace","replaceWith","includeChildren","_this$__props2","canBeReplaced","_createClass","key","value","getUnderlyingProps","restProps","_objectWithoutProperties","_excluded","BaseElementNode","_ElementNode","_inherits","_super","_createSuper","_thisSuper","_thisSuper2","_this2","_ref","_excluded2","call","_assertThisInitialized","__base","_get","_getPrototypeOf","prototype","Object","keys","hooks","forEach","method","bind","canBeEmpty","_this$__props$canBeEm","_this$__props3","canInsertTextBefore","_this$__props$canInse","_this$__props4","canInsertTextAfter","_this$__props$canInse2","_this$__props5","getProp","propName","_this$__props6","updateProps","writable","getWritable","_objectSpread","baseProps","_excluded3","BaseDecoratorNode","_DecoratorNode","_super2","_thisSuper3","_thisSuper4","_this3","_ref2","_excluded4","_this$__props7","assign","_objectDestructuringEmpty"],"sources":["../../../../src/components/Lexical/nodes/base.ts"],"sourcesContent":["import type { LexicalNode } from 'lexical';\nimport { DecoratorNode, ElementNode } from 'lexical';\n\n/**\n * - EN: Common behavior flags for custom nodes.\n * - CN: 自定义节点的通用行为标记。\n */\nexport interface BaseNodeProps {\n /**\n * - EN: Whether the node can be removed. Default `true`.\n * - CN: 是否可被删除,默认 `true`。\n */\n canBeRemoved?: boolean;\n /**\n * - EN: Whether the node can be replaced. Default `true`.\n * - CN: 是否可被替换,默认 `true`。\n */\n canBeReplaced?: boolean;\n}\n/**\n * - EN: Extra behavior flags for element nodes.\n * - CN: 元素节点的附加行为标记。\n */\nexport interface BaseElementProps extends BaseNodeProps {\n /**\n * - EN: Whether an element is allowed to be empty. Default `false`.\n * - CN: 是否允许节点为空,默认 `false`。\n */\n canBeEmpty?: boolean;\n /**\n * - EN: Allow inserting text at the start of the element. Default `true`.\n * - CN: 是否允许在节点内的起始位置插入文本,默认 `true`。\n */\n canInsertTextBefore?: boolean;\n /**\n * - EN: Allow inserting text at the end of the element. Default `true`.\n * - CN: 是否允许在节点内的结束位置插入文本,默认 `true`。\n */\n canInsertTextAfter?: boolean;\n}\n\nexport type BaseDecoratorNodeProps = BaseNodeProps;\n\n/**\n * - EN: A helper wrapping base behaviors (remove/replace) with guard flags.\n * - CN: 封装基础行为(删除/替换)并根据标记进行限制的帮助器。\n *\n * @param props Node behavior flags | 节点行为标记\n * @param superMethods Methods delegated to the underlying node | 委托给底层节点的方法\n */\nexport class BaseNodeHelper<P extends BaseNodeProps> {\n __props: (P & BaseNodeProps) | undefined;\n __superMethods: Pick<LexicalNode, 'replace' | 'remove'>;\n\n constructor(props: P | undefined, superMethods: Pick<LexicalNode, 'replace' | 'remove'>) {\n this.__props = props as P & BaseNodeProps;\n this.__superMethods = superMethods;\n }\n\n hooks = {\n remove: (preserveEmptyParent?: boolean): void => {\n if (this.__props?.canBeRemoved === false) {\n return;\n }\n this.__superMethods.remove(preserveEmptyParent);\n },\n\n replace: <N extends LexicalNode>(replaceWith: N, includeChildren?: boolean): N => {\n if (this.__props?.canBeReplaced === false) {\n return this as unknown as N;\n }\n return this.__superMethods.replace(replaceWith, includeChildren);\n },\n };\n /**\n * - EN: Strip helper-only flags from props for DOM usage.\n * - CN: 去除仅用于帮助器的标记属性,得到用于 DOM 的纯属性。\n *\n * @param props Props including helper flags | 含帮助标记的属性\n */\n getUnderlyingProps(props: P & BaseNodeProps): Omit<P, keyof BaseNodeProps> {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { canBeRemoved, canBeReplaced, ...restProps } = props;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n\n/**\n * - EN: Base element node with behavior flags.\n * - CN: 带行为标记的基础元素节点。\n */\nexport class BaseElementNode<P extends BaseElementProps> extends ElementNode {\n __props: P | undefined;\n __base: BaseNodeHelper<P>;\n\n constructor(props?: P & { key?: string }) {\n const { key, ...restProps } = props || {};\n super(key);\n this.__props = restProps as P;\n this.__base = new BaseNodeHelper<P>(this.__props, {\n remove: () => super.remove(),\n replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren),\n });\n Object.keys(this.__base.hooks).forEach((key) => {\n const method = this.__base.hooks[key as keyof typeof this.__base.hooks];\n if (typeof method === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this[key as keyof this] = method.bind(this.__base) as any;\n }\n });\n }\n\n canBeEmpty(): boolean {\n return this.__props?.canBeEmpty ?? false;\n }\n\n canInsertTextBefore(): boolean {\n return this.__props?.canInsertTextBefore ?? true;\n }\n\n canInsertTextAfter(): boolean {\n return this.__props?.canInsertTextAfter ?? true;\n }\n\n getProp(propName: keyof P): P[typeof propName] {\n return this.__props?.[propName] as P[typeof propName];\n }\n\n updateProps(props: Partial<P>): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props!,\n ...props,\n };\n }\n\n /**\n * - EN: Strip element-specific flags and return DOM props.\n * - CN: 去除元素特有的标记并返回 DOM 属性。\n *\n * @param props Element props including flags | 含标记的元素属性\n */\n getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseElementProps> {\n const baseProps = this.__base.getUnderlyingProps(props ?? ({} as P));\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { canBeEmpty, canInsertTextBefore, canInsertTextAfter, ...restProps } = baseProps;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n\n/**\n * - EN: Base decorator node with behavior flags.\n * - CN: 带行为标记的基础装饰器节点。\n */\nexport class BaseDecoratorNode<T, P extends BaseDecoratorNodeProps> extends DecoratorNode<T> {\n __props: P | undefined;\n __base: BaseNodeHelper<P>;\n\n constructor(props?: P & { key?: string }) {\n const { key, ...restProps } = props || {};\n super(key);\n this.__props = restProps as P;\n\n this.__base = new BaseNodeHelper<P>(this.__props, {\n remove: () => super.remove(),\n replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren),\n });\n Object.keys(this.__base.hooks).forEach((key) => {\n const method = this.__base.hooks[key as keyof typeof this.__base.hooks];\n if (typeof method === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this[key as keyof this] = method.bind(this.__base) as any;\n }\n });\n }\n getProp(propName: keyof P): P[typeof propName] {\n return this.__props?.[propName] as P[typeof propName];\n }\n\n updateProps(props: Partial<P>): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props!,\n ...props,\n };\n }\n\n /**\n * - EN: Strip decorator-specific flags and return DOM props.\n * - CN: 去除装饰器特有的标记并返回 DOM 属性。\n *\n * @param props Decorator props including flags | 含标记的装饰器属性\n */\n getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseDecoratorNodeProps> {\n const baseProps = this.__base.getUnderlyingProps(props ?? ({} as P));\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { ...restProps } = baseProps;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAASA,aAAa,EAAEC,WAAW,QAAQ,SAAS;;AAEpD;AACA;AACA;AACA;;AAaA;AACA;AACA;AACA;;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAaC,cAAc;EAIzB,SAAAA,eAAYC,KAAoB,EAAEC,YAAqD,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAJ,cAAA;IAAAK,eAAA;IAAAA,eAAA;IAAAA,eAAA,gBAKjF;MACNC,MAAM,EAAE,SAAAA,OAACC,mBAA6B,EAAW;QAAA,IAAAC,aAAA;QAC/C,IAAI,EAAAA,aAAA,GAAAL,KAAI,CAACM,OAAO,cAAAD,aAAA,uBAAZA,aAAA,CAAcE,YAAY,MAAK,KAAK,EAAE;UACxC;QACF;QACAP,KAAI,CAACQ,cAAc,CAACL,MAAM,C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SAAS,GAAAmB,MAAA,CAAAiC,MAAA,MAAAC,yBAAA,CAAKZ,SAAS,GAATA,SAAS;MAClC;MACA,OAAOzC,SAAS;IAClB;EAAC;EAAA,OAAA2C,iBAAA;AAAA,EA7CyElE,aAAa"}
@@ -71,3 +71,4 @@ export declare function updateDomStyle(dom: HTMLElement | undefined, style: CSSP
71
71
  * @returns Element attributes | 元素属性
72
72
  */
73
73
  export declare function getDomAttributes(dom: HTMLElement | undefined): HtmlHTMLAttributes<HTMLElement> | undefined;
74
+ export declare function shallowEqual(obj1: any, obj2: any): boolean;
@@ -25,6 +25,7 @@ __export(helpers_exports, {
25
25
  getDomAttributes: () => getDomAttributes,
26
26
  insertNodeAtCursor: () => insertNodeAtCursor,
27
27
  insertTextAtCursor: () => insertTextAtCursor,
28
+ shallowEqual: () => shallowEqual,
28
29
  updateDomProps: () => updateDomProps,
29
30
  updateDomStyle: () => updateDomStyle
30
31
  });
@@ -168,6 +169,8 @@ function updateDomProps(dom, props) {
168
169
  });
169
170
  } else if (key === "className" && value) {
170
171
  dom.className = value;
172
+ } else if (key.startsWith("on") && typeof value === "function") {
173
+ dom[key.toLowerCase()] = value;
171
174
  } else if (value !== void 0 && value !== null) {
172
175
  dom.setAttribute(key, value.toString());
173
176
  }
@@ -208,6 +211,25 @@ function getDomAttributes(dom) {
208
211
  }
209
212
  return attributes;
210
213
  }
214
+ function shallowEqual(obj1, obj2) {
215
+ if (obj1 === obj2)
216
+ return true;
217
+ if (!obj1 || !obj2)
218
+ return false;
219
+ const keys1 = Object.keys(obj1);
220
+ const keys2 = Object.keys(obj2);
221
+ if (keys1.length !== keys2.length)
222
+ return false;
223
+ for (const key of keys1) {
224
+ if (key === "style") {
225
+ if (!shallowEqual(obj1[key], obj2[key]))
226
+ return false;
227
+ } else if (obj1[key] !== obj2[key]) {
228
+ return false;
229
+ }
230
+ }
231
+ return true;
232
+ }
211
233
  // Annotate the CommonJS export names for ESM import in node:
212
234
  0 && (module.exports = {
213
235
  clearEditorContent,
@@ -216,6 +238,7 @@ function getDomAttributes(dom) {
216
238
  getDomAttributes,
217
239
  insertNodeAtCursor,
218
240
  insertTextAtCursor,
241
+ shallowEqual,
219
242
  updateDomProps,
220
243
  updateDomStyle
221
244
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/Lexical/helpers/index.ts"],
4
- "sourcesContent": ["import type { CSSProperties, HtmlHTMLAttributes } from 'react';\nimport type { LexicalEditor, LexicalNode } from 'lexical';\nimport {\n $createTextNode,\n $getRoot,\n $getSelection,\n $isDecoratorNode,\n $isElementNode,\n $isParagraphNode,\n $isRangeSelection,\n $isTextNode,\n} from 'lexical';\nimport { $createDivNode, $isDivNode } from '../nodes/DivNode';\n\n/**\n * - EN: Insert a node at the current cursor position.\n * - CN: 将节点插入到当前光标位置。\n *\n * @param editor LexicalEditor instance | LexicalEditor 实例\n * @param node Node to insert | 要插入的节点\n */\nexport function insertNodeAtCursor(editor: LexicalEditor, node: LexicalNode): void {\n editor.update(() => {\n const selection = $getSelection();\n if (selection) {\n if ($isRangeSelection(selection)) {\n // 如果没有选取,则直接在根节点末尾插入\n const lastNode = selection.focus.getNode();\n if (lastNode) {\n if ($isParagraphNode(lastNode)) {\n lastNode.append(node);\n } else if ($isTextNode(lastNode)) {\n // 如果最后一个节点是文本节点,则在其后插入 SelectNode\n lastNode.insertAfter(node);\n } else if ($isDivNode(lastNode)) {\n lastNode.append(node);\n } else {\n selection.insertNodes([node]);\n }\n node.selectNext();\n }\n } else {\n selection.insertNodes([node]);\n node.selectNext();\n }\n } else {\n const root = $getRoot();\n let nodeToInsert: LexicalNode = node;\n if ($isElementNode(node) || $isDecoratorNode(node)) {\n nodeToInsert = node;\n } else {\n const container = $createDivNode({\n style: { display: 'inline-block' },\n });\n container.append(node);\n nodeToInsert = container;\n }\n root.append(nodeToInsert);\n node.selectNext();\n }\n });\n}\n\n/**\n * - EN: Insert text at the current cursor position.\n * - CN: 将文本插入到当前光标位置。\n *\n * @param editor LexicalEditor instance | LexicalEditor 实例\n * @param text Text to insert | 要插入的文本\n */\nexport function insertTextAtCursor(editor: LexicalEditor, text: string): void {\n editor?.update(() => {\n const textNode = $createTextNode(text);\n const root = $getRoot();\n const selection = $getSelection();\n if (selection) {\n // 插入光标位置\n selection.insertText(text);\n } else {\n // 如果没有选取,则直接在根节点末尾插入\n const lastNode = root.getLastChild();\n if (lastNode && $isParagraphNode(lastNode)) {\n lastNode.append(textNode);\n } else {\n const container = $createDivNode({\n style: { display: 'inline-block' },\n });\n container.append(textNode);\n root.append(container);\n }\n }\n });\n}\n\n/**\n * - EN: Clear the editor content.\n * - CN: 清空编辑器内容。\n *\n * @param editor LexicalEditor instance | LexicalEditor 实例\n */\nexport function clearEditorContent(editor: LexicalEditor) {\n const state = editor.getEditorState();\n const stateJson = state.toJSON();\n // 默认创建一个ParagraphNode\n const newJson = {\n ...stateJson,\n root: {\n ...stateJson.root,\n children: [\n {\n children: [],\n direction: null,\n format: '',\n indent: 0,\n type: 'paragraph',\n version: 1,\n textFormat: 0,\n textStyle: '',\n },\n ],\n },\n };\n const emptyState = editor.parseEditorState(JSON.stringify(newJson));\n editor.setEditorState(emptyState);\n editor.update(() => {\n const root = $getRoot();\n root.clear();\n });\n}\n\n/**\n * - EN: Find the first node that matches the predicate.\n * - CN: 查找第一个符合条件的节点。\n *\n * @param editor LexicalEditor instance | LexicalEditor 实例\n * @param predicate Function to test whether a node matches | 用于匹配节点的函数\n *\n * @returns The matched node, or undefined | 符合条件的第一个节点,或 undefined\n */\nexport function findNode<T extends LexicalNode>(\n editor: LexicalEditor,\n predicate: (node: LexicalNode) => boolean\n): T | undefined {\n const matched = findNodes<T>(editor, predicate, { stopOnFirstMatch: true });\n return matched[0];\n}\n/**\n * - EN: Find all nodes that match the predicate.\n * - CN: 查找所有符合条件的节点数组。\n *\n * @param editor LexicalEditor instance | LexicalEditor 实例\n * @param predicate Function to test whether a node matches | 用于匹配节点的函数\n * @param options Options | 选项\n *\n * @returns An array of matched nodes | 符合条件的节点数组\n */\nexport function findNodes<T extends LexicalNode>(\n editor: LexicalEditor,\n predicate: (node: LexicalNode) => boolean,\n options?: {\n stopOnFirstMatch?: boolean;\n }\n): T[] {\n const matched: T[] = [];\n editor.getEditorState().read(() => {\n const root = $getRoot();\n const traverse = (node: LexicalNode, result: T[]) => {\n if (predicate(node)) {\n result.push(node as unknown as T);\n if (options?.stopOnFirstMatch) {\n return;\n }\n }\n if ($isElementNode(node)) {\n const children = node.getChildren();\n for (const child of children) {\n traverse(child, result);\n if (options?.stopOnFirstMatch && result.length > 0) {\n return;\n }\n }\n }\n };\n traverse(root, matched);\n });\n return matched;\n}\n\n/**\n * - EN: Update properties on a DOM element.\n * - CN: 更新 DOM 元素的属性。\n *\n * @param dom Target DOM element to update | 要更新的 DOM 元素\n * @param props Props to set on the element | 要设置的属性\n */\nexport function updateDomProps(dom: HTMLElement | undefined, props: HtmlHTMLAttributes<HTMLElement>): void {\n if (!dom) return;\n Array.from(dom.attributes).forEach((attr) => {\n if (!attr.name.startsWith('data-lexical')) {\n dom.removeAttribute(attr.name);\n }\n });\n\n dom.removeAttribute('style');\n dom.removeAttribute('class');\n\n if (props) {\n Object.entries(props).forEach(([key, value]) => {\n if (key === 'style' && value) {\n Object.entries(value as CSSProperties).forEach(([styleKey, styleValue]) => {\n if (styleValue !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (dom.style as any)[styleKey] = styleValue;\n }\n });\n } else if (key === 'className' && value) {\n dom.className = value as string;\n } else if (value !== undefined && value !== null) {\n dom.setAttribute(key, value.toString());\n }\n });\n }\n}\n\n/**\n * - EN: Update style on a DOM element.\n * - CN: 更新 DOM 元素的样式。\n *\n * @param dom Target DOM element to update | 要更新的 DOM 元素\n * @param style Style to set | 要设置的样式\n */\nexport function updateDomStyle(dom: HTMLElement | undefined, style: CSSProperties | undefined): void {\n if (!dom) return;\n dom.removeAttribute('style');\n if (style) {\n Object.entries(style).forEach(([styleKey, styleValue]) => {\n if (styleValue !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (dom.style as any)[styleKey] = styleValue;\n }\n });\n }\n}\n\n/**\n * - EN: Get attributes from a DOM element.\n * - CN: 从 DOM 元素获取属性。\n *\n * @param dom Target DOM element | 目标 DOM 元素\n *\n * @returns Element attributes | 元素属性\n */\nexport function getDomAttributes(dom: HTMLElement | undefined): HtmlHTMLAttributes<HTMLElement> | undefined {\n if (!dom) return undefined;\n\n const attributes: HtmlHTMLAttributes<HTMLElement> = {};\n Array.from(dom.attributes).forEach((attr) => {\n if (attr.name === 'class' || attr.name === 'style') {\n return;\n }\n attributes[attr.name as keyof HtmlHTMLAttributes<HTMLElement>] = attr.value;\n });\n\n if (dom.className) {\n attributes.className = dom.className;\n }\n\n if (dom.style) {\n const styles: CSSProperties = {};\n Array.from(dom.style).forEach((styleName) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (styles as any)[styleName] = (dom.style as any)[styleName];\n });\n attributes.style = styles;\n }\n\n return attributes;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,qBASO;AACP,qBAA2C;AASpC,SAAS,mBAAmB,QAAuB,MAAyB;AACjF,SAAO,OAAO,MAAM;AAClB,UAAM,gBAAY,8BAAc;AAChC,QAAI,WAAW;AACb,cAAI,kCAAkB,SAAS,GAAG;AAEhC,cAAM,WAAW,UAAU,MAAM,QAAQ;AACzC,YAAI,UAAU;AACZ,kBAAI,iCAAiB,QAAQ,GAAG;AAC9B,qBAAS,OAAO,IAAI;AAAA,UACtB,eAAW,4BAAY,QAAQ,GAAG;AAEhC,qBAAS,YAAY,IAAI;AAAA,UAC3B,eAAW,2BAAW,QAAQ,GAAG;AAC/B,qBAAS,OAAO,IAAI;AAAA,UACtB,OAAO;AACL,sBAAU,YAAY,CAAC,IAAI,CAAC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;AAAA,EACrB;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import type { CSSProperties, HtmlHTMLAttributes } from 'react';\nimport type { LexicalEditor, LexicalNode } from 'lexical';\nimport {\n $createTextNode,\n $getRoot,\n $getSelection,\n $isDecoratorNode,\n $isElementNode,\n $isParagraphNode,\n $isRangeSelection,\n $isTextNode,\n} from 'lexical';\nimport { $createDivNode, $isDivNode } from '../nodes/DivNode';\n\n/**\n * - EN: Insert a node at the current cursor position.\n * - CN: 将节点插入到当前光标位置。\n *\n * @param editor LexicalEditor instance | LexicalEditor 实例\n * @param node Node to insert | 要插入的节点\n */\nexport function insertNodeAtCursor(editor: LexicalEditor, node: LexicalNode): void {\n editor.update(() => {\n const selection = $getSelection();\n if (selection) {\n if ($isRangeSelection(selection)) {\n // 如果没有选取,则直接在根节点末尾插入\n const lastNode = selection.focus.getNode();\n if (lastNode) {\n if ($isParagraphNode(lastNode)) {\n lastNode.append(node);\n } else if ($isTextNode(lastNode)) {\n // 如果最后一个节点是文本节点,则在其后插入 SelectNode\n lastNode.insertAfter(node);\n } else if ($isDivNode(lastNode)) {\n lastNode.append(node);\n } else {\n selection.insertNodes([node]);\n }\n node.selectNext();\n }\n } else {\n selection.insertNodes([node]);\n node.selectNext();\n }\n } else {\n const root = $getRoot();\n let nodeToInsert: LexicalNode = node;\n if ($isElementNode(node) || $isDecoratorNode(node)) {\n nodeToInsert = node;\n } else {\n const container = $createDivNode({\n style: { display: 'inline-block' },\n });\n container.append(node);\n nodeToInsert = container;\n }\n root.append(nodeToInsert);\n node.selectNext();\n }\n });\n}\n\n/**\n * - EN: Insert text at the current cursor position.\n * - CN: 将文本插入到当前光标位置。\n *\n * @param editor LexicalEditor instance | LexicalEditor 实例\n * @param text Text to insert | 要插入的文本\n */\nexport function insertTextAtCursor(editor: LexicalEditor, text: string): void {\n editor?.update(() => {\n const textNode = $createTextNode(text);\n const root = $getRoot();\n const selection = $getSelection();\n if (selection) {\n // 插入光标位置\n selection.insertText(text);\n } else {\n // 如果没有选取,则直接在根节点末尾插入\n const lastNode = root.getLastChild();\n if (lastNode && $isParagraphNode(lastNode)) {\n lastNode.append(textNode);\n } else {\n const container = $createDivNode({\n style: { display: 'inline-block' },\n });\n container.append(textNode);\n root.append(container);\n }\n }\n });\n}\n\n/**\n * - EN: Clear the editor content.\n * - CN: 清空编辑器内容。\n *\n * @param editor LexicalEditor instance | LexicalEditor 实例\n */\nexport function clearEditorContent(editor: LexicalEditor) {\n const state = editor.getEditorState();\n const stateJson = state.toJSON();\n // 默认创建一个ParagraphNode\n const newJson = {\n ...stateJson,\n root: {\n ...stateJson.root,\n children: [\n {\n children: [],\n direction: null,\n format: '',\n indent: 0,\n type: 'paragraph',\n version: 1,\n textFormat: 0,\n textStyle: '',\n },\n ],\n },\n };\n const emptyState = editor.parseEditorState(JSON.stringify(newJson));\n editor.setEditorState(emptyState);\n editor.update(() => {\n const root = $getRoot();\n root.clear();\n });\n}\n\n/**\n * - EN: Find the first node that matches the predicate.\n * - CN: 查找第一个符合条件的节点。\n *\n * @param editor LexicalEditor instance | LexicalEditor 实例\n * @param predicate Function to test whether a node matches | 用于匹配节点的函数\n *\n * @returns The matched node, or undefined | 符合条件的第一个节点,或 undefined\n */\nexport function findNode<T extends LexicalNode>(\n editor: LexicalEditor,\n predicate: (node: LexicalNode) => boolean\n): T | undefined {\n const matched = findNodes<T>(editor, predicate, { stopOnFirstMatch: true });\n return matched[0];\n}\n/**\n * - EN: Find all nodes that match the predicate.\n * - CN: 查找所有符合条件的节点数组。\n *\n * @param editor LexicalEditor instance | LexicalEditor 实例\n * @param predicate Function to test whether a node matches | 用于匹配节点的函数\n * @param options Options | 选项\n *\n * @returns An array of matched nodes | 符合条件的节点数组\n */\nexport function findNodes<T extends LexicalNode>(\n editor: LexicalEditor,\n predicate: (node: LexicalNode) => boolean,\n options?: {\n stopOnFirstMatch?: boolean;\n }\n): T[] {\n const matched: T[] = [];\n editor.getEditorState().read(() => {\n const root = $getRoot();\n const traverse = (node: LexicalNode, result: T[]) => {\n if (predicate(node)) {\n result.push(node as unknown as T);\n if (options?.stopOnFirstMatch) {\n return;\n }\n }\n if ($isElementNode(node)) {\n const children = node.getChildren();\n for (const child of children) {\n traverse(child, result);\n if (options?.stopOnFirstMatch && result.length > 0) {\n return;\n }\n }\n }\n };\n traverse(root, matched);\n });\n return matched;\n}\n\n/**\n * - EN: Update properties on a DOM element.\n * - CN: 更新 DOM 元素的属性。\n *\n * @param dom Target DOM element to update | 要更新的 DOM 元素\n * @param props Props to set on the element | 要设置的属性\n */\nexport function updateDomProps(dom: HTMLElement | undefined, props: HtmlHTMLAttributes<HTMLElement>): void {\n if (!dom) return;\n Array.from(dom.attributes).forEach((attr) => {\n if (!attr.name.startsWith('data-lexical')) {\n dom.removeAttribute(attr.name);\n }\n });\n\n dom.removeAttribute('style');\n dom.removeAttribute('class');\n\n if (props) {\n Object.entries(props).forEach(([key, value]) => {\n if (key === 'style' && value) {\n Object.entries(value as CSSProperties).forEach(([styleKey, styleValue]) => {\n if (styleValue !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (dom.style as any)[styleKey] = styleValue;\n }\n });\n } else if (key === 'className' && value) {\n dom.className = value as string;\n } else if (key.startsWith('on') && typeof value === 'function') {\n dom[key.toLowerCase() as 'onclick'] = value as (event: MouseEvent) => void;\n } else if (value !== undefined && value !== null) {\n dom.setAttribute(key, value.toString());\n }\n });\n }\n}\n\n/**\n * - EN: Update style on a DOM element.\n * - CN: 更新 DOM 元素的样式。\n *\n * @param dom Target DOM element to update | 要更新的 DOM 元素\n * @param style Style to set | 要设置的样式\n */\nexport function updateDomStyle(dom: HTMLElement | undefined, style: CSSProperties | undefined): void {\n if (!dom) return;\n dom.removeAttribute('style');\n if (style) {\n Object.entries(style).forEach(([styleKey, styleValue]) => {\n if (styleValue !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (dom.style as any)[styleKey] = styleValue;\n }\n });\n }\n}\n\n/**\n * - EN: Get attributes from a DOM element.\n * - CN: 从 DOM 元素获取属性。\n *\n * @param dom Target DOM element | 目标 DOM 元素\n *\n * @returns Element attributes | 元素属性\n */\nexport function getDomAttributes(dom: HTMLElement | undefined): HtmlHTMLAttributes<HTMLElement> | undefined {\n if (!dom) return undefined;\n\n const attributes: HtmlHTMLAttributes<HTMLElement> = {};\n Array.from(dom.attributes).forEach((attr) => {\n if (attr.name === 'class' || attr.name === 'style') {\n return;\n }\n attributes[attr.name as keyof HtmlHTMLAttributes<HTMLElement>] = attr.value;\n });\n\n if (dom.className) {\n attributes.className = dom.className;\n }\n\n if (dom.style) {\n const styles: CSSProperties = {};\n Array.from(dom.style).forEach((styleName) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (styles as any)[styleName] = (dom.style as any)[styleName];\n });\n attributes.style = styles;\n }\n\n return attributes;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function shallowEqual(obj1: any, obj2: any): boolean {\n if (obj1 === obj2) return true;\n if (!obj1 || !obj2) return false;\n\n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n\n if (keys1.length !== keys2.length) return false;\n\n for (const key of keys1) {\n if (key === 'style') {\n // - EN: Special handling for style objects.\n // - CN: 特殊处理 style 对象。\n if (!shallowEqual(obj1[key], obj2[key])) return false;\n } else if (obj1[key] !== obj2[key]) {\n return false;\n }\n }\n\n return true;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,qBASO;AACP,qBAA2C;AASpC,SAAS,mBAAmB,QAAuB,MAAyB;AACjF,SAAO,OAAO,MAAM;AAClB,UAAM,gBAAY,8BAAc;AAChC,QAAI,WAAW;AACb,cAAI,kCAAkB,SAAS,GAAG;AAEhC,cAAM,WAAW,UAAU,MAAM,QAAQ;AACzC,YAAI,UAAU;AACZ,kBAAI,iCAAiB,QA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ClD;AAAA,IACF;AACA,eAAW,KAAK,IAA6C,IAAI,KAAK;AAAA,EACxE,CAAC;AAED,MAAI,IAAI,WAAW;AACjB,eAAW,YAAY,IAAI;AAAA,EAC7B;AAEA,MAAI,IAAI,OAAO;AACb,UAAM,SAAwB,CAAC;AAC/B,UAAM,KAAK,IAAI,KAAK,EAAE,QAAQ,CAAC,cAAc;AAE3C,MAAC,OAAe,SAAS,IAAK,IAAI,MAAc,SAAS;AAAA,IAC3D,CAAC;AACD,eAAW,QAAQ;AAAA,EACrB;AAEA,SAAO;AACT;AAGO,SAAS,aAAa,MAAW,MAAoB;AAC1D,MAAI,SAAS;AAAM,WAAO;AAC1B,MAAI,CAAC,QAAQ,CAAC;AAAM,WAAO;AAE3B,QAAM,QAAQ,OAAO,KAAK,IAAI;AAC9B,QAAM,QAAQ,OAAO,KAAK,IAAI;AAE9B,MAAI,MAAM,WAAW,MAAM;AAAQ,WAAO;AAE1C,aAAW,OAAO,OAAO;AACvB,QAAI,QAAQ,SAAS;AAGnB,UAAI,CAAC,aAAa,KAAK,GAAG,GAAG,KAAK,GAAG,CAAC;AAAG,eAAO;AAAA,IAClD,WAAW,KAAK,GAAG,MAAM,KAAK,GAAG,GAAG;AAClC,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -47,8 +47,6 @@ export declare class CloseIconNode extends BaseDecoratorNode<ReactNode, CloseIco
47
47
  updateDOM(): boolean;
48
48
  decorate(): ReactNode;
49
49
  isInline(): boolean;
50
- getPropValue(propName: keyof CloseIconNodeProps): CloseIconNodeProps[typeof propName];
51
- setProps(props: Partial<CloseIconNodeProps>): void;
52
50
  getUnderlyingProps(props: CloseIconNodeProps | undefined): Omit<CloseIconNodeProps, keyof BaseNodeProps>;
53
51
  }
54
52
  /**
@@ -112,17 +112,6 @@ var CloseIconNode = class extends import_base.BaseDecoratorNode {
112
112
  isInline() {
113
113
  return false;
114
114
  }
115
- getPropValue(propName) {
116
- var _a;
117
- return (_a = this.__props) == null ? void 0 : _a[propName];
118
- }
119
- setProps(props) {
120
- const writable = this.getWritable();
121
- writable.__props = {
122
- ...writable.__props,
123
- ...props
124
- };
125
- }
126
115
  getUnderlyingProps(props) {
127
116
  const excludeProps = super.getUnderlyingProps(props);
128
117
  const { icon, iconClassName, iconStyle, onClick, ...rest } = excludeProps || {};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/Lexical/nodes/CloseIcon.tsx"],
4
- "sourcesContent": ["import { type CSSProperties, type HtmlHTMLAttributes, type ReactNode } from 'react';\nimport { theme } from 'antd';\nimport classNames from 'classnames';\nimport type { LexicalNode, SerializedLexicalNode, Spread } from 'lexical';\nimport { CloseCircleOutlined } from '@ant-design/icons';\nimport { randomChars } from '../../../utils';\nimport { updateDomProps } from '../helpers';\nimport type { BaseDecoratorNodeProps, BaseNodeProps } from './base';\nimport { BaseDecoratorNode } from './base';\n\nconst CLOSE_ICON_CLASSNAME = 'lexical-close-icon';\n\nexport interface CloseIconNodeProps extends HtmlHTMLAttributes<HTMLSpanElement>, BaseDecoratorNodeProps {\n /**\n * - EN: Parent element class name, used to add positioning styles to the parent element.\n * - CN: 父元素的类名,用于给父元素添加定位样式\n */\n parentClassName: string;\n /**\n * - EN: The custom icon to display, optional\n * - CN: 要显示的自定义图标,可选\n */\n icon?: ReactNode;\n /**\n * - EN: The default class name for the close icon element. This property is invalid if `icon` is\n * set.\n * - CN: 默认关闭图标元素的类名,如果设置了 `icon` 则该属性无效\n */\n iconClassName?: string;\n /**\n * - EN: The custom style for the close icon element. This property is invalid if `icon` is set.\n * - CN: 自定义关闭图标元素的样式,如果设置了 `icon` 则该属性无效\n */\n iconStyle?: CSSProperties;\n /**\n * - EN: The click event handler for the close icon element.\n * - CN: 关闭图标元素的点击事件\n */\n onClick?: (e: React.MouseEvent<HTMLSpanElement>) => void;\n}\n\n/**\n * - EN: A node that represents a close icon.\n * - CN: 一个关闭图标的节点。\n */\nexport class CloseIconNode extends BaseDecoratorNode<ReactNode, CloseIconNodeProps> {\n __hashId: string;\n\n constructor(props: CloseIconNodeProps & { key?: string }) {\n super(props);\n this.__hashId = `hash-${randomChars(6)}`;\n }\n\n static getType(): string {\n return 'CloseIcon';\n }\n\n static clone(node: CloseIconNode): CloseIconNode {\n return new CloseIconNode({ ...node.__props!, key: node.getKey() });\n }\n\n static importJSON(serializedNode: SerializedCloseIconNode): CloseIconNode {\n return $createCloseIconNode(serializedNode.props);\n }\n\n exportJSON(): SerializedCloseIconNode {\n return {\n ...super.exportJSON(),\n props: this.__props!,\n type: this.getType(),\n version: 1,\n };\n }\n\n createDOM(): HTMLElement {\n const span = document.createElement('span');\n const underlyingProps = this.getUnderlyingProps(this.__props);\n const className = classNames(CLOSE_ICON_CLASSNAME, this.__hashId, underlyingProps?.className);\n updateDomProps(span, { ...underlyingProps, className });\n const stylesheet = document.createElement('style');\n const token = theme.getDesignToken();\n const parentCls = this.__props?.parentClassName ? `.${this.__props.parentClassName}` : '';\n stylesheet.innerHTML = `\n ${\n parentCls\n ? `\n ${parentCls} { \n position: relative;\n }\n `\n : ''\n }\n ${parentCls} .${CLOSE_ICON_CLASSNAME}.${this.__hashId} {\n position: absolute;\n top: 0;\n right: 0;\n transform: translate(50%, -50%);\n color: ${token.colorTextDisabled};\n font-size: ${token.fontSizeSM}px;\n line-height: 0;\n z-index: 1;\n opacity: 0;\n cursor: pointer;\n pointer-events: none;\n transition: opacity 0.2s ease;\n }\n ${parentCls}:hover .${CLOSE_ICON_CLASSNAME}.${this.__hashId} {\n opacity: 1;\n pointer-events: auto;\n }\n ${parentCls}:hover .${CLOSE_ICON_CLASSNAME}.${this.__hashId}:hover {\n color: ${token.colorTextSecondary};\n }\n `;\n span.append(stylesheet);\n return span;\n }\n\n updateDOM() {\n return false;\n }\n\n decorate(): ReactNode {\n return <CloseIconComponent node={this} />;\n }\n\n isInline(): boolean {\n return false;\n }\n\n getPropValue(propName: keyof CloseIconNodeProps): CloseIconNodeProps[typeof propName] {\n return this.__props?.[propName];\n }\n\n setProps(props: Partial<CloseIconNodeProps>): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props!,\n ...props,\n };\n }\n\n getUnderlyingProps(props: CloseIconNodeProps | undefined): Omit<CloseIconNodeProps, keyof BaseNodeProps> {\n const excludeProps = super.getUnderlyingProps(props);\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { icon, iconClassName, iconStyle, onClick, ...rest } = excludeProps || {};\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return rest;\n }\n}\n\n/**\n * - EN: React decorator component rendered for CloseIconNode.\n * - CN: CloseIconNode 对应的 React 装饰组件。\n *\n * @param node The bound CloseIconNode instance | 关联的 CloseIconNode 实例\n */\nfunction CloseIconComponent({ node }: CloseIconComponentProps): ReactNode {\n const { icon, iconClassName, iconStyle, onClick } = node.__props || {};\n\n const closeIcon = icon ?? (\n <CloseCircleOutlined className={classNames(node.__hashId, iconClassName)} style={iconStyle} onClick={onClick} />\n );\n return closeIcon;\n}\n\n/**\n * - EN: Factory to create a CloseIconNode.\n * - CN: 创建 CloseIconNode 的工厂函数。\n *\n * @param props Props for the CloseIcon node | CloseIcon 节点的属性\n */\nexport function $createCloseIconNode(props: CloseIconNodeProps): CloseIconNode {\n return new CloseIconNode(props);\n}\n\n/**\n * - EN: Type guard to check whether a node is CloseIconNode.\n * - CN: 判断节点是否为 CloseIconNode 的类型守卫。\n *\n * @param node Node to test | 要检测的节点\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function $isCloseIconNode(node: LexicalNode | null | undefined): node is CloseIconNode {\n return node instanceof CloseIconNode;\n}\n\ninterface CloseIconComponentProps {\n node: CloseIconNode;\n}\ntype SerializedCloseIconNode = Spread<\n {\n props: CloseIconNodeProps;\n },\n SerializedLexicalNode\n>;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AAAA;AAAA,QAQnB,oBAAoB,wBAAwB,KAAK;AAAA;AAAA;AAAA;AAAA,QAIjD,oBAAoB,wBAAwB,KAAK;AAAA,iBACxC,MAAM;AAAA;AAAA;AAGnB,SAAK,OAAO,UAAU;AACtB,WAAO;AAAA,EACT;AAAA,EAEA,YAAY;AACV,WAAO;AAAA,EACT;AAAA,EAEA,WAAsB;AACpB,WAAO,oCAAC,sBAAmB,MAAM,MAAM;AAAA,EACzC;AAAA,EAEA,WAAoB;AAClB,WAAO;AAAA,EACT;AAAA,EAEA,aAAa,UAAyE;AAlIxF;AAmII,YAAO,UAAK,YAAL,mBAAe;AAAA,EACxB;AAAA,EAEA,SAAS,OAA0C;AACjD,UAAM,WAAW,KAAK,YAAY;AAClC,aAAS,UAAU;AAAA,MACjB,GAAG,SAAS;AAAA,MACZ,GAAG;AAAA,IACL;AAAA,EACF;AAAA,EAEA,mBAAmB,OAAsF;AACvG,UAAM,eAAe,MAAM,mBAAmB,KAAK;AAEnD,UAAM,EAAE,MAAM,eAAe,WAAW,SAAS,GAAG,KAAK,IAAI,gBAAgB,CAAC;AAE9E,WAAO;AAAA,EACT;AACF;AAQA,SAAS,mBAAmB,EAAE,KAAK,GAAuC;AACxE,QAAM,EAAE,MAAM,eAAe,WAAW,QAAQ,IAAI,KAAK,WAAW,CAAC;AAErE,QAAM,YAAY,QAChB,oCAAC,oCAAoB,eAAW,kBAAAA,SAAW,KAAK,UAAU,aAAa,GAAG,OAAO,WAAW,SAAkB;AAEhH,SAAO;AACT;AAQO,SAAS,qBAAqB,OAA0C;AAC7E,SAAO,IAAI,cAAc,KAAK;AAChC;AASO,SAAS,iBAAiB,MAA6D;AAC5F,SAAO,gBAAgB;AACzB;",
4
+ "sourcesContent": ["import { type CSSProperties, type HtmlHTMLAttributes, type ReactNode } from 'react';\nimport { theme } from 'antd';\nimport classNames from 'classnames';\nimport type { LexicalNode, SerializedLexicalNode, Spread } from 'lexical';\nimport { CloseCircleOutlined } from '@ant-design/icons';\nimport { randomChars } from '../../../utils';\nimport { updateDomProps } from '../helpers';\nimport type { BaseDecoratorNodeProps, BaseNodeProps } from './base';\nimport { BaseDecoratorNode } from './base';\n\nconst CLOSE_ICON_CLASSNAME = 'lexical-close-icon';\n\nexport interface CloseIconNodeProps extends HtmlHTMLAttributes<HTMLSpanElement>, BaseDecoratorNodeProps {\n /**\n * - EN: Parent element class name, used to add positioning styles to the parent element.\n * - CN: 父元素的类名,用于给父元素添加定位样式\n */\n parentClassName: string;\n /**\n * - EN: The custom icon to display, optional\n * - CN: 要显示的自定义图标,可选\n */\n icon?: ReactNode;\n /**\n * - EN: The default class name for the close icon element. This property is invalid if `icon` is\n * set.\n * - CN: 默认关闭图标元素的类名,如果设置了 `icon` 则该属性无效\n */\n iconClassName?: string;\n /**\n * - EN: The custom style for the close icon element. This property is invalid if `icon` is set.\n * - CN: 自定义关闭图标元素的样式,如果设置了 `icon` 则该属性无效\n */\n iconStyle?: CSSProperties;\n /**\n * - EN: The click event handler for the close icon element.\n * - CN: 关闭图标元素的点击事件\n */\n onClick?: (e: React.MouseEvent<HTMLSpanElement>) => void;\n}\n\n/**\n * - EN: A node that represents a close icon.\n * - CN: 一个关闭图标的节点。\n */\nexport class CloseIconNode extends BaseDecoratorNode<ReactNode, CloseIconNodeProps> {\n __hashId: string;\n\n constructor(props: CloseIconNodeProps & { key?: string }) {\n super(props);\n this.__hashId = `hash-${randomChars(6)}`;\n }\n\n static getType(): string {\n return 'CloseIcon';\n }\n\n static clone(node: CloseIconNode): CloseIconNode {\n return new CloseIconNode({ ...node.__props!, key: node.getKey() });\n }\n\n static importJSON(serializedNode: SerializedCloseIconNode): CloseIconNode {\n return $createCloseIconNode(serializedNode.props);\n }\n\n exportJSON(): SerializedCloseIconNode {\n return {\n ...super.exportJSON(),\n props: this.__props!,\n type: this.getType(),\n version: 1,\n };\n }\n\n createDOM(): HTMLElement {\n const span = document.createElement('span');\n const underlyingProps = this.getUnderlyingProps(this.__props);\n const className = classNames(CLOSE_ICON_CLASSNAME, this.__hashId, underlyingProps?.className);\n updateDomProps(span, { ...underlyingProps, className });\n const stylesheet = document.createElement('style');\n const token = theme.getDesignToken();\n const parentCls = this.__props?.parentClassName ? `.${this.__props.parentClassName}` : '';\n stylesheet.innerHTML = `\n ${\n parentCls\n ? `\n ${parentCls} { \n position: relative;\n }\n `\n : ''\n }\n ${parentCls} .${CLOSE_ICON_CLASSNAME}.${this.__hashId} {\n position: absolute;\n top: 0;\n right: 0;\n transform: translate(50%, -50%);\n color: ${token.colorTextDisabled};\n font-size: ${token.fontSizeSM}px;\n line-height: 0;\n z-index: 1;\n opacity: 0;\n cursor: pointer;\n pointer-events: none;\n transition: opacity 0.2s ease;\n }\n ${parentCls}:hover .${CLOSE_ICON_CLASSNAME}.${this.__hashId} {\n opacity: 1;\n pointer-events: auto;\n }\n ${parentCls}:hover .${CLOSE_ICON_CLASSNAME}.${this.__hashId}:hover {\n color: ${token.colorTextSecondary};\n }\n `;\n span.append(stylesheet);\n return span;\n }\n\n updateDOM() {\n return false;\n }\n\n decorate(): ReactNode {\n return <CloseIconComponent node={this} />;\n }\n\n isInline(): boolean {\n return false;\n }\n\n getUnderlyingProps(props: CloseIconNodeProps | undefined): Omit<CloseIconNodeProps, keyof BaseNodeProps> {\n const excludeProps = super.getUnderlyingProps(props);\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { icon, iconClassName, iconStyle, onClick, ...rest } = excludeProps || {};\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return rest;\n }\n}\n\n/**\n * - EN: React decorator component rendered for CloseIconNode.\n * - CN: CloseIconNode 对应的 React 装饰组件。\n *\n * @param node The bound CloseIconNode instance | 关联的 CloseIconNode 实例\n */\nfunction CloseIconComponent({ node }: CloseIconComponentProps): ReactNode {\n const { icon, iconClassName, iconStyle, onClick } = node.__props || {};\n\n const closeIcon = icon ?? (\n <CloseCircleOutlined className={classNames(node.__hashId, iconClassName)} style={iconStyle} onClick={onClick} />\n );\n return closeIcon;\n}\n\n/**\n * - EN: Factory to create a CloseIconNode.\n * - CN: 创建 CloseIconNode 的工厂函数。\n *\n * @param props Props for the CloseIcon node | CloseIcon 节点的属性\n */\nexport function $createCloseIconNode(props: CloseIconNodeProps): CloseIconNode {\n return new CloseIconNode(props);\n}\n\n/**\n * - EN: Type guard to check whether a node is CloseIconNode.\n * - CN: 判断节点是否为 CloseIconNode 的类型守卫。\n *\n * @param node Node to test | 要检测的节点\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function $isCloseIconNode(node: LexicalNode | null | undefined): node is CloseIconNode {\n return node instanceof CloseIconNode;\n}\n\ninterface CloseIconComponentProps {\n node: CloseIconNode;\n}\ntype SerializedCloseIconNode = Spread<\n {\n props: CloseIconNodeProps;\n },\n SerializedLexicalNode\n>;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAsB;AACtB,wBAAuB;AAEvB,mBAAoC;AACpC,mBAA4B;AAC5B,qBAA+B;AAE/B,kBAAkC;AAElC,IAAM,uBAAuB;AAmCtB,IAAM,gBAAN,cAA4B,8BAAiD;AAAA,EAGlF,YAAY,OAA8C;AACxD,UAAM,KAAK;AACX,SAAK,WAAW,YAAQ,0BAAY,CAAC;AAAA,EACvC;AAAA,EAEA,OAAO,UAAkB;AACvB,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,MAAM,MAAoC;AAC/C,WAAO,IAAI,cAAc,EAAE,GAAG,KAAK,SAAU,KAAK,KAAK,OAAO,EAAE,CAAC;AAAA,EACnE;AAAA,EAEA,OAAO,WAAW,gBAAwD;AACxE,WAAO,qBAAqB,eAAe,KAAK;AAAA,EAClD;AAAA,EAEA,aAAsC;AACpC,WAAO;AAAA,MACL,GAAG,MAAM,WAAW;AAAA,MACpB,OAAO,KAAK;AAAA,MACZ,MAAM,KAAK,QAAQ;AAAA,MACnB,SAAS;AAAA,IACX;AAAA,EACF;A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kBAAAA,SAAW,KAAK,UAAU,aAAa,GAAG,OAAO,WAAW,SAAkB;AAEhH,SAAO;AACT;AAQO,SAAS,qBAAqB,OAA0C;AAC7E,SAAO,IAAI,cAAc,KAAK;AAChC;AASO,SAAS,iBAAiB,MAA6D;AAC5F,SAAO,gBAAgB;AACzB;",
6
6
  "names": ["classNames"]
7
7
  }
@@ -25,9 +25,7 @@ export declare class DivNode extends BaseElementNode<DivNodeProps> {
25
25
  exportJSON(): SerializedDivNode;
26
26
  exportDOM(): DOMExportOutput;
27
27
  isInline(): boolean;
28
- getPropValue<K extends keyof DivNodeProps>(key: K): DivNodeProps[K] | undefined;
29
- setProps(props: DivNodeProps): void;
30
- private shallowEqual;
28
+ updateProps(props: DivNodeProps): void;
31
29
  }
32
30
  /**
33
31
  * - EN: Factory to create a DivNode.
@@ -47,7 +47,7 @@ var DivNode = class extends import_base.BaseElementNode {
47
47
  updateDOM(prevNode, dom) {
48
48
  const prevProps = prevNode.__props;
49
49
  const currentProps = this.__props;
50
- const propsChanged = !this.shallowEqual(prevProps, currentProps);
50
+ const propsChanged = !(0, import_helpers.shallowEqual)(prevProps, currentProps);
51
51
  if (propsChanged) {
52
52
  (0, import_helpers.updateDomProps)(dom, this.getUnderlyingProps(currentProps));
53
53
  }
@@ -80,11 +80,7 @@ var DivNode = class extends import_base.BaseElementNode {
80
80
  const display = ((_b = (_a = this.__props) == null ? void 0 : _a.style) == null ? void 0 : _b.display) ?? "block";
81
81
  return display === "inline" || display === "inline-flex" || display === "inline-block" || display === "inline-grid" || display === "inline-table" || display === "inline-list-item";
82
82
  }
83
- getPropValue(key) {
84
- var _a;
85
- return (_a = this.__props) == null ? void 0 : _a[key];
86
- }
87
- setProps(props) {
83
+ updateProps(props) {
88
84
  var _a;
89
85
  const writable = this.getWritable();
90
86
  writable.__props = {
@@ -96,26 +92,6 @@ var DivNode = class extends import_base.BaseElementNode {
96
92
  }
97
93
  };
98
94
  }
99
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
- shallowEqual(obj1, obj2) {
101
- if (obj1 === obj2)
102
- return true;
103
- if (!obj1 || !obj2)
104
- return false;
105
- const keys1 = Object.keys(obj1);
106
- const keys2 = Object.keys(obj2);
107
- if (keys1.length !== keys2.length)
108
- return false;
109
- for (const key of keys1) {
110
- if (key === "style") {
111
- if (!this.shallowEqual(obj1[key], obj2[key]))
112
- return false;
113
- } else if (obj1[key] !== obj2[key]) {
114
- return false;
115
- }
116
- }
117
- return true;
118
- }
119
95
  };
120
96
  function convertDivElement(domNode) {
121
97
  const element = domNode;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/Lexical/nodes/DivNode.tsx"],
4
- "sourcesContent": ["import type { CSSProperties, HtmlHTMLAttributes } from 'react';\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n LexicalNode,\n SerializedElementNode,\n Spread,\n} from 'lexical';\nimport { updateDomProps } from '../helpers';\nimport { BaseElementNode, type BaseElementProps } from './base';\n\n/**\n * - EN: Props for the DivNode, combining DOM div attributes and element behavior flags.\n * - CN: DivNode 的属性,包含 DOM div 属性与元素行为标记。\n */\nexport interface DivNodeProps extends HtmlHTMLAttributes<HTMLDivElement>, BaseElementProps {}\n\nexport type SerializedDivNode = Spread<\n {\n props?: DivNodeProps;\n },\n SerializedElementNode\n>;\n\n/**\n * - EN: Lexical element node that renders a DOM div with controlled props.\n * - CN: 渲染为 DOM div 且可控制属性的 Lexical 元素节点。\n */\nexport class DivNode extends BaseElementNode<DivNodeProps> {\n static getType(): string {\n return 'html.div';\n }\n\n static clone(node: DivNode): DivNode {\n return new DivNode({ ...node.__props, key: node.getKey() });\n }\n\n protected getForceDisplay(): CSSProperties['display'] {\n return undefined;\n }\n\n createDOM(): HTMLElement {\n const div = document.createElement('div');\n const domProps = this.getUnderlyingProps(this.__props);\n if (domProps) {\n updateDomProps(div, domProps);\n }\n return div;\n }\n\n updateDOM(prevNode: DivNode, dom: HTMLElement): boolean {\n const prevProps = prevNode.__props;\n const currentProps = this.__props;\n const propsChanged = !this.shallowEqual(prevProps, currentProps);\n if (propsChanged) {\n updateDomProps(dom, this.getUnderlyingProps(currentProps));\n }\n return false;\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n div: (node: Node) => ({\n conversion: convertDivElement,\n priority: 1,\n }),\n };\n }\n\n static importJSON(serializedNode: SerializedDivNode): DivNode {\n return $createDivNode(serializedNode.props);\n }\n\n exportJSON(): SerializedDivNode {\n return {\n ...super.exportJSON(),\n props: this.__props,\n type: this.getType(),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = this.createDOM();\n return { element };\n }\n\n isInline(): boolean {\n const display = this.__props?.style?.display ?? 'block';\n return (\n display === 'inline' ||\n display === 'inline-flex' ||\n display === 'inline-block' ||\n display === 'inline-grid' ||\n display === 'inline-table' ||\n display === 'inline-list-item'\n );\n }\n\n getPropValue<K extends keyof DivNodeProps>(key: K): DivNodeProps[K] | undefined {\n return this.__props?.[key];\n }\n setProps(props: DivNodeProps): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props,\n ...props,\n style: {\n ...writable.__props?.style,\n ...props.style,\n },\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private shallowEqual(obj1: any, obj2: any): boolean {\n if (obj1 === obj2) return true;\n if (!obj1 || !obj2) return false;\n\n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n\n if (keys1.length !== keys2.length) return false;\n\n for (const key of keys1) {\n if (key === 'style') {\n // - EN: Special handling for style objects.\n // - CN: 特殊处理 style 对象。\n if (!this.shallowEqual(obj1[key], obj2[key])) return false;\n } else if (obj1[key] !== obj2[key]) {\n return false;\n }\n }\n\n return true;\n }\n}\n/**\n * - EN: Convert a DOM node to a DivNode during import.\n * - CN: 在导入时将 DOM 节点转换为 DivNode。\n *\n * @param domNode Source DOM node | 源 DOM 节点\n */\nfunction convertDivElement(domNode: Node): DOMConversionOutput {\n const element = domNode as HTMLElement;\n if (element.nodeName === 'DIV') {\n return { node: $createDivNode() };\n }\n return { node: null };\n}\n/**\n * - EN: Factory to create a DivNode.\n * - CN: 创建 DivNode 的工厂函数。\n *\n * @param props Props for the DivNode | DivNode 的属性\n */\nexport function $createDivNode(props?: DivNodeProps): DivNode {\n return new DivNode(props);\n}\n/**\n * - EN: Type guard to check if a node is DivNode.\n * - CN: 判断节点是否为 DivNode 的类型守卫。\n *\n * @param node Node to test | 要检测的节点\n */\nexport function $isDivNode(node: LexicalNode | null | undefined): node is DivNode {\n return node instanceof DivNode;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,qBAA+B;AAC/B,kBAAuD;AAmBhD,IAAM,UAAN,cAAsB,4BAA8B;AAAA,EACzD,OAAO,UAAkB;AACvB,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,MAAM,MAAwB;AACnC,WAAO,IAAI,QAAQ,EAAE,GAAG,KAAK,SAAS,KAAK,KAAK,OAAO,EAAE,CAAC;AAAA,EAC5D;AAAA,EAEU,kBAA4C;AACpD,WAAO;AAAA,EACT;AAAA,EAEA,YAAyB;AACvB,UAAM,MAAM,SAAS,cAAc,KAAK;AACxC,UAAM,WAAW,KAAK,mBAAmB,KAAK,OAAO;AACrD,QAAI,UAAU;AACZ,yCAAe,KAAK,QAAQ;AAAA,IAC9B;AACA,WAAO;AAAA,EACT;AAAA,EAEA,UAAU,UAAmB,KAA2B;AACtD,UAAM,YAAY,SAAS;AAC3B,UAAM,eAAe,KAAK;AAC1B,UAAM,eAAe,CAAC,KAAK,aAAa,WAAW,YAAY;AAC/D,QAAI,cAAc;AAChB,yCAAe,KAAK,KAAK,mBAAmB,YAAY,CAAC;AAAA,IAC3D;AACA,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,YAAqC;AAC1C,WAAO;AAAA,MACL,KAAK,CAAC,UAAgB;AAAA,QACpB,YAAY;AAAA,QACZ,U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AAG,MAAM,KAAK,GAAG,GAAG;AAClC,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;AAOA,SAAS,kBAAkB,SAAoC;AAC7D,QAAM,UAAU;AAChB,MAAI,QAAQ,aAAa,OAAO;AAC9B,WAAO,EAAE,MAAM,eAAe,EAAE;AAAA,EAClC;AACA,SAAO,EAAE,MAAM,KAAK;AACtB;AAOO,SAAS,eAAe,OAA+B;AAC5D,SAAO,IAAI,QAAQ,KAAK;AAC1B;AAOO,SAAS,WAAW,MAAuD;AAChF,SAAO,gBAAgB;AACzB;",
4
+ "sourcesContent": ["import type { CSSProperties, HtmlHTMLAttributes } from 'react';\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n LexicalNode,\n SerializedElementNode,\n Spread,\n} from 'lexical';\nimport { shallowEqual, updateDomProps } from '../helpers';\nimport { BaseElementNode, type BaseElementProps } from './base';\n\n/**\n * - EN: Props for the DivNode, combining DOM div attributes and element behavior flags.\n * - CN: DivNode 的属性,包含 DOM div 属性与元素行为标记。\n */\nexport interface DivNodeProps extends HtmlHTMLAttributes<HTMLDivElement>, BaseElementProps {}\n\nexport type SerializedDivNode = Spread<\n {\n props?: DivNodeProps;\n },\n SerializedElementNode\n>;\n\n/**\n * - EN: Lexical element node that renders a DOM div with controlled props.\n * - CN: 渲染为 DOM div 且可控制属性的 Lexical 元素节点。\n */\nexport class DivNode extends BaseElementNode<DivNodeProps> {\n static getType(): string {\n return 'html.div';\n }\n\n static clone(node: DivNode): DivNode {\n return new DivNode({ ...node.__props, key: node.getKey() });\n }\n\n protected getForceDisplay(): CSSProperties['display'] {\n return undefined;\n }\n\n createDOM(): HTMLElement {\n const div = document.createElement('div');\n const domProps = this.getUnderlyingProps(this.__props);\n if (domProps) {\n updateDomProps(div, domProps);\n }\n return div;\n }\n\n updateDOM(prevNode: DivNode, dom: HTMLElement): boolean {\n const prevProps = prevNode.__props;\n const currentProps = this.__props;\n const propsChanged = !shallowEqual(prevProps, currentProps);\n if (propsChanged) {\n updateDomProps(dom, this.getUnderlyingProps(currentProps));\n }\n return false;\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n div: (node: Node) => ({\n conversion: convertDivElement,\n priority: 1,\n }),\n };\n }\n\n static importJSON(serializedNode: SerializedDivNode): DivNode {\n return $createDivNode(serializedNode.props);\n }\n\n exportJSON(): SerializedDivNode {\n return {\n ...super.exportJSON(),\n props: this.__props,\n type: this.getType(),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = this.createDOM();\n return { element };\n }\n\n isInline(): boolean {\n const display = this.__props?.style?.display ?? 'block';\n return (\n display === 'inline' ||\n display === 'inline-flex' ||\n display === 'inline-block' ||\n display === 'inline-grid' ||\n display === 'inline-table' ||\n display === 'inline-list-item'\n );\n }\n\n updateProps(props: DivNodeProps): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props,\n ...props,\n style: {\n ...writable.__props?.style,\n ...props.style,\n },\n };\n }\n}\n/**\n * - EN: Convert a DOM node to a DivNode during import.\n * - CN: 在导入时将 DOM 节点转换为 DivNode。\n *\n * @param domNode Source DOM node | 源 DOM 节点\n */\nfunction convertDivElement(domNode: Node): DOMConversionOutput {\n const element = domNode as HTMLElement;\n if (element.nodeName === 'DIV') {\n return { node: $createDivNode() };\n }\n return { node: null };\n}\n/**\n * - EN: Factory to create a DivNode.\n * - CN: 创建 DivNode 的工厂函数。\n *\n * @param props Props for the DivNode | DivNode 的属性\n */\nexport function $createDivNode(props?: DivNodeProps): DivNode {\n return new DivNode(props);\n}\n/**\n * - EN: Type guard to check if a node is DivNode.\n * - CN: 判断节点是否为 DivNode 的类型守卫。\n *\n * @param node Node to test | 要检测的节点\n */\nexport function $isDivNode(node: LexicalNode | null | undefined): node is DivNode {\n return node instanceof DivNode;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,qBAA6C;AAC7C,kBAAu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,kBACZ,YAAY,iBACZ,YAAY,kBACZ,YAAY;AAAA,EAEhB;AAAA,EAEA,YAAY,OAA2B;AAnGzC;AAoGI,UAAM,WAAW,KAAK,YAAY;AAClC,aAAS,UAAU;AAAA,MACjB,GAAG,SAAS;AAAA,MACZ,GAAG;AAAA,MACH,OAAO;AAAA,QACL,IAAG,cAAS,YAAT,mBAAkB;AAAA,QACrB,GAAG,MAAM;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF;AAOA,SAAS,kBAAkB,SAAoC;AAC7D,QAAM,UAAU;AAChB,MAAI,QAAQ,aAAa,OAAO;AAC9B,WAAO,EAAE,MAAM,eAAe,EAAE;AAAA,EAClC;AACA,SAAO,EAAE,MAAM,KAAK;AACtB;AAOO,SAAS,eAAe,OAA+B;AAC5D,SAAO,IAAI,QAAQ,KAAK;AAC1B;AAOO,SAAS,WAAW,MAAuD;AAChF,SAAO,gBAAgB;AACzB;",
6
6
  "names": []
7
7
  }
@@ -37,14 +37,14 @@ export declare class SelectNode<ValueType = any, OptionType extends BaseOptionTy
37
37
  static importJSON<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(serializedNode: SerializedSelectNode<ValueType, OptionType>): SelectNode<ValueType, OptionType>;
38
38
  exportJSON(): SerializedSelectNode<ValueType, OptionType>;
39
39
  createDOM(): HTMLElement;
40
- updateDOM(): false;
40
+ updateDOM(prevNode: this, dom: HTMLElement): boolean;
41
41
  decorate(): ReactNode;
42
42
  isInline(): boolean;
43
43
  getTextContent(): string;
44
44
  getValue(): ValueType | undefined;
45
45
  setValue(value: ValueType | undefined): void;
46
- getPropValue(propName: keyof SelectNodeProps<ValueType, OptionType>): SelectNodeProps<ValueType, OptionType>[typeof propName];
47
- setProps(props: Partial<SelectNodeProps<ValueType, OptionType>>): void;
46
+ getProp(propName: keyof SelectNodeProps<ValueType, OptionType>): SelectNodeProps<ValueType, OptionType>[typeof propName];
47
+ updateProps(props: Partial<SelectNodeProps<ValueType, OptionType>>): void;
48
48
  }
49
49
  /**
50
50
  * - EN: Factory to create a SelectNode.
@@ -60,8 +60,9 @@ var SelectNode = class extends import_base.BaseDecoratorNode {
60
60
  (0, import_helpers.updateDomStyle)(span, (_a = this.__props) == null ? void 0 : _a.containerStyle);
61
61
  return span;
62
62
  }
63
- updateDOM() {
64
- return false;
63
+ updateDOM(prevNode, dom) {
64
+ const propsChanged = !(0, import_helpers.shallowEqual)(prevNode.__props, this.__props);
65
+ return propsChanged;
65
66
  }
66
67
  decorate() {
67
68
  return /* @__PURE__ */ React.createElement(SelectComponent, { node: this });
@@ -91,11 +92,11 @@ var SelectNode = class extends import_base.BaseDecoratorNode {
91
92
  const writable = this.getWritable();
92
93
  writable.__value = value;
93
94
  }
94
- getPropValue(propName) {
95
+ getProp(propName) {
95
96
  var _a;
96
97
  return (_a = this.__props) == null ? void 0 : _a[propName];
97
98
  }
98
- setProps(props) {
99
+ updateProps(props) {
99
100
  const writable = this.getWritable();
100
101
  writable.__props = {
101
102
  ...writable.__props,
@@ -106,7 +107,8 @@ var SelectNode = class extends import_base.BaseDecoratorNode {
106
107
  function SelectComponent({
107
108
  node
108
109
  }) {
109
- const { textContentMode, spaceAround, containerStyle, ...selectProps } = node.__props || {};
110
+ const underlyingProps = node.getUnderlyingProps(node.__props);
111
+ const { textContentMode, spaceAround, containerStyle, ...selectProps } = underlyingProps;
110
112
  const [editor] = (0, import_LexicalComposerContext.useLexicalComposerContext)();
111
113
  const handleChange = (0, import_react.useCallback)(
112
114
  (value, options) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/Lexical/nodes/SelectNode.tsx"],
4
- "sourcesContent": ["import { type CSSProperties, type ReactNode, useCallback } from 'react';\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\nimport { Select } from 'antd';\nimport type { SelectProps } from 'antd';\nimport type { BaseOptionType, DefaultOptionType } from 'antd/es/select';\nimport type { LexicalEditor, LexicalNode, SerializedLexicalNode, Spread } from 'lexical';\nimport { insertNodeAtCursor, updateDomStyle } from '../helpers';\nimport type { BaseDecoratorNodeProps } from './base';\nimport { BaseDecoratorNode } from './base';\n\n/**\n * - EN: Props for SelectNode, extending antd Select props plus behavior flags.\n * - CN: SelectNode 的属性,基于 antd Select 属性并附加行为标记。\n */\nexport interface SelectNodeProps<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> extends SelectProps<ValueType, OptionType>,\n BaseDecoratorNodeProps {\n /**\n * - EN: When reading editor textContent, whether to use option label or value. Default `value`.\n * - CN: 在获取 editor 的 textContent 时,使用选项的 label 还是 value。默认 `value`。\n * - label: use option label as text\n * - value: use option value as text\n */\n textContentMode?: 'label' | 'value';\n /**\n * - EN: Add a space around textContent. Default `true`.\n * - CN: 是否在 textContent 两边添加一个空格,默认 `true`。\n */\n spaceAround?: boolean;\n /**\n * - EN: Container DOM style.\n * - CN: 容器样式。\n */\n containerStyle?: CSSProperties;\n}\n\nexport class SelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> extends BaseDecoratorNode<ReactNode, SelectNodeProps<ValueType, OptionType>> {\n __value: ValueType | undefined;\n\n constructor(props?: SelectNodeProps<ValueType, OptionType> & { key?: string }) {\n super(props);\n this.__value = props?.defaultValue ?? undefined;\n }\n static getType(): string {\n return 'antd.Select';\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static clone<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(\n node: SelectNode<ValueType, OptionType>\n ): SelectNode<ValueType, OptionType> {\n return new SelectNode<ValueType, OptionType>({ ...node.__props, key: node.getKey() });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static importJSON<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(\n serializedNode: SerializedSelectNode<ValueType, OptionType>\n ): SelectNode<ValueType, OptionType> {\n return $createSelectNode(serializedNode.props);\n }\n\n exportJSON(): SerializedSelectNode<ValueType, OptionType> {\n return {\n ...super.exportJSON(),\n props: this.__props,\n type: this.getType(),\n version: 1,\n };\n }\n\n createDOM(): HTMLElement {\n const span = document.createElement('span');\n updateDomStyle(span, this.__props?.containerStyle);\n return span;\n }\n\n updateDOM(): false {\n return false;\n }\n\n decorate(): ReactNode {\n return <SelectComponent node={this} />;\n }\n\n isInline(): boolean {\n return true;\n }\n\n getTextContent(): string {\n let content: string;\n const valueContent = this.__value ? String(this.__value) : '';\n if (this.__props?.textContentMode === 'label') {\n const option = this.__props?.options?.find((opt) => opt.value === this.__value);\n content = option?.label ? String(option.label) : valueContent;\n } else {\n content = valueContent;\n }\n if (this.__props?.spaceAround !== false) {\n return ` ${content} `;\n }\n return content;\n }\n\n getValue(): ValueType | undefined {\n return this.__value;\n }\n\n setValue(value: ValueType | undefined): void {\n const writable = this.getWritable();\n writable.__value = value;\n }\n\n getPropValue(\n propName: keyof SelectNodeProps<ValueType, OptionType>\n ): SelectNodeProps<ValueType, OptionType>[typeof propName] {\n return this.__props?.[propName];\n }\n\n setProps(props: Partial<SelectNodeProps<ValueType, OptionType>>): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props,\n ...props,\n };\n }\n}\n\n/**\n * - EN: React decorator component rendered for SelectNode.\n * - CN: SelectNode 对应的 React 装饰组件。\n *\n * @param node The bound SelectNode instance | 关联的 SelectNode 实例\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction SelectComponent<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>({\n node,\n}: SelectComponentProps<ValueType, OptionType>): ReactNode {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { textContentMode, spaceAround, containerStyle, ...selectProps } = node.__props || {};\n /* eslint-enable @typescript-eslint/no-unused-vars */\n const [editor] = useLexicalComposerContext();\n\n const handleChange = useCallback<NonNullable<SelectNodeProps<ValueType, OptionType>['onChange']>>(\n (value, options) => {\n editor.update(() => {\n node.setValue(value);\n node.__props?.onChange?.(value, options);\n });\n },\n [editor, node]\n );\n\n const handleClear = useCallback(() => {\n editor.update(() => {\n node.setValue(undefined);\n node.__props?.onClear?.();\n });\n }, [editor, node]);\n\n return <Select {...selectProps} value={node.getValue()} onChange={handleChange} onClear={handleClear} />;\n}\n\n/**\n * - EN: Factory to create a SelectNode.\n * - CN: 创建 SelectNode 的工厂函数。\n *\n * @param props Props for the Select node | Select 节点的属性\n */\nexport function $createSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n>(props?: SelectNodeProps<ValueType, OptionType>): SelectNode<ValueType, OptionType> {\n return new SelectNode<ValueType, OptionType>(props);\n}\n\n/**\n * - EN: Type guard to check whether a node is SelectNode.\n * - CN: 判断节点是否为 SelectNode 的类型守卫。\n *\n * @param node Node to test | 要检测的节点\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function $isSelectNode(node: LexicalNode | null | undefined): node is SelectNode<any, any> {\n return node instanceof SelectNode;\n}\n\n/**\n * - EN: Insert a SelectNode at the current cursor position.\n * - CN: 在当前光标位置插入一个 SelectNode。\n *\n * @param editor LexicalEditor instance | LexicalEditor 实例\n * @param props Props for the Select node | Select 节点的属性\n */\nexport function $insertSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n>(editor: LexicalEditor, props: SelectNodeProps<ValueType, OptionType>): void {\n editor.update(() => {\n const selectNode = $createSelectNode<ValueType, OptionType>({\n ...props,\n containerStyle: {\n paddingLeft: '8px',\n paddingRight: '8px',\n ...props.containerStyle,\n },\n });\n insertNodeAtCursor(editor, selectNode);\n });\n}\n\n/**\n * - EN: Props passed to the Select decorator component.\n * - CN: 传递给 Select 装饰组件的属性。\n */\ninterface SelectComponentProps<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> {\n node: SelectNode<ValueType, OptionType>;\n}\ntype SerializedSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> = Spread<\n {\n props?: SelectNodeProps<ValueType, OptionType>;\n },\n SerializedLexicalNode\n>;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgE;AAChE,oCAA0C;AAC1C,kBAAuB;AAIvB,qBAAmD;AAEnD,kBAAkC;AA+B3B,IAAM,aAAN,cAIG,8BAAqE;AAAA,EAG7E,YAAY,OAAmE;AAC7E,UAAM,KAAK;AACX,SAAK,WAAU,+BAAO,iBAAgB;AAAA,EACxC;AAAA,EACA,OAAO,UAAkB;AACvB,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,OAAO,MACL,MACmC;AACnC,WAAO,IAAI,WAAkC,EAAE,GAAG,KAAK,SAAS,KAAK,KAAK,OAAO,EAAE,CAAC;AAAA,EACtF;AAAA;AAAA,EAGA,OAAO,WACL,gBACmC;AACnC,WAAO,kBAAkB,eAAe,KAAK;AAAA,EAC/C;AAAA,EAEA,aAA0D;AACxD,WAAO;AAAA,MACL,GAAG,MAAM,WAAW;AAAA,MACpB,OAAO,KAAK;AAAA,MACZ,MAAM,KAAK,QAAQ;AAAA,MACnB,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EAEA,YAAyB;AA7E3B;AA8EI,UAAM,OAAO,SAAS,cAAc,MAAM;AAC1C,uCAAe,OAAM,UAAK,YAAL,mBAAc,cAAc;AACjD,WAAO;AAAA,EACT;AAAA,EAEA,YAAmB;AACjB,WAAO;AAAA,EACT;AAAA,EAEA,WAAsB;AACpB,WAAO,oCAAC,mBAAgB,M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AEA,QAAM,kBAAc,0BAAY,MAAM;AACpC,WAAO,OAAO,MAAM;AAhKxB;AAiKM,WAAK,SAAS,MAAS;AACvB,uBAAK,YAAL,mBAAc,YAAd;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,QAAQ,IAAI,CAAC;AAEjB,SAAO,oCAAC,sBAAQ,GAAG,aAAa,OAAO,KAAK,SAAS,GAAG,UAAU,cAAc,SAAS,aAAa;AACxG;AAQO,SAAS,kBAId,OAAmF;AACnF,SAAO,IAAI,WAAkC,KAAK;AACpD;AASO,SAAS,cAAc,MAAoE;AAChG,SAAO,gBAAgB;AACzB;AASO,SAAS,kBAId,QAAuB,OAAqD;AAC5E,SAAO,OAAO,MAAM;AAClB,UAAM,aAAa,kBAAyC;AAAA,MAC1D,GAAG;AAAA,MACH,gBAAgB;AAAA,QACd,aAAa;AAAA,QACb,cAAc;AAAA,QACd,GAAG,MAAM;AAAA,MACX;AAAA,IACF,CAAC;AACD,2CAAmB,QAAQ,UAAU;AAAA,EACvC,CAAC;AACH;",
4
+ "sourcesContent": ["import { type CSSProperties, type ReactNode, useCallback } from 'react';\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\nimport { Select } from 'antd';\nimport type { SelectProps } from 'antd';\nimport type { BaseOptionType, DefaultOptionType } from 'antd/es/select';\nimport type { LexicalEditor, LexicalNode, SerializedLexicalNode, Spread } from 'lexical';\nimport { insertNodeAtCursor, shallowEqual, updateDomStyle } from '../helpers';\nimport type { BaseDecoratorNodeProps } from './base';\nimport { BaseDecoratorNode } from './base';\n\n/**\n * - EN: Props for SelectNode, extending antd Select props plus behavior flags.\n * - CN: SelectNode 的属性,基于 antd Select 属性并附加行为标记。\n */\nexport interface SelectNodeProps<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> extends SelectProps<ValueType, OptionType>,\n BaseDecoratorNodeProps {\n /**\n * - EN: When reading editor textContent, whether to use option label or value. Default `value`.\n * - CN: 在获取 editor 的 textContent 时,使用选项的 label 还是 value。默认 `value`。\n * - label: use option label as text\n * - value: use option value as text\n */\n textContentMode?: 'label' | 'value';\n /**\n * - EN: Add a space around textContent. Default `true`.\n * - CN: 是否在 textContent 两边添加一个空格,默认 `true`。\n */\n spaceAround?: boolean;\n /**\n * - EN: Container DOM style.\n * - CN: 容器样式。\n */\n containerStyle?: CSSProperties;\n}\n\nexport class SelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> extends BaseDecoratorNode<ReactNode, SelectNodeProps<ValueType, OptionType>> {\n __value: ValueType | undefined;\n\n constructor(props?: SelectNodeProps<ValueType, OptionType> & { key?: string }) {\n super(props);\n this.__value = props?.defaultValue ?? undefined;\n }\n static getType(): string {\n return 'antd.Select';\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static clone<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(\n node: SelectNode<ValueType, OptionType>\n ): SelectNode<ValueType, OptionType> {\n return new SelectNode<ValueType, OptionType>({ ...node.__props, key: node.getKey() });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static importJSON<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(\n serializedNode: SerializedSelectNode<ValueType, OptionType>\n ): SelectNode<ValueType, OptionType> {\n return $createSelectNode(serializedNode.props);\n }\n\n exportJSON(): SerializedSelectNode<ValueType, OptionType> {\n return {\n ...super.exportJSON(),\n props: this.__props,\n type: this.getType(),\n version: 1,\n };\n }\n\n createDOM(): HTMLElement {\n const span = document.createElement('span');\n updateDomStyle(span, this.__props?.containerStyle);\n return span;\n }\n\n updateDOM(prevNode: this, dom: HTMLElement): boolean {\n const propsChanged = !shallowEqual(prevNode.__props, this.__props);\n return propsChanged;\n }\n\n decorate(): ReactNode {\n return <SelectComponent node={this} />;\n }\n\n isInline(): boolean {\n return true;\n }\n\n getTextContent(): string {\n let content: string;\n const valueContent = this.__value ? String(this.__value) : '';\n if (this.__props?.textContentMode === 'label') {\n const option = this.__props?.options?.find((opt) => opt.value === this.__value);\n content = option?.label ? String(option.label) : valueContent;\n } else {\n content = valueContent;\n }\n if (this.__props?.spaceAround !== false) {\n return ` ${content} `;\n }\n return content;\n }\n\n getValue(): ValueType | undefined {\n return this.__value;\n }\n\n setValue(value: ValueType | undefined): void {\n const writable = this.getWritable();\n writable.__value = value;\n }\n\n getProp(\n propName: keyof SelectNodeProps<ValueType, OptionType>\n ): SelectNodeProps<ValueType, OptionType>[typeof propName] {\n return this.__props?.[propName];\n }\n\n updateProps(props: Partial<SelectNodeProps<ValueType, OptionType>>): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props,\n ...props,\n };\n }\n}\n\n/**\n * - EN: React decorator component rendered for SelectNode.\n * - CN: SelectNode 对应的 React 装饰组件。\n *\n * @param node The bound SelectNode instance | 关联的 SelectNode 实例\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction SelectComponent<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>({\n node,\n}: SelectComponentProps<ValueType, OptionType>): ReactNode {\n const underlyingProps = node.getUnderlyingProps(node.__props);\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { textContentMode, spaceAround, containerStyle, ...selectProps } = underlyingProps;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n const [editor] = useLexicalComposerContext();\n\n const handleChange = useCallback<NonNullable<SelectNodeProps<ValueType, OptionType>['onChange']>>(\n (value, options) => {\n editor.update(() => {\n node.setValue(value);\n node.__props?.onChange?.(value, options);\n });\n },\n [editor, node]\n );\n\n const handleClear = useCallback(() => {\n editor.update(() => {\n node.setValue(undefined);\n node.__props?.onClear?.();\n });\n }, [editor, node]);\n\n return <Select {...selectProps} value={node.getValue()} onChange={handleChange} onClear={handleClear} />;\n}\n\n/**\n * - EN: Factory to create a SelectNode.\n * - CN: 创建 SelectNode 的工厂函数。\n *\n * @param props Props for the Select node | Select 节点的属性\n */\nexport function $createSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n>(props?: SelectNodeProps<ValueType, OptionType>): SelectNode<ValueType, OptionType> {\n return new SelectNode<ValueType, OptionType>(props);\n}\n\n/**\n * - EN: Type guard to check whether a node is SelectNode.\n * - CN: 判断节点是否为 SelectNode 的类型守卫。\n *\n * @param node Node to test | 要检测的节点\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function $isSelectNode(node: LexicalNode | null | undefined): node is SelectNode<any, any> {\n return node instanceof SelectNode;\n}\n\n/**\n * - EN: Insert a SelectNode at the current cursor position.\n * - CN: 在当前光标位置插入一个 SelectNode。\n *\n * @param editor LexicalEditor instance | LexicalEditor 实例\n * @param props Props for the Select node | Select 节点的属性\n */\nexport function $insertSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n>(editor: LexicalEditor, props: SelectNodeProps<ValueType, OptionType>): void {\n editor.update(() => {\n const selectNode = $createSelectNode<ValueType, OptionType>({\n ...props,\n containerStyle: {\n paddingLeft: '8px',\n paddingRight: '8px',\n ...props.containerStyle,\n },\n });\n insertNodeAtCursor(editor, selectNode);\n });\n}\n\n/**\n * - EN: Props passed to the Select decorator component.\n * - CN: 传递给 Select 装饰组件的属性。\n */\ninterface SelectComponentProps<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> {\n node: SelectNode<ValueType, OptionType>;\n}\ntype SerializedSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> = Spread<\n {\n props?: SelectNodeProps<ValueType,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AAEjB,SAAO,oCAAC,sBAAQ,GAAG,aAAa,OAAO,KAAK,SAAS,GAAG,UAAU,cAAc,SAAS,aAAa;AACxG;AAQO,SAAS,kBAId,OAAmF;AACnF,SAAO,IAAI,WAAkC,KAAK;AACpD;AASO,SAAS,cAAc,MAAoE;AAChG,SAAO,gBAAgB;AACzB;AASO,SAAS,kBAId,QAAuB,OAAqD;AAC5E,SAAO,OAAO,MAAM;AAClB,UAAM,aAAa,kBAAyC;AAAA,MAC1D,GAAG;AAAA,MACH,gBAAgB;AAAA,QACd,aAAa;AAAA,QACb,cAAc;AAAA,QACd,GAAG,MAAM;AAAA,MACX;AAAA,IACF,CAAC;AACD,2CAAmB,QAAQ,UAAU;AAAA,EACvC,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -74,6 +74,8 @@ export declare class BaseElementNode<P extends BaseElementProps> extends Element
74
74
  canBeEmpty(): boolean;
75
75
  canInsertTextBefore(): boolean;
76
76
  canInsertTextAfter(): boolean;
77
+ getProp(propName: keyof P): P[typeof propName];
78
+ updateProps(props: Partial<P>): void;
77
79
  /**
78
80
  * - EN: Strip element-specific flags and return DOM props.
79
81
  * - CN: 去除元素特有的标记并返回 DOM 属性。
@@ -92,6 +94,8 @@ export declare class BaseDecoratorNode<T, P extends BaseDecoratorNodeProps> exte
92
94
  constructor(props?: P & {
93
95
  key?: string;
94
96
  });
97
+ getProp(propName: keyof P): P[typeof propName];
98
+ updateProps(props: Partial<P>): void;
95
99
  /**
96
100
  * - EN: Strip decorator-specific flags and return DOM props.
97
101
  * - CN: 去除装饰器特有的标记并返回 DOM 属性。
@@ -85,6 +85,17 @@ var BaseElementNode = class extends import_lexical.ElementNode {
85
85
  var _a;
86
86
  return ((_a = this.__props) == null ? void 0 : _a.canInsertTextAfter) ?? true;
87
87
  }
88
+ getProp(propName) {
89
+ var _a;
90
+ return (_a = this.__props) == null ? void 0 : _a[propName];
91
+ }
92
+ updateProps(props) {
93
+ const writable = this.getWritable();
94
+ writable.__props = {
95
+ ...writable.__props,
96
+ ...props
97
+ };
98
+ }
88
99
  /**
89
100
  * - EN: Strip element-specific flags and return DOM props.
90
101
  * - CN: 去除元素特有的标记并返回 DOM 属性。
@@ -113,6 +124,17 @@ var BaseDecoratorNode = class extends import_lexical.DecoratorNode {
113
124
  }
114
125
  });
115
126
  }
127
+ getProp(propName) {
128
+ var _a;
129
+ return (_a = this.__props) == null ? void 0 : _a[propName];
130
+ }
131
+ updateProps(props) {
132
+ const writable = this.getWritable();
133
+ writable.__props = {
134
+ ...writable.__props,
135
+ ...props
136
+ };
137
+ }
116
138
  /**
117
139
  * - EN: Strip decorator-specific flags and return DOM props.
118
140
  * - CN: 去除装饰器特有的标记并返回 DOM 属性。
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/Lexical/nodes/base.ts"],
4
- "sourcesContent": ["import type { LexicalNode } from 'lexical';\nimport { DecoratorNode, ElementNode } from 'lexical';\n\n/**\n * - EN: Common behavior flags for custom nodes.\n * - CN: 自定义节点的通用行为标记。\n */\nexport interface BaseNodeProps {\n /**\n * - EN: Whether the node can be removed. Default `true`.\n * - CN: 是否可被删除,默认 `true`。\n */\n canBeRemoved?: boolean;\n /**\n * - EN: Whether the node can be replaced. Default `true`.\n * - CN: 是否可被替换,默认 `true`。\n */\n canBeReplaced?: boolean;\n}\n/**\n * - EN: Extra behavior flags for element nodes.\n * - CN: 元素节点的附加行为标记。\n */\nexport interface BaseElementProps extends BaseNodeProps {\n /**\n * - EN: Whether an element is allowed to be empty. Default `false`.\n * - CN: 是否允许节点为空,默认 `false`。\n */\n canBeEmpty?: boolean;\n /**\n * - EN: Allow inserting text at the start of the element. Default `true`.\n * - CN: 是否允许在节点内的起始位置插入文本,默认 `true`。\n */\n canInsertTextBefore?: boolean;\n /**\n * - EN: Allow inserting text at the end of the element. Default `true`.\n * - CN: 是否允许在节点内的结束位置插入文本,默认 `true`。\n */\n canInsertTextAfter?: boolean;\n}\n\nexport type BaseDecoratorNodeProps = BaseNodeProps;\n\n/**\n * - EN: A helper wrapping base behaviors (remove/replace) with guard flags.\n * - CN: 封装基础行为(删除/替换)并根据标记进行限制的帮助器。\n *\n * @param props Node behavior flags | 节点行为标记\n * @param superMethods Methods delegated to the underlying node | 委托给底层节点的方法\n */\nexport class BaseNodeHelper<P extends BaseNodeProps> {\n __props: (P & BaseNodeProps) | undefined;\n __superMethods: Pick<LexicalNode, 'replace' | 'remove'>;\n\n constructor(props: P | undefined, superMethods: Pick<LexicalNode, 'replace' | 'remove'>) {\n this.__props = props as P & BaseNodeProps;\n this.__superMethods = superMethods;\n }\n\n hooks = {\n remove: (preserveEmptyParent?: boolean): void => {\n if (this.__props?.canBeRemoved === false) {\n return;\n }\n this.__superMethods.remove(preserveEmptyParent);\n },\n\n replace: <N extends LexicalNode>(replaceWith: N, includeChildren?: boolean): N => {\n if (this.__props?.canBeReplaced === false) {\n return this as unknown as N;\n }\n return this.__superMethods.replace(replaceWith, includeChildren);\n },\n };\n /**\n * - EN: Strip helper-only flags from props for DOM usage.\n * - CN: 去除仅用于帮助器的标记属性,得到用于 DOM 的纯属性。\n *\n * @param props Props including helper flags | 含帮助标记的属性\n */\n getUnderlyingProps(props: P & BaseNodeProps): Omit<P, keyof BaseNodeProps> {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { canBeRemoved, canBeReplaced, ...restProps } = props;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n\n/**\n * - EN: Base element node with behavior flags.\n * - CN: 带行为标记的基础元素节点。\n */\nexport class BaseElementNode<P extends BaseElementProps> extends ElementNode {\n __props: P | undefined;\n __base: BaseNodeHelper<P>;\n\n constructor(props?: P & { key?: string }) {\n const { key, ...restProps } = props || {};\n super(key);\n this.__props = restProps as P;\n this.__base = new BaseNodeHelper<P>(this.__props, {\n remove: () => super.remove(),\n replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren),\n });\n Object.keys(this.__base.hooks).forEach((key) => {\n const method = this.__base.hooks[key as keyof typeof this.__base.hooks];\n if (typeof method === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this[key as keyof this] = method.bind(this.__base) as any;\n }\n });\n }\n\n canBeEmpty(): boolean {\n return this.__props?.canBeEmpty ?? false;\n }\n\n canInsertTextBefore(): boolean {\n return this.__props?.canInsertTextBefore ?? true;\n }\n\n canInsertTextAfter(): boolean {\n return this.__props?.canInsertTextAfter ?? true;\n }\n\n /**\n * - EN: Strip element-specific flags and return DOM props.\n * - CN: 去除元素特有的标记并返回 DOM 属性。\n *\n * @param props Element props including flags | 含标记的元素属性\n */\n getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseElementProps> {\n const baseProps = this.__base.getUnderlyingProps(props ?? ({} as P));\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { canBeEmpty, canInsertTextBefore, canInsertTextAfter, ...restProps } = baseProps;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n\n/**\n * - EN: Base decorator node with behavior flags.\n * - CN: 带行为标记的基础装饰器节点。\n */\nexport class BaseDecoratorNode<T, P extends BaseDecoratorNodeProps> extends DecoratorNode<T> {\n __props: P | undefined;\n __base: BaseNodeHelper<P>;\n\n constructor(props?: P & { key?: string }) {\n const { key, ...restProps } = props || {};\n super(key);\n this.__props = restProps as P;\n\n this.__base = new BaseNodeHelper<P>(this.__props, {\n remove: () => super.remove(),\n replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren),\n });\n Object.keys(this.__base.hooks).forEach((key) => {\n const method = this.__base.hooks[key as keyof typeof this.__base.hooks];\n if (typeof method === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this[key as keyof this] = method.bind(this.__base) as any;\n }\n });\n }\n\n /**\n * - EN: Strip decorator-specific flags and return DOM props.\n * - CN: 去除装饰器特有的标记并返回 DOM 属性。\n *\n * @param props Decorator props including flags | 含标记的装饰器属性\n */\n getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseDecoratorNodeProps> {\n const baseProps = this.__base.getUnderlyingProps(props ?? ({} as P));\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { ...restProps } = baseProps;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAA2C;AAiDpC,IAAM,iBAAN,MAA8C;AAAA,EAInD,YAAY,OAAsB,cAAuD;AAKzF,iBAAQ;AAAA,MACN,QAAQ,CAAC,wBAAwC;AA5DrD;AA6DM,cAAI,UAAK,YAAL,mBAAc,kBAAiB,OAAO;AACxC;AAAA,QACF;AACA,aAAK,eAAe,OAAO,mBAAmB;AAAA,MAChD;AAAA,MAEA,SAAS,CAAwB,aAAgB,oBAAiC;AAnEtF;AAoEM,cAAI,UAAK,YAAL,mBAAc,mBAAkB,OAAO;AACzC,iBAAO;AAAA,QACT;AACA,eAAO,KAAK,eAAe,QAAQ,aAAa,eAAe;AAAA,MACjE;AAAA,IACF;AAlBE,SAAK,UAAU;AACf,SAAK,iBAAiB;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBA,mBAAmB,OAAwD;AAEzE,UAAM,EAAE,cAAc,eAAe,GAAG,UAAU,IAAI;AAEtD,WAAO;AAAA,EACT;AACF;AAMO,IAAM,kBAAN,cAA0D,2BAAY;AAAA,EAI3E,YAAY,OAA8B;AACxC,UAAM,EAAE,KAAK,GAAG,UAAU,IAAI,SAAS,CAAC;AACxC,UAAM,GAAG;AACT,SAAK,UAAU;AACf,SAAK,SAAS,IAAI,eAAkB,KAAK,SAAS;AAAA,MAChD,QAAQ,MAAM,MAAM,OAAO;AAAA,MAC3B,SAAS,CAAC,aAAa,oBAAoB,MAAM,QAAQ,aAAa,eAAe;AAAA,IACvF,CAAC;AACD,WAAO,KAAK,KAAK,OAAO,KAAK,EAAE,QAAQ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,OAA6D;AAC9E,UAAM,YAAY,KAAK,OAAO,mBAAmB,SAAU,CAAC,CAAO;AAEnE,UAAM,EAAE,GAAG,UAAU,IAAI;AAEzB,WAAO;AAAA,EACT;AACF;",
4
+ "sourcesContent": ["import type { LexicalNode } from 'lexical';\nimport { DecoratorNode, ElementNode } from 'lexical';\n\n/**\n * - EN: Common behavior flags for custom nodes.\n * - CN: 自定义节点的通用行为标记。\n */\nexport interface BaseNodeProps {\n /**\n * - EN: Whether the node can be removed. Default `true`.\n * - CN: 是否可被删除,默认 `true`。\n */\n canBeRemoved?: boolean;\n /**\n * - EN: Whether the node can be replaced. Default `true`.\n * - CN: 是否可被替换,默认 `true`。\n */\n canBeReplaced?: boolean;\n}\n/**\n * - EN: Extra behavior flags for element nodes.\n * - CN: 元素节点的附加行为标记。\n */\nexport interface BaseElementProps extends BaseNodeProps {\n /**\n * - EN: Whether an element is allowed to be empty. Default `false`.\n * - CN: 是否允许节点为空,默认 `false`。\n */\n canBeEmpty?: boolean;\n /**\n * - EN: Allow inserting text at the start of the element. Default `true`.\n * - CN: 是否允许在节点内的起始位置插入文本,默认 `true`。\n */\n canInsertTextBefore?: boolean;\n /**\n * - EN: Allow inserting text at the end of the element. Default `true`.\n * - CN: 是否允许在节点内的结束位置插入文本,默认 `true`。\n */\n canInsertTextAfter?: boolean;\n}\n\nexport type BaseDecoratorNodeProps = BaseNodeProps;\n\n/**\n * - EN: A helper wrapping base behaviors (remove/replace) with guard flags.\n * - CN: 封装基础行为(删除/替换)并根据标记进行限制的帮助器。\n *\n * @param props Node behavior flags | 节点行为标记\n * @param superMethods Methods delegated to the underlying node | 委托给底层节点的方法\n */\nexport class BaseNodeHelper<P extends BaseNodeProps> {\n __props: (P & BaseNodeProps) | undefined;\n __superMethods: Pick<LexicalNode, 'replace' | 'remove'>;\n\n constructor(props: P | undefined, superMethods: Pick<LexicalNode, 'replace' | 'remove'>) {\n this.__props = props as P & BaseNodeProps;\n this.__superMethods = superMethods;\n }\n\n hooks = {\n remove: (preserveEmptyParent?: boolean): void => {\n if (this.__props?.canBeRemoved === false) {\n return;\n }\n this.__superMethods.remove(preserveEmptyParent);\n },\n\n replace: <N extends LexicalNode>(replaceWith: N, includeChildren?: boolean): N => {\n if (this.__props?.canBeReplaced === false) {\n return this as unknown as N;\n }\n return this.__superMethods.replace(replaceWith, includeChildren);\n },\n };\n /**\n * - EN: Strip helper-only flags from props for DOM usage.\n * - CN: 去除仅用于帮助器的标记属性,得到用于 DOM 的纯属性。\n *\n * @param props Props including helper flags | 含帮助标记的属性\n */\n getUnderlyingProps(props: P & BaseNodeProps): Omit<P, keyof BaseNodeProps> {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { canBeRemoved, canBeReplaced, ...restProps } = props;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n\n/**\n * - EN: Base element node with behavior flags.\n * - CN: 带行为标记的基础元素节点。\n */\nexport class BaseElementNode<P extends BaseElementProps> extends ElementNode {\n __props: P | undefined;\n __base: BaseNodeHelper<P>;\n\n constructor(props?: P & { key?: string }) {\n const { key, ...restProps } = props || {};\n super(key);\n this.__props = restProps as P;\n this.__base = new BaseNodeHelper<P>(this.__props, {\n remove: () => super.remove(),\n replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren),\n });\n Object.keys(this.__base.hooks).forEach((key) => {\n const method = this.__base.hooks[key as keyof typeof this.__base.hooks];\n if (typeof method === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this[key as keyof this] = method.bind(this.__base) as any;\n }\n });\n }\n\n canBeEmpty(): boolean {\n return this.__props?.canBeEmpty ?? false;\n }\n\n canInsertTextBefore(): boolean {\n return this.__props?.canInsertTextBefore ?? true;\n }\n\n canInsertTextAfter(): boolean {\n return this.__props?.canInsertTextAfter ?? true;\n }\n\n getProp(propName: keyof P): P[typeof propName] {\n return this.__props?.[propName] as P[typeof propName];\n }\n\n updateProps(props: Partial<P>): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props!,\n ...props,\n };\n }\n\n /**\n * - EN: Strip element-specific flags and return DOM props.\n * - CN: 去除元素特有的标记并返回 DOM 属性。\n *\n * @param props Element props including flags | 含标记的元素属性\n */\n getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseElementProps> {\n const baseProps = this.__base.getUnderlyingProps(props ?? ({} as P));\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { canBeEmpty, canInsertTextBefore, canInsertTextAfter, ...restProps } = baseProps;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n\n/**\n * - EN: Base decorator node with behavior flags.\n * - CN: 带行为标记的基础装饰器节点。\n */\nexport class BaseDecoratorNode<T, P extends BaseDecoratorNodeProps> extends DecoratorNode<T> {\n __props: P | undefined;\n __base: BaseNodeHelper<P>;\n\n constructor(props?: P & { key?: string }) {\n const { key, ...restProps } = props || {};\n super(key);\n this.__props = restProps as P;\n\n this.__base = new BaseNodeHelper<P>(this.__props, {\n remove: () => super.remove(),\n replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren),\n });\n Object.keys(this.__base.hooks).forEach((key) => {\n const method = this.__base.hooks[key as keyof typeof this.__base.hooks];\n if (typeof method === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this[key as keyof this] = method.bind(this.__base) as any;\n }\n });\n }\n getProp(propName: keyof P): P[typeof propName] {\n return this.__props?.[propName] as P[typeof propName];\n }\n\n updateProps(props: Partial<P>): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props!,\n ...props,\n };\n }\n\n /**\n * - EN: Strip decorator-specific flags and return DOM props.\n * - CN: 去除装饰器特有的标记并返回 DOM 属性。\n *\n * @param props Decorator props including flags | 含标记的装饰器属性\n */\n getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseDecoratorNodeProps> {\n const baseProps = this.__base.getUnderlyingProps(props ?? ({} as P));\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { ...restProps } = baseProps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AAAA,MACnD;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EACA,QAAQ,UAAuC;AAjLjD;AAkLI,YAAO,UAAK,YAAL,mBAAe;AAAA,EACxB;AAAA,EAEA,YAAY,OAAyB;AACnC,UAAM,WAAW,KAAK,YAAY;AAClC,aAAS,UAAU;AAAA,MACjB,GAAG,SAAS;AAAA,MACZ,GAAG;AAAA,IACL;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,mBAAmB,OAA6D;AAC9E,UAAM,YAAY,KAAK,OAAO,mBAAmB,SAAU,CAAC,CAAO;AAEnE,UAAM,EAAE,GAAG,UAAU,IAAI;AAEzB,WAAO;AAAA,EACT;AACF;",
6
6
  "names": ["key"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiny-codes/react-easy",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "Simplify React and AntDesign development with practical components and hooks",
5
5
  "keywords": [
6
6
  "react",