在vue3 中使用tinymce 粘贴图片的时候粘贴本地图片images_upload_handler这个方法就执行 粘贴网页上的图片images_upload_handler这个就不执行 是为什么 怎么样做才能在粘贴网络图片时也上传到服务器那?
const initOptions = computed(() => {
const {height, options, toolbar, plugins} = props
const publicPath = '/'
return {
selector: `#${unref(tinymceId)}`,
// urlconverter_callback: function (url, node, onSave, name) {
// if (node === 'img' && url.startsWith('blob:')) {
// tinymce.activeEditor && tinymce.activeEditor.uploadImages()
// return url
// }
// if (node === 'img' && !url.startsWith('blob:')) {
// ElMessage.warning('复制网络图片时,外部机器可能无法访问,请下载到本地在复制')
// tinymce.activeEditor && tinymce.activeEditor.uploadImages()
// return "";
// }
// },
images_upload_handler: function (blobInfo, success, failure, progress) {
let blob = blobInfo.blob();
let data = new FormData();
data.append('file', blob);
data.append('newsId', props.newsId);
uploadImg(data).then((res) => {
//并且把返回之后的数据给加载到图片上面
success(axios.defaults.baseURL + res.FILEPATH);
})
},
// height,
height: 800,
toolbar,
// menubar: 'file edit insert view format table',
menubar: false,
// 初始化完成
init_instance_callback: (editor) => {
console.log("初始化完成:", editor, props.newsId)
},
plugins,
language_url: '/ERDSTrafficSystem/resource/tinymce/langS/zh_CN.js',
language: 'zh-Hans',
branding: false,
default_link_target: '_blank',
//黏贴功能
paste_word_import: 'propmt',// 参数可以是propmt, merge, clear,效果自行切换对比
paste_html_import: 'propmt',// propmt, merge, clear
paste_allow_local_images: true,
paste_data_images: true,
paste_as_text: false,
link_title: true,
object_resizing: true,
auto_focus: true,
skin: 'oxide',
skin_url: '/ERDSTrafficSystem/resource/tinymce/skins/ui/oxide',
content_css: '/ERDSTrafficSystem/resource/tinymce/skins/ui/oxide/content.min.css',
resize: false,
...options,
setup: (editor) => {
editorRef.value = editor
editor.on('init', (e) => initSetup(e))
}
}
})