@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,134 @@
1
+ var _excluded = ["key"];
2
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
6
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
7
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
9
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
11
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
13
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
14
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
17
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
18
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
19
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
20
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
21
+ 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); }
22
+ import { TextNode } from 'lexical';
23
+ import { BaseNodeHelper } from "./base";
24
+
25
+ /**
26
+ * - EN: Extra props for ExtendTextNode.
27
+ * - CN: ExtendTextNode 的附加属性。
28
+ */
29
+
30
+ /**
31
+ * - EN: A TextNode with extra behavior flags and controlled replacement.
32
+ * - CN: 带有额外行为标记并可控制替换行为的 TextNode。
33
+ */
34
+ export var ExtendTextNode = /*#__PURE__*/function (_TextNode) {
35
+ _inherits(ExtendTextNode, _TextNode);
36
+ var _super = _createSuper(ExtendTextNode);
37
+ function ExtendTextNode(props) {
38
+ var _thisSuper, _thisSuper2, _thisSuper3, _thisSuper4, _this;
39
+ _classCallCheck(this, ExtendTextNode);
40
+ var _ref = props || {},
41
+ key = _ref.key,
42
+ restProps = _objectWithoutProperties(_ref, _excluded);
43
+ _this = _super.call(this, props === null || props === void 0 ? void 0 : props.text, key);
44
+ _defineProperty(_assertThisInitialized(_this), "__props", void 0);
45
+ _defineProperty(_assertThisInitialized(_this), "__base", void 0);
46
+ _this.__props = restProps;
47
+ _this.__base = new BaseNodeHelper(_this.__props, {
48
+ remove: function remove() {
49
+ return _get((_thisSuper = _assertThisInitialized(_this), _getPrototypeOf(ExtendTextNode.prototype)), "remove", _thisSuper).call(_thisSuper);
50
+ },
51
+ replace: function replace(replaceWith, includeChildren) {
52
+ return _get((_thisSuper2 = _assertThisInitialized(_this), _getPrototypeOf(ExtendTextNode.prototype)), "replace", _thisSuper2).call(_thisSuper2, replaceWith, includeChildren);
53
+ }
54
+ });
55
+ Object.keys(_this.__base.hooks).forEach(function (key) {
56
+ var method = _this.__base.hooks[key];
57
+ if (typeof method === 'function') {
58
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
+ _this[key] = method.bind(_this.__base);
60
+ }
61
+ });
62
+ _this.remove = function (preserveEmptyParent) {
63
+ var _this$__props;
64
+ if (((_this$__props = _this.__props) === null || _this$__props === void 0 ? void 0 : _this$__props.canBeRemoved) === false) {
65
+ var _this$__props$prefixT;
66
+ _this.setTextContent((_this$__props$prefixT = _this.__props.prefixText) !== null && _this$__props$prefixT !== void 0 ? _this$__props$prefixT : ' ');
67
+ return;
68
+ }
69
+ _get((_thisSuper3 = _assertThisInitialized(_this), _getPrototypeOf(ExtendTextNode.prototype)), "remove", _thisSuper3).call(_thisSuper3, preserveEmptyParent);
70
+ };
71
+ _this.replace = function (replaceWith, includeChildren) {
72
+ var _this$__props2;
73
+ if (((_this$__props2 = _this.__props) === null || _this$__props2 === void 0 ? void 0 : _this$__props2.canBeReplaced) === false) {
74
+ var _this$__props3;
75
+ _this.setTextContent(((_this$__props3 = _this.__props) === null || _this$__props3 === void 0 ? void 0 : _this$__props3.text) || ' ');
76
+ _this.selectNext();
77
+ return _assertThisInitialized(_this);
78
+ }
79
+ return _get((_thisSuper4 = _assertThisInitialized(_this), _getPrototypeOf(ExtendTextNode.prototype)), "replace", _thisSuper4).call(_thisSuper4, replaceWith, includeChildren);
80
+ };
81
+ return _this;
82
+ }
83
+ _createClass(ExtendTextNode, [{
84
+ key: "exportJSON",
85
+ value: function exportJSON() {
86
+ return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(ExtendTextNode.prototype), "exportJSON", this).call(this)), {}, {
87
+ props: this.__props,
88
+ text: this.__text,
89
+ type: this.getType()
90
+ });
91
+ }
92
+ }], [{
93
+ key: "getType",
94
+ value: function getType() {
95
+ return 'html.TextNode';
96
+ }
97
+ }, {
98
+ key: "clone",
99
+ value: function clone(node) {
100
+ return new ExtendTextNode(_objectSpread(_objectSpread({}, node.__props), {}, {
101
+ text: node.__text,
102
+ key: node.getKey()
103
+ }));
104
+ }
105
+ }, {
106
+ key: "importJSON",
107
+ value: function importJSON(serializedNode) {
108
+ return $createExtendTextNode(_objectSpread(_objectSpread({}, serializedNode.props), {}, {
109
+ text: serializedNode.text
110
+ }));
111
+ }
112
+ }]);
113
+ return ExtendTextNode;
114
+ }(TextNode);
115
+ /**
116
+ * - EN: Factory to create an ExtendTextNode.
117
+ * - CN: 创建 ExtendTextNode 的工厂函数。
118
+ *
119
+ * @param props Props for the node | 节点的属性
120
+ */
121
+ export function $createExtendTextNode(props) {
122
+ return new ExtendTextNode(props);
123
+ }
124
+
125
+ /**
126
+ * - EN: Type guard to check whether a node is ExtendTextNode.
127
+ * - CN: 判断节点是否为 ExtendTextNode 的类型守卫。
128
+ *
129
+ * @param node Node to test | 要检测的节点
130
+ */
131
+ export function $isExtendTextNode(node) {
132
+ return node instanceof ExtendTextNode;
133
+ }
134
+ //# sourceMappingURL=ExtendTextNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TextNode","BaseNodeHelper","ExtendTextNode","_TextNode","_inherits","_super","_createSuper","props","_thisSuper","_thisSuper2","_thisSuper3","_thisSuper4","_this","_classCallCheck","_ref","key","restProps","_objectWithoutProperties","_excluded","call","text","_defineProperty","_assertThisInitialized","__props","__base","remove","_get","_getPrototypeOf","prototype","replace","replaceWith","includeChildren","Object","keys","hooks","forEach","method","bind","preserveEmptyParent","_this$__props","canBeRemoved","_this$__props$prefixT","setTextContent","prefixText","_this$__props2","canBeReplaced","_this$__props3","selectNext","_createClass","value","exportJSON","_objectSpread","__text","type","getType","clone","node","getKey","importJSON","serializedNode","$createExtendTextNode","$isExtendTextNode"],"sources":["../../../../src/components/Lexical/nodes/ExtendTextNode.tsx"],"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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,SAASA,QAAQ,QAAQ,SAAS;AAElC,SAASC,cAAc;;AAEvB;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA,WAAaC,cAAc,0BAAAC,SAAA;EAAAC,SAAA,CAAAF,cAAA,EAAAC,SAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,cAAA;EAIzB,SAAAA,eAAYK,KAA+C,EAAE;IAAA,IAAAC,UAAA,EAAAC,WAAA,EAAAC,WAAA,EAAAC,WAAA,EAAAC,KAAA;IAAAC,eAAA,OAAAX,cAAA;IAC3D,IAAAY,IAAA,GAA8BP,KAAK,IAAI,CAAC,CAAC;MAAjCQ,GAAG,GAAAD,IAAA,CAAHC,GAAG;MAAKC,SAAS,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA;IACzBN,KAAA,GAAAP,MAAA,CAAAc,IAAA,OAAMZ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,IAAI,CAACgC,MAAM;QACjBC,IAAI,EAAE,IAAI,CAACC,OAAO,CAAC;MAAC;IAExB;EAAC;IAAAvC,GAAA;IAAAkC,KAAA,EAtBD,SAAAK,QAAA,EAAyB;MACvB,OAAO,eAAe;IACxB;EAAC;IAAAvC,GAAA;IAAAkC,KAAA,EAED,SAAAM,MAAaC,IAAoB,EAAkB;MACjD,OAAO,IAAItD,cAAc,CAAAiD,aAAA,CAAAA,aAAA,KAAMK,IAAI,CAACjC,OAAO;QAAEH,IAAI,EAAEoC,IAAI,CAACJ,MAAM;QAAErC,GAAG,EAAEyC,IAAI,CAACC,MAAM,CAAC;MAAC,EAAE,CAAC;IACvF;EAAC;IAAA1C,GAAA;IAAAkC,KAAA,EAED,SAAAS,WAAkBC,cAAwC,EAAkB;MAC1E,OAAOC,qBAAqB,CAAAT,aAAA,CAAAA,aAAA,KACvBQ,cAAc,CAACpD,KAAK;QACvBa,IAAI,EAAEuC,cAAc,CAACvC;MAAI,EAC1B,CAAC;IACJ;EAAC;EAAA,OAAAlB,cAAA;AAAA,EAjDiCF,QAAQ;AAqE5C;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS4D,qBAAqBA,CAACrD,KAA2B,EAAkB;EACjF,OAAO,IAAIL,cAAc,CAACK,KAAK,CAAC;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASsD,iBAAiBA,CAACL,IAAoC,EAA0B;EAC9F,OAAOA,IAAI,YAAYtD,cAAc;AACvC"}
@@ -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,239 @@
1
+ var _excluded = ["textContentMode", "spaceAround", "containerStyle"];
2
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
8
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
9
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
15
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
16
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
17
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
18
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
19
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
20
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
21
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
22
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
23
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
24
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
25
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
26
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
27
+ 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); }
28
+ import { useCallback } from 'react';
29
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
30
+ import { Select } from 'antd';
31
+ import { insertNodeAtCursor, updateDomStyle } from "../helpers";
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
+ */
38
+ import { jsx as _jsx } from "react/jsx-runtime";
39
+ export var SelectNode = /*#__PURE__*/function (_BaseDecoratorNode) {
40
+ _inherits(SelectNode, _BaseDecoratorNode);
41
+ var _super = _createSuper(SelectNode);
42
+ function SelectNode(props) {
43
+ var _props$defaultValue;
44
+ var _this;
45
+ _classCallCheck(this, SelectNode);
46
+ _this = _super.call(this, props);
47
+ _defineProperty(_assertThisInitialized(_this), "__value", void 0);
48
+ _this.__value = (_props$defaultValue = props === null || props === void 0 ? void 0 : props.defaultValue) !== null && _props$defaultValue !== void 0 ? _props$defaultValue : undefined;
49
+ return _this;
50
+ }
51
+ _createClass(SelectNode, [{
52
+ key: "exportJSON",
53
+ value: function exportJSON() {
54
+ return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(SelectNode.prototype), "exportJSON", this).call(this)), {}, {
55
+ props: this.__props,
56
+ type: this.getType(),
57
+ version: 1
58
+ });
59
+ }
60
+ }, {
61
+ key: "createDOM",
62
+ value: function createDOM() {
63
+ var _this$__props;
64
+ var span = document.createElement('span');
65
+ updateDomStyle(span, (_this$__props = this.__props) === null || _this$__props === void 0 ? void 0 : _this$__props.containerStyle);
66
+ return span;
67
+ }
68
+ }, {
69
+ key: "updateDOM",
70
+ value: function updateDOM() {
71
+ return false;
72
+ }
73
+ }, {
74
+ key: "decorate",
75
+ value: function decorate() {
76
+ return /*#__PURE__*/_jsx(SelectComponent, {
77
+ node: this
78
+ });
79
+ }
80
+ }, {
81
+ key: "isInline",
82
+ value: function isInline() {
83
+ return true;
84
+ }
85
+ }, {
86
+ key: "getTextContent",
87
+ value: function getTextContent() {
88
+ var _this$__props2,
89
+ _this2 = this,
90
+ _this$__props4;
91
+ var content;
92
+ var valueContent = this.__value ? String(this.__value) : '';
93
+ if (((_this$__props2 = this.__props) === null || _this$__props2 === void 0 ? void 0 : _this$__props2.textContentMode) === 'label') {
94
+ var _this$__props3;
95
+ var option = (_this$__props3 = this.__props) === null || _this$__props3 === void 0 || (_this$__props3 = _this$__props3.options) === null || _this$__props3 === void 0 ? void 0 : _this$__props3.find(function (opt) {
96
+ return opt.value === _this2.__value;
97
+ });
98
+ content = option !== null && option !== void 0 && option.label ? String(option.label) : valueContent;
99
+ } else {
100
+ content = valueContent;
101
+ }
102
+ if (((_this$__props4 = this.__props) === null || _this$__props4 === void 0 ? void 0 : _this$__props4.spaceAround) !== false) {
103
+ return " ".concat(content, " ");
104
+ }
105
+ return content;
106
+ }
107
+ }, {
108
+ key: "getValue",
109
+ value: function getValue() {
110
+ return this.__value;
111
+ }
112
+ }, {
113
+ key: "setValue",
114
+ value: function setValue(value) {
115
+ var writable = this.getWritable();
116
+ writable.__value = value;
117
+ }
118
+ }, {
119
+ key: "getPropValue",
120
+ value: function getPropValue(propName) {
121
+ var _this$__props5;
122
+ return (_this$__props5 = this.__props) === null || _this$__props5 === void 0 ? void 0 : _this$__props5[propName];
123
+ }
124
+ }, {
125
+ key: "setProps",
126
+ value: function setProps(props) {
127
+ var writable = this.getWritable();
128
+ writable.__props = _objectSpread(_objectSpread({}, writable.__props), props);
129
+ }
130
+ }], [{
131
+ key: "getType",
132
+ value: function getType() {
133
+ return 'antd.Select';
134
+ }
135
+
136
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
137
+ }, {
138
+ key: "clone",
139
+ value: function clone(node) {
140
+ return new SelectNode(_objectSpread(_objectSpread({}, node.__props), {}, {
141
+ key: node.getKey()
142
+ }));
143
+ }
144
+
145
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
146
+ }, {
147
+ key: "importJSON",
148
+ value: function importJSON(serializedNode) {
149
+ return $createSelectNode(serializedNode.props);
150
+ }
151
+ }]);
152
+ return SelectNode;
153
+ }(BaseDecoratorNode);
154
+
155
+ /**
156
+ * - EN: React decorator component rendered for SelectNode.
157
+ * - CN: SelectNode 对应的 React 装饰组件。
158
+ *
159
+ * @param node The bound SelectNode instance | 关联的 SelectNode 实例
160
+ */
161
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
162
+ function SelectComponent(_ref) {
163
+ var node = _ref.node;
164
+ /* eslint-disable @typescript-eslint/no-unused-vars */
165
+ var _ref2 = node.__props || {},
166
+ textContentMode = _ref2.textContentMode,
167
+ spaceAround = _ref2.spaceAround,
168
+ containerStyle = _ref2.containerStyle,
169
+ selectProps = _objectWithoutProperties(_ref2, _excluded);
170
+ /* eslint-enable @typescript-eslint/no-unused-vars */
171
+ var _useLexicalComposerCo = useLexicalComposerContext(),
172
+ _useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
173
+ editor = _useLexicalComposerCo2[0];
174
+ var handleChange = useCallback(function (value, options) {
175
+ editor.update(function () {
176
+ var _node$__props, _node$__props$onChang;
177
+ node.setValue(value);
178
+ (_node$__props = node.__props) === null || _node$__props === void 0 || (_node$__props$onChang = _node$__props.onChange) === null || _node$__props$onChang === void 0 || _node$__props$onChang.call(_node$__props, value, options);
179
+ });
180
+ }, [editor, node]);
181
+ var handleClear = useCallback(function () {
182
+ editor.update(function () {
183
+ var _node$__props2, _node$__props2$onClea;
184
+ node.setValue(undefined);
185
+ (_node$__props2 = node.__props) === null || _node$__props2 === void 0 || (_node$__props2$onClea = _node$__props2.onClear) === null || _node$__props2$onClea === void 0 || _node$__props2$onClea.call(_node$__props2);
186
+ });
187
+ }, [editor, node]);
188
+ return /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({}, selectProps), {}, {
189
+ value: node.getValue(),
190
+ onChange: handleChange,
191
+ onClear: handleClear
192
+ }));
193
+ }
194
+
195
+ /**
196
+ * - EN: Factory to create a SelectNode.
197
+ * - CN: 创建 SelectNode 的工厂函数。
198
+ *
199
+ * @param props Props for the Select node | Select 节点的属性
200
+ */
201
+ export function $createSelectNode(props) {
202
+ return new SelectNode(props);
203
+ }
204
+
205
+ /**
206
+ * - EN: Type guard to check whether a node is SelectNode.
207
+ * - CN: 判断节点是否为 SelectNode 的类型守卫。
208
+ *
209
+ * @param node Node to test | 要检测的节点
210
+ */
211
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
212
+ export function $isSelectNode(node) {
213
+ return node instanceof SelectNode;
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
+ */
223
+ export function $insertSelectNode(editor, props) {
224
+ editor.update(function () {
225
+ var selectNode = $createSelectNode(_objectSpread(_objectSpread({}, props), {}, {
226
+ containerStyle: _objectSpread({
227
+ paddingLeft: '8px',
228
+ paddingRight: '8px'
229
+ }, props.containerStyle)
230
+ }));
231
+ insertNodeAtCursor(editor, selectNode);
232
+ });
233
+ }
234
+
235
+ /**
236
+ * - EN: Props passed to the Select decorator component.
237
+ * - CN: 传递给 Select 装饰组件的属性。
238
+ */
239
+ //# sourceMappingURL=SelectNode.js.map
@@ -0,0 +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\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,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EACnF,OAAO,IAAIL,UAAU,CAAwBK,KAAK,CAAC;AACrD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASgF,aAAaA,CAACjD,IAAoC,EAAgC;EAChG,OAAOA,IAAI,YAAYpC,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"}
@@ -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
+ }