CKEditor 版本 4.4.6 是否有等效的 get Index()?
Is there an equivalent for getIndex() for CK Editor Version 4.4.6?
我知道 getIndex() 方法是在 4.5 版中引入的,但我们目前无法更新我们的 CKEditor 版本,因为它与企业软件包相关联。有没有办法在 CKEditor 4.5 之前的版本中模仿 getIndex() 函数?
如果您指的是 CKEDITOR.tools.getIndex(), you can just use JavaScript's own Array.prototype.findIndex()(但不适用于 Internet Explorer):
function isBigEnough(element) {
return element >= 15;
}
[12, 5, 8, 130, 44].findIndex(isBigEnough);
// index of 4th element in the Array is returned,
// so this will result in '3'
我知道 getIndex() 方法是在 4.5 版中引入的,但我们目前无法更新我们的 CKEditor 版本,因为它与企业软件包相关联。有没有办法在 CKEditor 4.5 之前的版本中模仿 getIndex() 函数?
如果您指的是 CKEDITOR.tools.getIndex(), you can just use JavaScript's own Array.prototype.findIndex()(但不适用于 Internet Explorer):
function isBigEnough(element) {
return element >= 15;
}
[12, 5, 8, 130, 44].findIndex(isBigEnough);
// index of 4th element in the Array is returned,
// so this will result in '3'