-
Notifications
You must be signed in to change notification settings - Fork 1
/
editor.svelte
154 lines (135 loc) · 3.72 KB
/
editor.svelte
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
<script >
import EditorJS from '@editorjs/editorjs';
import Header from '@editorjs/header';
import List from '@editorjs/list';
import Quote from '@editorjs/quote';
import editorjsCodeflask from '@calumk/editorjs-codeflask';
import Embed from '@editorjs/embed';
import ImageTool from '@editorjs/image';
import LinkTool from '@editorjs/link';
import RawTool from '@editorjs/raw';
// import SimpleImage from '@editorjs/simple-image';
import EditorJSStyle from 'editorjs-style';
import Table from 'editorjs-table';
import Marker from '@editorjs/marker';
import Underline from '@editorjs/underline';
import Tooltip from 'editorjs-tooltip';
import InlineCode from '@editorjs/inline-code';
import Hyperlink from 'editorjs-hyperlink';;
//data
export let data = 'hi' ;
export let url ;
const editor = new EditorJS({
/**
* Id of Element that should contain the Editor
*/
holder: 'editorjs',
data:data,
placeholder: 'Let`s write an awesome story!',
/**
* Available Tools list.
* Pass Tool's class or Settings object for each Tool you want to use
*/
tools: {
tooltip: {
class: Tooltip,
config: {
location: 'left',
highlightColor: '#FFEFD5',
underline: true,
backgroundColor: '#154360',
textColor: '#FDFEFE',
//holder: 'editorId',
}
},
header: {
class: Header,
inlineToolbar: ['link']
},
list: {
class: List,
inlineToolbar: true
} ,
code : editorjsCodeflask,
quote: {
class: Quote,
inlineToolbar: true,
shortcut: 'CMD+SHIFT+O',
config: {
quotePlaceholder: 'Enter a quote',
captionPlaceholder: 'Quote\'s author',
},
},
embed: {
class: Embed,
inlineToolbar: true,
config: {
services: {
youtube: true,
coub: true
}
}
},
image: {
class: ImageTool,
config: {
endpoints: {
byFile: url, // Your backend file uploader endpoint
byUrl: url, // Your endpoint that provides uploading by Url
}
}
},
linkTool: {
class: LinkTool,
config: {
endpoint: 'http:https://localhost:8008/fetchUrl', // Your backend endpoint for url data fetching,
}
},
raw: RawTool,
style: EditorJSStyle.StyleInlineTool,
table: {
class: Table,
},
Marker: {
class: Marker,
shortcut: 'CMD+SHIFT+M',
},
underline: Underline,
inlineCode: {
class: InlineCode,
shortcut: 'CMD+SHIFT+M',
},
hyperlink: {
class: Hyperlink,
config: {
shortcut: 'CMD+L',
target: '_blank',
rel: '',
availableTargets: ['_blank', '_self'],
availableRels: ['author', 'noreferrer'],
validate: false,
}
},
},
})
//export editor instance
export {editor}
</script>
<div class='e-row '>
<div id='editorjs' >
</div>
</div>
<style>
.e-row{
display: contents;
box-shadow: rgba(0, 0, 0, 0.06) 0px 2px 4px 0px inset;
}
#editorjs{
min-width:200px;
min-height:200px;
max-width: 700px;
padding: 0 1.5em 0 1.5em;
margin: auto;
display: contents;
}
</style>