-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
60 lines (52 loc) · 1.77 KB
/
Copy pathindex.html
File metadata and controls
60 lines (52 loc) · 1.77 KB
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
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>editorjs-inline-template</title>
</head>
<body>
<div id="editorjs"></div>
<button id="button" type="button">Save</button>
<div id="output-data"></div>
<script src="https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest"></script>
<!-- For demo -->
<script src="https://cdn.jsdelivr.net/npm/editorjs-inline-template@latest"></script>
<!-- For development -->
<!--<script src="../dist/index.js"></script>-->
<script>
const data = {
blocks: [
{
type: "paragraph",
data: {
text: "editorjs-inline-template test",
},
},
],
};
const editorJS = new EditorJS({
data,
tools: {
template: {
class: EditorJSInlineTemplate.TemplateInlineTool,
config: {
buttonHTML: `
<svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512">
<path d="M336 64h32a48 48 0 0148 48v320a48 48 0 01-48 48H144a48 48 0 01-48-48V112a48 48 0 0148-48h32" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/>
<rect x="176" y="32" width="160" height="64" rx="26.13" ry="26.13" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/>
</svg>
`,
html: "<b>template</b>⭐",
},
},
},
});
document.querySelector("#button").addEventListener("click", async () => {
const outputData = await editorJS.save();
document.querySelector("#output-data").textContent = JSON.stringify(
outputData
);
});
</script>
</body>
</html>