Skip to content

feat(tiptap): integrate minimal Tiptap editor load/save - #435

Open
dengzhongyuan365-dev wants to merge 1 commit into
linuxdeepin:develop/snipefrom
dengzhongyuan365-dev:feature/v-375-ttp022-tiptap-load-save
Open

feat(tiptap): integrate minimal Tiptap editor load/save#435
dengzhongyuan365-dev wants to merge 1 commit into
linuxdeepin:develop/snipefrom
dengzhongyuan365-dev:feature/v-375-ttp022-tiptap-load-save

Conversation

@dengzhongyuan365-dev

@dengzhongyuan365-dev dengzhongyuan365-dev commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary

First integration of the Tiptap editor runtime, validating only loading and saving the envelope content. The Summernote fallback path remains untouched and Tiptap is not enabled by default.

Changes

  • web-editor runtime entry (tiptap-editor.html/tiptap-editor.js): minimal Tiptap editor with Vite build config and tiptap-extensions module; built dist/ artifacts are committed so the runtime loads offline from bundled resources
  • TiptapTempBridge (src/common): C++ bridge that loads the Tiptap editor via QWebEngineView, injects envelope content, and saves the editor.getJSON() wrapped envelope back
  • Resource registration: new deepin-voice-note-tiptap.qrc with QRC/install fallback load path; registered in CMakeLists.txt
  • QML integration: TiptapTempBridge registered in QML, WebEngineView.qml adjusted
  • Build config: package.json, CMakeLists.txt, and tests CMakeLists.txt updated for the new module and resources

Testing

  • Frontend npm test: 38 pass / 0 fail (round-trip load/save + schema/envelope validation)
  • C++ GTest ut_tiptaptempbridge: 5/5 pass
  • Built artifacts verified offline (grep -rE "https?://" dist/ — no runtime external dependencies)
  • Summernote existing path unaffected (no changes to Summernote load/save/webobj registration)

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @dengzhongyuan365-dev, your pull request is larger than the review limit of 150000 diff characters

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dengzhongyuan365-dev

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dengzhongyuan365-dev
dengzhongyuan365-dev force-pushed the feature/v-375-ttp022-tiptap-load-save branch from 76b1c5c to cb4ef16 Compare July 27, 2026 09:30
@github-actions

Copy link
Copy Markdown
  • 检测到敏感词unset变动
详情
    {
    "unset": {
        "tests/src/common/ut_tiptaptempbridge.cpp": {
            "b": [
                "TEST_F(UT_TiptapTempBridge, UT_TiptapTempBridge_debugEnabled_unset_001)"
            ]
        }
    }
}

@dengzhongyuan365-dev dengzhongyuan365-dev changed the title feat(tiptap): integrate minimal Tiptap load/save (TTP-022) feat(tiptap): integrate minimal Tiptap editor load/save Jul 27, 2026
First integration of the Tiptap editor runtime, validating only loading
and saving the envelope content. The Summernote fallback path remains
untouched and Tiptap is not enabled by default.

- Add web-editor runtime entry (tiptap-editor.html/js) with Vite build
  config and tiptap-extensions module; commit built dist artifacts so
  the runtime loads offline from bundled resources
- Add TiptapTempBridge (src/common) C++ bridge that loads the Tiptap
  editor via QWebEngineView, injects envelope content, and saves the
  editor.getJSON() wrapped envelope back
- Add deepin-voice-note-tiptap.qrc and register the Tiptap runtime
  resources; wire QRC/install fallback load path
- Register TiptapTempBridge in QML and adjust WebEngineView.qml
- Update package.json/CMakeLists/tests CMake for the new module and
  resources
- Add frontend round-trip unit test (npm test) and C++ GTest
  ut_tiptaptempbridge covering load/save envelope behavior

Log: 接入最小 Tiptap 编辑器运行时,验证加载和保存 envelope.content;新增运行时入口、C++ 桥接、QRC 资源注册、QML 注册,含前端往返单测和 C++ GTest
Influence: 新增 web-editor 运行时入口及打包产物、src/common/tiptaptempbridge 桥接、deepin-voice-note-tiptap.qrc 资源、QML 注册及 WebEngineView 调整;不改动 Summernote 回退路径,不默认启用 Tiptap
@dengzhongyuan365-dev
dengzhongyuan365-dev force-pushed the feature/v-375-ttp022-tiptap-load-save branch from cb4ef16 to 4e94098 Compare July 27, 2026 10:00
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:92分

■ 【总体评价】

代码实现了 Tiptap 富文本编辑器的临时桥接通道,架构清晰、测试完备,无安全漏洞
因残留调试日志及少量代码质量问题扣8分

■ 【详细分析】

  • 1.语法逻辑 基本正确 ✓
    tiptaptempbridge.cpptiptapHtmlPath() 使用 C 预处理器字符串拼接 "file://" TIPTAP_WEB_PATH "/tiptap-editor.html",CMake 中 add_definitions(-DTIPTAP_WEB_PATH="...") 正确带引号,拼接可行。QML 中 Component.onCompletedregisterObject 再设 webChannel 再设 url,时序正确,确保 JS 加载页面后可访问 qt.webChannelTransportbindTiptapTempChannelJSON.parse 有 try/catch 回退至空文档,容错合理。ut_tiptaptempbridge.cpp 中环境变量测试逻辑正确。
    潜在问题:tiptapHtmlPath() 每次调用都执行 QResource::isValid() 查询,虽当前仅初始化时调用一次,但若未来频繁调用存在轻微开销;QML 中若 debugEnabled 运行时切换,registerObject 可能重复注册同名对象导致警告
    建议:缓存 QResource::isValid() 结果为静态变量;在 Loader onActiveChanged 中处理反注册逻辑
  • 2.代码质量 良好 ✓
    文件结构清晰,C++ 桥接类职责单一,JS 模块分层合理(编辑器初始化与通道绑定分离)。SPDX 许可证头齐全,注释充分。测试覆盖环境变量、路径解析、回调安全三个维度。vite.config.js 中自定义 spdxBannerPlugin 为产物注入版权头,满足 REUSE 合规。
    潜在问题:tiptapTempBridge_providerqInfo() << "tiptapTempBridge_provider called"; 为调试日志残留于生产代码;Q_UNUSED(engine)Q_UNUSED(scriptEngine) 放在 qInfo() 之后,顺序略不规范;jsContentSaved 仅打印长度未做任何业务处理,属于占位实现但未标注 TODO
    建议:移除 qInfo() 调试日志或改为 qCDebug 分类日志;在 jsContentSaved 中添加 // TODO(TTP-023): persist envelope 注释
  • 3.代码性能 无性能问题 ✓
    Loader 通过 DVN_TIPTAP_DEBUG 环境变量门控,生产环境不加载 Tiptap WebEngineView,零性能开销。Debug 模式下 WebEngineView 独立于 Summernote webView,互不干扰。Vite 打包配置 inlineDynamicImports: trueassetsInlineLimit: 100000000 将所有资源内联为单文件,减少运行时网络请求。
    建议:无需改进
  • 4.代码安全 存在0个安全漏洞 ✓
    漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
    所有输入路径均来自编译期 CMake 宏或内部 C++ 桥接信号,无外部用户可控输入。tiptapHtmlPath() 返回的 file:// 路径由编译期 TIPTAP_WEB_PATH 宏决定,不存在路径遍历风险。JS 侧 JSON.parse 失败时安全回退至空文档,ProseMirror schema 验证机制确保 setContent 不会执行任意 HTML/JS。QML WebEngineView 仅加载 qrc: 或本地 file:// 资源,无远程内容加载。jsContentSaved 仅记录长度,不泄露文档内容。
    建议:在 TTP-023 正式通道中增加 envelope schemaVersion 字段校验,防止版本不兼容导致的数据损坏

■ 【改进建议代码示例】

// src/common/tiptaptempbridge.cpp — 移除调试日志,缓存资源检查结果
QString TiptapTempBridge::tiptapHtmlPath() const
{
    static const bool qrcValid = QResource(":/tiptap-editor.html").isValid();
    if (qrcValid) {
        return QStringLiteral("qrc:/tiptap-editor.html");
    }
    return QStringLiteral("file://" TIPTAP_WEB_PATH "/tiptap-editor.html");
}

void TiptapTempBridge::jsContentSaved(const QString &envelopeJson)
{
    // TODO(TTP-023): persist envelope to note storage
    qCDebug(dvnTiptap) << "Tiptap content saved, envelope length:" << envelopeJson.length();
}
// src/common/VNoteMainManager.cpp — 移除调试日志
QObject *tiptapTempBridge_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
{
    Q_UNUSED(engine)
    Q_UNUSED(scriptEngine)
    static TiptapTempBridge instance;
    return &instance;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants