mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
fix(editor): ctrl-clicking a reference link would open it in a new browser tab
This commit is contained in:
parent
c11c271aa6
commit
f4c615cfec
@ -1,4 +1,4 @@
|
|||||||
import { Command, Element, Plugin, toWidget, viewToModelPositionOutsideModelElement, Widget } from "ckeditor5";
|
import { Command, Element, LinkEditing, Plugin, toWidget, viewToModelPositionOutsideModelElement, Widget } from "ckeditor5";
|
||||||
|
|
||||||
export default class ReferenceLink extends Plugin {
|
export default class ReferenceLink extends Plugin {
|
||||||
static get requires() {
|
static get requires() {
|
||||||
@ -38,7 +38,7 @@ class ReferenceLinkCommand extends Command {
|
|||||||
|
|
||||||
class ReferenceLinkEditing extends Plugin {
|
class ReferenceLinkEditing extends Plugin {
|
||||||
static get requires() {
|
static get requires() {
|
||||||
return [ Widget ];
|
return [ Widget, LinkEditing ];
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@ -52,6 +52,12 @@ class ReferenceLinkEditing extends Plugin {
|
|||||||
viewToModelPositionOutsideModelElement( this.editor.model,
|
viewToModelPositionOutsideModelElement( this.editor.model,
|
||||||
viewElement => viewElement.hasClass( 'reference-link' ) )
|
viewElement => viewElement.hasClass( 'reference-link' ) )
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.editor.plugins.get("LinkEditing")._registerLinkOpener(() => {
|
||||||
|
// Prevent reference links from being opened in a new browser tab.
|
||||||
|
// This works even if the link is not a reference link, since it is handled by Trilium.
|
||||||
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_defineSchema() {
|
_defineSchema() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user