user989729
user989729

Reputation: 56

Referencing Anchors from multiple ckeditors

We display more than one ckeditors on a web page.

The user creates anchors in all the ckeditors.
Currently the Link icon in the toolbar gives the capability to the user to reference anchors within that ckeditor.
The user want to see the anchors created in other Ckeditors too and reference to those anchors, when a web link is clicked

Any tips / solutions on how to implement showing multiple anchors from other ckeditors ?

Thanks
MK

Upvotes: 0

Views: 296

Answers (2)

Oliver
Oliver

Reputation: 57

Thank you for your link to the source code.

Wouldn't it be as good to change the dialogs/links.js, more precisely https://github.com/ckeditor/ckeditor-dev/blob/master/plugins/link/dialogs/link.js#L255-L257

I thought about adding the following code:

anchors = plugin.getEditorAnchors(editor);
 for( var inst in CKEDITOR.instances) {
  if (!CKEDITOR.tools.objectCompare(editor, CKEDITOR.instances[inst])) {
      var a = plugin.getEditorAnchors(CKEDITOR.instances[inst]);
       while(a.length) {
          anchors.push( a.shift() );
       }
   }
}

this.getElement()[ anchors && anchors.length ? 'show' : 'hide' ]();

Upvotes: 0

Reinmar
Reinmar

Reputation: 22023

To change the algorithm which finds anchors you have to override this method: CKEDITOR.plugins.link#getEditorAnchors.

Here is its source: https://github.com/ckeditor/ckeditor-dev/blob/master/plugins/link/plugin.js#L335-L370

You can do this at any time - this method is called dynamically when link dialog is opened.

PS. It will work since CKEditor 4.3.3. There's no easy solution for previous versions.

Upvotes: 1

Related Questions