Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit b46eb2b

Browse files
Merge pull request #1286 from ssbc/publish-shortcut
Add publishing keyboard shortcuts
2 parents 89661d9 + aa5fd97 commit b46eb2b

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

lib/depject/message/html/compose.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ exports.create = function (api) {
311311
contentWarningInput.value = ''
312312
refreshHasContent()
313313
save()
314+
} else {
315+
textArea.focus()
314316
}
315317
if (cb) cb(null, msg)
316318
}

lib/depject/message/sheet/preview.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ exports.create = function (api) {
4646
// allow inspecting of raw message that is about to be sent
4747
messageElement.msg = msg
4848

49+
const cancelButton = h('button -cancel', { 'ev-click': cancel }, i18n('Cancel'))
4950
return {
5051
content: [
5152
messageElement
@@ -73,8 +74,22 @@ exports.create = function (api) {
7374
])
7475
),
7576
h('button -save', { 'ev-click': publish }, i18n('Confirm')),
76-
h('button -cancel', { 'ev-click': cancel }, i18n('Cancel'))
77-
]
77+
cancelButton
78+
],
79+
onMount: () => {
80+
cancelButton.focus()
81+
},
82+
attributes: {
83+
'ev-keydown': ev => {
84+
if (ev.key === 'Enter' && (ev.ctrlKey || ev.metaKey)) {
85+
publish()
86+
ev.preventDefault()
87+
} else if (ev.key === 'Escape') {
88+
cancel()
89+
ev.preventDefault()
90+
}
91+
}
92+
}
7893
}
7994

8095
function publish () {

lib/depject/sheet/display.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ exports.gives = nest('sheet.display')
55

66
exports.create = function () {
77
return nest('sheet.display', function (handler) {
8-
const { content, footer, classList, onMount } = handler(done)
8+
const { content, footer, classList, onMount, attributes } = handler(done)
99

10-
const container = h('div', { className: 'Sheet', classList }, [
10+
let fullAttributes = { className: 'Sheet', classList }
11+
if (attributes !== undefined) {
12+
fullAttributes = { ...attributes, ...fullAttributes }
13+
}
14+
const container = h('div', fullAttributes, [
1115
h('section', [content]),
1216
h('footer', [footer])
1317
])

0 commit comments

Comments
 (0)