|
@@ -7,24 +7,18 @@
|
|
|
:mode="mode"
|
|
|
/>
|
|
|
<Editor
|
|
|
- style="height: 500px; overflow-y: hidden;"
|
|
|
+ style="height: 500px; overflow-y: hidden"
|
|
|
v-model="html"
|
|
|
:defaultConfig="editorConfig"
|
|
|
:mode="mode"
|
|
|
@onCreated="onEditorCreated"
|
|
|
/>
|
|
|
<div class="bottom-bar">
|
|
|
- <button
|
|
|
- class="ui-button"
|
|
|
- @click="onClickCancel"
|
|
|
- >
|
|
|
- {{$i18n.t('common.cancel')}}
|
|
|
+ <button class="ui-button" @click="onClickCancel">
|
|
|
+ {{ $i18n.t("common.cancel") }}
|
|
|
</button>
|
|
|
- <button
|
|
|
- class="ui-button submit"
|
|
|
- @click="onClickOk"
|
|
|
- >
|
|
|
- {{$i18n.t('common.ok')}}
|
|
|
+ <button class="ui-button submit" @click="onClickOk">
|
|
|
+ {{ $i18n.t("common.ok") }}
|
|
|
</button>
|
|
|
</div>
|
|
|
|
|
@@ -53,8 +47,10 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import Vue from 'vue'
|
|
|
-import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
|
|
|
+import Vue from "vue";
|
|
|
+import { Editor, Toolbar } from "@wangeditor/editor-for-vue";
|
|
|
+import { i18nChangeLanguage, i18nGetResources } from "@wangeditor/editor";
|
|
|
+import browser from "@/utils/browser";
|
|
|
import MaterialSelector from "@/components/materialSelector.vue";
|
|
|
|
|
|
export default Vue.extend({
|
|
@@ -66,71 +62,85 @@ export default Vue.extend({
|
|
|
props: {
|
|
|
initialHtml: {
|
|
|
type: String,
|
|
|
- defaut: '',
|
|
|
- }
|
|
|
+ default: "",
|
|
|
+ },
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
editor: null,
|
|
|
html: this.initialHtml,
|
|
|
- toolbarConfig: {
|
|
|
- },
|
|
|
+ toolbarConfig: {},
|
|
|
editorConfig: {
|
|
|
- placeholder: 'fdf',
|
|
|
+ placeholder: "",
|
|
|
MENU_CONF: {
|
|
|
uploadImage: {
|
|
|
customBrowseAndUpload: (insertFn) => {
|
|
|
- this.isShowImageSelectionWindow = true
|
|
|
- this.insertFn = insertFn
|
|
|
- }
|
|
|
+ this.isShowImageSelectionWindow = true;
|
|
|
+ this.insertFn = insertFn;
|
|
|
+ },
|
|
|
},
|
|
|
uploadVideo: {
|
|
|
customBrowseAndUpload: (insertFn) => {
|
|
|
- this.isShowVideoSelectionWindow = true
|
|
|
- this.insertFn = insertFn
|
|
|
- }
|
|
|
+ this.isShowVideoSelectionWindow = true;
|
|
|
+ this.insertFn = insertFn;
|
|
|
+ },
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
- mode: 'default', // or 'simple',
|
|
|
+ mode: "default", // or 'simple',
|
|
|
|
|
|
isShowImageSelectionWindow: false,
|
|
|
isShowVideoSelectionWindow: false,
|
|
|
insertFn: null,
|
|
|
- }
|
|
|
+ };
|
|
|
},
|
|
|
methods: {
|
|
|
onEditorCreated(editor) {
|
|
|
- this.editor = Object.seal(editor) // 一定要用 Object.seal() ,否则会报错
|
|
|
+ this.editor = Object.seal(editor); // 一定要用 Object.seal() ,否则会报错
|
|
|
+ console.log("this.editor", this.editor);
|
|
|
+ let lang = browser.urlQueryValue("lang");
|
|
|
+
|
|
|
+ if (lang === "en") {
|
|
|
+ i18nChangeLanguage("en");
|
|
|
+ }
|
|
|
+ if (lang === "zh") {
|
|
|
+ i18nChangeLanguage("zh-CN");
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
onClickOk() {
|
|
|
- this.$emit('ok', this.html)
|
|
|
+ this.$emit("ok", this.html);
|
|
|
},
|
|
|
onClickCancel() {
|
|
|
- this.$emit('cancel')
|
|
|
+ this.$emit("cancel");
|
|
|
},
|
|
|
onSubmitFromImageMaterialSelector(selected) {
|
|
|
- this.isShowImageSelectionWindow = false
|
|
|
+ this.isShowImageSelectionWindow = false;
|
|
|
for (const selectedItem of selected) {
|
|
|
- this.insertFn(selectedItem.icon, `[${this.$i18n.t('gather.image')}: ${selectedItem.name}]`)
|
|
|
+ this.insertFn(
|
|
|
+ selectedItem.icon,
|
|
|
+ `[${this.$i18n.t("gather.image")}: ${selectedItem.name}]`
|
|
|
+ );
|
|
|
}
|
|
|
},
|
|
|
onSubmitFromVideoMaterialSelector(selected) {
|
|
|
- this.isShowVideoSelectionWindow = false
|
|
|
+ this.isShowVideoSelectionWindow = false;
|
|
|
for (const selectedItem of selected) {
|
|
|
console.log(selectedItem);
|
|
|
- this.insertFn(selectedItem.ossPath, selectedItem.ossPath + this.$videoImgOriginalSize)
|
|
|
+ this.insertFn(
|
|
|
+ selectedItem.ossPath,
|
|
|
+ selectedItem.ossPath + this.$videoImgOriginalSize
|
|
|
+ );
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
- mounted() {
|
|
|
- },
|
|
|
+ mounted() {},
|
|
|
beforeDestroy() {
|
|
|
- const editor = this.editor
|
|
|
- if (editor == null) return
|
|
|
- editor.destroy() // 组件销毁时,及时销毁编辑器
|
|
|
- }
|
|
|
-})
|
|
|
+ const editor = this.editor;
|
|
|
+ if (editor == null) return;
|
|
|
+ editor.destroy(); // 组件销毁时,及时销毁编辑器
|
|
|
+ },
|
|
|
+});
|
|
|
</script>
|
|
|
|
|
|
<style src="@wangeditor/editor/dist/css/style.css"></style>
|
|
@@ -142,7 +152,7 @@ export default Vue.extend({
|
|
|
overflow: hidden;
|
|
|
> .bottom-bar {
|
|
|
padding: 10px;
|
|
|
- background-color: rgba(0,0,0,0.8);
|
|
|
+ background-color: rgba(0, 0, 0, 0.8);
|
|
|
border-top: 1px solid #ccc;
|
|
|
display: flex;
|
|
|
justify-content: flex-end;
|
|
@@ -155,11 +165,12 @@ export default Vue.extend({
|
|
|
</style>
|
|
|
<style>
|
|
|
:root {
|
|
|
- --w-e-textarea-bg-color: #333;
|
|
|
- --w-e-textarea-color: #fff;
|
|
|
- --w-e-toolbar-active-bg-color:#666;
|
|
|
- --w-e-toolbar-color:#fff;
|
|
|
- --w-e-toolbar-bg-color:rgba(0.0.0,0.9);
|
|
|
- --w-e-modal-button-bg-color:rgba(0.0.0,0.5);
|
|
|
+ --w-e-textarea-bg-color: #333;
|
|
|
+ --w-e-textarea-color: #fff;
|
|
|
+ --w-e-toolbar-active-bg-color: #666;
|
|
|
+ --w-e-toolbar-color: #fff;
|
|
|
+ --w-e-toolbar-bg-color: rgba(0, 0, 0, 0.9);
|
|
|
+ --w-e-toolbar-active-color: #fff;
|
|
|
+ --w-e-modal-button-bg-color: rgba(0, 0.5);
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|