diff --git a/static/src/js/components/editorComponent.js b/static/src/js/components/editorComponent.js new file mode 100644 index 0000000..706f289 --- /dev/null +++ b/static/src/js/components/editorComponent.js @@ -0,0 +1,16 @@ +define("editorComponent", ["jquery", "avalon", "editor"], function ($, avalon, editor) { + avalon.component("ms:editor", { + $template: "", + editorId: "editorId", + content: "", + placeholder: "", + $editor: {}, + $ready: function (vm, el) { + el.msRetain = true; + vm.$editor = editor($("#" + vm.editorId)); + vm.$watch("content", function (oldValue, newValue) { + vm.$editor.setValue(oldValue); + }) + } + }) +}); diff --git a/static/src/js/config.js b/static/src/js/config.js index 56b4b8a..2e744a5 100644 --- a/static/src/js/config.js +++ b/static/src/js/config.js @@ -26,6 +26,7 @@ var require = { // ------ admin web 组件 ---------- pager: "components/pager", + editorComponent: "components/editorComponent", // ------ 下面写的都不要直接用,而是使用上面的封装版本 ------