refactor: externalize upload and conflict helpers
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// MNote document conflict panel 运行时外置模块。
|
||||
// 第一刀:纯 DOM 清理 helper clearSessionConflictSurface。
|
||||
// 本文件以 type="module" 加载,执行时机可能晚于 inline script。
|
||||
// web_shell.rs 的 inline clearSessionConflictSurface 会优先委托到
|
||||
// window.__mnoteDocumentConflictPanelRuntime;
|
||||
// 模块尚未加载或加载失败时,inline script 保留原地实现兜底。
|
||||
|
||||
/**
|
||||
* 清除指定 session 所有视图中冲突面板 DOM。
|
||||
* 只做 DOM 清理,不处理冲突 merge/accept/keep 业务逻辑。
|
||||
* @param {Object} session - document session 对象
|
||||
* @param {Object} deps - 依赖注入,从 inline 上下文传入
|
||||
* @param {Function} deps.sessionViews - session.views 迭代器
|
||||
*/
|
||||
function clearSessionConflictSurface(session, deps) {
|
||||
var views = deps && typeof deps.sessionViews === 'function'
|
||||
? deps.sessionViews(session)
|
||||
: [];
|
||||
views.forEach(function(view) {
|
||||
var host = view.runtimeDescriptor.root.closest('.document-pane') || view.runtimeDescriptor.root;
|
||||
if (!(host instanceof HTMLElement)) return;
|
||||
host.querySelectorAll('[data-testid="mnote-editor-conflict-panel"]').forEach(function(node) { node.remove(); });
|
||||
});
|
||||
}
|
||||
|
||||
window.__mnoteDocumentConflictPanelRuntime = {
|
||||
clearSessionConflictSurface: clearSessionConflictSurface
|
||||
};
|
||||
Reference in New Issue
Block a user