Skip to content

Commit 6853c44

Browse files
Desc editor improvements
1 parent b112731 commit 6853c44

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/App.svelte

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,14 @@
266266
tick().then(() => focusItem(newId))
267267
}
268268
269+
if (event.shiftKey && event.key === 'Enter' && !event.target.closest('[contenteditable]')) {
270+
if ($zoomedItemId) {
271+
event.preventDefault()
272+
focusDescription($zoomedItemId)
273+
return
274+
}
275+
}
276+
269277
if ((event.metaKey || event.ctrlKey) && event.key === 'z') {
270278
if (event.shiftKey) {
271279
event.preventDefault()

src/components/RichEditorExtensions.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ export function getExtensions({
115115
},
116116
onShiftArrowDown: () => {
117117
dispatch('shiftselectdown')
118+
},
119+
onEscape: () => {
120+
if (isDescription) {
121+
dispatch('exitdescription')
122+
}
118123
}
119124
}),
120125
CheckboxExtension.configure({

src/extensions/KeyboardExtension.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const KeyboardExtension = Extension.create({
1616
onArrowDown: null,
1717
onShiftArrowUp: null,
1818
onShiftArrowDown: null,
19+
onEscape: null,
1920
isDescription: false,
2021
isZoomedRootDescription: false
2122
}
@@ -155,6 +156,14 @@ export const KeyboardExtension = Extension.create({
155156
return true
156157
}
157158
return false
159+
},
160+
161+
'Escape': () => {
162+
if (this.options.isDescription && this.options.onEscape) {
163+
this.options.onEscape()
164+
return true
165+
}
166+
return false
158167
}
159168
}
160169
}

0 commit comments

Comments
 (0)