CKEditor Inline selection wrapping

廉价感情. 提交于 2019-12-02 10:56:26

I used this as solution. It is indeed possible to set attributes and element type. this wasn't defined in the api. I found this in the CKEditor 3.0 api (older version)

var style = new CKEDITOR.style({attributes: {name:"changed"}});
editor.applyStyle(style);

The latest Solution for your Problem.

Get Selected Text:

editor.getSelection().getSelectedText();

Put tags and attributes

editor.applyStyle(new CKEDITOR.style({
        element : 'span', 
        attributes : {'class':'YourClass','data-Otherattr':'otherattrvalue'}, 
        style : {'background-color':'gray'} 
    });
);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!