开发者

How to make simple ckeditor plugin?

开发者 https://www.devze.com 2023-03-06 18:11 出处:网络
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.

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() + 开发者_C百科'" >' + range.extractContents() + '</mytag>' );
            cked.insertElement(el);
        }

What did I do wrong?

Thanks!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消