@tiny-codes/react-easy 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/es/components/FormItemControl/index.d.ts +7 -7
  3. package/es/components/FormItemControl/index.js +6 -6
  4. package/es/components/FormItemControl/index.js.map +1 -1
  5. package/es/components/Lexical/helpers/index.d.ts +39 -24
  6. package/es/components/Lexical/helpers/index.js +61 -24
  7. package/es/components/Lexical/helpers/index.js.map +1 -1
  8. package/es/components/Lexical/index.d.ts +1 -0
  9. package/es/components/Lexical/index.js +1 -0
  10. package/es/components/Lexical/index.js.map +1 -1
  11. package/es/components/Lexical/nodes/CloseIcon.d.ts +71 -0
  12. package/es/components/Lexical/nodes/CloseIcon.js +176 -0
  13. package/es/components/Lexical/nodes/CloseIcon.js.map +1 -0
  14. package/es/components/Lexical/nodes/DivNode.d.ts +20 -0
  15. package/es/components/Lexical/nodes/DivNode.js +32 -4
  16. package/es/components/Lexical/nodes/DivNode.js.map +1 -1
  17. package/es/components/Lexical/nodes/ExtendTextNode.d.ts +23 -1
  18. package/es/components/Lexical/nodes/ExtendTextNode.js +38 -6
  19. package/es/components/Lexical/nodes/ExtendTextNode.js.map +1 -1
  20. package/es/components/Lexical/nodes/SelectNode.d.ts +39 -9
  21. package/es/components/Lexical/nodes/SelectNode.js +37 -2
  22. package/es/components/Lexical/nodes/SelectNode.js.map +1 -1
  23. package/es/components/Lexical/nodes/base.d.ts +59 -8
  24. package/es/components/Lexical/nodes/base.js +50 -1
  25. package/es/components/Lexical/nodes/base.js.map +1 -1
  26. package/es/utils/index.d.ts +1 -0
  27. package/es/utils/index.js +1 -0
  28. package/es/utils/index.js.map +1 -1
  29. package/es/utils/string.d.ts +7 -0
  30. package/es/utils/string.js +15 -0
  31. package/es/utils/string.js.map +1 -0
  32. package/lib/components/FormItemControl/index.d.ts +7 -7
  33. package/lib/components/FormItemControl/index.js.map +1 -1
  34. package/lib/components/Lexical/helpers/index.d.ts +39 -24
  35. package/lib/components/Lexical/helpers/index.js +24 -0
  36. package/lib/components/Lexical/helpers/index.js.map +2 -2
  37. package/lib/components/Lexical/index.d.ts +1 -0
  38. package/lib/components/Lexical/index.js +3 -1
  39. package/lib/components/Lexical/index.js.map +2 -2
  40. package/lib/components/Lexical/nodes/CloseIcon.d.ts +71 -0
  41. package/lib/components/Lexical/nodes/CloseIcon.js +149 -0
  42. package/lib/components/Lexical/nodes/CloseIcon.js.map +7 -0
  43. package/lib/components/Lexical/nodes/DivNode.d.ts +20 -0
  44. package/lib/components/Lexical/nodes/DivNode.js +1 -1
  45. package/lib/components/Lexical/nodes/DivNode.js.map +2 -2
  46. package/lib/components/Lexical/nodes/ExtendTextNode.d.ts +23 -1
  47. package/lib/components/Lexical/nodes/ExtendTextNode.js +9 -1
  48. package/lib/components/Lexical/nodes/ExtendTextNode.js.map +2 -2
  49. package/lib/components/Lexical/nodes/SelectNode.d.ts +39 -9
  50. package/lib/components/Lexical/nodes/SelectNode.js +0 -1
  51. package/lib/components/Lexical/nodes/SelectNode.js.map +2 -2
  52. package/lib/components/Lexical/nodes/base.d.ts +59 -8
  53. package/lib/components/Lexical/nodes/base.js +18 -0
  54. package/lib/components/Lexical/nodes/base.js.map +2 -2
  55. package/lib/utils/index.d.ts +1 -0
  56. package/lib/utils/index.js +3 -1
  57. package/lib/utils/index.js.map +2 -2
  58. package/lib/utils/string.d.ts +7 -0
  59. package/lib/utils/string.js +37 -0
  60. package/lib/utils/string.js.map +7 -0
  61. package/package.json +1 -1
@@ -0,0 +1,176 @@
1
+ var _excluded = ["icon", "iconClassName", "iconStyle", "onClick"];
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 _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; }
4
+ 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; }
5
+ 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; }
6
+ 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; }
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 _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); }
11
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
12
+ 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); }
13
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
14
+ 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); }; }
15
+ 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); }
16
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
17
+ 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; } }
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 { theme } from 'antd';
23
+ import classNames from 'classnames';
24
+ import { CloseCircleOutlined } from '@ant-design/icons';
25
+ import { randomChars } from "../../../utils";
26
+ import { updateDomProps } from "../helpers";
27
+ import { BaseDecoratorNode } from "./base";
28
+ import { jsx as _jsx } from "react/jsx-runtime";
29
+ var CLOSE_ICON_CLASSNAME = 'lexical-close-icon';
30
+ /**
31
+ * - EN: A node that represents a close icon.
32
+ * - CN: 一个关闭图标的节点。
33
+ */
34
+ export var CloseIconNode = /*#__PURE__*/function (_BaseDecoratorNode) {
35
+ _inherits(CloseIconNode, _BaseDecoratorNode);
36
+ var _super = _createSuper(CloseIconNode);
37
+ function CloseIconNode(props) {
38
+ var _this;
39
+ _classCallCheck(this, CloseIconNode);
40
+ _this = _super.call(this, props);
41
+ _defineProperty(_assertThisInitialized(_this), "__hashId", void 0);
42
+ _this.__hashId = "hash-".concat(randomChars(6));
43
+ return _this;
44
+ }
45
+ _createClass(CloseIconNode, [{
46
+ key: "exportJSON",
47
+ value: function exportJSON() {
48
+ return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(CloseIconNode.prototype), "exportJSON", this).call(this)), {}, {
49
+ props: this.__props,
50
+ type: this.getType(),
51
+ version: 1
52
+ });
53
+ }
54
+ }, {
55
+ key: "createDOM",
56
+ value: function createDOM() {
57
+ var _this$__props;
58
+ var span = document.createElement('span');
59
+ var underlyingProps = this.getUnderlyingProps(this.__props);
60
+ var className = classNames(CLOSE_ICON_CLASSNAME, this.__hashId, underlyingProps === null || underlyingProps === void 0 ? void 0 : underlyingProps.className);
61
+ updateDomProps(span, _objectSpread(_objectSpread({}, underlyingProps), {}, {
62
+ className: className
63
+ }));
64
+ var stylesheet = document.createElement('style');
65
+ var token = theme.getDesignToken();
66
+ var parentCls = (_this$__props = this.__props) !== null && _this$__props !== void 0 && _this$__props.parentClassName ? ".".concat(this.__props.parentClassName) : '';
67
+ stylesheet.innerHTML = "\n ".concat(parentCls ? "\n ".concat(parentCls, " { \n position: relative;\n }\n ") : '', "\n ").concat(parentCls, " .").concat(CLOSE_ICON_CLASSNAME, ".").concat(this.__hashId, " {\n position: absolute;\n top: 0;\n right: 0;\n transform: translate(50%, -50%);\n color: ").concat(token.colorTextDisabled, ";\n font-size: ").concat(token.fontSizeSM, "px;\n line-height: 0;\n z-index: 1;\n opacity: 0;\n cursor: pointer;\n pointer-events: none;\n transition: opacity 0.2s ease;\n }\n ").concat(parentCls, ":hover .").concat(CLOSE_ICON_CLASSNAME, ".").concat(this.__hashId, " {\n opacity: 1;\n pointer-events: auto;\n }\n ").concat(parentCls, ":hover .").concat(CLOSE_ICON_CLASSNAME, ".").concat(this.__hashId, ":hover {\n color: ").concat(token.colorTextSecondary, ";\n }\n ");
68
+ span.append(stylesheet);
69
+ return span;
70
+ }
71
+ }, {
72
+ key: "updateDOM",
73
+ value: function updateDOM() {
74
+ return false;
75
+ }
76
+ }, {
77
+ key: "decorate",
78
+ value: function decorate() {
79
+ return /*#__PURE__*/_jsx(CloseIconComponent, {
80
+ node: this
81
+ });
82
+ }
83
+ }, {
84
+ key: "isInline",
85
+ value: function isInline() {
86
+ return false;
87
+ }
88
+ }, {
89
+ key: "getPropValue",
90
+ value: function getPropValue(propName) {
91
+ var _this$__props2;
92
+ return (_this$__props2 = this.__props) === null || _this$__props2 === void 0 ? void 0 : _this$__props2[propName];
93
+ }
94
+ }, {
95
+ key: "setProps",
96
+ value: function setProps(props) {
97
+ var writable = this.getWritable();
98
+ writable.__props = _objectSpread(_objectSpread({}, writable.__props), props);
99
+ }
100
+ }, {
101
+ key: "getUnderlyingProps",
102
+ value: function getUnderlyingProps(props) {
103
+ var excludeProps = _get(_getPrototypeOf(CloseIconNode.prototype), "getUnderlyingProps", this).call(this, props);
104
+ /* eslint-disable @typescript-eslint/no-unused-vars */
105
+ var _ref = excludeProps || {},
106
+ icon = _ref.icon,
107
+ iconClassName = _ref.iconClassName,
108
+ iconStyle = _ref.iconStyle,
109
+ onClick = _ref.onClick,
110
+ rest = _objectWithoutProperties(_ref, _excluded);
111
+ /* eslint-enable @typescript-eslint/no-unused-vars */
112
+ return rest;
113
+ }
114
+ }], [{
115
+ key: "getType",
116
+ value: function getType() {
117
+ return 'CloseIcon';
118
+ }
119
+ }, {
120
+ key: "clone",
121
+ value: function clone(node) {
122
+ return new CloseIconNode(_objectSpread(_objectSpread({}, node.__props), {}, {
123
+ key: node.getKey()
124
+ }));
125
+ }
126
+ }, {
127
+ key: "importJSON",
128
+ value: function importJSON(serializedNode) {
129
+ return $createCloseIconNode(serializedNode.props);
130
+ }
131
+ }]);
132
+ return CloseIconNode;
133
+ }(BaseDecoratorNode);
134
+
135
+ /**
136
+ * - EN: React decorator component rendered for CloseIconNode.
137
+ * - CN: CloseIconNode 对应的 React 装饰组件。
138
+ *
139
+ * @param node The bound CloseIconNode instance | 关联的 CloseIconNode 实例
140
+ */
141
+ function CloseIconComponent(_ref2) {
142
+ var node = _ref2.node;
143
+ var _ref3 = node.__props || {},
144
+ icon = _ref3.icon,
145
+ iconClassName = _ref3.iconClassName,
146
+ iconStyle = _ref3.iconStyle,
147
+ onClick = _ref3.onClick;
148
+ var closeIcon = icon !== null && icon !== void 0 ? icon : /*#__PURE__*/_jsx(CloseCircleOutlined, {
149
+ className: classNames(node.__hashId, iconClassName),
150
+ style: iconStyle,
151
+ onClick: onClick
152
+ });
153
+ return closeIcon;
154
+ }
155
+
156
+ /**
157
+ * - EN: Factory to create a CloseIconNode.
158
+ * - CN: 创建 CloseIconNode 的工厂函数。
159
+ *
160
+ * @param props Props for the CloseIcon node | CloseIcon 节点的属性
161
+ */
162
+ export function $createCloseIconNode(props) {
163
+ return new CloseIconNode(props);
164
+ }
165
+
166
+ /**
167
+ * - EN: Type guard to check whether a node is CloseIconNode.
168
+ * - CN: 判断节点是否为 CloseIconNode 的类型守卫。
169
+ *
170
+ * @param node Node to test | 要检测的节点
171
+ */
172
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
173
+ export function $isCloseIconNode(node) {
174
+ return node instanceof CloseIconNode;
175
+ }
176
+ //# sourceMappingURL=CloseIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["theme","classNames","CloseCircleOutlined","randomChars","updateDomProps","BaseDecoratorNode","jsx","_jsx","CLOSE_ICON_CLASSNAME","CloseIconNode","_BaseDecoratorNode","_inherits","_super","_createSuper","props","_this","_classCallCheck","call","_defineProperty","_assertThisInitialized","__hashId","concat","_createClass","key","value","exportJSON","_objectSpread","_get","_getPrototypeOf","prototype","__props","type","getType","version","createDOM","_this$__props","span","document","createElement","underlyingProps","getUnderlyingProps","className","stylesheet","token","getDesignToken","parentCls","parentClassName","innerHTML","colorTextDisabled","fontSizeSM","colorTextSecondary","append","updateDOM","decorate","CloseIconComponent","node","isInline","getPropValue","propName","_this$__props2","setProps","writable","getWritable","excludeProps","_ref","icon","iconClassName","iconStyle","onClick","rest","_objectWithoutProperties","_excluded","clone","getKey","importJSON","serializedNode","$createCloseIconNode","_ref2","_ref3","closeIcon","style","$isCloseIconNode"],"sources":["../../../../src/components/Lexical/nodes/CloseIcon.tsx"],"sourcesContent":["import { type CSSProperties, type HtmlHTMLAttributes, type ReactNode } from 'react';\nimport { theme } from 'antd';\nimport classNames from 'classnames';\nimport type { LexicalNode, SerializedLexicalNode, Spread } from 'lexical';\nimport { CloseCircleOutlined } from '@ant-design/icons';\nimport { randomChars } from '../../../utils';\nimport { updateDomProps } from '../helpers';\nimport type { BaseDecoratorNodeProps, BaseNodeProps } from './base';\nimport { BaseDecoratorNode } from './base';\n\nconst CLOSE_ICON_CLASSNAME = 'lexical-close-icon';\n\nexport interface CloseIconNodeProps extends HtmlHTMLAttributes<HTMLSpanElement>, BaseDecoratorNodeProps {\n /**\n * - EN: Parent element class name, used to add positioning styles to the parent element.\n * - CN: 父元素的类名,用于给父元素添加定位样式\n */\n parentClassName: string;\n /**\n * - EN: The custom icon to display, optional\n * - CN: 要显示的自定义图标,可选\n */\n icon?: ReactNode;\n /**\n * - EN: The default class name for the close icon element. This property is invalid if `icon` is\n * set.\n * - CN: 默认关闭图标元素的类名,如果设置了 `icon` 则该属性无效\n */\n iconClassName?: string;\n /**\n * - EN: The custom style for the close icon element. This property is invalid if `icon` is set.\n * - CN: 自定义关闭图标元素的样式,如果设置了 `icon` 则该属性无效\n */\n iconStyle?: CSSProperties;\n /**\n * - EN: The click event handler for the close icon element.\n * - CN: 关闭图标元素的点击事件\n */\n onClick?: (e: React.MouseEvent<HTMLSpanElement>) => void;\n}\n\n/**\n * - EN: A node that represents a close icon.\n * - CN: 一个关闭图标的节点。\n */\nexport class CloseIconNode extends BaseDecoratorNode<ReactNode, CloseIconNodeProps> {\n __hashId: string;\n\n constructor(props: CloseIconNodeProps & { key?: string }) {\n super(props);\n this.__hashId = `hash-${randomChars(6)}`;\n }\n\n static getType(): string {\n return 'CloseIcon';\n }\n\n static clone(node: CloseIconNode): CloseIconNode {\n return new CloseIconNode({ ...node.__props!, key: node.getKey() });\n }\n\n static importJSON(serializedNode: SerializedCloseIconNode): CloseIconNode {\n return $createCloseIconNode(serializedNode.props);\n }\n\n exportJSON(): SerializedCloseIconNode {\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 const underlyingProps = this.getUnderlyingProps(this.__props);\n const className = classNames(CLOSE_ICON_CLASSNAME, this.__hashId, underlyingProps?.className);\n updateDomProps(span, { ...underlyingProps, className });\n const stylesheet = document.createElement('style');\n const token = theme.getDesignToken();\n const parentCls = this.__props?.parentClassName ? `.${this.__props.parentClassName}` : '';\n stylesheet.innerHTML = `\n ${\n parentCls\n ? `\n ${parentCls} { \n position: relative;\n }\n `\n : ''\n }\n ${parentCls} .${CLOSE_ICON_CLASSNAME}.${this.__hashId} {\n position: absolute;\n top: 0;\n right: 0;\n transform: translate(50%, -50%);\n color: ${token.colorTextDisabled};\n font-size: ${token.fontSizeSM}px;\n line-height: 0;\n z-index: 1;\n opacity: 0;\n cursor: pointer;\n pointer-events: none;\n transition: opacity 0.2s ease;\n }\n ${parentCls}:hover .${CLOSE_ICON_CLASSNAME}.${this.__hashId} {\n opacity: 1;\n pointer-events: auto;\n }\n ${parentCls}:hover .${CLOSE_ICON_CLASSNAME}.${this.__hashId}:hover {\n color: ${token.colorTextSecondary};\n }\n `;\n span.append(stylesheet);\n return span;\n }\n\n updateDOM() {\n return false;\n }\n\n decorate(): ReactNode {\n return <CloseIconComponent node={this} />;\n }\n\n isInline(): boolean {\n return false;\n }\n\n getPropValue(propName: keyof CloseIconNodeProps): CloseIconNodeProps[typeof propName] {\n return this.__props?.[propName];\n }\n\n setProps(props: Partial<CloseIconNodeProps>): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props!,\n ...props,\n };\n }\n\n getUnderlyingProps(props: CloseIconNodeProps | undefined): Omit<CloseIconNodeProps, keyof BaseNodeProps> {\n const excludeProps = super.getUnderlyingProps(props);\n /* eslint-disable @typescript-eslint/no-unused-vars */\n const { icon, iconClassName, iconStyle, onClick, ...rest } = excludeProps || {};\n /* eslint-enable @typescript-eslint/no-unused-vars */\n return rest;\n }\n}\n\n/**\n * - EN: React decorator component rendered for CloseIconNode.\n * - CN: CloseIconNode 对应的 React 装饰组件。\n *\n * @param node The bound CloseIconNode instance | 关联的 CloseIconNode 实例\n */\nfunction CloseIconComponent({ node }: CloseIconComponentProps): ReactNode {\n const { icon, iconClassName, iconStyle, onClick } = node.__props || {};\n\n const closeIcon = icon ?? (\n <CloseCircleOutlined className={classNames(node.__hashId, iconClassName)} style={iconStyle} onClick={onClick} />\n );\n return closeIcon;\n}\n\n/**\n * - EN: Factory to create a CloseIconNode.\n * - CN: 创建 CloseIconNode 的工厂函数。\n *\n * @param props Props for the CloseIcon node | CloseIcon 节点的属性\n */\nexport function $createCloseIconNode(props: CloseIconNodeProps): CloseIconNode {\n return new CloseIconNode(props);\n}\n\n/**\n * - EN: Type guard to check whether a node is CloseIconNode.\n * - CN: 判断节点是否为 CloseIconNode 的类型守卫。\n *\n * @param node Node to test | 要检测的节点\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function $isCloseIconNode(node: LexicalNode | null | undefined): node is CloseIconNode {\n return node instanceof CloseIconNode;\n}\n\ninterface CloseIconComponentProps {\n node: CloseIconNode;\n}\ntype SerializedCloseIconNode = Spread<\n {\n props: CloseIconNodeProps;\n },\n SerializedLexicalNode\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,SAASA,KAAK,QAAQ,MAAM;AAC5B,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,mBAAmB,QAAQ,mBAAmB;AACvD,SAASC,WAAW;AACpB,SAASC,cAAc;AAEvB,SAASC,iBAAiB;AAAiB,SAAAC,GAAA,IAAAC,IAAA;AAE3C,IAAMC,oBAAoB,GAAG,oBAAoB;AA+BjD;AACA;AACA;AACA;AACA,WAAaC,aAAa,0BAAAC,kBAAA;EAAAC,SAAA,CAAAF,aAAA,EAAAC,kBAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,aAAA;EAGxB,SAAAA,cAAYK,KAA4C,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAP,aAAA;IACxDM,KAAA,GAAAH,MAAA,CAAAK,IAAA,OAAMH,KAAK;IAAEI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,GAAAa,KAAA,CAAJb,IAAI;IAAEC,aAAa,GAAAY,KAAA,CAAbZ,aAAa;IAAEC,SAAS,GAAAW,KAAA,CAATX,SAAS;IAAEC,OAAO,GAAAU,KAAA,CAAPV,OAAO;EAE/C,IAAMW,SAAS,GAAGd,IAAI,aAAJA,IAAI,cAAJA,IAAI,gBACpB1D,IAAA,CAACL,mBAAmB;IAACuC,SAAS,EAAExC,UAAU,CAACsD,IAAI,CAACnC,QAAQ,EAAE8C,aAAa,CAAE;IAACc,KAAK,EAAEb,SAAU;IAACC,OAAO,EAAEA;EAAQ,CAAE,CAChH;EACD,OAAOW,SAAS;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASH,oBAAoBA,CAAC9D,KAAyB,EAAiB;EAC7E,OAAO,IAAIL,aAAa,CAACK,KAAK,CAAC;AACjC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASmE,gBAAgBA,CAAC1B,IAAoC,EAAyB;EAC5F,OAAOA,IAAI,YAAY9C,aAAa;AACtC"}
@@ -1,11 +1,19 @@
1
1
  import type { CSSProperties, HtmlHTMLAttributes } from 'react';
2
2
  import type { DOMConversionMap, DOMExportOutput, LexicalNode, SerializedElementNode, Spread } from 'lexical';
3
3
  import { BaseElementNode, type BaseElementProps } from './base';
4
+ /**
5
+ * - EN: Props for the DivNode, combining DOM div attributes and element behavior flags.
6
+ * - CN: DivNode 的属性,包含 DOM div 属性与元素行为标记。
7
+ */
4
8
  export interface DivNodeProps extends HtmlHTMLAttributes<HTMLDivElement>, BaseElementProps {
5
9
  }
6
10
  export type SerializedDivNode = Spread<{
7
11
  props?: DivNodeProps;
8
12
  }, SerializedElementNode>;
13
+ /**
14
+ * - EN: Lexical element node that renders a DOM div with controlled props.
15
+ * - CN: 渲染为 DOM div 且可控制属性的 Lexical 元素节点。
16
+ */
9
17
  export declare class DivNode extends BaseElementNode<DivNodeProps> {
10
18
  static getType(): string;
11
19
  static clone(node: DivNode): DivNode;
@@ -21,5 +29,17 @@ export declare class DivNode extends BaseElementNode<DivNodeProps> {
21
29
  setProps(props: DivNodeProps): void;
22
30
  private shallowEqual;
23
31
  }
32
+ /**
33
+ * - EN: Factory to create a DivNode.
34
+ * - CN: 创建 DivNode 的工厂函数。
35
+ *
36
+ * @param props Props for the DivNode | DivNode 的属性
37
+ */
24
38
  export declare function $createDivNode(props?: DivNodeProps): DivNode;
39
+ /**
40
+ * - EN: Type guard to check if a node is DivNode.
41
+ * - CN: 判断节点是否为 DivNode 的类型守卫。
42
+ *
43
+ * @param node Node to test | 要检测的节点
44
+ */
25
45
  export declare function $isDivNode(node: LexicalNode | null | undefined): node is DivNode;
@@ -18,6 +18,16 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
18
18
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
19
19
  import { updateDomProps } from "../helpers";
20
20
  import { BaseElementNode } from "./base";
21
+
22
+ /**
23
+ * - EN: Props for the DivNode, combining DOM div attributes and element behavior flags.
24
+ * - CN: DivNode 的属性,包含 DOM div 属性与元素行为标记。
25
+ */
26
+
27
+ /**
28
+ * - EN: Lexical element node that renders a DOM div with controlled props.
29
+ * - CN: 渲染为 DOM div 且可控制属性的 Lexical 元素节点。
30
+ */
21
31
  export var DivNode = /*#__PURE__*/function (_BaseElementNode) {
22
32
  _inherits(DivNode, _BaseElementNode);
23
33
  var _super = _createSuper(DivNode);
@@ -49,7 +59,6 @@ export var DivNode = /*#__PURE__*/function (_BaseElementNode) {
49
59
  if (propsChanged) {
50
60
  updateDomProps(dom, this.getUnderlyingProps(currentProps));
51
61
  }
52
- // 不重新创建
53
62
  return false;
54
63
  }
55
64
  }, {
@@ -71,8 +80,8 @@ export var DivNode = /*#__PURE__*/function (_BaseElementNode) {
71
80
  }, {
72
81
  key: "isInline",
73
82
  value: function isInline() {
74
- var _this$__props;
75
- var display = (_this$__props = this.__props) === null || _this$__props === void 0 || (_this$__props = _this$__props.style) === null || _this$__props === void 0 ? void 0 : _this$__props.display;
83
+ var _this$__props$style$d, _this$__props;
84
+ var display = (_this$__props$style$d = (_this$__props = this.__props) === null || _this$__props === void 0 || (_this$__props = _this$__props.style) === null || _this$__props === void 0 ? void 0 : _this$__props.display) !== null && _this$__props$style$d !== void 0 ? _this$__props$style$d : 'block';
76
85
  return display === 'inline' || display === 'inline-flex' || display === 'inline-block' || display === 'inline-grid' || display === 'inline-table' || display === 'inline-list-item';
77
86
  }
78
87
  }, {
@@ -103,7 +112,8 @@ export var DivNode = /*#__PURE__*/function (_BaseElementNode) {
103
112
  for (var _i = 0, _keys = keys1; _i < _keys.length; _i++) {
104
113
  var key = _keys[_i];
105
114
  if (key === 'style') {
106
- // 特殊处理 style 对象
115
+ // - EN: Special handling for style objects.
116
+ // - CN: 特殊处理 style 对象。
107
117
  if (!this.shallowEqual(obj1[key], obj2[key])) return false;
108
118
  } else if (obj1[key] !== obj2[key]) {
109
119
  return false;
@@ -143,6 +153,12 @@ export var DivNode = /*#__PURE__*/function (_BaseElementNode) {
143
153
  }]);
144
154
  return DivNode;
145
155
  }(BaseElementNode);
156
+ /**
157
+ * - EN: Convert a DOM node to a DivNode during import.
158
+ * - CN: 在导入时将 DOM 节点转换为 DivNode。
159
+ *
160
+ * @param domNode Source DOM node | 源 DOM 节点
161
+ */
146
162
  function convertDivElement(domNode) {
147
163
  var element = domNode;
148
164
  if (element.nodeName === 'DIV') {
@@ -154,9 +170,21 @@ function convertDivElement(domNode) {
154
170
  node: null
155
171
  };
156
172
  }
173
+ /**
174
+ * - EN: Factory to create a DivNode.
175
+ * - CN: 创建 DivNode 的工厂函数。
176
+ *
177
+ * @param props Props for the DivNode | DivNode 的属性
178
+ */
157
179
  export function $createDivNode(props) {
158
180
  return new DivNode(props);
159
181
  }
182
+ /**
183
+ * - EN: Type guard to check if a node is DivNode.
184
+ * - CN: 判断节点是否为 DivNode 的类型守卫。
185
+ *
186
+ * @param node Node to test | 要检测的节点
187
+ */
160
188
  export function $isDivNode(node) {
161
189
  return node instanceof DivNode;
162
190
  }
@@ -1 +1 @@
1
- {"version":3,"names":["updateDomProps","BaseElementNode","DivNode","_BaseElementNode","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_createClass","key","value","getForceDisplay","undefined","createDOM","div","document","createElement","domProps","getUnderlyingProps","__props","updateDOM","prevNode","dom","prevProps","currentProps","propsChanged","shallowEqual","exportJSON","_objectSpread","_get","_getPrototypeOf","prototype","call","props","type","getType","exportDOM","element","isInline","_this$__props","display","style","getPropValue","_this$__props2","setProps","_writable$__props","writable","getWritable","obj1","obj2","keys1","Object","keys","keys2","length","_i","_keys","clone","node","getKey","importDOM","conversion","convertDivElement","priority","importJSON","serializedNode","$createDivNode","domNode","nodeName","$isDivNode"],"sources":["../../../../src/components/Lexical/nodes/DivNode.tsx"],"sourcesContent":["import type { CSSProperties, HtmlHTMLAttributes } from 'react';\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n LexicalNode,\n SerializedElementNode,\n Spread,\n} from 'lexical';\nimport { updateDomProps } from '../helpers';\nimport { BaseElementNode, type BaseElementProps } from './base';\n\nexport interface DivNodeProps extends HtmlHTMLAttributes<HTMLDivElement>, BaseElementProps {}\n\nexport type SerializedDivNode = Spread<\n {\n props?: DivNodeProps;\n },\n SerializedElementNode\n>;\n\nexport class DivNode extends BaseElementNode<DivNodeProps> {\n static getType(): string {\n return 'html.div';\n }\n\n static clone(node: DivNode): DivNode {\n return new DivNode({ ...node.__props, key: node.getKey() });\n }\n\n protected getForceDisplay(): CSSProperties['display'] {\n return undefined;\n }\n\n createDOM(): HTMLElement {\n const div = document.createElement('div');\n const domProps = this.getUnderlyingProps(this.__props);\n if (domProps) {\n updateDomProps(div, domProps);\n }\n return div;\n }\n\n updateDOM(prevNode: DivNode, dom: HTMLElement): boolean {\n const prevProps = prevNode.__props;\n const currentProps = this.__props;\n const propsChanged = !this.shallowEqual(prevProps, currentProps);\n if (propsChanged) {\n updateDomProps(dom, this.getUnderlyingProps(currentProps));\n }\n // 不重新创建\n return false;\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n div: (node: Node) => ({\n conversion: convertDivElement,\n priority: 1,\n }),\n };\n }\n\n static importJSON(serializedNode: SerializedDivNode): DivNode {\n return $createDivNode(serializedNode.props);\n }\n\n exportJSON(): SerializedDivNode {\n return {\n ...super.exportJSON(),\n props: this.__props,\n type: this.getType(),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = this.createDOM();\n return { element };\n }\n\n isInline(): boolean {\n const display = this.__props?.style?.display;\n return (\n display === 'inline' ||\n display === 'inline-flex' ||\n display === 'inline-block' ||\n display === 'inline-grid' ||\n display === 'inline-table' ||\n display === 'inline-list-item'\n );\n }\n\n getPropValue<K extends keyof DivNodeProps>(key: K): DivNodeProps[K] | undefined {\n return this.__props?.[key];\n }\n setProps(props: DivNodeProps): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props,\n ...props,\n style: {\n ...writable.__props?.style,\n ...props.style,\n },\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private shallowEqual(obj1: any, obj2: any): boolean {\n if (obj1 === obj2) return true;\n if (!obj1 || !obj2) return false;\n\n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n\n if (keys1.length !== keys2.length) return false;\n\n for (const key of keys1) {\n if (key === 'style') {\n // 特殊处理 style 对象\n if (!this.shallowEqual(obj1[key], obj2[key])) return false;\n } else if (obj1[key] !== obj2[key]) {\n return false;\n }\n }\n\n return true;\n }\n}\n\nfunction convertDivElement(domNode: Node): DOMConversionOutput {\n const element = domNode as HTMLElement;\n if (element.nodeName === 'DIV') {\n return { node: $createDivNode() };\n }\n return { node: null };\n}\n\nexport function $createDivNode(props?: DivNodeProps): DivNode {\n return new DivNode(props);\n}\n\nexport function $isDivNode(node: Lex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EAAEiD,IAAI,CAACC,MAAM,CAAC;MAAC,EAAE,CAAC;IAC7D;EAAC;IAAAlD,GAAA;IAAAC,KAAA,EA0BD,SAAAkD,UAAA,EAA4C;MAC1C,OAAO;QACL9C,GAAG,EAAE,SAAAA,IAAC4C,IAAU;UAAA,OAAM;YACpBG,UAAU,EAAEC,iBAAiB;YAC7BC,QAAQ,EAAE;UACZ,CAAC;QAAA;MACH,CAAC;IACH;EAAC;IAAAtD,GAAA;IAAAC,KAAA,EAED,SAAAsD,WAAkBC,cAAiC,EAAW;MAC5D,OAAOC,cAAc,CAACD,cAAc,CAAChC,KAAK,CAAC;IAC7C;EAAC;EAAA,OAAAjC,OAAA;AAAA,EA5C0BD,eAAe;AA6G5C,SAAS+D,iBAAiBA,CAACK,OAAa,EAAuB;EAC7D,IAAM9B,OAAO,GAAG8B,OAAsB;EACtC,IAAI9B,OAAO,CAAC+B,QAAQ,KAAK,KAAK,EAAE;IAC9B,OAAO;MAAEV,IAAI,EAAEQ,cAAc,CAAC;IAAE,CAAC;EACnC;EACA,OAAO;IAAER,IAAI,EAAE;EAAK,CAAC;AACvB;AAEA,OAAO,SAASQ,cAAcA,CAACjC,KAAoB,EAAW;EAC5D,OAAO,IAAIjC,OAAO,CAACiC,KAAK,CAAC;AAC3B;AAEA,OAAO,SAASoC,UAAUA,CAACX,IAAoC,EAAmB;EAChF,OAAOA,IAAI,YAAY1D,OAAO;AAChC"}
1
+ {"version":3,"names":["updateDomProps","BaseElementNode","DivNode","_BaseElementNode","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_createClass","key","value","getForceDisplay","undefined","createDOM","div","document","createElement","domProps","getUnderlyingProps","__props","updateDOM","prevNode","dom","prevProps","currentProps","propsChanged","shallowEqual","exportJSON","_objectSpread","_get","_getPrototypeOf","prototype","call","props","type","getType","exportDOM","element","isInline","_this$__props$style$d","_this$__props","display","style","getPropValue","_this$__props2","setProps","_writable$__props","writable","getWritable","obj1","obj2","keys1","Object","keys","keys2","length","_i","_keys","clone","node","getKey","importDOM","conversion","convertDivElement","priority","importJSON","serializedNode","$createDivNode","domNode","nodeName","$isDivNode"],"sources":["../../../../src/components/Lexical/nodes/DivNode.tsx"],"sourcesContent":["import type { CSSProperties, HtmlHTMLAttributes } from 'react';\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n LexicalNode,\n SerializedElementNode,\n Spread,\n} from 'lexical';\nimport { updateDomProps } from '../helpers';\nimport { BaseElementNode, type BaseElementProps } from './base';\n\n/**\n * - EN: Props for the DivNode, combining DOM div attributes and element behavior flags.\n * - CN: DivNode 的属性,包含 DOM div 属性与元素行为标记。\n */\nexport interface DivNodeProps extends HtmlHTMLAttributes<HTMLDivElement>, BaseElementProps {}\n\nexport type SerializedDivNode = Spread<\n {\n props?: DivNodeProps;\n },\n SerializedElementNode\n>;\n\n/**\n * - EN: Lexical element node that renders a DOM div with controlled props.\n * - CN: 渲染为 DOM div 且可控制属性的 Lexical 元素节点。\n */\nexport class DivNode extends BaseElementNode<DivNodeProps> {\n static getType(): string {\n return 'html.div';\n }\n\n static clone(node: DivNode): DivNode {\n return new DivNode({ ...node.__props, key: node.getKey() });\n }\n\n protected getForceDisplay(): CSSProperties['display'] {\n return undefined;\n }\n\n createDOM(): HTMLElement {\n const div = document.createElement('div');\n const domProps = this.getUnderlyingProps(this.__props);\n if (domProps) {\n updateDomProps(div, domProps);\n }\n return div;\n }\n\n updateDOM(prevNode: DivNode, dom: HTMLElement): boolean {\n const prevProps = prevNode.__props;\n const currentProps = this.__props;\n const propsChanged = !this.shallowEqual(prevProps, currentProps);\n if (propsChanged) {\n updateDomProps(dom, this.getUnderlyingProps(currentProps));\n }\n return false;\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n div: (node: Node) => ({\n conversion: convertDivElement,\n priority: 1,\n }),\n };\n }\n\n static importJSON(serializedNode: SerializedDivNode): DivNode {\n return $createDivNode(serializedNode.props);\n }\n\n exportJSON(): SerializedDivNode {\n return {\n ...super.exportJSON(),\n props: this.__props,\n type: this.getType(),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = this.createDOM();\n return { element };\n }\n\n isInline(): boolean {\n const display = this.__props?.style?.display ?? 'block';\n return (\n display === 'inline' ||\n display === 'inline-flex' ||\n display === 'inline-block' ||\n display === 'inline-grid' ||\n display === 'inline-table' ||\n display === 'inline-list-item'\n );\n }\n\n getPropValue<K extends keyof DivNodeProps>(key: K): DivNodeProps[K] | undefined {\n return this.__props?.[key];\n }\n setProps(props: DivNodeProps): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props,\n ...props,\n style: {\n ...writable.__props?.style,\n ...props.style,\n },\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private shallowEqual(obj1: any, obj2: any): boolean {\n if (obj1 === obj2) return true;\n if (!obj1 || !obj2) return false;\n\n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n\n if (keys1.length !== keys2.length) return false;\n\n for (const key of keys1) {\n if (key === 'style') {\n // - EN: Special handling for style objects.\n // - CN: 特殊处理 style 对象。\n if (!this.shallowEqual(obj1[key], obj2[key])) return false;\n } else if (obj1[key] !== obj2[key]) {\n return false;\n }\n }\n\n return true;\n }\n}\n/**\n * - EN: Convert a DOM node to a DivNode during import.\n * - CN: 在导入时将 DOM 节点转换为 DivNode。\n *\n * @param domNode Source DOM node | 源 DOM 节点\n */\nfunction convertDivElement(domNode: Node): DOMConversionOutput {\n const element = domNode as HTMLElement;\n if (element.nodeName === 'DIV') {\n return { node: $createDivNode() };\n }\n return { node: null };\n}\n/**\n * - EN: Factory to create a DivNode.\n * - CN: 创建 DivNode 的工厂函数。\n *\n * @param props Props for the DivNode | DivNode 的属性\n */\nexport function $createDivNode(props?: DivNodeProps): DivNode {\n return new DivNode(props);\n}\n/**\n * - EN: Type guard to check if a node is DivNode.\n * - CN: 判断节点是否为 DivNode 的类型守卫。\n *\n * @param node Node to test | 要检测的节点\n */\nexport function $isDivNode(node: LexicalN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Aa,EAAW;MACnC,OAAO,IAAI3D,OAAO,CAAA4B,aAAA,CAAAA,aAAA,KAAM+B,IAAI,CAACxC,OAAO;QAAEV,GAAG,EAAEkD,IAAI,CAACC,MAAM,CAAC;MAAC,EAAE,CAAC;IAC7D;EAAC;IAAAnD,GAAA;IAAAC,KAAA,EAyBD,SAAAmD,UAAA,EAA4C;MAC1C,OAAO;QACL/C,GAAG,EAAE,SAAAA,IAAC6C,IAAU;UAAA,OAAM;YACpBG,UAAU,EAAEC,iBAAiB;YAC7BC,QAAQ,EAAE;UACZ,CAAC;QAAA;MACH,CAAC;IACH;EAAC;IAAAvD,GAAA;IAAAC,KAAA,EAED,SAAAuD,WAAkBC,cAAiC,EAAW;MAC5D,OAAOC,cAAc,CAACD,cAAc,CAACjC,KAAK,CAAC;IAC7C;EAAC;EAAA,OAAAjC,OAAA;AAAA,EA3C0BD,eAAe;AA4G5C;AACA;AACA;AACA;AACA;AACA;AACA,SAASgE,iBAAiBA,CAACK,OAAa,EAAuB;EAC7D,IAAM/B,OAAO,GAAG+B,OAAsB;EACtC,IAAI/B,OAAO,CAACgC,QAAQ,KAAK,KAAK,EAAE;IAC9B,OAAO;MAAEV,IAAI,EAAEQ,cAAc,CAAC;IAAE,CAAC;EACnC;EACA,OAAO;IAAER,IAAI,EAAE;EAAK,CAAC;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,cAAcA,CAAClC,KAAoB,EAAW;EAC5D,OAAO,IAAIjC,OAAO,CAACiC,KAAK,CAAC;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASqC,UAAUA,CAACX,IAAoC,EAAmB;EAChF,OAAOA,IAAI,YAAY3D,OAAO;AAChC"}
@@ -2,9 +2,18 @@ import type { LexicalNode, NodeKey, SerializedTextNode, Spread } from 'lexical';
2
2
  import { TextNode } from 'lexical';
3
3
  import type { BaseNodeProps } from './base';
4
4
  import { BaseNodeHelper } from './base';
5
+ /**
6
+ * - EN: Extra props for ExtendTextNode.
7
+ * - CN: ExtendTextNode 的附加属性。
8
+ */
5
9
  export interface ExtendTextNodeProps extends BaseNodeProps {
6
10
  text?: string;
11
+ prefixText?: string;
7
12
  }
13
+ /**
14
+ * - EN: A TextNode with extra behavior flags and controlled replacement.
15
+ * - CN: 带有额外行为标记并可控制替换行为的 TextNode。
16
+ */
8
17
  export declare class ExtendTextNode extends TextNode {
9
18
  __props: ExtendTextNodeProps | undefined;
10
19
  __base: BaseNodeHelper<ExtendTextNodeProps>;
@@ -16,9 +25,22 @@ export declare class ExtendTextNode extends TextNode {
16
25
  static importJSON(serializedNode: SerializedExtendTextNode): ExtendTextNode;
17
26
  exportJSON(): SerializedExtendTextNode;
18
27
  }
19
- export type SerializedExtendTextNode = Spread<{
28
+ type SerializedExtendTextNode = Spread<{
20
29
  props?: ExtendTextNodeProps;
21
30
  text: string;
22
31
  }, SerializedTextNode>;
32
+ /**
33
+ * - EN: Factory to create an ExtendTextNode.
34
+ * - CN: 创建 ExtendTextNode 的工厂函数。
35
+ *
36
+ * @param props Props for the node | 节点的属性
37
+ */
23
38
  export declare function $createExtendTextNode(props?: ExtendTextNodeProps): ExtendTextNode;
39
+ /**
40
+ * - EN: Type guard to check whether a node is ExtendTextNode.
41
+ * - CN: 判断节点是否为 ExtendTextNode 的类型守卫。
42
+ *
43
+ * @param node Node to test | 要检测的节点
44
+ */
24
45
  export declare function $isExtendTextNode(node: LexicalNode | null | undefined): node is ExtendTextNode;
46
+ export {};
@@ -21,11 +21,21 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
21
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
22
  import { TextNode } from 'lexical';
23
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
+ */
24
34
  export var ExtendTextNode = /*#__PURE__*/function (_TextNode) {
25
35
  _inherits(ExtendTextNode, _TextNode);
26
36
  var _super = _createSuper(ExtendTextNode);
27
37
  function ExtendTextNode(props) {
28
- var _thisSuper, _thisSuper2, _thisSuper3, _this;
38
+ var _thisSuper, _thisSuper2, _thisSuper3, _thisSuper4, _this;
29
39
  _classCallCheck(this, ExtendTextNode);
30
40
  var _ref = props || {},
31
41
  key = _ref.key,
@@ -49,15 +59,24 @@ export var ExtendTextNode = /*#__PURE__*/function (_TextNode) {
49
59
  _this[key] = method.bind(_this.__base);
50
60
  }
51
61
  });
52
- _this.replace = function (replaceWith, includeChildren) {
62
+ _this.remove = function (preserveEmptyParent) {
53
63
  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) || '');
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) || ' ');
57
76
  _this.selectNext();
58
77
  return _assertThisInitialized(_this);
59
78
  }
60
- return _get((_thisSuper3 = _assertThisInitialized(_this), _getPrototypeOf(ExtendTextNode.prototype)), "replace", _thisSuper3).call(_thisSuper3, replaceWith, includeChildren);
79
+ return _get((_thisSuper4 = _assertThisInitialized(_this), _getPrototypeOf(ExtendTextNode.prototype)), "replace", _thisSuper4).call(_thisSuper4, replaceWith, includeChildren);
61
80
  };
62
81
  return _this;
63
82
  }
@@ -93,9 +112,22 @@ export var ExtendTextNode = /*#__PURE__*/function (_TextNode) {
93
112
  }]);
94
113
  return ExtendTextNode;
95
114
  }(TextNode);
115
+ /**
116
+ * - EN: Factory to create an ExtendTextNode.
117
+ * - CN: 创建 ExtendTextNode 的工厂函数。
118
+ *
119
+ * @param props Props for the node | 节点的属性
120
+ */
96
121
  export function $createExtendTextNode(props) {
97
122
  return new ExtendTextNode(props);
98
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
+ */
99
131
  export function $isExtendTextNode(node) {
100
132
  return node instanceof ExtendTextNode;
101
133
  }
@@ -1 +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 $isExt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AAT,IAAA;QAEEX,KAAK,EAAE,IAAI,CAACe,OAAO;QACnBH,IAAI,EAAE,IAAI,CAAC2B,MAAM;QACjBC,IAAI,EAAE,IAAI,CAACC,OAAO,CAAC;MAAC;IAExB;EAAC;IAAAlC,GAAA;IAAA6B,KAAA,EAtBD,SAAAK,QAAA,EAAyB;MACvB,OAAO,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"}
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,EAAA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EEZ,KAAK,EAAE,IAAI,CAACgB,OAAO;QACnBH,IAAI,EAAE,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"}
@@ -4,17 +4,27 @@ import type { BaseOptionType, DefaultOptionType } from 'antd/es/select';
4
4
  import type { LexicalEditor, LexicalNode, SerializedLexicalNode, Spread } from 'lexical';
5
5
  import type { BaseDecoratorNodeProps } from './base';
6
6
  import { BaseDecoratorNode } from './base';
7
+ /**
8
+ * - EN: Props for SelectNode, extending antd Select props plus behavior flags.
9
+ * - CN: SelectNode 的属性,基于 antd Select 属性并附加行为标记。
10
+ */
7
11
  export interface SelectNodeProps<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> extends SelectProps<ValueType, OptionType>, BaseDecoratorNodeProps {
8
12
  /**
9
- * 在获取editortextContent时,是否将选项的label作为文本内容插入到编辑器中,默认 `value`
10
- *
11
- * - `label` - 将选项的label作为文本内容
12
- * - `value` - 将选项的value作为文本内容
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
13
17
  */
14
18
  textContentMode?: 'label' | 'value';
15
- /** 是否在`textContext`两边添加一个空格,默认`true` */
19
+ /**
20
+ * - EN: Add a space around textContent. Default `true`.
21
+ * - CN: 是否在 textContent 两边添加一个空格,默认 `true`。
22
+ */
16
23
  spaceAround?: boolean;
17
- /** 容器样式 */
24
+ /**
25
+ * - EN: Container DOM style.
26
+ * - CN: 容器样式。
27
+ */
18
28
  containerStyle?: CSSProperties;
19
29
  }
20
30
  export declare class SelectNode<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> extends BaseDecoratorNode<ReactNode, SelectNodeProps<ValueType, OptionType>> {
@@ -33,12 +43,32 @@ export declare class SelectNode<ValueType = any, OptionType extends BaseOptionTy
33
43
  getTextContent(): string;
34
44
  getValue(): ValueType | undefined;
35
45
  setValue(value: ValueType | undefined): void;
36
- getPropValue(propName: keyof SelectNodeProps<ValueType, OptionType>): any;
37
- setProps(props: SelectNodeProps<ValueType, OptionType>): void;
46
+ getPropValue(propName: keyof SelectNodeProps<ValueType, OptionType>): SelectNodeProps<ValueType, OptionType>[typeof propName];
47
+ setProps(props: Partial<SelectNodeProps<ValueType, OptionType>>): void;
38
48
  }
49
+ /**
50
+ * - EN: Factory to create a SelectNode.
51
+ * - CN: 创建 SelectNode 的工厂函数。
52
+ *
53
+ * @param props Props for the Select node | Select 节点的属性
54
+ */
39
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
+ */
40
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
+ */
41
70
  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<{
71
+ type SerializedSelectNode<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> = Spread<{
43
72
  props?: SelectNodeProps<ValueType, OptionType>;
44
73
  }, SerializedLexicalNode>;
74
+ export {};