是否可以将自己的ID设置为CKEditor?

问题描述:

CKEditor 自动生成一个ID,例如 cke_xxx。

是否可以将自己的ID设置为CKEditor实例?

CKEditor automatically generates an id like 'cke_xxx'.
Is it possible to set my own id to CKEditor instance?

Ckeditor将创建实例基于与之相关的DOM元素的名称(通常是id属性),因此您可以基于该名称自定义实例名称。

Ckeditor will create the instance name based on the DOM element it was related to ( usually id attribute ), so you can customize the instance name based on that.

如果您更多是指更改CKEditor创建的实际DOM元素的id,我不认为有一种在创建时进行设置的方法,但是您始终可以在创建后使用类似的东西对其进行更新

If you are more referring to changing the id of the actual DOM element that CKEditor creates, I don't think there is a way to set it on creation, but you can always update it after creation with something like

var editor = CKEDITOR.instances[*instace-name*];
document.getElementById( 'cke_' + editor.element.$.id ).id = newValue

但是我不确定这是否是最佳实践,因为它可能会影响在ckeditor方法中构建的查找 cke _ + id的方法

However I'm not sure if this is the best practice because it may effect built in ckeditor methods that look for "cke_" + id