-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathshape-textbox.js
More file actions
52 lines (44 loc) · 1017 Bytes
/
shape-textbox.js
File metadata and controls
52 lines (44 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { Node, Attribute } from '@core/index.js';
export const ShapeTextbox = Node.create({
name: 'shapeTextbox',
group: 'block',
content: 'paragraph* block*',
isolating: true,
addOptions() {
return {
htmlAttributes: {
class: 'sd-editor-shape-textbox',
'aria-label': 'Shape textbox node',
},
};
},
addAttributes() {
return {
sdBlockId: {
default: null,
keepOnSplit: false,
parseDOM: (elem) => elem.getAttribute('data-sd-block-id'),
renderDOM: (attrs) => {
return attrs.sdBlockId ? { 'data-sd-block-id': attrs.sdBlockId } : {};
},
},
attributes: {
rendered: false,
},
};
},
parseDOM() {
return [
{
tag: `div[data-type="${this.name}"]`,
},
];
},
renderDOM({ htmlAttributes }) {
return [
'div',
Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes, { 'data-type': this.name }),
0,
];
},
});