15
15
w-full
16
16
rounded-none
17
17
border-none
18
- bg-theme-editor-input-background
19
- hover:bg-theme-editor-input-background-hover
20
- active:bg-theme-editor-input-background-active
21
- text-theme-editor-input-text
18
+ bg-theme-editor-input-background
19
+ hover:bg-theme-editor-input-background-hover
20
+ active:bg-theme-editor-input-background-active
21
+ text-theme-editor-input-text
22
22
placeholder-theme-editor-input-placeholder
23
- hover:theme-editor-input-text-hover
23
+ hover:theme-editor-input-text-hover
24
24
active:theme-editor-input-text-active
25
- px-4 md:px-14
25
+ px-4
26
+ md:px-14
26
27
"
27
28
:style =" { minHeight: '50px' }"
28
29
:class =" [
29
30
EDITOR.styles.input.fontSize,
30
31
EDITOR.styles.input.fontFamily,
31
32
EDITOR.styles.input.fontColor,
32
33
]"
33
- :placeholder =" t('editor.text.placeholder.base', { prefix: EDITOR.configuration.commands.prefix })"
34
+ :placeholder ="
35
+ t('editor.text.placeholder.base', {
36
+ prefix: EDITOR.configuration.commands.prefix,
37
+ })
38
+ "
34
39
@input =" onInput"
35
40
@keypress.enter.prevent =" enterHandler"
36
41
@keydown =" onKeyboard"
48
53
import { useInput } from ' @/use/input'
49
54
import { useScroll } from ' @/use/scroll'
50
55
import useEmitter from ' @/use/emitter'
51
- import { ref , computed , watch , onMounted , nextTick } from ' vue' ;
56
+ import { ref , computed , watch , onMounted , nextTick } from ' vue'
52
57
import { useI18n } from ' vue-i18n'
53
58
import { useToast } from ' vue-toastification'
54
59
import { useEnv } from ' @/use/env'
55
60
import { useFactory } from ' @/use/factory'
56
61
import { useEditorStore } from ' @/store/editor'
57
62
import { useContextStore } from ' @/store/context'
58
63
import usePlugin from ' @/use/plugin/core'
59
- import { useUtils } from ' @/use/utils'
64
+ import { useUtils } from ' @/use/utils'
60
65
61
66
const toast = useToast ()
62
67
const { t } = useI18n ()
@@ -112,43 +117,58 @@ import { useUtils } from '@/use/utils'
112
117
watch (cmp , (_cmp : string ) => {
113
118
plugin .emit (' plugin-input-watch-initial' , {
114
119
data: _cmp ,
115
- index: CONTEXT .entities .length
116
- })
120
+ index: CONTEXT .entities .length ,
121
+ })
117
122
118
123
if (paste .value ) {
119
124
cmp .value = ' '
120
125
121
126
paste .value = false
122
127
}
123
128
124
- if (_cmp .startsWith (EDITOR .configuration .commands .prefix ) && _cmp .length <= 2 ) {
129
+ if (
130
+ _cmp .startsWith (EDITOR .configuration .commands .prefix ) &&
131
+ _cmp .length <= 2
132
+ ) {
125
133
commands .value = true
126
134
} else {
127
135
commands .value = false
128
136
}
129
137
130
- if (entity .utils ().entry (_cmp , EDITOR .configuration .commands .paragraph .prefix )) {
138
+ if (
139
+ entity .utils ().entry (_cmp , EDITOR .configuration .commands .paragraph .prefix )
140
+ ) {
131
141
type .value = ' paragraph'
132
142
cmp .value = ' '
133
143
input .value .placeholder = t (' editor.text.placeholder.paragraph' )
134
144
return
135
145
}
136
146
137
- if (entity .utils ().entry (_cmp , EDITOR .configuration .commands .headingTwo .prefix )) {
147
+ if (
148
+ entity
149
+ .utils ()
150
+ .entry (_cmp , EDITOR .configuration .commands .headingTwo .prefix )
151
+ ) {
138
152
type .value = ' heading-two'
139
153
cmp .value = ' '
140
154
input .value .placeholder = t (' editor.text.placeholder.headingtwo' )
141
155
return
142
156
}
143
157
144
- if (entity .utils ().entry (_cmp , EDITOR .configuration .commands .headingThree .prefix )) {
158
+ if (
159
+ entity
160
+ .utils ()
161
+ .entry (_cmp , EDITOR .configuration .commands .headingThree .prefix )
162
+ ) {
145
163
type .value = ' heading-three'
146
164
cmp .value = ' '
147
165
input .value .placeholder = t (' editor.text.placeholder.headingthree' )
148
166
return
149
167
}
150
168
151
- if (entity .utils ().entry (_cmp , EDITOR .configuration .commands .pageBreak .prefix )) {
169
+ if (
170
+ entity .utils ().entry (_cmp , EDITOR .configuration .commands .pageBreak .prefix )
171
+ ) {
152
172
cmp .value = ' '
153
173
154
174
const content = {
@@ -166,7 +186,9 @@ import { useUtils } from '@/use/utils'
166
186
return
167
187
}
168
188
169
- if (entity .utils ().entry (_cmp , EDITOR .configuration .commands .lineBreak .prefix )) {
189
+ if (
190
+ entity .utils ().entry (_cmp , EDITOR .configuration .commands .lineBreak .prefix )
191
+ ) {
170
192
cmp .value = ' '
171
193
172
194
const content = {
@@ -184,26 +206,36 @@ import { useUtils } from '@/use/utils'
184
206
return
185
207
}
186
208
187
- if (entity .utils ().entry (_cmp , EDITOR .configuration .commands .image .prefix )) {
209
+ if (
210
+ entity .utils ().entry (_cmp , EDITOR .configuration .commands .image .prefix )
211
+ ) {
188
212
cmp .value = ' '
189
213
190
- factory .simulate ().file ((content : Entity ) => {
191
- type .value = ' paragraph'
192
- input .value .placeholder = t (' editor.text.placeholder.paragraph' )
214
+ factory .simulate ().file (
215
+ (content : Entity ) => {
216
+ type .value = ' paragraph'
217
+ input .value .placeholder = t (' editor.text.placeholder.paragraph' )
193
218
194
- emit (' enter' , content )
219
+ emit (' enter' , content )
195
220
196
- return
197
- }, () => {
198
- toast .error (t (' toast.generics.error' ))
199
- })
221
+ return
222
+ },
223
+ () => {
224
+ toast .error (t (' toast.generics.error' ))
225
+ }
226
+ )
200
227
}
201
228
202
- const dialogue = EDITOR .configuration .commands .prefix + EDITOR .configuration .commands .dialogue .prefix
229
+ const dialogue =
230
+ EDITOR .configuration .commands .prefix +
231
+ EDITOR .configuration .commands .dialogue .prefix
203
232
204
233
if (_cmp .includes (dialogue )) {
205
234
const offset = _cmp .indexOf (dialogue ) + dialogue .length
206
- const sub = _cmp .replace (dialogue , EDITOR .configuration .commands .dialogue .value )
235
+ const sub = _cmp .replace (
236
+ dialogue ,
237
+ EDITOR .configuration .commands .dialogue .value
238
+ )
207
239
208
240
input .value .setSelectionRange (offset , offset )
209
241
@@ -215,7 +247,7 @@ import { useUtils } from '@/use/utils'
215
247
})
216
248
217
249
const enterHandler = () => {
218
- if (! cmp .value ) return
250
+ if (! cmp .value ) return
219
251
220
252
const content = {
221
253
type: type .value ,
@@ -246,7 +278,7 @@ import { useUtils } from '@/use/utils'
246
278
data .forEach (async (raw : string ) => {
247
279
const normalize = raw .replace (/ \s + / g , ' ' ).trim ()
248
280
249
- if (! normalize ) return
281
+ if (! normalize ) return
250
282
251
283
const content = {
252
284
type: type .value ,
@@ -262,12 +294,12 @@ import { useUtils } from '@/use/utils'
262
294
263
295
plugin .emit (' plugin-entity-paste-in-page' , {
264
296
index: CONTEXT .entities .length ,
265
- quantity: _plugin_quantity
297
+ quantity: _plugin_quantity ,
266
298
})
267
299
}
268
300
269
301
const onKeyboard = async (e : KeyboardEvent ) => {
270
- if (e .ctrlKey ) {
302
+ if (e .ctrlKey ) {
271
303
// italic entity
272
304
if (e .key === ' i' ) {
273
305
const content = entity
@@ -317,23 +349,21 @@ import { useUtils } from '@/use/utils'
317
349
return
318
350
}
319
351
320
- if (e .key === ' ArrowUp' ) {
352
+ if (e .key === ' ArrowUp' ) {
321
353
emitter .emit (' entity-open-last' )
322
354
return
323
355
}
324
356
325
- if ((e .key === ' Delete' || e .key === ' Backspace' ) && cmp .value === ' ' ) {
357
+ if ((e .key === ' Delete' || e .key === ' Backspace' ) && cmp .value === ' ' ) {
326
358
e .preventDefault ()
327
359
e .stopPropagation ()
328
-
360
+
329
361
emitter .emit (' entity-open-last' )
330
362
return
331
363
}
332
364
}
333
365
334
- const onInput = () => {
335
-
336
- }
366
+ const onInput = () => {}
337
367
338
368
const onClick = () => {
339
369
emitter .emit (' entity-focus' )
0 commit comments