Skip to content

refactor: 优化构建配置并增强 Stream 模式预览区交互功能#1618

Closed
RSS1102 wants to merge 11 commits intodevfrom
rss1102/chore/build/simplify-rollup-config
Closed

refactor: 优化构建配置并增强 Stream 模式预览区交互功能#1618
RSS1102 wants to merge 11 commits intodevfrom
rss1102/chore/build/simplify-rollup-config

Conversation

@RSS1102
Copy link
Copy Markdown
Collaborator

@RSS1102 RSS1102 commented Feb 2, 2026

0.11.0-alpha-2

主要修改内容包括:

  1. 构建相关修改(这部分是核心):

    • packages/cherry-markdown/build/addons.build.cjs - 删除文件
    • packages/cherry-markdown/build/addons.build.js - 修改
    • packages/cherry-markdown/build/build.js - 修改
    • packages/cherry-markdown/build/replacePaths.cjs - 删除文件
    • packages/cherry-markdown/build/replacePaths.js - 修改
    • packages/cherry-markdown/build/rollup.base.config.js - 修改
    • packages/cherry-markdown/build/rollup.core.config.js - 修改
    • packages/cherry-markdown/build/rollup.engine.config.js - 修改
    • packages/cherry-markdown/build/rollup.stream.config.js - 修改
  2. 示例文件修改

    • examples/h5.html - 修改导入顺序
    • examples/img.html - 修改导入顺序
    • examples/index.html - 修改
    • examples/multiple.html - 修改
    • examples/notoolbar.html - 修改
    • examples/preview_only.html - 修改
  3. 核心源代码和依赖处理

    • packages/cherry-markdown/src/Previewer.js - 新增一行
    • packages/cherry-markdown/src/core/hooks/Suggester.js - 功能扩展
    • packages/cherry-markdown/src/index.stream.core.js - 删除文件
    • packages/cherry-markdown/src/index.stream.js - 简化版本
    • 移除旧版本 Mermaid API
    • packages/cherry-markdown/src/utils/codeBlockContentHandler.js - 优化加载机制
    • CodeMirror 引入动态加载策略

这些调整主要集中在构建流程、依赖管理和模块化优化,目的是提升项目整体性能和可维护性。代码处理更加动态和灵活,减少了不必要的依赖和冗余代码。
我来分析一下当前分支相对于 dev 分支的修改内容及其影响。

📊 修改统计

  • 修改了 24 个文件
  • 新增 245 行,删除 319 行
  • 核心改动:简化 rollup 构建配置

🔧 主要修改内容

1️⃣ 构建系统优化(核心改动)

  • 删除冗余的 CommonJS 配置文件

    • addons.build.cjs
    • replacePaths.cjs
    • 统一使用 ESM 格式(.js
  • 简化 rollup 配置

    • 优化了 rollup.base.config.jsrollup.core.config.js 等配置文件
    • 减少配置复杂度,提升构建效率

2️⃣ 代码模块化优化

  • CodeMirror 动态导入

    // 从静态导入改为动态加载
    async function loadCodeMirror() {
      if (!codemirror) {
        codemirror = (await import('codemirror')).default;
        await import('codemirror/keymap/sublime');
      }
    }
    • 好处:减少打包体积,按需加载
  • 移除冗余文件

    • 删除 src/index.stream.core.js(合并到其他文件)
    • 删除旧版本 mermaidAPI.8.5.2.js

3️⃣ 示例文件调整

  • 统一 ES 模块导入顺序
  • 优化 HTML 示例的脚本加载逻辑

4️⃣ 其他改进

  • .eslintignore 规则更精准
  • 补充缺失的导入语句(如 Previewer.js

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 2, 2026

⚠️ No Changeset found

Latest commit: 9b8c7de

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cherry-markdown-bot
Copy link
Copy Markdown
Collaborator

cherry-markdown-bot commented Feb 2, 2026

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 2, 2026

Open in StackBlitz

pnpm add https://pkg.pr.new/cherry-markdown@1618
npm i https://pkg.pr.new/cherry-markdown@1618
yarn add https://pkg.pr.new/cherry-markdown@1618.tgz

commit: 526d211

@RSS1102 RSS1102 changed the title build: 移除 CJS 构建目标并优化打包配置 build: 只输出 ESM 和 UMD 格式,并移除 **/min.js Feb 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 2, 2026

Size Change: -1.88 MB (-22.87%) 🎉

Total Size: 6.34 MB

Filename Size Change
./packages/cherry-markdown/dist/addons/advance/cherry-table-echarts-plugin.esm.js 49.4 kB +49.4 kB (new file) 🆕
./packages/cherry-markdown/dist/addons/advance/cherry-tapd-checklist-plugin.esm.js 22.4 kB +22.4 kB (new file) 🆕
./packages/cherry-markdown/dist/addons/advance/cherry-tapd-html-tag-plugin.esm.js 22.3 kB +22.3 kB (new file) 🆕
./packages/cherry-markdown/dist/addons/advance/cherry-tapd-table-plugin.esm.js 25.4 kB +25.4 kB (new file) 🆕
./packages/cherry-markdown/dist/addons/cherry-code-block-mermaid-plugin.esm.js 23.1 kB +23.1 kB (new file) 🆕
./packages/cherry-markdown/dist/addons/cherry-code-block-plantuml-plugin.esm.js 24.7 kB +24.7 kB (new file) 🆕
./packages/cherry-markdown/dist/cherry-markdown.core.common.d.ts 0 B -106 B (removed) 🏆
./packages/cherry-markdown/dist/cherry-markdown.core.common.js 0 B -546 kB (removed) 🏆
./packages/cherry-markdown/dist/cherry-markdown.core.js 575 kB +28.6 kB (+5.24%) 🔍
./packages/cherry-markdown/dist/cherry-markdown.engine.core.common.d.ts 0 B -116 B (removed) 🏆
./packages/cherry-markdown/dist/cherry-markdown.engine.core.common.js 0 B -244 kB (removed) 🏆
./packages/cherry-markdown/dist/cherry-markdown.engine.core.esm.js 274 kB +29.7 kB (+12.18%) ⚠️
./packages/cherry-markdown/dist/cherry-markdown.engine.core.js 274 kB +29.5 kB (+12.08%) ⚠️
./packages/cherry-markdown/dist/cherry-markdown.esm.js 1.45 MB +71.2 kB (+5.15%) 🔍
./packages/cherry-markdown/dist/cherry-markdown.js 2.43 MB +263 kB (+12.12%) ⚠️
./packages/cherry-markdown/dist/cherry-markdown.min.d.ts 0 B -101 B (removed) 🏆
./packages/cherry-markdown/dist/cherry-markdown.min.js 0 B -1.38 MB (removed) 🏆
./packages/cherry-markdown/dist/cherry-markdown.stream.common.d.ts 0 B -113 B (removed) 🏆
./packages/cherry-markdown/dist/cherry-markdown.stream.common.js 0 B -354 kB (removed) 🏆
./packages/cherry-markdown/dist/cherry-markdown.stream.d.ts 100 B -13 B (-11.5%) 👏
./packages/cherry-markdown/dist/cherry-markdown.stream.esm.d.ts 100 B -13 B (-11.5%) 👏
./packages/cherry-markdown/dist/cherry-markdown.stream.esm.js 382 kB +28.2 kB (+7.96%) 🔍
./packages/cherry-markdown/dist/cherry-markdown.stream.js 383 kB +28 kB (+7.91%) 🔍
./packages/cherry-markdown/dist/types/Cherry.config.d.ts 122 B +5 B (+4.27%)
./packages/cherry-markdown/dist/types/Cherry.d.ts 4.48 kB +4 B (+0.09%)
./packages/cherry-markdown/dist/types/CherryStream.d.ts 1.59 kB +1.59 kB (new file) 🆕
./packages/cherry-markdown/dist/types/core/HookCenter.d.ts 816 B -2 B (-0.24%)
./packages/cherry-markdown/dist/types/core/hooks/Strikethrough.d.ts 240 B +5 B (+2.13%)
./packages/cherry-markdown/dist/types/core/SyntaxBase.d.ts 955 B +4 B (+0.42%)
./packages/cherry-markdown/dist/types/Editor.d.ts 1.98 kB +51 B (+2.64%)
./packages/cherry-markdown/dist/types/index.engine.core.d.ts 376 B +3 B (+0.8%)
./packages/cherry-markdown/dist/types/index.stream.d.ts 107 B +107 B (new file) 🆕
./packages/cherry-markdown/dist/types/Previewer.d.ts 2.52 kB +255 B (+11.23%) ⚠️
./packages/cherry-markdown/dist/types/toolbars/HookCenter.d.ts 508 B +3 B (+0.59%)
./packages/cherry-markdown/dist/types/toolbars/MenuBase.d.ts 2.61 kB +7 B (+0.27%)
./packages/cherry-markdown/dist/types/toolbars/PreviewerBubble.d.ts 2.21 kB +174 B (+8.56%) 🔍
./packages/cherry-markdown/dist/types/toolbars/ShortcutKeyConfigPanel.d.ts 1.36 kB +6 B (+0.44%)
./packages/cherry-markdown/dist/types/utils/codeBlockContentHandler.d.ts 1.32 kB +374 B (+39.33%) 🚨
./packages/cherry-markdown/dist/types/utils/formulaUtilsHandler.d.ts 624 B +93 B (+17.51%) ⚠️
ℹ️ View Unchanged
Filename Size
./packages/cherry-markdown/dist/addons/advance/cherry-table-echarts-plugin.js 49.4 kB
./packages/cherry-markdown/dist/addons/advance/cherry-tapd-checklist-plugin.js 22.5 kB
./packages/cherry-markdown/dist/addons/advance/cherry-tapd-html-tag-plugin.js 22.4 kB
./packages/cherry-markdown/dist/addons/advance/cherry-tapd-table-plugin.js 25.5 kB
./packages/cherry-markdown/dist/addons/cherry-code-block-mermaid-plugin.js 23.2 kB
./packages/cherry-markdown/dist/addons/cherry-code-block-plantuml-plugin.js 24.8 kB
./packages/cherry-markdown/dist/cherry-markdown.core.d.ts 106 B
./packages/cherry-markdown/dist/cherry-markdown.css 36.7 kB
./packages/cherry-markdown/dist/cherry-markdown.d.ts 101 B
./packages/cherry-markdown/dist/cherry-markdown.engine.core.d.ts 116 B
./packages/cherry-markdown/dist/cherry-markdown.engine.core.esm.d.ts 116 B
./packages/cherry-markdown/dist/cherry-markdown.esm.d.ts 101 B
./packages/cherry-markdown/dist/cherry-markdown.markdown.css 20.3 kB
./packages/cherry-markdown/dist/cherry-markdown.markdown.min.css 13.9 kB
./packages/cherry-markdown/dist/cherry-markdown.min.css 28.4 kB
./packages/cherry-markdown/dist/types/addons/advance/cherry-table-echarts-plugin.d.ts 1.73 kB
./packages/cherry-markdown/dist/types/addons/advance/cherry-tapd-checklist-plugin.d.ts 323 B
./packages/cherry-markdown/dist/types/addons/advance/cherry-tapd-html-tag-plugin.d.ts 494 B
./packages/cherry-markdown/dist/types/addons/advance/cherry-tapd-table-plugin.d.ts 1.15 kB
./packages/cherry-markdown/dist/types/addons/cherry-code-block-mermaid-plugin.d.ts 1.37 kB
./packages/cherry-markdown/dist/types/addons/cherry-code-block-plantuml-plugin.d.ts 160 B
./packages/cherry-markdown/dist/types/CherryStatic.d.ts 509 B
./packages/cherry-markdown/dist/types/core/hooks/AiFlowAutoClose.d.ts 370 B
./packages/cherry-markdown/dist/types/core/hooks/AutoLink.d.ts 948 B
./packages/cherry-markdown/dist/types/core/hooks/BackgroundColor.d.ts 189 B
./packages/cherry-markdown/dist/types/core/hooks/Blockquote.d.ts 195 B
./packages/cherry-markdown/dist/types/core/hooks/Br.d.ts 193 B
./packages/cherry-markdown/dist/types/core/hooks/CodeBlock.d.ts 1.31 kB
./packages/cherry-markdown/dist/types/core/hooks/Color.d.ts 183 B
./packages/cherry-markdown/dist/types/core/hooks/CommentReference.d.ts 665 B
./packages/cherry-markdown/dist/types/core/hooks/Detail.d.ts 328 B
./packages/cherry-markdown/dist/types/core/hooks/Emoji.config.d.ts 9.31 kB
./packages/cherry-markdown/dist/types/core/hooks/Emoji.d.ts 9.36 kB
./packages/cherry-markdown/dist/types/core/hooks/Emphasis.d.ts 263 B
./packages/cherry-markdown/dist/types/core/hooks/Footnote.d.ts 307 B
./packages/cherry-markdown/dist/types/core/hooks/FrontMatter.d.ts 192 B
./packages/cherry-markdown/dist/types/core/hooks/Header.d.ts 605 B
./packages/cherry-markdown/dist/types/core/hooks/HighLight.d.ts 158 B
./packages/cherry-markdown/dist/types/core/hooks/Hr.d.ts 223 B
./packages/cherry-markdown/dist/types/core/hooks/HtmlBlock.d.ts 313 B
./packages/cherry-markdown/dist/types/core/hooks/Image.d.ts 325 B
./packages/cherry-markdown/dist/types/core/hooks/InlineCode.d.ts 181 B
./packages/cherry-markdown/dist/types/core/hooks/InlineMath.d.ts 696 B
./packages/cherry-markdown/dist/types/core/hooks/Link.d.ts 583 B
./packages/cherry-markdown/dist/types/core/hooks/List.d.ts 347 B
./packages/cherry-markdown/dist/types/core/hooks/MathBlock.d.ts 451 B
./packages/cherry-markdown/dist/types/core/hooks/Panel.d.ts 435 B
./packages/cherry-markdown/dist/types/core/hooks/Paragraph.d.ts 664 B
./packages/cherry-markdown/dist/types/core/hooks/Ruby.d.ts 154 B
./packages/cherry-markdown/dist/types/core/hooks/Size.d.ts 177 B
./packages/cherry-markdown/dist/types/core/hooks/Space.d.ts 199 B
./packages/cherry-markdown/dist/types/core/hooks/Sub.d.ts 180 B
./packages/cherry-markdown/dist/types/core/hooks/Suggester.d.ts 1.72 kB
./packages/cherry-markdown/dist/types/core/hooks/SuggestList.d.ts 158 B
./packages/cherry-markdown/dist/types/core/hooks/Sup.d.ts 180 B
./packages/cherry-markdown/dist/types/core/hooks/Table.d.ts 554 B
./packages/cherry-markdown/dist/types/core/hooks/Toc.d.ts 974 B
./packages/cherry-markdown/dist/types/core/hooks/Transfer.d.ts 176 B
./packages/cherry-markdown/dist/types/core/hooks/Underline.d.ts 157 B
./packages/cherry-markdown/dist/types/core/HooksConfig.d.ts 524 B
./packages/cherry-markdown/dist/types/core/ParagraphBase.d.ts 1.38 kB
./packages/cherry-markdown/dist/types/Engine.d.ts 1.49 kB
./packages/cherry-markdown/dist/types/Event.d.ts 531 B
./packages/cherry-markdown/dist/types/Factory.d.ts 979 B
./packages/cherry-markdown/dist/types/index.core.d.ts 122 B
./packages/cherry-markdown/dist/types/index.d.ts 76 B
./packages/cherry-markdown/dist/types/index.engine.d.ts 87 B
./packages/cherry-markdown/dist/types/libs/rawdeflate.d.ts 87 B
./packages/cherry-markdown/dist/types/locales/en_US.d.ts 1.1 kB
./packages/cherry-markdown/dist/types/locales/index.d.ts 141 B
./packages/cherry-markdown/dist/types/locales/ru_RU.d.ts 1.1 kB
./packages/cherry-markdown/dist/types/locales/zh_CN.d.ts 1.11 kB
./packages/cherry-markdown/dist/types/Logger.d.ts 441 B
./packages/cherry-markdown/dist/types/Sanitizer.d.ts 85 B
./packages/cherry-markdown/dist/types/toolbars/Bubble.d.ts 657 B
./packages/cherry-markdown/dist/types/toolbars/BubbleFormula.d.ts 1.38 kB
./packages/cherry-markdown/dist/types/toolbars/BubbleTable.d.ts 329 B
./packages/cherry-markdown/dist/types/toolbars/FloatMenu.d.ts 577 B
./packages/cherry-markdown/dist/types/toolbars/HiddenToolbar.d.ts 226 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Align.d.ts 191 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Audio.d.ts 322 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Bold.d.ts 455 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Br.d.ts 318 B
./packages/cherry-markdown/dist/types/toolbars/hooks/ChangeLocale.d.ts 252 B
./packages/cherry-markdown/dist/types/toolbars/hooks/CheckList.d.ts 353 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Code.d.ts 398 B
./packages/cherry-markdown/dist/types/toolbars/hooks/CodeTheme.d.ts 451 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Color.d.ts 2.11 kB
./packages/cherry-markdown/dist/types/toolbars/hooks/Copy.d.ts 697 B
./packages/cherry-markdown/dist/types/toolbars/hooks/CursorPosition.d.ts 207 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Detail.d.ts 324 B
./packages/cherry-markdown/dist/types/toolbars/hooks/DrawIo.d.ts 421 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Export.d.ts 195 B
./packages/cherry-markdown/dist/types/toolbars/hooks/File.d.ts 319 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Formula.d.ts 459 B
./packages/cherry-markdown/dist/types/toolbars/hooks/FullScreen.d.ts 206 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Graph.d.ts 736 B
./packages/cherry-markdown/dist/types/toolbars/hooks/H1.d.ts 390 B
./packages/cherry-markdown/dist/types/toolbars/hooks/H2.d.ts 391 B
./packages/cherry-markdown/dist/types/toolbars/hooks/H3.d.ts 391 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Header.d.ts 505 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Hr.d.ts 322 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Image.d.ts 345 B
./packages/cherry-markdown/dist/types/toolbars/hooks/InlineCode.d.ts 429 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Insert.d.ts 473 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Italic.d.ts 464 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Justify.d.ts 163 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Link.d.ts 347 B
./packages/cherry-markdown/dist/types/toolbars/hooks/List.d.ts 486 B
./packages/cherry-markdown/dist/types/toolbars/hooks/MobilePreview.d.ts 316 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Ol.d.ts 349 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Panel.d.ts 475 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Pdf.d.ts 318 B
./packages/cherry-markdown/dist/types/toolbars/hooks/ProTable.d.ts 561 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Publish.d.ts 388 B
./packages/cherry-markdown/dist/types/toolbars/hooks/QuickTable.d.ts 441 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Quote.d.ts 245 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Redo.d.ts 268 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Ruby.d.ts 447 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Search.d.ts 369 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Settings.d.ts 752 B
./packages/cherry-markdown/dist/types/toolbars/hooks/ShortcutKey.d.ts 442 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Size.d.ts 301 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Split.d.ts 319 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Strikethrough.d.ts 404 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Sub.d.ts 372 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Sup.d.ts 372 B
./packages/cherry-markdown/dist/types/toolbars/hooks/SwitchModel.d.ts 285 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Table.d.ts 364 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Theme.d.ts 465 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Toc.d.ts 320 B
./packages/cherry-markdown/dist/types/toolbars/hooks/TogglePreview.d.ts 340 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Ul.d.ts 350 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Underline.d.ts 404 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Undo.d.ts 245 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Video.d.ts 322 B
./packages/cherry-markdown/dist/types/toolbars/hooks/Word.d.ts 318 B
./packages/cherry-markdown/dist/types/toolbars/hooks/WordCount.d.ts 376 B
./packages/cherry-markdown/dist/types/toolbars/Sidebar.d.ts 224 B
./packages/cherry-markdown/dist/types/toolbars/Toc.d.ts 390 B
./packages/cherry-markdown/dist/types/toolbars/Toolbar.d.ts 2.28 kB
./packages/cherry-markdown/dist/types/toolbars/ToolbarRight.d.ts 156 B
./packages/cherry-markdown/dist/types/UrlCache.d.ts 529 B
./packages/cherry-markdown/dist/types/utils/async-render-handler.d.ts 344 B
./packages/cherry-markdown/dist/types/utils/autoindent.d.ts 450 B
./packages/cherry-markdown/dist/types/utils/cm-search-replace.d.ts 1.52 kB
./packages/cherry-markdown/dist/types/utils/code-preview-language-setting.d.ts 169 B
./packages/cherry-markdown/dist/types/utils/color.d.ts 205 B
./packages/cherry-markdown/dist/types/utils/config.d.ts 984 B
./packages/cherry-markdown/dist/types/utils/copy.d.ts 577 B
./packages/cherry-markdown/dist/types/utils/dialog.d.ts 195 B
./packages/cherry-markdown/dist/types/utils/dom.d.ts 650 B
./packages/cherry-markdown/dist/types/utils/downloadUtil.d.ts 426 B
./packages/cherry-markdown/dist/types/utils/env.d.ts 482 B
./packages/cherry-markdown/dist/types/utils/error.d.ts 185 B
./packages/cherry-markdown/dist/types/utils/event.d.ts 440 B
./packages/cherry-markdown/dist/types/utils/export.d.ts 351 B
./packages/cherry-markdown/dist/types/utils/exportWord.d.ts 424 B
./packages/cherry-markdown/dist/types/utils/file.d.ts 848 B
./packages/cherry-markdown/dist/types/utils/footnoteHoverHandler.d.ts 889 B
./packages/cherry-markdown/dist/types/utils/htmlparser.d.ts 1.67 kB
./packages/cherry-markdown/dist/types/utils/image.d.ts 454 B
./packages/cherry-markdown/dist/types/utils/imgSizeHandler.d.ts 969 B
./packages/cherry-markdown/dist/types/utils/imgToolHandler.d.ts 332 B
./packages/cherry-markdown/dist/types/utils/lazyLoadImg.d.ts 2.57 kB
./packages/cherry-markdown/dist/types/utils/lineFeed.d.ts 720 B
./packages/cherry-markdown/dist/types/utils/listContentHandler.d.ts 645 B
./packages/cherry-markdown/dist/types/utils/lookbehind-replace.d.ts 381 B
./packages/cherry-markdown/dist/types/utils/LRUCache.d.ts 554 B
./packages/cherry-markdown/dist/types/utils/mathjax.d.ts 218 B
./packages/cherry-markdown/dist/types/utils/myersDiff.d.ts 906 B
./packages/cherry-markdown/dist/types/utils/pasteHelper.d.ts 757 B
./packages/cherry-markdown/dist/types/utils/platformTransform.d.ts 151 B
./packages/cherry-markdown/dist/types/utils/recount-pos.d.ts 259 B
./packages/cherry-markdown/dist/types/utils/regexp.d.ts 1.58 kB
./packages/cherry-markdown/dist/types/utils/sanitize.d.ts 423 B
./packages/cherry-markdown/dist/types/utils/selection.d.ts 723 B
./packages/cherry-markdown/dist/types/utils/shortcutKey.d.ts 539 B
./packages/cherry-markdown/dist/types/utils/svgUtils.d.ts 650 B
./packages/cherry-markdown/dist/types/utils/tableContentHandler.d.ts 3.24 kB

compressed-size-action

@RSS1102 RSS1102 added the minor 破坏性更改,break change label Feb 2, 2026
@RSS1102 RSS1102 force-pushed the rss1102/chore/build/simplify-rollup-config branch 2 times, most recently from dd5ecbe to aa9b262 Compare February 13, 2026 07:45
@RSS1102

This comment was marked as outdated.

@RSS1102
Copy link
Copy Markdown
Collaborator Author

RSS1102 commented Feb 24, 2026

用户想复制修正后的功能对比表。让我把表格整理得更清晰,方便用户复制。 @sunsonliu

修正后的功能对比表

功能 Stream 模式 普通模式 + enablePreviewerBubble: true 普通模式 + enablePreviewerBubble: false
代码块复制/展开
公式工具栏
普通 <a> 链接点击冒泡
TOC 目录链接 (updateLocationHash=false) ❌ 阻止冒泡 ❌ 阻止冒泡 ❌ 阻止冒泡
脚注链接 (updateLocationHash=false) ❌ 阻止冒泡 ❌ 阻止冒泡 ❌ 阻止冒泡
脚注链接 (clickRefNumberCallback 返回 false) ❌ 阻止冒泡 ❌ 阻止冒泡 ❌ 阻止冒泡
图片编辑
表格编辑
列表编辑
checkbox 编辑

<a> 标签点击冒泡条件

会阻止冒泡的情况:

  1. TOC 目录链接 + updateLocationHash === falsee.stopPropagation() + e.preventDefault()
  2. 脚注链接 + updateLocationHash === falsee.stopPropagation() + e.preventDefault()
  3. 脚注链接 + clickRefNumberCallback 返回 falsee.stopPropagation() + e.preventDefault()

会冒泡的情况:

  1. 普通链接(非 TOC、非脚注)
  2. TOC 目录链接 + updateLocationHash === true(默认)
  3. 脚注链接 + updateLocationHash === true + clickRefNumberCallback 未返回 false

@RSS1102 RSS1102 force-pushed the rss1102/chore/build/simplify-rollup-config branch 2 times, most recently from 8f3596b to 758d217 Compare February 25, 2026 06:30
@RSS1102 RSS1102 force-pushed the rss1102/chore/build/simplify-rollup-config branch from 48b597b to c618edf Compare February 25, 2026 08:17
@RSS1102 RSS1102 changed the title build: 只输出 ESM 和 UMD 格式,并移除 **/min.js refactor: 优化构建配置并增强 Stream 模式预览区交互功能 Feb 25, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

该 PR 面向 0.11.0-alpha 系列,核心聚焦于 构建配置/产物调整(统一 ESM、简化 rollup 配置、处理动态导入)并增强 Stream 模式下预览区交互(在无编辑器时保留只读交互、禁用编辑能力)。

Changes:

  • 重构/简化 rollup 构建配置:移除 CJS 构建路径、调整输出产物、处理(或规避)动态导入导致的代码分割。
  • Stream/PreviewOnly 场景增强:PreviewerBubble 在无 Editor 时仍初始化以支持基础点击交互;表格/列表/代码块编辑能力按“是否有 editor”自动降级。
  • 公式工具增强:在 math DOM 上写入 data-content 并在公式工具栏中从 DOM 获取 latex 源码。

Reviewed changes

Copilot reviewed 31 out of 33 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
packages/cherry-markdown/tsconfig.json src/index.stream.js 纳入 types 构建输入
packages/cherry-markdown/src/utils/tableContentHandler.js Stream 场景无 CodeMirror 时跳过表格编辑初始化
packages/cherry-markdown/src/utils/listContentHandler.js Stream 场景无 Editor 时跳过列表编辑逻辑,并在 remove/selection 处加保护
packages/cherry-markdown/src/utils/formulaUtilsHandler.js 公式工具从依赖 Editor 改为依赖 $cherry,并改为从 DOM data-content 获取 latex
packages/cherry-markdown/src/utils/codeBlockContentHandler.js CodeMirror 改为动态加载;无编辑器时禁用代码块编辑相关能力
packages/cherry-markdown/src/toolbars/PreviewerBubble.js 增加 $hasEditor(),区分基础交互/只读交互/编辑交互;Stream 下禁用编辑能力但保留基础能力
packages/cherry-markdown/src/index.stream.js Stream 入口改为直接导出 CherryStream,并调整导出内容
packages/cherry-markdown/src/index.stream.core.js 删除旧的 stream core 入口文件
packages/cherry-markdown/src/core/hooks/Suggester.js 为避免 stream 包引入 codemirror,改为动态加载 Pass 并提供 fallback
packages/cherry-markdown/src/core/hooks/MathBlock.js 输出 math DOM 增加 data-content(latex 源)
packages/cherry-markdown/src/core/hooks/InlineMath.js 输出 inline math DOM 增加 data-content(latex 源)
packages/cherry-markdown/src/Previewer.js initWithoutEditor() 始终初始化 PreviewerBubble(以支持基础交互)
packages/cherry-markdown/src/CherryStream.js 增强类型标注;Engine/Previewer 构造处加显式类型转换
packages/cherry-markdown/package.json 版本号/入口 main 调整;移除 build:cjs;构建脚本/检查脚本更新
packages/cherry-markdown/build/rollup.stream.config.js stream 构建:禁用 tree-shaking;添加替换 codemirror 动态导入的插件;external 合并
packages/cherry-markdown/build/rollup.engine.config.js engine 构建:类似处理动态导入/禁用 tree-shaking/禁用 chunks
packages/cherry-markdown/build/rollup.core.config.js core 构建:类似处理动态导入/禁用 tree-shaking/禁用 chunks
packages/cherry-markdown/build/rollup.base.config.js base 配置:移除 CJS 分支逻辑;dist-types 生成增强安全检查;全局禁用 tree-shaking
packages/cherry-markdown/build/replacePaths.js 改为 ESM 版本 replace-in-file 调用实现
packages/cherry-markdown/build/replacePaths.cjs 删除旧 CJS replacePaths
packages/cherry-markdown/build/build.js full 构建输出调整(移除 min UMD 输出;内联动态导入)
packages/cherry-markdown/build/addons.build.js addons 同时生成 UMD/ESM 两份输出
packages/cherry-markdown/build/addons.build.cjs 删除旧 CJS addons build
examples/preview_only.html demo:改为 module 内 import 配置,调整 import 顺序
examples/notoolbar.html demo:改为 module 内 import 配置,调整 import 顺序
examples/multiple.html demo:改为 module 内 import 配置,调整 import 顺序
examples/index.html demo:改为 module 内 import 配置,调整 import 顺序
examples/img.html demo:调整 import/fetch 顺序
examples/h5.html demo:改为 module 内 import 配置,调整 import 顺序
examples/assets/scripts/ai-chat-stream-demo.js demo:开启 enablePreviewerBubble;格式化细节
.eslintignore 精准忽略 cherry-markdown/src/libs/*.js

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/cherry-markdown/src/utils/codeBlockContentHandler.js Outdated
Comment thread packages/cherry-markdown/build/rollup.stream.config.js Outdated
Comment thread packages/cherry-markdown/src/core/hooks/Suggester.js Outdated
Comment thread packages/cherry-markdown/src/Previewer.js
Comment thread packages/cherry-markdown/src/index.stream.js
Comment thread packages/cherry-markdown/package.json
Comment thread packages/cherry-markdown/build/rollup.core.config.js
@RSS1102
Copy link
Copy Markdown
Collaborator Author

RSS1102 commented Mar 5, 2026

新方案: 隔离 stream 引入 codeMirror @sunsonliu

Cherry.js                    CherryStream.js
     │                              │
     ▼                              ▼
Editor (codemirrorModule)    (无 Editor)
     │                              │
     ▼                              ▼
Previewer.init(editor)       Previewer.initWithoutEditor()
  └ codemirrorModule = editor?.constructor?.codemirrorModule   └ codemirrorModule = null
     │                              │
     └──────────┬───────────────────┘
                ▼
        PreviewerBubble
          └ const { codemirrorModule } = this.previewer;

@RSS1102
Copy link
Copy Markdown
Collaborator Author

RSS1102 commented Mar 5, 2026

@sunsonliu

┌──────────────────────┐     ┌──────────────────────┐
│      Cherry.js       │     │   CherryStream.js    │
│          │           │     │          │           │
│          ▼           │     │          ▼           │
│ Editor (codemirror-  │     │    (无 Editor)       │
│      Module)         │     │    editor = null     │
│          │           │     │          │           │
│          ▼           │     │          ▼           │
│ Previewer.init()     │     │ Previewer.init       │
│ codemirrorModule =   │     │ WithoutEditor()      │
│ editor?.constructor  │     │ codemirrorModule     │
│ ?.codemirrorModule   │     │     = null           │
│          │           │     │          │           │
│          ▼           │     │          ▼           │
│ getPass(cherry)      │     │ bindEvent()          │
│   → 真实 Pass ✅     │     │   早期 return ✅      │
└──────────────────────┘     └──────────────────────┘

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 32 out of 34 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/cherry-markdown/build/replacePaths.js Outdated
Comment thread examples/assets/scripts/ai-chat-stream-demo.js Outdated
Comment thread packages/cherry-markdown/src/core/hooks/MathBlock.js
Comment thread packages/cherry-markdown/src/core/hooks/MathBlock.js
Comment thread packages/cherry-markdown/src/core/hooks/InlineMath.js Outdated
Comment thread packages/cherry-markdown/src/core/hooks/InlineMath.js Outdated
Comment thread packages/cherry-markdown/src/core/hooks/Suggester.js
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 33 out of 36 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/cherry-markdown/src/utils/formulaUtilsHandler.js Outdated
Comment thread packages/cherry-markdown/src/toolbars/PreviewerBubble.js
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 33 out of 36 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/cherry-markdown/src/core/hooks/Suggester.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor 破坏性更改,break change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants