feat: Markdown, HTML & JSON export options for super notes (#2054)
This commit is contained in:
@@ -2,8 +2,8 @@ import { KeyboardCommand } from './KeyboardCommands'
|
||||
|
||||
export type KeyboardCommandHandler = {
|
||||
command: KeyboardCommand
|
||||
onKeyDown?: (event: KeyboardEvent) => boolean | void
|
||||
onKeyUp?: (event: KeyboardEvent) => boolean | void
|
||||
onKeyDown?: (event: KeyboardEvent, data?: unknown) => boolean | void
|
||||
onKeyUp?: (event: KeyboardEvent, data?: unknown) => boolean | void
|
||||
element?: HTMLElement
|
||||
elements?: HTMLElement[]
|
||||
notElement?: HTMLElement
|
||||
|
||||
@@ -25,3 +25,6 @@ export const CAPTURE_SAVE_COMMAND = createKeyboardCommand('CAPTURE_SAVE_COMMAND'
|
||||
export const STAR_NOTE_COMMAND = createKeyboardCommand('STAR_NOTE_COMMAND')
|
||||
export const PIN_NOTE_COMMAND = createKeyboardCommand('PIN_NOTE_COMMAND')
|
||||
export const SUPER_SHOW_MARKDOWN_PREVIEW = createKeyboardCommand('SUPER_SHOW_MARKDOWN_PREVIEW')
|
||||
export const SUPER_EXPORT_JSON = createKeyboardCommand('SUPER_EXPORT_JSON')
|
||||
export const SUPER_EXPORT_MARKDOWN = createKeyboardCommand('SUPER_EXPORT_MARKDOWN')
|
||||
export const SUPER_EXPORT_HTML = createKeyboardCommand('SUPER_EXPORT_HTML')
|
||||
|
||||
@@ -165,7 +165,7 @@ export class KeyboardService {
|
||||
}
|
||||
}
|
||||
|
||||
public triggerCommand(command: KeyboardCommand): void {
|
||||
public triggerCommand(command: KeyboardCommand, data?: unknown): void {
|
||||
for (const observer of this.commandHandlers) {
|
||||
if (observer.command !== command) {
|
||||
continue
|
||||
@@ -173,7 +173,7 @@ export class KeyboardService {
|
||||
|
||||
const callback = observer.onKeyDown || observer.onKeyUp
|
||||
if (callback) {
|
||||
const exclusive = callback(new KeyboardEvent('command-trigger'))
|
||||
const exclusive = callback(new KeyboardEvent('command-trigger'), data)
|
||||
if (exclusive) {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user