save_shortcut.ts

The editors' save shortcut, Ctrl+S / Cmd+S — shared by ContentEditor and SourceEditor so both save the same way.

view source

Declarations
#

2 declarations

handle_save_shortcut_keydown
#

save_shortcut.ts view source

(event: KeyboardEvent, save: (() => void) | null | undefined): void import {handle_save_shortcut_keydown} from '@fuzdev/zzz/save_shortcut.js';

Calls save on Ctrl+S / Cmd+S (case-insensitive, without Alt), swallowing the event so the browser's save dialog never opens and a page-level listener never saves a different editor than the focused one. An event a handler already took (defaultPrevented) is ignored, and a held key saves once per press.

event

the keydown event

type KeyboardEvent

save

the editor's save, or nullish to let the event through untouched

type (() => void) | null | undefined

returns

void

mutates

  • event — swallowed (`preventDefault` + `stopImmediatePropagation`) when it's the shortcut

SaveShortcutScope
#

save_shortcut.ts view source

SaveShortcutScope

type "focused" | "page"

import type {SaveShortcutScope} from '@fuzdev/zzz/save_shortcut.js';

Where an editor's save shortcut triggers its save: 'focused' only while its textarea has focus, 'page' from anywhere on the page unless a focused editor handles it first. Use 'page' only for the one main editor of a page.

Imported by
#