-
Couldn't load subscription status.
- Fork 63
feat: add flowchart and mindmap #360
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
Open
kagol
wants to merge
13
commits into
main
Choose a base branch
from
kagol/main-flowchart-mindmap
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3270589
feat(mind):为编辑器添加插入思维导图功能 (#293)
shenyaofeng 3313bf7
feat(flow-chart):为编辑器添加插入流程图与调整大小布局功能 (#309)
shenyaofeng cdbbc9e
feat(mind-map):为思维导图添加调整大小与布局功能 (#310)
shenyaofeng c13bae6
feat(mind-map):新增插入图标,改变结构,控制面板显隐,全屏功能, 修复光标问题 (#326)
shenyaofeng 6410093
feat(flow-chart):新增改变连线方式,控制面板显隐,全屏功能,修复光标问题 (#327)
shenyaofeng 8566211
docs(flow-chart):给流程图添加文档 (#332)
shenyaofeng 8653e3c
docs(mind-map):给思维导图添加文档 (#333)
shenyaofeng 4f39a50
test(mind-map):为思维导图图添加自动化测试用例 (#341)
shenyaofeng 636dc17
test(flow-chart):为流程图添加自动化测试用例 (#342)
shenyaofeng 828568d
Feature:(projects)工具栏增加思维导图与流程图 (#350)
shenyaofeng 0826f3f
feat: add flowchart and mindmap
kagol ff076c4
chore: delete useless files
kagol 9e2d55c
[autofix.ci] apply automated fixes
autofix-ci[bot] 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
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
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
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
43 changes: 43 additions & 0 deletions
43
packages/docs/fluent-editor/demos/flow-chart-background.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,43 @@ | ||
| <script setup lang="ts"> | ||
| import type FluentEditor from '@opentiny/fluent-editor' | ||
| import { onMounted, ref } from 'vue' | ||
|
|
||
| let editor: FluentEditor | ||
| const editorRef = ref<HTMLElement>() | ||
|
|
||
| const TOOLBAR_CONFIG = [ | ||
| [{ header: [] }], | ||
| ['bold', 'italic', 'underline', 'link'], | ||
| [{ align: [] }, { list: 'ordered' }, { list: 'bullet' }, { list: 'check' }], | ||
| ['clean'], | ||
| ['flow-chart'], | ||
| ] | ||
|
|
||
| onMounted(() => { | ||
| import('@opentiny/fluent-editor').then(({ default: FluentEditor }) => { | ||
| if (!editorRef.value) return | ||
| editor = new FluentEditor(editorRef.value, { | ||
| theme: 'snow', | ||
| modules: { | ||
| 'toolbar': TOOLBAR_CONFIG, | ||
| 'flow-chart': { | ||
| background: { | ||
| color: '#98FB98', | ||
| // image: 'url(path/to/image.png)', | ||
| repeat: 'repeat', | ||
| position: 'center', | ||
| size: 'auto', | ||
| opacity: 0.1, | ||
| }, | ||
| }, | ||
| }, | ||
| }) | ||
| const ops = [{ insert: '\n' }, { insert: { 'flow-chart': { nodes: [{ id: 'node1', type: 'rect', x: 100, y: 150, text: '开始' }, { id: 'node2', type: 'rect', x: 300, y: 150, text: '结束' }], edges: [{ id: 'edge1', sourceNodeId: 'node1', targetNodeId: 'node2', type: 'polyline' }] } } }, { insert: '\n\n' }] | ||
| editor.setContents(ops) | ||
| }) | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div ref="editorRef" /> | ||
| </template> |
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,42 @@ | ||
| <script setup lang="ts"> | ||
| import type FluentEditor from '@opentiny/fluent-editor' | ||
| import { onMounted, ref } from 'vue' | ||
|
|
||
| let editor: FluentEditor | ||
| const editorRef = ref<HTMLElement>() | ||
|
|
||
| const TOOLBAR_CONFIG = [ | ||
| [{ header: [] }], | ||
| ['bold', 'italic', 'underline', 'link'], | ||
| [{ align: [] }, { list: 'ordered' }, { list: 'bullet' }, { list: 'check' }], | ||
| ['clean'], | ||
| ['flow-chart'], | ||
| ] | ||
|
|
||
| onMounted(() => { | ||
| import('@opentiny/fluent-editor').then(({ default: FluentEditor }) => { | ||
| if (!editorRef.value) return | ||
| editor = new FluentEditor(editorRef.value, { | ||
| theme: 'snow', | ||
| modules: { | ||
| 'toolbar': TOOLBAR_CONFIG, | ||
| 'flow-chart': { grid: { | ||
| size: 15, | ||
| visible: true, | ||
| type: 'mesh', | ||
| config: { | ||
| color: '#98FB98', | ||
| thickness: 5, | ||
| }, | ||
| } }, | ||
| }, | ||
| }) | ||
| const ops = [{ insert: '\n' }, { insert: { 'flow-chart': { nodes: [{ id: 'node1', type: 'rect', x: 100, y: 150, text: '开始' }, { id: 'node2', type: 'rect', x: 300, y: 150, text: '结束' }], edges: [{ id: 'edge1', sourceNodeId: 'node1', targetNodeId: 'node2', type: 'polyline' }] } } }, { insert: '\n\n' }] | ||
| editor.setContents(ops) | ||
| }) | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div ref="editorRef" /> | ||
| </template> |
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 @@ | ||
| <script setup lang="ts"> | ||
| import type FluentEditor from '@opentiny/fluent-editor' | ||
| import { onMounted, ref } from 'vue' | ||
|
|
||
| let editor: FluentEditor | ||
| const editorRef = ref<HTMLElement>() | ||
|
|
||
| const TOOLBAR_CONFIG = [ | ||
| [{ header: [] }], | ||
| ['bold', 'italic', 'underline', 'link'], | ||
| [{ align: [] }, { list: 'ordered' }, { list: 'bullet' }, { list: 'check' }], | ||
| ['clean'], | ||
| ['flow-chart'], | ||
| ] | ||
|
|
||
| onMounted(() => { | ||
| import('@opentiny/fluent-editor').then(({ default: FluentEditor }) => { | ||
| if (!editorRef.value) return | ||
| editor = new FluentEditor(editorRef.value, { | ||
| theme: 'snow', | ||
| modules: { | ||
| 'toolbar': TOOLBAR_CONFIG, | ||
| 'flow-chart': { | ||
| resize: true, | ||
| }, | ||
| }, | ||
| }) | ||
| const ops = [{ insert: '\n' }, { insert: { 'flow-chart': { nodes: [{ id: 'node1', type: 'rect', x: 100, y: 150, text: '开始' }, { id: 'node2', type: 'rect', x: 300, y: 150, text: '结束' }], edges: [{ id: 'edge1', sourceNodeId: 'node1', targetNodeId: 'node2', type: 'polyline' }] } } }, { insert: '\n\n' }] | ||
| editor.setContents(ops) | ||
| }) | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div ref="editorRef" /> | ||
| </template> |
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,55 @@ | ||
| import { expect, test } from '@playwright/test' | ||
|
|
||
| test.describe('FlowChart.vue', () => { | ||
| test.beforeEach(async ({ page }) => { | ||
| await page.goto('http://localhost:5173/tiny-editor/docs/demo/flow-chart') | ||
| }) | ||
|
|
||
| test('should render the editor', async ({ page }) => { | ||
| const editor = page.locator('.ql-editor') | ||
| await expect(editor).toBeVisible() | ||
| }) | ||
|
|
||
| test('should have flow-chart button in toolbar', async ({ page }) => { | ||
| const toolbar = page.locator('.ql-toolbar') | ||
| await expect(toolbar).toBeVisible() | ||
|
|
||
| const flowChartButton = toolbar.locator('.ql-flow-chart') | ||
| await expect(flowChartButton).toBeVisible() | ||
| }) | ||
|
|
||
| test('should initialize editor with flow chart content', async ({ page }) => { | ||
| const editor = page.locator('.ql-editor') | ||
| await expect(editor).toBeVisible() | ||
|
|
||
| await page.waitForTimeout(1000) | ||
|
|
||
| const flowChartElement = editor.locator('.ql-flow-chart-item') | ||
| await expect(flowChartElement).toBeVisible() | ||
| }) | ||
|
|
||
| test('should contain initial flow chart nodes and edges', async ({ page }) => { | ||
| await page.waitForTimeout(2000) | ||
|
|
||
| const flowChartContainer = page.locator('.ql-flow-chart-item') | ||
| await expect(flowChartContainer).toBeVisible() | ||
|
|
||
| const nodes = page.locator('.lf-node') | ||
| await expect(nodes).toHaveCount(2) | ||
|
|
||
| const edges = page.locator('.lf-edge') | ||
| await expect(edges).toHaveCount(1) | ||
| }) | ||
|
|
||
| test('should activate flow-chart when button is clicked', async ({ page }) => { | ||
| const flowChartButton = page.locator('.ql-toolbar .ql-flow-chart') | ||
| await expect(flowChartButton).toBeVisible() | ||
|
|
||
| await flowChartButton.click() | ||
|
|
||
| await page.waitForTimeout(500) | ||
|
|
||
| const editor = page.locator('.ql-editor') | ||
| await expect(editor).toBeVisible() | ||
| }) | ||
| }) | ||
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,34 @@ | ||
| <script setup lang="ts"> | ||
| import type FluentEditor from '@opentiny/fluent-editor' | ||
| import { onMounted, ref } from 'vue' | ||
|
|
||
| let editor: FluentEditor | ||
| const editorRef = ref<HTMLElement>() | ||
|
|
||
| const TOOLBAR_CONFIG = [ | ||
| [{ header: [] }], | ||
| ['bold', 'italic', 'underline', 'link'], | ||
| [{ align: [] }, { list: 'ordered' }, { list: 'bullet' }, { list: 'check' }], | ||
| ['clean'], | ||
| ['flow-chart'], | ||
| ] | ||
|
|
||
| onMounted(() => { | ||
| import('@opentiny/fluent-editor').then(({ default: FluentEditor }) => { | ||
| if (!editorRef.value) return | ||
| editor = new FluentEditor(editorRef.value, { | ||
| theme: 'snow', | ||
| modules: { | ||
| 'toolbar': TOOLBAR_CONFIG, | ||
| 'flow-chart': true, | ||
| }, | ||
| }) | ||
| const ops = [{ insert: '\n' }, { insert: { 'flow-chart': { nodes: [{ id: 'node1', type: 'rect', x: 100, y: 150, text: '开始' }, { id: 'node2', type: 'rect', x: 300, y: 150, text: '结束' }], edges: [{ id: 'edge1', sourceNodeId: 'node1', targetNodeId: 'node2', type: 'polyline' }] } } }, { insert: '\n\n' }] | ||
| editor.setContents(ops) | ||
| }) | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div ref="editorRef" /> | ||
| </template> |
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,42 @@ | ||
| <script setup lang="ts"> | ||
| import type FluentEditor from '@opentiny/fluent-editor' | ||
| import { onMounted, ref } from 'vue' | ||
|
|
||
| let editor: FluentEditor | ||
| const editorRef = ref<HTMLElement>() | ||
|
|
||
| const TOOLBAR_CONFIG = [ | ||
| [{ header: [] }], | ||
| ['bold', 'italic', 'underline', 'link'], | ||
| [{ align: [] }, { list: 'ordered' }, { list: 'bullet' }, { list: 'check' }], | ||
| ['clean'], | ||
| ['mind-map'], | ||
| ] | ||
|
|
||
| onMounted(() => { | ||
| import('@opentiny/fluent-editor').then(({ default: FluentEditor }) => { | ||
| if (!editorRef.value) return | ||
| editor = new FluentEditor(editorRef.value, { | ||
| theme: 'snow', | ||
| modules: { | ||
| 'toolbar': TOOLBAR_CONFIG, | ||
| 'mind-map': { | ||
| background: { | ||
| color: '#A4DD00', | ||
| // image: 'url(path/to/image.png)', | ||
| repeat: 'repeat', | ||
| position: 'center', | ||
| size: 'auto', | ||
| }, | ||
| }, | ||
| }, | ||
| }) | ||
| const ops = [{ insert: '\n' }, { insert: { 'mind-map': { layout: 'logicalStructure', root: { data: { text: '根节点', expand: true, uid: '36bae545-da0b-4c08-be14-ff05f7f05d0a', isActive: false }, children: [{ data: { text: '二级节点', uid: 'ef0895d2-b5cc-4214-b0ee-e29f8f02420d', expand: true, richText: false, isActive: false }, children: [] }], smmVersion: '0.14.0-fix.1' }, theme: { template: 'default', config: { backgroundColor: '#A4DD00', backgroundRepeat: 'repeat', backgroundPosition: 'center', backgroundSize: 'auto' } }, view: { transform: { scaleX: 1, scaleY: 1, shear: 0, rotate: 0, translateX: 0, translateY: 0, originX: 0, originY: 0, a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, state: { scale: 1, x: 0, y: 0, sx: 0, sy: 0 } } } } }, { insert: '\n\n' }] | ||
| editor.setContents(ops) | ||
| }) | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div ref="editorRef" /> | ||
| </template> |
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,41 @@ | ||
| <script setup lang="ts"> | ||
| import type FluentEditor from '@opentiny/fluent-editor' | ||
| import { onMounted, ref } from 'vue' | ||
|
|
||
| let editor: FluentEditor | ||
| const editorRef = ref<HTMLElement>() | ||
|
|
||
| const TOOLBAR_CONFIG = [ | ||
| [{ header: [] }], | ||
| ['bold', 'italic', 'underline', 'link'], | ||
| [{ align: [] }, { list: 'ordered' }, { list: 'bullet' }, { list: 'check' }], | ||
| ['clean'], | ||
| ['mind-map'], | ||
| ] | ||
|
|
||
| onMounted(() => { | ||
| import('@opentiny/fluent-editor').then(({ default: FluentEditor }) => { | ||
| if (!editorRef.value) return | ||
| editor = new FluentEditor(editorRef.value, { | ||
| theme: 'snow', | ||
| modules: { | ||
| 'toolbar': TOOLBAR_CONFIG, | ||
| 'mind-map': { | ||
| line: { | ||
| color: '#009CE0', | ||
| width: 3, | ||
| dasharray: '15, 10, 5, 10, 15', | ||
| style: 'curve', | ||
| }, | ||
| }, | ||
| }, | ||
| }) | ||
| const ops = [{ insert: '\n' }, { insert: { 'mind-map': { layout: 'logicalStructure', root: { data: { text: '根节点', expand: true, uid: '36bae545-da0b-4c08-be14-ff05f7f05d0a', isActive: false }, children: [{ data: { text: '二级节点', uid: 'ef0895d2-b5cc-4214-b0ee-e29f8f02420d', expand: true, richText: false, isActive: false }, children: [] }], smmVersion: '0.14.0-fix.1' }, theme: { template: 'default', config: { lineColor: '#009CE0', lineWidth: 3, lineDasharray: '15, 10, 5, 10, 15', lineStyle: 'curve' } }, view: { transform: { scaleX: 1, scaleY: 1, shear: 0, rotate: 0, translateX: 0, translateY: 0, originX: 0, originY: 0, a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, state: { scale: 1, x: 0, y: 0, sx: 0, sy: 0 } } } } }, { insert: '\n\n' }] | ||
| editor.setContents(ops) | ||
| }) | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div ref="editorRef" /> | ||
| </template> |
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 @@ | ||
| <script setup lang="ts"> | ||
| import type FluentEditor from '@opentiny/fluent-editor' | ||
| import { onMounted, ref } from 'vue' | ||
|
|
||
| let editor: FluentEditor | ||
| const editorRef = ref<HTMLElement>() | ||
|
|
||
| const TOOLBAR_CONFIG = [ | ||
| [{ header: [] }], | ||
| ['bold', 'italic', 'underline', 'link'], | ||
| [{ align: [] }, { list: 'ordered' }, { list: 'bullet' }, { list: 'check' }], | ||
| ['clean'], | ||
| ['mind-map'], | ||
| ] | ||
|
|
||
| onMounted(() => { | ||
| import('@opentiny/fluent-editor').then(({ default: FluentEditor }) => { | ||
| if (!editorRef.value) return | ||
| editor = new FluentEditor(editorRef.value, { | ||
| theme: 'snow', | ||
| modules: { | ||
| 'toolbar': TOOLBAR_CONFIG, | ||
| 'mind-map': { | ||
| resize: true, | ||
| }, | ||
| }, | ||
| }) | ||
| const ops = [{ insert: '\n' }, { insert: { 'mind-map': { layout: 'logicalStructure', root: { data: { text: '根节点', expand: true, uid: '36bae545-da0b-4c08-be14-ff05f7f05d0a', isActive: false }, children: [{ data: { text: '二级节点', uid: 'ef0895d2-b5cc-4214-b0ee-e29f8f02420d', expand: true, richText: false, isActive: false }, children: [] }], smmVersion: '0.14.0-fix.1' }, theme: { template: 'default', config: {} }, view: { transform: { scaleX: 1, scaleY: 1, shear: 0, rotate: 0, translateX: 0, translateY: 0, originX: 0, originY: 0, a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, state: { scale: 1, x: 0, y: 0, sx: 0, sy: 0 } } } } }, { insert: '\n\n' }] | ||
| editor.setContents(ops) | ||
| }) | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div ref="editorRef" /> | ||
| </template> |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix strict-mode locator conflicts; scope to one editor container and remove arbitrary waits.
Multiple editors/toolbars exist on the docs page, so generic class selectors break in Playwright strict mode. Scope all queries to a single
.ql-container(or a dedicated test id), and replacewaitForTimeoutwith expectations.Apply this diff:
Optionally, add data-testid hooks to the demo page and scope to
page.getByTestId('flow-chart-demo')for maximum stability.Also applies to: 13-19, 21-29, 31-42, 44-54
🧰 Tools
🪛 GitHub Actions: Playwright Tests
[error] 8-10: Playwright test failure: strict mode violation. locator('.ql-editor') resolved to multiple elements; expected a single element for visibility check.
🤖 Prompt for AI Agents