javascript - 如何从ckeditor中删除特定按钮
问题描述
我在两个 textarea 上使用 ckeditor,但问题是我需要有限的选项来显示(B,IU)项目符号格式,我按照一个链接并在 config.js 中进行了更改,但它反映了所有 ckediotr,但我希望更改应该反映该文本区域的特定 ckediotr。
我关注的链接:
1) 我只需要 B,I,U 所以我必须在 js ile 中提到
2)以上bultes风格只需要一个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>
在所有 textarea 上应用 ckeditor 的脚本
<script type="text/javascript">
$('.editor_cls').each(function() { //alert();
var editor_id = $(this).attr('id');
CKEDITOR.replace( editor_id, {
height: 100
});
});
</script>
解决方案
首先,你的文本区域应该有不同的 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>
推荐阅读
- php - 常量值未在 laravel 视图中打印
- c++ - 使用 opengl 和 SOIL2 从纹理采样给出黑色模型
- python - 如何输入多个键,输出应返回多个值。请检查脚本和我的评论
- reactjs - 反应检查组件是否从 TabView 获得焦点
- ibm-cloud - 如何提取 IBM Watson 在物体检测模型中检测到的图像?
- bash - 如何使列表中的每个项目在 Bash 的同一行上重复
- scala - 从 hdfs 文件创建 neo4j 图
- xamarin - Xamarin Forms - 从 WebView 访问 CookieStore
- docker - Kubernetes 私有注册表证书由未知机构签名
- jquery - 使用jquery获取最近项目的值