-
Notifications
You must be signed in to change notification settings - Fork 308
feat(vue): [mind-map] mindmap #1207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ec7dd85
feat(mind-map): drag and zoom
GaoNeng-wWw d576844
feat(vue): mindmap component
GaoNeng-wWw 4aa9564
fix(renderless): restore tsconfig.json
GaoNeng-wWw a0e4a92
fix: remove fabric add mind-elixir
GaoNeng-wWw 2cce24b
docs: composition api
GaoNeng-wWw 1bf2c5b
feat(vue): extract inline-style
GaoNeng-wWw d6d0926
refactor(mind-map): delete exportData function
GaoNeng-wWw b4347b7
refactor(mind-map): extract initEvent function
GaoNeng-wWw 90a3848
feat: add lang=ts
GaoNeng-wWw ef37767
test(mind-map): e2e test
GaoNeng-wWw 3c75308
feat: rename import event
GaoNeng-wWw 9da0552
docs: add en-us doc & change event name
GaoNeng-wWw 5ea30b0
fix: depends install error
GaoNeng-wWw 3faed4a
refactor(mind-map): extract fn to index.ts
GaoNeng-wWw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
examples/sites/demos/pc/app/mind-map/basic-usage-composition-api.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<template> | ||
<tiny-mind-map class="mindmap" /> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { MindMap as TinyMindMap } from '@opentiny/vue' | ||
</script> | ||
|
||
<style scoped> | ||
.mindmap { | ||
width: 100%; | ||
height: 300px; | ||
} | ||
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('基本使用', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('mind-map#basic-usage') | ||
|
||
const root = page.locator('me-tpc').filter({ hasText: 'root' }) | ||
expect(root).not.toBeNull() | ||
await expect(root).toHaveText('root') | ||
}) | ||
test('追加节点', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('mind-map#basic-usage') | ||
|
||
await page.locator('me-tpc').click() | ||
await page.locator('.map-canvas').press('Tab') | ||
await page.locator('me-tpc').filter({ hasText: 'root' }).click() | ||
await page.locator('.map-canvas').press('Tab') | ||
await expect(page.locator('me-main me-wrapper')).toHaveCount(2) | ||
}) | ||
test('修改节点', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('mind-map#basic-usage') | ||
await page.locator('me-tpc').dblclick() | ||
await page.locator('#input-box').fill('root-new') | ||
await page.locator('#input-box').press('Enter') | ||
}) | ||
test('删除节点', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('mind-map#basic-usage') | ||
await page.locator('me-tpc').click() | ||
await page.locator('.map-canvas').press('Tab') | ||
await page.locator('me-tpc').filter({ hasText: 'root' }).click() | ||
await page.locator('.map-canvas').press('Tab') | ||
await page.locator('me-tpc').nth(2).press('Delete') | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<template> | ||
<tiny-mind-map class="mindmap" /> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { MindMap } from '@opentiny/vue' | ||
|
||
export default { | ||
components: { | ||
TinyMindMap: MindMap | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.mindmap { | ||
width: 100%; | ||
height: 300px; | ||
} | ||
</style> |
125 changes: 125 additions & 0 deletions
125
examples/sites/demos/pc/app/mind-map/event-composition-api.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<template> | ||
<tiny-mind-map | ||
ref="mindmap" | ||
class="mindmap" | ||
@create="onCreate" | ||
@operation="onOperation" | ||
@select-node="onSelectNode" | ||
@select-new-node="onSelectNewNode" | ||
@select-nodes="onSelectNodes" | ||
@unselect-node="onUnselectNode" | ||
@unselect-nodes="onUnselectNodes" | ||
@expand-node="onExpandNode" | ||
v-model="exampleData" | ||
/> | ||
</template> | ||
|
||
<script setup> | ||
import { Notify, MindMap as TinyMindMap } from '@opentiny/vue' | ||
import { ref } from 'vue' | ||
|
||
const exmpleData = ref({ | ||
'nodeData': { | ||
'id': 'c9ee6647385c42de', | ||
'topic': '前端修仙指南', | ||
'root': true, | ||
'children': [ | ||
{ | ||
'topic': 'Handfirst html and css', | ||
'id': 'c9ee977189f3b1f1' | ||
}, | ||
{ | ||
'topic': '高程', | ||
'id': 'c9ee9a4e8f3f83c5' | ||
}, | ||
{ | ||
'topic': 'Javascript权威指南', | ||
'id': 'c9ee9b8e87958282' | ||
}, | ||
{ | ||
'topic': '算法 第四版', | ||
'id': 'c9eea19c874d331f' | ||
}, | ||
{ | ||
'topic': '大话数据结构', | ||
'id': 'c9eea8d788441a71' | ||
}, | ||
{ | ||
'topic': '算法导论', | ||
'id': 'c9eeac4c84aaba37' | ||
}, | ||
{ | ||
'topic': '编译原理', | ||
'id': 'c9eeadee881cf229' | ||
}, | ||
{ | ||
'topic': '宫水三叶的刷题日记', | ||
'id': 'c9eec88a85d8ff76' | ||
} | ||
] | ||
} | ||
}) | ||
const onCreate = () => { | ||
Notify({ | ||
type: 'info', | ||
message: '触发事件create', | ||
duration: 1000 | ||
}) | ||
} | ||
const onOperation = () => { | ||
Notify({ | ||
type: 'info', | ||
message: '触发事件operation', | ||
duration: 1000 | ||
}) | ||
} | ||
const onSelectNode = () => { | ||
Notify({ | ||
type: 'info', | ||
message: '触发事件selectNode', | ||
duration: 1000 | ||
}) | ||
} | ||
const onSelectNewNode = () => { | ||
Notify({ | ||
type: 'info', | ||
message: '触发事件selectNewNode', | ||
duration: 1000 | ||
}) | ||
} | ||
const onSelectNodes = () => { | ||
Notify({ | ||
type: 'info', | ||
message: '触发事件selectNodes', | ||
duration: 1000 | ||
}) | ||
} | ||
const onUnselectNode = () => { | ||
Notify({ | ||
type: 'info', | ||
message: '触发事件unselectNode', | ||
duration: 1000 | ||
}) | ||
} | ||
const onUnselectNodes = () => { | ||
Notify({ | ||
type: 'info', | ||
message: '触发事件unselectNodes', | ||
duration: 1000 | ||
}) | ||
} | ||
const onExpandNode = () => { | ||
Notify({ | ||
type: 'info', | ||
message: '触发事件expandNode', | ||
duration: 1000 | ||
}) | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.mindmap { | ||
width: 100%; | ||
height: 300px; | ||
} | ||
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('测试创建事件', async ({ page }) => { | ||
await page.goto('mind-map#event') | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.getByText('触发事件create').isVisible() | ||
}) | ||
|
||
test('测试operation事件', async ({ page }) => { | ||
await page.goto('mind-map#event') | ||
await page.locator('me-tpc').click() | ||
await page.locator('.map-canvas').press('Tab') | ||
await page.getByText('触发事件operation').first().isVisible() | ||
// 新创建node时会触发selectNewNode事件 | ||
// 这个触发是符合逻辑的, 因为创建后的node的确是new-node | ||
// 创建后会自动选择, 自然触发selectNewNode是符合逻辑的 | ||
await page.getByText('触发事件selectNewNode').first().isVisible() | ||
}) | ||
test('测试select-node, select-nodes, select-new-node事件', async ({ page }) => { | ||
await page.goto('mind-map#event') | ||
await page.locator('me-tpc').filter({ hasText: 'root' }).click() | ||
await page.locator('.map-canvas').press('Tab') | ||
await page.locator('me-tpc').filter({ hasText: 'root' }).click() | ||
await page.locator('.map-canvas').press('Tab') | ||
await page.locator('me-tpc').filter({ hasText: 'root' }).click() | ||
await page | ||
.locator('me-tpc') | ||
.nth(1) | ||
.filter({ hasText: 'new node' }) | ||
.click({ | ||
modifiers: ['Control'] | ||
}) | ||
await page.getByText('触发事件selectNode').first().isVisible() | ||
await page.getByAltText('触发事件selectNodes').isVisible() | ||
}) | ||
test('测试 unselect-node,unselect-nodes', async ({ page }) => { | ||
await page.goto('mind-map#event') | ||
await page.locator('me-tpc').filter({ hasText: 'root' }).click() | ||
await page.locator('.map-canvas').press('Tab') | ||
await page.locator('me-tpc').filter({ hasText: 'root' }).click() | ||
await page.locator('.map-canvas').press('Tab') | ||
|
||
await page.locator('me-tpc').nth(2).click() | ||
await page | ||
.locator('me-tpc') | ||
.nth(1) | ||
|
||
.click({ | ||
modifiers: ['Control'] | ||
}) | ||
await page.locator('.map-canvas').click() | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<template> | ||
<tiny-mind-map | ||
ref="mindmap" | ||
class="mindmap" | ||
@create="onCreate" | ||
@operation="onOperation" | ||
@select-node="onSelectNode" | ||
@select-new-node="onSelectNewNode" | ||
@select-nodes="onSelectNodes" | ||
@unselect-node="onUnselectNode" | ||
@unselect-nodes="onUnselectNodes" | ||
@expand-node="onExpandNode" | ||
v-model="exampleData" | ||
/> | ||
</template> | ||
|
||
<script lang="jsx"> | ||
import { MindMap, Notify } from '@opentiny/vue' | ||
|
||
export default { | ||
components: { | ||
TinyMindMap: MindMap | ||
}, | ||
data() { | ||
return { | ||
exampleData: { | ||
'nodeData': { | ||
'id': 'c9ee6647385c42de', | ||
'topic': '前端修仙指南', | ||
'root': true, | ||
'children': [ | ||
{ | ||
'topic': 'Handfirst html and css', | ||
'id': 'c9ee977189f3b1f1' | ||
}, | ||
{ | ||
'topic': '高程', | ||
'id': 'c9ee9a4e8f3f83c5' | ||
}, | ||
{ | ||
'topic': 'Javascript权威指南', | ||
'id': 'c9ee9b8e87958282' | ||
}, | ||
{ | ||
'topic': '算法 第四版', | ||
'id': 'c9eea19c874d331f' | ||
}, | ||
{ | ||
'topic': '大话数据结构', | ||
'id': 'c9eea8d788441a71' | ||
}, | ||
{ | ||
'topic': '算法导论', | ||
'id': 'c9eeac4c84aaba37' | ||
}, | ||
{ | ||
'topic': '编译原理', | ||
'id': 'c9eeadee881cf229' | ||
}, | ||
{ | ||
'topic': '宫水三叶的刷题日记', | ||
'id': 'c9eec88a85d8ff76' | ||
} | ||
] | ||
} | ||
}, | ||
loading: false | ||
} | ||
}, | ||
methods: { | ||
onCreate() { | ||
Notify({ | ||
type: 'info', | ||
message: '触发事件create', | ||
duration: 1000 | ||
}) | ||
}, | ||
onOperation() { | ||
Notify({ | ||
type: 'info', | ||
message: '触发事件operation', | ||
duration: 1000 | ||
}) | ||
}, | ||
onSelectNode() { | ||
Notify({ | ||
type: 'info', | ||
message: '触发事件selectNode', | ||
duration: 1000 | ||
}) | ||
}, | ||
onSelectNewNode() { | ||
Notify({ | ||
type: 'info', | ||
message: '触发事件selectNewNode', | ||
duration: 1000 | ||
}) | ||
}, | ||
onSelectNodes() { | ||
Notify({ | ||
type: 'info', | ||
message: '触发事件selectNodes', | ||
duration: 1000 | ||
}) | ||
}, | ||
onUnselectNode() { | ||
Notify({ | ||
type: 'info', | ||
message: '触发事件unselectNode', | ||
duration: 1000 | ||
}) | ||
}, | ||
onUnselectNodes() { | ||
Notify({ | ||
type: 'info', | ||
message: '触发事件unselectNodes', | ||
duration: 1000 | ||
}) | ||
}, | ||
onExpandNode() { | ||
Notify({ | ||
type: 'info', | ||
message: '触发事件expandNode', | ||
duration: 1000 | ||
}) | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.mindmap { | ||
width: 100%; | ||
height: 300px; | ||
} | ||
</style> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.