mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 10:22:55 +08:00
fix(editor): disable slash menu in callout (#10656)
This commit is contained in:
@@ -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: [
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user