Merge pull request #336 from wanghao1993/feature/add_opt_fit

Feature/add opt fit
This commit is contained in:
街角小林 2023-09-18 09:06:40 +08:00 committed by GitHub
commit 43216ed925
5 changed files with 2378 additions and 2201 deletions

View File

@ -92,7 +92,7 @@ class MindMap {
}) })
// 初始渲染 // 初始渲染
this.render() this.render(this.opt.fit ? () => this.view.fit() : () => {})
setTimeout(() => { setTimeout(() => {
this.command.addHistory() this.command.addHistory()
}, 0) }, 0)

View File

@ -186,5 +186,7 @@ export const defaultOpt = {
// 删除节点后激活相邻节点 // 删除节点后激活相邻节点
deleteNodeActive: true, deleteNodeActive: true,
// 拖拽节点时鼠标移动到画布边缘是否开启画布自动移动 // 拖拽节点时鼠标移动到画布边缘是否开启画布自动移动
autoMoveWhenMouseInEdgeOnDrag: true autoMoveWhenMouseInEdgeOnDrag: true,
// 是否首次加载fit view
fit: false
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -12,10 +12,7 @@
<ShortcutKey></ShortcutKey> <ShortcutKey></ShortcutKey>
<Contextmenu v-if="mindMap" :mindMap="mindMap"></Contextmenu> <Contextmenu v-if="mindMap" :mindMap="mindMap"></Contextmenu>
<RichTextToolbar v-if="mindMap" :mindMap="mindMap"></RichTextToolbar> <RichTextToolbar v-if="mindMap" :mindMap="mindMap"></RichTextToolbar>
<NodeNoteContentShow <NodeNoteContentShow v-if="mindMap" :mindMap="mindMap"></NodeNoteContentShow>
v-if="mindMap"
:mindMap="mindMap"
></NodeNoteContentShow>
<NodeImgPreview v-if="mindMap" :mindMap="mindMap"></NodeImgPreview> <NodeImgPreview v-if="mindMap" :mindMap="mindMap"></NodeImgPreview>
<SidebarTrigger v-if="!isZenMode"></SidebarTrigger> <SidebarTrigger v-if="!isZenMode"></SidebarTrigger>
<Search v-if="mindMap" :mindMap="mindMap"></Search> <Search v-if="mindMap" :mindMap="mindMap"></Search>
@ -268,7 +265,7 @@ export default {
if (hasFileURL) { if (hasFileURL) {
root = { root = {
"data": { "data": {
"text": "根节点" "text": "根节点"
}, },
"children": [] "children": []
} }
@ -279,6 +276,7 @@ export default {
this.mindMap = new MindMap({ this.mindMap = new MindMap({
el: this.$refs.mindMapContainer, el: this.$refs.mindMapContainer,
data: root, data: root,
fit: true,
layout: layout, layout: layout,
theme: theme.template, theme: theme.template,
themeConfig: theme.config, themeConfig: theme.config,
@ -346,31 +344,31 @@ export default {
this.mindMap.keyCommand.addShortcut('Control+s', () => { this.mindMap.keyCommand.addShortcut('Control+s', () => {
this.manualSave() this.manualSave()
}) })
// //
;[ ;[
'node_active', 'node_active',
'data_change', 'data_change',
'view_data_change', 'view_data_change',
'back_forward', 'back_forward',
'node_contextmenu', 'node_contextmenu',
'node_click', 'node_click',
'draw_click', 'draw_click',
'expand_btn_click', 'expand_btn_click',
'svg_mousedown', 'svg_mousedown',
'mouseup', 'mouseup',
'mode_change', 'mode_change',
'node_tree_render_end', 'node_tree_render_end',
'rich_text_selection_change', 'rich_text_selection_change',
'transforming-dom-to-images', 'transforming-dom-to-images',
'generalization_node_contextmenu', 'generalization_node_contextmenu',
'painter_start', 'painter_start',
'painter_end', 'painter_end',
'scrollbar_change' 'scrollbar_change'
].forEach(event => { ].forEach(event => {
this.mindMap.on(event, (...args) => { this.mindMap.on(event, (...args) => {
this.$bus.$emit(event, ...args) this.$bus.$emit(event, ...args)
})
}) })
})
this.bindSaveEvent() this.bindSaveEvent()
// setTimeout(() => { // setTimeout(() => {
// //