Skip to content

feat(mind):为编辑器添加插入思维导图功能 - #293

Merged
kagol merged 26 commits into
opentiny:ospp-2025/flowchartfrom
shenyaofeng:ospp-2025/flowchart
Aug 7, 2025
Merged

feat(mind):为编辑器添加插入思维导图功能#293
kagol merged 26 commits into
opentiny:ospp-2025/flowchartfrom
shenyaofeng:ospp-2025/flowchart

Conversation

@shenyaofeng

@shenyaofeng shenyaofeng commented Jul 29, 2025

Copy link
Copy Markdown
Contributor

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe: 添加插入思维导图功能

What is the current behavior?

添加插入思维导图功能:
image

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@coderabbitai

coderabbitai Bot commented Jul 29, 2025

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@shenyaofeng shenyaofeng changed the title Ospp 2025/flowchart fix(mind):为编辑器添加插入思维导图功能 Jul 30, 2025
@github-actions github-actions Bot added the bug Something isn't working label Jul 30, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

国际化只有这么点吗?思维导图扩展增加子节点、导出导入等之类的不国际化吗 @shenyaofeng

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我改一下

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'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.5、1 这个文件中反复出现,是不是应该不要硬编码

@shenyaofeng shenyaofeng changed the title fix(mind):为编辑器添加插入思维导图功能 feat(mind):为编辑器添加插入思维导图功能 Jul 31, 2025
@github-actions github-actions Bot added enhancement New feature or request and removed bug Something isn't working labels Jul 31, 2025
Comment thread packages/docs/package.json
background-color: #f5f5f5;
}
}
}

@kagol kagol Aug 1, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shenyaofeng
把思维导图当成一个独立的 Quill 模块来写,不要作为内置模块,不要耦合到了 tiny-editor 项目里,样式应该放在这个模块里面,不要放在这里。参考下 quill-header-list: https://github.com/opentiny/quill-header-list

'file'?: boolean
'mathlive'?: boolean
'image'?: boolean | Partial<BlotFormatterOptionsInput>
'mind'?: boolean

@kagol kagol Aug 1, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

所有地方的名字需要统一成一个:mind-map(根据不同场合可能是 MindMap 或者别的),不要简写成 mind

export * from './link'
export * from './mathlive'
export * from './mention'
export * from './mind/index'

@kagol kagol Aug 1, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export * from './mind/index'
export * from './mind'

'strike': 'Strikethrough',
'image': 'Image',
'file': 'File',
'mind': 'Mind Map',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'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' // 思维导图

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static blotName = 'mindmap-placeholder'
static blotName = 'mind-map-placeholder'

static blotName = 'mindmap-placeholder'
static tagName = 'div'
static className = 'ql-mindmap'
mm: MindMap | null = null

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mm: MindMap | null = null
mindMap: MindMap | null = null

class MindmapPlaceholderBlot extends BlockEmbed {
static blotName = 'mindmap-placeholder'
static tagName = 'div'
static className = 'ql-mindmap'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static className = 'ql-mindmap'
static className = 'ql-mind-map'

@@ -0,0 +1,28 @@
export const MIND_EN_US = {
'mindmap.contextMenu.copy': 'Copy',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'mindmap.contextMenu.copy': 'Copy',
'mind-map.contextMenu.copy': 'Copy',


export function registerMindI18N(I18N: any) {
I18N.register({
'en-US': MIND_EN_US,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export function registerMindI18N(I18N: any) {
export function registerMindMapI18N(I18N: any) {

export class MindModule {
quill: Quill
toolbar: any
mmContainer: HTMLElement | null = null

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mmContainer: HTMLElement | null = null
mindMapContainer: HTMLElement | null = null

import type Quill from 'quill'
import './formats/mind-blot'

export class MindModule {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export class MindModule {
export class MindMapModule {

@@ -0,0 +1,51 @@
import type Quill from 'quill'
import './formats/mind-blot'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import './formats/mind-blot'
import './formats/mind-map-blot'

@kagol

kagol commented Aug 4, 2025

Copy link
Copy Markdown
Member

@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,注意细节,养成良好的编码习惯。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shenyaofeng 老的文件没有删除

name: 'sldt',
alias: ['mind'],
icon: icons.mind,
title: this.quill.getLangText('mind'),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const mindModule = this.getModule('mind')
const mindMapModule = this.getModule('mind-map')

CatsAndMice

This comment was marked as resolved.

@kagol
kagol merged commit 3270589 into opentiny:ospp-2025/flowchart Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants