refactor: extract conflict panel host mount helper
This commit is contained in:
@@ -2139,8 +2139,6 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str {
|
||||
const renderSessionConflictSurface = (session, message) => {
|
||||
clearSessionConflictSurface(session);
|
||||
sessionViews(session).forEach((view) => {
|
||||
const host = view.runtimeDescriptor.root.closest('.document-pane') || view.runtimeDescriptor.root;
|
||||
if (!(host instanceof HTMLElement)) return;
|
||||
const runtime = window.__mnoteDocumentConflictPanelRuntime;
|
||||
const handleConflictActionError = (error) => {
|
||||
setSessionStatus(session, 'external-change-conflict', error instanceof Error ? error.message : String(error));
|
||||
@@ -2211,6 +2209,13 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str {
|
||||
});
|
||||
}
|
||||
|
||||
if (runtime && typeof runtime.mountSessionConflictPanel === 'function') {
|
||||
if (runtime.mountSessionConflictPanel(view.runtimeDescriptor.root, panel)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const host = view.runtimeDescriptor.root.closest('.document-pane') || view.runtimeDescriptor.root;
|
||||
if (!(host instanceof HTMLElement)) return;
|
||||
const header = host.querySelector('.document-shell-header');
|
||||
if (header && header.parentNode) {
|
||||
header.parentNode.insertBefore(panel, header.nextSibling);
|
||||
@@ -5628,6 +5633,9 @@ mod tests {
|
||||
assert!(html.contains("mnote-conflict-open-diff"));
|
||||
assert!(html.contains("mnote-conflict-merge-text"));
|
||||
assert!(html.contains("mnote-conflict-merge-save"));
|
||||
assert!(
|
||||
html.contains("runtime.mountSessionConflictPanel(view.runtimeDescriptor.root, panel)")
|
||||
);
|
||||
assert!(html.contains("agent run"));
|
||||
assert!(!html.contains(
|
||||
"setInterval(() => {\n void pollLocalMarkdownExternalChange();\n }, 1200);"
|
||||
@@ -5665,9 +5673,10 @@ mod tests {
|
||||
assert!(DOCUMENT_CONFLICT_PANEL_RUNTIME_JS.contains("onUseCurrent"));
|
||||
assert!(DOCUMENT_CONFLICT_PANEL_RUNTIME_JS.contains("onUseDisk"));
|
||||
assert!(DOCUMENT_CONFLICT_PANEL_RUNTIME_JS.contains("onSaveMerge"));
|
||||
assert!(DOCUMENT_CONFLICT_PANEL_RUNTIME_JS.contains("function runSessionConflictAction"));
|
||||
assert!(DOCUMENT_CONFLICT_PANEL_RUNTIME_JS.contains("function mountSessionConflictPanel"));
|
||||
assert!(DOCUMENT_CONFLICT_PANEL_RUNTIME_JS
|
||||
.contains("runSessionConflictAction: runSessionConflictAction"));
|
||||
assert!(DOCUMENT_CONFLICT_PANEL_RUNTIME_JS.contains("function runSessionConflictAction"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user