Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit f4c615c

Browse files
committed
fix(editor): ctrl-clicking a reference link would open it in a new browser tab
1 parent c11c271 commit f4c615c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/ckeditor5/src/plugins/referencelink.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Command, Element, Plugin, toWidget, viewToModelPositionOutsideModelElement, Widget } from "ckeditor5";
1+
import { Command, Element, LinkEditing, Plugin, toWidget, viewToModelPositionOutsideModelElement, Widget } from "ckeditor5";
22

33
export default class ReferenceLink extends Plugin {
44
static get requires() {
@@ -38,7 +38,7 @@ class ReferenceLinkCommand extends Command {
3838

3939
class ReferenceLinkEditing extends Plugin {
4040
static get requires() {
41-
return [ Widget ];
41+
return [ Widget, LinkEditing ];
4242
}
4343

4444
init() {
@@ -52,6 +52,12 @@ class ReferenceLinkEditing extends Plugin {
5252
viewToModelPositionOutsideModelElement( this.editor.model,
5353
viewElement => viewElement.hasClass( 'reference-link' ) )
5454
);
55+
56+
this.editor.plugins.get("LinkEditing")._registerLinkOpener(() => {
57+
// Prevent reference links from being opened in a new browser tab.
58+
// This works even if the link is not a reference link, since it is handled by Trilium.
59+
return true;
60+
});
5561
}
5662

5763
_defineSchema() {

0 commit comments

Comments
 (0)