|
@@ -31,13 +31,13 @@ export default {
|
|
font_formats: '微软雅黑=Microsoft YaHei,Helvetica Neue,PingFang SC,sans-serif;宋体=simsun,serif',
|
|
font_formats: '微软雅黑=Microsoft YaHei,Helvetica Neue,PingFang SC,sans-serif;宋体=simsun,serif',
|
|
fontsize_formats: '12px 14px 16px 18px 20px 22px 24px 28px 32px 36px 42px 48px',
|
|
fontsize_formats: '12px 14px 16px 18px 20px 22px 24px 28px 32px 36px 42px 48px',
|
|
branding: false,
|
|
branding: false,
|
|
- images_upload_handler: function (blobInfo , success, failure) {
|
|
|
|
|
|
+ images_upload_handler: function (blobInfo, success, failure) {
|
|
var xhr, formData;
|
|
var xhr, formData;
|
|
xhr = new XMLHttpRequest();
|
|
xhr = new XMLHttpRequest();
|
|
xhr.withCredentials = false;
|
|
xhr.withCredentials = false;
|
|
//创建连接
|
|
//创建连接
|
|
xhr.open('POST', url.baseUrl + '/public/uploadFile');
|
|
xhr.open('POST', url.baseUrl + '/public/uploadFile');
|
|
- xhr.onload = function() {
|
|
|
|
|
|
+ xhr.onload = function () {
|
|
var json;
|
|
var json;
|
|
if (xhr.status < 200 || xhr.status >= 300) {
|
|
if (xhr.status < 200 || xhr.status >= 300) {
|
|
failure('HTTP Error: ' + xhr.status);
|
|
failure('HTTP Error: ' + xhr.status);
|
|
@@ -45,18 +45,18 @@ export default {
|
|
}
|
|
}
|
|
json = JSON.parse(xhr.responseText);
|
|
json = JSON.parse(xhr.responseText);
|
|
console.log(json)
|
|
console.log(json)
|
|
- if (json.code!=200) {
|
|
|
|
|
|
+ if (json.code != 200) {
|
|
failure('图片上传失败! ' + json.message);
|
|
failure('图片上传失败! ' + json.message);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
success(json.data.imgUrl);
|
|
success(json.data.imgUrl);
|
|
// Listen for the NodeChange event to set the alt attribute
|
|
// Listen for the NodeChange event to set the alt attribute
|
|
const editor = tinymce.activeEditor;
|
|
const editor = tinymce.activeEditor;
|
|
- editor.on('NodeChange', function(e) {
|
|
|
|
|
|
+ editor.on('NodeChange', function (e) {
|
|
const imgElm = e.element;
|
|
const imgElm = e.element;
|
|
if (imgElm.nodeName === 'IMG' && imgElm.src === json.data.imgUrl) {
|
|
if (imgElm.nodeName === 'IMG' && imgElm.src === json.data.imgUrl) {
|
|
- console.log("Setting alt attribute to:", json.data.oldName || '全国政务信息一体化应用平台'); // Debugging: Check the alt value
|
|
|
|
- editor.dom.setAttrib(imgElm, 'alt',json.data.oldName || '全国政务信息一体化应用平台'); // Use oldName or a default value
|
|
|
|
|
|
+ console.log("Setting alt attribute to:", json.data.oldName || '全国政务信息一体化应用平台'); // Debugging: Check the alt value
|
|
|
|
+ editor.dom.setAttrib(imgElm, 'alt', json.data.oldName || '全国政务信息一体化应用平台'); // Use oldName or a default value
|
|
editor.off('NodeChange'); // Remove the event listener after setting the alt
|
|
editor.off('NodeChange'); // Remove the event listener after setting the alt
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -89,10 +89,13 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
components: {
|
|
components: {
|
|
- 'tiny-editor': editor,
|
|
|
|
|
|
+ 'tiny-editor': editor,
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|
|
|
|
|
|
|
|
+ },
|
|
|
|
+ mounted() {
|
|
|
|
+ this.reinitEditor();
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
// 强制重新初始化编辑器(必要时使用)
|
|
// 强制重新初始化编辑器(必要时使用)
|