如何从ckeditor中删除特定按钮

How to remove specific button from ckeditor

我在两个文本区域上使用 ckeditor,但问题是我需要有限的选项来显示像 (B,I U) 项目符号格式,我遵循了一个 link 并在 config.js 中进行了更改,但是它反映在所有 ckediotr 上,但我希望更改应反映在该文本区域的特定 ckediotr 上。

link 我关注了:

How to remove buttons from CKeditor 4

1) 我只需要 B,I,U 所以我必须在 js 文件中提到的内容

2) above bulltes style 只需要一个ckeditor

从 ckeditor 的 config.js 文件中删除按钮/项目符号。

CKEDITOR.editorConfig = function (config) {
config.removePlugins = 'save,newpage,flash,about,iframe,language'; 
//The options which remove all styles except (B,I,U)
};



<textarea class="form-control editor_cls" id="htapply" rows="5" required></textarea>

 <textarea class="form-control editor_cls"  id="htapply" rows="5" required></textarea>

在所有文本区域应用 ckeditor 的脚本

<script type="text/javascript">
$('.editor_cls').each(function() { //alert();
  var editor_id = $(this).attr('id');
  CKEDITOR.replace( editor_id, {
      height: 100
    });
});
</script>

首先你的textareas应该有不同的id,你不应该在同一个页面中有两次相同的id。如果您给它们不同的 ID,您将能够轻松区分它们:

<textarea class="form-control editor_cls" id="htapply" rows="5" required></textarea>

<textarea class="form-control editor_cls"  id="htapply2" rows="5" required></textarea>

然后在你的 JS 代码中你可以:

<script type="text/javascript">
$('.editor_cls').each(function() { //alert();
  var editor_id = $(this).attr('id');
  if (editor_id === 'htapply2') {
    // add B, I, U to this editor
    CKEDITOR.replace(editor_id, {
      height: 100,
      plugins: 'bold,italic,underline',
      removePlugins: 'save,newpage,flash,about,iframe,language'
    });
  } else {
    CKEDITOR.replace(editor_id, {
      height: 100,
      removePlugins: 'save,newpage,flash,about,iframe,language'
    });
  }
});
</script>