我是Dojo的新手,正在嘗試使用dijit.Editor。修改dijit.editor過濾器以允許使用標記
我能夠成功創建我的編輯器,並且每當有人按下按鈕時,我都會在編輯器中添加html。例如,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js" data-dojo-config="async: true,parseOnLoad: true"></script>
<style type="text/css">
/* bring in the claro theme */
@import "//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/claro/claro.css";
</style>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<script>
function onDrag(event) {
event.dataTransfer.setData('Text', 'Some content');
}
</script>
</head>
<body>
<div class="row">
<div style="border:1px solid #000" id="myeditor" class="col-md-6 claro" data-dojo-type="dijit/Editor" data-dojo-props="extraPlugins:['foreColor','hiliteColor','|','createLink','insertImage','fullscreen','viewsource','newpage']">
This is the <strong>default</strong> content.
</div>
<div class="col-md-6" >
<div id="btn" >BLAST</div>
</div>
</div>
<script>
// Include the class
require([
"dijit/Editor",
"dojo/parser",
"dijit/_editor/plugins/ViewSource",
]);
require(["dijit/form/Button", "dijit/registry"], function(Button, dijitRegistry) {
var button = new Button({
label: "Click Me!",
onClick: function(){
var editor = dijitRegistry.byId("myeditor");
editor.execCommand("inserthtml","<div>Here</div>");
}
}, "btn");
button.startup();
});
</script>
</body>
</html>
但是,div標籤被剝離。我需要做什麼才能使用inserthtml命令插入div標籤?