import {Extension} from "@tiptap/core";
import {LinwitDocEditor, InnerEditor} from "../core/LinwitDocEditor.ts";


export interface SaveExtOptions {
    onSave?: (e: LinwitDocEditor) => boolean,
}

export const SaveExt = Extension.create<SaveExtOptions>({
    name: "saveExt",
    addKeyboardShortcuts() {
        return {
            'Mod-s': ({editor}) => {
                if (this.options.onSave) {
                    return this.options.onSave((editor as InnerEditor).linwitDocEditor)
                }
                return false;
            },
        }
    },
})
