| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 | import type { LexicalNode, NodeKey, SerializedLexicalNode } from 'lexical'import { DecoratorNode } from 'lexical'import type { WorkflowVariableBlockType } from '../../types'import WorkflowVariableBlockComponent from './component'export type WorkflowNodesMap = WorkflowVariableBlockType['workflowNodesMap']export type SerializedNode = SerializedLexicalNode & {  variables: string[]  workflowNodesMap: WorkflowNodesMap}export class WorkflowVariableBlockNode extends DecoratorNode<React.JSX.Element> {  __variables: string[]  __workflowNodesMap: WorkflowNodesMap  static getType(): string {    return 'workflow-variable-block'  }  static clone(node: WorkflowVariableBlockNode): WorkflowVariableBlockNode {    return new WorkflowVariableBlockNode(node.__variables, node.__workflowNodesMap, node.__key)  }  isInline(): boolean {    return true  }  constructor(variables: string[], workflowNodesMap: WorkflowNodesMap, key?: NodeKey) {    super(key)    this.__variables = variables    this.__workflowNodesMap = workflowNodesMap  }  createDOM(): HTMLElement {    const div = document.createElement('div')    div.classList.add('inline-flex', 'items-center', 'align-middle')    return div  }  updateDOM(): false {    return false  }  decorate(): React.JSX.Element {    return (      <WorkflowVariableBlockComponent        nodeKey={this.getKey()}        variables={this.__variables}        workflowNodesMap={this.__workflowNodesMap}      />    )  }  static importJSON(serializedNode: SerializedNode): WorkflowVariableBlockNode {    const node = $createWorkflowVariableBlockNode(serializedNode.variables, serializedNode.workflowNodesMap)    return node  }  exportJSON(): SerializedNode {    return {      type: 'workflow-variable-block',      version: 1,      variables: this.getVariables(),      workflowNodesMap: this.getWorkflowNodesMap(),    }  }  getVariables(): string[] {    const self = this.getLatest()    return self.__variables  }  getWorkflowNodesMap(): WorkflowNodesMap {    const self = this.getLatest()    return self.__workflowNodesMap  }  getTextContent(): string {    return `{{#${this.getVariables().join('.')}#}}`  }}export function $createWorkflowVariableBlockNode(variables: string[], workflowNodesMap: WorkflowNodesMap): WorkflowVariableBlockNode {  return new WorkflowVariableBlockNode(variables, workflowNodesMap)}export function $isWorkflowVariableBlockNode(  node: WorkflowVariableBlockNode | LexicalNode | null | undefined,): node is WorkflowVariableBlockNode {  return node instanceof WorkflowVariableBlockNode}
 |