@tiny-codes/react-easy 1.4.0 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/es/components/FormItemControl/index.d.ts +7 -7
  3. package/es/components/FormItemControl/index.js +6 -6
  4. package/es/components/FormItemControl/index.js.map +1 -1
  5. package/es/components/Lexical/helpers/index.d.ts +39 -24
  6. package/es/components/Lexical/helpers/index.js +63 -24
  7. package/es/components/Lexical/helpers/index.js.map +1 -1
  8. package/es/components/Lexical/index.d.ts +1 -0
  9. package/es/components/Lexical/index.js +1 -0
  10. package/es/components/Lexical/index.js.map +1 -1
  11. package/es/components/Lexical/nodes/CloseIcon.d.ts +71 -0
  12. package/es/components/Lexical/nodes/CloseIcon.js +176 -0
  13. package/es/components/Lexical/nodes/CloseIcon.js.map +1 -0
  14. package/es/components/Lexical/nodes/DivNode.d.ts +20 -0
  15. package/es/components/Lexical/nodes/DivNode.js +32 -4
  16. package/es/components/Lexical/nodes/DivNode.js.map +1 -1
  17. package/es/components/Lexical/nodes/ExtendTextNode.d.ts +23 -1
  18. package/es/components/Lexical/nodes/ExtendTextNode.js +38 -6
  19. package/es/components/Lexical/nodes/ExtendTextNode.js.map +1 -1
  20. package/es/components/Lexical/nodes/SelectNode.d.ts +39 -9
  21. package/es/components/Lexical/nodes/SelectNode.js +42 -7
  22. package/es/components/Lexical/nodes/SelectNode.js.map +1 -1
  23. package/es/components/Lexical/nodes/base.d.ts +59 -8
  24. package/es/components/Lexical/nodes/base.js +50 -1
  25. package/es/components/Lexical/nodes/base.js.map +1 -1
  26. package/es/utils/index.d.ts +1 -0
  27. package/es/utils/index.js +1 -0
  28. package/es/utils/index.js.map +1 -1
  29. package/es/utils/string.d.ts +7 -0
  30. package/es/utils/string.js +15 -0
  31. package/es/utils/string.js.map +1 -0
  32. package/lib/components/FormItemControl/index.d.ts +7 -7
  33. package/lib/components/FormItemControl/index.js.map +1 -1
  34. package/lib/components/Lexical/helpers/index.d.ts +39 -24
  35. package/lib/components/Lexical/helpers/index.js +26 -0
  36. package/lib/components/Lexical/helpers/index.js.map +2 -2
  37. package/lib/components/Lexical/index.d.ts +1 -0
  38. package/lib/components/Lexical/index.js +3 -1
  39. package/lib/components/Lexical/index.js.map +2 -2
  40. package/lib/components/Lexical/nodes/CloseIcon.d.ts +71 -0
  41. package/lib/components/Lexical/nodes/CloseIcon.js +149 -0
  42. package/lib/components/Lexical/nodes/CloseIcon.js.map +7 -0
  43. package/lib/components/Lexical/nodes/DivNode.d.ts +20 -0
  44. package/lib/components/Lexical/nodes/DivNode.js +1 -1
  45. package/lib/components/Lexical/nodes/DivNode.js.map +2 -2
  46. package/lib/components/Lexical/nodes/ExtendTextNode.d.ts +23 -1
  47. package/lib/components/Lexical/nodes/ExtendTextNode.js +9 -1
  48. package/lib/components/Lexical/nodes/ExtendTextNode.js.map +2 -2
  49. package/lib/components/Lexical/nodes/SelectNode.d.ts +39 -9
  50. package/lib/components/Lexical/nodes/SelectNode.js +2 -2
  51. package/lib/components/Lexical/nodes/SelectNode.js.map +2 -2
  52. package/lib/components/Lexical/nodes/base.d.ts +59 -8
  53. package/lib/components/Lexical/nodes/base.js +18 -0
  54. package/lib/components/Lexical/nodes/base.js.map +2 -2
  55. package/lib/utils/index.d.ts +1 -0
  56. package/lib/utils/index.js +3 -1
  57. package/lib/utils/index.js.map +2 -2
  58. package/lib/utils/string.d.ts +7 -0
  59. package/lib/utils/string.js +37 -0
  60. package/lib/utils/string.js.map +7 -0
  61. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## 1.4.2
6
+
7
+ 2025-8-10
8
+
9
+ ### Features
10
+
11
+ - ✨ `SelectNode` component now supports `onXXX` event props like `onClick`, `onMouseEnter`, etc.
12
+
13
+ ## 1.4.1
14
+
15
+ 2025-8-10
16
+
17
+ ### Features
18
+
19
+ - 🔥 Add `CloseIcon` component for `Lexical`.
20
+
5
21
  ## 1.4.0
6
22
 
7
23
  2025-8-7
@@ -2,16 +2,16 @@ import type { FC, ReactNode } from 'react';
2
2
  export interface FormItemControlProps {
3
3
  children: (options: {
4
4
  value: any;
5
- onChange?: (value: any) => void;
5
+ onChange: (value: any) => void;
6
6
  }) => ReactNode;
7
7
  }
8
8
  /**
9
- * - **EN:** FormItemControl is a component that wraps custom content into a valid Form.Item control.
10
- * It provides a value and an onChange function to the children, allowing them to interact with
11
- * the form state. This is useful for creating custom form controls that need to integrate with
12
- * Ant Design's Form.Item.
13
- * - **CN:** FormItemControl 是一个将自定义内容包装成有效的 Form.Item 控件的组件。它向子组件提供了一个 `value` 和一个 `onChange`
14
- * 函数,使得子组件能够与表单状态进行交互。 这对于创建需要与 Ant Design 的 `Form.Item` 集成的自定义表单控件非常有用。
9
+ * - **EN:** FormItemControl is a component that wraps custom content into a valid Form.Item control,
10
+ * and must be used as a direct child of Form.Item. It provides its children with a `value` and an
11
+ * `onChange` function, allowing them to interact with the form state. This is useful for creating
12
+ * custom form controls that need to integrate with Ant Design's Form.Item.
13
+ * - **CN:** FormItemControl 是一个将自定义内容包装成有效的 Form.Item 控件的组件,必须作为 Form.Item 的直接子节点使用。它向子组件提供了一个
14
+ * `value` 和一个 `onChange` 函数,使得子组件能够与表单状态进行交互。这对于创建需要与 Ant Design 的 `Form.Item` 集成的自定义表单控件非常有用。
15
15
  */
16
16
  declare const FormItemControl: FC<FormItemControlProps>;
17
17
  export default FormItemControl;
@@ -1,10 +1,10 @@
1
1
  /**
2
- * - **EN:** FormItemControl is a component that wraps custom content into a valid Form.Item control.
3
- * It provides a value and an onChange function to the children, allowing them to interact with
4
- * the form state. This is useful for creating custom form controls that need to integrate with
5
- * Ant Design's Form.Item.
6
- * - **CN:** FormItemControl 是一个将自定义内容包装成有效的 Form.Item 控件的组件。它向子组件提供了一个 `value` 和一个 `onChange`
7
- * 函数,使得子组件能够与表单状态进行交互。 这对于创建需要与 Ant Design 的 `Form.Item` 集成的自定义表单控件非常有用。
2
+ * - **EN:** FormItemControl is a component that wraps custom content into a valid Form.Item control,
3
+ * and must be used as a direct child of Form.Item. It provides its children with a `value` and an
4
+ * `onChange` function, allowing them to interact with the form state. This is useful for creating
5
+ * custom form controls that need to integrate with Ant Design's Form.Item.
6
+ * - **CN:** FormItemControl 是一个将自定义内容包装成有效的 Form.Item 控件的组件,必须作为 Form.Item 的直接子节点使用。它向子组件提供了一个
7
+ * `value` 和一个 `onChange` 函数,使得子组件能够与表单状态进行交互。这对于创建需要与 Ant Design 的 `Form.Item` 集成的自定义表单控件非常有用。
8
8
  */
9
9
  var FormItemControl = function FormItemControl(props) {
10
10
  // eslint-disable-next-line react/prop-types
@@ -1 +1 @@
1
- {"version":3,"names":["FormItemControl","props","_ref","children","value","onChange"],"sources":["../../../src/components/FormItemControl/index.tsx"],"sourcesContent":["import type { FC, ReactNode } from 'react';\n\nexport interface FormItemControlProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n children: (options: { value: any; onChange?: (value: any) => void }) => ReactNode;\n}\n\n/**\n * - **EN:** FormItemControl is a component that wraps custom content into a valid Form.Item control.\n * It provides a value and an onChange function to the children, allowing them to interact with\n * the form state. This is useful for creating custom form controls that need to integrate with\n * Ant Design's Form.Item.\n * - **CN:** FormItemControl 是一个将自定义内容包装成有效的 Form.Item 控件的组件。它向子组件提供了一个 `value` 和一个 `onChange`\n * 函数,使得子组件能够与表单状态进行交互。 这对于创建需要与 Ant Design 的 `Form.Item` 集成的自定义表单控件非常有用。\n */\nconst FormItemControl: FC<FormItemControlProps> = (props) => {\n // eslint-disable-next-line react/prop-types\n const { children, value, onChange } = props as FormItemControlProps & {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value?: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange?: (value: any) => void;\n };\n\n return children({ value, onChange });\n};\n\nexport default FormItemControl;\n"],"mappings":"AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMA,eAAyC,GAAG,SAA5CA,eAAyCA,CAAIC,KAAK,EAAK;EAC3D;EACA,IAAAC,IAAA,GAAsCD,KAAK;IAAnCE,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAEC,KAAK,GAAAF,IAAA,CAALE,KAAK;IAAEC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;EAOjC,OAAOF,QAAQ,CAAC;IAAEC,KAAK,EAALA,KAAK;IAAEC,QAAQ,EAARA;EAAS,CAAC,CAAC;AACtC,CAAC;AAED,eAAeL,eAAe"}
1
+ {"version":3,"names":["FormItemControl","props","_ref","children","value","onChange"],"sources":["../../../src/components/FormItemControl/index.tsx"],"sourcesContent":["import type { FC, ReactNode } from 'react';\n\nexport interface FormItemControlProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n children: (options: { value: any; onChange: (value: any) => void }) => ReactNode;\n}\n\n/**\n * - **EN:** FormItemControl is a component that wraps custom content into a valid Form.Item control,\n * and must be used as a direct child of Form.Item. It provides its children with a `value` and an\n * `onChange` function, allowing them to interact with the form state. This is useful for creating\n * custom form controls that need to integrate with Ant Design's Form.Item.\n * - **CN:** FormItemControl 是一个将自定义内容包装成有效的 Form.Item 控件的组件,必须作为 Form.Item 的直接子节点使用。它向子组件提供了一个\n * `value` 和一个 `onChange` 函数,使得子组件能够与表单状态进行交互。这对于创建需要与 Ant Design 的 `Form.Item` 集成的自定义表单控件非常有用。\n */\nconst FormItemControl: FC<FormItemControlProps> = (props) => {\n // eslint-disable-next-line react/prop-types\n const { children, value, onChange } = props as FormItemControlProps & {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (value: any) => void;\n };\n\n return children({ value, onChange });\n};\n\nexport default FormItemControl;\n"],"mappings":"AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMA,eAAyC,GAAG,SAA5CA,eAAyCA,CAAIC,KAAK,EAAK;EAC3D;EACA,IAAAC,IAAA,GAAsCD,KAAK;IAAnCE,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAEC,KAAK,GAAAF,IAAA,CAALE,KAAK;IAAEC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;EAOjC,OAAOF,QAAQ,CAAC;IAAEC,KAAK,EAALA,KAAK;IAAEC,QAAQ,EAARA;EAAS,CAAC,CAAC;AACtC,CAAC;AAED,eAAeL,eAAe"}
@@ -1,58 +1,73 @@
1
1
  import type { CSSProperties, HtmlHTMLAttributes } from 'react';
2
2
  import type { LexicalEditor, LexicalNode } from 'lexical';
3
3
  /**
4
- * 将节点插入到当前光标位置
4
+ * - EN: Insert a node at the current cursor position.
5
+ * - CN: 将节点插入到当前光标位置。
5
6
  *
6
- * @param editor LexicalEditor 实例
7
- * @param node 要插入的节点
7
+ * @param editor LexicalEditor instance | LexicalEditor 实例
8
+ * @param node Node to insert | 要插入的节点
8
9
  */
9
10
  export declare function insertNodeAtCursor(editor: LexicalEditor, node: LexicalNode): void;
10
11
  /**
11
- * 将文本插入到当前光标位置
12
+ * - EN: Insert text at the current cursor position.
13
+ * - CN: 将文本插入到当前光标位置。
12
14
  *
13
- * @param editor LexicalEditor 实例
14
- * @param text 要插入的文本
15
+ * @param editor LexicalEditor instance | LexicalEditor 实例
16
+ * @param text Text to insert | 要插入的文本
15
17
  */
16
18
  export declare function insertTextAtCursor(editor: LexicalEditor, text: string): void;
17
19
  /**
18
- * 清空编辑器内容
20
+ * - EN: Clear the editor content.
21
+ * - CN: 清空编辑器内容。
19
22
  *
20
- * @param editor LexicalEditor 实例
23
+ * @param editor LexicalEditor instance | LexicalEditor 实例
21
24
  */
22
25
  export declare function clearEditorContent(editor: LexicalEditor): void;
23
26
  /**
24
- * 查找符合条件的节点
27
+ * - EN: Find the first node that matches the predicate.
28
+ * - CN: 查找第一个符合条件的节点。
25
29
  *
26
- * @param editor LexicalEditor 实例
27
- * @param predicate 用于匹配节点的函数
28
- * @param options 选项
30
+ * @param editor LexicalEditor instance | LexicalEditor 实例
31
+ * @param predicate Function to test whether a node matches | 用于匹配节点的函数
29
32
  *
30
- * @returns 符合条件的节点数组
33
+ * @returns The matched node, or undefined | 符合条件的第一个节点,或 undefined
31
34
  */
32
35
  export declare function findNode<T extends LexicalNode>(editor: LexicalEditor, predicate: (node: LexicalNode) => boolean): T | undefined;
33
36
  /**
34
- * 查找所有符合条件的节点数组
37
+ * - EN: Find all nodes that match the predicate.
38
+ * - CN: 查找所有符合条件的节点数组。
35
39
  *
36
- * @param editor LexicalEditor 实例
37
- * @param predicate 用于匹配节点的函数
38
- * @param options 选项
40
+ * @param editor LexicalEditor instance | LexicalEditor 实例
41
+ * @param predicate Function to test whether a node matches | 用于匹配节点的函数
42
+ * @param options Options | 选项
39
43
  *
40
- * @returns 符合条件的节点数组
44
+ * @returns An array of matched nodes | 符合条件的节点数组
41
45
  */
42
46
  export declare function findNodes<T extends LexicalNode>(editor: LexicalEditor, predicate: (node: LexicalNode) => boolean, options?: {
43
47
  stopOnFirstMatch?: boolean;
44
48
  }): T[];
45
49
  /**
46
- * 更新 DOM 元素的属性
50
+ * - EN: Update properties on a DOM element.
51
+ * - CN: 更新 DOM 元素的属性。
47
52
  *
48
- * @param dom 要更新的 DOM 元素
49
- * @param props 要设置的属性
53
+ * @param dom Target DOM element to update | 要更新的 DOM 元素
54
+ * @param props Props to set on the element | 要设置的属性
50
55
  */
51
56
  export declare function updateDomProps(dom: HTMLElement | undefined, props: HtmlHTMLAttributes<HTMLElement>): void;
52
57
  /**
53
- * 更新 DOM 元素的样式
58
+ * - EN: Update style on a DOM element.
59
+ * - CN: 更新 DOM 元素的样式。
54
60
  *
55
- * @param dom 要更新的 DOM 元素
56
- * @param style 要设置的样式
61
+ * @param dom Target DOM element to update | 要更新的 DOM 元素
62
+ * @param style Style to set | 要设置的样式
57
63
  */
58
64
  export declare function updateDomStyle(dom: HTMLElement | undefined, style: CSSProperties | undefined): void;
65
+ /**
66
+ * - EN: Get attributes from a DOM element.
67
+ * - CN: 从 DOM 元素获取属性。
68
+ *
69
+ * @param dom Target DOM element | 目标 DOM 元素
70
+ *
71
+ * @returns Element attributes | 元素属性
72
+ */
73
+ export declare function getDomAttributes(dom: HTMLElement | undefined): HtmlHTMLAttributes<HTMLElement> | undefined;
@@ -15,10 +15,11 @@ import { $createTextNode, $getRoot, $getSelection, $isDecoratorNode, $isElementN
15
15
  import { $createDivNode, $isDivNode } from "../nodes/DivNode";
16
16
 
17
17
  /**
18
- * 将节点插入到当前光标位置
18
+ * - EN: Insert a node at the current cursor position.
19
+ * - CN: 将节点插入到当前光标位置。
19
20
  *
20
- * @param editor LexicalEditor 实例
21
- * @param node 要插入的节点
21
+ * @param editor LexicalEditor instance | LexicalEditor 实例
22
+ * @param node Node to insert | 要插入的节点
22
23
  */
23
24
  export function insertNodeAtCursor(editor, node) {
24
25
  editor.update(function () {
@@ -65,10 +66,11 @@ export function insertNodeAtCursor(editor, node) {
65
66
  }
66
67
 
67
68
  /**
68
- * 将文本插入到当前光标位置
69
+ * - EN: Insert text at the current cursor position.
70
+ * - CN: 将文本插入到当前光标位置。
69
71
  *
70
- * @param editor LexicalEditor 实例
71
- * @param text 要插入的文本
72
+ * @param editor LexicalEditor instance | LexicalEditor 实例
73
+ * @param text Text to insert | 要插入的文本
72
74
  */
73
75
  export function insertTextAtCursor(editor, text) {
74
76
  editor === null || editor === void 0 || editor.update(function () {
@@ -97,9 +99,10 @@ export function insertTextAtCursor(editor, text) {
97
99
  }
98
100
 
99
101
  /**
100
- * 清空编辑器内容
102
+ * - EN: Clear the editor content.
103
+ * - CN: 清空编辑器内容。
101
104
  *
102
- * @param editor LexicalEditor 实例
105
+ * @param editor LexicalEditor instance | LexicalEditor 实例
103
106
  */
104
107
  export function clearEditorContent(editor) {
105
108
  var state = editor.getEditorState();
@@ -128,13 +131,13 @@ export function clearEditorContent(editor) {
128
131
  }
129
132
 
130
133
  /**
131
- * 查找符合条件的节点
134
+ * - EN: Find the first node that matches the predicate.
135
+ * - CN: 查找第一个符合条件的节点。
132
136
  *
133
- * @param editor LexicalEditor 实例
134
- * @param predicate 用于匹配节点的函数
135
- * @param options 选项
137
+ * @param editor LexicalEditor instance | LexicalEditor 实例
138
+ * @param predicate Function to test whether a node matches | 用于匹配节点的函数
136
139
  *
137
- * @returns 符合条件的节点数组
140
+ * @returns The matched node, or undefined | 符合条件的第一个节点,或 undefined
138
141
  */
139
142
  export function findNode(editor, predicate) {
140
143
  var matched = findNodes(editor, predicate, {
@@ -143,13 +146,14 @@ export function findNode(editor, predicate) {
143
146
  return matched[0];
144
147
  }
145
148
  /**
146
- * 查找所有符合条件的节点数组
149
+ * - EN: Find all nodes that match the predicate.
150
+ * - CN: 查找所有符合条件的节点数组。
147
151
  *
148
- * @param editor LexicalEditor 实例
149
- * @param predicate 用于匹配节点的函数
150
- * @param options 选项
152
+ * @param editor LexicalEditor instance | LexicalEditor 实例
153
+ * @param predicate Function to test whether a node matches | 用于匹配节点的函数
154
+ * @param options Options | 选项
151
155
  *
152
- * @returns 符合条件的节点数组
156
+ * @returns An array of matched nodes | 符合条件的节点数组
153
157
  */
154
158
  export function findNodes(editor, predicate, options) {
155
159
  var matched = [];
@@ -187,10 +191,11 @@ export function findNodes(editor, predicate, options) {
187
191
  }
188
192
 
189
193
  /**
190
- * 更新 DOM 元素的属性
194
+ * - EN: Update properties on a DOM element.
195
+ * - CN: 更新 DOM 元素的属性。
191
196
  *
192
- * @param dom 要更新的 DOM 元素
193
- * @param props 要设置的属性
197
+ * @param dom Target DOM element to update | 要更新的 DOM 元素
198
+ * @param props Props to set on the element | 要设置的属性
194
199
  */
195
200
  export function updateDomProps(dom, props) {
196
201
  if (!dom) return;
@@ -218,6 +223,8 @@ export function updateDomProps(dom, props) {
218
223
  });
219
224
  } else if (key === 'className' && value) {
220
225
  dom.className = value;
226
+ } else if (key.startsWith('on') && typeof value === 'function') {
227
+ dom[key.toLowerCase()] = value;
221
228
  } else if (value !== undefined && value !== null) {
222
229
  dom.setAttribute(key, value.toString());
223
230
  }
@@ -226,10 +233,11 @@ export function updateDomProps(dom, props) {
226
233
  }
227
234
 
228
235
  /**
229
- * 更新 DOM 元素的样式
236
+ * - EN: Update style on a DOM element.
237
+ * - CN: 更新 DOM 元素的样式。
230
238
  *
231
- * @param dom 要更新的 DOM 元素
232
- * @param style 要设置的样式
239
+ * @param dom Target DOM element to update | 要更新的 DOM 元素
240
+ * @param style Style to set | 要设置的样式
233
241
  */
234
242
  export function updateDomStyle(dom, style) {
235
243
  if (!dom) return;
@@ -246,4 +254,35 @@ export function updateDomStyle(dom, style) {
246
254
  });
247
255
  }
248
256
  }
257
+
258
+ /**
259
+ * - EN: Get attributes from a DOM element.
260
+ * - CN: 从 DOM 元素获取属性。
261
+ *
262
+ * @param dom Target DOM element | 目标 DOM 元素
263
+ *
264
+ * @returns Element attributes | 元素属性
265
+ */
266
+ export function getDomAttributes(dom) {
267
+ if (!dom) return undefined;
268
+ var attributes = {};
269
+ Array.from(dom.attributes).forEach(function (attr) {
270
+ if (attr.name === 'class' || attr.name === 'style') {
271
+ return;
272
+ }
273
+ attributes[attr.name] = attr.value;
274
+ });
275
+ if (dom.className) {
276
+ attributes.className = dom.className;
277
+ }
278
+ if (dom.style) {
279
+ var styles = {};
280
+ Array.from(dom.style).forEach(function (styleName) {
281
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
282
+ styles[styleName] = dom.style[styleName];
283
+ });
284
+ attributes.style = styles;
285
+ }
286
+ return attributes;
287
+ }
249
288
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["$createTextNode","$getRoot","$getSelection","$isDecoratorNode","$isElementNode","$isParagraphNode","$isRangeSelection","$isTextNode","$createDivNode","$isDivNode","insertNodeAtCursor","editor","node","update","selection","lastNode","focus","getNode","append","insertAfter","insertNodes","selectNext","root","nodeToInsert","container","style","display","insertTextAtCursor","text","textNode","insertText","getLastChild","clearEditorContent","state","getEditorState","stateJson","toJSON","newJson","_objectSpread","children","direction","format","indent","type","version","textFormat","textStyle","emptyState","parseEditorState","JSON","stringify","setEditorState","clear","findNode","predicate","matched","findNodes","stopOnFirstMatch","options","read","traverse","result","push","getChildren","_iterator","_createForOfIteratorHelper","_step","s","n","done","child","value","length","err","e","f","updateDomProps","dom","props","Array","from","attributes","forEach","attr","name","startsWith","removeAttribute","Object","entries","_ref","_ref2","_slicedToArray","key","_ref3","_ref4","styleKey","styleValue","undefined","className","setAttribute","toString","updateDomStyle","_ref5","_ref6"],"sources":["../../../../src/components/Lexical/helpers/index.ts"],"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 * 将节点插入到当前光标位置\n *\n * @param editor LexicalEditor 实例\n * @param node 要插入的节点\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 * 将文本插入到当前光标位置\n *\n * @param editor LexicalEditor 实例\n * @param text 要插入的文本\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 * 清空编辑器内容\n *\n * @param editor 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 * 查找符合条件的节点\n *\n * @param editor LexicalEditor 实例\n * @param predicate 用于匹配节点的函数\n * @param options 选项\n *\n * @returns 符合条件的节点数组\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 * 查找所有符合条件的节点数组\n *\n * @param editor LexicalEditor 实例\n * @param predicate 用于匹配节点的函数\n * @param options 选项\n *\n * @returns 符合条件的节点数组\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 * 更新 DOM 元素的属性\n *\n * @param dom 要更新的 DOM 元素\n * @param props 要设置的属性\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 * 更新 DOM 元素的样式\n *\n * @param dom 要更新的 DOM 元素\n * @param style 要设置的样式\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"],"mappings":";;;;;;;;;;;;;AAEA,SACEA,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,gBAAgB,EAChBC,cAAc,EACdC,gBAAgB,EAChBC,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D,OAAO,CAAC,UAAAoB,KAAA,EAA4B;MAAA,IAAAC,KAAA,GAAAZ,cAAA,CAAAW,KAAA;QAA1BP,QAAQ,GAAAQ,KAAA;QAAEP,UAAU,GAAAO,KAAA;MAClD,IAAIP,UAAU,KAAKC,SAAS,EAAE;QAC5B;QACCpB,GAAG,CAACpD,KAAK,CAASsE,QAAQ,CAAC,GAAGC,UAAU;MAC3C;IACF,CAAC,CAAC;EACJ;AACF"}
1
+ {"version":3,"names":["$createTextNode","$getRoot","$getSelection","$isDecoratorNode","$isElementNode","$isParagraphNode","$isRangeSelection","$isTextNode","$createDivNode","$isDivNode","insertNodeAtCursor","editor","node","update","selection","lastNode","focus","getNode","append","insertAfter","insertNodes","selectNext","root","nodeToInsert","container","style","display","insertTextAtCursor","text","textNode","insertText","getLastChild","clearEditorContent","state","getEditorState","stateJson","toJSON","newJson","_objectSpread","children","direction","format","indent","type","version","textFormat","textStyle","emptyState","parseEditorState","JSON","stringify","setEditorState","clear","findNode","predicate","matched","findNodes","stopOnFirstMatch","options","read","traverse","result","push","getChildren","_iterator","_createForOfIteratorHelper","_step","s","n","done","child","value","length","err","e","f","updateDomProps","dom","props","Array","from","attributes","forEach","attr","name","startsWith","removeAttribute","Object","entries","_ref","_ref2","_slicedToArray","key","_ref3","_ref4","styleKey","styleValue","undefined","className","toLowerCase","setAttribute","toString","updateDomStyle","_ref5","_ref6","getDomAttributes","styles","styleName"],"sources":["../../../../src/components/Lexical/helpers/index.ts"],"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"],"mappings":";;;;;;;;;;;;;AAEA,SACEA,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,gBAAgB,EAChBC,cAAc,EACdC,gBAAgB,EAChBC,iBAAiB,EACjBC,WAAW,QACN,SAAS;AAChB,SAASC,cAAc,EAAEC,UAAU;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,MAAqB,EAAEC,IAAiB,EAAQ;EACjFD,MAAM,CAACE,MAAM,CAAC,YAAM;IAClB,IAAMC,SAAS,GAAGZ,aAAa,CAAC,CAAC;IACjC,IAAIY,SAAS,EAAE;MACb,IAAIR,iBAAiB,CAACQ,SAAS,CAAC,EAAE;QAChC;QACA,IAAMC,QAAQ,GAAGD,SAAS,CAACE,KAAK,CAACC,OAAO,CAAC,CAAC;QAC1C,IAAIF,QAAQ,EAAE;UACZ,IAAIV,gBAAgB,CAACU,QAAQ,CAAC,EAAE;YAC9BA,QAAQ,CAACG,MAAM,CAACN,IAAI,CAAC;UACvB,CAAC,MAAM,IAAIL,WAAW,CAACQ,QAAQ,CAAC,EAAE;YAChC;YACAA,QAAQ,CAACI,WAAW,CAACP,IAAI,CAAC;UAC5B,CAAC,MAAM,IAAIH,UAAU,CAACM,QAAQ,CAAC,EAAE;YAC/BA,QAAQ,CAACG,MAAM,CAACN,IAAI,CAAC;UACvB,CAAC,MAAM;YACLE,SAAS,CAACM,WAAW,CAAC,CAACR,IAAI,CAAC,CAAC;UAC/B;UACAA,IAAI,CAACS,UAAU,CAAC,CAAC;QACnB;MACF,CAAC,MAAM;QACLP,SAAS,CAACM,WAAW,CAAC,CAACR,IAAI,CAAC,CAAC;QAC7BA,IAAI,CAACS,U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AEF,IAAIM,GAAG,CAACqB,SAAS,EAAE;IACjBjB,UAAU,CAACiB,SAAS,GAAGrB,GAAG,CAACqB,SAAS;EACtC;EAEA,IAAIrB,GAAG,CAACpD,KAAK,EAAE;IACb,IAAMiF,MAAqB,GAAG,CAAC,CAAC;IAChC3B,KAAK,CAACC,IAAI,CAACH,GAAG,CAACpD,KAAK,CAAC,CAACyD,OAAO,CAAC,UAACyB,SAAS,EAAK;MAC3C;MACCD,MAAM,CAASC,SAAS,CAAC,GAAI9B,GAAG,CAACpD,KAAK,CAASkF,SAAS,CAAC;IAC5D,CAAC,CAAC;IACF1B,UAAU,CAACxD,KAAK,GAAGiF,MAAM;EAC3B;EAEA,OAAOzB,UAAU;AACnB"}
@@ -3,3 +3,4 @@ export * from './nodes/base';
3
3
  export * from './nodes/DivNode';
4
4
  export * from './nodes/SelectNode';
5
5
  export * from './nodes/ExtendTextNode';
6
+ export * from './nodes/CloseIcon';
@@ -3,4 +3,5 @@ export * from "./nodes/base";
3
3
  export * from "./nodes/DivNode";
4
4
  export * from "./nodes/SelectNode";
5
5
  export * from "./nodes/ExtendTextNode";
6
+ export * from "./nodes/CloseIcon";
6
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../../src/components/Lexical/index.ts"],"sourcesContent":["export * from './helpers';\nexport * from './nodes/base';\nexport * from './nodes/DivNode';\nexport * from './nodes/SelectNode';\nexport * from './nodes/ExtendTextNode';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"names":[],"sources":["../../../src/components/Lexical/index.ts"],"sourcesContent":["export * from './helpers';\nexport * from './nodes/base';\nexport * from './nodes/DivNode';\nexport * from './nodes/SelectNode';\nexport * from './nodes/ExtendTextNode';\nexport * from './nodes/CloseIcon';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA"}
@@ -0,0 +1,71 @@
1
+ import { type CSSProperties, type HtmlHTMLAttributes, type ReactNode } from 'react';
2
+ import type { LexicalNode, SerializedLexicalNode, Spread } from 'lexical';
3
+ import type { BaseDecoratorNodeProps, BaseNodeProps } from './base';
4
+ import { BaseDecoratorNode } from './base';
5
+ export interface CloseIconNodeProps extends HtmlHTMLAttributes<HTMLSpanElement>, BaseDecoratorNodeProps {
6
+ /**
7
+ * - EN: Parent element class name, used to add positioning styles to the parent element.
8
+ * - CN: 父元素的类名,用于给父元素添加定位样式
9
+ */
10
+ parentClassName: string;
11
+ /**
12
+ * - EN: The custom icon to display, optional
13
+ * - CN: 要显示的自定义图标,可选
14
+ */
15
+ icon?: ReactNode;
16
+ /**
17
+ * - EN: The default class name for the close icon element. This property is invalid if `icon` is
18
+ * set.
19
+ * - CN: 默认关闭图标元素的类名,如果设置了 `icon` 则该属性无效
20
+ */
21
+ iconClassName?: string;
22
+ /**
23
+ * - EN: The custom style for the close icon element. This property is invalid if `icon` is set.
24
+ * - CN: 自定义关闭图标元素的样式,如果设置了 `icon` 则该属性无效
25
+ */
26
+ iconStyle?: CSSProperties;
27
+ /**
28
+ * - EN: The click event handler for the close icon element.
29
+ * - CN: 关闭图标元素的点击事件
30
+ */
31
+ onClick?: (e: React.MouseEvent<HTMLSpanElement>) => void;
32
+ }
33
+ /**
34
+ * - EN: A node that represents a close icon.
35
+ * - CN: 一个关闭图标的节点。
36
+ */
37
+ export declare class CloseIconNode extends BaseDecoratorNode<ReactNode, CloseIconNodeProps> {
38
+ __hashId: string;
39
+ constructor(props: CloseIconNodeProps & {
40
+ key?: string;
41
+ });
42
+ static getType(): string;
43
+ static clone(node: CloseIconNode): CloseIconNode;
44
+ static importJSON(serializedNode: SerializedCloseIconNode): CloseIconNode;
45
+ exportJSON(): SerializedCloseIconNode;
46
+ createDOM(): HTMLElement;
47
+ updateDOM(): boolean;
48
+ decorate(): ReactNode;
49
+ isInline(): boolean;
50
+ getPropValue(propName: keyof CloseIconNodeProps): CloseIconNodeProps[typeof propName];
51
+ setProps(props: Partial<CloseIconNodeProps>): void;
52
+ getUnderlyingProps(props: CloseIconNodeProps | undefined): Omit<CloseIconNodeProps, keyof BaseNodeProps>;
53
+ }
54
+ /**
55
+ * - EN: Factory to create a CloseIconNode.
56
+ * - CN: 创建 CloseIconNode 的工厂函数。
57
+ *
58
+ * @param props Props for the CloseIcon node | CloseIcon 节点的属性
59
+ */
60
+ export declare function $createCloseIconNode(props: CloseIconNodeProps): CloseIconNode;
61
+ /**
62
+ * - EN: Type guard to check whether a node is CloseIconNode.
63
+ * - CN: 判断节点是否为 CloseIconNode 的类型守卫。
64
+ *
65
+ * @param node Node to test | 要检测的节点
66
+ */
67
+ export declare function $isCloseIconNode(node: LexicalNode | null | undefined): node is CloseIconNode;
68
+ type SerializedCloseIconNode = Spread<{
69
+ props: CloseIconNodeProps;
70
+ }, SerializedLexicalNode>;
71
+ export {};