UNPKG

@yuntijs/ui

Version:

☁️ Yunti UI - an open-source UI component library for building Cloud Native web apps

72 lines (71 loc) 3.01 kB
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; import _createClass from "@babel/runtime/helpers/esm/createClass"; import _get from "@babel/runtime/helpers/esm/get"; import _inherits from "@babel/runtime/helpers/esm/inherits"; import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf"; 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); }; } 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; } } import { $createTextNode, TextNode } from 'lexical'; export var CustomTextNode = /*#__PURE__*/function (_TextNode) { _inherits(CustomTextNode, _TextNode); var _super = _createSuper(CustomTextNode); function CustomTextNode() { _classCallCheck(this, CustomTextNode); return _super.apply(this, arguments); } _createClass(CustomTextNode, [{ key: "createDOM", value: // constructor(text: string, key?: NodeKey) { // super(text, key) // } function createDOM(config) { var dom = _get(_getPrototypeOf(CustomTextNode.prototype), "createDOM", this).call(this, config); dom.classList.add('align-middle'); return dom; } }, { key: "exportJSON", value: function exportJSON() { return { detail: this.getDetail(), format: this.getFormat(), mode: this.getMode(), style: this.getStyle(), text: this.getTextContent(), type: 'custom-text', version: 1 }; } }, { key: "isSimpleText", value: function isSimpleText() { return (this.__type === 'text' || this.__type === 'custom-text') && this.__mode === 0; } }], [{ key: "getType", value: function getType() { return 'custom-text'; } }, { key: "clone", value: function clone(node) { return new CustomTextNode(node.__text, node.__key); } }, { key: "importJSON", value: function importJSON(serializedNode) { var node = $createTextNode(serializedNode.text); node.setFormat(serializedNode.format); node.setDetail(serializedNode.detail); node.setMode(serializedNode.mode); node.setStyle(serializedNode.style); return node; } }]); return CustomTextNode; }(TextNode); export function $createCustomTextNode(text) { return new CustomTextNode(text); }