feat(tiptap): add scroll reporting channel and wire host interactions - #445
Conversation
Add jsReportScroll entry point and scrollChanged signal to TiptapChannelBridge for receiving scroll position from the frontend editor, connected in VNoteMainManager. Wire tiptapWebView in WebEngineView.qml for context menu, scroll, focus, and findText search. Add Qt5/Qt6 context menu adaptation in web_engine_handler. Add unit tests for scroll reporting.
There was a problem hiding this comment.
Sorry @dengzhongyuan365-dev, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideAdds scroll position reporting from the Tiptap editor to the host, wires the debug-only Tiptap WebView into existing host interactions (context menu, search, focus, select/delete), and adapts voice-menu handling to avoid legacy JS paths in Tiptap mode, with unit tests validating the new scroll reporting behavior. Sequence diagram for Tiptap scroll reporting to hostsequenceDiagram
participant JsEditor as JsTiptapEditor
participant Bridge as TiptapChannelBridge
participant MainMgr as VNoteMainManager
JsEditor->>Bridge: jsReportScroll(scrollTop)
Bridge->>Bridge: compute isTop = (scrollTop <= 0)
Bridge-->>MainMgr: scrollChanged(isTop)
MainMgr->>MainMgr: scrollChange(isTop) (update hasScroll / header state)
Sequence diagram for Tiptap context menu and voice deletion handlingsequenceDiagram
actor User
participant TiptapView as tiptapWebView
participant Handler as WebEngineHandler
participant JsContent as JsContent
participant Bridge as TiptapChannelBridge
User->>TiptapView: onContextMenuRequested(req)
TiptapView->>TiptapView: runJavaScript(probeJs)
TiptapView-->>Handler: onSaveMenuParam(type, json)
TiptapView-->>Handler: onContextMenuRequested(req)
Handler->>Handler: processVoiceMenuRequest(request)
alt debugEnabled() is false
Handler-->>JsContent: callJsDeleteSelection()
else debugEnabled() is true
Handler->>Handler: skip legacy Summernote delete path
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Coerce req.position.x/y via Number() with isNaN guard to reject non-numeric values early. Use String(Math.round()) to produce pure digit strings before concatenating into the probe script, eliminating JavaScript injection risk from untrusted position data.
|
/test github-pr-review-ci |
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // WebEngineView.qml 优化示例:将DOM检测逻辑移至前端JS函数
// 假设前端已定义 window.__dvnCheckContextMenu(x, y) 函数
onContextMenuRequested: req => {
req.accepted = true;
var rawX = Number(req.position.x);
var rawY = Number(req.position.y);
if (isNaN(rawX) || isNaN(rawY)) return;
var sx = String(Math.round(rawX));
var sy = String(Math.round(rawY));
tiptapWebView.runJavaScript(
"window.__dvnCheckContextMenu ? window.__dvnCheckContextMenu(" + sx + "," + sy + ") : JSON.stringify({type:2,json:''})",
function(result) {
var info = null;
try { info = JSON.parse(result); } catch(e) {}
if (!info) return;
if (info.type === 0) return;
handler.onSaveMenuParam(info.type, info.json);
handler.onContextMenuRequested(req);
});
} |
What changed
Adds scroll position reporting to the Tiptap channel bridge and wires the Tiptap WebView into existing host-interaction flows (context menu, scroll, focus, search). All behind the debug-only flag.
jsReportScrollentry point andscrollChangedsignal to receive scroll position from the frontend editor.scrollChangedto track whether the editor is scrolled to the top.tiptapWebViewfor context menu requests, scroll reporting, editor focus, andfindText-based search.ut_tiptapchannelbridgetests covering top and scrolled scroll states.Why
The Tiptap editor (debug-only) lacked host-interaction parity with the legacy editor — no scroll reporting, context menu, focus, or search wiring. This adds the channel and QML wiring needed for the debug-mode editor to reach feature parity without affecting the default editor.
How verified
ut_tiptapchannelbridgepasses (39 tests including 2 new scroll tests).Summary by Sourcery
Add scroll position reporting and host interaction wiring for the debug-only Tiptap editor to reach parity with the legacy editor.
New Features:
Bug Fixes:
Tests: