Skip to content
Snippets Groups Projects

feat: persist report on the backend

Merged Samed requested to merge feat/report_backend into main
1 unresolved thread
1 file
+ 25
1
Compare changes
  • Side-by-side
  • Inline
import type { NodeKey, LexicalEditor, DOMExportOutput } from 'lexical';
import type { NodeKey, LexicalEditor, DOMExportOutput, SerializedLexicalNode, Spread } from 'lexical';
import { DecoratorNode, EditorConfig } from 'lexical';
export enum VariableType {
@@ -6,6 +6,14 @@ export enum VariableType {
visualization = 'visualization',
}
export type SerializedVariableNode = Spread<
{
name: string,
variableType: VariableType
},
SerializedLexicalNode
>;
export class VariableNode extends DecoratorNode<JSX.Element> {
__name: string;
__variableType: VariableType;
@@ -39,6 +47,22 @@ export class VariableNode extends DecoratorNode<JSX.Element> {
return `{{ ${self.__variableType}:${self.__name} }}`;
}
// Import and export
exportJSON(): SerializedVariableNode {
return {
type: this.getType(),
variableType: this.__variableType,
name: this.__name,
version: 1,
};
}
static importJSON(jsonNode: SerializedVariableNode): VariableNode {
const node = new VariableNode(jsonNode.name, jsonNode.variableType);
return node;
}
// View
createDOM(config: EditorConfig): HTMLElement {
Loading