wangeditor 编辑器 第三方插件 如何追加 HTML
yu_十三 • 2023-12-05 22:06 • 324 次点击 •
在第三方插件 想 在 wangeditor
编辑器 追加 注意 是追加 需要怎么做呢
wangeditor 编辑器 暴露出了插入 HTML
/**
* 暴露外部插入内容
* @param html {string} https://www.wangeditor.com/v5/API.html#dangerouslyinserthtml
* @param callback {function} 回调函数
* */
dangerouslyInsertHtml(html: string, callback: function)
第三方 如果 想 支持 编辑器插件 这里 以 图片 为例
let md_img = `![](${res.data.gitee.content.download_url})`
let html_img = `<p><img src="${res.data.gitee.content.download_url}" data-href="${res.data.gitee.content.download_url}" /></p>`
// 需要注意的 按照 JS 的执行顺序 官方的 md Editor 为最后兜底
if (typeof tinymce != 'undefined') {
tinymce.activeEditor.insertContent(html_img)
} else if (typeof logcontent_wangeditor != 'undefined') {
dangerouslyInsertHtml(html_img, function(e) {})
} else if (typeof Editor != 'undefined') {
Editor.insertValue(download_url)
}