UNPKG

phx-react

Version:

PHX REACT

65 lines 2.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FigmaNode = void 0; exports.$createFigmaNode = $createFigmaNode; exports.$isFigmaNode = $isFigmaNode; const tslib_1 = require("tslib"); const LexicalBlockWithAlignableContents_1 = require("@lexical/react/LexicalBlockWithAlignableContents"); const LexicalDecoratorBlockNode_1 = require("@lexical/react/LexicalDecoratorBlockNode"); const React = tslib_1.__importStar(require("react")); function FigmaComponent({ className, documentID, format, nodeKey }) { return (React.createElement(LexicalBlockWithAlignableContents_1.BlockWithAlignableContents, { className: className, format: format, nodeKey: nodeKey }, React.createElement("iframe", { allowFullScreen: true, height: '315', src: `https://www.figma.com/embed?embed_host=lexical&url=\ https://www.figma.com/file/${documentID}`, width: '560' }))); } class FigmaNode extends LexicalDecoratorBlockNode_1.DecoratorBlockNode { static getType() { return 'figma'; } static clone(node) { return new FigmaNode(node.__id, node.__format, node.__key); } static importJSON(serializedNode) { const node = $createFigmaNode(serializedNode.documentID); node.setFormat(serializedNode.format); return node; } exportJSON() { return { ...super.exportJSON(), documentID: this.__id, type: 'figma', version: 1, }; } constructor(id, format, key) { super(format, key); this.__id = id; } updateDOM() { return false; } getTextContent( // eslint-disable-next-line @typescript-eslint/no-unused-vars _includeInert, // eslint-disable-next-line @typescript-eslint/no-unused-vars _includeDirectionless) { return `https://www.figma.com/file/${this.__id}`; } decorate(_editor, config) { const embedBlockTheme = config.theme.embedBlock || {}; const className = { base: embedBlockTheme.base || '', focus: embedBlockTheme.focus || '', }; return (React.createElement(FigmaComponent, { className: className, documentID: this.__id, format: this.__format, nodeKey: this.getKey() })); } } exports.FigmaNode = FigmaNode; function $createFigmaNode(documentID) { return new FigmaNode(documentID); } function $isFigmaNode(node) { return node instanceof FigmaNode; } //# sourceMappingURL=FigmaNode.js.map