Ticket #7145 (confirmed New Feature)

Opened 3 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 3 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 3 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 2 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 2 years ago by markmansour

  • Cc mark@… added

comment:11 Changed 13 months ago by j.swiderski

#1729 was marked as duplicate.

comment:12 Changed 13 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 12 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 3 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 2 weeks ago by j.swiderski

  • Keywords Support added

This issue has been requested on our support channel.

Note: See TracTickets for help on using tickets.
© 2003 – 2012 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy