mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
feat(editor): hide balloon toolbar when in code block
This commit is contained in:
parent
be718ce4e0
commit
995de2b740
@ -1,4 +1,4 @@
|
|||||||
import { CodeBlock, Plugin, ViewDocumentFragment, WidgetToolbarRepository, type ViewNode } from "ckeditor5";
|
import { BalloonToolbarShowEvent, CodeBlock, Plugin, ViewDocumentFragment, WidgetToolbarRepository, type ViewNode } from "ckeditor5";
|
||||||
import CodeBlockLanguageDropdown from "./code_block_language_dropdown";
|
import CodeBlockLanguageDropdown from "./code_block_language_dropdown";
|
||||||
import CopyToClipboardButton from "./copy_to_clipboard_button";
|
import CopyToClipboardButton from "./copy_to_clipboard_button";
|
||||||
|
|
||||||
@ -37,6 +37,18 @@ export default class CodeBlockToolbar extends Plugin {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Hide balloon toolbar when in a code block
|
||||||
|
if (editor.plugins.has("BalloonToolbar")) {
|
||||||
|
editor.listenTo(editor.plugins.get('BalloonToolbar'), 'show', (evt) => {
|
||||||
|
const firstPosition = editor.model.document.selection.getFirstPosition();
|
||||||
|
const isInCodeBlock = firstPosition?.findAncestor('codeBlock');
|
||||||
|
|
||||||
|
if (isInCodeBlock) {
|
||||||
|
evt.stop(); // Prevent the balloon toolbar from showing
|
||||||
|
}
|
||||||
|
}, { priority: 'high' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user