@blocksuite/inline
Advanced tools
Comparing version 0.12.0-canary-202402021144-9d70d32 to 0.12.0-canary-202402031458-7bf5564
@@ -99,4 +99,4 @@ import { DisposableGroup, Slot } from '@blocksuite/global/utils'; | ||
get hooks(): { | ||
beforeinput?: ((props: import("./services/hook.js").BeforeinputHookCtx<TextAttributes>) => import("./services/hook.js").BeforeinputHookCtx<TextAttributes> | null) | undefined; | ||
compositionEnd?: ((props: import("./services/hook.js").CompositionEndHookCtx<TextAttributes>) => import("./services/hook.js").CompositionEndHookCtx<TextAttributes> | null) | undefined; | ||
beforeinput?: ((props: import("./services/hook.js").BeforeinputHookCtx<TextAttributes>) => void) | undefined; | ||
compositionEnd?: ((props: import("./services/hook.js").CompositionEndHookCtx<TextAttributes>) => void) | undefined; | ||
}; | ||
@@ -103,0 +103,0 @@ get isComposing(): boolean; |
@@ -144,3 +144,3 @@ import { ZERO_WIDTH_SPACE } from '../consts.js'; | ||
event.preventDefault(); | ||
let ctx = { | ||
const ctx = { | ||
inlineEditor: this.editor, | ||
@@ -152,8 +152,3 @@ raw: event, | ||
}; | ||
const hook = this.editor.hooks.compositionEnd; | ||
if (hook) { | ||
ctx = hook(ctx); | ||
} | ||
if (!ctx) | ||
return; | ||
this.editor.hooks.compositionEnd?.(ctx); | ||
const { inlineRange: newInlineRange, data: newData } = ctx; | ||
@@ -193,3 +188,3 @@ if (newData && newData.length > 0) { | ||
event.preventDefault(); | ||
let ctx = { | ||
const ctx = { | ||
inlineEditor: this.editor, | ||
@@ -201,8 +196,3 @@ raw: event, | ||
}; | ||
const hook = this.editor.hooks.beforeinput; | ||
if (hook) { | ||
ctx = hook(ctx); | ||
} | ||
if (!ctx) | ||
return; | ||
this.editor.hooks.beforeinput?.(ctx); | ||
const { raw: newEvent, data, inlineRange: newInlineRange } = ctx; | ||
@@ -209,0 +199,0 @@ transformInput(newEvent.inputType, data, ctx.attributes, newInlineRange, this.editor); |
@@ -22,10 +22,10 @@ import type { InlineEditor } from '../inline-editor.js'; | ||
readonly hooks: { | ||
beforeinput?: (props: BeforeinputHookCtx<TextAttributes>) => BeforeinputHookCtx<TextAttributes> | null; | ||
compositionEnd?: (props: CompositionEndHookCtx<TextAttributes>) => CompositionEndHookCtx<TextAttributes> | null; | ||
beforeinput?: (props: BeforeinputHookCtx<TextAttributes>) => void; | ||
compositionEnd?: (props: CompositionEndHookCtx<TextAttributes>) => void; | ||
}; | ||
constructor(editor: InlineEditor<TextAttributes>, hooks?: { | ||
beforeinput?: (props: BeforeinputHookCtx<TextAttributes>) => BeforeinputHookCtx<TextAttributes> | null; | ||
compositionEnd?: (props: CompositionEndHookCtx<TextAttributes>) => CompositionEndHookCtx<TextAttributes> | null; | ||
beforeinput?: (props: BeforeinputHookCtx<TextAttributes>) => void; | ||
compositionEnd?: (props: CompositionEndHookCtx<TextAttributes>) => void; | ||
}); | ||
} | ||
//# sourceMappingURL=hook.d.ts.map |
{ | ||
"name": "@blocksuite/inline", | ||
"version": "0.12.0-canary-202402021144-9d70d32", | ||
"version": "0.12.0-canary-202402031458-7bf5564", | ||
"description": "A micro editor.", | ||
@@ -33,3 +33,3 @@ "type": "module", | ||
"zod": "^3.22.4", | ||
"@blocksuite/global": "0.12.0-canary-202402021144-9d70d32" | ||
"@blocksuite/global": "0.12.0-canary-202402031458-7bf5564" | ||
}, | ||
@@ -36,0 +36,0 @@ "scripts": { |
@@ -220,3 +220,3 @@ import { ZERO_WIDTH_SPACE } from '../consts.js'; | ||
let ctx: CompositionEndHookCtx<TextAttributes> | null = { | ||
const ctx: CompositionEndHookCtx<TextAttributes> = { | ||
inlineEditor: this.editor, | ||
@@ -228,7 +228,3 @@ raw: event, | ||
}; | ||
const hook = this.editor.hooks.compositionEnd; | ||
if (hook) { | ||
ctx = hook(ctx); | ||
} | ||
if (!ctx) return; | ||
this.editor.hooks.compositionEnd?.(ctx); | ||
@@ -280,3 +276,3 @@ const { inlineRange: newInlineRange, data: newData } = ctx; | ||
let ctx: BeforeinputHookCtx<TextAttributes> | null = { | ||
const ctx: BeforeinputHookCtx<TextAttributes> = { | ||
inlineEditor: this.editor, | ||
@@ -288,7 +284,3 @@ raw: event, | ||
}; | ||
const hook = this.editor.hooks.beforeinput; | ||
if (hook) { | ||
ctx = hook(ctx); | ||
} | ||
if (!ctx) return; | ||
this.editor.hooks.beforeinput?.(ctx); | ||
@@ -295,0 +287,0 @@ const { raw: newEvent, data, inlineRange: newInlineRange } = ctx; |
@@ -30,10 +30,6 @@ import type { InlineEditor } from '../inline-editor.js'; | ||
public readonly hooks: { | ||
beforeinput?: ( | ||
props: BeforeinputHookCtx<TextAttributes> | ||
) => BeforeinputHookCtx<TextAttributes> | null; | ||
compositionEnd?: ( | ||
props: CompositionEndHookCtx<TextAttributes> | ||
) => CompositionEndHookCtx<TextAttributes> | null; | ||
beforeinput?: (props: BeforeinputHookCtx<TextAttributes>) => void; | ||
compositionEnd?: (props: CompositionEndHookCtx<TextAttributes>) => void; | ||
} = {} | ||
) {} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
310695
5370
+ Added@blocksuite/global@0.12.0-canary-202402031458-7bf5564(transitive)
- Removed@blocksuite/global@0.12.0-canary-202402021144-9d70d32(transitive)
Updated@blocksuite/global@0.12.0-canary-202402031458-7bf5564