All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.modules.keyboard.d.ts Maven / Gradle / Ivy

import type { BlockBlot } from 'parchment';
import Quill from '../core/quill.js';
import Module from '../core/module.js';
import type { BlockEmbed } from '../blots/block.js';
import type { Range } from '../core/selection.js';
declare const SHORTKEY: string;
export interface Context {
    collapsed: boolean;
    empty: boolean;
    offset: number;
    prefix: string;
    suffix: string;
    format: Record;
    event: KeyboardEvent;
    line: BlockEmbed | BlockBlot;
}
interface BindingObject extends Partial> {
    key: number | string | string[];
    shortKey?: boolean | null;
    shiftKey?: boolean | null;
    altKey?: boolean | null;
    metaKey?: boolean | null;
    ctrlKey?: boolean | null;
    prefix?: RegExp;
    suffix?: RegExp;
    format?: Record | string[];
    handler?: (this: {
        quill: Quill;
    }, range: Range, curContext: Context, binding: NormalizedBinding) => boolean | void;
}
type Binding = BindingObject | string | number;
interface NormalizedBinding extends Omit {
    key: string | number;
}
interface KeyboardOptions {
    bindings: Record;
}
interface KeyboardOptions {
    bindings: Record;
}
declare class Keyboard extends Module {
    static DEFAULTS: KeyboardOptions;
    static match(evt: KeyboardEvent, binding: BindingObject): boolean;
    bindings: Record;
    constructor(quill: Quill, options: Partial);
    addBinding(keyBinding: Binding, context?: Required | Partial>, handler?: Required | Partial>): void;
    listen(): void;
    handleBackspace(range: Range, context: Context): void;
    handleDelete(range: Range, context: Context): void;
    handleDeleteRange(range: Range): void;
    handleEnter(range: Range, context: Context): void;
}
declare function normalize(binding: Binding): BindingObject | null;
declare function deleteRange({ quill, range }: {
    quill: Quill;
    range: Range;
}): void;
export { Keyboard as default, SHORTKEY, normalize, deleteRange };




© 2015 - 2025 Weber Informatics LLC | Privacy Policy