@tiny-codes/react-easy 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/es/components/ConfirmAction/withConfirmAction.js +23 -1
  3. package/es/components/ConfirmAction/withConfirmAction.js.map +1 -1
  4. package/es/components/Lexical/helpers/index.d.ts +58 -0
  5. package/es/components/Lexical/helpers/index.js +249 -0
  6. package/es/components/Lexical/helpers/index.js.map +1 -0
  7. package/es/components/Lexical/index.d.ts +5 -0
  8. package/es/components/Lexical/index.js +6 -0
  9. package/es/components/Lexical/index.js.map +1 -0
  10. package/es/components/Lexical/nodes/DivNode.d.ts +25 -0
  11. package/es/components/Lexical/nodes/DivNode.js +163 -0
  12. package/es/components/Lexical/nodes/DivNode.js.map +1 -0
  13. package/es/components/Lexical/nodes/ExtendTextNode.d.ts +24 -0
  14. package/es/components/Lexical/nodes/ExtendTextNode.js +102 -0
  15. package/es/components/Lexical/nodes/ExtendTextNode.js.map +1 -0
  16. package/es/components/Lexical/nodes/SelectNode.d.ts +44 -0
  17. package/es/components/Lexical/nodes/SelectNode.js +204 -0
  18. package/es/components/Lexical/nodes/SelectNode.js.map +1 -0
  19. package/es/components/Lexical/nodes/base.d.ts +51 -0
  20. package/es/components/Lexical/nodes/base.js +168 -0
  21. package/es/components/Lexical/nodes/base.js.map +1 -0
  22. package/es/hooks/useRefValue.d.ts +2 -2
  23. package/es/hooks/useRefValue.js.map +1 -1
  24. package/lib/components/ConfirmAction/withConfirmAction.js +5 -1
  25. package/lib/components/ConfirmAction/withConfirmAction.js.map +2 -2
  26. package/lib/components/Lexical/helpers/index.d.ts +58 -0
  27. package/lib/components/Lexical/helpers/index.js +198 -0
  28. package/lib/components/Lexical/helpers/index.js.map +7 -0
  29. package/lib/components/Lexical/index.d.ts +5 -0
  30. package/lib/components/Lexical/index.js +32 -0
  31. package/lib/components/Lexical/index.js.map +7 -0
  32. package/lib/components/Lexical/nodes/DivNode.d.ts +25 -0
  33. package/lib/components/Lexical/nodes/DivNode.js +139 -0
  34. package/lib/components/Lexical/nodes/DivNode.js.map +7 -0
  35. package/lib/components/Lexical/nodes/ExtendTextNode.d.ts +24 -0
  36. package/lib/components/Lexical/nodes/ExtendTextNode.js +87 -0
  37. package/lib/components/Lexical/nodes/ExtendTextNode.js.map +7 -0
  38. package/lib/components/Lexical/nodes/SelectNode.d.ts +44 -0
  39. package/lib/components/Lexical/nodes/SelectNode.js +157 -0
  40. package/lib/components/Lexical/nodes/SelectNode.js.map +7 -0
  41. package/lib/components/Lexical/nodes/base.d.ts +51 -0
  42. package/lib/components/Lexical/nodes/base.js +116 -0
  43. package/lib/components/Lexical/nodes/base.js.map +7 -0
  44. package/lib/hooks/useRefValue.d.ts +2 -2
  45. package/lib/hooks/useRefValue.js.map +2 -2
  46. package/package.json +20 -1
@@ -0,0 +1,32 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/components/Lexical/index.ts
17
+ var Lexical_exports = {};
18
+ module.exports = __toCommonJS(Lexical_exports);
19
+ __reExport(Lexical_exports, require("./helpers"), module.exports);
20
+ __reExport(Lexical_exports, require("./nodes/base"), module.exports);
21
+ __reExport(Lexical_exports, require("./nodes/DivNode"), module.exports);
22
+ __reExport(Lexical_exports, require("./nodes/SelectNode"), module.exports);
23
+ __reExport(Lexical_exports, require("./nodes/ExtendTextNode"), module.exports);
24
+ // Annotate the CommonJS export names for ESM import in node:
25
+ 0 && (module.exports = {
26
+ ...require("./helpers"),
27
+ ...require("./nodes/base"),
28
+ ...require("./nodes/DivNode"),
29
+ ...require("./nodes/SelectNode"),
30
+ ...require("./nodes/ExtendTextNode")
31
+ });
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Lexical/index.ts"],
4
+ "sourcesContent": ["export * from './helpers';\nexport * from './nodes/base';\nexport * from './nodes/DivNode';\nexport * from './nodes/SelectNode';\nexport * from './nodes/ExtendTextNode';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,4BAAc,sBAAd;AACA,4BAAc,yBADd;AAEA,4BAAc,4BAFd;AAGA,4BAAc,+BAHd;AAIA,4BAAc,mCAJd;",
6
+ "names": []
7
+ }
@@ -0,0 +1,25 @@
1
+ import type { CSSProperties, HtmlHTMLAttributes } from 'react';
2
+ import type { DOMConversionMap, DOMExportOutput, LexicalNode, SerializedElementNode, Spread } from 'lexical';
3
+ import { BaseElementNode, type BaseElementProps } from './base';
4
+ export interface DivNodeProps extends HtmlHTMLAttributes<HTMLDivElement>, BaseElementProps {
5
+ }
6
+ export type SerializedDivNode = Spread<{
7
+ props?: DivNodeProps;
8
+ }, SerializedElementNode>;
9
+ export declare class DivNode extends BaseElementNode<DivNodeProps> {
10
+ static getType(): string;
11
+ static clone(node: DivNode): DivNode;
12
+ protected getForceDisplay(): CSSProperties['display'];
13
+ createDOM(): HTMLElement;
14
+ updateDOM(prevNode: DivNode, dom: HTMLElement): boolean;
15
+ static importDOM(): DOMConversionMap | null;
16
+ static importJSON(serializedNode: SerializedDivNode): DivNode;
17
+ exportJSON(): SerializedDivNode;
18
+ exportDOM(): DOMExportOutput;
19
+ isInline(): boolean;
20
+ getPropValue<K extends keyof DivNodeProps>(key: K): DivNodeProps[K] | undefined;
21
+ setProps(props: DivNodeProps): void;
22
+ private shallowEqual;
23
+ }
24
+ export declare function $createDivNode(props?: DivNodeProps): DivNode;
25
+ export declare function $isDivNode(node: LexicalNode | null | undefined): node is DivNode;
@@ -0,0 +1,139 @@
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/DivNode.tsx
20
+ var DivNode_exports = {};
21
+ __export(DivNode_exports, {
22
+ $createDivNode: () => $createDivNode,
23
+ $isDivNode: () => $isDivNode,
24
+ DivNode: () => DivNode
25
+ });
26
+ module.exports = __toCommonJS(DivNode_exports);
27
+ var import_helpers = require("../helpers");
28
+ var import_base = require("./base");
29
+ var DivNode = class extends import_base.BaseElementNode {
30
+ static getType() {
31
+ return "html.div";
32
+ }
33
+ static clone(node) {
34
+ return new DivNode({ ...node.__props, key: node.getKey() });
35
+ }
36
+ getForceDisplay() {
37
+ return void 0;
38
+ }
39
+ createDOM() {
40
+ const div = document.createElement("div");
41
+ const domProps = this.getUnderlyingProps(this.__props);
42
+ if (domProps) {
43
+ (0, import_helpers.updateDomProps)(div, domProps);
44
+ }
45
+ return div;
46
+ }
47
+ updateDOM(prevNode, dom) {
48
+ const prevProps = prevNode.__props;
49
+ const currentProps = this.__props;
50
+ const propsChanged = !this.shallowEqual(prevProps, currentProps);
51
+ if (propsChanged) {
52
+ (0, import_helpers.updateDomProps)(dom, this.getUnderlyingProps(currentProps));
53
+ }
54
+ return false;
55
+ }
56
+ static importDOM() {
57
+ return {
58
+ div: (node) => ({
59
+ conversion: convertDivElement,
60
+ priority: 1
61
+ })
62
+ };
63
+ }
64
+ static importJSON(serializedNode) {
65
+ return $createDivNode(serializedNode.props);
66
+ }
67
+ exportJSON() {
68
+ return {
69
+ ...super.exportJSON(),
70
+ props: this.__props,
71
+ type: this.getType()
72
+ };
73
+ }
74
+ exportDOM() {
75
+ const element = this.createDOM();
76
+ return { element };
77
+ }
78
+ isInline() {
79
+ var _a, _b;
80
+ const display = (_b = (_a = this.__props) == null ? void 0 : _a.style) == null ? void 0 : _b.display;
81
+ return display === "inline" || display === "inline-flex" || display === "inline-block" || display === "inline-grid" || display === "inline-table" || display === "inline-list-item";
82
+ }
83
+ getPropValue(key) {
84
+ var _a;
85
+ return (_a = this.__props) == null ? void 0 : _a[key];
86
+ }
87
+ setProps(props) {
88
+ var _a;
89
+ const writable = this.getWritable();
90
+ writable.__props = {
91
+ ...writable.__props,
92
+ ...props,
93
+ style: {
94
+ ...(_a = writable.__props) == null ? void 0 : _a.style,
95
+ ...props.style
96
+ }
97
+ };
98
+ }
99
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
+ shallowEqual(obj1, obj2) {
101
+ if (obj1 === obj2)
102
+ return true;
103
+ if (!obj1 || !obj2)
104
+ return false;
105
+ const keys1 = Object.keys(obj1);
106
+ const keys2 = Object.keys(obj2);
107
+ if (keys1.length !== keys2.length)
108
+ return false;
109
+ for (const key of keys1) {
110
+ if (key === "style") {
111
+ if (!this.shallowEqual(obj1[key], obj2[key]))
112
+ return false;
113
+ } else if (obj1[key] !== obj2[key]) {
114
+ return false;
115
+ }
116
+ }
117
+ return true;
118
+ }
119
+ };
120
+ function convertDivElement(domNode) {
121
+ const element = domNode;
122
+ if (element.nodeName === "DIV") {
123
+ return { node: $createDivNode() };
124
+ }
125
+ return { node: null };
126
+ }
127
+ function $createDivNode(props) {
128
+ return new DivNode(props);
129
+ }
130
+ function $isDivNode(node) {
131
+ return node instanceof DivNode;
132
+ }
133
+ // Annotate the CommonJS export names for ESM import in node:
134
+ 0 && (module.exports = {
135
+ $createDivNode,
136
+ $isDivNode,
137
+ DivNode
138
+ });
139
+ //# sourceMappingURL=DivNode.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/components/Lexical/nodes/DivNode.tsx"],
4
+ "sourcesContent": ["import type { CSSProperties, HtmlHTMLAttributes } from 'react';\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n LexicalNode,\n SerializedElementNode,\n Spread,\n} from 'lexical';\nimport { updateDomProps } from '../helpers';\nimport { BaseElementNode, type BaseElementProps } from './base';\n\nexport interface DivNodeProps extends HtmlHTMLAttributes<HTMLDivElement>, BaseElementProps {}\n\nexport type SerializedDivNode = Spread<\n {\n props?: DivNodeProps;\n },\n SerializedElementNode\n>;\n\nexport class DivNode extends BaseElementNode<DivNodeProps> {\n static getType(): string {\n return 'html.div';\n }\n\n static clone(node: DivNode): DivNode {\n return new DivNode({ ...node.__props, key: node.getKey() });\n }\n\n protected getForceDisplay(): CSSProperties['display'] {\n return undefined;\n }\n\n createDOM(): HTMLElement {\n const div = document.createElement('div');\n const domProps = this.getUnderlyingProps(this.__props);\n if (domProps) {\n updateDomProps(div, domProps);\n }\n return div;\n }\n\n updateDOM(prevNode: DivNode, dom: HTMLElement): boolean {\n const prevProps = prevNode.__props;\n const currentProps = this.__props;\n const propsChanged = !this.shallowEqual(prevProps, currentProps);\n if (propsChanged) {\n updateDomProps(dom, this.getUnderlyingProps(currentProps));\n }\n // 不重新创建\n return false;\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n div: (node: Node) => ({\n conversion: convertDivElement,\n priority: 1,\n }),\n };\n }\n\n static importJSON(serializedNode: SerializedDivNode): DivNode {\n return $createDivNode(serializedNode.props);\n }\n\n exportJSON(): SerializedDivNode {\n return {\n ...super.exportJSON(),\n props: this.__props,\n type: this.getType(),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = this.createDOM();\n return { element };\n }\n\n isInline(): boolean {\n const display = this.__props?.style?.display;\n return (\n display === 'inline' ||\n display === 'inline-flex' ||\n display === 'inline-block' ||\n display === 'inline-grid' ||\n display === 'inline-table' ||\n display === 'inline-list-item'\n );\n }\n\n getPropValue<K extends keyof DivNodeProps>(key: K): DivNodeProps[K] | undefined {\n return this.__props?.[key];\n }\n setProps(props: DivNodeProps): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props,\n ...props,\n style: {\n ...writable.__props?.style,\n ...props.style,\n },\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private shallowEqual(obj1: any, obj2: any): boolean {\n if (obj1 === obj2) return true;\n if (!obj1 || !obj2) return false;\n\n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n\n if (keys1.length !== keys2.length) return false;\n\n for (const key of keys1) {\n if (key === 'style') {\n // 特殊处理 style 对象\n if (!this.shallowEqual(obj1[key], obj2[key])) return false;\n } else if (obj1[key] !== obj2[key]) {\n return false;\n }\n }\n\n return true;\n }\n}\n\nfunction convertDivElement(domNode: Node): DOMConversionOutput {\n const element = domNode as HTMLElement;\n if (element.nodeName === 'DIV') {\n return { node: $createDivNode() };\n }\n return { node: null };\n}\n\nexport function $createDivNode(props?: DivNodeProps): DivNode {\n return new DivNode(props);\n}\n\nexport function $isDivNode(node: LexicalNode | null | undefined): node is DivNode {\n return node instanceof DivNode;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,qBAA+B;AAC/B,kBAAuD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lexical';
3
+ import type { BaseNodeProps } from './base';
4
+ import { BaseNodeHelper } from './base';
5
+ export interface ExtendTextNodeProps extends BaseNodeProps {
6
+ text?: string;
7
+ }
8
+ export declare class ExtendTextNode extends TextNode {
9
+ __props: ExtendTextNodeProps | undefined;
10
+ __base: BaseNodeHelper<ExtendTextNodeProps>;
11
+ constructor(props?: ExtendTextNodeProps & {
12
+ key?: NodeKey;
13
+ });
14
+ static getType(): string;
15
+ static clone(node: ExtendTextNode): ExtendTextNode;
16
+ static importJSON(serializedNode: SerializedExtendTextNode): ExtendTextNode;
17
+ exportJSON(): SerializedExtendTextNode;
18
+ }
19
+ export type SerializedExtendTextNode = Spread<{
20
+ props?: ExtendTextNodeProps;
21
+ text: string;
22
+ }, SerializedTextNode>;
23
+ export declare function $createExtendTextNode(props?: ExtendTextNodeProps): ExtendTextNode;
24
+ export declare function $isExtendTextNode(node: LexicalNode | null | undefined): node is ExtendTextNode;
@@ -0,0 +1,87 @@
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.replace = (replaceWith, includeChildren) => {
45
+ var _a, _b;
46
+ if (((_a = this.__props) == null ? void 0 : _a.canBeReplaced) === false) {
47
+ this.setTextContent(((_b = this.__props) == null ? void 0 : _b.text) || "");
48
+ this.selectNext();
49
+ return this;
50
+ }
51
+ return super.replace(replaceWith, includeChildren);
52
+ };
53
+ }
54
+ static getType() {
55
+ return "html.TextNode";
56
+ }
57
+ static clone(node) {
58
+ return new ExtendTextNode({ ...node.__props, text: node.__text, key: node.getKey() });
59
+ }
60
+ static importJSON(serializedNode) {
61
+ return $createExtendTextNode({
62
+ ...serializedNode.props,
63
+ text: serializedNode.text
64
+ });
65
+ }
66
+ exportJSON() {
67
+ return {
68
+ ...super.exportJSON(),
69
+ props: this.__props,
70
+ text: this.__text,
71
+ type: this.getType()
72
+ };
73
+ }
74
+ };
75
+ function $createExtendTextNode(props) {
76
+ return new ExtendTextNode(props);
77
+ }
78
+ function $isExtendTextNode(node) {
79
+ return node instanceof ExtendTextNode;
80
+ }
81
+ // Annotate the CommonJS export names for ESM import in node:
82
+ 0 && (module.exports = {
83
+ $createExtendTextNode,
84
+ $isExtendTextNode,
85
+ ExtendTextNode
86
+ });
87
+ //# 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\nexport interface ExtendTextNodeProps extends BaseNodeProps {\n text?: string;\n}\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.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\nexport type SerializedExtendTextNode = Spread<\n {\n props?: ExtendTextNodeProps;\n text: string;\n },\n SerializedTextNode\n>;\n\nexport function $createExtendTextNode(props?: ExtendTextNodeProps): ExtendTextNode {\n return new ExtendTextNode(props);\n}\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;AAMxB,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,UAAU,CAAwB,aAAgB,oBAAiC;AA5B5F;AA6BM,YAAI,UAAK,YAAL,mBAAc,mBAAkB,OAAO;AACzC,aAAK,iBAAe,UAAK,YAAL,mBAAc,SAAQ,EAAE;AAC5C,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;AAUO,SAAS,sBAAsB,OAA6C;AACjF,SAAO,IAAI,eAAe,KAAK;AACjC;AAEO,SAAS,kBAAkB,MAA8D;AAC9F,SAAO,gBAAgB;AACzB;",
6
+ "names": ["key"]
7
+ }
@@ -0,0 +1,44 @@
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
+ export interface SelectNodeProps<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> extends SelectProps<ValueType, OptionType>, BaseDecoratorNodeProps {
8
+ /**
9
+ * 在获取editor的textContent时,是否将选项的label作为文本内容插入到编辑器中,默认 `value`
10
+ *
11
+ * - `label` - 将选项的label作为文本内容
12
+ * - `value` - 将选项的value作为文本内容
13
+ */
14
+ textContentMode?: 'label' | 'value';
15
+ /** 是否在`textContext`两边添加一个空格,默认`true` */
16
+ spaceAround?: boolean;
17
+ /** 容器样式 */
18
+ containerStyle?: CSSProperties;
19
+ }
20
+ export declare class SelectNode<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> extends BaseDecoratorNode<ReactNode, SelectNodeProps<ValueType, OptionType>> {
21
+ __value: ValueType | undefined;
22
+ constructor(props?: SelectNodeProps<ValueType, OptionType> & {
23
+ key?: string;
24
+ });
25
+ static getType(): string;
26
+ static clone<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(node: SelectNode<ValueType, OptionType>): SelectNode<ValueType, OptionType>;
27
+ static importJSON<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(serializedNode: SerializedSelectNode<ValueType, OptionType>): SelectNode<ValueType, OptionType>;
28
+ exportJSON(): SerializedSelectNode<ValueType, OptionType>;
29
+ createDOM(): HTMLElement;
30
+ updateDOM(): false;
31
+ decorate(): ReactNode;
32
+ isInline(): boolean;
33
+ getTextContent(): string;
34
+ getValue(): ValueType | undefined;
35
+ setValue(value: ValueType | undefined): void;
36
+ getPropValue(propName: keyof SelectNodeProps<ValueType, OptionType>): any;
37
+ setProps(props: SelectNodeProps<ValueType, OptionType>): void;
38
+ }
39
+ export declare function $createSelectNode<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props?: SelectNodeProps<ValueType, OptionType>): SelectNode<ValueType, OptionType>;
40
+ export declare function $isSelectNode(node: LexicalNode | null | undefined): node is SelectNode<any, any>;
41
+ export declare function $insertSelectNode<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(editor: LexicalEditor, props: SelectNodeProps<ValueType, OptionType>): void;
42
+ export type SerializedSelectNode<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> = Spread<{
43
+ props?: SelectNodeProps<ValueType, OptionType>;
44
+ }, SerializedLexicalNode>;
@@ -0,0 +1,157 @@
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
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
+ getPropValue(propName) {
96
+ var _a;
97
+ return (_a = this.__props) == null ? void 0 : _a[propName];
98
+ }
99
+ setProps(props) {
100
+ const writable = this.getWritable();
101
+ writable.__props = {
102
+ ...writable.__props,
103
+ ...props
104
+ };
105
+ }
106
+ };
107
+ function SelectComponent({
108
+ node
109
+ }) {
110
+ const { textContentMode, spaceAround, containerStyle, ...selectProps } = node.__props || {};
111
+ const [editor] = (0, import_LexicalComposerContext.useLexicalComposerContext)();
112
+ const handleChange = (0, import_react.useCallback)(
113
+ (value, options) => {
114
+ editor.update(() => {
115
+ var _a, _b;
116
+ node.setValue(value);
117
+ (_b = (_a = node.__props) == null ? void 0 : _a.onChange) == null ? void 0 : _b.call(_a, value, options);
118
+ });
119
+ },
120
+ [editor, node]
121
+ );
122
+ const handleClear = (0, import_react.useCallback)(() => {
123
+ editor.update(() => {
124
+ var _a, _b;
125
+ node.setValue(void 0);
126
+ (_b = (_a = node.__props) == null ? void 0 : _a.onClear) == null ? void 0 : _b.call(_a);
127
+ });
128
+ }, [editor, node]);
129
+ return /* @__PURE__ */ React.createElement(import_antd.Select, { ...selectProps, value: node.getValue(), onChange: handleChange, onClear: handleClear });
130
+ }
131
+ function $createSelectNode(props) {
132
+ return new SelectNode(props);
133
+ }
134
+ function $isSelectNode(node) {
135
+ return node instanceof SelectNode;
136
+ }
137
+ function $insertSelectNode(editor, props) {
138
+ editor.update(() => {
139
+ const selectNode = $createSelectNode({
140
+ ...props,
141
+ containerStyle: {
142
+ paddingLeft: "8px",
143
+ paddingRight: "8px",
144
+ ...props.containerStyle
145
+ }
146
+ });
147
+ (0, import_helpers.insertNodeAtCursor)(editor, selectNode);
148
+ });
149
+ }
150
+ // Annotate the CommonJS export names for ESM import in node:
151
+ 0 && (module.exports = {
152
+ $createSelectNode,
153
+ $insertSelectNode,
154
+ $isSelectNode,
155
+ SelectNode
156
+ });
157
+ //# 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\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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgE;AAChE,oCAA0C;AAC1C,kBAAuB;AAIvB,qBAAmD;AAEnD,kBAAkC;AAqB3B,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;AAnE3B;AAoEI,UAAM,OAAO,SAAS,cAAc,MAAM;AAC1C,uCAAe,OAAM,UAAK,YAAL,mBAAc,cAAc;AACjD,WAAO;AA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K,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;AA/IxB;AAgJM,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;AAEO,SAAS,kBAId,OAAmF;AACnF,SAAO,IAAI,WAAkC,KAAK;AACpD;AAGO,SAAS,cAAc,MAAoE;AAChG,SAAO,gBAAgB;AACzB;AAEO,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,51 @@
1
+ import type { LexicalNode } from 'lexical';
2
+ import { DecoratorNode, ElementNode } from 'lexical';
3
+ export interface BaseNodeProps {
4
+ /** 是否可被删除,默认 `true` */
5
+ canBeRemoved?: boolean;
6
+ /** 是否可被替换,默认 `true` */
7
+ canBeReplaced?: boolean;
8
+ }
9
+ export interface BaseElementProps extends BaseNodeProps {
10
+ /**
11
+ * 是否允许节点为空,默认 `false`
12
+ *
13
+ * - `true` - 允许节点为空
14
+ * - `false` - 不允许节点为空,当最后一个子节点被删除后,节点也会被删除
15
+ */
16
+ canBeEmpty?: boolean;
17
+ /** 是否允许在节点内的起始位置插入文本,默认 `true` */
18
+ canInsertTextBefore?: boolean;
19
+ /** 是否允许在节点内的结束位置插入文本,默认 `true` */
20
+ canInsertTextAfter?: boolean;
21
+ }
22
+ export type BaseDecoratorNodeProps = BaseNodeProps;
23
+ export declare class BaseNodeHelper<P extends BaseNodeProps> {
24
+ __props: (P & BaseNodeProps) | undefined;
25
+ __superMethods: Pick<LexicalNode, 'replace' | 'remove'>;
26
+ constructor(props: P | undefined, superMethods: Pick<LexicalNode, 'replace' | 'remove'>);
27
+ hooks: {
28
+ remove: (preserveEmptyParent?: boolean) => void;
29
+ replace: <N extends LexicalNode>(replaceWith: N, includeChildren?: boolean) => N;
30
+ };
31
+ getUnderlyingProps(props: P & BaseNodeProps): Omit<P, keyof BaseNodeProps>;
32
+ }
33
+ export declare class BaseElementNode<P extends BaseElementProps> extends ElementNode {
34
+ __props: P | undefined;
35
+ __base: BaseNodeHelper<P>;
36
+ constructor(props?: P & {
37
+ key?: string;
38
+ });
39
+ canBeEmpty(): boolean;
40
+ canInsertTextBefore(): boolean;
41
+ canInsertTextAfter(): boolean;
42
+ getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseElementProps>;
43
+ }
44
+ export declare class BaseDecoratorNode<T, P extends BaseDecoratorNodeProps> extends DecoratorNode<T> {
45
+ __props: P | undefined;
46
+ __base: BaseNodeHelper<P>;
47
+ constructor(props?: P & {
48
+ key?: string;
49
+ });
50
+ getUnderlyingProps(props: P | undefined): Omit<P, keyof BaseDecoratorNodeProps>;
51
+ }