feat: Markdown, HTML & JSON export options for super notes (#2054)

This commit is contained in:
Aman Harwara
2022-11-25 13:58:44 +05:30
committed by GitHub
parent ff1d71c2f8
commit dcc8cfbe45
9 changed files with 268 additions and 61 deletions

View File

@@ -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

View File

@@ -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')

View File

@@ -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
}