Skip to content

Commit

Permalink
build: update for mind-elixir 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SSShooter committed Aug 19, 2023
1 parent 76bf88a commit 83c08d0
Show file tree
Hide file tree
Showing 6 changed files with 487 additions and 316 deletions.
66 changes: 33 additions & 33 deletions lite-template.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
/* eslint-disable import/no-webpack-loader-syntax */
import js from 'mind-elixir/dist/MindElixirLite.js?raw'

export default data => `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>${data.nodeData.topic}</title>
<style>
html, body {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
#map {
height: 100%;
width: 100%;
overflow: auto;
}
</style>
</head>
<body>
<div id="map"></div>
<script>${js}</script>
<script>
let mind = new MindElixirLite({el: '#map'})
mind.init(${JSON.stringify(data)})
</script>
</body>
</html>`
/* eslint-disable import/no-webpack-loader-syntax */
import js from 'mind-elixir/lite?raw'

export default data => `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>${data.nodeData.topic}</title>
<style>
html, body {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
#map {
height: 100%;
width: 100%;
overflow: auto;
}
</style>
</head>
<body>
<div id="map"></div>
<script>${js}</script>
<script>
let mind = new MindElixirLite({el: '#map'})
mind.init(${JSON.stringify(data)})
</script>
</body>
</html>`
178 changes: 89 additions & 89 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,89 +1,89 @@
import MindElixir, { E } from 'mind-elixir'
import example from 'mind-elixir/dist/example1'

import exportHtml from './index'
// import exportHtml from '@mind-elixir/export-html'

const app = document.querySelector('#app')
app.style.marginTop = '50px'
app.style.height = '800px'
app.style.width = '100%'

const options = {
el: app,
newTopicName: '子节点',
direction: MindElixir.SIDE,
// direction: MindElixir.RIGHT,
locale: 'en',
draggable: true,
editable: true,
contextMenu: true,
contextMenuOption: {
focus: true,
link: true,
extend: [
{
name: 'Node edit',
onclick: () => {
alert('extend menu')
},
},
],
},
toolBar: true,
nodeMenu: true,
keypress: true,
allowUndo: false,
before: {
moveDownNode() {
return false
},
insertSibling(el, obj) {
console.log('insertSibling', el, obj)
return true
},
async addChild(el, obj) {
console.log('addChild', el, obj)
// await sleep()
return true
},
},
primaryLinkStyle: 1,
primaryNodeVerticalGap: 15, // 25
primaryNodeHorizontalGap: 15, // 65
}

const mind = new MindElixir(options)
mind.install(exportHtml)
const data = MindElixir.new('new topic')
mind.init(example) // or try `example`
function sleep() {
return new Promise((res, rej) => {
setTimeout(() => res(), 1000)
})
}
console.log('test E function', E('bd4313fbac40284b'))
window.currentOperation = null
mind.bus.addListener('operation', (operation) => {
console.log(operation)
if (operation.name !== 'finishEdit') window.currentOperation = operation
// return {
// name: action name,
// obj: target object
// }

// name: [insertSibling|addChild|removeNode|beginEdit|finishEdit]
// obj: target

// name: moveNode
// obj: {from:target1,to:target2}
})
mind.bus.addListener('selectNode', (node) => {
console.log(node)
})
mind.bus.addListener('expandNode', (node) => {
console.log('expandNode: ', node)
})
window.m = mind
window.M = MindElixir
window.E = MindElixir.E
import MindElixir from 'mind-elixir'
import example from 'mind-elixir/example'

import exportHtml from './index'
// import exportHtml from '@mind-elixir/export-html'
const E = MindElixir.E
const app = document.querySelector('#app')
app.style.marginTop = '50px'
app.style.height = '800px'
app.style.width = '100%'

const options = {
el: app,
newTopicName: '子节点',
direction: MindElixir.SIDE,
// direction: MindElixir.RIGHT,
locale: 'en',
draggable: true,
editable: true,
contextMenu: true,
contextMenuOption: {
focus: true,
link: true,
extend: [
{
name: 'Node edit',
onclick: () => {
alert('extend menu')
},
},
],
},
toolBar: true,
nodeMenu: true,
keypress: true,
allowUndo: false,
before: {
moveDownNode() {
return false
},
insertSibling(el, obj) {
console.log('insertSibling', el, obj)
return true
},
async addChild(el, obj) {
console.log('addChild', el, obj)
// await sleep()
return true
},
},
primaryLinkStyle: 1,
primaryNodeVerticalGap: 15, // 25
primaryNodeHorizontalGap: 15, // 65
}

const mind = new MindElixir(options)
mind.install(exportHtml)
const data = MindElixir.new('new topic')
mind.init(example) // or try `example`
function sleep() {
return new Promise((res, rej) => {
setTimeout(() => res(), 1000)
})
}
console.log('test E function', E('bd4313fbac40284b'))
window.currentOperation = null
mind.bus.addListener('operation', (operation) => {
console.log(operation)
if (operation.name !== 'finishEdit') window.currentOperation = operation
// return {
// name: action name,
// obj: target object
// }

// name: [insertSibling|addChild|removeNode|beginEdit|finishEdit]
// obj: target

// name: moveNode
// obj: {from:target1,to:target2}
})
mind.bus.addListener('selectNode', (node) => {
console.log(node)
})
mind.bus.addListener('expandNode', (node) => {
console.log('expandNode: ', node)
})
window.m = mind
window.M = MindElixir
window.E = MindElixir.E
Loading

0 comments on commit 83c08d0

Please sign in to comment.