From 19d47884892fc1456da9d75eb2283c27471c906b Mon Sep 17 00:00:00 2001 From: wanghao1993 Date: Sun, 17 Sep 2023 18:08:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=94=9F=E6=88=90dts=E5=A3=B0=E6=98=8E=E6=96=87=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E6=89=A7=E8=A1=8C=E4=BA=86=E4=B8=80=E4=B8=8Bformat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/full.js | 5 +- simple-mind-map/index.d.ts | 14 -- simple-mind-map/index.js | 9 +- simple-mind-map/package.json | 5 +- simple-mind-map/scripts/walkJsFiles.js | 6 +- simple-mind-map/src/constants/constant.js | 20 +-- simple-mind-map/src/core/command/Command.js | 22 ++- .../src/core/command/KeyCommand.js | 11 +- simple-mind-map/src/core/event/Event.js | 2 +- simple-mind-map/src/core/render/node/Node.js | 20 ++- simple-mind-map/src/core/render/node/Style.js | 9 +- .../src/core/render/node/nodeExpandBtn.js | 3 +- .../core/render/node/nodeGeneralization.js | 30 ++-- simple-mind-map/src/core/view/View.js | 5 +- .../src/layouts/CatalogOrganization.js | 21 ++- simple-mind-map/src/layouts/Fishbone.js | 3 +- simple-mind-map/src/layouts/FishboneBottom.js | 7 +- simple-mind-map/src/layouts/FishboneTop.js | 9 +- .../src/layouts/LogicalStructure.js | 13 +- simple-mind-map/src/layouts/MindMap.js | 15 +- .../src/layouts/OrganizationStructure.js | 9 +- simple-mind-map/src/layouts/fishboneUtils.js | 53 ++++-- simple-mind-map/src/parse/toMarkdown.js | 2 +- simple-mind-map/src/parse/xmind.js | 2 +- .../src/plugins/AssociativeLine.js | 2 +- simple-mind-map/src/plugins/Export.js | 29 +-- simple-mind-map/src/plugins/ExportPDF.js | 9 +- .../src/plugins/KeyboardNavigation.js | 2 +- simple-mind-map/src/plugins/MiniMap.js | 10 +- simple-mind-map/src/plugins/NodeImgAdjust.js | 2 +- simple-mind-map/src/plugins/RichText.js | 6 +- simple-mind-map/src/plugins/Search.js | 7 +- simple-mind-map/src/plugins/Watermark.js | 7 +- .../associativeLine/associativeLineText.js | 6 +- simple-mind-map/src/themes/default.js | 12 +- simple-mind-map/src/utils/Lru.js | 59 +++---- simple-mind-map/src/utils/index.js | 6 +- .../utils/simulateCSSBackgroundInCanvas.js | 2 +- simple-mind-map/types/index.d.ts | 166 ++++++++++++++++++ .../types/src/constants/constant.d.ts | 113 ++++++++++++ .../types/src/constants/defaultOptions.d.ts | 82 +++++++++ .../types/src/core/command/Command.d.ts | 19 ++ .../types/src/core/command/KeyCommand.d.ts | 26 +++ .../types/src/core/command/keyMap.d.ts | 42 +++++ .../types/src/core/event/Event.d.ts | 35 ++++ .../types/src/core/render/Render.d.ts | 107 +++++++++++ .../types/src/core/render/TextEdit.d.ts | 29 +++ .../types/src/core/render/node/Node.d.ts | 116 ++++++++++++ .../types/src/core/render/node/Shape.d.ts | 28 +++ .../types/src/core/render/node/Style.d.ts | 43 +++++ .../core/render/node/nodeCommandWraps.d.ts | 23 +++ .../core/render/node/nodeCreateContents.d.ts | 45 +++++ .../src/core/render/node/nodeExpandBtn.d.ts | 34 ++++ .../node/nodeExpandBtnPlaceholderRect.d.ts | 18 ++ .../core/render/node/nodeGeneralization.d.ts | 32 ++++ simple-mind-map/types/src/core/view/View.d.ts | 36 ++++ simple-mind-map/types/src/layouts/Base.d.ts | 46 +++++ .../src/layouts/CatalogOrganization.d.ts | 21 +++ .../types/src/layouts/Fishbone.d.ts | 25 +++ .../types/src/layouts/LogicalStructure.d.ts | 23 +++ .../types/src/layouts/MindMap.d.ts | 23 +++ .../src/layouts/OrganizationStructure.d.ts | 22 +++ .../types/src/layouts/Timeline.d.ts | 23 +++ .../types/src/layouts/VerticalTimeline.d.ts | 25 +++ .../types/src/layouts/fishboneUtils.d.ts | 137 +++++++++++++++ simple-mind-map/types/src/svg/btns.d.ts | 11 ++ simple-mind-map/types/src/svg/icons.d.ts | 18 ++ simple-mind-map/types/src/themes/autumn.d.ts | 2 + simple-mind-map/types/src/themes/avocado.d.ts | 2 + .../types/src/themes/blackGold.d.ts | 2 + .../types/src/themes/blackHumour.d.ts | 2 + simple-mind-map/types/src/themes/blueSky.d.ts | 2 + .../types/src/themes/brainImpairedPink.d.ts | 2 + simple-mind-map/types/src/themes/classic.d.ts | 2 + .../types/src/themes/classic2.d.ts | 2 + .../types/src/themes/classic3.d.ts | 2 + .../types/src/themes/classic4.d.ts | 2 + .../types/src/themes/classicBlue.d.ts | 2 + .../types/src/themes/classicGreen.d.ts | 2 + simple-mind-map/types/src/themes/coffee.d.ts | 2 + .../types/src/themes/courseGreen.d.ts | 2 + simple-mind-map/types/src/themes/dark.d.ts | 2 + simple-mind-map/types/src/themes/dark2.d.ts | 2 + simple-mind-map/types/src/themes/default.d.ts | 143 +++++++++++++++ .../types/src/themes/earthYellow.d.ts | 2 + .../types/src/themes/freshGreen.d.ts | 2 + .../types/src/themes/freshRed.d.ts | 2 + simple-mind-map/types/src/themes/gold.d.ts | 2 + .../types/src/themes/greenLeaf.d.ts | 2 + simple-mind-map/types/src/themes/index.d.ts | 67 +++++++ .../types/src/themes/lateNightOffice.d.ts | 2 + simple-mind-map/types/src/themes/minions.d.ts | 2 + simple-mind-map/types/src/themes/mint.d.ts | 2 + .../types/src/themes/orangeJuice.d.ts | 2 + .../types/src/themes/pinkGrape.d.ts | 2 + .../types/src/themes/redSpirit.d.ts | 2 + .../types/src/themes/romanticPurple.d.ts | 2 + .../types/src/themes/simpleBlack.d.ts | 2 + .../types/src/themes/skyGreen.d.ts | 2 + .../types/src/themes/vitalityOrange.d.ts | 2 + .../types/src/utils/BatchExecution.d.ts | 8 + simple-mind-map/types/src/utils/Lru.d.ts | 10 ++ simple-mind-map/types/src/utils/index.d.ts | 113 ++++++++++++ 103 files changed, 2051 insertions(+), 174 deletions(-) delete mode 100644 simple-mind-map/index.d.ts create mode 100644 simple-mind-map/types/index.d.ts create mode 100644 simple-mind-map/types/src/constants/constant.d.ts create mode 100644 simple-mind-map/types/src/constants/defaultOptions.d.ts create mode 100644 simple-mind-map/types/src/core/command/Command.d.ts create mode 100644 simple-mind-map/types/src/core/command/KeyCommand.d.ts create mode 100644 simple-mind-map/types/src/core/command/keyMap.d.ts create mode 100644 simple-mind-map/types/src/core/event/Event.d.ts create mode 100644 simple-mind-map/types/src/core/render/Render.d.ts create mode 100644 simple-mind-map/types/src/core/render/TextEdit.d.ts create mode 100644 simple-mind-map/types/src/core/render/node/Node.d.ts create mode 100644 simple-mind-map/types/src/core/render/node/Shape.d.ts create mode 100644 simple-mind-map/types/src/core/render/node/Style.d.ts create mode 100644 simple-mind-map/types/src/core/render/node/nodeCommandWraps.d.ts create mode 100644 simple-mind-map/types/src/core/render/node/nodeCreateContents.d.ts create mode 100644 simple-mind-map/types/src/core/render/node/nodeExpandBtn.d.ts create mode 100644 simple-mind-map/types/src/core/render/node/nodeExpandBtnPlaceholderRect.d.ts create mode 100644 simple-mind-map/types/src/core/render/node/nodeGeneralization.d.ts create mode 100644 simple-mind-map/types/src/core/view/View.d.ts create mode 100644 simple-mind-map/types/src/layouts/Base.d.ts create mode 100644 simple-mind-map/types/src/layouts/CatalogOrganization.d.ts create mode 100644 simple-mind-map/types/src/layouts/Fishbone.d.ts create mode 100644 simple-mind-map/types/src/layouts/LogicalStructure.d.ts create mode 100644 simple-mind-map/types/src/layouts/MindMap.d.ts create mode 100644 simple-mind-map/types/src/layouts/OrganizationStructure.d.ts create mode 100644 simple-mind-map/types/src/layouts/Timeline.d.ts create mode 100644 simple-mind-map/types/src/layouts/VerticalTimeline.d.ts create mode 100644 simple-mind-map/types/src/layouts/fishboneUtils.d.ts create mode 100644 simple-mind-map/types/src/svg/btns.d.ts create mode 100644 simple-mind-map/types/src/svg/icons.d.ts create mode 100644 simple-mind-map/types/src/themes/autumn.d.ts create mode 100644 simple-mind-map/types/src/themes/avocado.d.ts create mode 100644 simple-mind-map/types/src/themes/blackGold.d.ts create mode 100644 simple-mind-map/types/src/themes/blackHumour.d.ts create mode 100644 simple-mind-map/types/src/themes/blueSky.d.ts create mode 100644 simple-mind-map/types/src/themes/brainImpairedPink.d.ts create mode 100644 simple-mind-map/types/src/themes/classic.d.ts create mode 100644 simple-mind-map/types/src/themes/classic2.d.ts create mode 100644 simple-mind-map/types/src/themes/classic3.d.ts create mode 100644 simple-mind-map/types/src/themes/classic4.d.ts create mode 100644 simple-mind-map/types/src/themes/classicBlue.d.ts create mode 100644 simple-mind-map/types/src/themes/classicGreen.d.ts create mode 100644 simple-mind-map/types/src/themes/coffee.d.ts create mode 100644 simple-mind-map/types/src/themes/courseGreen.d.ts create mode 100644 simple-mind-map/types/src/themes/dark.d.ts create mode 100644 simple-mind-map/types/src/themes/dark2.d.ts create mode 100644 simple-mind-map/types/src/themes/default.d.ts create mode 100644 simple-mind-map/types/src/themes/earthYellow.d.ts create mode 100644 simple-mind-map/types/src/themes/freshGreen.d.ts create mode 100644 simple-mind-map/types/src/themes/freshRed.d.ts create mode 100644 simple-mind-map/types/src/themes/gold.d.ts create mode 100644 simple-mind-map/types/src/themes/greenLeaf.d.ts create mode 100644 simple-mind-map/types/src/themes/index.d.ts create mode 100644 simple-mind-map/types/src/themes/lateNightOffice.d.ts create mode 100644 simple-mind-map/types/src/themes/minions.d.ts create mode 100644 simple-mind-map/types/src/themes/mint.d.ts create mode 100644 simple-mind-map/types/src/themes/orangeJuice.d.ts create mode 100644 simple-mind-map/types/src/themes/pinkGrape.d.ts create mode 100644 simple-mind-map/types/src/themes/redSpirit.d.ts create mode 100644 simple-mind-map/types/src/themes/romanticPurple.d.ts create mode 100644 simple-mind-map/types/src/themes/simpleBlack.d.ts create mode 100644 simple-mind-map/types/src/themes/skyGreen.d.ts create mode 100644 simple-mind-map/types/src/themes/vitalityOrange.d.ts create mode 100644 simple-mind-map/types/src/utils/BatchExecution.d.ts create mode 100644 simple-mind-map/types/src/utils/Lru.d.ts create mode 100644 simple-mind-map/types/src/utils/index.d.ts diff --git a/simple-mind-map/full.js b/simple-mind-map/full.js index 8ee27854..6aecb594 100644 --- a/simple-mind-map/full.js +++ b/simple-mind-map/full.js @@ -28,8 +28,7 @@ MindMap.constants = constants MindMap.themes = themes MindMap.defaultTheme = defaultTheme -MindMap - .usePlugin(MiniMap) +MindMap.usePlugin(MiniMap) .usePlugin(Watermark) .usePlugin(Drag) .usePlugin(KeyboardNavigation) @@ -45,4 +44,4 @@ MindMap .usePlugin(Painter) .usePlugin(Scrollbar) -export default MindMap \ No newline at end of file +export default MindMap diff --git a/simple-mind-map/index.d.ts b/simple-mind-map/index.d.ts deleted file mode 100644 index 88636563..00000000 --- a/simple-mind-map/index.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -// declare module "simple-mind-map"; -declare module 'simple-mind-map'{ - class MindMap { - constructor(opt:any); - handleOpt(opt:any):void; - render(callback:any, source:string):void; - reRender(callback:any, source:string):void; - resize():void; - on(event:any, fn:any):void; - setFullData(data:any):void; - getData(withConfig:any):any; - } - export default MindMap; -} diff --git a/simple-mind-map/index.js b/simple-mind-map/index.js index e1556230..a7890021 100644 --- a/simple-mind-map/index.js +++ b/simple-mind-map/index.js @@ -24,6 +24,10 @@ import { defaultOpt } from './src/constants/defaultOptions' // 思维导图 class MindMap { // 构造函数 + /** + * + * @param {defaultOpt} opt + */ constructor(opt = {}) { // 合并选项 this.opt = this.handleOpt(merge(defaultOpt, opt)) @@ -36,7 +40,8 @@ class MindMap { // 画布宽高 this.width = this.elRect.width this.height = this.elRect.height - if (this.width <= 0 || this.height <= 0) throw new Error('容器元素el的宽高不能为0') + if (this.width <= 0 || this.height <= 0) + throw new Error('容器元素el的宽高不能为0') // 添加css this.cssEl = null @@ -360,7 +365,7 @@ class MindMap { // 克隆一份数据 let clone = svg.clone() // 添加必要的样式 - clone.add(SVG(``)) + clone.add(SVG(``)) // 如果实际图形宽高超出了屏幕宽高,且存在水印的话需要重新绘制水印,否则会出现超出部分没有水印的问题 if ( (rect.width > origWidth || rect.height > origHeight) && diff --git a/simple-mind-map/package.json b/simple-mind-map/package.json index c81c2ff6..188778a5 100644 --- a/simple-mind-map/package.json +++ b/simple-mind-map/package.json @@ -12,6 +12,7 @@ "url": "http://lxqnsys.com/" } ], + "types": "./types/index.d.ts", "license": "MIT", "repository": { "type": "git", @@ -19,7 +20,8 @@ }, "scripts": { "lint": "eslint src/", - "format": "prettier --write ." + "format": "prettier --write .", + "types": "npx -p typescript tsc index.js --declaration --allowJs --emitDeclarationOnly --outDir types --target es2017" }, "module": "index.js", "__main": "./dist/simpleMindMap.umd.min.js", @@ -31,6 +33,7 @@ "jszip": "^3.10.1", "mdast-util-from-markdown": "^1.3.0", "quill": "^1.3.6", + "tern": "^0.24.3", "uuid": "^9.0.0", "xml-js": "^1.6.11" }, diff --git a/simple-mind-map/scripts/walkJsFiles.js b/simple-mind-map/scripts/walkJsFiles.js index 96124251..69ed7c1e 100644 --- a/simple-mind-map/scripts/walkJsFiles.js +++ b/simple-mind-map/scripts/walkJsFiles.js @@ -17,7 +17,7 @@ const transform = dir => { } const transformFile = file => { - console.log(file); + console.log(file) let content = fs.readFileSync(file, 'utf-8') countCodeLines(content) // transformComments(file, content) @@ -25,7 +25,7 @@ const transformFile = file => { // 统计代码行数 let totalLines = 0 -const countCodeLines = (content) => { +const countCodeLines = content => { totalLines += content.split(/\n/).length } @@ -43,4 +43,4 @@ const transformComments = (file, content) => { transform(entryPath) transformFile(path.join(__dirname, '../index.js')) -console.log(totalLines); \ No newline at end of file +console.log(totalLines) diff --git a/simple-mind-map/src/constants/constant.js b/simple-mind-map/src/constants/constant.js index d37e6ade..d3d3f2b8 100644 --- a/simple-mind-map/src/constants/constant.js +++ b/simple-mind-map/src/constants/constant.js @@ -261,42 +261,42 @@ export const initRootNodePositionMap = { [CONSTANTS.INIT_ROOT_NODE_POSITION.TOP]: 0, [CONSTANTS.INIT_ROOT_NODE_POSITION.RIGHT]: 1, [CONSTANTS.INIT_ROOT_NODE_POSITION.BOTTOM]: 1, - [CONSTANTS.INIT_ROOT_NODE_POSITION.CENTER]: 0.5, + [CONSTANTS.INIT_ROOT_NODE_POSITION.CENTER]: 0.5 } // 布局结构列表 export const layoutList = [ { name: '逻辑结构图', - value: CONSTANTS.LAYOUT.LOGICAL_STRUCTURE, + value: CONSTANTS.LAYOUT.LOGICAL_STRUCTURE }, { name: '思维导图', - value: CONSTANTS.LAYOUT.MIND_MAP, + value: CONSTANTS.LAYOUT.MIND_MAP }, { name: '组织结构图', - value: CONSTANTS.LAYOUT.ORGANIZATION_STRUCTURE, + value: CONSTANTS.LAYOUT.ORGANIZATION_STRUCTURE }, { name: '目录组织图', - value: CONSTANTS.LAYOUT.CATALOG_ORGANIZATION, + value: CONSTANTS.LAYOUT.CATALOG_ORGANIZATION }, { name: '时间轴', - value: CONSTANTS.LAYOUT.TIMELINE, + value: CONSTANTS.LAYOUT.TIMELINE }, { name: '时间轴2', - value: CONSTANTS.LAYOUT.TIMELINE2, + value: CONSTANTS.LAYOUT.TIMELINE2 }, { name: '竖向时间轴', - value: CONSTANTS.LAYOUT.VERTICAL_TIMELINE, + value: CONSTANTS.LAYOUT.VERTICAL_TIMELINE }, { name: '鱼骨图', - value: CONSTANTS.LAYOUT.FISHBONE, + value: CONSTANTS.LAYOUT.FISHBONE } ] export const layoutValueList = [ @@ -374,4 +374,4 @@ export const cssContent = ` opacity: 1; stroke-width: 2; } -` \ No newline at end of file +` diff --git a/simple-mind-map/src/core/command/Command.js b/simple-mind-map/src/core/command/Command.js index d8edde54..8b59b98d 100644 --- a/simple-mind-map/src/core/command/Command.js +++ b/simple-mind-map/src/core/command/Command.js @@ -37,7 +37,11 @@ class Command { this.commands[name].forEach(fn => { fn(...args) }) - if (['BACK', 'FORWARD', 'SET_NODE_ACTIVE', 'CLEAR_ACTIVE_NODE'].includes(name)) { + if ( + ['BACK', 'FORWARD', 'SET_NODE_ACTIVE', 'CLEAR_ACTIVE_NODE'].includes( + name + ) + ) { return } this.addHistory() @@ -78,7 +82,11 @@ class Command { } let data = this.getCopyData() // 此次数据和上次一样则不重复添加 - if (this.history.length > 0 && JSON.stringify(this.history[this.history.length - 1]) === JSON.stringify(data)) { + if ( + this.history.length > 0 && + JSON.stringify(this.history[this.history.length - 1]) === + JSON.stringify(data) + ) { return } // 删除当前历史指针后面的数据 @@ -123,7 +131,11 @@ class Command { let len = this.history.length if (this.activeHistoryIndex + step <= len - 1) { this.activeHistoryIndex += step - this.mindMap.emit('back_forward', this.activeHistoryIndex, this.history.length) + this.mindMap.emit( + 'back_forward', + this.activeHistoryIndex, + this.history.length + ) let data = simpleDeepClone(this.history[this.activeHistoryIndex]) this.mindMap.emit('data_change', data) return data @@ -138,10 +150,10 @@ class Command { // 移除节点数据中的uid removeDataUid(data) { data = simpleDeepClone(data) - let walk = (root) => { + let walk = root => { delete root.data.uid if (root.children && root.children.length > 0) { - root.children.forEach((item) => { + root.children.forEach(item => { walk(item) }) } diff --git a/simple-mind-map/src/core/command/KeyCommand.js b/simple-mind-map/src/core/command/KeyCommand.js index 4b493fd6..39abc3c6 100644 --- a/simple-mind-map/src/core/command/KeyCommand.js +++ b/simple-mind-map/src/core/command/KeyCommand.js @@ -46,13 +46,20 @@ export default class KeyCommand { if (this.mindMap.richText && this.mindMap.richText.showTextEdit) { return } - if (this.mindMap.renderer.textEdit.showTextEdit || (this.mindMap.associativeLine && this.mindMap.associativeLine.showTextEdit)) { + if ( + this.mindMap.renderer.textEdit.showTextEdit || + (this.mindMap.associativeLine && + this.mindMap.associativeLine.showTextEdit) + ) { return } this.isInSvg = false }) window.addEventListener('keydown', e => { - if (this.isPause || (this.mindMap.opt.enableShortcutOnlyWhenMouseInSvg && !this.isInSvg)) { + if ( + this.isPause || + (this.mindMap.opt.enableShortcutOnlyWhenMouseInSvg && !this.isInSvg) + ) { return } Object.keys(this.shortcutMap).forEach(key => { diff --git a/simple-mind-map/src/core/event/Event.js b/simple-mind-map/src/core/event/Event.js index f1313b37..5aa9faea 100644 --- a/simple-mind-map/src/core/event/Event.js +++ b/simple-mind-map/src/core/event/Event.js @@ -113,7 +113,7 @@ class Event extends EventEmitter { this.isMiddleMousedown || (useLeftKeySelectionRightKeyDrag ? this.isRightMousedown - : this.isLeftMousedown) + : this.isLeftMousedown) ) { e.preventDefault() this.emit('drag', e, this) diff --git a/simple-mind-map/src/core/render/node/Node.js b/simple-mind-map/src/core/render/node/Node.js index 21674201..493eb46f 100644 --- a/simple-mind-map/src/core/render/node/Node.js +++ b/simple-mind-map/src/core/render/node/Node.js @@ -394,7 +394,11 @@ class Node { this.active(e) }) this.group.on('mousedown', e => { - const { readonly, enableCtrlKeyNodeSelection, useLeftKeySelectionRightKeyDrag } = this.mindMap.opt + const { + readonly, + enableCtrlKeyNodeSelection, + useLeftKeySelectionRightKeyDrag + } = this.mindMap.opt // 只读模式不需要阻止冒泡 if (!readonly) { if (this.isRoot) { @@ -423,11 +427,9 @@ class Node { this.mindMap.renderer[isActive ? 'removeActiveNode' : 'addActiveNode']( this ) - this.mindMap.emit( - 'node_active', - isActive ? null : this, - [...this.mindMap.renderer.activeNodeList] - ) + this.mindMap.emit('node_active', isActive ? null : this, [ + ...this.mindMap.renderer.activeNodeList + ]) } this.mindMap.emit('node_mousedown', this, e) }) @@ -466,7 +468,11 @@ class Node { e.stopPropagation() e.preventDefault() // 如果是多选节点结束,那么不要触发右键菜单事件 - if(this.mindMap.select && !useLeftKeySelectionRightKeyDrag && this.mindMap.select.hasSelectRange()) { + if ( + this.mindMap.select && + !useLeftKeySelectionRightKeyDrag && + this.mindMap.select.hasSelectRange() + ) { return } if (this.nodeData.data.isActive) { diff --git a/simple-mind-map/src/core/render/node/Style.js b/simple-mind-map/src/core/render/node/Style.js index dacc31c3..55dc9b22 100644 --- a/simple-mind-map/src/core/render/node/Style.js +++ b/simple-mind-map/src/core/render/node/Style.js @@ -234,12 +234,9 @@ class Style { // hover和激活节点 hoverNode(node) { const { hoverRectColor } = this.ctx.mindMap.opt - node - .radius(5) - .fill('none') - .stroke({ - color: hoverRectColor - }) + node.radius(5).fill('none').stroke({ + color: hoverRectColor + }) } } diff --git a/simple-mind-map/src/core/render/node/nodeExpandBtn.js b/simple-mind-map/src/core/render/node/nodeExpandBtn.js index 61936759..004f74f4 100644 --- a/simple-mind-map/src/core/render/node/nodeExpandBtn.js +++ b/simple-mind-map/src/core/render/node/nodeExpandBtn.js @@ -70,7 +70,8 @@ function updateExpandBtnNode() { if (this._expandBtn) { // 如果是收起按钮加上边框 - let { isShowExpandNum, expandBtnStyle, expandBtnNumHandler } = this.mindMap.opt + let { isShowExpandNum, expandBtnStyle, expandBtnNumHandler } = + this.mindMap.opt if (isShowExpandNum) { if (!expand) { // 数字按钮添加边框 diff --git a/simple-mind-map/src/core/render/node/nodeGeneralization.js b/simple-mind-map/src/core/render/node/nodeGeneralization.js index ec7f95aa..3459e0e2 100644 --- a/simple-mind-map/src/core/render/node/nodeGeneralization.js +++ b/simple-mind-map/src/core/render/node/nodeGeneralization.js @@ -2,12 +2,12 @@ import Node from './Node' import { createUid } from '../../../utils/index' // 检查是否存在概要 -function checkHasGeneralization () { +function checkHasGeneralization() { return !!this.nodeData.data.generalization } // 创建概要节点 -function createGeneralizationNode () { +function createGeneralizationNode() { if (this.isGeneralization || !this.checkHasGeneralization()) { return } @@ -35,14 +35,14 @@ function createGeneralizationNode () { } // 更新概要节点 -function updateGeneralization () { +function updateGeneralization() { if (this.isGeneralization) return this.removeGeneralization() this.createGeneralizationNode() } // 渲染概要节点 -function renderGeneralization () { +function renderGeneralization() { if (this.isGeneralization) return if (!this.checkHasGeneralization()) { this.removeGeneralization() @@ -65,7 +65,7 @@ function renderGeneralization () { } // 删除概要节点 -function removeGeneralization () { +function removeGeneralization() { if (this.isGeneralization) return if (this._generalizationLine) { this._generalizationLine.remove() @@ -86,7 +86,7 @@ function removeGeneralization () { } // 隐藏概要节点 -function hideGeneralization () { +function hideGeneralization() { if (this.isGeneralization) return if (this._generalizationLine) { this._generalizationLine.hide() @@ -97,7 +97,7 @@ function hideGeneralization () { } // 显示概要节点 -function showGeneralization () { +function showGeneralization() { if (this.isGeneralization) return if (this._generalizationLine) { this._generalizationLine.show() @@ -108,11 +108,11 @@ function showGeneralization () { } export default { - checkHasGeneralization, - createGeneralizationNode, - updateGeneralization, - renderGeneralization, - removeGeneralization, - hideGeneralization, - showGeneralization -} \ No newline at end of file + checkHasGeneralization, + createGeneralizationNode, + updateGeneralization, + renderGeneralization, + removeGeneralization, + hideGeneralization, + showGeneralization +} diff --git a/simple-mind-map/src/core/view/View.js b/simple-mind-map/src/core/view/View.js index 5682f6ee..ac235615 100644 --- a/simple-mind-map/src/core/view/View.js +++ b/simple-mind-map/src/core/view/View.js @@ -79,7 +79,10 @@ class View { // 鼠标滚轮事件控制缩放 if (mousewheelAction === CONSTANTS.MOUSE_WHEEL_ACTION.ZOOM) { if (disableMouseWheelZoom) return - const { x: clientX, y: clientY } = this.mindMap.toPos(e.clientX, e.clientY) + const { x: clientX, y: clientY } = this.mindMap.toPos( + e.clientX, + e.clientY + ) let cx = mouseScaleCenterUseMousePosition ? clientX : undefined let cy = mouseScaleCenterUseMousePosition ? clientY : undefined switch (dir) { diff --git a/simple-mind-map/src/layouts/CatalogOrganization.js b/simple-mind-map/src/layouts/CatalogOrganization.js index 615c3dab..1438c5e2 100644 --- a/simple-mind-map/src/layouts/CatalogOrganization.js +++ b/simple-mind-map/src/layouts/CatalogOrganization.js @@ -87,11 +87,18 @@ class CatalogOrganization extends Base { totalLeft += cur.width + marginX }) } else { - let totalTop = node.top + this.getNodeHeightWithGeneralization(node) + marginY + (this.getNodeActChildrenLength(node) > 0 ? node.expandBtnSize : 0) + let totalTop = + node.top + + this.getNodeHeightWithGeneralization(node) + + marginY + + (this.getNodeActChildrenLength(node) > 0 ? node.expandBtnSize : 0) node.children.forEach(cur => { cur.left = node.left + node.width * 0.5 cur.top = totalTop - totalTop += this.getNodeHeightWithGeneralization(cur) + marginY + (this.getNodeActChildrenLength(cur) > 0 ? cur.expandBtnSize : 0) + totalTop += + this.getNodeHeightWithGeneralization(cur) + + marginY + + (this.getNodeActChildrenLength(cur) > 0 ? cur.expandBtnSize : 0) }) } } @@ -124,7 +131,13 @@ class CatalogOrganization extends Base { let marginY = this.getMarginY(layerIndex + 1) let totalHeight = node.children.reduce((h, item) => { - return h + this.getNodeHeightWithGeneralization(item) + (this.getNodeActChildrenLength(item) > 0 ? item.expandBtnSize : 0) + return ( + h + + this.getNodeHeightWithGeneralization(item) + + (this.getNodeActChildrenLength(item) > 0 + ? item.expandBtnSize + : 0) + ) }, 0) + len * marginY this.updateBrothersTop(node, totalHeight) @@ -134,7 +147,7 @@ class CatalogOrganization extends Base { if (isRoot) { let { right, left } = this.getNodeBoundaries(node, 'h') let childrenWidth = right - left - let offset = (node.left - left) - (childrenWidth - node.width) / 2 + let offset = node.left - left - (childrenWidth - node.width) / 2 this.updateChildren(node.children, 'left', offset) } }, diff --git a/simple-mind-map/src/layouts/Fishbone.js b/simple-mind-map/src/layouts/Fishbone.js index 0706caba..481d918d 100644 --- a/simple-mind-map/src/layouts/Fishbone.js +++ b/simple-mind-map/src/layouts/Fishbone.js @@ -159,7 +159,8 @@ class Fishbone extends Base { let marginY = this.getMarginY(node.layerIndex) totalHeight += node.height + - (this.getNodeActChildrenLength(node) > 0 ? node.expandBtnSize : 0) + marginY + (this.getNodeActChildrenLength(node) > 0 ? node.expandBtnSize : 0) + + marginY if (node.children.length) { node.children.forEach(item => { loop(item) diff --git a/simple-mind-map/src/layouts/FishboneBottom.js b/simple-mind-map/src/layouts/FishboneBottom.js index ca66b6a6..e0bca450 100644 --- a/simple-mind-map/src/layouts/FishboneBottom.js +++ b/simple-mind-map/src/layouts/FishboneBottom.js @@ -170,7 +170,8 @@ class Fishbone extends Base { item.top += _top // 调整left let offsetLeft = - (totalHeight2 + nodeTotalHeight) / Math.tan(degToRad(this.mindMap.opt.fishboneDeg)) + (totalHeight2 + nodeTotalHeight) / + Math.tan(degToRad(this.mindMap.opt.fishboneDeg)) item.left += offsetLeft totalHeight += offset totalHeight2 += nodeTotalHeight @@ -312,7 +313,9 @@ class Fishbone extends Base { if (node.parent && node.parent.isRoot) { line.plot( `M ${x},${top + height} L ${x + lineLength},${ - top + height + Math.tan(degToRad(this.mindMap.opt.fishboneDeg)) * lineLength + top + + height + + Math.tan(degToRad(this.mindMap.opt.fishboneDeg)) * lineLength }` ) } else { diff --git a/simple-mind-map/src/layouts/FishboneTop.js b/simple-mind-map/src/layouts/FishboneTop.js index 0f4fa57a..a27fcbde 100644 --- a/simple-mind-map/src/layouts/FishboneTop.js +++ b/simple-mind-map/src/layouts/FishboneTop.js @@ -140,7 +140,8 @@ class Fishbone extends Base { node.top - (item.top - node.top) - nodeTotalHeight + node.height // 调整left let offsetLeft = - (nodeTotalHeight + totalHeight) / Math.tan(degToRad(this.mindMap.opt.fishboneDeg)) + (nodeTotalHeight + totalHeight) / + Math.tan(degToRad(this.mindMap.opt.fishboneDeg)) item.left += offsetLeft totalHeight += nodeTotalHeight // 同步更新后代节点 @@ -285,14 +286,16 @@ class Fishbone extends Base { ) { line.plot( `M ${x},${top} L ${x + lineLength},${ - top - Math.tan(degToRad(this.mindMap.opt.fishboneDeg)) * lineLength + top - + Math.tan(degToRad(this.mindMap.opt.fishboneDeg)) * lineLength }` ) } else { if (node.parent && node.parent.isRoot) { line.plot( `M ${x},${top} L ${x + lineLength},${ - top - Math.tan(degToRad(this.mindMap.opt.fishboneDeg)) * lineLength + top - + Math.tan(degToRad(this.mindMap.opt.fishboneDeg)) * lineLength }` ) } else { diff --git a/simple-mind-map/src/layouts/LogicalStructure.js b/simple-mind-map/src/layouts/LogicalStructure.js index d66955cd..038ed5e3 100644 --- a/simple-mind-map/src/layouts/LogicalStructure.js +++ b/simple-mind-map/src/layouts/LogicalStructure.js @@ -57,8 +57,14 @@ class LogicalStructure extends Base { (len + 1) * this.getMarginY(layerIndex + 1) : 0 // 如果存在概要,则和概要的高度取最大值 - let generalizationNodeHeight = cur._node.checkHasGeneralization() ? cur._node._generalizationNodeHeight + this.getMarginY(layerIndex + 1) : 0 - cur._node.childrenAreaHeight2 = Math.max(cur._node.childrenAreaHeight, generalizationNodeHeight) + let generalizationNodeHeight = cur._node.checkHasGeneralization() + ? cur._node._generalizationNodeHeight + + this.getMarginY(layerIndex + 1) + : 0 + cur._node.childrenAreaHeight2 = Math.max( + cur._node.childrenAreaHeight, + generalizationNodeHeight + ) }, true, 0 @@ -103,7 +109,8 @@ class LogicalStructure extends Base { // 判断子节点所占的高度之和是否大于该节点自身,大于则需要调整位置 let difference = node.childrenAreaHeight2 - - this.getMarginY(layerIndex + 1) * 2 - node.height + this.getMarginY(layerIndex + 1) * 2 - + node.height if (difference > 0) { this.updateBrothers(node, difference / 2) } diff --git a/simple-mind-map/src/layouts/MindMap.js b/simple-mind-map/src/layouts/MindMap.js index 35af2c04..4f9455c3 100644 --- a/simple-mind-map/src/layouts/MindMap.js +++ b/simple-mind-map/src/layouts/MindMap.js @@ -92,9 +92,18 @@ class MindMap extends Base { (rightLen + 1) * this.getMarginY(layerIndex + 1) // 如果存在概要,则和概要的高度取最大值 - let generalizationNodeHeight = cur._node.checkHasGeneralization() ? cur._node._generalizationNodeHeight + this.getMarginY(layerIndex + 1) : 0 - cur._node.leftChildrenAreaHeight2 = Math.max(cur._node.leftChildrenAreaHeight, generalizationNodeHeight) - cur._node.rightChildrenAreaHeight2 = Math.max(cur._node.rightChildrenAreaHeight, generalizationNodeHeight) + let generalizationNodeHeight = cur._node.checkHasGeneralization() + ? cur._node._generalizationNodeHeight + + this.getMarginY(layerIndex + 1) + : 0 + cur._node.leftChildrenAreaHeight2 = Math.max( + cur._node.leftChildrenAreaHeight, + generalizationNodeHeight + ) + cur._node.rightChildrenAreaHeight2 = Math.max( + cur._node.rightChildrenAreaHeight, + generalizationNodeHeight + ) }, true, 0 diff --git a/simple-mind-map/src/layouts/OrganizationStructure.js b/simple-mind-map/src/layouts/OrganizationStructure.js index c3b49092..85daf271 100644 --- a/simple-mind-map/src/layouts/OrganizationStructure.js +++ b/simple-mind-map/src/layouts/OrganizationStructure.js @@ -59,8 +59,13 @@ class OrganizationStructure extends Base { : 0 // 如果存在概要,则和概要的高度取最大值 - let generalizationNodeWidth = cur._node.checkHasGeneralization() ? cur._node._generalizationNodeWidth + this.getMarginY(layerIndex + 1) : 0 - cur._node.childrenAreaWidth2 = Math.max(cur._node.childrenAreaWidth, generalizationNodeWidth) + let generalizationNodeWidth = cur._node.checkHasGeneralization() + ? cur._node._generalizationNodeWidth + this.getMarginY(layerIndex + 1) + : 0 + cur._node.childrenAreaWidth2 = Math.max( + cur._node.childrenAreaWidth, + generalizationNodeWidth + ) }, true, 0 diff --git a/simple-mind-map/src/layouts/fishboneUtils.js b/simple-mind-map/src/layouts/fishboneUtils.js index e95e2ec2..f4fbf137 100644 --- a/simple-mind-map/src/layouts/fishboneUtils.js +++ b/simple-mind-map/src/layouts/fishboneUtils.js @@ -52,13 +52,15 @@ export default { let totalTop = node.top + node.height + - (ctx.getNodeActChildrenLength(node) > 0 ? node.expandBtnSize : 0) + marginY + (ctx.getNodeActChildrenLength(node) > 0 ? node.expandBtnSize : 0) + + marginY node.children.forEach(item => { item.left = startLeft item.top += totalTop totalTop += item.height + - (ctx.getNodeActChildrenLength(item) > 0 ? item.expandBtnSize : 0) + marginY + (ctx.getNodeActChildrenLength(item) > 0 ? item.expandBtnSize : 0) + + marginY }) } }, @@ -72,7 +74,8 @@ export default { return ( h + item.height + - (ctx.getNodeActChildrenLength(item) > 0 ? item.expandBtnSize : 0) + marginY + (ctx.getNodeActChildrenLength(item) > 0 ? item.expandBtnSize : 0) + + marginY ) }, 0) ctx.updateBrothersTop(node, totalHeight) @@ -92,7 +95,11 @@ export default { item.top = node.top - (item.top - node.top) - nodeTotalHeight + node.height // 调整left - item.left = node.left + node.width * ctx.indent + (nodeTotalHeight + totalHeight) / Math.tan(degToRad(ctx.mindMap.opt.fishboneDeg)) + item.left = + node.left + + node.width * ctx.indent + + (nodeTotalHeight + totalHeight) / + Math.tan(degToRad(ctx.mindMap.opt.fishboneDeg)) totalHeight += nodeTotalHeight // 同步更新后代节点 ctx.updateChildrenPro(item.children, { @@ -129,7 +136,9 @@ export default { if (node.parent && node.parent.isRoot) { line.plot( `M ${x},${top + height} L ${x + lineLength},${ - top + height + Math.tan(degToRad(ctx.mindMap.opt.fishboneDeg)) * lineLength + top + + height + + Math.tan(degToRad(ctx.mindMap.opt.fishboneDeg)) * lineLength }` ) } else { @@ -144,7 +153,8 @@ export default { let totalTop = node.top + node.height + - (ctx.getNodeActChildrenLength(node) > 0 ? node.expandBtnSize : 0) + marginY + (ctx.getNodeActChildrenLength(node) > 0 ? node.expandBtnSize : 0) + + marginY node.children.forEach(item => { item.left = startLeft @@ -153,7 +163,8 @@ export default { (ctx.getNodeActChildrenLength(item) > 0 ? item.expandBtnSize : 0) totalTop += item.height + - (ctx.getNodeActChildrenLength(item) > 0 ? item.expandBtnSize : 0) + marginY + (ctx.getNodeActChildrenLength(item) > 0 ? item.expandBtnSize : 0) + + marginY }) } if (layerIndex > 1 && node.children) { @@ -161,13 +172,15 @@ export default { let startLeft = node.left + node.width * ctx.childIndent let totalTop = node.top - - (ctx.getNodeActChildrenLength(node) > 0 ? node.expandBtnSize : 0) - marginY + (ctx.getNodeActChildrenLength(node) > 0 ? node.expandBtnSize : 0) - + marginY node.children.forEach(item => { item.left = startLeft item.top = totalTop - item.height totalTop -= item.height + - (ctx.getNodeActChildrenLength(item) > 0 ? item.expandBtnSize : 0) + marginY + (ctx.getNodeActChildrenLength(item) > 0 ? item.expandBtnSize : 0) + + marginY }) } }, @@ -180,7 +193,8 @@ export default { return ( h + item.height + - (ctx.getNodeActChildrenLength(item) > 0 ? item.expandBtnSize : 0) + marginY + (ctx.getNodeActChildrenLength(item) > 0 ? item.expandBtnSize : 0) + + marginY ) }, 0) ctx.updateBrothersTop(node, -totalHeight) @@ -197,18 +211,21 @@ export default { // 调整top let hasChildren = ctx.getNodeActChildrenLength(item) > 0 let nodeTotalHeight = ctx.getNodeAreaHeight(item) - let offset = - hasChildren - ? nodeTotalHeight - - item.height - - (hasChildren ? item.expandBtnSize : 0) - : 0 - offset -= (hasChildren ? marginY : 0) + let offset = hasChildren + ? nodeTotalHeight - + item.height - + (hasChildren ? item.expandBtnSize : 0) + : 0 + offset -= hasChildren ? marginY : 0 let _top = totalHeight + offset let _left = item.left item.top += _top // 调整left - item.left = node.left + node.width * ctx.indent + (nodeTotalHeight + totalHeight2) / Math.tan(degToRad(ctx.mindMap.opt.fishboneDeg)) + item.left = + node.left + + node.width * ctx.indent + + (nodeTotalHeight + totalHeight2) / + Math.tan(degToRad(ctx.mindMap.opt.fishboneDeg)) totalHeight += offset totalHeight2 += nodeTotalHeight // 同步更新后代节点 diff --git a/simple-mind-map/src/parse/toMarkdown.js b/simple-mind-map/src/parse/toMarkdown.js index 9164d7d7..13e48053 100644 --- a/simple-mind-map/src/parse/toMarkdown.js +++ b/simple-mind-map/src/parse/toMarkdown.js @@ -50,4 +50,4 @@ export const transformToMarkdown = root => { true ) return content -} \ No newline at end of file +} diff --git a/simple-mind-map/src/parse/xmind.js b/simple-mind-map/src/parse/xmind.js index 1c5c48bd..07cfd7c1 100644 --- a/simple-mind-map/src/parse/xmind.js +++ b/simple-mind-map/src/parse/xmind.js @@ -191,7 +191,7 @@ const transformOldXmind = content => { if (_children && _children.elements && _children.elements.length > 0) { _children.elements.forEach(item => { if (item.name === 'topics') { - (item.elements || []).forEach(item2 => { + ;(item.elements || []).forEach(item2 => { let newChild = {} newNode.children.push(newChild) walk(item2, newChild) diff --git a/simple-mind-map/src/plugins/AssociativeLine.js b/simple-mind-map/src/plugins/AssociativeLine.js index 5855c27b..42550286 100644 --- a/simple-mind-map/src/plugins/AssociativeLine.js +++ b/simple-mind-map/src/plugins/AssociativeLine.js @@ -105,7 +105,7 @@ class AssociativeLine { this.markerPath = add.path('M0,0 L2,5 L0,10 L10,5 Z') }) } - + // 判断关联线坐标是否变更,有变更则使用变化后的坐标,无则默认坐标 updateAllLinesPos(node, toNode, associativeLinePoint) { associativeLinePoint = associativeLinePoint || {} diff --git a/simple-mind-map/src/plugins/Export.js b/simple-mind-map/src/plugins/Export.js index aa447540..a90aa7c0 100644 --- a/simple-mind-map/src/plugins/Export.js +++ b/simple-mind-map/src/plugins/Export.js @@ -58,7 +58,13 @@ class Export { } // svg转png - svgToPng(svgSrc, transparent, checkRotate = () => { return false }) { + svgToPng( + svgSrc, + transparent, + checkRotate = () => { + return false + } + ) { return new Promise((resolve, reject) => { const img = new Image() // 跨域图片需要添加这个属性,否则画布被污染了无法导出图片 @@ -66,7 +72,10 @@ class Export { img.onload = async () => { try { const canvas = document.createElement('canvas') - const dpr = Math.max(window.devicePixelRatio, this.mindMap.opt.minExportImgCanvasScale) + const dpr = Math.max( + window.devicePixelRatio, + this.mindMap.opt.minExportImgCanvasScale + ) const imgWidth = img.width const imgHeight = img.height // 如果宽比高长,那么旋转90度 @@ -185,7 +194,9 @@ class Export { // 覆盖html默认的样式 let foreignObjectList = node.find('foreignObject') if (foreignObjectList.length > 0) { - foreignObjectList[0].add(SVG(``)) + foreignObjectList[0].add( + SVG(``) + ) } str = node.svg() // 使用其他库(html2canvas、dom-to-image-more等)来完成导出 @@ -204,11 +215,7 @@ class Export { // 转换成data:url数据 let svgUrl = await readBlob(blob) // 绘制到canvas上 - let res = await this.svgToPng( - svgUrl, - transparent, - checkRotate - ) + let res = await this.svgToPng(svgUrl, transparent, checkRotate) return res } @@ -219,7 +226,7 @@ class Export { } let img = await this.png('', false, (width, height) => { if (width <= a4Size.width && height && a4Size.height) return false - return (width / height) > 1 + return width / height > 1 }) this.mindMap.doExportPDF.pdf(name, img, useMultiPageExport) } @@ -243,7 +250,9 @@ class Export { if (this.mindMap.richText) { let foreignObjectList = node.find('foreignObject') if (foreignObjectList.length > 0) { - foreignObjectList[0].add(SVG(``)) + foreignObjectList[0].add( + SVG(``) + ) } } node.first().before(SVG(`${name}`)) diff --git a/simple-mind-map/src/plugins/ExportPDF.js b/simple-mind-map/src/plugins/ExportPDF.js index 83f7ee88..5bffffc1 100644 --- a/simple-mind-map/src/plugins/ExportPDF.js +++ b/simple-mind-map/src/plugins/ExportPDF.js @@ -40,7 +40,14 @@ class ExportPDF { w = a4Size.width h = a4Size.width / imageRatio } - pdf.addImage(img, 'PNG', (a4Size.width - w) / 2, (a4Size.height - h) / 2, w, h) + pdf.addImage( + img, + 'PNG', + (a4Size.width - w) / 2, + (a4Size.height - h) / 2, + w, + h + ) pdf.save(name) } image.src = img diff --git a/simple-mind-map/src/plugins/KeyboardNavigation.js b/simple-mind-map/src/plugins/KeyboardNavigation.js index d38815d0..f3eb694e 100644 --- a/simple-mind-map/src/plugins/KeyboardNavigation.js +++ b/simple-mind-map/src/plugins/KeyboardNavigation.js @@ -232,4 +232,4 @@ class KeyboardNavigation { KeyboardNavigation.instanceName = 'keyboardNavigation' -export default KeyboardNavigation \ No newline at end of file +export default KeyboardNavigation diff --git a/simple-mind-map/src/plugins/MiniMap.js b/simple-mind-map/src/plugins/MiniMap.js index 0127c2dd..fe745700 100644 --- a/simple-mind-map/src/plugins/MiniMap.js +++ b/simple-mind-map/src/plugins/MiniMap.js @@ -1,4 +1,8 @@ -import { isWhite, isTransparent, getVisibleColorFromTheme } from '../utils/index' +import { + isWhite, + isTransparent, + getVisibleColorFromTheme +} from '../utils/index' // 小地图插件 class MiniMap { @@ -78,7 +82,7 @@ class MiniMap { viewBoxStyle.left = miniMapBoxLeft + actWidth } - Object.keys(viewBoxStyle).forEach((key) => { + Object.keys(viewBoxStyle).forEach(key => { viewBoxStyle[key] = viewBoxStyle[key] + 'px' }) @@ -106,7 +110,7 @@ class MiniMap { } let children = svg.children() if (children && children.length > 0) { - children.forEach((node) => { + children.forEach(node => { this.removeNodeContent(node) }) } diff --git a/simple-mind-map/src/plugins/NodeImgAdjust.js b/simple-mind-map/src/plugins/NodeImgAdjust.js index ff62cb56..9913ed33 100644 --- a/simple-mind-map/src/plugins/NodeImgAdjust.js +++ b/simple-mind-map/src/plugins/NodeImgAdjust.js @@ -49,7 +49,7 @@ class NodeImgAdjust { // 如果当前正在拖动调整中那么直接返回 if (this.isMousedown || this.isAdjusted || this.mindMap.opt.readonly) return // 如果在当前节点内移动,以及自定义元素已经是显示状态,那么直接返回 - if ((this.node && this.node.uid === node.uid) && this.isShowHandleEl) return + if (this.node && this.node.uid === node.uid && this.isShowHandleEl) return // 更新当前节点信息 this.node = node this.img = img diff --git a/simple-mind-map/src/plugins/RichText.js b/simple-mind-map/src/plugins/RichText.js index 8c158fba..4117d144 100644 --- a/simple-mind-map/src/plugins/RichText.js +++ b/simple-mind-map/src/plugins/RichText.js @@ -249,7 +249,9 @@ class RichText { this.showTextEdit = true // 如果是刚创建的节点,那么默认全选,否则普通激活不全选,除非selectTextOnEnterEditText配置为true // 在selectTextOnEnterEditText时,如果是在keydown事件进入的节点编辑,也不需要全选 - this.focus(isInserting || (selectTextOnEnterEditText && !isFromKeyDown) ? 0 : null) + this.focus( + isInserting || (selectTextOnEnterEditText && !isFromKeyDown) ? 0 : null + ) if (!node.nodeData.data.richText) { // 如果是非富文本的情况,需要手动应用文本样式 this.setTextStyleIfNotRichText(node) @@ -373,7 +375,7 @@ class RichText { } }) // 拦截粘贴,只允许粘贴纯文本 - this.quill.clipboard.addMatcher(Node.TEXT_NODE, (node) => { + this.quill.clipboard.addMatcher(Node.TEXT_NODE, node => { let style = this.getPasteTextStyle() return new Delta().insert(node.data, style) }) diff --git a/simple-mind-map/src/plugins/Search.js b/simple-mind-map/src/plugins/Search.js index c3bf654f..77afa6df 100644 --- a/simple-mind-map/src/plugins/Search.js +++ b/simple-mind-map/src/plugins/Search.js @@ -1,4 +1,9 @@ -import { bfsWalk, getTextFromHtml, isUndef, replaceHtmlText } from '../utils/index' +import { + bfsWalk, + getTextFromHtml, + isUndef, + replaceHtmlText +} from '../utils/index' // 搜索插件 class Search { diff --git a/simple-mind-map/src/plugins/Watermark.js b/simple-mind-map/src/plugins/Watermark.js index cd6a3c98..c511be50 100644 --- a/simple-mind-map/src/plugins/Watermark.js +++ b/simple-mind-map/src/plugins/Watermark.js @@ -109,7 +109,10 @@ class Watermark { // 更新水印 updateWatermark(config) { - this.mindMap.opt.watermarkConfig = merge(this.mindMap.opt.watermarkConfig, config) + this.mindMap.opt.watermarkConfig = merge( + this.mindMap.opt.watermarkConfig, + config + ) this.handleConfig(config) this.draw() } @@ -117,4 +120,4 @@ class Watermark { Watermark.instanceName = 'watermark' -export default Watermark \ No newline at end of file +export default Watermark diff --git a/simple-mind-map/src/plugins/associativeLine/associativeLineText.js b/simple-mind-map/src/plugins/associativeLine/associativeLineText.js index deb812d9..b511d4ed 100644 --- a/simple-mind-map/src/plugins/associativeLine/associativeLineText.js +++ b/simple-mind-map/src/plugins/associativeLine/associativeLineText.js @@ -119,10 +119,8 @@ function getText(node, toNode) { // 渲染关联线文字 function renderText(str, path, text) { if (!str) return - let { - associativeLineTextFontSize, - associativeLineTextLineHeight - } = this.mindMap.themeConfig + let { associativeLineTextFontSize, associativeLineTextLineHeight } = + this.mindMap.themeConfig text.clear() let textArr = str.split(/\n/gim) textArr.forEach((item, index) => { diff --git a/simple-mind-map/src/themes/default.js b/simple-mind-map/src/themes/default.js index 34bd20b6..897a46d7 100644 --- a/simple-mind-map/src/themes/default.js +++ b/simple-mind-map/src/themes/default.js @@ -161,12 +161,14 @@ const nodeSizeIndependenceList = [ 'backgroundSize', 'rootLineKeepSameInCurve' ] -export const checkIsNodeSizeIndependenceConfig = (config) => { +export const checkIsNodeSizeIndependenceConfig = config => { let keys = Object.keys(config) - for(let i = 0; i < keys.length; i++) { - if (!nodeSizeIndependenceList.find((item) => { - return item === keys[i] - })) { + for (let i = 0; i < keys.length; i++) { + if ( + !nodeSizeIndependenceList.find(item => { + return item === keys[i] + }) + ) { return false } } diff --git a/simple-mind-map/src/utils/Lru.js b/simple-mind-map/src/utils/Lru.js index 0518a1fa..bb20162d 100644 --- a/simple-mind-map/src/utils/Lru.js +++ b/simple-mind-map/src/utils/Lru.js @@ -1,39 +1,38 @@ // LRU缓存类 export default class CRU { - constructor(max) { - this.max = max || 1000 - this.size = 0 - this.pool = new Map() - } + constructor(max) { + this.max = max || 1000 + this.size = 0 + this.pool = new Map() + } - add(key, value) { - // 如果该key是否已经存在,则先删除 - this.delete(key) - this.pool.set(key, value) - this.size++ - // 如果数量超出最大值,则删除最早的 - if (this.size > this.max) { - let keys = this.pool.keys() - let last = keys.next() - this.delete(last.value) - } - + add(key, value) { + // 如果该key是否已经存在,则先删除 + this.delete(key) + this.pool.set(key, value) + this.size++ + // 如果数量超出最大值,则删除最早的 + if (this.size > this.max) { + let keys = this.pool.keys() + let last = keys.next() + this.delete(last.value) } + } - delete(key) { - if (this.pool.has(key)) { - this.pool.delete(key) - this.size-- - } + delete(key) { + if (this.pool.has(key)) { + this.pool.delete(key) + this.size-- } + } - has(key) { - return this.pool.has(key) - } + has(key) { + return this.pool.has(key) + } - get(key) { - if (this.pool.has(key)) { - return this.pool.get(key) - } + get(key) { + if (this.pool.has(key)) { + return this.pool.get(key) } -} \ No newline at end of file + } +} diff --git a/simple-mind-map/src/utils/index.js b/simple-mind-map/src/utils/index.js index d9de6f48..babbdb0e 100644 --- a/simple-mind-map/src/utils/index.js +++ b/simple-mind-map/src/utils/index.js @@ -637,7 +637,7 @@ export const isMobile = () => { // 获取对象改变了的的属性 export const getObjectChangedProps = (oldObject, newObject) => { const res = {} - Object.keys(newObject).forEach((prop) => { + Object.keys(newObject).forEach(prop => { const oldVal = oldObject[prop] const newVal = newObject[prop] if (getType(oldVal) !== getType(newVal)) { @@ -660,7 +660,7 @@ export const getObjectChangedProps = (oldObject, newObject) => { } // 判断一个字段是否是节点数据中的样式字段 -export const checkIsNodeStyleDataKey = (key) => { +export const checkIsNodeStyleDataKey = key => { // 用户自定义字段 if (/^_/.test(key)) return false // 不在节点非样式字段列表里,那么就是样式字段 @@ -668,4 +668,4 @@ export const checkIsNodeStyleDataKey = (key) => { return true } return false -} \ No newline at end of file +} diff --git a/simple-mind-map/src/utils/simulateCSSBackgroundInCanvas.js b/simple-mind-map/src/utils/simulateCSSBackgroundInCanvas.js index 5f33b3bb..c11cd215 100644 --- a/simple-mind-map/src/utils/simulateCSSBackgroundInCanvas.js +++ b/simple-mind-map/src/utils/simulateCSSBackgroundInCanvas.js @@ -351,4 +351,4 @@ const drawBackgroundImageToCanvas = ( } } -export default drawBackgroundImageToCanvas \ No newline at end of file +export default drawBackgroundImageToCanvas diff --git a/simple-mind-map/types/index.d.ts b/simple-mind-map/types/index.d.ts new file mode 100644 index 00000000..709890d3 --- /dev/null +++ b/simple-mind-map/types/index.d.ts @@ -0,0 +1,166 @@ +export default MindMap +declare class MindMap { + /** + * + * @param {defaultOpt} opt + */ + constructor(opt?: { + readonly: boolean + layout: string + fishboneDeg: number + theme: string + themeConfig: {} + scaleRatio: number + mouseScaleCenterUseMousePosition: boolean + maxTag: number + expandBtnSize: number + imgTextMargin: number + textContentMargin: number + selectTranslateStep: number + selectTranslateLimit: number + customNoteContentShow: any + enableFreeDrag: boolean + watermarkConfig: { + text: string + lineSpacing: number + textSpacing: number + angle: number + textStyle: { + color: string + opacity: number + fontSize: number + } + } + textAutoWrapWidth: number + customHandleMousewheel: any + mousewheelAction: string + mousewheelMoveStep: number + mousewheelZoomActionReverse: boolean + defaultInsertSecondLevelNodeText: string + defaultInsertBelowSecondLevelNodeText: string + expandBtnStyle: { + color: string + fill: string + fontSize: number + strokeColor: string + } + expandBtnIcon: { + open: string + close: string + } + expandBtnNumHandler: (num: any) => any + isShowExpandNum: boolean + enableShortcutOnlyWhenMouseInSvg: boolean + initRootNodePosition: any + exportPaddingX: number + exportPaddingY: number + nodeTextEditZIndex: number + nodeNoteTooltipZIndex: number + isEndNodeTextEditOnClickOuter: boolean + maxHistoryCount: number + alwaysShowExpandBtn: boolean + iconList: any[] + maxNodeCacheCount: number + defaultAssociativeLineText: string + fitPadding: number + enableCtrlKeyNodeSelection: boolean + useLeftKeySelectionRightKeyDrag: boolean + beforeTextEdit: any + isUseCustomNodeContent: boolean + customCreateNodeContent: any + customInnerElsAppendTo: any + nodeDragPlaceholderMaxSize: number + enableAutoEnterTextEditWhenKeydown: boolean + richTextEditFakeInPlace: boolean + customHandleClipboardText: any + disableMouseWheelZoom: boolean + errorHandler: (code: any, error: any) => void + resetCss: string + enableDblclickReset: boolean + minExportImgCanvasScale: number + hoverRectColor: string + hoverRectPadding: number + selectTextOnEnterEditText: boolean + deleteNodeActive: boolean + autoMoveWhenMouseInEdgeOnDrag: boolean + }) + opt: any + el: any + elRect: any + width: any + height: any + cssEl: HTMLStyleElement + svg: any + draw: any + event: Event + keyCommand: KeyCommand + command: Command + renderer: Render + view: View + batchExecution: BatchExecution + handleOpt(opt: any): any + addCss(): void + removeCss(): void + render(callback: any, source?: string): void + reRender(callback: any, source?: string): void + resize(): void + on(event: any, fn: any): void + emit(event: any, ...args: any[]): void + off(event: any, fn: any): void + initCache(): void + initTheme(): void + themeConfig: any + setTheme(theme: any): void + getTheme(): any + setThemeConfig(config: any): void + getCustomThemeConfig(): any + getThemeConfig(prop: any): any + getConfig(prop: any): any + updateConfig(opt?: {}): void + getLayout(): any + setLayout(layout: any): void + execCommand(...args: any[]): void + setData(data: any): void + setFullData(data: any): void + getData(withConfig: any): any + export(...args: any[]): Promise + toPos( + x: any, + y: any + ): { + x: number + y: number + } + setMode(mode: any): void + getSvgData({ + paddingX, + paddingY + }?: { + paddingX?: number + paddingY?: number + }): { + svg: any + svgHTML: any + rect: any + origWidth: any + origHeight: any + scaleX: any + scaleY: any + } + addPlugin(plugin: any, opt: any): void + removePlugin(plugin: any): void + initPlugin(plugin: any): void + destroy(): void +} +declare namespace MindMap { + let pluginList: any[] + function usePlugin(plugin: any, opt?: {}): typeof MindMap + function hasPlugin(plugin: any): number + function defineTheme(name: any, config?: {}): Error +} +import Event from './src/core/event/Event' +import KeyCommand from './src/core/command/KeyCommand' +import Command from './src/core/command/Command' +import Render from './src/core/render/Render' +import View from './src/core/view/View' +import BatchExecution from './src/utils/BatchExecution' diff --git a/simple-mind-map/types/src/constants/constant.d.ts b/simple-mind-map/types/src/constants/constant.d.ts new file mode 100644 index 00000000..2d098d23 --- /dev/null +++ b/simple-mind-map/types/src/constants/constant.d.ts @@ -0,0 +1,113 @@ +export const tagColorList: { + color: string + background: string +}[] +export const themeList: { + name: string + value: string + dark: boolean +}[] +export namespace CONSTANTS { + let CHANGE_THEME: string + let CHANGE_LAYOUT: string + let SET_DATA: string + let TRANSFORM_TO_NORMAL_NODE: string + namespace MODE { + let READONLY: string + let EDIT: string + } + namespace LAYOUT { + let LOGICAL_STRUCTURE: string + let MIND_MAP: string + let ORGANIZATION_STRUCTURE: string + let CATALOG_ORGANIZATION: string + let TIMELINE: string + let TIMELINE2: string + let FISHBONE: string + let VERTICAL_TIMELINE: string + } + namespace DIR { + let UP: string + let LEFT: string + let DOWN: string + let RIGHT: string + } + namespace KEY_DIR { + let LEFT_1: string + export { LEFT_1 as LEFT } + let UP_1: string + export { UP_1 as UP } + let RIGHT_1: string + export { RIGHT_1 as RIGHT } + let DOWN_1: string + export { DOWN_1 as DOWN } + } + namespace SHAPE { + let RECTANGLE: string + let DIAMOND: string + let PARALLELOGRAM: string + let ROUNDED_RECTANGLE: string + let OCTAGONAL_RECTANGLE: string + let OUTER_TRIANGULAR_RECTANGLE: string + let INNER_TRIANGULAR_RECTANGLE: string + let ELLIPSE: string + let CIRCLE: string + } + namespace MOUSE_WHEEL_ACTION { + let ZOOM: string + let MOVE: string + } + namespace INIT_ROOT_NODE_POSITION { + let LEFT_2: string + export { LEFT_2 as LEFT } + export let TOP: string + let RIGHT_2: string + export { RIGHT_2 as RIGHT } + export let BOTTOM: string + export let CENTER: string + } + namespace LAYOUT_GROW_DIR { + let LEFT_3: string + export { LEFT_3 as LEFT } + let TOP_1: string + export { TOP_1 as TOP } + let RIGHT_3: string + export { RIGHT_3 as RIGHT } + let BOTTOM_1: string + export { BOTTOM_1 as BOTTOM } + } + namespace PASTE_TYPE { + let CLIP_BOARD: string + let CANVAS: string + } + namespace SCROLL_BAR_DIR { + let VERTICAL: string + let HORIZONTAL: string + } +} +export const initRootNodePositionMap: { + [x: string]: number +} +export const layoutList: { + name: string + value: string +}[] +export const layoutValueList: string[] +export const nodeDataNoStylePropList: string[] +export namespace commonCaches { + let measureCustomNodeContentSizeEl: any + let measureRichtextNodeTextSizeEl: any +} +export namespace ERROR_TYPES { + let READ_CLIPBOARD_ERROR: string + let PARSE_PASTE_DATA_ERROR: string + let CUSTOM_HANDLE_CLIPBOARD_TEXT_ERROR: string + let LOAD_CLIPBOARD_IMAGE_ERROR: string + let BEFORE_TEXT_EDIT_ERROR: string + let EXPORT_ERROR: string +} +export namespace a4Size { + let width: number + let height: number +} +export const cssContent: '\n /* 鼠标hover和激活时渲染的矩形 */\n .smm-hover-node{\n display: none;\n opacity: 0.6;\n stroke-width: 1;\n }\n\n .smm-node:hover .smm-hover-node{\n display: block;\n }\n\n .smm-node.active .smm-hover-node{\n display: block;\n opacity: 1;\n stroke-width: 2;\n }\n' diff --git a/simple-mind-map/types/src/constants/defaultOptions.d.ts b/simple-mind-map/types/src/constants/defaultOptions.d.ts new file mode 100644 index 00000000..b65804fa --- /dev/null +++ b/simple-mind-map/types/src/constants/defaultOptions.d.ts @@ -0,0 +1,82 @@ +export namespace defaultOpt { + let readonly: boolean + let layout: string + let fishboneDeg: number + let theme: string + let themeConfig: {} + let scaleRatio: number + let mouseScaleCenterUseMousePosition: boolean + let maxTag: number + let expandBtnSize: number + let imgTextMargin: number + let textContentMargin: number + let selectTranslateStep: number + let selectTranslateLimit: number + let customNoteContentShow: any + let enableFreeDrag: boolean + namespace watermarkConfig { + let text: string + let lineSpacing: number + let textSpacing: number + let angle: number + namespace textStyle { + let color: string + let opacity: number + let fontSize: number + } + } + let textAutoWrapWidth: number + let customHandleMousewheel: any + let mousewheelAction: string + let mousewheelMoveStep: number + let mousewheelZoomActionReverse: boolean + let defaultInsertSecondLevelNodeText: string + let defaultInsertBelowSecondLevelNodeText: string + namespace expandBtnStyle { + let color_1: string + export { color_1 as color } + export let fill: string + let fontSize_1: number + export { fontSize_1 as fontSize } + export let strokeColor: string + } + namespace expandBtnIcon { + let open: string + let close: string + } + function expandBtnNumHandler(num: any): any + let isShowExpandNum: boolean + let enableShortcutOnlyWhenMouseInSvg: boolean + let initRootNodePosition: any + let exportPaddingX: number + let exportPaddingY: number + let nodeTextEditZIndex: number + let nodeNoteTooltipZIndex: number + let isEndNodeTextEditOnClickOuter: boolean + let maxHistoryCount: number + let alwaysShowExpandBtn: boolean + let iconList: any[] + let maxNodeCacheCount: number + let defaultAssociativeLineText: string + let fitPadding: number + let enableCtrlKeyNodeSelection: boolean + let useLeftKeySelectionRightKeyDrag: boolean + let beforeTextEdit: any + let isUseCustomNodeContent: boolean + let customCreateNodeContent: any + let customInnerElsAppendTo: any + let nodeDragPlaceholderMaxSize: number + let enableAutoEnterTextEditWhenKeydown: boolean + let richTextEditFakeInPlace: boolean + let customHandleClipboardText: any + let disableMouseWheelZoom: boolean + function errorHandler(code: any, error: any): void + let resetCss: string + let enableDblclickReset: boolean + let minExportImgCanvasScale: number + let hoverRectColor: string + let hoverRectPadding: number + let selectTextOnEnterEditText: boolean + let deleteNodeActive: boolean + let autoMoveWhenMouseInEdgeOnDrag: boolean +} diff --git a/simple-mind-map/types/src/core/command/Command.d.ts b/simple-mind-map/types/src/core/command/Command.d.ts new file mode 100644 index 00000000..d4684f1b --- /dev/null +++ b/simple-mind-map/types/src/core/command/Command.d.ts @@ -0,0 +1,19 @@ +export default Command +declare class Command { + constructor(opt?: {}) + opt: {} + mindMap: any + commands: {} + history: any[] + activeHistoryIndex: number + addHistory(): void + clearHistory(): void + registerShortcutKeys(): void + exec(name: any, ...args: any[]): void + add(name: any, fn: any): void + remove(name: any, fn: any): void + back(step?: number): any + forward(step?: number): any + getCopyData(): any + removeDataUid(data: any): any +} diff --git a/simple-mind-map/types/src/core/command/KeyCommand.d.ts b/simple-mind-map/types/src/core/command/KeyCommand.d.ts new file mode 100644 index 00000000..8a6c8317 --- /dev/null +++ b/simple-mind-map/types/src/core/command/KeyCommand.d.ts @@ -0,0 +1,26 @@ +export default class KeyCommand { + constructor(opt: any) + opt: any + mindMap: any + shortcutMap: {} + shortcutMapCache: {} + isPause: boolean + isInSvg: boolean + pause(): void + recovery(): void + save(): void + restore(): void + bindEvent(): void + checkKey(e: any, key: any): boolean + getOriginEventCodeArr(e: any): any[] + hasCombinationKey(e: any): any + getKeyCodeArr(key: any): any[] + /** + * Enter + * Tab | Insert + * Shift + a + */ + addShortcut(key: any, fn: any): void + removeShortcut(key: any, fn: any): void + getShortcutFn(key: any): any[] +} diff --git a/simple-mind-map/types/src/core/command/keyMap.d.ts b/simple-mind-map/types/src/core/command/keyMap.d.ts new file mode 100644 index 00000000..80049249 --- /dev/null +++ b/simple-mind-map/types/src/core/command/keyMap.d.ts @@ -0,0 +1,42 @@ +export const keyMap: { + Backspace: number + Tab: number + Enter: number + Shift: number + Control: number + Alt: number + CapsLock: number + Esc: number + Spacebar: number + PageUp: number + PageDown: number + End: number + Home: number + Insert: number + Left: number + Up: number + Right: number + Down: number + Del: number + NumLock: number + Cmd: number + CmdFF: number + F1: number + F2: number + F3: number + F4: number + F5: number + F6: number + F7: number + F8: number + F9: number + F10: number + F11: number + F12: number + '`': number + '=': number + '-': number + '/': number + '.': number +} +export function isKey(e: any, key: any): boolean diff --git a/simple-mind-map/types/src/core/event/Event.d.ts b/simple-mind-map/types/src/core/event/Event.d.ts new file mode 100644 index 00000000..fb3706ff --- /dev/null +++ b/simple-mind-map/types/src/core/event/Event.d.ts @@ -0,0 +1,35 @@ +export default Event +declare class Event { + constructor(opt?: {}) + opt: {} + mindMap: any + isLeftMousedown: boolean + isRightMousedown: boolean + isMiddleMousedown: boolean + mousedownPos: { + x: number + y: number + } + mousemovePos: { + x: number + y: number + } + mousemoveOffset: { + x: number + y: number + } + bindFn(): void + onBodyClick(e: any): void + onDrawClick(e: any): void + onMousedown(e: any): void + onMousemove(e: any): void + onMouseup(e: any): void + onMousewheel(e: any): void + onContextmenu(e: any): void + onSvgMousedown(e: any): void + onKeyup(e: any): void + onMouseenter(e: any): void + onMouseleave(e: any): void + bind(): void + unbind(): void +} diff --git a/simple-mind-map/types/src/core/render/Render.d.ts b/simple-mind-map/types/src/core/render/Render.d.ts new file mode 100644 index 00000000..5e47e1f2 --- /dev/null +++ b/simple-mind-map/types/src/core/render/Render.d.ts @@ -0,0 +1,107 @@ +export default Render +declare class Render { + constructor(opt?: {}) + opt: {} + mindMap: any + themeConfig: any + draw: any + renderTree: any + reRender: boolean + isRendering: boolean + hasWaitRendering: boolean + nodeCache: {} + lastNodeCache: {} + renderSource: string + activeNodeList: any[] + root: any + textEdit: TextEdit + lastBeingCopyData: any + beingCopyData: any + beingPasteText: string + beingPasteImgSize: number + currentBeingPasteType: string + setLayout(): void + layout: + | MindMap + | CatalogOrganization + | OrganizationStructure + | Timeline + | VerticalTimeline + bindEvent(): void + registerCommands(): void + selectAll(): void + back(step: any): void + forward(step: any): void + insertNode( + openEdit?: boolean, + appointNodes?: any[], + appointData?: any, + appointChildren?: any[] + ): void + insertChildNode( + openEdit?: boolean, + appointNodes?: any[], + appointData?: any, + appointChildren?: any[] + ): void + upNode(): void + downNode(): void + insertAfter(node: any, exist: any): void + insertBefore(node: any, exist: any): void + moveNodeTo(node: any, toNode: any): void + removeNode(appointNodes?: any[]): void + pasteNode(data: any): void + cutNode(callback: any): any + setNodeStyle(node: any, prop: any, value: any): void + setNodeStyles(node: any, style: any): void + setNodeActive(node: any, active: any): void + clearAllActive(): void + setNodeExpand(node: any, expand: any): void + expandAllNode(): void + unexpandAllNode(): void + expandToLevel(level: any): void + setNodeData(node: any, data: any): void + setNodeText(node: any, text: any, richText: any, resetRichText: any): void + setNodeImage(node: any, data: any): void + setNodeIcon(node: any, icons: any): void + setNodeHyperlink(node: any, link: any, title?: string): void + setNodeNote(node: any, note: any): void + setNodeTag(node: any, tag: any): void + addGeneralization(data: any): void + removeGeneralization(): void + setNodeCustomPosition(node: any, left?: any, top?: any): void + resetLayout(): void + setNodeShape(node: any, shape: any): void + goTargetNode(node: any, callback?: () => void): void + registerShortcutKeys(): void + insertNodeWrap: () => void + toggleActiveExpand(): void + removeNodeWrap: () => void + copy(): void + cut(): void + startTextEdit(): void + endTextEdit(): void + render(callback: () => void, source: any): void + clearActive(): void + addActiveNode(node: any): void + removeActiveNode(node: any): void + findActiveNodeIndex(node: any): number + getNodeIndex(node: any): any + formatAppointNodes(appointNodes: any): any[] + setCoptyDataToClipboard(data: any): void + paste(): void + onPaste(): Promise + removeOneNode(node: any): void + copyNode(): any + toggleNodeExpand(node: any): void + setNodeDataRender(node: any, data: any, notRender?: boolean): void + moveNodeToCenter(node: any): void + expandToNodeUid(uid: any, callback?: () => void): void + findNodeByUid(uid: any): any +} +import TextEdit from './TextEdit' +import MindMap from '../../layouts/MindMap' +import CatalogOrganization from '../../layouts/CatalogOrganization' +import OrganizationStructure from '../../layouts/OrganizationStructure' +import Timeline from '../../layouts/Timeline' +import VerticalTimeline from '../../layouts/VerticalTimeline' diff --git a/simple-mind-map/types/src/core/render/TextEdit.d.ts b/simple-mind-map/types/src/core/render/TextEdit.d.ts new file mode 100644 index 00000000..1cbbd25d --- /dev/null +++ b/simple-mind-map/types/src/core/render/TextEdit.d.ts @@ -0,0 +1,29 @@ +export default class TextEdit { + constructor(renderer: any) + renderer: any + mindMap: any + currentNode: any + textEditNode: HTMLDivElement + showTextEdit: boolean + cacheEditingText: string + bindEvent(): void + show( + node: any, + e: any, + isInserting?: boolean, + isFromKeyDown?: boolean + ): Promise + onScale(): void + checkIsAutoEnterTextEditKey(e: any): boolean + registerTmpShortcut(): void + showEditTextBox( + node: any, + rect: any, + isInserting: any, + isFromKeyDown: any + ): void + focus(): void + selectNodeText(): void + getEditText(): any + hideEditTextBox(): any +} diff --git a/simple-mind-map/types/src/core/render/node/Node.d.ts b/simple-mind-map/types/src/core/render/node/Node.d.ts new file mode 100644 index 00000000..3f78f7c0 --- /dev/null +++ b/simple-mind-map/types/src/core/render/node/Node.d.ts @@ -0,0 +1,116 @@ +export default Node +declare class Node { + constructor(opt?: {}) + nodeData: any + uid: any + mindMap: any + renderer: any + draw: any + style: Style + shapeInstance: Shape + shapePadding: { + paddingX: number + paddingY: number + } + isRoot: any + isGeneralization: any + generalizationBelongNode: any + layerIndex: any + width: any + height: any + _left: any + _top: any + customLeft: any + customTop: any + isDrag: boolean + parent: any + children: any + group: any + shapeNode: any + hoverNode: any + _customNodeContent: any + _imgData: any + _iconData: any + _textData: any + _hyperlinkData: any + _tagData: any + _noteData: any + noteEl: any + _expandBtn: any + _lastExpandBtnType: any + _showExpandBtn: boolean + _openExpandNode: any + _closeExpandNode: any + _fillExpandNode: any + _lines: any[] + _generalizationLine: any + _generalizationNode: any + _unVisibleRectRegionNode: any + _isMouseenter: boolean + _rectInfo: { + imgContentWidth: number + imgContentHeight: number + textContentWidth: number + textContentHeight: number + } + _generalizationNodeWidth: number + _generalizationNodeHeight: number + textContentItemMargin: any + blockContentMargin: any + expandBtnSize: any + isMultipleChoice: boolean + needLayout: boolean + isHide: boolean + set left(arg: any) + get left(): any + set top(arg: any) + get top(): any + reset(): void + handleData(data: any): any + createNodeData(): void + getSize(): boolean + getNodeRect(): { + width: any + height: any + } + layout(): void + bindGroupEvent(): void + active(e: any): void + update(): void + getNodePosInClient( + _left: any, + _top: any + ): { + left: any + top: any + } + reRender(): boolean + updateNodeActive(): void + render(callback?: () => void): void + remove(): void + destroy(): void + hide(): void + show(): void + renderLine(deep?: boolean): void + getShape(): any + hasCustomPosition(): boolean + ancestorHasCustomPosition(): boolean + addChildren(node: any): void + styleLine(line: any, node: any): void + removeLine(): void + isParent(node: any): boolean + isBrother(node: any): any + getPaddingVale(): { + paddingX: any + paddingY: any + } + getStyle(prop: any, root: any): any + getSelfStyle(prop: any): any + getParentSelfStyle(prop: any): any + getSelfInhertStyle(prop: any): any + getBorderWidth(): any + getData(key: any): any + hasCustomStyle(): boolean +} +import Style from './Style' +import Shape from './Shape' diff --git a/simple-mind-map/types/src/core/render/node/Shape.d.ts b/simple-mind-map/types/src/core/render/node/Shape.d.ts new file mode 100644 index 00000000..e30ee14b --- /dev/null +++ b/simple-mind-map/types/src/core/render/node/Shape.d.ts @@ -0,0 +1,28 @@ +export default class Shape { + constructor(node: any) + node: any + getShapePadding( + width: any, + height: any, + paddingX: any, + paddingY: any + ): { + paddingX: number + paddingY: number + } + createShape(): any + getNodeSize(): { + width: any + height: any + } + createRect(): any + createDiamond(): any + createParallelogram(): any + createRoundedRectangle(): any + createOctagonalRectangle(): any + createOuterTriangularRectangle(): any + createInnerTriangularRectangle(): any + createEllipse(): any + createCircle(): any +} +export const shapeList: string[] diff --git a/simple-mind-map/types/src/core/render/node/Style.d.ts b/simple-mind-map/types/src/core/render/node/Style.d.ts new file mode 100644 index 00000000..c4bbe42f --- /dev/null +++ b/simple-mind-map/types/src/core/render/node/Style.d.ts @@ -0,0 +1,43 @@ +export default Style +declare class Style { + static setBackgroundStyle(el: any, themeConfig: any): void + static removeBackgroundStyle(el: any): void + constructor(ctx: any) + ctx: any + merge(prop: any, root: any): any + getStyle(prop: any, root: any): any + getSelfStyle(prop: any): any + rect(node: any): void + shape(node: any): void + text(node: any): void + createStyleText(): string + getTextFontStyle(): { + italic: boolean + bold: any + fontSize: any + fontFamily: any + } + domText(node: any, fontSizeScale: number, isMultiLine: any): void + tagText(node: any, index: any): void + tagRect(node: any, index: any): void + iconNode(node: any): void + line( + node: any, + { + width, + color, + dasharray + }?: { + width: any + color: any + dasharray: any + } + ): void + generalizationLine(node: any): void + iconBtn(node: any, node2: any, fillNode: any): void + hasCustomStyle(): boolean + hoverNode(node: any): void +} +declare namespace Style { + let cacheStyle: any +} diff --git a/simple-mind-map/types/src/core/render/node/nodeCommandWraps.d.ts b/simple-mind-map/types/src/core/render/node/nodeCommandWraps.d.ts new file mode 100644 index 00000000..4b286026 --- /dev/null +++ b/simple-mind-map/types/src/core/render/node/nodeCommandWraps.d.ts @@ -0,0 +1,23 @@ +declare namespace _default { + export { setData } + export { setText } + export { setImage } + export { setIcon } + export { setHyperlink } + export { setNote } + export { setTag } + export { setShape } + export { setStyle } + export { setStyles } +} +export default _default +declare function setData(data?: {}): void +declare function setText(text: any, richText: any, resetRichText: any): void +declare function setImage(imgData: any): void +declare function setIcon(icons: any): void +declare function setHyperlink(link: any, title: any): void +declare function setNote(note: any): void +declare function setTag(tag: any): void +declare function setShape(shape: any): void +declare function setStyle(prop: any, value: any): void +declare function setStyles(style: any): void diff --git a/simple-mind-map/types/src/core/render/node/nodeCreateContents.d.ts b/simple-mind-map/types/src/core/render/node/nodeCreateContents.d.ts new file mode 100644 index 00000000..31886fa9 --- /dev/null +++ b/simple-mind-map/types/src/core/render/node/nodeCreateContents.d.ts @@ -0,0 +1,45 @@ +declare namespace _default { + export { createImgNode } + export { getImgShowSize } + export { createIconNode } + export { createRichTextNode } + export { createTextNode } + export { createHyperlinkNode } + export { createTagNode } + export { createNoteNode } + export { measureCustomNodeContentSize } + export { isUseCustomNodeContent } +} +export default _default +declare function createImgNode(): { + node: any + width: any + height: any +} +declare function getImgShowSize(): any +declare function createIconNode(): any +declare function createRichTextNode(): { + node: any + width: any + height: any +} +declare function createTextNode(): any +declare function createHyperlinkNode(): { + node: any + width: any + height: any +} +declare function createTagNode(): any[] +declare function createNoteNode(): { + node: any + width: any + height: any +} +declare class createNoteNode { + noteEl: HTMLDivElement +} +declare function measureCustomNodeContentSize(content: any): { + width: any + height: any +} +declare function isUseCustomNodeContent(): boolean diff --git a/simple-mind-map/types/src/core/render/node/nodeExpandBtn.d.ts b/simple-mind-map/types/src/core/render/node/nodeExpandBtn.d.ts new file mode 100644 index 00000000..7de1ef79 --- /dev/null +++ b/simple-mind-map/types/src/core/render/node/nodeExpandBtn.d.ts @@ -0,0 +1,34 @@ +declare namespace _default { + export { createExpandNodeContent } + export { updateExpandBtnNode } + export { updateExpandBtnPos } + export { renderExpandBtn } + export { removeExpandBtn } + export { showExpandBtn } + export { hideExpandBtn } + export { sumNode } +} +export default _default +declare function createExpandNodeContent(): void +declare class createExpandNodeContent { + _openExpandNode: any + _closeExpandNode: any + _fillExpandNode: any +} +declare function updateExpandBtnNode(): void +declare class updateExpandBtnNode { + _lastExpandBtnType: boolean +} +declare function updateExpandBtnPos(): void +declare function renderExpandBtn(): void +declare class renderExpandBtn { + _expandBtn: any + _showExpandBtn: boolean +} +declare function removeExpandBtn(): void +declare class removeExpandBtn { + _showExpandBtn: boolean +} +declare function showExpandBtn(): void +declare function hideExpandBtn(): void +declare function sumNode(data?: any[]): any diff --git a/simple-mind-map/types/src/core/render/node/nodeExpandBtnPlaceholderRect.d.ts b/simple-mind-map/types/src/core/render/node/nodeExpandBtnPlaceholderRect.d.ts new file mode 100644 index 00000000..6506b0f2 --- /dev/null +++ b/simple-mind-map/types/src/core/render/node/nodeExpandBtnPlaceholderRect.d.ts @@ -0,0 +1,18 @@ +declare namespace _default { + export { renderExpandBtnPlaceholderRect } + export { clearExpandBtnPlaceholderRect } + export { updateExpandBtnPlaceholderRect } +} +export default _default +declare function renderExpandBtnPlaceholderRect(): void +declare class renderExpandBtnPlaceholderRect { + _unVisibleRectRegionNode: any +} +declare function clearExpandBtnPlaceholderRect(): void +declare class clearExpandBtnPlaceholderRect { + _unVisibleRectRegionNode: any +} +declare function updateExpandBtnPlaceholderRect(): void +declare class updateExpandBtnPlaceholderRect { + needRerenderExpandBtnPlaceholderRect: boolean +} diff --git a/simple-mind-map/types/src/core/render/node/nodeGeneralization.d.ts b/simple-mind-map/types/src/core/render/node/nodeGeneralization.d.ts new file mode 100644 index 00000000..723a7efc --- /dev/null +++ b/simple-mind-map/types/src/core/render/node/nodeGeneralization.d.ts @@ -0,0 +1,32 @@ +declare namespace _default { + export { checkHasGeneralization } + export { createGeneralizationNode } + export { updateGeneralization } + export { renderGeneralization } + export { removeGeneralization } + export { hideGeneralization } + export { showGeneralization } +} +export default _default +declare function checkHasGeneralization(): boolean +declare function createGeneralizationNode(): void +declare class createGeneralizationNode { + _generalizationLine: any + _generalizationNode: Node + _generalizationNodeWidth: any + _generalizationNodeHeight: any +} +declare function updateGeneralization(): void +declare function renderGeneralization(): void +declare class renderGeneralization { + _generalizationNodeWidth: number + _generalizationNodeHeight: number +} +declare function removeGeneralization(): void +declare class removeGeneralization { + _generalizationLine: any + _generalizationNode: any +} +declare function hideGeneralization(): void +declare function showGeneralization(): void +import Node from './Node' diff --git a/simple-mind-map/types/src/core/view/View.d.ts b/simple-mind-map/types/src/core/view/View.d.ts new file mode 100644 index 00000000..6f095673 --- /dev/null +++ b/simple-mind-map/types/src/core/view/View.d.ts @@ -0,0 +1,36 @@ +export default View +declare class View { + constructor(opt?: {}) + opt: {} + mindMap: any + scale: number + sx: number + sy: number + x: number + y: number + firstDrag: boolean + bind(): void + getTransformData(): { + transform: any + state: { + scale: number + x: number + y: number + sx: number + sy: number + } + } + setTransformData(viewData: any): void + translateXY(x: any, y: any): void + translateX(step: any): void + translateXTo(x: any): void + translateY(step: any): void + translateYTo(y: any): void + transform(): void + reset(): void + narrow(cx: any, cy: any, isTouchPad: any): void + enlarge(cx: any, cy: any, isTouchPad: any): void + scaleInCenter(scale: any, cx: any, cy: any): void + setScale(scale: any, cx: any, cy: any): void + fit(): void +} diff --git a/simple-mind-map/types/src/layouts/Base.d.ts b/simple-mind-map/types/src/layouts/Base.d.ts new file mode 100644 index 00000000..876662e0 --- /dev/null +++ b/simple-mind-map/types/src/layouts/Base.d.ts @@ -0,0 +1,46 @@ +export default Base +declare class Base { + constructor(renderer: any) + renderer: any + mindMap: any + draw: any + root: any + lru: Lru + doLayout(): void + renderLine(): void + renderExpandBtn(): void + renderGeneralization(): void + cacheNode(uid: any, node: any): void + checkIsNeedResizeSources(): boolean + checkIsLayerTypeChange(oldIndex: any, newIndex: any): boolean + checkIsLayoutChangeRerenderExpandBtnPlaceholderRect(node: any): void + createNode(data: any, parent: any, isRoot: any, layerIndex: any): any + formatPosition(value: any, size: any, nodeSize: any): number + setNodeCenter(node: any): void + updateChildren(children: any, prop: any, offset: any): void + updateChildrenPro(children: any, props: any): void + getNodeAreaWidth(node: any, withGeneralization?: boolean): number + quadraticCurvePath(x1: any, y1: any, x2: any, y2: any): string + cubicBezierPath(x1: any, y1: any, x2: any, y2: any): string + getMarginX(layerIndex: any): any + getMarginY(layerIndex: any): any + getNodeWidthWithGeneralization(node: any): number + getNodeHeightWithGeneralization(node: any): number + /** + * dir:生长方向,h(水平)、v(垂直) + * isLeft:是否向左生长 + */ + getNodeBoundaries( + node: any, + dir: any + ): { + left: any + right: any + top: any + bottom: any + generalizationLineMargin: any + generalizationNodeMargin: any + } + getNodeActChildrenLength(node: any): any +} +import Lru from '../utils/Lru' diff --git a/simple-mind-map/types/src/layouts/CatalogOrganization.d.ts b/simple-mind-map/types/src/layouts/CatalogOrganization.d.ts new file mode 100644 index 00000000..4f735710 --- /dev/null +++ b/simple-mind-map/types/src/layouts/CatalogOrganization.d.ts @@ -0,0 +1,21 @@ +export default CatalogOrganization +declare class CatalogOrganization extends Base { + constructor(opt?: {}) + doLayout(callback: any): void + computedBaseValue(): void + computedLeftTopValue(): void + adjustLeftTopValue(): void + updateBrothersLeft(node: any, addWidth: any): void + updateBrothersTop(node: any, addHeight: any): void + renderLine(node: any, lines: any, style: any): any[] + renderExpandBtn(node: any, btn: any): void + renderGeneralization(node: any, gLine: any, gNode: any): void + renderExpandBtnRect( + rect: any, + expandBtnSize: any, + width: any, + height: any, + node: any + ): void +} +import Base from './Base' diff --git a/simple-mind-map/types/src/layouts/Fishbone.d.ts b/simple-mind-map/types/src/layouts/Fishbone.d.ts new file mode 100644 index 00000000..faee290d --- /dev/null +++ b/simple-mind-map/types/src/layouts/Fishbone.d.ts @@ -0,0 +1,25 @@ +export default Fishbone +declare class Fishbone extends Base { + constructor(opt?: {}) + indent: number + childIndent: number + doLayout(callback: any): void + computedBaseValue(): void + computedLeftTopValue(): void + adjustLeftTopValue(): void + getNodeAreaHeight(node: any): number + updateBrothersLeft(node: any): void + updateBrothersTop(node: any, addHeight: any): void + checkIsTop(node: any): boolean + renderLine(node: any, lines: any, style: any): any[] + renderExpandBtn(node: any, btn: any): void + renderGeneralization(node: any, gLine: any, gNode: any): void + renderExpandBtnRect( + rect: any, + expandBtnSize: any, + width: any, + height: any, + node: any + ): void +} +import Base from './Base' diff --git a/simple-mind-map/types/src/layouts/LogicalStructure.d.ts b/simple-mind-map/types/src/layouts/LogicalStructure.d.ts new file mode 100644 index 00000000..73d8bc56 --- /dev/null +++ b/simple-mind-map/types/src/layouts/LogicalStructure.d.ts @@ -0,0 +1,23 @@ +export default LogicalStructure +declare class LogicalStructure extends Base { + constructor(opt?: {}) + doLayout(callback: any): void + computedBaseValue(): void + computedTopValue(): void + adjustTopValue(): void + updateBrothers(node: any, addHeight: any): void + renderLine(node: any, lines: any, style: any, lineStyle: any): void + renderLineStraight(node: any, lines: any, style: any): any[] + renderLineDirect(node: any, lines: any, style: any): any[] + renderLineCurve(node: any, lines: any, style: any): any[] + renderExpandBtn(node: any, btn: any): void + renderGeneralization(node: any, gLine: any, gNode: any): void + renderExpandBtnRect( + rect: any, + expandBtnSize: any, + width: any, + height: any, + node: any + ): void +} +import Base from './Base' diff --git a/simple-mind-map/types/src/layouts/MindMap.d.ts b/simple-mind-map/types/src/layouts/MindMap.d.ts new file mode 100644 index 00000000..be1eeaa0 --- /dev/null +++ b/simple-mind-map/types/src/layouts/MindMap.d.ts @@ -0,0 +1,23 @@ +export default MindMap +declare class MindMap extends Base { + constructor(opt?: {}) + doLayout(callback: any): void + computedBaseValue(): void + computedTopValue(): void + adjustTopValue(): void + updateBrothers(node: any, leftAddHeight: any, rightAddHeight: any): void + renderLine(node: any, lines: any, style: any, lineStyle: any): void + renderLineStraight(node: any, lines: any, style: any): any[] + renderLineDirect(node: any, lines: any, style: any): any[] + renderLineCurve(node: any, lines: any, style: any): any[] + renderExpandBtn(node: any, btn: any): void + renderGeneralization(node: any, gLine: any, gNode: any): void + renderExpandBtnRect( + rect: any, + expandBtnSize: any, + width: any, + height: any, + node: any + ): void +} +import Base from './Base' diff --git a/simple-mind-map/types/src/layouts/OrganizationStructure.d.ts b/simple-mind-map/types/src/layouts/OrganizationStructure.d.ts new file mode 100644 index 00000000..3b07bfe0 --- /dev/null +++ b/simple-mind-map/types/src/layouts/OrganizationStructure.d.ts @@ -0,0 +1,22 @@ +export default OrganizationStructure +declare class OrganizationStructure extends Base { + constructor(opt?: {}) + doLayout(callback: any): void + computedBaseValue(): void + computedLeftValue(): void + adjustLeftValue(): void + updateBrothers(node: any, addWidth: any): void + renderLine(node: any, lines: any, style: any, lineStyle: any): void + renderLineDirect(node: any, lines: any, style: any): any[] + renderLineStraight(node: any, lines: any, style: any): any[] + renderExpandBtn(node: any, btn: any): void + renderGeneralization(node: any, gLine: any, gNode: any): void + renderExpandBtnRect( + rect: any, + expandBtnSize: any, + width: any, + height: any, + node: any + ): void +} +import Base from './Base' diff --git a/simple-mind-map/types/src/layouts/Timeline.d.ts b/simple-mind-map/types/src/layouts/Timeline.d.ts new file mode 100644 index 00000000..c229829a --- /dev/null +++ b/simple-mind-map/types/src/layouts/Timeline.d.ts @@ -0,0 +1,23 @@ +export default Timeline +declare class Timeline extends Base { + constructor(opt: {}, layout: any) + layout: any + doLayout(callback: any): void + computedBaseValue(): void + computedLeftTopValue(): void + adjustLeftTopValue(): void + getNodeAreaHeight(node: any): number + updateBrothersLeft(node: any): void + updateBrothersTop(node: any, addHeight: any): void + renderLine(node: any, lines: any, style: any): any[] + renderExpandBtn(node: any, btn: any): void + renderGeneralization(node: any, gLine: any, gNode: any): void + renderExpandBtnRect( + rect: any, + expandBtnSize: any, + width: any, + height: any, + node: any + ): void +} +import Base from './Base' diff --git a/simple-mind-map/types/src/layouts/VerticalTimeline.d.ts b/simple-mind-map/types/src/layouts/VerticalTimeline.d.ts new file mode 100644 index 00000000..7de96333 --- /dev/null +++ b/simple-mind-map/types/src/layouts/VerticalTimeline.d.ts @@ -0,0 +1,25 @@ +export default VerticalTimeline +declare class VerticalTimeline extends Base { + constructor(opt: {}, layout: any) + layout: any + doLayout(callback: any): void + computedBaseValue(): void + computedTopValue(): void + adjustLeftTopValue(): void + updateBrothers(node: any, addHeight: any): void + updateBrothersTop(node: any, addHeight: any): void + renderLine(node: any, lines: any, style: any, lineStyle: any): void + renderLineStraight(node: any, lines: any, style: any): any[] + renderLineDirect(node: any, lines: any, style: any): any[] + renderLineCurve(node: any, lines: any, style: any): any[] + renderExpandBtn(node: any, btn: any): void + renderGeneralization(node: any, gLine: any, gNode: any): void + renderExpandBtnRect( + rect: any, + expandBtnSize: any, + width: any, + height: any, + node: any + ): void +} +import Base from './Base' diff --git a/simple-mind-map/types/src/layouts/fishboneUtils.d.ts b/simple-mind-map/types/src/layouts/fishboneUtils.d.ts new file mode 100644 index 00000000..6e3cf22d --- /dev/null +++ b/simple-mind-map/types/src/layouts/fishboneUtils.d.ts @@ -0,0 +1,137 @@ +declare namespace _default { + namespace top { + function renderExpandBtn({ + node, + btn, + expandBtnSize, + translateX, + translateY, + width, + height + }: { + node: any + btn: any + expandBtnSize: any + translateX: any + translateY: any + width: any + height: any + }): void + function renderLine({ + node, + line, + top, + x, + lineLength, + height, + expandBtnSize, + maxy, + ctx + }: { + node: any + line: any + top: any + x: any + lineLength: any + height: any + expandBtnSize: any + maxy: any + ctx: any + }): void + function computedLeftTopValue({ + layerIndex, + node, + ctx + }: { + layerIndex: any + node: any + ctx: any + }): void + function adjustLeftTopValueBefore({ + node, + parent, + ctx, + layerIndex + }: { + node: any + parent: any + ctx: any + layerIndex: any + }): void + function adjustLeftTopValueAfter({ + parent, + node, + ctx + }: { + parent: any + node: any + ctx: any + }): void + } + namespace bottom { + function renderExpandBtn({ + node, + btn, + expandBtnSize, + translateX, + translateY, + width, + height + }: { + node: any + btn: any + expandBtnSize: any + translateX: any + translateY: any + width: any + height: any + }): void + function renderLine({ + node, + line, + top, + x, + lineLength, + height, + miny, + ctx + }: { + node: any + line: any + top: any + x: any + lineLength: any + height: any + miny: any + ctx: any + }): void + function computedLeftTopValue({ + layerIndex, + node, + ctx + }: { + layerIndex: any + node: any + ctx: any + }): void + function adjustLeftTopValueBefore({ + node, + ctx, + layerIndex + }: { + node: any + ctx: any + layerIndex: any + }): void + function adjustLeftTopValueAfter({ + parent, + node, + ctx + }: { + parent: any + node: any + ctx: any + }): void + } +} +export default _default diff --git a/simple-mind-map/types/src/svg/btns.d.ts b/simple-mind-map/types/src/svg/btns.d.ts new file mode 100644 index 00000000..1805faf9 --- /dev/null +++ b/simple-mind-map/types/src/svg/btns.d.ts @@ -0,0 +1,11 @@ +declare namespace _default { + export { open } + export { close } + export { remove } + export { imgAdjust } +} +export default _default +declare const open: '' +declare const close: '' +declare const remove: '' +declare const imgAdjust: '' diff --git a/simple-mind-map/types/src/svg/icons.d.ts b/simple-mind-map/types/src/svg/icons.d.ts new file mode 100644 index 00000000..d6bf9332 --- /dev/null +++ b/simple-mind-map/types/src/svg/icons.d.ts @@ -0,0 +1,18 @@ +export const nodeIconList: { + name: string + type: string + list: { + name: string + icon: string + }[] +}[] +declare namespace _default { + export { hyperlink } + export { note } + export { nodeIconList } + export { getNodeIconListIcon } +} +export default _default +declare const hyperlink: '' +declare const note: '' +declare function getNodeIconListIcon(name: any, extendIconList?: any[]): any diff --git a/simple-mind-map/types/src/themes/autumn.d.ts b/simple-mind-map/types/src/themes/autumn.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/autumn.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/avocado.d.ts b/simple-mind-map/types/src/themes/avocado.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/avocado.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/blackGold.d.ts b/simple-mind-map/types/src/themes/blackGold.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/blackGold.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/blackHumour.d.ts b/simple-mind-map/types/src/themes/blackHumour.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/blackHumour.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/blueSky.d.ts b/simple-mind-map/types/src/themes/blueSky.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/blueSky.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/brainImpairedPink.d.ts b/simple-mind-map/types/src/themes/brainImpairedPink.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/brainImpairedPink.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/classic.d.ts b/simple-mind-map/types/src/themes/classic.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/classic.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/classic2.d.ts b/simple-mind-map/types/src/themes/classic2.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/classic2.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/classic3.d.ts b/simple-mind-map/types/src/themes/classic3.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/classic3.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/classic4.d.ts b/simple-mind-map/types/src/themes/classic4.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/classic4.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/classicBlue.d.ts b/simple-mind-map/types/src/themes/classicBlue.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/classicBlue.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/classicGreen.d.ts b/simple-mind-map/types/src/themes/classicGreen.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/classicGreen.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/coffee.d.ts b/simple-mind-map/types/src/themes/coffee.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/coffee.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/courseGreen.d.ts b/simple-mind-map/types/src/themes/courseGreen.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/courseGreen.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/dark.d.ts b/simple-mind-map/types/src/themes/dark.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/dark.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/dark2.d.ts b/simple-mind-map/types/src/themes/dark2.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/dark2.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/default.d.ts b/simple-mind-map/types/src/themes/default.d.ts new file mode 100644 index 00000000..340bce46 --- /dev/null +++ b/simple-mind-map/types/src/themes/default.d.ts @@ -0,0 +1,143 @@ +declare namespace _default { + let paddingX: number + let paddingY: number + let imgMaxWidth: number + let imgMaxHeight: number + let iconSize: number + let lineWidth: number + let lineColor: string + let lineDasharray: string + let lineStyle: string + let rootLineKeepSameInCurve: boolean + let generalizationLineWidth: number + let generalizationLineColor: string + let generalizationLineMargin: number + let generalizationNodeMargin: number + let associativeLineWidth: number + let associativeLineColor: string + let associativeLineActiveWidth: number + let associativeLineActiveColor: string + let associativeLineTextColor: string + let associativeLineTextFontSize: number + let associativeLineTextLineHeight: number + let associativeLineTextFontFamily: string + let backgroundColor: string + let backgroundImage: string + let backgroundRepeat: string + let backgroundPosition: string + let backgroundSize: string + let nodeUseLineStyle: boolean + namespace root { + let shape: string + let fillColor: string + let fontFamily: string + let color: string + let fontSize: number + let fontWeight: string + let fontStyle: string + let lineHeight: number + let borderColor: string + let borderWidth: number + let borderDasharray: string + let borderRadius: number + let textDecoration: string + } + namespace second { + let shape_1: string + export { shape_1 as shape } + export let marginX: number + export let marginY: number + let fillColor_1: string + export { fillColor_1 as fillColor } + let fontFamily_1: string + export { fontFamily_1 as fontFamily } + let color_1: string + export { color_1 as color } + let fontSize_1: number + export { fontSize_1 as fontSize } + let fontWeight_1: string + export { fontWeight_1 as fontWeight } + let fontStyle_1: string + export { fontStyle_1 as fontStyle } + let lineHeight_1: number + export { lineHeight_1 as lineHeight } + let borderColor_1: string + export { borderColor_1 as borderColor } + let borderWidth_1: number + export { borderWidth_1 as borderWidth } + let borderDasharray_1: string + export { borderDasharray_1 as borderDasharray } + let borderRadius_1: number + export { borderRadius_1 as borderRadius } + let textDecoration_1: string + export { textDecoration_1 as textDecoration } + } + namespace node { + let shape_2: string + export { shape_2 as shape } + let marginX_1: number + export { marginX_1 as marginX } + let marginY_1: number + export { marginY_1 as marginY } + let fillColor_2: string + export { fillColor_2 as fillColor } + let fontFamily_2: string + export { fontFamily_2 as fontFamily } + let color_2: string + export { color_2 as color } + let fontSize_2: number + export { fontSize_2 as fontSize } + let fontWeight_2: string + export { fontWeight_2 as fontWeight } + let fontStyle_2: string + export { fontStyle_2 as fontStyle } + let lineHeight_2: number + export { lineHeight_2 as lineHeight } + let borderColor_2: string + export { borderColor_2 as borderColor } + let borderWidth_2: number + export { borderWidth_2 as borderWidth } + let borderRadius_2: number + export { borderRadius_2 as borderRadius } + let borderDasharray_2: string + export { borderDasharray_2 as borderDasharray } + let textDecoration_2: string + export { textDecoration_2 as textDecoration } + } + namespace generalization { + let shape_3: string + export { shape_3 as shape } + let marginX_2: number + export { marginX_2 as marginX } + let marginY_2: number + export { marginY_2 as marginY } + let fillColor_3: string + export { fillColor_3 as fillColor } + let fontFamily_3: string + export { fontFamily_3 as fontFamily } + let color_3: string + export { color_3 as color } + let fontSize_3: number + export { fontSize_3 as fontSize } + let fontWeight_3: string + export { fontWeight_3 as fontWeight } + let fontStyle_3: string + export { fontStyle_3 as fontStyle } + let lineHeight_3: number + export { lineHeight_3 as lineHeight } + let borderColor_3: string + export { borderColor_3 as borderColor } + let borderWidth_3: number + export { borderWidth_3 as borderWidth } + let borderDasharray_3: string + export { borderDasharray_3 as borderDasharray } + let borderRadius_3: number + export { borderRadius_3 as borderRadius } + let textDecoration_3: string + export { textDecoration_3 as textDecoration } + } +} +export default _default +export const supportActiveStyle: string[] +export function checkIsNodeSizeIndependenceConfig(config: any): boolean +export const lineStyleProps: string[] diff --git a/simple-mind-map/types/src/themes/earthYellow.d.ts b/simple-mind-map/types/src/themes/earthYellow.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/earthYellow.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/freshGreen.d.ts b/simple-mind-map/types/src/themes/freshGreen.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/freshGreen.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/freshRed.d.ts b/simple-mind-map/types/src/themes/freshRed.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/freshRed.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/gold.d.ts b/simple-mind-map/types/src/themes/gold.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/gold.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/greenLeaf.d.ts b/simple-mind-map/types/src/themes/greenLeaf.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/greenLeaf.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/index.d.ts b/simple-mind-map/types/src/themes/index.d.ts new file mode 100644 index 00000000..7c4ac003 --- /dev/null +++ b/simple-mind-map/types/src/themes/index.d.ts @@ -0,0 +1,67 @@ +declare namespace _default { + export { defaultTheme as default } + export { freshGreen } + export { blueSky } + export { brainImpairedPink } + export { romanticPurple } + export { freshRed } + export { earthYellow } + export { classic } + export { classic2 } + export { classic3 } + export { classic4 } + export { dark } + export { classicGreen } + export { classicBlue } + export { minions } + export { pinkGrape } + export { mint } + export { gold } + export { vitalityOrange } + export { greenLeaf } + export { dark2 } + export { skyGreen } + export { simpleBlack } + export { courseGreen } + export { coffee } + export { redSpirit } + export { blackHumour } + export { lateNightOffice } + export { blackGold } + export { avocado } + export { autumn } + export { orangeJuice } +} +export default _default +import defaultTheme from './default' +import freshGreen from './freshGreen' +import blueSky from './blueSky' +import brainImpairedPink from './brainImpairedPink' +import romanticPurple from './romanticPurple' +import freshRed from './freshRed' +import earthYellow from './earthYellow' +import classic from './classic' +import classic2 from './classic2' +import classic3 from './classic3' +import classic4 from './classic4' +import dark from './dark' +import classicGreen from './classicGreen' +import classicBlue from './classicBlue' +import minions from './minions' +import pinkGrape from './pinkGrape' +import mint from './mint' +import gold from './gold' +import vitalityOrange from './vitalityOrange' +import greenLeaf from './greenLeaf' +import dark2 from './dark2' +import skyGreen from './skyGreen' +import simpleBlack from './simpleBlack' +import courseGreen from './courseGreen' +import coffee from './coffee' +import redSpirit from './redSpirit' +import blackHumour from './blackHumour' +import lateNightOffice from './lateNightOffice' +import blackGold from './blackGold' +import avocado from './avocado' +import autumn from './autumn' +import orangeJuice from './orangeJuice' diff --git a/simple-mind-map/types/src/themes/lateNightOffice.d.ts b/simple-mind-map/types/src/themes/lateNightOffice.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/lateNightOffice.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/minions.d.ts b/simple-mind-map/types/src/themes/minions.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/minions.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/mint.d.ts b/simple-mind-map/types/src/themes/mint.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/mint.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/orangeJuice.d.ts b/simple-mind-map/types/src/themes/orangeJuice.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/orangeJuice.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/pinkGrape.d.ts b/simple-mind-map/types/src/themes/pinkGrape.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/pinkGrape.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/redSpirit.d.ts b/simple-mind-map/types/src/themes/redSpirit.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/redSpirit.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/romanticPurple.d.ts b/simple-mind-map/types/src/themes/romanticPurple.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/romanticPurple.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/simpleBlack.d.ts b/simple-mind-map/types/src/themes/simpleBlack.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/simpleBlack.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/skyGreen.d.ts b/simple-mind-map/types/src/themes/skyGreen.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/skyGreen.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/themes/vitalityOrange.d.ts b/simple-mind-map/types/src/themes/vitalityOrange.d.ts new file mode 100644 index 00000000..c461e215 --- /dev/null +++ b/simple-mind-map/types/src/themes/vitalityOrange.d.ts @@ -0,0 +1,2 @@ +declare const _default: any +export default _default diff --git a/simple-mind-map/types/src/utils/BatchExecution.d.ts b/simple-mind-map/types/src/utils/BatchExecution.d.ts new file mode 100644 index 00000000..f2009e8a --- /dev/null +++ b/simple-mind-map/types/src/utils/BatchExecution.d.ts @@ -0,0 +1,8 @@ +export default BatchExecution +declare class BatchExecution { + has: {} + queue: any[] + nextTick: any + push(name: any, fn: any): void + flush(): void +} diff --git a/simple-mind-map/types/src/utils/Lru.d.ts b/simple-mind-map/types/src/utils/Lru.d.ts new file mode 100644 index 00000000..555c64cf --- /dev/null +++ b/simple-mind-map/types/src/utils/Lru.d.ts @@ -0,0 +1,10 @@ +export default class CRU { + constructor(max: any) + max: any + size: number + pool: Map + add(key: any, value: any): void + delete(key: any): void + has(key: any): boolean + get(key: any): any +} diff --git a/simple-mind-map/types/src/utils/index.d.ts b/simple-mind-map/types/src/utils/index.d.ts new file mode 100644 index 00000000..b856ae1d --- /dev/null +++ b/simple-mind-map/types/src/utils/index.d.ts @@ -0,0 +1,113 @@ +export function walk( + root: any, + parent: any, + beforeCallback: any, + afterCallback: any, + isRoot: any, + layerIndex?: number, + index?: number +): void +export function bfsWalk(root: any, callback: any): void +export function resizeImgSizeByOriginRatio( + width: any, + height: any, + newWidth: any, + newHeight: any +): any[] +export function resizeImgSize( + width: any, + height: any, + maxWidth: any, + maxHeight: any +): any[] +export function resizeImg( + imgUrl: any, + maxWidth: any, + maxHeight: any +): Promise +export function getStrWithBrFromHtml(str: any): any +export function simpleDeepClone(data: any): any +export function copyRenderTree( + tree: any, + root: any, + removeActiveState?: boolean +): any +export function copyNodeTree( + tree: any, + root: any, + removeActiveState?: boolean, + keepId?: boolean +): any +export function imgToDataUrl(src: any): Promise +export function parseDataUrl(data: any): any +export function downloadFile(file: any, fileName: any): void +export function throttle( + fn: any, + time: number, + ctx: any +): (...args: any[]) => void +export function asyncRun(taskList: any, callback?: () => void): void +export function degToRad(deg: any): number +export function camelCaseToHyphen(str: any): any +export function measureText( + text: any, + { + italic, + bold, + fontSize, + fontFamily + }: { + italic: any + bold: any + fontSize: any + fontFamily: any + } +): { + width: any + height: any +} +export function joinFontStr({ + italic, + bold, + fontSize, + fontFamily +}: { + italic: any + bold: any + fontSize: any + fontFamily: any +}): string +export function nextTick(fn: any, ctx: any): () => void +export function checkNodeOuter( + mindMap: any, + node: any +): { + isOuter: boolean + offsetLeft: number + offsetTop: number +} +export function getTextFromHtml(html: any): any +export function readBlob(blob: any): Promise +export function nodeToHTML(node: any): any +export function getImageSize(src: any): Promise +export function createUid(): any +export function loadImage(imgFile: any): Promise +export function removeHTMLEntities(str: any): any +export function getType(data: any): any +export function isUndef(data: any): boolean +export function removeHtmlStyle(html: any): any +export function addHtmlStyle(html: any, tag: any, style: any): any +export function checkIsRichText(str: any): boolean +export function replaceHtmlText( + html: any, + searchText: any, + replaceText: any +): any +export function isWhite(color: any): boolean +export function isTransparent(color: any): boolean +export function getVisibleColorFromTheme(themeConfig: any): any +export function nodeRichTextToTextWithWrap(html: any): string +export function textToNodeRichTextWithWrap(html: any): string +export function isMobile(): boolean +export function getObjectChangedProps(oldObject: any, newObject: any): {} +export function checkIsNodeStyleDataKey(key: any): boolean