Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d9b8b61
feat: add insert flowChart and mindChart
shenyaofeng Jul 16, 2025
c2a1639
fix: update mindmap style
shenyaofeng Jul 17, 2025
52e7239
fix: update mindmap ability
shenyaofeng Jul 17, 2025
f225469
fix: update mindmap node error
shenyaofeng Jul 19, 2025
2fb6c36
fix:flow content delete and edit
shenyaofeng Jul 21, 2025
13db14b
fix: add mindmap adjust size
shenyaofeng Jul 22, 2025
2f4d886
fix:node content delete
shenyaofeng Jul 22, 2025
ef86d9a
fix(mind): 调整思维导图文件结构
shenyaofeng Jul 25, 2025
2f84edb
fix:删除防抖函数
shenyaofeng Jul 25, 2025
ab00d0e
fix:更新mind
shenyaofeng Jul 26, 2025
ad953be
fix:添加右键删除节点内容
shenyaofeng Jul 26, 2025
3e4e33f
fix:快捷键添加思维导图
shenyaofeng Jul 29, 2025
e34b6d6
fix:删除工具栏
shenyaofeng Jul 29, 2025
7e02c27
Merge branch 'ospp-2025/flowchart' of https://github.com/opentiny/tin…
shenyaofeng Jul 30, 2025
c9e4343
fix(mind):更新快捷键插入思维导图图标
shenyaofeng Jul 30, 2025
d5829b1
fix(mind):取消硬编码
shenyaofeng Jul 31, 2025
7227b2a
fix:更新依赖包
shenyaofeng Jul 31, 2025
ce3d2de
fix(mind):完善国际化
shenyaofeng Aug 1, 2025
ad38183
fix(mind-map):更新模块名称与将国际化和样式放入mind-map文件夹中
shenyaofeng Aug 4, 2025
9450055
fix(mind-map):规范思维导图相关变量名称
shenyaofeng Aug 4, 2025
5ee0db1
fix(mind-map):删除思维导图多余样式文件
shenyaofeng Aug 4, 2025
f4aacc5
fix(mind-map):规范思维导图相关变量名称
shenyaofeng Aug 5, 2025
a7c759a
fix(mind-map):规范思维导图相关类名称
shenyaofeng Aug 5, 2025
df69f4f
fix(mind-map):删除打印
shenyaofeng Aug 5, 2025
f127b1b
fix(mind-map):规范思维导图样式文件名称
shenyaofeng Aug 5, 2025
369af95
fix(mind-map):调整思维导图控制面板图标与样式
shenyaofeng Aug 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"dependencies": {
"@emoji-mart/data": "^1.2.1",
"@floating-ui/dom": "^1.7.2",
"@logicflow/core": "^2.0.16",
"@logicflow/extension": "^2.0.21",
"@opentiny/fluent-editor": "workspace:^",
"emoji-mart": "^5.6.0",
"highlight.js": "^10.2.0",
Expand All @@ -26,6 +28,7 @@
"quill-markdown-shortcuts": "^0.0.10",
"quill-table-up": "^2.1.7",
"quill-toolbar-tip": "^0.0.13",
"simple-mind-map": "0.14.0-fix.1",
"vue": "^3.5.13",
"vue-toastification": "2.0.0-rc.5"
},
Comment thread
kagol marked this conversation as resolved.
Expand Down
3 changes: 3 additions & 0 deletions packages/fluent-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
"devDependencies": {
"@emoji-mart/data": "^1.2.1",
"@floating-ui/dom": "^1.7.2",
"@logicflow/core": "^2.0.16",
"@logicflow/extension": "^2.0.21",
"@types/jest": "^26.0.23",
"@types/lodash-es": "^4.17.12",
"commander": "^6.2.0",
Expand All @@ -51,6 +53,7 @@
"parchment": "^3.0.0",
"sass": "^1.47.0",
"shelljs": "^0.8.4",
"simple-mind-map": "0.14.0-fix.1",
"ts-jest": "^26.5.6",
"ts-node": "^9.1.1",
"typescript": "^4.9.5",
Expand Down
1 change: 1 addition & 0 deletions packages/fluent-editor/src/config/i18n/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const EN_US = {
'strike': 'Strikethrough',
'image': 'Image',
'file': 'File',
'mind-map': 'Mind Map',
'link': 'Hyperlink',
'code': 'Inline Code',
'table': 'Table',
Expand Down
2 changes: 1 addition & 1 deletion packages/fluent-editor/src/config/i18n/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const ZH_CN = {
'strike': '删除线',
'image': '图片',
'file': '文件',
'mind-map': '思维导图',
'link': '超链接',
'divider': '分割线',
'code': '行内代码',
Expand Down Expand Up @@ -133,5 +134,4 @@ export const ZH_CN = {
'DeleteTable': '删除当前表格',
'BackgroundColor': '设置背景颜色',
'BorderColor': '设置边框颜色',

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ export interface IEditorModules {
'file'?: boolean
'mathlive'?: boolean
'image'?: boolean | Partial<BlotFormatterOptionsInput>
'mind-map'?: boolean
}
2 changes: 2 additions & 0 deletions packages/fluent-editor/src/fluent-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import I18N from './modules/i18n'
import { LinkBlot } from './modules/link' // 超链接
import { MathliveModule } from './modules/mathlive' // latex公式
import { Mention } from './modules/mention' // @提醒
import { MindMapModule } from './modules/mind-map' // 思维导图
import { ShortCutKey } from './modules/shortcut-key'
import Syntax from './modules/syntax' // 代码块高亮
import { BetterToolbar } from './modules/toolbar' // 工具栏
Expand Down Expand Up @@ -57,6 +58,7 @@ FluentEditor.register(
'modules/toolbar': BetterToolbar,
'modules/uploader': FileUploader,
'modules/shortcut-key': ShortCutKey,
'modules/mind-map': MindMapModule,

'themes/snow': SnowTheme,

Expand Down
1 change: 1 addition & 0 deletions packages/fluent-editor/src/modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export * from './i18n'
export * from './link'
export * from './mathlive'
export * from './mention'
export * from './mind-map'
export * from './shortcut-key'
export * from './syntax'
export * from './table-up'
Expand Down
106 changes: 106 additions & 0 deletions packages/fluent-editor/src/modules/mind-map/formats/mind-map-blot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import type { Root } from 'parchment'
import type { BlockEmbed as TypeBlockEmbed } from 'quill/blots/block'
import type FluentEditor from '../../../core/fluent-editor'
import Quill from 'quill'
import SimpleMindMap from 'simple-mind-map'
import Drag from 'simple-mind-map/src/plugins/Drag.js'
import Export from 'simple-mind-map/src/plugins/Export.js'
import { initContextMenu } from '../modules/context-menu'
import { createControlPanel } from '../modules/control-panel'
import '../style/mind-map.scss'

const BlockEmbed = Quill.import('blots/embed') as typeof TypeBlockEmbed

class MindMapPlaceholderBlot extends BlockEmbed {
static blotName = 'mind-map-placeholder'
static tagName = 'div'
static className = 'ql-mind-map'
mindMap: SimpleMindMap | null = null
data: any
zoomCount = 0
contextMenu: HTMLElement | null = null
currentNode: any = null

constructor(scroll: Root, domNode: HTMLElement) {
super(scroll, domNode)
this.domNode.classList.add('ql-mind-map-container')
this.domNode.style.height = '500px'
this.domNode.style.border = '1px solid #e8e8e8'
this.data = MindMapPlaceholderBlot.value(this.domNode)
this.initMindMap()
}

static value(domNode: HTMLElement): any {
const dataStr = JSON.parse(domNode.getAttribute('data-mind-map'))
return dataStr.root ? dataStr.root : dataStr
}

static create(value: any): HTMLElement {
const node = super.create() as HTMLElement
if (value) {
node.setAttribute('data-mind-map', JSON.stringify(value))
}
return node
}

initMindMap(): void {
if (this.domNode.isConnected) {
this.insertMindMapEditor()
}
else {
const observer = new MutationObserver(() => {
if (this.domNode.isConnected) {
this.insertMindMapEditor()
observer.disconnect()
}
})
observer.observe(document.body, { childList: true, subtree: true })
}
}

insertMindMapEditor(): void {
this.domNode.style.width = '100%'
this.domNode.style.height = '500px'
while (this.domNode.firstChild) {
this.domNode.removeChild(this.domNode.firstChild)
}
SimpleMindMap.usePlugin(Drag).usePlugin(Export)
this.mindMap = new SimpleMindMap ({
el: this.domNode,
mousewheelAction: 'zoom',
disableMouseWheelZoom: true,
data: this.data,
} as any)

const handleScroll = () => {
if (this.mindMap && this.domNode && this.domNode.isConnected) {
this.mindMap.getElRectInfo()
}
}

window.addEventListener('scroll', handleScroll, { passive: true })

this.domNode.addEventListener('remove', () => {
window.removeEventListener('scroll', handleScroll)
})
const quill = this.scroll as unknown as FluentEditor
createControlPanel(this, quill) // 创建控制面板
initContextMenu(this, quill) // 初始化右键菜单
this.mindMap.on('node_tree_render_end', () => {
this.data = this.mindMap.getData({})
this.domNode.setAttribute('data-mind-map', JSON.stringify(this.data))
this.scroll.update([], {})
})
if (this.mindMap) {
this.mindMap.setData(this.data)
}
}

value(): any {
return this.data
}
}

Quill.register(MindMapPlaceholderBlot)

export default MindMapPlaceholderBlot
28 changes: 28 additions & 0 deletions packages/fluent-editor/src/modules/mind-map/i18n/en-us.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export const MIND_MAP_EN_US = {
'mindMap.contextMenu.copy': 'Copy',
'mindMap.contextMenu.cut': 'Cut',
'mindMap.contextMenu.paste': 'Paste',
'mindMap.contextMenu.deleteContent': 'Delete',
'mindMap.controlPanel.zoomOut': 'Out',
'mindMap.controlPanel.zoomIn': 'In',
'mindMap.controlPanel.fit': 'Fit',
'mindMap.controlPanel.back': 'Back',
'mindMap.controlPanel.forward': 'Forward',
'mindMap.controlPanel.export': 'Export',
'mindMap.controlPanel.import': 'Import',
'mindMap.controlPanel.inserChildNode': 'Child',
'mindMap.controlPanel.inserNode': 'Node',
'mindMap.controlPanel.inserParentNode': 'Parent',
'mindMap.controlPanel.removeNode': 'Remove',
'mindMap.controlPanel.zoomOutTitle': 'Zoom Out View',
'mindMap.controlPanel.zoomInTitle': 'Zoom In View',
'mindMap.controlPanel.fitTitle': 'Fit View Size',
'mindMap.controlPanel.backTitle': 'Step Back',
'mindMap.controlPanel.forwardTitle': 'Step Forward',
'mindMap.controlPanel.exportTitle': 'Export Mind Map',
'mindMap.controlPanel.importTitle': 'Import Mind Map',
'mindMap.controlPanel.inserChildNodeTitle': 'Insert Child Node',
'mindMap.controlPanel.inserNodeTitle': 'Insert Sibling Node',
'mindMap.controlPanel.inserParentNodeTitle': 'Insert Parent Node',
'mindMap.controlPanel.removeNodeTitle': 'Delete Current Node',
}
9 changes: 9 additions & 0 deletions packages/fluent-editor/src/modules/mind-map/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { MIND_MAP_EN_US } from './en-us'
import { MIND_MAP_ZH_CN } from './zh-cn'

export function registerMindMapI18N(I18N: any) {
I18N.register({
'en-US': MIND_MAP_EN_US,
'zh-CN': MIND_MAP_ZH_CN,
}, false)
}
28 changes: 28 additions & 0 deletions packages/fluent-editor/src/modules/mind-map/i18n/zh-cn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export const MIND_MAP_ZH_CN = {
'mindMap.contextMenu.copy': '复制',
'mindMap.contextMenu.cut': '剪切',
'mindMap.contextMenu.paste': '粘贴',
'mindMap.contextMenu.deleteContent': '删除',
'mindMap.controlPanel.zoomOut': '缩小',
'mindMap.controlPanel.zoomIn': '放大',
'mindMap.controlPanel.fit': '适应',
'mindMap.controlPanel.back': '上一步',
'mindMap.controlPanel.forward': '下一步',
'mindMap.controlPanel.export': '导出',
'mindMap.controlPanel.import': '导入',
'mindMap.controlPanel.inserChildNode': '子节点',
'mindMap.controlPanel.inserNode': '同级节点',
'mindMap.controlPanel.inserParentNode': '父节点',
'mindMap.controlPanel.removeNode': '删除',
'mindMap.controlPanel.zoomOutTitle': '缩小视图',
'mindMap.controlPanel.zoomInTitle': '放大视图',
'mindMap.controlPanel.fitTitle': '适应视图大小',
'mindMap.controlPanel.backTitle': '后退一步',
'mindMap.controlPanel.forwardTitle': '前进一步',
'mindMap.controlPanel.exportTitle': '导出思维导图',
'mindMap.controlPanel.importTitle': '导入思维导图',
'mindMap.controlPanel.inserChildNodeTitle': '插入子节点',
'mindMap.controlPanel.inserNodeTitle': '插入同级节点',
'mindMap.controlPanel.inserParentNodeTitle': '插入父节点',
'mindMap.controlPanel.removeNodeTitle': '删除当前节点',
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions packages/fluent-editor/src/modules/mind-map/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import type Quill from 'quill'
import './formats/mind-map-blot'

export class MindMapModule {
quill: Quill
toolbar: any

constructor(quill: Quill, options: any) {
this.quill = quill
this.toolbar = quill.getModule('toolbar')
const domNode = document.querySelector('.ql-mind-map')

if (domNode) {
domNode.addEventListener('click', () => {
this.insertMindMapEditor()
})
}
}

public insertMindMapEditor(): void {
const range = this.quill.getSelection()
if (range) {
const defaultData = {
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',
}
this.quill.insertEmbed(range.index, 'mind-map-placeholder', defaultData, 'user')
this.quill.setSelection(range.index + 1, 0)
}
}
}
Loading