From 71a71c73e7b9f4bcb77c3ddbbfa720be2df2c63b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Jun 2023 02:20:14 +0200 Subject: [PATCH] FIX #25113 #25173 --- htdocs/theme/eldy/ckeditor/config.js | 20 ++++++++++++++++++++ htdocs/theme/md/ckeditor/config.js | 21 +++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/htdocs/theme/eldy/ckeditor/config.js b/htdocs/theme/eldy/ckeditor/config.js index 6dce53be431..035656bf8dd 100644 --- a/htdocs/theme/eldy/ckeditor/config.js +++ b/htdocs/theme/eldy/ckeditor/config.js @@ -104,3 +104,23 @@ CKEDITOR.editorConfig = function( config ) ['Source'] ]; }; + + +/* Code to make links into CKEditor, in readonly, mode clickable */ +CKEDITOR.on('instanceReady', function(event) { + var editor = event.editor; + if (editor.readOnly) { + var editable = editor.editable(); + editable.attachListener(editable, 'click', function(evt) { + console.log("We click on a link in CKEditor in readonly mode"); + var target = evt.data.getTarget(); + var anchor = target.getAscendant('a', true); + if (anchor) { + var href = anchor.getAttribute('href'); + if (href) { + window.open(href, '_blank'); // Open link in a new tab/window + } + } + }); + } +}); diff --git a/htdocs/theme/md/ckeditor/config.js b/htdocs/theme/md/ckeditor/config.js index c7e10f9a123..32c3000cb7e 100644 --- a/htdocs/theme/md/ckeditor/config.js +++ b/htdocs/theme/md/ckeditor/config.js @@ -104,3 +104,24 @@ CKEDITOR.editorConfig = function( config ) ['Source'] ]; }; + + +/* Code to make links into CKEditor, in readonly, mode clickable */ +CKEDITOR.on('instanceReady', function(event) { + var editor = event.editor; + if (editor.readOnly) { + var editable = editor.editable(); + editable.attachListener(editable, 'click', function(evt) { + console.log("We click on a link in CKEditor in readonly mode"); + var target = evt.data.getTarget(); + var anchor = target.getAscendant('a', true); + if (anchor) { + var href = anchor.getAttribute('href'); + if (href) { + window.open(href, '_blank'); // Open link in a new tab/window + } + } + }); + } +}); +