UNPKG

phx-react

Version:

PHX REACT

58 lines 2.15 kB
import { BlockWithAlignableContents } from '@lexical/react/LexicalBlockWithAlignableContents'; import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode'; import * as React from 'react'; function FigmaComponent({ className, documentID, format, nodeKey }) { return (React.createElement(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' }))); } export class FigmaNode extends 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() })); } } export function $createFigmaNode(documentID) { return new FigmaNode(documentID); } export function $isFigmaNode(node) { return node instanceof FigmaNode; } //# sourceMappingURL=FigmaNode.js.map