@tiny-codes/react-easy 1.3.1 → 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 (65) 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 +73 -0
  6. package/es/components/Lexical/helpers/index.js +286 -0
  7. package/es/components/Lexical/helpers/index.js.map +1 -0
  8. package/es/components/Lexical/index.d.ts +6 -0
  9. package/es/components/Lexical/index.js +7 -0
  10. package/es/components/Lexical/index.js.map +1 -0
  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 +45 -0
  15. package/es/components/Lexical/nodes/DivNode.js +191 -0
  16. package/es/components/Lexical/nodes/DivNode.js.map +1 -0
  17. package/es/components/Lexical/nodes/ExtendTextNode.d.ts +46 -0
  18. package/es/components/Lexical/nodes/ExtendTextNode.js +134 -0
  19. package/es/components/Lexical/nodes/ExtendTextNode.js.map +1 -0
  20. package/es/components/Lexical/nodes/SelectNode.d.ts +74 -0
  21. package/es/components/Lexical/nodes/SelectNode.js +239 -0
  22. package/es/components/Lexical/nodes/SelectNode.js.map +1 -0
  23. package/es/components/Lexical/nodes/base.d.ts +102 -0
  24. package/es/components/Lexical/nodes/base.js +217 -0
  25. package/es/components/Lexical/nodes/base.js.map +1 -0
  26. package/es/hooks/useRefValue.d.ts +2 -2
  27. package/es/hooks/useRefValue.js.map +1 -1
  28. package/es/utils/index.d.ts +1 -0
  29. package/es/utils/index.js +1 -0
  30. package/es/utils/index.js.map +1 -1
  31. package/es/utils/string.d.ts +7 -0
  32. package/es/utils/string.js +15 -0
  33. package/es/utils/string.js.map +1 -0
  34. package/lib/components/FormItemControl/index.d.ts +7 -7
  35. package/lib/components/FormItemControl/index.js.map +1 -1
  36. package/lib/components/Lexical/helpers/index.d.ts +73 -0
  37. package/lib/components/Lexical/helpers/index.js +222 -0
  38. package/lib/components/Lexical/helpers/index.js.map +7 -0
  39. package/lib/components/Lexical/index.d.ts +6 -0
  40. package/lib/components/Lexical/index.js +34 -0
  41. package/lib/components/Lexical/index.js.map +7 -0
  42. package/lib/components/Lexical/nodes/CloseIcon.d.ts +71 -0
  43. package/lib/components/Lexical/nodes/CloseIcon.js +149 -0
  44. package/lib/components/Lexical/nodes/CloseIcon.js.map +7 -0
  45. package/lib/components/Lexical/nodes/DivNode.d.ts +45 -0
  46. package/lib/components/Lexical/nodes/DivNode.js +139 -0
  47. package/lib/components/Lexical/nodes/DivNode.js.map +7 -0
  48. package/lib/components/Lexical/nodes/ExtendTextNode.d.ts +46 -0
  49. package/lib/components/Lexical/nodes/ExtendTextNode.js +95 -0
  50. package/lib/components/Lexical/nodes/ExtendTextNode.js.map +7 -0
  51. package/lib/components/Lexical/nodes/SelectNode.d.ts +74 -0
  52. package/lib/components/Lexical/nodes/SelectNode.js +156 -0
  53. package/lib/components/Lexical/nodes/SelectNode.js.map +7 -0
  54. package/lib/components/Lexical/nodes/base.d.ts +102 -0
  55. package/lib/components/Lexical/nodes/base.js +134 -0
  56. package/lib/components/Lexical/nodes/base.js.map +7 -0
  57. package/lib/hooks/useRefValue.d.ts +2 -2
  58. package/lib/hooks/useRefValue.js.map +2 -2
  59. package/lib/utils/index.d.ts +1 -0
  60. package/lib/utils/index.js +3 -1
  61. package/lib/utils/index.js.map +2 -2
  62. package/lib/utils/string.d.ts +7 -0
  63. package/lib/utils/string.js +37 -0
  64. package/lib/utils/string.js.map +7 -0
  65. package/package.json +20 -1
@@ -0,0 +1,95 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/Lexical/nodes/ExtendTextNode.tsx
20
+ var ExtendTextNode_exports = {};
21
+ __export(ExtendTextNode_exports, {
22
+ $createExtendTextNode: () => $createExtendTextNode,
23
+ $isExtendTextNode: () => $isExtendTextNode,
24
+ ExtendTextNode: () => ExtendTextNode
25
+ });
26
+ module.exports = __toCommonJS(ExtendTextNode_exports);
27
+ var import_lexical = require("lexical");
28
+ var import_base = require("./base");
29
+ var ExtendTextNode = class extends import_lexical.TextNode {
30
+ constructor(props) {
31
+ const { key, ...restProps } = props || {};
32
+ super(props == null ? void 0 : props.text, key);
33
+ this.__props = restProps;
34
+ this.__base = new import_base.BaseNodeHelper(this.__props, {
35
+ remove: () => super.remove(),
36
+ replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren)
37
+ });
38
+ Object.keys(this.__base.hooks).forEach((key2) => {
39
+ const method = this.__base.hooks[key2];
40
+ if (typeof method === "function") {
41
+ this[key2] = method.bind(this.__base);
42
+ }
43
+ });
44
+ this.remove = (preserveEmptyParent) => {
45
+ var _a;
46
+ if (((_a = this.__props) == null ? void 0 : _a.canBeRemoved) === false) {
47
+ this.setTextContent(this.__props.prefixText ?? " ");
48
+ return;
49
+ }
50
+ super.remove(preserveEmptyParent);
51
+ };
52
+ this.replace = (replaceWith, includeChildren) => {
53
+ var _a, _b;
54
+ if (((_a = this.__props) == null ? void 0 : _a.canBeReplaced) === false) {
55
+ this.setTextContent(((_b = this.__props) == null ? void 0 : _b.text) || " ");
56
+ this.selectNext();
57
+ return this;
58
+ }
59
+ return super.replace(replaceWith, includeChildren);
60
+ };
61
+ }
62
+ static getType() {
63
+ return "html.TextNode";
64
+ }
65
+ static clone(node) {
66
+ return new ExtendTextNode({ ...node.__props, text: node.__text, key: node.getKey() });
67
+ }
68
+ static importJSON(serializedNode) {
69
+ return $createExtendTextNode({
70
+ ...serializedNode.props,
71
+ text: serializedNode.text
72
+ });
73
+ }
74
+ exportJSON() {
75
+ return {
76
+ ...super.exportJSON(),
77
+ props: this.__props,
78
+ text: this.__text,
79
+ type: this.getType()
80
+ };
81
+ }
82
+ };
83
+ function $createExtendTextNode(props) {
84
+ return new ExtendTextNode(props);
85
+ }
86
+ function $isExtendTextNode(node) {
87
+ return node instanceof ExtendTextNode;
88
+ }
89
+ // Annotate the CommonJS export names for ESM import in node:
90
+ 0 && (module.exports = {
91
+ $createExtendTextNode,
92
+ $isExtendTextNode,
93
+ ExtendTextNode
94
+ });
95
+ //# sourceMappingURL=ExtendTextNode.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/components/Lexical/nodes/ExtendTextNode.tsx"],
4
+ "sourcesContent": ["import type { LexicalNode, NodeKey, SerializedTextNode, Spread } from 'lexical';\nimport { TextNode } from 'lexical';\nimport type { BaseNodeProps } from './base';\nimport { BaseNodeHelper } from './base';\n\n/**\n * - EN: Extra props for ExtendTextNode.\n * - CN: ExtendTextNode 的附加属性。\n */\nexport interface ExtendTextNodeProps extends BaseNodeProps {\n text?: string;\n prefixText?: string;\n}\n\n/**\n * - EN: A TextNode with extra behavior flags and controlled replacement.\n * - CN: 带有额外行为标记并可控制替换行为的 TextNode。\n */\nexport class ExtendTextNode extends TextNode {\n __props: ExtendTextNodeProps | undefined;\n __base: BaseNodeHelper<ExtendTextNodeProps>;\n\n constructor(props?: ExtendTextNodeProps & { key?: NodeKey }) {\n const { key, ...restProps } = props || {};\n super(props?.text, key);\n this.__props = restProps;\n this.__base = new BaseNodeHelper<ExtendTextNodeProps>(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 this.remove = (preserveEmptyParent?: boolean): void => {\n if (this.__props?.canBeRemoved === false) {\n this.setTextContent(this.__props.prefixText ?? ' ');\n return;\n }\n super.remove(preserveEmptyParent);\n };\n this.replace = <N extends LexicalNode>(replaceWith: N, includeChildren?: boolean): N => {\n if (this.__props?.canBeReplaced === false) {\n this.setTextContent(this.__props?.text || ' ');\n this.selectNext();\n return this as unknown as N;\n }\n return super.replace(replaceWith, includeChildren);\n };\n }\n\n static getType(): string {\n return 'html.TextNode';\n }\n\n static clone(node: ExtendTextNode): ExtendTextNode {\n return new ExtendTextNode({ ...node.__props, text: node.__text, key: node.getKey() });\n }\n\n static importJSON(serializedNode: SerializedExtendTextNode): ExtendTextNode {\n return $createExtendTextNode({\n ...serializedNode.props,\n text: serializedNode.text,\n });\n }\n\n exportJSON(): SerializedExtendTextNode {\n return {\n ...super.exportJSON(),\n props: this.__props,\n text: this.__text,\n type: this.getType(),\n };\n }\n}\n\ntype SerializedExtendTextNode = Spread<\n {\n props?: ExtendTextNodeProps;\n text: string;\n },\n SerializedTextNode\n>;\n\n/**\n * - EN: Factory to create an ExtendTextNode.\n * - CN: 创建 ExtendTextNode 的工厂函数。\n *\n * @param props Props for the node | 节点的属性\n */\nexport function $createExtendTextNode(props?: ExtendTextNodeProps): ExtendTextNode {\n return new ExtendTextNode(props);\n}\n\n/**\n * - EN: Type guard to check whether a node is ExtendTextNode.\n * - CN: 判断节点是否为 ExtendTextNode 的类型守卫。\n *\n * @param node Node to test | 要检测的节点\n */\nexport function $isExtendTextNode(node: LexicalNode | null | undefined): node is ExtendTextNode {\n return node instanceof ExtendTextNode;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAAyB;AAEzB,kBAA+B;AAexB,IAAM,iBAAN,cAA6B,wBAAS;AAAA,EAI3C,YAAY,OAAiD;AAC3D,UAAM,EAAE,KAAK,GAAG,UAAU,IAAI,SAAS,CAAC;AACxC,UAAM,+BAAO,MAAM,GAAG;AACtB,SAAK,UAAU;AACf,SAAK,SAAS,IAAI,2BAAoC,KAAK,SAAS;AAAA,MAClE,QAAQ,MAAM,MAAM,OAAO;AAAA,MAC3B,SAAS,CAAC,aAAa,oBAAoB,MAAM,QAAQ,aAAa,eAAe;AAAA,IACvF,CAAC;AACD,WAAO,KAAK,KAAK,OAAO,KAAK,EAAE,QAAQ,CAACA,SAAQ;AAC9C,YAAM,SAAS,KAAK,OAAO,MAAMA,IAAqC;AACtE,UAAI,OAAO,WAAW,YAAY;AAEhC,aAAKA,IAAiB,IAAI,OAAO,KAAK,KAAK,MAAM;AAAA,MACnD;AAAA,IACF,CAAC;AACD,SAAK,SAAS,CAAC,wBAAwC;AArC3D;AAsCM,YAAI,UAAK,YAAL,mBAAc,kBAAiB,OAAO;AACxC,aAAK,eAAe,KAAK,QAAQ,cAAc,GAAG;AAClD;AAAA,MACF;AACA,YAAM,OAAO,mBAAmB;AAAA,IAClC;AACA,SAAK,UAAU,CAAwB,aAAgB,oBAAiC;AA5C5F;AA6CM,YAAI,UAAK,YAAL,mBAAc,mBAAkB,OAAO;AACzC,aAAK,iBAAe,UAAK,YAAL,mBAAc,SAAQ,GAAG;AAC7C,aAAK,WAAW;AAChB,eAAO;AAAA,MACT;AACA,aAAO,MAAM,QAAQ,aAAa,eAAe;AAAA,IACnD;AAAA,EACF;AAAA,EAEA,OAAO,UAAkB;AACvB,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,MAAM,MAAsC;AACjD,WAAO,IAAI,eAAe,EAAE,GAAG,KAAK,SAAS,MAAM,KAAK,QAAQ,KAAK,KAAK,OAAO,EAAE,CAAC;AAAA,EACtF;AAAA,EAEA,OAAO,WAAW,gBAA0D;AAC1E,WAAO,sBAAsB;AAAA,MAC3B,GAAG,eAAe;AAAA,MAClB,MAAM,eAAe;AAAA,IACvB,CAAC;AAAA,EACH;AAAA,EAEA,aAAuC;AACrC,WAAO;AAAA,MACL,GAAG,MAAM,WAAW;AAAA,MACpB,OAAO,KAAK;AAAA,MACZ,MAAM,KAAK;AAAA,MACX,MAAM,KAAK,QAAQ;AAAA,IACrB;AAAA,EACF;AACF;AAgBO,SAAS,sBAAsB,OAA6C;AACjF,SAAO,IAAI,eAAe,KAAK;AACjC;AAQO,SAAS,kBAAkB,MAA8D;AAC9F,SAAO,gBAAgB;AACzB;",
6
+ "names": ["key"]
7
+ }
@@ -0,0 +1,74 @@
1
+ import { type CSSProperties, type ReactNode } from 'react';
2
+ import type { SelectProps } from 'antd';
3
+ import type { BaseOptionType, DefaultOptionType } from 'antd/es/select';
4
+ import type { LexicalEditor, LexicalNode, SerializedLexicalNode, Spread } from 'lexical';
5
+ import type { BaseDecoratorNodeProps } from './base';
6
+ import { BaseDecoratorNode } from './base';
7
+ /**
8
+ * - EN: Props for SelectNode, extending antd Select props plus behavior flags.
9
+ * - CN: SelectNode 的属性,基于 antd Select 属性并附加行为标记。
10
+ */
11
+ export interface SelectNodeProps<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> extends SelectProps<ValueType, OptionType>, BaseDecoratorNodeProps {
12
+ /**
13
+ * - EN: When reading editor textContent, whether to use option label or value. Default `value`.
14
+ * - CN: 在获取 editor 的 textContent 时,使用选项的 label 还是 value。默认 `value`。
15
+ * - label: use option label as text
16
+ * - value: use option value as text
17
+ */
18
+ textContentMode?: 'label' | 'value';
19
+ /**
20
+ * - EN: Add a space around textContent. Default `true`.
21
+ * - CN: 是否在 textContent 两边添加一个空格,默认 `true`。
22
+ */
23
+ spaceAround?: boolean;
24
+ /**
25
+ * - EN: Container DOM style.
26
+ * - CN: 容器样式。
27
+ */
28
+ containerStyle?: CSSProperties;
29
+ }
30
+ export declare class SelectNode<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> extends BaseDecoratorNode<ReactNode, SelectNodeProps<ValueType, OptionType>> {
31
+ __value: ValueType | undefined;
32
+ constructor(props?: SelectNodeProps<ValueType, OptionType> & {
33
+ key?: string;
34
+ });
35
+ static getType(): string;
36
+ static clone<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(node: SelectNode<ValueType, OptionType>): SelectNode<ValueType, OptionType>;
37
+ static importJSON<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(serializedNode: SerializedSelectNode<ValueType, OptionType>): SelectNode<ValueType, OptionType>;
38
+ exportJSON(): SerializedSelectNode<ValueType, OptionType>;
39
+ createDOM(): HTMLElement;
40
+ updateDOM(): false;
41
+ decorate(): ReactNode;
42
+ isInline(): boolean;
43
+ getTextContent(): string;
44
+ getValue(): ValueType | undefined;
45
+ setValue(value: ValueType | undefined): void;
46
+ getPropValue(propName: keyof SelectNodeProps<ValueType, OptionType>): SelectNodeProps<ValueType, OptionType>[typeof propName];
47
+ setProps(props: Partial<SelectNodeProps<ValueType, OptionType>>): void;
48
+ }
49
+ /**
50
+ * - EN: Factory to create a SelectNode.
51
+ * - CN: 创建 SelectNode 的工厂函数。
52
+ *
53
+ * @param props Props for the Select node | Select 节点的属性
54
+ */
55
+ export declare function $createSelectNode<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props?: SelectNodeProps<ValueType, OptionType>): SelectNode<ValueType, OptionType>;
56
+ /**
57
+ * - EN: Type guard to check whether a node is SelectNode.
58
+ * - CN: 判断节点是否为 SelectNode 的类型守卫。
59
+ *
60
+ * @param node Node to test | 要检测的节点
61
+ */
62
+ export declare function $isSelectNode(node: LexicalNode | null | undefined): node is SelectNode<any, any>;
63
+ /**
64
+ * - EN: Insert a SelectNode at the current cursor position.
65
+ * - CN: 在当前光标位置插入一个 SelectNode。
66
+ *
67
+ * @param editor LexicalEditor instance | LexicalEditor 实例
68
+ * @param props Props for the Select node | Select 节点的属性
69
+ */
70
+ export declare function $insertSelectNode<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(editor: LexicalEditor, props: SelectNodeProps<ValueType, OptionType>): void;
71
+ type SerializedSelectNode<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> = Spread<{
72
+ props?: SelectNodeProps<ValueType, OptionType>;
73
+ }, SerializedLexicalNode>;
74
+ export {};
@@ -0,0 +1,156 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/Lexical/nodes/SelectNode.tsx
20
+ var SelectNode_exports = {};
21
+ __export(SelectNode_exports, {
22
+ $createSelectNode: () => $createSelectNode,
23
+ $insertSelectNode: () => $insertSelectNode,
24
+ $isSelectNode: () => $isSelectNode,
25
+ SelectNode: () => SelectNode
26
+ });
27
+ module.exports = __toCommonJS(SelectNode_exports);
28
+ var import_react = require("react");
29
+ var import_LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
30
+ var import_antd = require("antd");
31
+ var import_helpers = require("../helpers");
32
+ var import_base = require("./base");
33
+ var SelectNode = class extends import_base.BaseDecoratorNode {
34
+ constructor(props) {
35
+ super(props);
36
+ this.__value = (props == null ? void 0 : props.defaultValue) ?? void 0;
37
+ }
38
+ static getType() {
39
+ return "antd.Select";
40
+ }
41
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
+ static clone(node) {
43
+ return new SelectNode({ ...node.__props, key: node.getKey() });
44
+ }
45
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
46
+ static importJSON(serializedNode) {
47
+ return $createSelectNode(serializedNode.props);
48
+ }
49
+ exportJSON() {
50
+ return {
51
+ ...super.exportJSON(),
52
+ props: this.__props,
53
+ type: this.getType(),
54
+ version: 1
55
+ };
56
+ }
57
+ createDOM() {
58
+ var _a;
59
+ const span = document.createElement("span");
60
+ (0, import_helpers.updateDomStyle)(span, (_a = this.__props) == null ? void 0 : _a.containerStyle);
61
+ return span;
62
+ }
63
+ updateDOM() {
64
+ return false;
65
+ }
66
+ decorate() {
67
+ return /* @__PURE__ */ React.createElement(SelectComponent, { node: this });
68
+ }
69
+ isInline() {
70
+ return true;
71
+ }
72
+ getTextContent() {
73
+ var _a, _b, _c, _d;
74
+ let content;
75
+ const valueContent = this.__value ? String(this.__value) : "";
76
+ if (((_a = this.__props) == null ? void 0 : _a.textContentMode) === "label") {
77
+ const option = (_c = (_b = this.__props) == null ? void 0 : _b.options) == null ? void 0 : _c.find((opt) => opt.value === this.__value);
78
+ content = (option == null ? void 0 : option.label) ? String(option.label) : valueContent;
79
+ } else {
80
+ content = valueContent;
81
+ }
82
+ if (((_d = this.__props) == null ? void 0 : _d.spaceAround) !== false) {
83
+ return ` ${content} `;
84
+ }
85
+ return content;
86
+ }
87
+ getValue() {
88
+ return this.__value;
89
+ }
90
+ setValue(value) {
91
+ const writable = this.getWritable();
92
+ writable.__value = value;
93
+ }
94
+ getPropValue(propName) {
95
+ var _a;
96
+ return (_a = this.__props) == null ? void 0 : _a[propName];
97
+ }
98
+ setProps(props) {
99
+ const writable = this.getWritable();
100
+ writable.__props = {
101
+ ...writable.__props,
102
+ ...props
103
+ };
104
+ }
105
+ };
106
+ function SelectComponent({
107
+ node
108
+ }) {
109
+ const { textContentMode, spaceAround, containerStyle, ...selectProps } = node.__props || {};
110
+ const [editor] = (0, import_LexicalComposerContext.useLexicalComposerContext)();
111
+ const handleChange = (0, import_react.useCallback)(
112
+ (value, options) => {
113
+ editor.update(() => {
114
+ var _a, _b;
115
+ node.setValue(value);
116
+ (_b = (_a = node.__props) == null ? void 0 : _a.onChange) == null ? void 0 : _b.call(_a, value, options);
117
+ });
118
+ },
119
+ [editor, node]
120
+ );
121
+ const handleClear = (0, import_react.useCallback)(() => {
122
+ editor.update(() => {
123
+ var _a, _b;
124
+ node.setValue(void 0);
125
+ (_b = (_a = node.__props) == null ? void 0 : _a.onClear) == null ? void 0 : _b.call(_a);
126
+ });
127
+ }, [editor, node]);
128
+ return /* @__PURE__ */ React.createElement(import_antd.Select, { ...selectProps, value: node.getValue(), onChange: handleChange, onClear: handleClear });
129
+ }
130
+ function $createSelectNode(props) {
131
+ return new SelectNode(props);
132
+ }
133
+ function $isSelectNode(node) {
134
+ return node instanceof SelectNode;
135
+ }
136
+ function $insertSelectNode(editor, props) {
137
+ editor.update(() => {
138
+ const selectNode = $createSelectNode({
139
+ ...props,
140
+ containerStyle: {
141
+ paddingLeft: "8px",
142
+ paddingRight: "8px",
143
+ ...props.containerStyle
144
+ }
145
+ });
146
+ (0, import_helpers.insertNodeAtCursor)(editor, selectNode);
147
+ });
148
+ }
149
+ // Annotate the CommonJS export names for ESM import in node:
150
+ 0 && (module.exports = {
151
+ $createSelectNode,
152
+ $insertSelectNode,
153
+ $isSelectNode,
154
+ SelectNode
155
+ });
156
+ //# sourceMappingURL=SelectNode.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/components/Lexical/nodes/SelectNode.tsx"],
4
+ "sourcesContent": ["import { type CSSProperties, type ReactNode, useCallback } from 'react';\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\nimport { Select } from 'antd';\nimport type { SelectProps } from 'antd';\nimport type { BaseOptionType, DefaultOptionType } from 'antd/es/select';\nimport type { LexicalEditor, LexicalNode, SerializedLexicalNode, Spread } from 'lexical';\nimport { insertNodeAtCursor, updateDomStyle } from '../helpers';\nimport type { BaseDecoratorNodeProps } from './base';\nimport { BaseDecoratorNode } from './base';\n\n/**\n * - EN: Props for SelectNode, extending antd Select props plus behavior flags.\n * - CN: SelectNode 的属性,基于 antd Select 属性并附加行为标记。\n */\nexport interface SelectNodeProps<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> extends SelectProps<ValueType, OptionType>,\n BaseDecoratorNodeProps {\n /**\n * - EN: When reading editor textContent, whether to use option label or value. Default `value`.\n * - CN: 在获取 editor 的 textContent 时,使用选项的 label 还是 value。默认 `value`。\n * - label: use option label as text\n * - value: use option value as text\n */\n textContentMode?: 'label' | 'value';\n /**\n * - EN: Add a space around textContent. Default `true`.\n * - CN: 是否在 textContent 两边添加一个空格,默认 `true`。\n */\n spaceAround?: boolean;\n /**\n * - EN: Container DOM style.\n * - CN: 容器样式。\n */\n containerStyle?: CSSProperties;\n}\n\nexport class SelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> extends BaseDecoratorNode<ReactNode, SelectNodeProps<ValueType, OptionType>> {\n __value: ValueType | undefined;\n\n constructor(props?: SelectNodeProps<ValueType, OptionType> & { key?: string }) {\n super(props);\n this.__value = props?.defaultValue ?? undefined;\n }\n static getType(): string {\n return 'antd.Select';\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static clone<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(\n node: SelectNode<ValueType, OptionType>\n ): SelectNode<ValueType, OptionType> {\n return new SelectNode<ValueType, OptionType>({ ...node.__props, key: node.getKey() });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static importJSON<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(\n serializedNode: SerializedSelectNode<ValueType, OptionType>\n ): SelectNode<ValueType, OptionType> {\n return $createSelectNode(serializedNode.props);\n }\n\n exportJSON(): SerializedSelectNode<ValueType, OptionType> {\n return {\n ...super.exportJSON(),\n props: this.__props,\n type: this.getType(),\n version: 1,\n };\n }\n\n createDOM(): HTMLElement {\n const span = document.createElement('span');\n updateDomStyle(span, this.__props?.containerStyle);\n return span;\n }\n\n updateDOM(): false {\n return false;\n }\n\n decorate(): ReactNode {\n return <SelectComponent node={this} />;\n }\n\n isInline(): boolean {\n return true;\n }\n\n getTextContent(): string {\n let content: string;\n const valueContent = this.__value ? String(this.__value) : '';\n if (this.__props?.textContentMode === 'label') {\n const option = this.__props?.options?.find((opt) => opt.value === this.__value);\n content = option?.label ? String(option.label) : valueContent;\n } else {\n content = valueContent;\n }\n if (this.__props?.spaceAround !== false) {\n return ` ${content} `;\n }\n return content;\n }\n\n getValue(): ValueType | undefined {\n return this.__value;\n }\n\n setValue(value: ValueType | undefined): void {\n const writable = this.getWritable();\n writable.__value = value;\n }\n\n getPropValue(\n propName: keyof SelectNodeProps<ValueType, OptionType>\n ): SelectNodeProps<ValueType, OptionType>[typeof propName] {\n return this.__props?.[propName];\n }\n\n setProps(props: Partial<SelectNodeProps<ValueType, OptionType>>): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props,\n ...props,\n };\n }\n}\n\n/**\n * - EN: React decorator component rendered for SelectNode.\n * - CN: SelectNode 对应的 React 装饰组件。\n *\n * @param node The bound SelectNode instance | 关联的 SelectNode 实例\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction SelectComponent<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>({\n node,\n}: SelectComponentProps<ValueType, OptionType>): ReactNode {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { textContentMode, spaceAround, containerStyle, ...selectProps } = node.__props || {};\n /* eslint-enable @typescript-eslint/no-unused-vars */\n const [editor] = useLexicalComposerContext();\n\n const handleChange = useCallback<NonNullable<SelectNodeProps<ValueType, OptionType>['onChange']>>(\n (value, options) => {\n editor.update(() => {\n node.setValue(value);\n node.__props?.onChange?.(value, options);\n });\n },\n [editor, node]\n );\n\n const handleClear = useCallback(() => {\n editor.update(() => {\n node.setValue(undefined);\n node.__props?.onClear?.();\n });\n }, [editor, node]);\n\n return <Select {...selectProps} value={node.getValue()} onChange={handleChange} onClear={handleClear} />;\n}\n\n/**\n * - EN: Factory to create a SelectNode.\n * - CN: 创建 SelectNode 的工厂函数。\n *\n * @param props Props for the Select node | Select 节点的属性\n */\nexport function $createSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n>(props?: SelectNodeProps<ValueType, OptionType>): SelectNode<ValueType, OptionType> {\n return new SelectNode<ValueType, OptionType>(props);\n}\n\n/**\n * - EN: Type guard to check whether a node is SelectNode.\n * - CN: 判断节点是否为 SelectNode 的类型守卫。\n *\n * @param node Node to test | 要检测的节点\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function $isSelectNode(node: LexicalNode | null | undefined): node is SelectNode<any, any> {\n return node instanceof SelectNode;\n}\n\n/**\n * - EN: Insert a SelectNode at the current cursor position.\n * - CN: 在当前光标位置插入一个 SelectNode。\n *\n * @param editor LexicalEditor instance | LexicalEditor 实例\n * @param props Props for the Select node | Select 节点的属性\n */\nexport function $insertSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n>(editor: LexicalEditor, props: SelectNodeProps<ValueType, OptionType>): void {\n editor.update(() => {\n const selectNode = $createSelectNode<ValueType, OptionType>({\n ...props,\n containerStyle: {\n paddingLeft: '8px',\n paddingRight: '8px',\n ...props.containerStyle,\n },\n });\n insertNodeAtCursor(editor, selectNode);\n });\n}\n\n/**\n * - EN: Props passed to the Select decorator component.\n * - CN: 传递给 Select 装饰组件的属性。\n */\ninterface SelectComponentProps<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> {\n node: SelectNode<ValueType, OptionType>;\n}\ntype SerializedSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> = Spread<\n {\n props?: SelectNodeProps<ValueType, OptionType>;\n },\n SerializedLexicalNode\n>;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgE;AAChE,oCAA0C;AAC1C,kBAAuB;AAIvB,qBAAmD;AAEnD,kBAAkC;AA+B3B,IAAM,aAAN,cAIG,8BAAqE;AAAA,EAG7E,YAAY,OAAmE;AAC7E,UAAM,KAAK;AACX,SAAK,WAAU,+BAAO,iBAAgB;AAAA,EACxC;AAAA,EACA,OAAO,UAAkB;AACvB,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,OAAO,MACL,MACmC;AACnC,WAAO,IAAI,WAAkC,EAAE,GAAG,KAAK,SAAS,KAAK,KAAK,OAAO,EAAE,CAAC;AAAA,EACtF;AAAA;AAAA,EAGA,OAAO,WACL,gBACmC;AACnC,WAAO,kBAAkB,eAAe,KAAK;AAAA,EAC/C;AAAA,EAEA,aAA0D;AACxD,WAAO;AAAA,MACL,GAAG,MAAM,WAAW;AAAA,MACpB,OAAO,KAAK;AAAA,MACZ,MAAM,KAAK,QAAQ;AAAA,MACnB,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EAEA,YAAyB;AA7E3B;AA8EI,UAAM,OAAO,SAAS,cAAc,MAAM;AAC1C,uCAAe,OAAM,UAAK,YAAL,mBAAc,cAAc;AACjD,WAAO;AAAA,EACT;AAAA,EAEA,YAAmB;AACjB,WAAO;AAAA,EACT;AAAA,EAEA,WAAsB;AACpB,WAAO,oCAAC,mBAAgB,MAAM,MAAM;AAAA,EACtC;AAAA,EAEA,WAAoB;AAClB,WAAO;AAAA,EACT;AAAA,EAEA,iBAAyB;AA/F3B;AAgGI,QAAI;AACJ,UAAM,eAAe,KAAK,UAAU,OAAO,KAAK,OAAO,IAAI;AAC3D,UAAI,UAAK,YAAL,mBAAc,qBAAoB,SAAS;AAC7C,YAAM,UAAS,gBAAK,YAAL,mBAAc,YAAd,mBAAuB,KAAK,CAAC,QAAQ,IAAI,UAAU,KAAK;AACvE,iBAAU,iCAAQ,SAAQ,OAAO,OAAO,KAAK,IAAI;AAAA,IACnD,OAAO;AACL,gBAAU;AAAA,IACZ;AACA,UAAI,UAAK,YAAL,mBAAc,iBAAgB,OAAO;AACvC,aAAO,IAAI;AAAA,IACb;AACA,WAAO;AAAA,EACT;AAAA,EAEA,WAAkC;AAChC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,SAAS,OAAoC;AAC3C,UAAM,WAAW,KAAK,YAAY;AAClC,aAAS,UAAU;AAAA,EACrB;AAAA,EAEA,aACE,UACyD;AAzH7D;AA0HI,YAAO,UAAK,YAAL,mBAAe;AAAA,EACxB;AAAA,EAEA,SAAS,OAA8D;AACrE,UAAM,WAAW,KAAK,YAAY;AAClC,aAAS,UAAU;AAAA,MACjB,GAAG,SAAS;AAAA,MACZ,GAAG;AAAA,IACL;AAAA,EACF;AACF;AASA,SAAS,gBAA4G;AAAA,EACnH;AACF,GAA2D;AAEzD,QAAM,EAAE,iBAAiB,aAAa,gBAAgB,GAAG,YAAY,IAAI,KAAK,WAAW,CAAC;AAE1F,QAAM,CAAC,MAAM,QAAI,yDAA0B;AAE3C,QAAM,mBAAe;AAAA,IACnB,CAAC,OAAO,YAAY;AAClB,aAAO,OAAO,MAAM;AAvJ1B;AAwJQ,aAAK,SAAS,KAAK;AACnB,yBAAK,YAAL,mBAAc,aAAd,4BAAyB,OAAO;AAAA,MAClC,CAAC;AAAA,IACH;AAAA,IACA,CAAC,QAAQ,IAAI;AAAA,EACf;AAEA,QAAM,kBAAc,0BAAY,MAAM;AACpC,WAAO,OAAO,MAAM;AAhKxB;AAiKM,WAAK,SAAS,MAAS;AACvB,uBAAK,YAAL,mBAAc,YAAd;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,QAAQ,IAAI,CAAC;AAEjB,SAAO,oCAAC,sBAAQ,GAAG,aAAa,OAAO,KAAK,SAAS,GAAG,UAAU,cAAc,SAAS,aAAa;AACxG;AAQO,SAAS,kBAId,OAAmF;AACnF,SAAO,IAAI,WAAkC,KAAK;AACpD;AASO,SAAS,cAAc,MAAoE;AAChG,SAAO,gBAAgB;AACzB;AASO,SAAS,kBAId,QAAuB,OAAqD;AAC5E,SAAO,OAAO,MAAM;AAClB,UAAM,aAAa,kBAAyC;AAAA,MAC1D,GAAG;AAAA,MACH,gBAAgB;AAAA,QACd,aAAa;AAAA,QACb,cAAc;AAAA,QACd,GAAG,MAAM;AAAA,MACX;AAAA,IACF,CAAC;AACD,2CAAmB,QAAQ,UAAU;AAAA,EACvC,CAAC;AACH;",
6
+ "names": []
7
+ }
@@ -0,0 +1,102 @@
1
+ import type { LexicalNode } from 'lexical';
2
+ import { DecoratorNode, ElementNode } from 'lexical';
3
+ /**
4
+ * - EN: Common behavior flags for custom nodes.
5
+ * - CN: 自定义节点的通用行为标记。
6
+ */
7
+ export interface BaseNodeProps {
8
+ /**
9
+ * - EN: Whether the node can be removed. Default `true`.
10
+ * - CN: 是否可被删除,默认 `true`。
11
+ */
12
+ canBeRemoved?: boolean;
13
+ /**
14
+ * - EN: Whether the node can be replaced. Default `true`.
15
+ * - CN: 是否可被替换,默认 `true`。
16
+ */
17
+ canBeReplaced?: boolean;
18
+ }
19
+ /**
20
+ * - EN: Extra behavior flags for element nodes.
21
+ * - CN: 元素节点的附加行为标记。
22
+ */
23
+ export interface BaseElementProps extends BaseNodeProps {
24
+ /**
25
+ * - EN: Whether an element is allowed to be empty. Default `false`.
26
+ * - CN: 是否允许节点为空,默认 `false`。
27
+ */
28
+ canBeEmpty?: boolean;
29
+ /**
30
+ * - EN: Allow inserting text at the start of the element. Default `true`.
31
+ * - CN: 是否允许在节点内的起始位置插入文本,默认 `true`。
32
+ */
33
+ canInsertTextBefore?: boolean;
34
+ /**
35
+ * - EN: Allow inserting text at the end of the element. Default `true`.
36
+ * - CN: 是否允许在节点内的结束位置插入文本,默认 `true`。
37
+ */
38
+ canInsertTextAfter?: boolean;
39
+ }
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
+ */
48
+ export declare class BaseNodeHelper<P extends BaseNodeProps> {
49
+ __props: (P & BaseNodeProps) | undefined;
50
+ __superMethods: Pick<LexicalNode, 'replace' | 'remove'>;
51
+ constructor(props: P | undefined, superMethods: Pick<LexicalNode, 'replace' | 'remove'>);
52
+ hooks: {
53
+ remove: (preserveEmptyParent?: boolean) => void;
54
+ replace: <N extends LexicalNode>(replaceWith: N, includeChildren?: boolean) => N;
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
+ */
62
+ getUnderlyingProps(props: P & BaseNodeProps): Omit<P, keyof BaseNodeProps>;
63
+ }
64
+ /**
65
+ * - EN: Base element node with behavior flags.
66
+ * - CN: 带行为标记的基础元素节点。
67
+ */
68
+ export declare class BaseElementNode<P extends BaseElementProps> extends ElementNode {
69
+ __props: P | undefined;
70
+ __base: BaseNodeHelper<P>;
71
+ constructor(props?: P & {
72
+ key?: string;
73
+ });
74
+ canBeEmpty(): boolean;
75
+ canInsertTextBefore(): boolean;
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
+ */
83
+ getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseElementProps>;
84
+ }
85
+ /**
86
+ * - EN: Base decorator node with behavior flags.
87
+ * - CN: 带行为标记的基础装饰器节点。
88
+ */
89
+ export declare class BaseDecoratorNode<T, P extends BaseDecoratorNodeProps> extends DecoratorNode<T> {
90
+ __props: P | undefined;
91
+ __base: BaseNodeHelper<P>;
92
+ constructor(props?: P & {
93
+ key?: string;
94
+ });
95
+ /**
96
+ * - EN: Strip decorator-specific flags and return DOM props.
97
+ * - CN: 去除装饰器特有的标记并返回 DOM 属性。
98
+ *
99
+ * @param props Decorator props including flags | 含标记的装饰器属性
100
+ */
101
+ getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseDecoratorNodeProps>;
102
+ }
@@ -0,0 +1,134 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/Lexical/nodes/base.ts
20
+ var base_exports = {};
21
+ __export(base_exports, {
22
+ BaseDecoratorNode: () => BaseDecoratorNode,
23
+ BaseElementNode: () => BaseElementNode,
24
+ BaseNodeHelper: () => BaseNodeHelper
25
+ });
26
+ module.exports = __toCommonJS(base_exports);
27
+ var import_lexical = require("lexical");
28
+ var BaseNodeHelper = class {
29
+ constructor(props, superMethods) {
30
+ this.hooks = {
31
+ remove: (preserveEmptyParent) => {
32
+ var _a;
33
+ if (((_a = this.__props) == null ? void 0 : _a.canBeRemoved) === false) {
34
+ return;
35
+ }
36
+ this.__superMethods.remove(preserveEmptyParent);
37
+ },
38
+ replace: (replaceWith, includeChildren) => {
39
+ var _a;
40
+ if (((_a = this.__props) == null ? void 0 : _a.canBeReplaced) === false) {
41
+ return this;
42
+ }
43
+ return this.__superMethods.replace(replaceWith, includeChildren);
44
+ }
45
+ };
46
+ this.__props = props;
47
+ this.__superMethods = superMethods;
48
+ }
49
+ /**
50
+ * - EN: Strip helper-only flags from props for DOM usage.
51
+ * - CN: 去除仅用于帮助器的标记属性,得到用于 DOM 的纯属性。
52
+ *
53
+ * @param props Props including helper flags | 含帮助标记的属性
54
+ */
55
+ getUnderlyingProps(props) {
56
+ const { canBeRemoved, canBeReplaced, ...restProps } = props;
57
+ return restProps;
58
+ }
59
+ };
60
+ var BaseElementNode = class extends import_lexical.ElementNode {
61
+ constructor(props) {
62
+ const { key, ...restProps } = props || {};
63
+ super(key);
64
+ this.__props = restProps;
65
+ this.__base = new BaseNodeHelper(this.__props, {
66
+ remove: () => super.remove(),
67
+ replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren)
68
+ });
69
+ Object.keys(this.__base.hooks).forEach((key2) => {
70
+ const method = this.__base.hooks[key2];
71
+ if (typeof method === "function") {
72
+ this[key2] = method.bind(this.__base);
73
+ }
74
+ });
75
+ }
76
+ canBeEmpty() {
77
+ var _a;
78
+ return ((_a = this.__props) == null ? void 0 : _a.canBeEmpty) ?? false;
79
+ }
80
+ canInsertTextBefore() {
81
+ var _a;
82
+ return ((_a = this.__props) == null ? void 0 : _a.canInsertTextBefore) ?? true;
83
+ }
84
+ canInsertTextAfter() {
85
+ var _a;
86
+ return ((_a = this.__props) == null ? void 0 : _a.canInsertTextAfter) ?? true;
87
+ }
88
+ /**
89
+ * - EN: Strip element-specific flags and return DOM props.
90
+ * - CN: 去除元素特有的标记并返回 DOM 属性。
91
+ *
92
+ * @param props Element props including flags | 含标记的元素属性
93
+ */
94
+ getUnderlyingProps(props) {
95
+ const baseProps = this.__base.getUnderlyingProps(props ?? {});
96
+ const { canBeEmpty, canInsertTextBefore, canInsertTextAfter, ...restProps } = baseProps;
97
+ return restProps;
98
+ }
99
+ };
100
+ var BaseDecoratorNode = class extends import_lexical.DecoratorNode {
101
+ constructor(props) {
102
+ const { key, ...restProps } = props || {};
103
+ super(key);
104
+ this.__props = restProps;
105
+ this.__base = new BaseNodeHelper(this.__props, {
106
+ remove: () => super.remove(),
107
+ replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren)
108
+ });
109
+ Object.keys(this.__base.hooks).forEach((key2) => {
110
+ const method = this.__base.hooks[key2];
111
+ if (typeof method === "function") {
112
+ this[key2] = method.bind(this.__base);
113
+ }
114
+ });
115
+ }
116
+ /**
117
+ * - EN: Strip decorator-specific flags and return DOM props.
118
+ * - CN: 去除装饰器特有的标记并返回 DOM 属性。
119
+ *
120
+ * @param props Decorator props including flags | 含标记的装饰器属性
121
+ */
122
+ getUnderlyingProps(props) {
123
+ const baseProps = this.__base.getUnderlyingProps(props ?? {});
124
+ const { ...restProps } = baseProps;
125
+ return restProps;
126
+ }
127
+ };
128
+ // Annotate the CommonJS export names for ESM import in node:
129
+ 0 && (module.exports = {
130
+ BaseDecoratorNode,
131
+ BaseElementNode,
132
+ BaseNodeHelper
133
+ });
134
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/components/Lexical/nodes/base.ts"],
4
+ "sourcesContent": ["import type { LexicalNode } from 'lexical';\nimport { DecoratorNode, ElementNode } from 'lexical';\n\n/**\n * - EN: Common behavior flags for custom nodes.\n * - CN: 自定义节点的通用行为标记。\n */\nexport interface BaseNodeProps {\n /**\n * - EN: Whether the node can be removed. Default `true`.\n * - CN: 是否可被删除,默认 `true`。\n */\n canBeRemoved?: boolean;\n /**\n * - EN: Whether the node can be replaced. Default `true`.\n * - CN: 是否可被替换,默认 `true`。\n */\n canBeReplaced?: boolean;\n}\n/**\n * - EN: Extra behavior flags for element nodes.\n * - CN: 元素节点的附加行为标记。\n */\nexport interface BaseElementProps extends BaseNodeProps {\n /**\n * - EN: Whether an element is allowed to be empty. Default `false`.\n * - CN: 是否允许节点为空,默认 `false`。\n */\n canBeEmpty?: boolean;\n /**\n * - EN: Allow inserting text at the start of the element. Default `true`.\n * - CN: 是否允许在节点内的起始位置插入文本,默认 `true`。\n */\n canInsertTextBefore?: boolean;\n /**\n * - EN: Allow inserting text at the end of the element. Default `true`.\n * - CN: 是否允许在节点内的结束位置插入文本,默认 `true`。\n */\n canInsertTextAfter?: boolean;\n}\n\nexport type BaseDecoratorNodeProps = BaseNodeProps;\n\n/**\n * - EN: A helper wrapping base behaviors (remove/replace) with guard flags.\n * - CN: 封装基础行为(删除/替换)并根据标记进行限制的帮助器。\n *\n * @param props Node behavior flags | 节点行为标记\n * @param superMethods Methods delegated to the underlying node | 委托给底层节点的方法\n */\nexport class BaseNodeHelper<P extends BaseNodeProps> {\n __props: (P & BaseNodeProps) | undefined;\n __superMethods: Pick<LexicalNode, 'replace' | 'remove'>;\n\n constructor(props: P | undefined, superMethods: Pick<LexicalNode, 'replace' | 'remove'>) {\n this.__props = props as P & BaseNodeProps;\n this.__superMethods = superMethods;\n }\n\n hooks = {\n remove: (preserveEmptyParent?: boolean): void => {\n if (this.__props?.canBeRemoved === false) {\n return;\n }\n this.__superMethods.remove(preserveEmptyParent);\n },\n\n replace: <N extends LexicalNode>(replaceWith: N, includeChildren?: boolean): N => {\n if (this.__props?.canBeReplaced === false) {\n return this as unknown as N;\n }\n return this.__superMethods.replace(replaceWith, includeChildren);\n },\n };\n /**\n * - EN: Strip helper-only flags from props for DOM usage.\n * - CN: 去除仅用于帮助器的标记属性,得到用于 DOM 的纯属性。\n *\n * @param props Props including helper flags | 含帮助标记的属性\n */\n getUnderlyingProps(props: P & BaseNodeProps): Omit<P, keyof BaseNodeProps> {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { canBeRemoved, canBeReplaced, ...restProps } = props;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n\n/**\n * - EN: Base element node with behavior flags.\n * - CN: 带行为标记的基础元素节点。\n */\nexport class BaseElementNode<P extends BaseElementProps> extends ElementNode {\n __props: P | undefined;\n __base: BaseNodeHelper<P>;\n\n constructor(props?: P & { key?: string }) {\n const { key, ...restProps } = props || {};\n super(key);\n this.__props = restProps as P;\n this.__base = new BaseNodeHelper<P>(this.__props, {\n remove: () => super.remove(),\n replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren),\n });\n Object.keys(this.__base.hooks).forEach((key) => {\n const method = this.__base.hooks[key as keyof typeof this.__base.hooks];\n if (typeof method === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this[key as keyof this] = method.bind(this.__base) as any;\n }\n });\n }\n\n canBeEmpty(): boolean {\n return this.__props?.canBeEmpty ?? false;\n }\n\n canInsertTextBefore(): boolean {\n return this.__props?.canInsertTextBefore ?? true;\n }\n\n canInsertTextAfter(): boolean {\n return this.__props?.canInsertTextAfter ?? true;\n }\n\n /**\n * - EN: Strip element-specific flags and return DOM props.\n * - CN: 去除元素特有的标记并返回 DOM 属性。\n *\n * @param props Element props including flags | 含标记的元素属性\n */\n getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseElementProps> {\n const baseProps = this.__base.getUnderlyingProps(props ?? ({} as P));\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { canBeEmpty, canInsertTextBefore, canInsertTextAfter, ...restProps } = baseProps;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n\n/**\n * - EN: Base decorator node with behavior flags.\n * - CN: 带行为标记的基础装饰器节点。\n */\nexport class BaseDecoratorNode<T, P extends BaseDecoratorNodeProps> extends DecoratorNode<T> {\n __props: P | undefined;\n __base: BaseNodeHelper<P>;\n\n constructor(props?: P & { key?: string }) {\n const { key, ...restProps } = props || {};\n super(key);\n this.__props = restProps as P;\n\n this.__base = new BaseNodeHelper<P>(this.__props, {\n remove: () => super.remove(),\n replace: (replaceWith, includeChildren) => super.replace(replaceWith, includeChildren),\n });\n Object.keys(this.__base.hooks).forEach((key) => {\n const method = this.__base.hooks[key as keyof typeof this.__base.hooks];\n if (typeof method === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this[key as keyof this] = method.bind(this.__base) as any;\n }\n });\n }\n\n /**\n * - EN: Strip decorator-specific flags and return DOM props.\n * - CN: 去除装饰器特有的标记并返回 DOM 属性。\n *\n * @param props Decorator props including flags | 含标记的装饰器属性\n */\n getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseDecoratorNodeProps> {\n const baseProps = this.__base.getUnderlyingProps(props ?? ({} as P));\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { ...restProps } = baseProps;\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return restProps as P;\n }\n}\n"],
5
+ "mappings": "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",
6
+ "names": ["key"]
7
+ }
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import type { RefObject } from 'react';
2
2
  /**
3
3
  * - **EN:** Get a mutable ref object and automatically update the value change
4
4
  * - **CN:** 获取一个可变的ref对象,并自动更新值变化
@@ -7,5 +7,5 @@
7
7
  *
8
8
  * @returns A mutable ref object, but the reference is immutable | 可变的ref对象,但引用不可变
9
9
  */
10
- declare const useRefValue: <T>(value: T) => import("react").RefObject<T>;
10
+ declare const useRefValue: <T>(value: T) => RefObject<T>;
11
11
  export default useRefValue;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/useRefValue.ts"],
4
- "sourcesContent": ["import { useRef } from 'react';\n\n/**\n * - **EN:** Get a mutable ref object and automatically update the value change\n * - **CN:** 获取一个可变的ref对象,并自动更新值变化\n *\n * @param value the wrapped value | 被包装的值\n *\n * @returns A mutable ref object, but the reference is immutable | 可变的ref对象,但引用不可变\n */\nconst useRefValue = <T>(value: T) => {\n const ref = useRef<T>(value);\n ref.current = value;\n return ref;\n};\n\nexport default useRefValue;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AAUvB,IAAM,cAAc,CAAI,UAAa;AACnC,QAAM,UAAM,qBAAU,KAAK;AAC3B,MAAI,UAAU;AACd,SAAO;AACT;AAEA,IAAO,sBAAQ;",
4
+ "sourcesContent": ["import type { RefObject } from 'react';\nimport { useRef } from 'react';\n\n/**\n * - **EN:** Get a mutable ref object and automatically update the value change\n * - **CN:** 获取一个可变的ref对象,并自动更新值变化\n *\n * @param value the wrapped value | 被包装的值\n *\n * @returns A mutable ref object, but the reference is immutable | 可变的ref对象,但引用不可变\n */\nconst useRefValue = <T>(value: T): RefObject<T> => {\n const ref = useRef<T>(value);\n ref.current = value;\n return ref;\n};\n\nexport default useRefValue;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAuB;AAUvB,IAAM,cAAc,CAAI,UAA2B;AACjD,QAAM,UAAM,qBAAU,KAAK;AAC3B,MAAI,UAAU;AACd,SAAO;AACT;AAEA,IAAO,sBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,3 @@
1
1
  export * from './color';
2
2
  export * from './math';
3
+ export * from './string';