Skip to content

Commit d660b2c

Browse files
committed
fix(editor): copy without html
1 parent f7574b7 commit d660b2c

File tree

6 files changed

+126
-68
lines changed

6 files changed

+126
-68
lines changed

src/components/editor/entity/EditorEntityInput.vue renamed to src/components/editor/entity/default/EditorEntityDefaultInput.vue

Lines changed: 68 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,27 @@
1515
w-full
1616
rounded-none
1717
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
2222
placeholder-theme-editor-input-placeholder
23-
hover:theme-editor-input-text-hover
23+
hover:theme-editor-input-text-hover
2424
active:theme-editor-input-text-active
25-
px-4 md:px-14
25+
px-4
26+
md:px-14
2627
"
2728
:style="{ minHeight: '50px' }"
2829
:class="[
2930
EDITOR.styles.input.fontSize,
3031
EDITOR.styles.input.fontFamily,
3132
EDITOR.styles.input.fontColor,
3233
]"
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+
"
3439
@input="onInput"
3540
@keypress.enter.prevent="enterHandler"
3641
@keydown="onKeyboard"
@@ -48,15 +53,15 @@
4853
import { useInput } from '@/use/input'
4954
import { useScroll } from '@/use/scroll'
5055
import useEmitter from '@/use/emitter'
51-
import { ref, computed, watch, onMounted, nextTick } from 'vue';
56+
import { ref, computed, watch, onMounted, nextTick } from 'vue'
5257
import { useI18n } from 'vue-i18n'
5358
import { useToast } from 'vue-toastification'
5459
import { useEnv } from '@/use/env'
5560
import { useFactory } from '@/use/factory'
5661
import { useEditorStore } from '@/store/editor'
5762
import { useContextStore } from '@/store/context'
5863
import usePlugin from '@/use/plugin/core'
59-
import { useUtils } from '@/use/utils'
64+
import { useUtils } from '@/use/utils'
6065
6166
const toast = useToast()
6267
const { t } = useI18n()
@@ -112,43 +117,58 @@ import { useUtils } from '@/use/utils'
112117
watch(cmp, (_cmp: string) => {
113118
plugin.emit('plugin-input-watch-initial', {
114119
data: _cmp,
115-
index: CONTEXT.entities.length
116-
})
120+
index: CONTEXT.entities.length,
121+
})
117122
118123
if (paste.value) {
119124
cmp.value = ''
120125
121126
paste.value = false
122127
}
123128
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+
) {
125133
commands.value = true
126134
} else {
127135
commands.value = false
128136
}
129137
130-
if (entity.utils().entry(_cmp, EDITOR.configuration.commands.paragraph.prefix)) {
138+
if (
139+
entity.utils().entry(_cmp, EDITOR.configuration.commands.paragraph.prefix)
140+
) {
131141
type.value = 'paragraph'
132142
cmp.value = ''
133143
input.value.placeholder = t('editor.text.placeholder.paragraph')
134144
return
135145
}
136146
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+
) {
138152
type.value = 'heading-two'
139153
cmp.value = ''
140154
input.value.placeholder = t('editor.text.placeholder.headingtwo')
141155
return
142156
}
143157
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+
) {
145163
type.value = 'heading-three'
146164
cmp.value = ''
147165
input.value.placeholder = t('editor.text.placeholder.headingthree')
148166
return
149167
}
150168
151-
if (entity.utils().entry(_cmp, EDITOR.configuration.commands.pageBreak.prefix)) {
169+
if (
170+
entity.utils().entry(_cmp, EDITOR.configuration.commands.pageBreak.prefix)
171+
) {
152172
cmp.value = ''
153173
154174
const content = {
@@ -166,7 +186,9 @@ import { useUtils } from '@/use/utils'
166186
return
167187
}
168188
169-
if (entity.utils().entry(_cmp, EDITOR.configuration.commands.lineBreak.prefix)) {
189+
if (
190+
entity.utils().entry(_cmp, EDITOR.configuration.commands.lineBreak.prefix)
191+
) {
170192
cmp.value = ''
171193
172194
const content = {
@@ -184,26 +206,36 @@ import { useUtils } from '@/use/utils'
184206
return
185207
}
186208
187-
if (entity.utils().entry(_cmp, EDITOR.configuration.commands.image.prefix)) {
209+
if (
210+
entity.utils().entry(_cmp, EDITOR.configuration.commands.image.prefix)
211+
) {
188212
cmp.value = ''
189213
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')
193218
194-
emit('enter', content)
219+
emit('enter', content)
195220
196-
return
197-
}, () => {
198-
toast.error(t('toast.generics.error'))
199-
})
221+
return
222+
},
223+
() => {
224+
toast.error(t('toast.generics.error'))
225+
}
226+
)
200227
}
201228
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
203232
204233
if (_cmp.includes(dialogue)) {
205234
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+
)
207239
208240
input.value.setSelectionRange(offset, offset)
209241
@@ -215,7 +247,7 @@ import { useUtils } from '@/use/utils'
215247
})
216248
217249
const enterHandler = () => {
218-
if(!cmp.value) return
250+
if (!cmp.value) return
219251
220252
const content = {
221253
type: type.value,
@@ -246,7 +278,7 @@ import { useUtils } from '@/use/utils'
246278
data.forEach(async (raw: string) => {
247279
const normalize = raw.replace(/\s+/g, ' ').trim()
248280
249-
if(!normalize) return
281+
if (!normalize) return
250282
251283
const content = {
252284
type: type.value,
@@ -262,12 +294,12 @@ import { useUtils } from '@/use/utils'
262294
263295
plugin.emit('plugin-entity-paste-in-page', {
264296
index: CONTEXT.entities.length,
265-
quantity: _plugin_quantity
297+
quantity: _plugin_quantity,
266298
})
267299
}
268300
269301
const onKeyboard = async (e: KeyboardEvent) => {
270-
if(e.ctrlKey) {
302+
if (e.ctrlKey) {
271303
// italic entity
272304
if (e.key === 'i') {
273305
const content = entity
@@ -317,23 +349,21 @@ import { useUtils } from '@/use/utils'
317349
return
318350
}
319351
320-
if(e.key === 'ArrowUp') {
352+
if (e.key === 'ArrowUp') {
321353
emitter.emit('entity-open-last')
322354
return
323355
}
324356
325-
if((e.key === 'Delete' || e.key === 'Backspace') && cmp.value === '') {
357+
if ((e.key === 'Delete' || e.key === 'Backspace') && cmp.value === '') {
326358
e.preventDefault()
327359
e.stopPropagation()
328-
360+
329361
emitter.emit('entity-open-last')
330362
return
331363
}
332364
}
333365
334-
const onInput = () => {
335-
336-
}
366+
const onInput = () => {}
337367
338368
const onClick = () => {
339369
emitter.emit('entity-focus')

src/components/editor/entity/EditorEntityShow.vue renamed to src/components/editor/entity/default/EditorEntityDefaultShow.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@mouseleave="hover = false"
99
@click="onClickInEntity"
1010
>
11-
<EditorEntityShowPopover
11+
<EditorEntityDefaultShowPopover
1212
v-if="hover && props.entity.type !== 'heading-one'"
1313
:entity="props.entity"
1414
/>
@@ -27,6 +27,7 @@
2727
@keydown="onKeyboard"
2828
@click="onClick"
2929
@paste="entity.base().onPaste(props.entity, data, $event)"
30+
@copy="raw.v2().copy()"
3031
v-html="raw.v2().purge().editor(props.entity)"
3132
/>
3233
</section>

src/components/editor/entity/EditorEntityShowPopover.vue renamed to src/components/editor/entity/default/EditorEntityDefaultShowPopover.vue

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,31 @@
3131
"
3232
@mouseleave="onReset"
3333
>
34-
<EditorEntityShowSelect @click.prevent.stop="onNewEntity('paragraph')">
34+
<EditorEntityDefaultShowSelect
35+
@click.prevent.stop="onNewEntity('paragraph')"
36+
>
3537
P
36-
</EditorEntityShowSelect>
37-
<EditorEntityShowSelect @click.prevent.stop="onNewEntity('heading-two')">
38+
</EditorEntityDefaultShowSelect>
39+
<EditorEntityDefaultShowSelect
40+
@click.prevent.stop="onNewEntity('heading-two')"
41+
>
3842
H2
39-
</EditorEntityShowSelect>
40-
<EditorEntityShowSelect
43+
</EditorEntityDefaultShowSelect>
44+
<EditorEntityDefaultShowSelect
4145
@click.prevent.stop="onNewEntity('heading-three')"
4246
>
4347
H3
44-
</EditorEntityShowSelect>
45-
<EditorEntityShowSelect @click.prevent.stop="onNewEntity('page-break')">
48+
</EditorEntityDefaultShowSelect>
49+
<EditorEntityDefaultShowSelect
50+
@click.prevent.stop="onNewEntity('page-break')"
51+
>
4652
BP
47-
</EditorEntityShowSelect>
48-
<EditorEntityShowSelect @click.prevent.stop="onNewEntity('line-break')">
53+
</EditorEntityDefaultShowSelect>
54+
<EditorEntityDefaultShowSelect
55+
@click.prevent.stop="onNewEntity('line-break')"
56+
>
4957
LB
50-
</EditorEntityShowSelect>
58+
</EditorEntityDefaultShowSelect>
5159
</section>
5260
<HeroIcon @mouseenter.prevent.stop="onNewEntityWrapper">
5361
<svg
@@ -76,29 +84,31 @@
7684
z-max
7785
"
7886
>
79-
<EditorEntityShowSelect @click.prevent.stop="onSwitchEntity('paragraph')">
87+
<EditorEntityDefaultShowSelect
88+
@click.prevent.stop="onSwitchEntity('paragraph')"
89+
>
8090
P
81-
</EditorEntityShowSelect>
82-
<EditorEntityShowSelect
91+
</EditorEntityDefaultShowSelect>
92+
<EditorEntityDefaultShowSelect
8393
@click.prevent.stop="onSwitchEntity('heading-two')"
8494
>
8595
H2
86-
</EditorEntityShowSelect>
87-
<EditorEntityShowSelect
96+
</EditorEntityDefaultShowSelect>
97+
<EditorEntityDefaultShowSelect
8898
@click.prevent.stop="onSwitchEntity('heading-three')"
8999
>
90100
H3
91-
</EditorEntityShowSelect>
92-
<EditorEntityShowSelect
101+
</EditorEntityDefaultShowSelect>
102+
<EditorEntityDefaultShowSelect
93103
@click.prevent.stop="onSwitchEntity('page-break')"
94104
>
95105
BP
96-
</EditorEntityShowSelect>
97-
<EditorEntityShowSelect
106+
</EditorEntityDefaultShowSelect>
107+
<EditorEntityDefaultShowSelect
98108
@click.prevent.stop="onSwitchEntity('line-break')"
99109
>
100110
LB
101-
</EditorEntityShowSelect>
111+
</EditorEntityDefaultShowSelect>
102112
</section>
103113
<HeroIcon
104114
class="wb-icon"
@@ -129,7 +139,7 @@
129139
border-theme-border-1
130140
"
131141
>
132-
<EditorEntityShowSelect @click.prevent.stop="onUpEntity">
142+
<EditorEntityDefaultShowSelect @click.prevent.stop="onUpEntity">
133143
<template #icon>
134144
<HeroIcon>
135145
<svg
@@ -147,8 +157,8 @@
147157
</HeroIcon>
148158
</template>
149159
<p>{{ t('editor.aside.entity.up') }}</p>
150-
</EditorEntityShowSelect>
151-
<EditorEntityShowSelect @click.prevent.stop="onDownEntity">
160+
</EditorEntityDefaultShowSelect>
161+
<EditorEntityDefaultShowSelect @click.prevent.stop="onDownEntity">
152162
<template #icon>
153163
<HeroIcon>
154164
<svg
@@ -166,8 +176,8 @@
166176
</HeroIcon>
167177
</template>
168178
<p>{{ t('editor.aside.entity.down') }}</p>
169-
</EditorEntityShowSelect>
170-
<EditorEntityShowSelect @click.prevent.stop="onDeleteEntity">
179+
</EditorEntityDefaultShowSelect>
180+
<EditorEntityDefaultShowSelect @click.prevent.stop="onDeleteEntity">
171181
<template #icon>
172182
<HeroIcon>
173183
<svg
@@ -185,7 +195,7 @@
185195
</HeroIcon>
186196
</template>
187197
<p>{{ t('editor.aside.entity.delete') }}</p>
188-
</EditorEntityShowSelect>
198+
</EditorEntityDefaultShowSelect>
189199
</section>
190200
<HeroIcon
191201
v-if="

src/components/editor/main/EditorBase.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
overflow-y-auto overflow-x-hidden
2929
"
3030
>
31-
<EditorEntityShow
31+
<EditorEntityDefaultShow
3232
v-for="(entity, index) in entities"
3333
:id="`entity-${String(index)}`"
3434
:key="index"
3535
:entity="entity"
3636
/>
37-
<EditorEntityInput
37+
<EditorEntityDefaultInput
3838
v-if="PROJECT.name !== env.projectEmpty()"
3939
v-model="entry"
4040
@enter="enterListener"

0 commit comments

Comments
 (0)