Fix:修复节点图片加载失败时导出图片也会失败的问题
This commit is contained in:
parent
52600f6fdf
commit
2863c0404a
@ -495,7 +495,7 @@ class MindMap {
|
|||||||
}
|
}
|
||||||
// 移除插件
|
// 移除插件
|
||||||
;[...MindMap.pluginList].forEach(plugin => {
|
;[...MindMap.pluginList].forEach(plugin => {
|
||||||
if (this[plugin.instanceName].beforePluginDestroy) {
|
if (this[plugin.instanceName] && this[plugin.instanceName].beforePluginDestroy) {
|
||||||
this[plugin.instanceName].beforePluginDestroy()
|
this[plugin.instanceName].beforePluginDestroy()
|
||||||
}
|
}
|
||||||
this[plugin.instanceName] = null
|
this[plugin.instanceName] = null
|
||||||
|
|||||||
@ -328,7 +328,8 @@ export const ERROR_TYPES = {
|
|||||||
CUSTOM_HANDLE_CLIPBOARD_TEXT_ERROR: 'custom_handle_clipboard_text_error',
|
CUSTOM_HANDLE_CLIPBOARD_TEXT_ERROR: 'custom_handle_clipboard_text_error',
|
||||||
LOAD_CLIPBOARD_IMAGE_ERROR: 'load_clipboard_image_error',
|
LOAD_CLIPBOARD_IMAGE_ERROR: 'load_clipboard_image_error',
|
||||||
BEFORE_TEXT_EDIT_ERROR: 'before_text_edit_error',
|
BEFORE_TEXT_EDIT_ERROR: 'before_text_edit_error',
|
||||||
EXPORT_ERROR: 'export_error'
|
EXPORT_ERROR: 'export_error',
|
||||||
|
EXPORT_LOAD_IMAGE_ERROR: 'export_load_image_error'
|
||||||
}
|
}
|
||||||
|
|
||||||
// a4纸的宽高
|
// a4纸的宽高
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import {
|
|||||||
import { SVG } from '@svgdotjs/svg.js'
|
import { SVG } from '@svgdotjs/svg.js'
|
||||||
import drawBackgroundImageToCanvas from '../utils/simulateCSSBackgroundInCanvas'
|
import drawBackgroundImageToCanvas from '../utils/simulateCSSBackgroundInCanvas'
|
||||||
import { transformToMarkdown } from '../parse/toMarkdown'
|
import { transformToMarkdown } from '../parse/toMarkdown'
|
||||||
import { a4Size } from '../constants/constant'
|
import { a4Size, ERROR_TYPES } from '../constants/constant'
|
||||||
|
|
||||||
// 导出插件
|
// 导出插件
|
||||||
class Export {
|
class Export {
|
||||||
@ -47,7 +47,8 @@ class Export {
|
|||||||
|
|
||||||
// 获取svg数据
|
// 获取svg数据
|
||||||
async getSvgData() {
|
async getSvgData() {
|
||||||
let { exportPaddingX, exportPaddingY } = this.mindMap.opt
|
let { exportPaddingX, exportPaddingY, errorHandler, resetCss } =
|
||||||
|
this.mindMap.opt
|
||||||
let { svg, svgHTML } = this.mindMap.getSvgData({
|
let { svg, svgHTML } = this.mindMap.getSvgData({
|
||||||
paddingX: exportPaddingX,
|
paddingX: exportPaddingX,
|
||||||
paddingY: exportPaddingY
|
paddingY: exportPaddingY
|
||||||
@ -66,15 +67,17 @@ class Export {
|
|||||||
return item.attr('src')
|
return item.attr('src')
|
||||||
})
|
})
|
||||||
const taskList = [...task1, ...task2]
|
const taskList = [...task1, ...task2]
|
||||||
await Promise.all(taskList)
|
try {
|
||||||
|
await Promise.all(taskList)
|
||||||
|
} catch (error) {
|
||||||
|
errorHandler(ERROR_TYPES.EXPORT_LOAD_IMAGE_ERROR, error)
|
||||||
|
}
|
||||||
// 开启了节点富文本编辑,需要增加一些样式
|
// 开启了节点富文本编辑,需要增加一些样式
|
||||||
let isAddResetCss
|
let isAddResetCss
|
||||||
if (this.mindMap.richText) {
|
if (this.mindMap.richText) {
|
||||||
const foreignObjectList = svg.find('foreignObject')
|
const foreignObjectList = svg.find('foreignObject')
|
||||||
if (foreignObjectList.length > 0) {
|
if (foreignObjectList.length > 0) {
|
||||||
foreignObjectList[0].add(
|
foreignObjectList[0].add(SVG(`<style>${resetCss}</style>`))
|
||||||
SVG(`<style>${this.mindMap.opt.resetCss}</style>`)
|
|
||||||
)
|
|
||||||
isAddResetCss = true
|
isAddResetCss = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user