Liutas
Liutas

Reputation: 5783

How to make simple ckeditor plugin?

I uses the CKEditor. I'd like to make an incredibly simple plugin: when a user selects text and then hits MyPluginIcon, the editor surrounds the text in a mytag tag with a specific class.

So it's just like the Bold or Italic button, but for:

tata

I am far from a JS expert, so I have been looking for a plugin to copy. I cant get data from selected range :(. My code is:

        var cked = $("#" + part_id).ckeditorGet();
        var select = cked.getSelection();
        var ranges = select.getRanges( true );

        if ( ranges.length == 1 ) {
            range = ranges[0];
            var el = CKEDITOR.dom.element.createFromHtml( '<mytag"'+ $("#link").val() + '" >' + range.extractContents() + '</mytag>' );
            cked.insertElement(el);
        }

What did I do wrong?

Thanks!

Upvotes: 0

Views: 882

Answers (1)

Zer001
Zer001

Reputation: 619

There is some way given by CKEDITOR for defining custom style in styes plugin code. And how to use that go to basicstyles plugin. I think you will be benefited.

Upvotes: 1

Related Questions