mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 20:16:26 +08:00
chore: merge blocksuite source code (#9213)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import type { InlineEditor } from '../inline-editor.js';
|
||||
import type { InlineRange } from '../types.js';
|
||||
import type { BaseTextAttributes } from '../utils/base-attributes.js';
|
||||
|
||||
export interface BeforeinputHookCtx<TextAttributes extends BaseTextAttributes> {
|
||||
inlineEditor: InlineEditor<TextAttributes>;
|
||||
raw: InputEvent;
|
||||
inlineRange: InlineRange;
|
||||
data: string | null;
|
||||
attributes: TextAttributes;
|
||||
}
|
||||
export interface CompositionEndHookCtx<
|
||||
TextAttributes extends BaseTextAttributes,
|
||||
> {
|
||||
inlineEditor: InlineEditor<TextAttributes>;
|
||||
raw: CompositionEvent;
|
||||
inlineRange: InlineRange;
|
||||
data: string | null;
|
||||
attributes: TextAttributes;
|
||||
}
|
||||
|
||||
export type HookContext<TextAttributes extends BaseTextAttributes> =
|
||||
| BeforeinputHookCtx<TextAttributes>
|
||||
| CompositionEndHookCtx<TextAttributes>;
|
||||
|
||||
export class InlineHookService<TextAttributes extends BaseTextAttributes> {
|
||||
constructor(
|
||||
readonly editor: InlineEditor<TextAttributes>,
|
||||
readonly hooks: {
|
||||
beforeinput?: (props: BeforeinputHookCtx<TextAttributes>) => void;
|
||||
compositionEnd?: (props: CompositionEndHookCtx<TextAttributes>) => void;
|
||||
} = {}
|
||||
) {}
|
||||
}
|
||||
Reference in New Issue
Block a user