]> BookStack Code Mirror - bookstack/blob - resources/js/wysiwyg/lexical/core/nodes/CommonBlockNode.ts
37ca1cdef7f5c96608aa219aa41503ddd6fc2fa9
[bookstack] / resources / js / wysiwyg / lexical / core / nodes / CommonBlockNode.ts
1 import {ElementNode} from "./LexicalElementNode";
2 import {CommonBlockAlignment, SerializedCommonBlockNode} from "../../../nodes/_common";
3
4
5 export class CommonBlockNode extends ElementNode {
6     __id: string = '';
7     __alignment: CommonBlockAlignment = '';
8     __inset: number = 0;
9
10     setId(id: string) {
11         const self = this.getWritable();
12         self.__id = id;
13     }
14
15     getId(): string {
16         const self = this.getLatest();
17         return self.__id;
18     }
19
20     setAlignment(alignment: CommonBlockAlignment) {
21         const self = this.getWritable();
22         self.__alignment = alignment;
23     }
24
25     getAlignment(): CommonBlockAlignment {
26         const self = this.getLatest();
27         return self.__alignment;
28     }
29
30     setInset(size: number) {
31         const self = this.getWritable();
32         self.__inset = size;
33     }
34
35     getInset(): number {
36         const self = this.getLatest();
37         return self.__inset;
38     }
39
40     exportJSON(): SerializedCommonBlockNode {
41         return {
42             ...super.exportJSON(),
43             id: this.__id,
44             alignment: this.__alignment,
45             inset: this.__inset,
46         };
47     }
48 }
49
50 export function copyCommonBlockProperties(from: CommonBlockNode, to: CommonBlockNode): void {
51     to.__id = from.__id;
52     to.__alignment = from.__alignment;
53     to.__inset = from.__inset;
54 }