From 2863c0404a3aa1a7dd1f8b46cc5940203e862026 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com>
Date: Tue, 12 Dec 2023 09:17:22 +0800
Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E8=8A=82?=
=?UTF-8?q?=E7=82=B9=E5=9B=BE=E7=89=87=E5=8A=A0=E8=BD=BD=E5=A4=B1=E8=B4=A5?=
=?UTF-8?q?=E6=97=B6=E5=AF=BC=E5=87=BA=E5=9B=BE=E7=89=87=E4=B9=9F=E4=BC=9A?=
=?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
simple-mind-map/index.js | 2 +-
simple-mind-map/src/constants/constant.js | 3 ++-
simple-mind-map/src/plugins/Export.js | 15 +++++++++------
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/simple-mind-map/index.js b/simple-mind-map/index.js
index 27c182e2..91f3b9cd 100644
--- a/simple-mind-map/index.js
+++ b/simple-mind-map/index.js
@@ -495,7 +495,7 @@ class MindMap {
}
// 移除插件
;[...MindMap.pluginList].forEach(plugin => {
- if (this[plugin.instanceName].beforePluginDestroy) {
+ if (this[plugin.instanceName] && this[plugin.instanceName].beforePluginDestroy) {
this[plugin.instanceName].beforePluginDestroy()
}
this[plugin.instanceName] = null
diff --git a/simple-mind-map/src/constants/constant.js b/simple-mind-map/src/constants/constant.js
index f0046027..a4e8abf5 100644
--- a/simple-mind-map/src/constants/constant.js
+++ b/simple-mind-map/src/constants/constant.js
@@ -328,7 +328,8 @@ export const ERROR_TYPES = {
CUSTOM_HANDLE_CLIPBOARD_TEXT_ERROR: 'custom_handle_clipboard_text_error',
LOAD_CLIPBOARD_IMAGE_ERROR: 'load_clipboard_image_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纸的宽高
diff --git a/simple-mind-map/src/plugins/Export.js b/simple-mind-map/src/plugins/Export.js
index 32a89fdf..31d2d3bc 100644
--- a/simple-mind-map/src/plugins/Export.js
+++ b/simple-mind-map/src/plugins/Export.js
@@ -9,7 +9,7 @@ import {
import { SVG } from '@svgdotjs/svg.js'
import drawBackgroundImageToCanvas from '../utils/simulateCSSBackgroundInCanvas'
import { transformToMarkdown } from '../parse/toMarkdown'
-import { a4Size } from '../constants/constant'
+import { a4Size, ERROR_TYPES } from '../constants/constant'
// 导出插件
class Export {
@@ -47,7 +47,8 @@ class Export {
// 获取svg数据
async getSvgData() {
- let { exportPaddingX, exportPaddingY } = this.mindMap.opt
+ let { exportPaddingX, exportPaddingY, errorHandler, resetCss } =
+ this.mindMap.opt
let { svg, svgHTML } = this.mindMap.getSvgData({
paddingX: exportPaddingX,
paddingY: exportPaddingY
@@ -66,15 +67,17 @@ class Export {
return item.attr('src')
})
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
if (this.mindMap.richText) {
const foreignObjectList = svg.find('foreignObject')
if (foreignObjectList.length > 0) {
- foreignObjectList[0].add(
- SVG(``)
- )
+ foreignObjectList[0].add(SVG(``))
isAddResetCss = true
}
}