@tiny-codes/react-easy 1.3.1 → 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 (42) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/es/components/Lexical/helpers/index.d.ts +58 -0
  3. package/es/components/Lexical/helpers/index.js +249 -0
  4. package/es/components/Lexical/helpers/index.js.map +1 -0
  5. package/es/components/Lexical/index.d.ts +5 -0
  6. package/es/components/Lexical/index.js +6 -0
  7. package/es/components/Lexical/index.js.map +1 -0
  8. package/es/components/Lexical/nodes/DivNode.d.ts +25 -0
  9. package/es/components/Lexical/nodes/DivNode.js +163 -0
  10. package/es/components/Lexical/nodes/DivNode.js.map +1 -0
  11. package/es/components/Lexical/nodes/ExtendTextNode.d.ts +24 -0
  12. package/es/components/Lexical/nodes/ExtendTextNode.js +102 -0
  13. package/es/components/Lexical/nodes/ExtendTextNode.js.map +1 -0
  14. package/es/components/Lexical/nodes/SelectNode.d.ts +44 -0
  15. package/es/components/Lexical/nodes/SelectNode.js +204 -0
  16. package/es/components/Lexical/nodes/SelectNode.js.map +1 -0
  17. package/es/components/Lexical/nodes/base.d.ts +51 -0
  18. package/es/components/Lexical/nodes/base.js +168 -0
  19. package/es/components/Lexical/nodes/base.js.map +1 -0
  20. package/es/hooks/useRefValue.d.ts +2 -2
  21. package/es/hooks/useRefValue.js.map +1 -1
  22. package/lib/components/Lexical/helpers/index.d.ts +58 -0
  23. package/lib/components/Lexical/helpers/index.js +198 -0
  24. package/lib/components/Lexical/helpers/index.js.map +7 -0
  25. package/lib/components/Lexical/index.d.ts +5 -0
  26. package/lib/components/Lexical/index.js +32 -0
  27. package/lib/components/Lexical/index.js.map +7 -0
  28. package/lib/components/Lexical/nodes/DivNode.d.ts +25 -0
  29. package/lib/components/Lexical/nodes/DivNode.js +139 -0
  30. package/lib/components/Lexical/nodes/DivNode.js.map +7 -0
  31. package/lib/components/Lexical/nodes/ExtendTextNode.d.ts +24 -0
  32. package/lib/components/Lexical/nodes/ExtendTextNode.js +87 -0
  33. package/lib/components/Lexical/nodes/ExtendTextNode.js.map +7 -0
  34. package/lib/components/Lexical/nodes/SelectNode.d.ts +44 -0
  35. package/lib/components/Lexical/nodes/SelectNode.js +157 -0
  36. package/lib/components/Lexical/nodes/SelectNode.js.map +7 -0
  37. package/lib/components/Lexical/nodes/base.d.ts +51 -0
  38. package/lib/components/Lexical/nodes/base.js +116 -0
  39. package/lib/components/Lexical/nodes/base.js.map +7 -0
  40. package/lib/hooks/useRefValue.d.ts +2 -2
  41. package/lib/hooks/useRefValue.js.map +2 -2
  42. package/package.json +20 -1
@@ -0,0 +1,102 @@
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
+ export var ExtendTextNode = /*#__PURE__*/function (_TextNode) {
25
+ _inherits(ExtendTextNode, _TextNode);
26
+ var _super = _createSuper(ExtendTextNode);
27
+ function ExtendTextNode(props) {
28
+ var _thisSuper, _thisSuper2, _thisSuper3, _this;
29
+ _classCallCheck(this, ExtendTextNode);
30
+ var _ref = props || {},
31
+ key = _ref.key,
32
+ restProps = _objectWithoutProperties(_ref, _excluded);
33
+ _this = _super.call(this, props === null || props === void 0 ? void 0 : props.text, key);
34
+ _defineProperty(_assertThisInitialized(_this), "__props", void 0);
35
+ _defineProperty(_assertThisInitialized(_this), "__base", void 0);
36
+ _this.__props = restProps;
37
+ _this.__base = new BaseNodeHelper(_this.__props, {
38
+ remove: function remove() {
39
+ return _get((_thisSuper = _assertThisInitialized(_this), _getPrototypeOf(ExtendTextNode.prototype)), "remove", _thisSuper).call(_thisSuper);
40
+ },
41
+ replace: function replace(replaceWith, includeChildren) {
42
+ return _get((_thisSuper2 = _assertThisInitialized(_this), _getPrototypeOf(ExtendTextNode.prototype)), "replace", _thisSuper2).call(_thisSuper2, replaceWith, includeChildren);
43
+ }
44
+ });
45
+ Object.keys(_this.__base.hooks).forEach(function (key) {
46
+ var method = _this.__base.hooks[key];
47
+ if (typeof method === 'function') {
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
+ _this[key] = method.bind(_this.__base);
50
+ }
51
+ });
52
+ _this.replace = function (replaceWith, includeChildren) {
53
+ var _this$__props;
54
+ if (((_this$__props = _this.__props) === null || _this$__props === void 0 ? void 0 : _this$__props.canBeReplaced) === false) {
55
+ var _this$__props2;
56
+ _this.setTextContent(((_this$__props2 = _this.__props) === null || _this$__props2 === void 0 ? void 0 : _this$__props2.text) || '');
57
+ _this.selectNext();
58
+ return _assertThisInitialized(_this);
59
+ }
60
+ return _get((_thisSuper3 = _assertThisInitialized(_this), _getPrototypeOf(ExtendTextNode.prototype)), "replace", _thisSuper3).call(_thisSuper3, replaceWith, includeChildren);
61
+ };
62
+ return _this;
63
+ }
64
+ _createClass(ExtendTextNode, [{
65
+ key: "exportJSON",
66
+ value: function exportJSON() {
67
+ return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(ExtendTextNode.prototype), "exportJSON", this).call(this)), {}, {
68
+ props: this.__props,
69
+ text: this.__text,
70
+ type: this.getType()
71
+ });
72
+ }
73
+ }], [{
74
+ key: "getType",
75
+ value: function getType() {
76
+ return 'html.TextNode';
77
+ }
78
+ }, {
79
+ key: "clone",
80
+ value: function clone(node) {
81
+ return new ExtendTextNode(_objectSpread(_objectSpread({}, node.__props), {}, {
82
+ text: node.__text,
83
+ key: node.getKey()
84
+ }));
85
+ }
86
+ }, {
87
+ key: "importJSON",
88
+ value: function importJSON(serializedNode) {
89
+ return $createExtendTextNode(_objectSpread(_objectSpread({}, serializedNode.props), {}, {
90
+ text: serializedNode.text
91
+ }));
92
+ }
93
+ }]);
94
+ return ExtendTextNode;
95
+ }(TextNode);
96
+ export function $createExtendTextNode(props) {
97
+ return new ExtendTextNode(props);
98
+ }
99
+ export function $isExtendTextNode(node) {
100
+ return node instanceof ExtendTextNode;
101
+ }
102
+ //# sourceMappingURL=ExtendTextNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TextNode","BaseNodeHelper","ExtendTextNode","_TextNode","_inherits","_super","_createSuper","props","_thisSuper","_thisSuper2","_thisSuper3","_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","_this$__props","canBeReplaced","_this$__props2","setTextContent","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\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,SAASA,QAAQ,QAAQ,SAAS;AAElC,SAASC,cAAc;AAMvB,WAAaC,cAAc,0BAAAC,SAAA;EAAAC,SAAA,CAAAF,cAAA,EAAA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AO,eAAe;IACxB;EAAC;IAAAlC,GAAA;IAAA6B,KAAA,EAED,SAAAM,MAAaC,IAAoB,EAAkB;MACjD,OAAO,IAAIhD,cAAc,CAAA2C,aAAA,CAAAA,aAAA,KAAMK,IAAI,CAAC5B,OAAO;QAAEH,IAAI,EAAE+B,IAAI,CAACJ,MAAM;QAAEhC,GAAG,EAAEoC,IAAI,CAACC,MAAM,CAAC;MAAC,EAAE,CAAC;IACvF;EAAC;IAAArC,GAAA;IAAA6B,KAAA,EAED,SAAAS,WAAkBC,cAAwC,EAAkB;MAC1E,OAAOC,qBAAqB,CAAAT,aAAA,CAAAA,aAAA,KACvBQ,cAAc,CAAC9C,KAAK;QACvBY,IAAI,EAAEkC,cAAc,CAAClC;MAAI,EAC1B,CAAC;IACJ;EAAC;EAAA,OAAAjB,cAAA;AAAA,EA1CiCF,QAAQ;AA8D5C,OAAO,SAASsD,qBAAqBA,CAAC/C,KAA2B,EAAkB;EACjF,OAAO,IAAIL,cAAc,CAACK,KAAK,CAAC;AAClC;AAEA,OAAO,SAASgD,iBAAiBA,CAACL,IAAoC,EAA0B;EAC9F,OAAOA,IAAI,YAAYhD,cAAc;AACvC"}
@@ -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,204 @@
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
+ import { jsx as _jsx } from "react/jsx-runtime";
34
+ export var SelectNode = /*#__PURE__*/function (_BaseDecoratorNode) {
35
+ _inherits(SelectNode, _BaseDecoratorNode);
36
+ var _super = _createSuper(SelectNode);
37
+ function SelectNode(props) {
38
+ var _props$defaultValue;
39
+ var _this;
40
+ _classCallCheck(this, SelectNode);
41
+ _this = _super.call(this, props);
42
+ _defineProperty(_assertThisInitialized(_this), "__value", void 0);
43
+ _this.__value = (_props$defaultValue = props === null || props === void 0 ? void 0 : props.defaultValue) !== null && _props$defaultValue !== void 0 ? _props$defaultValue : undefined;
44
+ return _this;
45
+ }
46
+ _createClass(SelectNode, [{
47
+ key: "exportJSON",
48
+ value: function exportJSON() {
49
+ return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(SelectNode.prototype), "exportJSON", this).call(this)), {}, {
50
+ props: this.__props,
51
+ type: this.getType(),
52
+ version: 1
53
+ });
54
+ }
55
+ }, {
56
+ key: "createDOM",
57
+ value: function createDOM() {
58
+ var _this$__props;
59
+ var span = document.createElement('span');
60
+ updateDomStyle(span, (_this$__props = this.__props) === null || _this$__props === void 0 ? void 0 : _this$__props.containerStyle);
61
+ return span;
62
+ }
63
+ }, {
64
+ key: "updateDOM",
65
+ value: function updateDOM() {
66
+ return false;
67
+ }
68
+ }, {
69
+ key: "decorate",
70
+ value: function decorate() {
71
+ return /*#__PURE__*/_jsx(SelectComponent, {
72
+ node: this
73
+ });
74
+ }
75
+ }, {
76
+ key: "isInline",
77
+ value: function isInline() {
78
+ return true;
79
+ }
80
+ }, {
81
+ key: "getTextContent",
82
+ value: function getTextContent() {
83
+ var _this$__props2,
84
+ _this2 = this,
85
+ _this$__props4;
86
+ var content;
87
+ var valueContent = this.__value ? String(this.__value) : '';
88
+ if (((_this$__props2 = this.__props) === null || _this$__props2 === void 0 ? void 0 : _this$__props2.textContentMode) === 'label') {
89
+ var _this$__props3;
90
+ 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) {
91
+ return opt.value === _this2.__value;
92
+ });
93
+ content = option !== null && option !== void 0 && option.label ? String(option.label) : valueContent;
94
+ } else {
95
+ content = valueContent;
96
+ }
97
+ if (((_this$__props4 = this.__props) === null || _this$__props4 === void 0 ? void 0 : _this$__props4.spaceAround) !== false) {
98
+ return " ".concat(content, " ");
99
+ }
100
+ return content;
101
+ }
102
+ }, {
103
+ key: "getValue",
104
+ value: function getValue() {
105
+ return this.__value;
106
+ }
107
+ }, {
108
+ key: "setValue",
109
+ value: function setValue(value) {
110
+ var writable = this.getWritable();
111
+ writable.__value = value;
112
+ }
113
+
114
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
115
+ }, {
116
+ key: "getPropValue",
117
+ value: function getPropValue(propName) {
118
+ var _this$__props5;
119
+ return (_this$__props5 = this.__props) === null || _this$__props5 === void 0 ? void 0 : _this$__props5[propName];
120
+ }
121
+ }, {
122
+ key: "setProps",
123
+ value: function setProps(props) {
124
+ var writable = this.getWritable();
125
+ writable.__props = _objectSpread(_objectSpread({}, writable.__props), props);
126
+ }
127
+ }], [{
128
+ key: "getType",
129
+ value: function getType() {
130
+ return 'antd.Select';
131
+ }
132
+
133
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
134
+ }, {
135
+ key: "clone",
136
+ value: function clone(node) {
137
+ return new SelectNode(_objectSpread(_objectSpread({}, node.__props), {}, {
138
+ key: node.getKey()
139
+ }));
140
+ }
141
+
142
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
143
+ }, {
144
+ key: "importJSON",
145
+ value: function importJSON(serializedNode) {
146
+ return $createSelectNode(serializedNode.props);
147
+ }
148
+ }]);
149
+ return SelectNode;
150
+ }(BaseDecoratorNode);
151
+
152
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
153
+ function SelectComponent(_ref) {
154
+ var node = _ref.node;
155
+ /* eslint-disable @typescript-eslint/no-unused-vars */
156
+ var _ref2 = node.__props || {},
157
+ textContentMode = _ref2.textContentMode,
158
+ spaceAround = _ref2.spaceAround,
159
+ containerStyle = _ref2.containerStyle,
160
+ selectProps = _objectWithoutProperties(_ref2, _excluded);
161
+ /* eslint-enable @typescript-eslint/no-unused-vars */
162
+ var _useLexicalComposerCo = useLexicalComposerContext(),
163
+ _useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
164
+ editor = _useLexicalComposerCo2[0];
165
+ var handleChange = useCallback(function (value, options) {
166
+ editor.update(function () {
167
+ var _node$__props, _node$__props$onChang;
168
+ node.setValue(value);
169
+ (_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);
170
+ });
171
+ }, [editor, node]);
172
+ var handleClear = useCallback(function () {
173
+ editor.update(function () {
174
+ var _node$__props2, _node$__props2$onClea;
175
+ node.setValue(undefined);
176
+ (_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);
177
+ });
178
+ }, [editor, node]);
179
+ return /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({}, selectProps), {}, {
180
+ value: node.getValue(),
181
+ onChange: handleChange,
182
+ onClear: handleClear
183
+ }));
184
+ }
185
+ export function $createSelectNode(props) {
186
+ return new SelectNode(props);
187
+ }
188
+
189
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
190
+ export function $isSelectNode(node) {
191
+ return node instanceof SelectNode;
192
+ }
193
+ export function $insertSelectNode(editor, props) {
194
+ editor.update(function () {
195
+ var selectNode = $createSelectNode(_objectSpread(_objectSpread({}, props), {}, {
196
+ containerStyle: _objectSpread({
197
+ paddingLeft: '8px',
198
+ paddingRight: '8px'
199
+ }, props.containerStyle)
200
+ }));
201
+ insertNodeAtCursor(editor, selectNode);
202
+ });
203
+ }
204
+ //# 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\nexport interface SelectNodeProps<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> extends SelectProps<ValueType, OptionType>,\n BaseDecoratorNodeProps {\n /**\n * 在获取editor的textContent时,是否将选项的label作为文本内容插入到编辑器中,默认 `value`\n *\n * - `label` - 将选项的label作为文本内容\n * - `value` - 将选项的value作为文本内容\n */\n textContentMode?: 'label' | 'value';\n /** 是否在`textContext`两边添加一个空格,默认`true` */\n spaceAround?: boolean;\n /** 容器样式 */\n containerStyle?: CSSProperties;\n}\n\nexport class SelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> extends BaseDecoratorNode<ReactNode, SelectNodeProps<ValueType, OptionType>> {\n __value: ValueType | undefined;\n\n constructor(props?: SelectNodeProps<ValueType, OptionType> & { key?: string }) {\n super(props);\n this.__value = props?.defaultValue ?? undefined;\n }\n static getType(): string {\n return 'antd.Select';\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static clone<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(\n node: SelectNode<ValueType, OptionType>\n ): SelectNode<ValueType, OptionType> {\n return new SelectNode<ValueType, OptionType>({ ...node.__props, key: node.getKey() });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static importJSON<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(\n serializedNode: SerializedSelectNode<ValueType, OptionType>\n ): SelectNode<ValueType, OptionType> {\n return $createSelectNode(serializedNode.props);\n }\n\n exportJSON(): SerializedSelectNode<ValueType, OptionType> {\n return {\n ...super.exportJSON(),\n props: this.__props,\n type: this.getType(),\n version: 1,\n };\n }\n\n createDOM(): HTMLElement {\n const span = document.createElement('span');\n updateDomStyle(span, this.__props?.containerStyle);\n return span;\n }\n\n updateDOM(): false {\n return false;\n }\n\n decorate(): ReactNode {\n return <SelectComponent node={this} />;\n }\n\n isInline(): boolean {\n return true;\n }\n\n getTextContent(): string {\n let content: string;\n const valueContent = this.__value ? String(this.__value) : '';\n if (this.__props?.textContentMode === 'label') {\n const option = this.__props?.options?.find((opt) => opt.value === this.__value);\n content = option?.label ? String(option.label) : valueContent;\n } else {\n content = valueContent;\n }\n if (this.__props?.spaceAround !== false) {\n return ` ${content} `;\n }\n return content;\n }\n\n getValue(): ValueType | undefined {\n return this.__value;\n }\n\n setValue(value: ValueType | undefined): void {\n const writable = this.getWritable();\n writable.__value = value;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getPropValue(propName: keyof SelectNodeProps<ValueType, OptionType>): any {\n return this.__props?.[propName];\n }\n\n setProps(props: SelectNodeProps<ValueType, OptionType>): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props,\n ...props,\n };\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction SelectComponent<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>({\n node,\n}: SelectComponentProps<ValueType, OptionType>): ReactNode {\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { textContentMode, spaceAround, containerStyle, ...selectProps } = node.__props || {};\n /* eslint-enable @typescript-eslint/no-unused-vars */\n const [editor] = useLexicalComposerContext();\n\n const handleChange = useCallback<NonNullable<SelectNodeProps<ValueType, OptionType>['onChange']>>(\n (value, options) => {\n editor.update(() => {\n node.setValue(value);\n node.__props?.onChange?.(value, options);\n });\n },\n [editor, node]\n );\n\n const handleClear = useCallback(() => {\n editor.update(() => {\n node.setValue(undefined);\n node.__props?.onClear?.();\n });\n }, [editor, node]);\n\n return <Select {...selectProps} value={node.getValue()} onChange={handleChange} onClear={handleClear} />;\n}\n\nexport function $createSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n>(props?: SelectNodeProps<ValueType, OptionType>): SelectNode<ValueType, OptionType> {\n return new SelectNode<ValueType, OptionType>(props);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function $isSelectNode(node: LexicalNode | null | undefined): node is SelectNode<any, any> {\n return node instanceof SelectNode;\n}\n\nexport function $insertSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n>(editor: LexicalEditor, props: SelectNodeProps<ValueType, OptionType>): void {\n editor.update(() => {\n const selectNode = $createSelectNode<ValueType, OptionType>({\n ...props,\n containerStyle: {\n paddingLeft: '8px',\n paddingRight: '8px',\n ...props.containerStyle,\n },\n });\n insertNodeAtCursor(editor, selectNode);\n });\n}\n\ninterface SelectComponentProps<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> {\n node: SelectNode<ValueType, OptionType>;\n}\nexport type SerializedSelectNode<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ValueType = any,\n OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType,\n> = Spread<\n {\n props?: SelectNodeProps<ValueType, OptionType>;\n },\n SerializedLexicalNode\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAA6CA,WAAW,QAAQ,OAAO;AACvE,SAASC,yBAAyB,QAAQ,uCAAuC;AACjF,SAASC,MAAM,QAAQ,MAAM;AAI7B,SAASC,kBAAkB,EAAEC,cAAc;AAE3C,SAASC,iBAAiB;A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L,MAAM,EAAAyB,aAAA,CAAAA,aAAA,KAAKkD,WAAW;IAAEpD,KAAK,EAAEmB,IAAI,CAACkB,QAAQ,CAAC,CAAE;IAAC0B,QAAQ,EAAEJ,YAAa;IAACQ,OAAO,EAAEH;EAAY,EAAE,CAAC;AAC1G;AAEA,OAAO,SAASf,iBAAiBA,CAI/B7D,KAA8C,EAAqC;EACnF,OAAO,IAAIL,UAAU,CAAwBK,KAAK,CAAC;AACrD;;AAEA;AACA,OAAO,SAASgF,aAAaA,CAACjD,IAAoC,EAAgC;EAChG,OAAOA,IAAI,YAAYpC,UAAU;AACnC;AAEA,OAAO,SAASsF,iBAAiBA,CAI/BX,MAAqB,EAAEtE,KAA6C,EAAQ;EAC5EsE,MAAM,CAACE,MAAM,CAAC,YAAM;IAClB,IAAMU,UAAU,GAAGrB,iBAAiB,CAAA/C,aAAA,CAAAA,aAAA,KAC/Bd,KAAK;MACR2B,cAAc,EAAAb,aAAA;QACZqE,WAAW,EAAE,KAAK;QAClBC,YAAY,EAAE;MAAK,GAChBpF,KAAK,CAAC2B,cAAc;IACxB,EACF,CAAC;IACFrC,kBAAkB,CAACgF,MAAM,EAAEY,UAAU,CAAC;EACxC,CAAC,CAAC;AACJ"}
@@ -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
+ }
@@ -0,0 +1,168 @@
1
+ var _excluded = ["canBeRemoved", "canBeReplaced"],
2
+ _excluded2 = ["key"],
3
+ _excluded3 = ["canBeEmpty", "canInsertTextBefore", "canInsertTextAfter"],
4
+ _excluded4 = ["key"];
5
+ 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); }
6
+ function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
7
+ 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); }
8
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
9
+ 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); }; }
10
+ 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); }
11
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12
+ 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; } }
13
+ 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); }
14
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
15
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
16
+ 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; }
17
+ 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; }
18
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
+ 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); } }
20
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
21
+ 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; }
22
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
23
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
24
+ import { DecoratorNode, ElementNode } from 'lexical';
25
+ export var BaseNodeHelper = /*#__PURE__*/function () {
26
+ function BaseNodeHelper(props, superMethods) {
27
+ var _this = this;
28
+ _classCallCheck(this, BaseNodeHelper);
29
+ _defineProperty(this, "__props", void 0);
30
+ _defineProperty(this, "__superMethods", void 0);
31
+ _defineProperty(this, "hooks", {
32
+ remove: function remove(preserveEmptyParent) {
33
+ var _this$__props;
34
+ if (((_this$__props = _this.__props) === null || _this$__props === void 0 ? void 0 : _this$__props.canBeRemoved) === false) {
35
+ return;
36
+ }
37
+ _this.__superMethods.remove(preserveEmptyParent);
38
+ },
39
+ replace: function replace(replaceWith, includeChildren) {
40
+ var _this$__props2;
41
+ if (((_this$__props2 = _this.__props) === null || _this$__props2 === void 0 ? void 0 : _this$__props2.canBeReplaced) === false) {
42
+ return _this;
43
+ }
44
+ return _this.__superMethods.replace(replaceWith, includeChildren);
45
+ }
46
+ });
47
+ this.__props = props;
48
+ this.__superMethods = superMethods;
49
+ }
50
+ _createClass(BaseNodeHelper, [{
51
+ key: "getUnderlyingProps",
52
+ value: function getUnderlyingProps(props) {
53
+ /* eslint-disable @typescript-eslint/no-unused-vars */
54
+ var canBeRemoved = props.canBeRemoved,
55
+ canBeReplaced = props.canBeReplaced,
56
+ restProps = _objectWithoutProperties(props, _excluded);
57
+ /* eslint-enable @typescript-eslint/no-unused-vars */
58
+ return restProps;
59
+ }
60
+ }]);
61
+ return BaseNodeHelper;
62
+ }();
63
+ export var BaseElementNode = /*#__PURE__*/function (_ElementNode) {
64
+ _inherits(BaseElementNode, _ElementNode);
65
+ var _super = _createSuper(BaseElementNode);
66
+ function BaseElementNode(props) {
67
+ var _thisSuper, _thisSuper2, _this2;
68
+ _classCallCheck(this, BaseElementNode);
69
+ var _ref = props || {},
70
+ key = _ref.key,
71
+ restProps = _objectWithoutProperties(_ref, _excluded2);
72
+ _this2 = _super.call(this, key);
73
+ _defineProperty(_assertThisInitialized(_this2), "__props", void 0);
74
+ _defineProperty(_assertThisInitialized(_this2), "__base", void 0);
75
+ _this2.__props = restProps;
76
+ _this2.__base = new BaseNodeHelper(_this2.__props, {
77
+ remove: function remove() {
78
+ return _get((_thisSuper = _assertThisInitialized(_this2), _getPrototypeOf(BaseElementNode.prototype)), "remove", _thisSuper).call(_thisSuper);
79
+ },
80
+ replace: function replace(replaceWith, includeChildren) {
81
+ return _get((_thisSuper2 = _assertThisInitialized(_this2), _getPrototypeOf(BaseElementNode.prototype)), "replace", _thisSuper2).call(_thisSuper2, replaceWith, includeChildren);
82
+ }
83
+ });
84
+ Object.keys(_this2.__base.hooks).forEach(function (key) {
85
+ var method = _this2.__base.hooks[key];
86
+ if (typeof method === 'function') {
87
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
+ _this2[key] = method.bind(_this2.__base);
89
+ }
90
+ });
91
+ return _this2;
92
+ }
93
+ _createClass(BaseElementNode, [{
94
+ key: "canBeEmpty",
95
+ value: function canBeEmpty() {
96
+ var _this$__props$canBeEm, _this$__props3;
97
+ return (_this$__props$canBeEm = (_this$__props3 = this.__props) === null || _this$__props3 === void 0 ? void 0 : _this$__props3.canBeEmpty) !== null && _this$__props$canBeEm !== void 0 ? _this$__props$canBeEm : false;
98
+ }
99
+ }, {
100
+ key: "canInsertTextBefore",
101
+ value: function canInsertTextBefore() {
102
+ var _this$__props$canInse, _this$__props4;
103
+ return (_this$__props$canInse = (_this$__props4 = this.__props) === null || _this$__props4 === void 0 ? void 0 : _this$__props4.canInsertTextBefore) !== null && _this$__props$canInse !== void 0 ? _this$__props$canInse : true;
104
+ }
105
+ }, {
106
+ key: "canInsertTextAfter",
107
+ value: function canInsertTextAfter() {
108
+ var _this$__props$canInse2, _this$__props5;
109
+ return (_this$__props$canInse2 = (_this$__props5 = this.__props) === null || _this$__props5 === void 0 ? void 0 : _this$__props5.canInsertTextAfter) !== null && _this$__props$canInse2 !== void 0 ? _this$__props$canInse2 : true;
110
+ }
111
+ }, {
112
+ key: "getUnderlyingProps",
113
+ value: function getUnderlyingProps(props) {
114
+ var baseProps = this.__base.getUnderlyingProps(props !== null && props !== void 0 ? props : {});
115
+ /* eslint-disable @typescript-eslint/no-unused-vars */
116
+ var canBeEmpty = baseProps.canBeEmpty,
117
+ canInsertTextBefore = baseProps.canInsertTextBefore,
118
+ canInsertTextAfter = baseProps.canInsertTextAfter,
119
+ restProps = _objectWithoutProperties(baseProps, _excluded3);
120
+ /* eslint-enable @typescript-eslint/no-unused-vars */
121
+ return restProps;
122
+ }
123
+ }]);
124
+ return BaseElementNode;
125
+ }(ElementNode);
126
+ export var BaseDecoratorNode = /*#__PURE__*/function (_DecoratorNode) {
127
+ _inherits(BaseDecoratorNode, _DecoratorNode);
128
+ var _super2 = _createSuper(BaseDecoratorNode);
129
+ function BaseDecoratorNode(props) {
130
+ var _thisSuper3, _thisSuper4, _this3;
131
+ _classCallCheck(this, BaseDecoratorNode);
132
+ var _ref2 = props || {},
133
+ key = _ref2.key,
134
+ restProps = _objectWithoutProperties(_ref2, _excluded4);
135
+ _this3 = _super2.call(this, key);
136
+ _defineProperty(_assertThisInitialized(_this3), "__props", void 0);
137
+ _defineProperty(_assertThisInitialized(_this3), "__base", void 0);
138
+ _this3.__props = restProps;
139
+ _this3.__base = new BaseNodeHelper(_this3.__props, {
140
+ remove: function remove() {
141
+ return _get((_thisSuper3 = _assertThisInitialized(_this3), _getPrototypeOf(BaseDecoratorNode.prototype)), "remove", _thisSuper3).call(_thisSuper3);
142
+ },
143
+ replace: function replace(replaceWith, includeChildren) {
144
+ return _get((_thisSuper4 = _assertThisInitialized(_this3), _getPrototypeOf(BaseDecoratorNode.prototype)), "replace", _thisSuper4).call(_thisSuper4, replaceWith, includeChildren);
145
+ }
146
+ });
147
+ Object.keys(_this3.__base.hooks).forEach(function (key) {
148
+ var method = _this3.__base.hooks[key];
149
+ if (typeof method === 'function') {
150
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
151
+ _this3[key] = method.bind(_this3.__base);
152
+ }
153
+ });
154
+ return _this3;
155
+ }
156
+ _createClass(BaseDecoratorNode, [{
157
+ key: "getUnderlyingProps",
158
+ value: function getUnderlyingProps(props) {
159
+ var baseProps = this.__base.getUnderlyingProps(props !== null && props !== void 0 ? props : {});
160
+ /* eslint-disable @typescript-eslint/no-unused-vars */
161
+ var restProps = Object.assign({}, (_objectDestructuringEmpty(baseProps), baseProps));
162
+ /* eslint-enable @typescript-eslint/no-unused-vars */
163
+ return restProps;
164
+ }
165
+ }]);
166
+ return BaseDecoratorNode;
167
+ }(DecoratorNode);
168
+ //# sourceMappingURL=base.js.map