@tiny-codes/react-easy 1.4.0 → 1.4.1

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 +8 -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 +61 -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 +37 -2
  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 +24 -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 +0 -1
  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
@@ -30,6 +30,11 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext
30
30
  import { Select } from 'antd';
31
31
  import { insertNodeAtCursor, updateDomStyle } from "../helpers";
32
32
  import { BaseDecoratorNode } from "./base";
33
+
34
+ /**
35
+ * - EN: Props for SelectNode, extending antd Select props plus behavior flags.
36
+ * - CN: SelectNode 的属性,基于 antd Select 属性并附加行为标记。
37
+ */
33
38
  import { jsx as _jsx } from "react/jsx-runtime";
34
39
  export var SelectNode = /*#__PURE__*/function (_BaseDecoratorNode) {
35
40
  _inherits(SelectNode, _BaseDecoratorNode);
@@ -110,8 +115,6 @@ export var SelectNode = /*#__PURE__*/function (_BaseDecoratorNode) {
110
115
  var writable = this.getWritable();
111
116
  writable.__value = value;
112
117
  }
113
-
114
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
115
118
  }, {
116
119
  key: "getPropValue",
117
120
  value: function getPropValue(propName) {
@@ -149,6 +152,12 @@ export var SelectNode = /*#__PURE__*/function (_BaseDecoratorNode) {
149
152
  return SelectNode;
150
153
  }(BaseDecoratorNode);
151
154
 
155
+ /**
156
+ * - EN: React decorator component rendered for SelectNode.
157
+ * - CN: SelectNode 对应的 React 装饰组件。
158
+ *
159
+ * @param node The bound SelectNode instance | 关联的 SelectNode 实例
160
+ */
152
161
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
153
162
  function SelectComponent(_ref) {
154
163
  var node = _ref.node;
@@ -182,14 +191,35 @@ function SelectComponent(_ref) {
182
191
  onClear: handleClear
183
192
  }));
184
193
  }
194
+
195
+ /**
196
+ * - EN: Factory to create a SelectNode.
197
+ * - CN: 创建 SelectNode 的工厂函数。
198
+ *
199
+ * @param props Props for the Select node | Select 节点的属性
200
+ */
185
201
  export function $createSelectNode(props) {
186
202
  return new SelectNode(props);
187
203
  }
188
204
 
205
+ /**
206
+ * - EN: Type guard to check whether a node is SelectNode.
207
+ * - CN: 判断节点是否为 SelectNode 的类型守卫。
208
+ *
209
+ * @param node Node to test | 要检测的节点
210
+ */
189
211
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
190
212
  export function $isSelectNode(node) {
191
213
  return node instanceof SelectNode;
192
214
  }
215
+
216
+ /**
217
+ * - EN: Insert a SelectNode at the current cursor position.
218
+ * - CN: 在当前光标位置插入一个 SelectNode。
219
+ *
220
+ * @param editor LexicalEditor instance | LexicalEditor 实例
221
+ * @param props Props for the Select node | Select 节点的属性
222
+ */
193
223
  export function $insertSelectNode(editor, props) {
194
224
  editor.update(function () {
195
225
  var selectNode = $createSelectNode(_objectSpread(_objectSpread({}, props), {}, {
@@ -201,4 +231,9 @@ export function $insertSelectNode(editor, props) {
201
231
  insertNodeAtCursor(editor, selectNode);
202
232
  });
203
233
  }
234
+
235
+ /**
236
+ * - EN: Props passed to the Select decorator component.
237
+ * - CN: 传递给 Select 装饰组件的属性。
238
+ */
204
239
  //# sourceMappingURL=SelectNode.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","useLexicalComposerContext","Select","insertNodeAtCursor","updateDomStyle","BaseDecoratorNode","jsx","_jsx","SelectNode","_BaseDecoratorNode","_inherits","_super","_createSuper","props","_props$defaultValue","_this","_classCallCheck","call","_defineProperty","_assertThisInitialized","__value","defaultValue","undefined","_createClass","key","value","exportJSON","_objectSpread","_get","_getPrototypeOf","prototype","__props","type","getType","version","createDOM","_this$__props","span","document","createElement","containerStyle","updateDOM","decorate","SelectComponent","node","isInline","getTextContent","_this$__props2","_this2","_this$__props4","content","valueContent","String","textContentMode","_this$__props3","option","options","find","opt","label","spaceAround","concat","getValue","setValue","writable","getWritable","getPropValue","propName","_this$__props5","setProps","clone","getKey","importJSON","serializedNode","$createSelectNode","_ref","_ref2","selectProps","_objectWithoutProperties","_excluded","_useLexicalComposerCo","_useLexicalComposerCo2","_slicedToArray","editor","handleChange","update","_node$__props","_node$__props$onChang","onChange","handleClear","_node$__props2","_node$__props2$onClea","onClear","$isSelectNode","$insertSelectNode","selectNode","paddingLeft","paddingRight"],"sources":["../../../../src/components/Lexical/nodes/SelectNode.tsx"],"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\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 * 在获取editor的textContent时,是否将选项的label作为文本内容插入到编辑器中,默认 `value`\n *\n * - `label` - 将选项的label作为文本内容\n * - `value` - 将选项的value作为文本内容\n */\n textContentMode?: 'label' | 'value';\n /** 是否在`textContext`两边添加一个空格,默认`true` */\n spaceAround?: boolean;\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getPropValue(propName: keyof SelectNodeProps<ValueType, OptionType>): any {\n return this.__props?.[propName];\n }\n\n setProps(props: SelectNodeProps<ValueType, OptionType>): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props,\n ...props,\n };\n }\n}\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\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// 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\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\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}\nexport type 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAA6CA,WAAW,QAAQ,OAAO;AACvE,SAASC,yBAAyB,QAAQ,uCAAuC;AACjF,SAASC,MAAM,QAAQ,MAAM;AAI7B,SAASC,kBAAkB,EAAEC,cAAc;AAE3C,SAASC,iBAAiB;AAAiB,SAAAC,GAAA,IAAAC,IAAA;AAqB3C,WAAaC,UAAU,0BAAAC,kBAAA;EAAAC,SAAA,CAAAF,UAAA,EAAAC,kBAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,UAA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;EAAY,EAAE,CAAC;AAC1G;AAEA,OAAO,SAASf,iBAAiBA,CAI/B7D,KAA8C,EAAqC;EACnF,OAAO,IAAIL,UAAU,CAAwBK,KAAK,CAAC;AACrD;;AAEA;AACA,OAAO,SAASgF,aAAaA,CAACjD,IAAoC,EAAgC;EAChG,OAAOA,IAAI,YAAYpC,UAAU;AACnC;AAEA,OAAO,SAASsF,iBAAiBA,CAI/BX,MAAqB,EAAEtE,KAA6C,EAAQ;EAC5EsE,MAAM,CAACE,MAAM,CAAC,YAAM;IAClB,IAAMU,UAAU,GAAGrB,iBAAiB,CAAA/C,aAAA,CAAAA,aAAA,KAC/Bd,KAAK;MACR2B,cAAc,EAAAb,aAAA;QACZqE,WAAW,EAAE,KAAK;QAClBC,YAAY,EAAE;MAAK,GAChBpF,KAAK,CAAC2B,cAAc;IACxB,EACF,CAAC;IACFrC,kBAAkB,CAACgF,MAAM,EAAEY,UAAU,CAAC;EACxC,CAAC,CAAC;AACJ"}
1
+ {"version":3,"names":["useCallback","useLexicalComposerContext","Select","insertNodeAtCursor","updateDomStyle","BaseDecoratorNode","jsx","_jsx","SelectNode","_BaseDecoratorNode","_inherits","_super","_createSuper","props","_props$defaultValue","_this","_classCallCheck","call","_defineProperty","_assertThisInitialized","__value","defaultValue","undefined","_createClass","key","value","exportJSON","_objectSpread","_get","_getPrototypeOf","prototype","__props","type","getType","version","createDOM","_this$__props","span","document","createElement","containerStyle","updateDOM","decorate","SelectComponent","node","isInline","getTextContent","_this$__props2","_this2","_this$__props4","content","valueContent","String","textContentMode","_this$__props3","option","options","find","opt","label","spaceAround","concat","getValue","setValue","writable","getWritable","getPropValue","propName","_this$__props5","setProps","clone","getKey","importJSON","serializedNode","$createSelectNode","_ref","_ref2","selectProps","_objectWithoutProperties","_excluded","_useLexicalComposerCo","_useLexicalComposerCo2","_slicedToArray","editor","handleChange","update","_node$__props","_node$__props$onChang","onChange","handleClear","_node$__props2","_node$__props2$onClea","onClear","$isSelectNode","$insertSelectNode","selectNode","paddingLeft","paddingRight"],"sources":["../../../../src/components/Lexical/nodes/SelectNode.tsx"],"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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAA6CA,WAAW,QAAQ,OAAO;AACvE,SAASC,yBAAyB,QAAQ,uCAAuC;AACjF,SAASC,MAAM,QAAQ,MAAM;AAI7B,SAASC,kBAAkB,EAAEC,cAAc;AAE3C,SAASC,iBAAiB;;AAE1B;AACA;AACA;AACA;AAHA,SAAAC,GAAA,IAAAC,IAAA;AA6BA,WAAaC,UAAU,0BAAAC,kBAAA;EAAAC,SAAA,CAAAF,UAAA,EAAAC,kBAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,UAAA;EAOrB,SAAAA,WAAYK,KAAiE,EAAE;IAAA,IAAAC,mBAAA;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAR,UAAA;IAC7EO,KAAA,GAAAJ,MAAA,CAAAM,IAAA,OAAMJ,KAAK;IAAEK,eAAA,CAAAC,sBAAA,CAAAJ,KAAA;IACbA,KAAA,CAAKK,OAAO,IAAAN,mBAAA,GAAGD,KAAK,aAALA,KAAK,uBAALA,KAAK,CA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AYpC,UAAU;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASsF,iBAAiBA,CAI/BX,MAAqB,EAAEtE,KAA6C,EAAQ;EAC5EsE,MAAM,CAACE,MAAM,CAAC,YAAM;IAClB,IAAMU,UAAU,GAAGrB,iBAAiB,CAAA/C,aAAA,CAAAA,aAAA,KAC/Bd,KAAK;MACR2B,cAAc,EAAAb,aAAA;QACZqE,WAAW,EAAE,KAAK;QAClBC,YAAY,EAAE;MAAK,GAChBpF,KAAK,CAAC2B,cAAc;IACxB,EACF,CAAC;IACFrC,kBAAkB,CAACgF,MAAM,EAAEY,UAAU,CAAC;EACxC,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA"}
@@ -1,25 +1,50 @@
1
1
  import type { LexicalNode } from 'lexical';
2
2
  import { DecoratorNode, ElementNode } from 'lexical';
3
+ /**
4
+ * - EN: Common behavior flags for custom nodes.
5
+ * - CN: 自定义节点的通用行为标记。
6
+ */
3
7
  export interface BaseNodeProps {
4
- /** 是否可被删除,默认 `true` */
8
+ /**
9
+ * - EN: Whether the node can be removed. Default `true`.
10
+ * - CN: 是否可被删除,默认 `true`。
11
+ */
5
12
  canBeRemoved?: boolean;
6
- /** 是否可被替换,默认 `true` */
13
+ /**
14
+ * - EN: Whether the node can be replaced. Default `true`.
15
+ * - CN: 是否可被替换,默认 `true`。
16
+ */
7
17
  canBeReplaced?: boolean;
8
18
  }
19
+ /**
20
+ * - EN: Extra behavior flags for element nodes.
21
+ * - CN: 元素节点的附加行为标记。
22
+ */
9
23
  export interface BaseElementProps extends BaseNodeProps {
10
24
  /**
11
- * 是否允许节点为空,默认 `false`
12
- *
13
- * - `true` - 允许节点为空
14
- * - `false` - 不允许节点为空,当最后一个子节点被删除后,节点也会被删除
25
+ * - EN: Whether an element is allowed to be empty. Default `false`.
26
+ * - CN: 是否允许节点为空,默认 `false`。
15
27
  */
16
28
  canBeEmpty?: boolean;
17
- /** 是否允许在节点内的起始位置插入文本,默认 `true` */
29
+ /**
30
+ * - EN: Allow inserting text at the start of the element. Default `true`.
31
+ * - CN: 是否允许在节点内的起始位置插入文本,默认 `true`。
32
+ */
18
33
  canInsertTextBefore?: boolean;
19
- /** 是否允许在节点内的结束位置插入文本,默认 `true` */
34
+ /**
35
+ * - EN: Allow inserting text at the end of the element. Default `true`.
36
+ * - CN: 是否允许在节点内的结束位置插入文本,默认 `true`。
37
+ */
20
38
  canInsertTextAfter?: boolean;
21
39
  }
22
40
  export type BaseDecoratorNodeProps = BaseNodeProps;
41
+ /**
42
+ * - EN: A helper wrapping base behaviors (remove/replace) with guard flags.
43
+ * - CN: 封装基础行为(删除/替换)并根据标记进行限制的帮助器。
44
+ *
45
+ * @param props Node behavior flags | 节点行为标记
46
+ * @param superMethods Methods delegated to the underlying node | 委托给底层节点的方法
47
+ */
23
48
  export declare class BaseNodeHelper<P extends BaseNodeProps> {
24
49
  __props: (P & BaseNodeProps) | undefined;
25
50
  __superMethods: Pick<LexicalNode, 'replace' | 'remove'>;
@@ -28,8 +53,18 @@ export declare class BaseNodeHelper<P extends BaseNodeProps> {
28
53
  remove: (preserveEmptyParent?: boolean) => void;
29
54
  replace: <N extends LexicalNode>(replaceWith: N, includeChildren?: boolean) => N;
30
55
  };
56
+ /**
57
+ * - EN: Strip helper-only flags from props for DOM usage.
58
+ * - CN: 去除仅用于帮助器的标记属性,得到用于 DOM 的纯属性。
59
+ *
60
+ * @param props Props including helper flags | 含帮助标记的属性
61
+ */
31
62
  getUnderlyingProps(props: P & BaseNodeProps): Omit<P, keyof BaseNodeProps>;
32
63
  }
64
+ /**
65
+ * - EN: Base element node with behavior flags.
66
+ * - CN: 带行为标记的基础元素节点。
67
+ */
33
68
  export declare class BaseElementNode<P extends BaseElementProps> extends ElementNode {
34
69
  __props: P | undefined;
35
70
  __base: BaseNodeHelper<P>;
@@ -39,13 +74,29 @@ export declare class BaseElementNode<P extends BaseElementProps> extends Element
39
74
  canBeEmpty(): boolean;
40
75
  canInsertTextBefore(): boolean;
41
76
  canInsertTextAfter(): boolean;
77
+ /**
78
+ * - EN: Strip element-specific flags and return DOM props.
79
+ * - CN: 去除元素特有的标记并返回 DOM 属性。
80
+ *
81
+ * @param props Element props including flags | 含标记的元素属性
82
+ */
42
83
  getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseElementProps>;
43
84
  }
85
+ /**
86
+ * - EN: Base decorator node with behavior flags.
87
+ * - CN: 带行为标记的基础装饰器节点。
88
+ */
44
89
  export declare class BaseDecoratorNode<T, P extends BaseDecoratorNodeProps> extends DecoratorNode<T> {
45
90
  __props: P | undefined;
46
91
  __base: BaseNodeHelper<P>;
47
92
  constructor(props?: P & {
48
93
  key?: string;
49
94
  });
95
+ /**
96
+ * - EN: Strip decorator-specific flags and return DOM props.
97
+ * - CN: 去除装饰器特有的标记并返回 DOM 属性。
98
+ *
99
+ * @param props Decorator props including flags | 含标记的装饰器属性
100
+ */
50
101
  getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseDecoratorNodeProps>;
51
102
  }
@@ -22,6 +22,24 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
22
22
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
23
23
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
24
24
  import { DecoratorNode, ElementNode } from 'lexical';
25
+
26
+ /**
27
+ * - EN: Common behavior flags for custom nodes.
28
+ * - CN: 自定义节点的通用行为标记。
29
+ */
30
+
31
+ /**
32
+ * - EN: Extra behavior flags for element nodes.
33
+ * - CN: 元素节点的附加行为标记。
34
+ */
35
+
36
+ /**
37
+ * - EN: A helper wrapping base behaviors (remove/replace) with guard flags.
38
+ * - CN: 封装基础行为(删除/替换)并根据标记进行限制的帮助器。
39
+ *
40
+ * @param props Node behavior flags | 节点行为标记
41
+ * @param superMethods Methods delegated to the underlying node | 委托给底层节点的方法
42
+ */
25
43
  export var BaseNodeHelper = /*#__PURE__*/function () {
26
44
  function BaseNodeHelper(props, superMethods) {
27
45
  var _this = this;
@@ -49,7 +67,14 @@ export var BaseNodeHelper = /*#__PURE__*/function () {
49
67
  }
50
68
  _createClass(BaseNodeHelper, [{
51
69
  key: "getUnderlyingProps",
52
- value: function getUnderlyingProps(props) {
70
+ value:
71
+ /**
72
+ * - EN: Strip helper-only flags from props for DOM usage.
73
+ * - CN: 去除仅用于帮助器的标记属性,得到用于 DOM 的纯属性。
74
+ *
75
+ * @param props Props including helper flags | 含帮助标记的属性
76
+ */
77
+ function getUnderlyingProps(props) {
53
78
  /* eslint-disable @typescript-eslint/no-unused-vars */
54
79
  var canBeRemoved = props.canBeRemoved,
55
80
  canBeReplaced = props.canBeReplaced,
@@ -60,6 +85,11 @@ export var BaseNodeHelper = /*#__PURE__*/function () {
60
85
  }]);
61
86
  return BaseNodeHelper;
62
87
  }();
88
+
89
+ /**
90
+ * - EN: Base element node with behavior flags.
91
+ * - CN: 带行为标记的基础元素节点。
92
+ */
63
93
  export var BaseElementNode = /*#__PURE__*/function (_ElementNode) {
64
94
  _inherits(BaseElementNode, _ElementNode);
65
95
  var _super = _createSuper(BaseElementNode);
@@ -108,6 +138,13 @@ export var BaseElementNode = /*#__PURE__*/function (_ElementNode) {
108
138
  var _this$__props$canInse2, _this$__props5;
109
139
  return (_this$__props$canInse2 = (_this$__props5 = this.__props) === null || _this$__props5 === void 0 ? void 0 : _this$__props5.canInsertTextAfter) !== null && _this$__props$canInse2 !== void 0 ? _this$__props$canInse2 : true;
110
140
  }
141
+
142
+ /**
143
+ * - EN: Strip element-specific flags and return DOM props.
144
+ * - CN: 去除元素特有的标记并返回 DOM 属性。
145
+ *
146
+ * @param props Element props including flags | 含标记的元素属性
147
+ */
111
148
  }, {
112
149
  key: "getUnderlyingProps",
113
150
  value: function getUnderlyingProps(props) {
@@ -123,6 +160,11 @@ export var BaseElementNode = /*#__PURE__*/function (_ElementNode) {
123
160
  }]);
124
161
  return BaseElementNode;
125
162
  }(ElementNode);
163
+
164
+ /**
165
+ * - EN: Base decorator node with behavior flags.
166
+ * - CN: 带行为标记的基础装饰器节点。
167
+ */
126
168
  export var BaseDecoratorNode = /*#__PURE__*/function (_DecoratorNode) {
127
169
  _inherits(BaseDecoratorNode, _DecoratorNode);
128
170
  var _super2 = _createSuper(BaseDecoratorNode);
@@ -153,6 +195,13 @@ export var BaseDecoratorNode = /*#__PURE__*/function (_DecoratorNode) {
153
195
  });
154
196
  return _this3;
155
197
  }
198
+
199
+ /**
200
+ * - EN: Strip decorator-specific flags and return DOM props.
201
+ * - CN: 去除装饰器特有的标记并返回 DOM 属性。
202
+ *
203
+ * @param props Decorator props including flags | 含标记的装饰器属性
204
+ */
156
205
  _createClass(BaseDecoratorNode, [{
157
206
  key: "getUnderlyingProps",
158
207
  value: function getUnderlyingProps(props) {
@@ -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\nexport interface BaseNodeProps {\n /** 是否可被删除,默认 `true` */\n canBeRemoved?: boolean;\n /** 是否可被替换,默认 `true` */\n canBeReplaced?: boolean;\n}\nexport interface BaseElementProps extends BaseNodeProps {\n /**\n * 是否允许节点为空,默认 `false`\n *\n * - `true` - 允许节点为空\n * - `false` - 不允许节点为空,当最后一个子节点被删除后,节点也会被删除\n */\n canBeEmpty?: boolean;\n /** 是否允许在节点内的起始位置插入文本,默认 `true` */\n canInsertTextBefore?: boolean;\n /** 是否允许在节点内的结束位置插入文本,默认 `true` */\n canInsertTextAfter?: boolean;\n}\n\nexport type BaseDecoratorNodeProps = BaseNodeProps;\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 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\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 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\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 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"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AAAsB,WAAA,EAAA3B,IAAA,CAAA2B,WAAA,EAAmBhD,WAAW,EAAEC,eAAe;MAAA;IACvF,CAAC,CAAC;IACF0B,MAAM,CAACC,IAAI,CAACqB,MAAA,CAAK1B,MAAM,CAACM,KAAK,CAAC,CAACC,OAAO,CAAC,UAACzB,GAAG,EAAK;MAC9C,IAAM0B,MAAM,GAAGkB,MAAA,CAAK1B,MAAM,CAACM,KAAK,CAACxB,GAAG,CAAmC;MACvE,IAAI,OAAO0B,MAAM,KAAK,UAAU,EAAE;QAChC;QACAkB,MAAA,CAAK5C,GAAG,CAAe,GAAG0B,MAAM,CAACC,IAAI,CAACiB,MAAA,CAAK1B,MAAM,CAAQ;MAC3D;IACF,CAAC,CAAC;IAAC,OAAA0B,MAAA;EACL;EAAC7C,YAAA,CAAAwC,iBAAA;IAAAvC,GAAA;IAAAC,KAAA,EAED,SAAAC,mBAAmBnB,KAAoB,EAAyC;MAC9E,IAAMsD,SAAS,GAAG,IAAI,CAACnB,MAAM,CAAChB,kBAAkB,CAACnB,KAAK,aAALA,KAAK,cAALA,KAAK,GAAK,CAAC,CAAO,CAAC;MACpE;MACA,IAAWoB,SAAS,GAAAmB,MAAA,CAAAyB,MAAA,MAAAC,yBAAA,CAAKX,SAAS,GAATA,SAAS;MAClC;MACA,OAAOlC,SAAS;IAClB;EAAC;EAAA,OAAAoC,iBAAA;AAAA,EA5ByE3D,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","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;AAC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CAAAmB,iBAAA,CAAAlB,SAAA,eAAAsB,WAAA,EAAA3B,IAAA,CAAA2B,WAAA,EAAmBhD,WAAW,EAAEC,eAAe;MAAA;IACvF,CAAC,CAAC;IACF0B,MAAM,CAACC,IAAI,CAACqB,MAAA,CAAK1B,MAAM,CAACM,KAAK,CAAC,CAACC,OAAO,CAAC,UAACzB,GAAG,EAAK;MAC9C,IAAM0B,MAAM,GAAGkB,MAAA,CAAK1B,MAAM,CAACM,KAAK,CAACxB,GAAG,CAAmC;MACvE,IAAI,OAAO0B,MAAM,KAAK,UAAU,EAAE;QAChC;QACAkB,MAAA,CAAK5C,GAAG,CAAe,GAAG0B,MAAM,CAACC,IAAI,CAACiB,MAAA,CAAK1B,MAAM,CAAQ;MAC3D;IACF,CAAC,CAAC;IAAC,OAAA0B,MAAA;EACL;;EAEA;AACF;AACA;AACA;AACA;AACA;EALE7C,YAAA,CAAAwC,iBAAA;IAAAvC,GAAA;IAAAC,KAAA,EAMA,SAAAC,mBAAmBnB,KAAoB,EAAyC;MAC9E,IAAMsD,SAAS,GAAG,IAAI,CAACnB,MAAM,CAAChB,kBAAkB,CAACnB,KAAK,aAALA,KAAK,cAALA,KAAK,GAAK,CAAC,CAAO,CAAC;MACpE;MACA,IAAWoB,SAAS,GAAAmB,MAAA,CAAAyB,MAAA,MAAAC,yBAAA,CAAKX,SAAS,GAATA,SAAS;MAClC;MACA,OAAOlC,SAAS;IAClB;EAAC;EAAA,OAAAoC,iBAAA;AAAA,EAlCyE3D,aAAa"}
@@ -1,2 +1,3 @@
1
1
  export * from './color';
2
2
  export * from './math';
3
+ export * from './string';
package/es/utils/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./color";
2
2
  export * from "./math";
3
+ export * from "./string";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './color';\nexport * from './math';\n"],"mappings":"AAAA;AACA"}
1
+ {"version":3,"names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './color';\nexport * from './math';\nexport * from './string';\n"],"mappings":"AAAA;AACA;AACA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * - EN: Generate a random string of alphanumeric characters.
3
+ * - CN: 生成一个随机的字母数字字符串。
4
+ *
5
+ * @param length Length of the random string | 随机字符串的长度
6
+ */
7
+ export declare function randomChars(length: number): string;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * - EN: Generate a random string of alphanumeric characters.
3
+ * - CN: 生成一个随机的字母数字字符串。
4
+ *
5
+ * @param length Length of the random string | 随机字符串的长度
6
+ */
7
+ export function randomChars(length) {
8
+ var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
9
+ var result = '';
10
+ for (var i = 0; i < length; i++) {
11
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
12
+ }
13
+ return result;
14
+ }
15
+ //# sourceMappingURL=string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["randomChars","length","chars","result","i","charAt","Math","floor","random"],"sources":["../../src/utils/string.ts"],"sourcesContent":["/**\n * - EN: Generate a random string of alphanumeric characters.\n * - CN: 生成一个随机的字母数字字符串。\n *\n * @param length Length of the random string | 随机字符串的长度\n */\nexport function randomChars(length: number): string {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let result = '';\n for (let i = 0; i < length; i++) {\n result += chars.charAt(Math.floor(Math.random() * chars.length));\n }\n return result;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,WAAWA,CAACC,MAAc,EAAU;EAClD,IAAMC,KAAK,GAAG,gEAAgE;EAC9E,IAAIC,MAAM,GAAG,EAAE;EACf,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,MAAM,EAAEG,CAAC,EAAE,EAAE;IAC/BD,MAAM,IAAID,KAAK,CAACG,MAAM,CAACC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,MAAM,CAAC,CAAC,GAAGN,KAAK,CAACD,MAAM,CAAC,CAAC;EAClE;EACA,OAAOE,MAAM;AACf"}
@@ -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,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/FormItemControl/index.tsx"],
4
- "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"],
4
+ "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"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,IAAM,kBAA4C,CAAC,UAAU;AAE3D,QAAM,EAAE,UAAU,OAAO,SAAS,IAAI;AAOtC,SAAO,SAAS,EAAE,OAAO,SAAS,CAAC;AACrC;AAEA,IAAO,0BAAQ;",
6
6
  "names": []
7
7
  }
@@ -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;
@@ -22,6 +22,7 @@ __export(helpers_exports, {
22
22
  clearEditorContent: () => clearEditorContent,
23
23
  findNode: () => findNode,
24
24
  findNodes: () => findNodes,
25
+ getDomAttributes: () => getDomAttributes,
25
26
  insertNodeAtCursor: () => insertNodeAtCursor,
26
27
  insertTextAtCursor: () => insertTextAtCursor,
27
28
  updateDomProps: () => updateDomProps,
@@ -185,11 +186,34 @@ function updateDomStyle(dom, style) {
185
186
  });
186
187
  }
187
188
  }
189
+ function getDomAttributes(dom) {
190
+ if (!dom)
191
+ return void 0;
192
+ const attributes = {};
193
+ Array.from(dom.attributes).forEach((attr) => {
194
+ if (attr.name === "class" || attr.name === "style") {
195
+ return;
196
+ }
197
+ attributes[attr.name] = attr.value;
198
+ });
199
+ if (dom.className) {
200
+ attributes.className = dom.className;
201
+ }
202
+ if (dom.style) {
203
+ const styles = {};
204
+ Array.from(dom.style).forEach((styleName) => {
205
+ styles[styleName] = dom.style[styleName];
206
+ });
207
+ attributes.style = styles;
208
+ }
209
+ return attributes;
210
+ }
188
211
  // Annotate the CommonJS export names for ESM import in node:
189
212
  0 && (module.exports = {
190
213
  clearEditorContent,
191
214
  findNode,
192
215
  findNodes,
216
+ getDomAttributes,
193
217
  insertNodeAtCursor,
194
218
  insertTextAtCursor,
195
219
  updateDomProps,