-
-
Notifications
You must be signed in to change notification settings - Fork 73
/
Demo.vue
220 lines (216 loc) · 7.58 KB
/
Demo.vue
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<template>
<div class="demo">
<h1 style="text-align: center;">DEMO</h1>
<editor ref="editor" :config="config" :initialized="onInitialized"/>
</div>
</template>
<script>
import Header from '@editorjs/header';
import List from '@editorjs/list';
import CodeTool from '@editorjs/code'
import Paragraph from '@editorjs/paragraph'
import Embed from '@editorjs/embed'
import Table from '@editorjs/table'
import Checklist from '@editorjs/checklist'
import Marker from '@editorjs/marker'
import Warning from '@editorjs/warning'
import RawTool from '@editorjs/raw'
import Quote from '@editorjs/quote'
import InlineCode from '@editorjs/inline-code'
import Delimiter from '@editorjs/delimiter'
import SimpleImage from '@editorjs/simple-image'
export default {
data() {
return {
config: {
tools:{
header: {
class: Header,
config: {
placeholder: 'Enter a header',
levels: [2, 3, 4],
defaultLevel: 3,
}
},
list: {
class: List,
inlineToolbar: true,
},
code: {
class: CodeTool
},
paragraph: {
class: Paragraph,
},
embed: {
class: Embed,
config: {
services: {
youtube: true,
coub: true,
imgur: true
}
}
},
table: {
class: Table,
inlineToolbar: true,
config: {
rows: 2,
cols: 3,
},
},
checklist: {
class: Checklist,
},
Marker: {
class: Marker,
shortcut: 'CMD+SHIFT+M',
},
warning: {
class: Warning,
inlineToolbar: true,
shortcut: 'CMD+SHIFT+W',
config: {
titlePlaceholder: 'Title',
messagePlaceholder: 'Message',
},
},
raw: RawTool,
quote: {
class: Quote,
inlineToolbar: true,
shortcut: 'CMD+SHIFT+O',
config: {
quotePlaceholder: 'Enter a quote',
captionPlaceholder: 'Quote\'s author',
},
},
inlineCode: {
class: InlineCode,
shortcut: 'CMD+SHIFT+M',
},
delimiter: Delimiter,
image: SimpleImage,
},
onReady: () => {
console.log('on ready')
},
onChange: (args) => {
console.log('Now I know that Editor\'s content changed!')
},
data: {
"time": 1591362820044,
"blocks": [
{
"type" : "header",
"data" : {
"text" : "Editor.js",
"level" : 2
}
},
{
"type" : "paragraph",
"data" : {
"text" : "Hey. Meet the new Editor. On this page you can see it in action — try to edit this text."
}
},
{
"type" : "header",
"data" : {
"text" : "Key features",
"level" : 3
}
},
{
"type" : "list",
"data" : {
"style" : "unordered",
"items" : [
"It is a block-styled editor",
"It returns clean data output in JSON",
"Designed to be extendable and pluggable with a simple API"
]
}
},
{
"type" : "header",
"data" : {
"text" : "What does it mean «block-styled editor»",
"level" : 3
}
},
{
"type" : "paragraph",
"data" : {
"text" : "Workspace in classic editors is made of a single contenteditable element, used to create different HTML markups. Editor.js <mark class=\"cdx-marker\">workspace consists of separate Blocks: paragraphs, headings, images, lists, quotes, etc</mark>. Each of them is an independent contenteditable element (or more complex structure) provided by Plugin and united by Editor's Core."
}
},
{
"type" : "paragraph",
"data" : {
"text" : "There are dozens of <a href=\"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/editor-js\">ready-to-use Blocks</a> and the <a href=\"https://editorjs.io/creating-a-block-tool\">simple API</a> for creation any Block you need. For example, you can implement Blocks for Tweets, Instagram posts, surveys and polls, CTA-buttons and even games."
}
},
{
"type" : "header",
"data" : {
"text" : "What does it mean clean data output",
"level" : 3
}
},
{
"type" : "paragraph",
"data" : {
"text" : "Classic WYSIWYG-editors produce raw HTML-markup with both content data and content appearance. On the contrary, Editor.js outputs JSON object with data of each Block. You can see an example below"
}
},
{
"type" : "paragraph",
"data" : {
"text" : "Given data can be used as you want: render with HTML for <code class=\"inline-code\">Web clients</code>, render natively for <code class=\"inline-code\">mobile apps</code>, create markup for <code class=\"inline-code\">Facebook Instant Articles</code> or <code class=\"inline-code\">Google AMP</code>, generate an <code class=\"inline-code\">audio version</code> and so on."
}
},
{
"type" : "paragraph",
"data" : {
"text" : "Clean data is useful to sanitize, validate and process on the backend."
}
},
{
"type" : "delimiter",
"data" : {}
},
{
"type" : "paragraph",
"data" : {
"text" : "We have been working on this project more than three years. Several large media projects help us to test and debug the Editor, to make it's core more stable. At the same time we significantly improved the API. Now, it can be used to create any plugin for any task. Hope you enjoy. 😏"
}
},
{
"type" : "image",
"data" : {
"file" : {
"url" : "https://codex.so/public/app/img/external/codex2x.png"
},
"caption" : "",
"withBorder" : false,
"stretched" : false,
"withBackground" : false
}
},
],
"version" : "2.18.0"
}
},
};
},
methods: {
onInitialized (editor) {
console.log(editor)
}
}
};
</script>
<style>
</style>