|
@@ -16,7 +16,7 @@ export default {
|
|
|
height: 500,
|
|
height: 500,
|
|
|
theme: "modern",
|
|
theme: "modern",
|
|
|
menubar: false,
|
|
menubar: false,
|
|
|
- toolbar: `styleselect | fontselect | formatselect | fontsizeselect | forecolor backcolor | bold italic underline strikethrough | image media | table | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | preview removeformat hr | paste link | undo redo | fullscreen code`,
|
|
|
|
|
|
|
+ toolbar: `styleselect | fontselect | formatselect | fontsizeselect | forecolor backcolor | bold italic underline strikethrough | link image media | table | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | preview removeformat hr | paste undo redo | fullscreen code`,
|
|
|
plugins: `
|
|
plugins: `
|
|
|
paste
|
|
paste
|
|
|
importcss
|
|
importcss
|
|
@@ -33,6 +33,7 @@ export default {
|
|
|
hr
|
|
hr
|
|
|
preview
|
|
preview
|
|
|
`,
|
|
`,
|
|
|
|
|
+ theme_advanced_buttons1: "ankupload",
|
|
|
// CONFIG
|
|
// CONFIG
|
|
|
forced_root_block: "p",
|
|
forced_root_block: "p",
|
|
|
force_p_newlines: true,
|
|
force_p_newlines: true,
|
|
@@ -171,10 +172,9 @@ export default {
|
|
|
methods: {
|
|
methods: {
|
|
|
setContent(value) {
|
|
setContent(value) {
|
|
|
if (this.Editor != null) {
|
|
if (this.Editor != null) {
|
|
|
- // get(id:String)
|
|
|
|
|
|
|
+ // get(id:String)
|
|
|
window.tinymce.get(`${this.Id}`).setContent(value);
|
|
window.tinymce.get(`${this.Id}`).setContent(value);
|
|
|
- }
|
|
|
|
|
- else{
|
|
|
|
|
|
|
+ } else {
|
|
|
/* eslint-disable-next-line */
|
|
/* eslint-disable-next-line */
|
|
|
console.log("setContent before editor init!");
|
|
console.log("setContent before editor init!");
|
|
|
}
|
|
}
|
|
@@ -182,8 +182,7 @@ export default {
|
|
|
getContent() {
|
|
getContent() {
|
|
|
if (this.Editor != null) {
|
|
if (this.Editor != null) {
|
|
|
return window.tinymce.get(`${this.Id}`).getContent();
|
|
return window.tinymce.get(`${this.Id}`).getContent();
|
|
|
- }
|
|
|
|
|
- else{
|
|
|
|
|
|
|
+ } else {
|
|
|
/* eslint-disable-next-line */
|
|
/* eslint-disable-next-line */
|
|
|
console.log("setContent before editor init!");
|
|
console.log("setContent before editor init!");
|
|
|
return "";
|
|
return "";
|
|
@@ -191,10 +190,10 @@ export default {
|
|
|
},
|
|
},
|
|
|
init() {
|
|
init() {
|
|
|
const self = this;
|
|
const self = this;
|
|
|
|
|
+
|
|
|
this.Editor = window.tinymce.init({
|
|
this.Editor = window.tinymce.init({
|
|
|
// 默认配置
|
|
// 默认配置
|
|
|
...this.DefaultConfig,
|
|
...this.DefaultConfig,
|
|
|
-
|
|
|
|
|
// 图片上传
|
|
// 图片上传
|
|
|
images_upload_handler: function(blobInfo, success, failure) {
|
|
images_upload_handler: function(blobInfo, success, failure) {
|
|
|
if (blobInfo.blob().size > self.maxSize) {
|
|
if (blobInfo.blob().size > self.maxSize) {
|
|
@@ -209,7 +208,7 @@ export default {
|
|
|
} else {
|
|
} else {
|
|
|
failure("图片格式错误");
|
|
failure("图片格式错误");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
function uploadPic() {
|
|
function uploadPic() {
|
|
|
const xhr = new XMLHttpRequest();
|
|
const xhr = new XMLHttpRequest();
|
|
|
const formData = new FormData();
|
|
const formData = new FormData();
|
|
@@ -236,7 +235,46 @@ export default {
|
|
|
xhr.send(formData);
|
|
xhr.send(formData);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ file_picker_types: "file",
|
|
|
|
|
+ file_picker_callback: function(callback, value, meta) {
|
|
|
|
|
+ //文件上传
|
|
|
|
|
+ console.log("文件上传:" + meta.filetype);
|
|
|
|
|
+
|
|
|
|
|
+ var input = document.createElement("input");
|
|
|
|
|
+ input.setAttribute("type", "file");
|
|
|
|
|
|
|
|
|
|
+ input.click();
|
|
|
|
|
+ input.onchange = function() {
|
|
|
|
|
+ var file = this.files[0];
|
|
|
|
|
+
|
|
|
|
|
+ const xhr = new XMLHttpRequest();
|
|
|
|
|
+ const formData = new FormData();
|
|
|
|
|
+ xhr.withCredentials = self.withCredentials;
|
|
|
|
|
+ xhr.open("POST", self.url);
|
|
|
|
|
+ xhr.onload = function() {
|
|
|
|
|
+ if (xhr.status !== 200) {
|
|
|
|
|
+ // 抛出 'on-upload-fail' 钩子
|
|
|
|
|
+ alert("上传失败: " + xhr.status);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const json = JSON.parse(xhr.responseText);
|
|
|
|
|
+
|
|
|
|
|
+ /* eslint-disable-next-line */
|
|
|
|
|
+ console.log(json);
|
|
|
|
|
+
|
|
|
|
|
+ var fileName = file.name;
|
|
|
|
|
+ fileName = fileName.substring(fileName.lastIndexOf("/"));
|
|
|
|
|
+
|
|
|
|
|
+ callback(json.url, { title: fileName,text:fileName});
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ formData.append(self.uploadName, file, file.name);
|
|
|
|
|
+ xhr.send(formData);
|
|
|
|
|
+
|
|
|
|
|
+ callback('',{title:'文件上传中...'});
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
// prop内传入的的config
|
|
// prop内传入的的config
|
|
|
...this.config,
|
|
...this.config,
|
|
|
|
|
|
|
@@ -248,9 +286,9 @@ export default {
|
|
|
editor.on("init", () => {
|
|
editor.on("init", () => {
|
|
|
self.loading = false;
|
|
self.loading = false;
|
|
|
self.$emit("on-ready");
|
|
self.$emit("on-ready");
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/* eslint-disable-next-line */
|
|
/* eslint-disable-next-line */
|
|
|
- if(self.value!=null){
|
|
|
|
|
|
|
+ if (self.value != null) {
|
|
|
editor.setContent(self.value);
|
|
editor.setContent(self.value);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|