在显示事件后替换 CKEditor 对话框中的元素
Replace Element in CKEditor Dialog after onShow Event
我尝试为 CKEditor 编写一个自己的插件。目标是单击工具栏中打开对话框的按钮。在对话框中有一个textArea
元素,该元素应替换为 CodeMirror 实例。
我走了这么远,以至于对话框打开,我可以抓住textArea
并替换它。但它看起来很糟糕,没有任何功能。此外,控制台中没有错误。
我不知道为什么这不起作用。
点击我的插件按钮时开始plugin.js
CKEDITOR.plugins.add( 'abbr', {
icons: 'abbr',
init: function( editor ) {
editor.addCommand( 'abbr',new CKEDITOR.dialogCommand( 'abbrDialog' ) );
// Create a toolbar button that executes the plugin command.
editor.ui.addButton( 'Abbr', {
label: 'Insert SourceCode',
command: 'abbr',
toolbar: 'insert'
} );
CKEDITOR.dialog.add( 'abbrDialog', function ( editor ) {
return {
title : 'Insert SourceCode',
minWidth : 700,
minHeight : 300,
contents : [{
id : 'tab1',
label : 'label1',
elements :
[{
type : 'html',
html: '<textarea id="codeEditor"></textarea>',
id : 'codeEditor',
label : 'CodeEditor',
}]
}],
onShow : replacaByCodeMirror,
onOk : saveActionFunc
};
});
}
});
function replacaByCodeMirror() {
var codeEditor = CodeMirror.fromTextArea(document.getElementById("codeEditor"), {
mode : "mixedMode",
theme : "default"
});
}
索引.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<script src="../ckeditor.js"></script>
<script src="../plugins/codemirror/js/codemirror.js"></script></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css" type="text/css"/>
<link rel="stylesheet" href="../plugins/codemirror/css/codemirror.css"/>
<link rel="stylesheet" href="../plugins/codemirror/css/myStyle.css">
</head>
<body>
<form>
<textarea name="editor1" id="editor1" rows="10" cols="80">
StartWort
</textarea>
<script>
var editor = CKEDITOR.replace( 'editor1' );
</script>
</form>
</body>
</html>
屏幕截图:对话框屏幕截图
您不能在 ckeditor 窗口(或 ckeditor 对话框中)运行 JavaScript 代码。解决方法是在对话框中使用 iframe(您必须添加一个 iframedialog 插件)。
这正是我需要的信息。多谢!我会给你一票,但我只有 2 个代表。
不幸的是,网上几乎没有好的例子。这对我有帮助:CKForum
相关文章:
- 单击函数生成的 jQuery 对话框中的元素
- Jquery具有iframe和生成的元素的简单模态对话框
- jQuery对话框,关闭时在对话框中隐藏一个元素
- 循环遍历javascript数组,并在JQuery对话框中显示每个元素
- 如何获取离子对话框中动态加载的元素的元素高度
- 专注于第一个表单元素,无论它是什么.j查询对话框
- 单击元素后无法显示角度对话框
- 在显示事件后替换 CKEditor 对话框中的元素
- “Jquery ”对话框在表单元素中不会保持打开状态
- 使用 JQuery 在动态 JQuery UI 对话框中为动态创建的表单元素设置值
- 如何使用鼠标移动<对话框>元素
- onsen ui:访问ons对话框's父页中的DOM元素
- 在jQuery UI对话框中设置元素样式
- 在jQueryUI对话框中显示和格式化数组元素
- ckeditor-如何将css类添加到对话框中的输入元素中
- 通过Javascript函数打开和关闭对话框元素
- jQuery UI对话框:对话框元素从DOM中消失
- 通过单击背景来消除html对话框元素
- 使用tab键在Safari和Chrome中不工作的对话框元素内循环
- 添加事件处理程序到对话框元素