Ticket #7145 (confirmed New Feature)

Opened 4 years ago

Last modified 2 weeks ago

Allow opening links in edit mode

Reported by: damo Owned by:
Priority: Normal Milestone:
Component: General Version: 3.0
Keywords: IBM Support Cc: satya, jamescun, tmonahan, mark@…

Description

When editing a document with links, CKEditor deliberately disables these links to allow proper editing of them. Some users would still like the ability to follow links in edit mode, as in Word.

This feature request proposes adding a keystroke, e.g. CTRL+click to allow the opening of a link target in a new window.

Change History

comment:1 Changed 4 years ago by ComputecWebDev

  • Keywords links, edit mode, click added; IBM removed

We would also appreciate this feature.

A custom hotfix would be to include this in your config-File (jQuery required):

CKEDITOR.on('instanceReady', function(ev) {						
	//catch ctrl+clicks on <a>'s in edit mode to open hrefs in new tab/window
	$('iframe').contents().click(function(e) {		
		if(typeof e.target.href != 'undefined' && e.ctrlKey == true) {			
			window.open(e.target.href, 'new' + e.screenX);
		}
	});	
});

Works with FF3.6.13 and most recent versions of Chrome/Opera/Safari (Windows). In IE8 however, CTRL+click selects one or more paragraphs, not sure where this comes from.

comment:2 Changed 4 years ago by damo

  • Keywords click, IBM added; click removed

Please do not remove the IBM keyword.

comment:3 Changed 3 years ago by wwalc

  • Keywords links, edit mode, click, removed
  • Status changed from new to confirmed
  • Version set to 3.0

#6893 was marked as duplicate, a similar ticket for FCKeditor was mentioned there: http://dev.ckeditor.com/ticket/439 where we introduced two things: Ctrl + Click to follow the link and "Open Link" item in the context menu.

comment:4 Changed 3 years ago by j.swiderski

  • Cc changed from satya,jamescun,tmonahan to satya, jamescun, tmonahan

This issue was duplicated in #8251

comment:5 follow-up: ↓ 6 Changed 3 years ago by j.swiderski

When editing a document with links, CKEditor deliberately disables these links to allow proper editing of them.

I don’t understand why blaming CKEditor? If you open a link inside document with body set to contenteditable="true", no link will be recognized be a browser. Only when using CRTL+right-click all browsers except IE will recognize it and display appropriate native context menu options.

In my opinion this is more about adding something extra to CKEditor to handle something which browsers can't.

As @wwalc and @duncansimey (in 8251) pointed out, in #439 such feature was introduced for FCK.

comment:6 in reply to: ↑ 5 ; follow-up: ↓ 7 Changed 3 years ago by damo

Replying to j.swiderski:

I don’t understand why blaming CKEditor? If you open a link inside document with body set to contenteditable="true", no link will be recognized be a browser.

I wasn't blaming CKEditor, as I think it makes perfect sense to disable links in edit mode. Users would quickly become frustrated if they always activated the link by clicking it to edit it :)

Agreed, it is true that browsers disable links in contenteditable containers, but they don't disable CTRL+Click. CKEditor deliberately disables the click (and ctrl+click) event on anchors, see [5751].

In my opinion this is more about adding something extra to CKEditor to handle something which browsers can't.

Right, we're looking for CKEditor to provide a way to follow a link when the user actually wants to open the target, hence the new feature status.

As @wwalc and @duncansimey (in 8251) pointed out, in #439 such feature was introduced for FCK.

Yes, #439 sounds exactly like my suggested approach (CTRL+Click) and I'd be happy with a context menu option too. One thing that doesn't really work well is the Ctrl+right click, since as you already said, IE doesn't support it.

comment:7 in reply to: ↑ 6 Changed 3 years ago by damo

Replying to damo:

Agreed, it is true that browsers disable links in contenteditable containers, but they don't disable CTRL+Click. CKEditor deliberately disables the click (and ctrl+click) event on anchors, see [5751].

To correct myself, it seems that not all browser allow ctrl+click in contenteditable. I've only seen it work in Firefox...

comment:8 Changed 3 years ago by berend_engelbrecht

Ctrl-click indeed seems to be difficult. However, it is fairly simple to support double click for opening the link. Double click opens the link properties dialog in ckeditor. That is redundant, because the same dialog can also be opened through an option in the right-click menu.

To make double click open the link for an a element in a new window, it is possible to do something like this: Find the double click handler in ckeditor.js. It starts with this code:

X.on('dblclick', function (af) { 
  var ag = af.data.getTarget(), ah = { element: ag, dialog: '' }; 

After the code shown above, insert some code to check whether the element that received the double-click is an a element with a valid http or https link. If so, open the link in a new window. For instance:

if (ag.is('a') && ag.$.href && (ag.$.protocol.indexOf('http') == 0)) { 
  window.open(ag.$.href, '_blank'); af.data.preventDefault(); return; }

Code tested in firefox, chrome, safari, IE7 and IE9.

comment:9 Changed 3 years ago by ibisrobe

This is a real nuisance when editing - when will the "Open Link" item in the context menu be made available in CKeditor please?

comment:10 Changed 3 years ago by markmansour

  • Cc mark@… added

comment:11 Changed 18 months ago by j.swiderski

#1729 was marked as duplicate.

comment:12 Changed 17 months ago by chevas

Even though the browser is the entity that is disabling the links from being clickable, this is a significant problem for the inline editor. If the inline editor is customer / user facing (and it often is), users need to have the ability to single click a link. This feature should be added.

comment:13 Changed 17 months ago by j.swiderski

@chevas I have stumbled upon this ticket #10317. I think this is great idea which will allow to keep editor functionality unchanged (blocking links) and would only change “opening editor rules” with config option (which would allow opening links when editor is inactive).

comment:14 Changed 8 months ago by Zane

Hi all, I found this ticket googling for this exact issue.

I agree that the standard "click to open link" behaviour must be disabled, otherwise it would be an usability hell to work with hyperlinks.

As of CKEditor 4.3.1, the Ctrl+Click works ok on Chrome and Firefox, and this is the right approach for me. Moreover, both display a "Open in a new tab" on the browser-own, non-customized right-click menu. This is golden.

Unfortunately, the issue is that neither work on Internet Explorer: no Ctrl+Click, no right-click, so I can't open my hyperlinks in any mind-sane way.

I tried some jQuery workaround, but IE automatically select my whole paragraph on Ctrl+click: the workaround result is extra-clunky (you have to click, click again, do some voodoo dance and then the link still got opened twice)...

So I think this is something that must be fixed at CKEditor level. What do you think?

comment:15 Changed 5 months ago by j.swiderski

  • Keywords Support added

This issue has been requested on our support channel.

comment:16 Changed 2 months ago by wwalc

Can you please check the following plugin (prototype) and let us know your feedback?

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

It offers an additional item in the context menu and allows clicking links in read-only mode.

comment:17 Changed 5 weeks ago by jbalinski

This is a feature we would like to see as well.

comment:18 Changed 4 weeks ago by Reinmar

cc

comment:19 Changed 3 weeks ago by j.swiderski

@jbalinski and everyone else interested in such plugin. In comment:16 @wwalc has shown you sample plugin that could be used as prototype to create CKEditor plugin you ask about.

@wwals has also asked what you think of such plugin; if it is acceptable or not? Unfortunately despite many comments in this ticket, no one has bothered to actually give us any feedback about this plugin.

Could anyone do that now?

comment:20 Changed 3 weeks ago by jbalinski

The plugin submitted by @wwalc does not work for CTRL+CLICK in IE8, IE9, and IE11 (presumably IE 10 as well but I didn't test it). We implemented something similar without the context menu option so that it would at least work in Chrome and Firefox.

Ultimately the CTRL + Click does not fire the click event in IE for links at all regardless of whether or not the CTRL + Click occurs in a contenteditable element or not. However, the default action that IE takes differs when in a contenteditable element than when not. When a link is in a contenteditable element, the clicked text is selected. When the link is not in a contenteditable element the default action of the browser is to open the link in a new tab/window.

Here are some workarounds that have been posted to the web to overcome this limitation.

  1. Nest a span inside of all links <a href="www.test.com"><span>click here</span></a> http://stackoverflow.com/questions/2694408/ie-7-ctrl-click-opens-a-new-window-how-to-suppress-it
  2. Temporarily set the contenteditable flag on the parent element to false on CTRL keydown, and back to true on CTRL keyup. http://stackoverflow.com/questions/12059211/how-to-make-clickable-anchor-in-contenteditable-div

Both of these approaches are pretty heavy handed. I'd lean towards the first approach if it could be handled natively by CKEditor.

The context menu option provided by @wwalc seems to work well for all browsers. It would be nice if this could be wrapped into the link plugin.

comment:21 Changed 3 weeks ago by berend_engelbrecht

What about the solution to use double-click to follow the link, that I suggested 3 years ago? It is easily implemented with minimal code change (see my comment of August 2011) and works in all desktop browsers, including all IE versions. I think by default the double-click does the default action of the right-click context menu, which is by nature redundant.

We have been using this workaround in production since then and our users are happy with it. Many of them double-click by habit on links anyway, so for that group of people it is intuitive.

Last edited 3 weeks ago by berend_engelbrecht (previous) (diff)

comment:22 Changed 3 weeks ago by Reinmar

Thanks for your feedback.

@berend_engelbrecht: Double-click opens link dialog and I think the plugin should not change that by default. We can make this configurable though. For example config.openLink_byCtrl (defaults to true) and config.openLink_byDoubleClick (defaults to false).

@jbalinski: We'll check that CTRL+click issue on IEs. Thanks for the research on this!

comment:23 Changed 2 weeks ago by j.swiderski

#12133 was marked as duplicate.

#9810 looks related to this one.

Last edited 2 weeks ago by j.swiderski (previous) (diff)
Note: See TracTickets for help on using tickets.
© 2003 – 2012 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy