feat(markdown): integrate three-view orchestration in EditWrapper - #532
Conversation
There was a problem hiding this comment.
Sorry @pengfeixx, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
13a33fc to
bd6c294
Compare
Reviewer's GuideThis PR adds a three-view Markdown orchestration to EditWrapper (edit, read-only render, and live preview splitter), with lazy MarkdownView creation, a shared renderer interface, debounced content syncing, bidirectional scroll syncing, theme propagation, and automatic mode transitions based on Markdown detection and language changes. Sequence diagram for Markdown file load and automatic view mode selectionsequenceDiagram
actor User
participant EditWrapper
participant MarkdownLogic
participant ViewModeFsm
participant IMarkdownRenderer
User->>EditWrapper: reinitOnFileLoad(encode)
EditWrapper->>EditWrapper: updateMarkdownRecognition(filePath, definitionName)
EditWrapper->>MarkdownLogic: isMarkdown(filePath, definitionName)
MarkdownLogic-->>EditWrapper: isMarkdown
EditWrapper->>ViewModeFsm: resolveDefaultMode(isMarkdown)
ViewModeFsm-->>EditWrapper: ViewMode
EditWrapper->>EditWrapper: setViewMode(mode)
EditWrapper->>ViewModeFsm: canSwitchTo(mode, isMarkdown)
ViewModeFsm-->>EditWrapper: allowed
EditWrapper->>EditWrapper: ensureMarkdownViewCreated()
EditWrapper->>EditWrapper: ensureLiveSplitterCreated()
EditWrapper->>IMarkdownRenderer: setLayout(width, center)
EditWrapper->>IMarkdownRenderer: setMarkdown(content)
EditWrapper-->>User: viewModeChanged(mode)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Add a three-page view stack (edit page, read page, live-preview splitter) in EditWrapper with lazy-created MarkdownView. Wire 300ms throttled content sync with mdimg image rewrite, bidirectional ratio scroll sync with loop guard, theme injection on change and creation, markdown recognition on load and language switch with fallback/elevate mode transitions, and explicit show() after cross-container reparent. EditWrapper 集成三页视图栈(编辑页/查看页/实时预览分栏),懒创建 MarkdownView;接入 300ms 节流内容同步(含 mdimg 图片路径改写)、带 防回环护栏的双向比例滚动同步、 变更与创建时的主题注入、文件加载与 语言切换时的 Markdown 识别及模式回退/跃迁;跨容器 reparent 后显式 show() 防分栏零宽。 Log: 集成 Markdown 三视图编排与同步机制 PMS: TASK-393979 Influence: 打开 .md 默认实时预览;语言切为 Markdown 自动进入预览、 切走自动回退编辑视图。
bd6c294 to
358801d
Compare
deepin pr auto review★ 总体评分:92分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 建议在 EditWrapper 构造函数中保留或通过其他方式恢复光标模式的状态同步
// 如果 handleCursorModeChanged 确实不再需要,应确保 BottomBar 有其他机制获取该状态
// 以下是恢复连接的示例代码
// 在构造函数中添加:
connect(m_pTextEdit, &TextEdit::cursorModeChanged, this, [this](TextEdit::CursorMode mode) {
switch (mode) {
case TextEdit::Insert:
m_pBottomBar->setCursorStatus(tr("INSERT"));
break;
case TextEdit::Overwrite:
m_pBottomBar->setCursorStatus(tr("OVERWRITE"));
break;
case TextEdit::Readonly:
m_pBottomBar->setCursorStatus(tr("R/O"));
break;
}
});
// 在 setViewMode 中,针对 Edit 模式返回 Page0 时,建议显式调用 show() 以防万一
if (m_pEditPage->parentWidget() != m_viewStack) {
m_viewStack->insertWidget(0, m_pEditPage);
m_pEditPage->show(); // 显式恢复显示
}
m_viewStack->setCurrentWidget(m_pEditPage); |
|
感谢 @humanfans 在 #522 中的探索与贡献,QTextBrowser + QTextDocument::setMarkdown 的轻量实现为我们提供了很好的参照! 本 PR 采用 Milkdown(WebEngine)渲染内核,以三视图状态机(编辑/查看/实时预览)编排视图栈,配合 300ms 节流内容同步、双向比例滚动同步、编辑器主题注入与 mdimg:// 本地图片方案,并为后续升级 WYSIWYG 所见即所得编辑预留了零重构路径。 相较 #522,QTextDocument::setMarkdown 方案在渲染能力上存在一些局限:代码块无语法高亮、不支持数学公式,且每次输入全量重建文档、缺少节流与滚动同步(刷新后预览回到顶部),本地相对路径图片与外部链接也无法使用,因此选择了渲染能力更完整的 Web 内核方案。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
Add a three-page view stack (edit page, read page, live-preview splitter) in EditWrapper with lazy-created MarkdownView. Wire 300ms throttled content sync with mdimg image rewrite, bidirectional ratio scroll sync with loop guard, theme injection on change and creation, markdown recognition on load and language switch with fallback/elevate mode transitions, and explicit show() after cross-container reparent.
EditWrapper 集成三页视图栈(编辑页/查看页/实时预览分栏),懒创建
MarkdownView;接入 300ms 节流内容同步(含 mdimg 图片路径改写)、带
防回环护栏的双向比例滚动同步、变更与创建时的主题注入、文件加载与
语言切换时的 Markdown 识别及模式回退/跃迁;跨容器 reparent 后显式
show() 防分栏零宽。
Log: 集成 Markdown 三视图编排与同步机制
PMS: TASK-393979
Influence: 打开 .md 默认实时预览;语言切为 Markdown 自动进入预览、
切走自动回退编辑视图。
Summary by Sourcery
Integrate coordinated Markdown editing, reading, and live-preview modes into EditWrapper.
New Features:
Bug Fixes:
Enhancements:
Tests: