fix(editor): disable slash menu in callout (#10656)

This commit is contained in:
Flrande
2025-03-06 11:07:10 +00:00
parent d2b45783ea
commit b85812d8dd
3 changed files with 30 additions and 7 deletions

View File

@@ -88,6 +88,7 @@ import {
export type SlashMenuConfig = {
triggerKeys: string[];
ignoreBlockTypes: string[];
ignoreSelector: string;
items: SlashMenuItem[];
maxHeight: number;
tooltipTimeout: number;
@@ -142,6 +143,7 @@ export type SlashMenuContext = {
export const defaultSlashMenuConfig: SlashMenuConfig = {
triggerKeys: ['/'],
ignoreBlockTypes: ['affine:code'],
ignoreSelector: 'affine-callout',
maxHeight: 344,
tooltipTimeout: 800,
items: [

View File

@@ -126,10 +126,13 @@ export class AffineSlashMenuWidget extends WidgetComponent {
const textSelection = this.host.selection.find(TextSelection);
if (!textSelection) return;
const model = this.host.doc.getBlock(textSelection.blockId)?.model;
if (!model) return;
const block = this.host.view.getBlock(textSelection.blockId);
if (!block) return;
const model = block.model;
if (this.config.ignoreBlockTypes.includes(model.flavour)) return;
if (block.closest(this.config.ignoreSelector)) return;
if (this.config.ignoreBlockTypes.includes(block.flavour)) return;
const inlineRange = inlineEditor.getInlineRange();
if (!inlineRange) return;
@@ -217,7 +220,6 @@ export class AffineSlashMenuWidget extends WidgetComponent {
return;
}
// this.handleEvent('beforeInput', this._onBeforeInput);
this.handleEvent('keyDown', this._onKeyDown);
this.handleEvent('compositionEnd', this._onCompositionEnd);
}