Skip to content

Commit

Permalink
修复 WangEditor 默认值问题
Browse files Browse the repository at this point in the history
  • Loading branch information
SmallRuralDog committed Jun 5, 2020
1 parent a7cdf76 commit cac1565
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 152 deletions.
259 changes: 146 additions & 113 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@
"babel-plugin-component": "^1.1.1",
"babel-plugin-import": "^1.13.0",
"cross-env": "^5.1",
"element-ui": "^2.13.0",
"element-ui": "^2.13.2",
"laravel-mix": "^4.1.4",
"lodash": "^4.17.15",
"popper.js": "^1.12",
"popper.js": "^1.16.1",
"resolve-url-loader": "^2.3.1",
"sass": "^1.20.1",
"sass": "^1.26.8",
"sass-loader": "7.*",
"vue": "^2.6.11",
"vue-bus": "^1.2.1",
"vue-clipboard2": "^0.3.1",
"vue-dplayer": "0.0.10",
"vue-happy-scroll": "^2.1.1",
"vue-router": "^3.1.6",
"vue-router": "^3.3.2",
"vue-template-compiler": "^2.6.10",
"vue-waterfall2": "^1.9.6",
"wangeditor": "^3.1.1"
},
"dependencies": {
"@antv/g2plot": "^1.0.2",
"@antv/g2plot": "^1.1.6",
"awe-dnd": "^0.3.4",
"babel-plugin-dynamic-import-webpack": "^1.1.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"nprogress": "^0.2.0",
"url-loader": "^3.0.0",
"vue-nprogress": "^0.1.5",
"vuex": "^3.1.3"
"vuex": "^3.4.0"
}
}
2 changes: 1 addition & 1 deletion public/0.js

Large diffs are not rendered by default.

22 changes: 9 additions & 13 deletions public/3.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ __webpack_require__.r(__webpack_exports__);
//
//
//
//
//
//
//

/* harmony default export */ __webpack_exports__["default"] = ({
props: ["value", "attrs", "form_data", "form_items"],
Expand All @@ -37,7 +41,7 @@ __webpack_require__.r(__webpack_exports__);
mounted: function mounted() {
var _this = this;

this.defaultValue = this._.cloneDeep(this.value);
this.defaultValue = this._.cloneDeep(this.attrs.componentValue);
this.editor = new wangeditor__WEBPACK_IMPORTED_MODULE_0___default.a(this.$refs.toolbar, this.$refs.editor);
this.editor.customConfig.menus = this.attrs.menus;
this.editor.customConfig.zIndex = this.attrs.zIndex;
Expand All @@ -60,24 +64,16 @@ __webpack_require__.r(__webpack_exports__);
this.editor.customConfig.uploadImgHeaders = this.attrs.uploadImgHeaders;
}

this.editor.customConfig.onchange = function (html) {
_this.onChange(html);
};

this.$nextTick(function () {
_this.editor.create();

_this.editor.txt.html(_this.defaultValue);

_this.editor.customConfig.onchange = function (html) {
_this.onChange(html);
};
});
},
watch: {
value: function value(html) {
if (!this.initHtml) {
this.initHtml = true;
this.editor.txt.html(html);
}
}
},
methods: {
onChange: function onChange(value) {
this.$emit("change", value);
Expand Down
2 changes: 1 addition & 1 deletion public/6.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/app.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"/app.js": "/app.js?id=44b53029cb7cbb645934",
"/app.js": "/app.js?id=bac12be78a7b572195b9",
"/manifest.js": "/manifest.js?id=8991394a854ee5cdffc3",
"/vendor.js": "/vendor.js?id=159feaa1cb9cfd111212"
"/vendor.js": "/vendor.js?id=f20525ac5ecb92ff064c"
}
2 changes: 1 addition & 1 deletion public/vendor.js

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions resources/js/components/widgets/Form/WangEditor.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<template>
<div class="wangeditor-main">
<div ref="toolbar" class="toolbar"></div>
<div v-if='attrs.component'>
<component :is="attrs.component.componentName" :attrs='attrs.component' :editor.sync='editor' />
<div v-if="attrs.component">
<component
:is="attrs.component.componentName"
:attrs="attrs.component"
:editor.sync="editor"
/>
</div>
<div ref="editor" :style="attrs.style" :class="attrs.className"></div>
</div>
Expand All @@ -22,8 +26,10 @@ export default {
defaultValue: "",
};
},
mounted() {
this.defaultValue = this._.cloneDeep(this.value);
this.defaultValue = this._.cloneDeep(this.attrs.componentValue);
this.editor = new E(this.$refs.toolbar, this.$refs.editor);
this.editor.customConfig.menus = this.attrs.menus;
Expand All @@ -45,21 +51,15 @@ export default {
this.editor.customConfig.uploadImgHeaders = this.attrs.uploadImgHeaders;
}
this.editor.customConfig.onchange = (html) => {
this.onChange(html);
};
this.$nextTick(() => {
this.editor.create();
this.editor.txt.html(this.defaultValue);
this.editor.customConfig.onchange = (html) => {
this.onChange(html);
};
});
},
watch: {
value(html) {
if (!this.initHtml) {
this.initHtml = true;
this.editor.txt.html(html);
}
},
},
methods: {
onChange(value) {
Expand Down

0 comments on commit cac1565

Please sign in to comment.