Skip to content

Commit f7574b7

Browse files
committed
feat(editor): commands preferences
1 parent 94a968f commit f7574b7

File tree

6 files changed

+132
-23
lines changed

6 files changed

+132
-23
lines changed

src/components/editor/entity/EditorEntityInput.vue

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
EDITOR.styles.input.fontFamily,
3131
EDITOR.styles.input.fontColor,
3232
]"
33-
:placeholder="t('editor.text.placeholder.base')"
33+
:placeholder="t('editor.text.placeholder.base', { prefix: EDITOR.configuration.commands.prefix })"
3434
@input="onInput"
3535
@keypress.enter.prevent="enterHandler"
3636
@keydown="onKeyboard"
@@ -121,34 +121,34 @@ import { useUtils } from '@/use/utils'
121121
paste.value = false
122122
}
123123
124-
if (_cmp.startsWith('/') && _cmp.length <= 2) {
124+
if (_cmp.startsWith(EDITOR.configuration.commands.prefix) && _cmp.length <= 2) {
125125
commands.value = true
126126
} else {
127127
commands.value = false
128128
}
129129
130-
if (entity.utils().entry(_cmp, 'p')) {
130+
if (entity.utils().entry(_cmp, EDITOR.configuration.commands.paragraph.prefix)) {
131131
type.value = 'paragraph'
132132
cmp.value = ''
133133
input.value.placeholder = t('editor.text.placeholder.paragraph')
134134
return
135135
}
136136
137-
if (entity.utils().entry(_cmp, 'h2')) {
137+
if (entity.utils().entry(_cmp, EDITOR.configuration.commands.headingTwo.prefix)) {
138138
type.value = 'heading-two'
139139
cmp.value = ''
140140
input.value.placeholder = t('editor.text.placeholder.headingtwo')
141141
return
142142
}
143143
144-
if (entity.utils().entry(_cmp, 'h3')) {
144+
if (entity.utils().entry(_cmp, EDITOR.configuration.commands.headingThree.prefix)) {
145145
type.value = 'heading-three'
146146
cmp.value = ''
147147
input.value.placeholder = t('editor.text.placeholder.headingthree')
148148
return
149149
}
150150
151-
if (entity.utils().entry(_cmp, 'bp')) {
151+
if (entity.utils().entry(_cmp, EDITOR.configuration.commands.pageBreak.prefix)) {
152152
cmp.value = ''
153153
154154
const content = {
@@ -166,7 +166,7 @@ import { useUtils } from '@/use/utils'
166166
return
167167
}
168168
169-
if (entity.utils().entry(_cmp, 'lb')) {
169+
if (entity.utils().entry(_cmp, EDITOR.configuration.commands.lineBreak.prefix)) {
170170
cmp.value = ''
171171
172172
const content = {
@@ -184,7 +184,7 @@ import { useUtils } from '@/use/utils'
184184
return
185185
}
186186
187-
if (entity.utils().entry(_cmp, 'im')) {
187+
if (entity.utils().entry(_cmp, EDITOR.configuration.commands.image.prefix)) {
188188
cmp.value = ''
189189
190190
factory.simulate().file((content: Entity) => {
@@ -199,9 +199,11 @@ import { useUtils } from '@/use/utils'
199199
})
200200
}
201201
202-
if (_cmp.includes('/d')) {
203-
const offset = _cmp.indexOf('/d') + 2
204-
const sub = _cmp.replace('/d', '')
202+
const dialogue = EDITOR.configuration.commands.prefix + EDITOR.configuration.commands.dialogue.prefix
203+
204+
if (_cmp.includes(dialogue)) {
205+
const offset = _cmp.indexOf(dialogue) + dialogue.length
206+
const sub = _cmp.replace(dialogue, EDITOR.configuration.commands.dialogue.value)
205207
206208
input.value.setSelectionRange(offset, offset)
207209

src/components/editor/entity/EditorEntityShow.vue

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,21 @@
133133
index: _index.value,
134134
})
135135
136-
if (data.value.startsWith('/') && data.value.length <= 2) {
136+
if (
137+
data.value.startsWith(EDITOR.configuration.commands.prefix) &&
138+
data.value.length <= 2
139+
) {
137140
scroll.to(`#entity-${_index.value}`, 'center')
138141
commands.value = true
139142
} else {
140143
commands.value = false
141144
}
142145
143-
if (entity.utils().entry(_data, 'p')) {
146+
if (
147+
entity
148+
.utils()
149+
.entry(_data, EDITOR.configuration.commands.paragraph.prefix)
150+
) {
144151
setData('')
145152
146153
CONTEXT.newInExistentEntity({
@@ -149,7 +156,11 @@
149156
})
150157
}
151158
152-
if (entity.utils().entry(_data, 'h2')) {
159+
if (
160+
entity
161+
.utils()
162+
.entry(_data, EDITOR.configuration.commands.headingTwo.prefix)
163+
) {
153164
setData('')
154165
155166
CONTEXT.newInExistentEntity({
@@ -158,7 +169,11 @@
158169
})
159170
}
160171
161-
if (entity.utils().entry(_data, 'h3')) {
172+
if (
173+
entity
174+
.utils()
175+
.entry(_data, EDITOR.configuration.commands.headingThree.prefix)
176+
) {
162177
setData('')
163178
164179
CONTEXT.newInExistentEntity({
@@ -167,7 +182,11 @@
167182
})
168183
}
169184
170-
if (entity.utils().entry(_data, 'bp')) {
185+
if (
186+
entity
187+
.utils()
188+
.entry(_data, EDITOR.configuration.commands.pageBreak.prefix)
189+
) {
171190
setData('')
172191
173192
CONTEXT.newInExistentEntity({
@@ -180,7 +199,11 @@
180199
emitter.emit('entity-not-mutate-down', props.entity)
181200
}
182201
183-
if (entity.utils().entry(_data, 'lb')) {
202+
if (
203+
entity
204+
.utils()
205+
.entry(_data, EDITOR.configuration.commands.lineBreak.prefix)
206+
) {
184207
setData('')
185208
186209
CONTEXT.newInExistentEntity({
@@ -193,7 +216,9 @@
193216
emitter.emit('entity-not-mutate-down', props.entity)
194217
}
195218
196-
if (entity.utils().entry(_data, 'im')) {
219+
if (
220+
entity.utils().entry(_data, EDITOR.configuration.commands.image.prefix)
221+
) {
197222
setData('')
198223
199224
factory.simulate().file(
@@ -215,9 +240,16 @@
215240
)
216241
}
217242
218-
if (_data.includes('/d')) {
219-
const offset = _data.indexOf('/d') + 2
220-
const sub = _data.replace('/d', '')
243+
const dialogue =
244+
EDITOR.configuration.commands.prefix +
245+
EDITOR.configuration.commands.dialogue.prefix
246+
247+
if (_data.includes(dialogue)) {
248+
const offset = _data.indexOf(dialogue) + dialogue.length
249+
const sub = _data.replace(
250+
dialogue,
251+
EDITOR.configuration.commands.dialogue.value
252+
)
221253
222254
setData(sub)
223255
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<template>
2+
<div class="flex flex-col w-full p-1 my-8 shadow-lg lg:w-1/2">
3+
<h3 class="text-2xl font-bold text-theme-text-2">
4+
{{ t('editor.aside.commands.title') }}
5+
</h3>
6+
<div class="wb-configuration">
7+
<p>{{ t('editor.aside.commands.prefix') }}</p>
8+
<InputText
9+
v-model="EDITOR.configuration.commands.prefix"
10+
class="wb-configuration-input-text"
11+
/>
12+
</div>
13+
<div class="wb-configuration">
14+
<p>{{ t('editor.aside.commands.contents[1].title') }}</p>
15+
<InputText
16+
v-model="EDITOR.configuration.commands.paragraph.prefix"
17+
class="wb-configuration-input-text"
18+
/>
19+
</div>
20+
<div class="wb-configuration">
21+
<p>{{ t('editor.aside.commands.contents[4].title') }}</p>
22+
<InputText
23+
v-model="EDITOR.configuration.commands.headingTwo.prefix"
24+
class="wb-configuration-input-text"
25+
/>
26+
</div>
27+
<div class="wb-configuration">
28+
<p>{{ t('editor.aside.commands.contents[5].title') }}</p>
29+
<InputText
30+
v-model="EDITOR.configuration.commands.headingThree.prefix"
31+
class="wb-configuration-input-text"
32+
/>
33+
</div>
34+
<div class="wb-configuration">
35+
<p>{{ t('editor.aside.commands.contents[6].title') }}</p>
36+
<InputText
37+
v-model="EDITOR.configuration.commands.pageBreak.prefix"
38+
class="wb-configuration-input-text"
39+
/>
40+
</div>
41+
<div class="wb-configuration">
42+
<p>{{ t('editor.aside.commands.contents[7].title') }}</p>
43+
<InputText
44+
v-model="EDITOR.configuration.commands.lineBreak.prefix"
45+
class="wb-configuration-input-text"
46+
/>
47+
</div>
48+
<div class="wb-configuration">
49+
<p>{{ t('editor.aside.commands.contents[8].title') }}</p>
50+
<InputText
51+
v-model="EDITOR.configuration.commands.image.prefix"
52+
class="wb-configuration-input-text"
53+
/>
54+
</div>
55+
<div class="wb-configuration">
56+
<p>{{ t('editor.aside.commands.contents[9].title') }}</p>
57+
<InputText
58+
v-model="EDITOR.configuration.commands.dialogue.prefix"
59+
class="wb-configuration-input-text"
60+
/>
61+
</div>
62+
</div>
63+
</template>
64+
65+
<script setup lang="ts">
66+
import { useEditorStore } from '@/store/editor'
67+
import { useI18n } from 'vue-i18n'
68+
69+
const EDITOR = useEditorStore()
70+
71+
const { t } = useI18n()
72+
</script>

src/components/editor/provider/project/ProviderProjectPreferences.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<EditorProjectPreferencesDefault />
44
<EditorProjectPreferencesConfiguration />
55
<EditorProjectPreferencesEntity />
6+
<EditorProjectPreferencesCommands />
67
<EditorProjectPreferencesKeyboard />
78
</div>
89
</template>

src/lang/br/editor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default {
106106
},
107107
text: {
108108
placeholder: {
109-
base: `Insira '/' para exibir a lista de comandos.`,
109+
base: `Insira '{prefix}' para exibir a lista de comandos.`,
110110
paragraph: 'Parágrafo',
111111
headingone: 'H1',
112112
headingtwo: 'H2',
@@ -324,6 +324,7 @@ export default {
324324
},
325325
commands: {
326326
title: 'Comandos',
327+
prefix: 'Prefixo',
327328
contents: [
328329
{
329330
tag: 'P',

src/lang/en/editor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default {
107107
},
108108
text: {
109109
placeholder: {
110-
base: `Insert '/' to display a list of commands.`,
110+
base: `Insert '{prefix}' to display a list of commands.`,
111111
paragraph: 'Paragraph',
112112
headingone: 'H1',
113113
headingtwo: 'H2',
@@ -324,6 +324,7 @@ export default {
324324
},
325325
commands: {
326326
title: 'Commands',
327+
prefix: 'Prefix',
327328
contents: [
328329
{
329330
tag: 'P',

0 commit comments

Comments
 (0)