Opened 10 years ago

Last modified 8 years ago

#12133 confirmed Bug

Links not opening when CKEditor is in readOnly mode

Reported by: Tsvetelin Novkirishki Owned by:
Priority: Normal Milestone:
Component: Core : Read-only Version:
Keywords: Cc:

Description

Descriptive summary: When editor is initialized in readOnly mode, there is no need to preventDefault() on links, because he doesn't need caret positioning.

Steps to reproduce:

  1. Open readOnly editor demo
  2. Enable readOnly mode
  3. Click on the link

Browser and OS: Chrome and Firefox under both Windows and Linux

Change History (16)

comment:1 Changed 10 years ago by Wiktor Walc

Is it possible that this plugin does what you need?

https://github.com/mlewand/ckeditor-plugin-openlink

comment:2 Changed 10 years ago by Tsvetelin Novkirishki

Unfortunately, this plugin requires the user to right click to open the link, which is a problem when you don't have contextmenu plugin enabled. And the user might not figure it out to right click. I assume you prevent the default browser action (opening the link) so user can place the caret inside of the link and this way to be able to change the text. When in read only, user won't be allowed to change the text, so no need to prevent the default. In our case, we use CKEditor to display a document (created with CKEditor) in read only mode, because there is a rendering logic which CKEditor knows best (downcasting and upcasting) and we don't want to write and support another (separate) logic to render CKEditor template outside of CKEditor. Biggest problem with initializing CKEditor in readOnly=true is links - user cannot open the links inside of the page and to him, there shouldn't be any reason why not (visually it's a page, not an editor)

comment:3 Changed 10 years ago by Wiktor Walc

The mentioned plugin makes links clickable in read-only mode, there is no need to use the context menu. A single click on a link is enough to open it in new window.

Is it possible that you did not check it in read-only mode?

comment:4 Changed 10 years ago by Tsvetelin Novkirishki

Sorry, I didn't check it, because the description mentioned only context menu and I thought you didn't understand me. Now when I tried it, it works, but it loads the contextmenu plugin, which blocks the normal context menu, which means the user cannot copy with right click, because the clipboard plugin is not loaded. Is there any other way of enabling the click on a link? That's too many plugins for such a simple thing, which seems to me it should be enabled by default. Thank you.

comment:5 Changed 10 years ago by Jakub Ś

That's too many plugins for such a simple thing, which seems to me it should be enabled by default.

If this was enabled by default then clicking link in read-only mode would cause new page being loaded in content area. In such case data enter by user would be lost.
For opening links there should be either plugin/code extension that opens each link in new window/tab (target _blank would have to be assigned by editor) or plugin that remembers history and allows loading new pages with back/forward buttons. As you can see this is simple thing but unfortunately it requires some amount of work when you think about all possibilities where it might break.

NOTE: There seems to be related issue to this topic - #9810.

comment:6 Changed 10 years ago by Piotrek Koszuliński

The ckeditor-openlink plugin does not need to require contextmenu plugin. It makes sense to check if context menu is loaded and then adding option inside it, rather than assuming it exists.

comment:7 Changed 10 years ago by Jakub Ś

Resolution: duplicate
Status: newclosed
Version: 4.4.3

DUP of #7145.

comment:8 Changed 9 years ago by steph123

This is not a DUP of #7145, please kindly reopen this ticket.

#7145 deals with clicking on a link when read-only is off. Solutions for this can be allowing CTRL+click, or adding an item in the context menu, or whatever.

The present ticket deals with clicking on a link when read-only is on. This is a different subject. When read-only is on, there should be an option to enable links to behave like in a normal (non-editable) page.

The fact that a prototype plugin (​https://github.com/mlewand/ckeditor-plugin-openlink) tries to address both issues does not make them the same.

comment:9 Changed 9 years ago by Piotrek Koszuliński

Resolution: duplicate
Status: closedreopened

I agree. These are separate tickets.

comment:10 Changed 9 years ago by Piotrek Koszuliński

Status: reopenedconfirmed
Type: BugNew Feature

comment:11 Changed 9 years ago by steph123

To understand this feature request, do the following:

  1. Go to http://ckeditor.com/demo#inline
  2. Turn all editable regions to read only mode by pasting the following code in the console:
    for(var n in CKEDITOR.instances)
       CKEDITOR.instances[n].setReadOnly(true);
    
  3. Now click on any link in the editable regions: nothing happens! This is very puzzling for users.

comment:12 Changed 9 years ago by Piotrek Koszuliński

Type: New FeatureBug

I think that this ticket could be split into two. One is new feature - ability to open links in read only mode. Second is a bug - editor loses focus when links are clicked (see case in comment:11).

Version 0, edited 9 years ago by Piotrek Koszuliński (next)

comment:13 Changed 9 years ago by steph123

In terms of feature, the plugin proposed by @wwalc (​​https://github.com/mlewand/ckeditor-plugin-openlink) is exactly what is needed (it also solves #7145). I think it should be made part of ckeditor.

comment:14 Changed 9 years ago by Piotrek Koszuliński

I replied there too: http://dev.ckeditor.com/ticket/7145#comment:27

We should keep the discussion in one of these threads ;).

comment:15 Changed 8 years ago by gusl8903

CKEDITOR.on('instanceReady', function (ev) {

$('iframe').contents().click(function (e) {

var url;

url = e.target.href;

if (url !== undefined && url !== "") {

window.open(url);

}

});

});

Last edited 8 years ago by gusl8903 (previous) (diff)

comment:16 Changed 8 years ago by lilvenus

gusl8903......brilliant i could kiss you, have been searching all day for a resolution to this. thank you soooo much!!!

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy