Hello,
I coded a plugin to insert an internal link, that is, a link to a resource on the website.
The plugin works fine, up to the point where it wants to enclose, the text selected by the user, by a link <a > tag in the okListener handler.
Here is my handler:
The first alert is displayed, but not the second one.
The linkUrl, target and selection variables are retrieved fine.
The stumbling block is when I try to enclose the selected text, by an <a> tag.
Has any one tried to do this ?
Thanks !
I coded a plugin to insert an internal link, that is, a link to a resource on the website.
The plugin works fine, up to the point where it wants to enclose, the text selected by the user, by a link <a > tag in the okListener handler.
Here is my handler:
var okListener = function(event) {
var linkUrl = this.getContentElement(linkTabName, 'selectedLink').getValue();
var target = this.getContentElement(linkTabName, 'selectedTarget').getValue();
// Get the element currently selected by the user
var editor = this.getParentEditor();
var selection = editor.getSelection();
var attributes = {href : linkUrl, target : target};
alert("displayed");
selection.getNative().setAttributes(attributes);
alert("not displayed");
parentEditor.dialog.getCurrent().removeListener("ok", okListener);
};
The first alert is displayed, but not the second one.
The linkUrl, target and selection variables are retrieved fine.
The stumbling block is when I try to enclose the selected text, by an <a> tag.
Has any one tried to do this ?
Thanks !

Re: Insert an internal link
I use something similar to this :
var textToInsert = 'This this the contents variable which holds some text you want to insert. A separate function might generate this text first.'; var CKEDITOR = window.parent.CKEDITOR, l = function(ev) { this._.editor.insertHtml('<a href="#" class="link">' + textToInsert + '</a>'); CKEDITOR.dialog.getCurrent().removeListener('ok', l); }; CKEDITOR.dialog.getCurrent().on('ok', l);Does that help?
Thanks,
Zanpakutō
Re: Insert an internal link
http://www.thalasoft.com/engine/modules ... npageId=78
Re: Insert an internal link