Select text inside editable node in CKEditor

别等时光非礼了梦想. 提交于 2019-12-11 06:34:17

问题


I have a CKEditor widget with some tables with editable fields.

I need to select all the text inside the field when a user clicks it, to make changing the text faster.

For now I was able to come up with this:

editor = CKEDITOR.instances.editor1;
widget = editor.widgets.instances[0]

$.each(widget.editables, function(e) {
    element = $(this.$);
    element.on( 'click', function( ev ) {
        elementId = editor.document.getActive().getId()
        editor.getSelection().selectElement( editor.document.getById(elementId) );
    });
});

Basically, I get all editable elements and bind a click event to them. My problem is only on how to select the text inside the editable element, since currently all I managed to do is select the element itself.

I need to select the text inside the element that I get when calling editor.document.getById(element) .

All other questions on StackOverflow show how to get a selection value, but I could not find anything on how to select only the text inside a node.

来源:https://stackoverflow.com/questions/53437165/select-text-inside-editable-node-in-ckeditor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!