feat(mind):为编辑器添加插入思维导图功能 - #293
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
…y-editor into ospp-2025/flowchart
There was a problem hiding this comment.
国际化只有这么点吗?思维导图扩展增加子节点、导出导入等之类的不国际化吗 @shenyaofeng
| backBtn.style.cursor = isStart ? 'not-allowed' : 'pointer' | ||
| backBtn.style.opacity = isStart ? '0.5' : '1' | ||
| forwardBtn.style.cursor = isEnd ? 'not-allowed' : 'pointer' | ||
| forwardBtn.style.opacity = isEnd ? '0.5' : '1' |
| background-color: #f5f5f5; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
@shenyaofeng
把思维导图当成一个独立的 Quill 模块来写,不要作为内置模块,不要耦合到了 tiny-editor 项目里,样式应该放在这个模块里面,不要放在这里。参考下 quill-header-list: https://github.com/opentiny/quill-header-list
| 'file'?: boolean | ||
| 'mathlive'?: boolean | ||
| 'image'?: boolean | Partial<BlotFormatterOptionsInput> | ||
| 'mind'?: boolean |
There was a problem hiding this comment.
所有地方的名字需要统一成一个:mind-map(根据不同场合可能是 MindMap 或者别的),不要简写成 mind
| export * from './link' | ||
| export * from './mathlive' | ||
| export * from './mention' | ||
| export * from './mind/index' |
There was a problem hiding this comment.
| export * from './mind/index' | |
| export * from './mind' |
| 'strike': 'Strikethrough', | ||
| 'image': 'Image', | ||
| 'file': 'File', | ||
| 'mind': 'Mind Map', |
There was a problem hiding this comment.
| 'mind': 'Mind Map', | |
| 'mind-map': 'Mind Map', |
| import { LinkBlot } from './modules/link' // 超链接 | ||
| import { MathliveModule } from './modules/mathlive' // latex公式 | ||
| import { Mention } from './modules/mention' // @提醒 | ||
| import { MindModule } from './modules/mind-map' // 思维导图 |
There was a problem hiding this comment.
| import { MindModule } from './modules/mind-map' // 思维导图 | |
| import { MindMapModule } from './modules/mind-map' // 思维导图 |
| import type { BlockEmbed as TypeBlockEmbed } from 'quill/blots/block' | ||
| import type FluentEditor from '../../../core/fluent-editor' | ||
| import Quill from 'quill' | ||
| import MindMap from 'simple-mind-map' |
There was a problem hiding this comment.
| import MindMap from 'simple-mind-map' | |
| import SimpleMindMap from 'simple-mind-map' |
|
|
||
| const BlockEmbed = Quill.import('blots/embed') as typeof TypeBlockEmbed | ||
|
|
||
| class MindmapPlaceholderBlot extends BlockEmbed { |
There was a problem hiding this comment.
| class MindmapPlaceholderBlot extends BlockEmbed { | |
| class MindMapPlaceholderBlot extends BlockEmbed { |
| const BlockEmbed = Quill.import('blots/embed') as typeof TypeBlockEmbed | ||
|
|
||
| class MindmapPlaceholderBlot extends BlockEmbed { | ||
| static blotName = 'mindmap-placeholder' |
There was a problem hiding this comment.
| static blotName = 'mindmap-placeholder' | |
| static blotName = 'mind-map-placeholder' |
| static blotName = 'mindmap-placeholder' | ||
| static tagName = 'div' | ||
| static className = 'ql-mindmap' | ||
| mm: MindMap | null = null |
There was a problem hiding this comment.
| mm: MindMap | null = null | |
| mindMap: MindMap | null = null |
| class MindmapPlaceholderBlot extends BlockEmbed { | ||
| static blotName = 'mindmap-placeholder' | ||
| static tagName = 'div' | ||
| static className = 'ql-mindmap' |
There was a problem hiding this comment.
| static className = 'ql-mindmap' | |
| static className = 'ql-mind-map' |
| @@ -0,0 +1,28 @@ | |||
| export const MIND_EN_US = { | |||
| 'mindmap.contextMenu.copy': 'Copy', | |||
There was a problem hiding this comment.
| 'mindmap.contextMenu.copy': 'Copy', | |
| 'mind-map.contextMenu.copy': 'Copy', |
|
|
||
| export function registerMindI18N(I18N: any) { | ||
| I18N.register({ | ||
| 'en-US': MIND_EN_US, |
There was a problem hiding this comment.
| 'en-US': MIND_EN_US, | |
| 'en-US': MIND_MAP_EN_US, |
| import { MIND_EN_US } from './en-us' | ||
| import { MIND_ZH_CN } from './zh-cn' | ||
|
|
||
| export function registerMindI18N(I18N: any) { |
There was a problem hiding this comment.
| export function registerMindI18N(I18N: any) { | |
| export function registerMindMapI18N(I18N: any) { |
| export class MindModule { | ||
| quill: Quill | ||
| toolbar: any | ||
| mmContainer: HTMLElement | null = null |
There was a problem hiding this comment.
| mmContainer: HTMLElement | null = null | |
| mindMapContainer: HTMLElement | null = null |
| import type Quill from 'quill' | ||
| import './formats/mind-blot' | ||
|
|
||
| export class MindModule { |
There was a problem hiding this comment.
| export class MindModule { | |
| export class MindMapModule { |
| @@ -0,0 +1,51 @@ | |||
| import type Quill from 'quill' | |||
| import './formats/mind-blot' | |||
There was a problem hiding this comment.
| import './formats/mind-blot' | |
| import './formats/mind-map-blot' |
|
@shenyaofeng 统一下 Mind Map 的命名,目前一会儿是 mind,一会是 mm / mindmap,Mind 和 Map 是两个单词,烤串写法是:mind-map,大驼峰是 MindMap,小驼峰是 mindMap,以下写法请仔细对比(仅举部分例子,需要自行排查和修改不一致的代码),除了注意变量、函数、类等的命名,也要注意文件、文件夹的命名,保持统一命名风格。 - 'mind': 'Mind Map',
+ 'mind-map': 'Mind Map',- import { MindModule } from './modules/mind-map'
+ import { MindMapModule } from './modules/mind-map'- class MindmapPlaceholderBlot extends BlockEmbed {
+ class MindMapPlaceholderBlot extends BlockEmbed {- static blotName = 'mindmap-placeholder'
+ static blotName = 'mind-map-placeholder'- static className = 'ql-mindmap'
+ static className = 'ql-mind-map'- mm: MindMap | null = null
+ mindMap: MindMap | null = null- 'mindmap.contextMenu.copy': 'Copy',
+ 'mind-map.contextMenu.copy': 'Copy',- export function registerMindI18N(I18N: any) {
+ export function registerMindMapI18N(I18N: any) {- 'en-US': MIND_EN_US,
+ 'en-US': MIND_MAP_EN_US,写法不一致很容易导致 bug,注意细节,养成良好的编码习惯。 |
| name: 'sldt', | ||
| alias: ['mind'], | ||
| icon: icons.mind, | ||
| title: this.quill.getLangText('mind'), |
There was a problem hiding this comment.
| title: this.quill.getLangText('mind'), | |
| title: this.quill.getLangText('mind-map'), | |
| title: this.quill.getLangText('mind'), | ||
| onClick(this: Quill, range: Range | null, _: any) { | ||
| if (!range) return | ||
| const mindModule = this.getModule('mind') |
There was a problem hiding this comment.
| const mindModule = this.getModule('mind') | |
| const mindMapModule = this.getModule('mind-map') | |
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
添加插入思维导图功能:

Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information