Skip to content

Commit 708f920

Browse files
committed
fix(editor): not mutate entities in swap
1 parent fe8a2ee commit 708f920

File tree

4 files changed

+24
-19
lines changed

4 files changed

+24
-19
lines changed

src/components/editor/entity/EditorEntityShow.vue

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,33 @@
365365
}
366366
})
367367
368+
emitter.on('entity-not-mutate-down', async (entity: Entity) => {
369+
const _id = CONTEXT.entities.indexOf(entity)
370+
371+
focus.value = false
372+
edit.value = false
373+
374+
await nextTick
375+
376+
if (CONTEXT.entities[_id + 1] === props.entity) {
377+
onEdit()
378+
}
379+
})
380+
368381
emitter.on('project-save', () => {
369382
emitter.emit('entity-close', { all: true })
370383
})
371384
372385
emitter.on('entity-force-close', () => {
373386
onUpdateContent()
374387
})
388+
389+
emitter.on('entity-update-area', () => {
390+
if (document.activeElement === input.value) {
391+
console.log('kekwww')
392+
onChangeArea()
393+
}
394+
})
375395
})
376396
377397
const onUpdateContent = async () => {
@@ -530,7 +550,7 @@
530550
}
531551
532552
// delete entity
533-
if (e.key === 'm') {
553+
if (e.key === 'd') {
534554
entity.base().onDelete(props.entity, _index.value)
535555
}
536556

src/types/emitter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export type VueEmitterName =
1919
| 'entity-open-last'
2020
| 'entity-not-mutate'
2121
| 'entity-force-close'
22+
| 'entity-update-area'
23+
| 'entity-not-mutate-down'
2224
| 'project-save'
2325
| 'pdf-preview-exists'
2426

src/use/entity.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export const useEntity = () => {
198198
const onDown = async (entity: Entity, index: number) => {
199199
await nextTick
200200

201-
emitter.emit('entity-not-mutate', entity)
201+
emitter.emit('entity-not-mutate-down', entity)
202202

203203
await nextTick
204204

@@ -207,16 +207,6 @@ export const useEntity = () => {
207207
direction: 'down',
208208
})
209209

210-
emitter.emit('entity-close', { all: true })
211-
212-
await nextTick
213-
214-
emitter.emit('entity-open', {
215-
entity,
216-
up: false,
217-
switch: true,
218-
})
219-
220210
if (index === CONTEXT.entities.length - 1) return
221211

222212
plugin.emit('plugin-entity-swap', {

src/use/keyboard.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export const useKeyboard = () => {
2525
const project = useProject()
2626

2727
const init: Callback<void> = () => {
28-
defaultPrevents()
2928
saveLocal()
3029
loadLocal()
3130
newProject()
@@ -43,12 +42,6 @@ export const useKeyboard = () => {
4342
keyboard.stop()
4443
}
4544

46-
const defaultPrevents = () => {
47-
keyboard.bind('ctrl > d', (e: Event) => {
48-
utils.prevent(e)
49-
})
50-
}
51-
5245
const saveLocal = () => {
5346
keyboard.bind(SHORTCUTS.localSaveProject[1], (e: Event) => {
5447
utils.prevent(e)

0 commit comments

Comments
 (0)