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 + } + } + }); + } +}); +