Replace unmaintained html2canvas with @zumer/snapdom for mind-map/image export

未关闭
#1,210 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
78/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
领域
frontend

调研方向

Start with src/components/studio/views/html2canvas-loader.ts, which isolates the dependency behind a loader, then inspect src/components/studio/views/mindmap-export.ts for option and return-value usage. Replace the dynamic import with @zumer/snapdom, map the supported options, and update src/components/studio/views/mindmap-export.test.ts to verify the export behavior rather than matching html2canvas output. Also check the standalone HTML reader path for embedded captures and DPR or size handling.

由索引模型根据 Issue 内容生成。

描述

chore deps priority: medium

Summary

html2canvas (used for mind-map/PNG export) has had no stable release since January 2022 (1.4.1); its own README still describes the project as experimental and recommends against production use. The 2026 ecosystem consensus replacement is a foreignObject-based capture library — @zumer/snapdom (actively maintained, v2.x, zero-dependency, TypeScript).

Evidence

  • Dependency: html2canvas ^1.4.1 in package.json.
  • Usage: src/components/studio/views/html2canvas-loader.ts (dedicated loader) and src/components/studio/views/mindmap-export.ts (consumer).
  • Tests exist, which keeps the migration safe: src/components/studio/views/mindmap-export.test.ts.

Impact

  • Fidelity: html2canvas hand-paints CSS in JS and ships a long list of unsupported properties (pseudo-elements, some fonts, Shadow DOM). SnapDOM clones the DOM and lets the browser rasterize, so styled mind-map exports (custom themes, web fonts from "Editorial Paper & Saffron") render correctly.
  • Performance: serialize-then-rasterize is several times faster on dense mind-map trees; html2canvas cost grows per node in its JS interpreter.
  • Supply chain / maintenance: an unmaintained rendering dependency is a standing risk in the dependency-audit posture this repo already enforces (scripts/verify-deps.sh, Dependabot alerts).

Proposed approach

  1. Swap the loader (html2canvas-loader.ts) to dynamically import @zumer/snapdom behind the same interface — the loader abstraction makes this a one-module change.
  2. Map options (scale, backgroundColor, filter) per the official migration guide; mind the return-value change (reusable CaptureResult).
  3. Re-baseline mindmap-export.test.ts against live rendering, not against html2canvas output (differences are usually features html2canvas was dropping).
  4. Verify export size + DPR handling in the encrypted standalone HTML reader path if it embeds captures.

References

主要语言
TypeScript
星标
3
派生
2
平均合并
11 小时 49 分钟
30 天内合并 PR
102

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

d-oit/do-knowledge-studio 的其他 Issue

查看 d-oit/do-knowledge-studio 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。