Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src-mdviewer/src/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,15 @@ export function initBridge() {

// Cursor sync toggle
on("toggle:cursorSync", ({ enabled }) => {
// Clear any existing highlights when cursor sync is disabled
if (!enabled) {
const viewer = document.getElementById("viewer-content");
if (viewer) {
_removeCursorHighlight(viewer);
}
_lastHighlightSourceLine = null;
_lastHighlightTargetLine = null;
}
sendToParent("mdviewrCursorSyncToggle", { enabled });
});

Expand Down
2 changes: 1 addition & 1 deletion src-mdviewer/src/components/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@ export function convertToMarkdown(contentEl) {

// Debounced content change emitter for bridge
let contentChangeTimer = null;
const CONTENT_CHANGE_DEBOUNCE = 300;
const CONTENT_CHANGE_DEBOUNCE = 50;

/**
* Re-compute data-source-line attributes on top-level block elements
Expand Down
14 changes: 10 additions & 4 deletions src-mdviewer/src/components/embedded-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ const THRESHOLD_BLOCKS = 640; // collapse block elements + image first
const THRESHOLD_LISTS = 590; // then lists
const THRESHOLD_TEXT = 590; // finally text formatting (all dropdowns collapsed)

// window.print() from inside an iframe is a no-op in WKWebView (Safari on macOS),
// which is what Tauri uses for the Mac desktop build. Hide the button there.
const _isMacWebKit = /Mac/.test(navigator.platform)
&& /AppleWebKit/.test(navigator.userAgent)
&& !/Chrome|CriOS|Edg|Firefox|FxiOS/.test(navigator.userAgent);

const allIcons = { Bold, Italic, Strikethrough, Underline, Code, Link, List, ListOrdered,
ListChecks, Quote, Minus, Table, FileCode, ChevronDown, Type, MoreHorizontal, Pencil, BookOpen, Link2, Link2Off, Printer, Image: ImageIcon, Upload, Sun, Moon };

Expand Down Expand Up @@ -89,9 +95,9 @@ function renderReadMode() {
<button class="toolbar-btn theme-toggle-btn" id="emb-theme-toggle" data-tooltip="${t("toolbar.theme") || "Toggle theme"}">
<i data-lucide="${isDark ? "sun" : "moon"}"></i>
</button>
<button class="toolbar-btn print-btn" id="emb-print-btn" data-tooltip="${t("toolbar.print") || "Print"}">
${_isMacWebKit ? "" : `<button class="toolbar-btn print-btn" id="emb-print-btn" data-tooltip="${t("toolbar.print") || "Print"}">
<i data-lucide="printer"></i>
</button>
</button>`}
<button class="toolbar-btn cursor-sync-btn${cursorSyncEnabled ? " active" : ""}" id="emb-cursor-sync" data-tooltip="${t("toolbar.cursor_sync") || "Cursor sync"}" aria-pressed="${cursorSyncEnabled}">
<i data-lucide="link-2" class="sync-on-icon"${cursorSyncEnabled ? "" : ' style="display:none"'}></i>
<i data-lucide="link-2-off" class="sync-off-icon"${cursorSyncEnabled ? ' style="display:none"' : ""}></i>
Expand Down Expand Up @@ -206,9 +212,9 @@ function renderEditMode(level) {
<button class="toolbar-btn theme-toggle-btn" id="emb-theme-toggle" data-tooltip="${t("toolbar.theme") || "Toggle theme"}">
<i data-lucide="${isDark ? "sun" : "moon"}"></i>
</button>
<button class="toolbar-btn print-btn" id="emb-print-btn" data-tooltip="${t("toolbar.print") || "Print"}">
${_isMacWebKit ? "" : `<button class="toolbar-btn print-btn" id="emb-print-btn" data-tooltip="${t("toolbar.print") || "Print"}">
<i data-lucide="printer"></i>
</button>
</button>`}
<button class="toolbar-btn cursor-sync-btn${cursorSyncEnabled ? " active" : ""}" id="emb-cursor-sync" data-tooltip="${t("toolbar.cursor_sync") || "Cursor sync"}" aria-pressed="${cursorSyncEnabled}">
<i data-lucide="link-2" class="sync-on-icon"${cursorSyncEnabled ? "" : ' style="display:none"'}></i>
<i data-lucide="link-2-off" class="sync-off-icon"${cursorSyncEnabled ? ' style="display:none"' : ""}></i>
Expand Down
10 changes: 9 additions & 1 deletion src/extensionsIntegrated/Phoenix-live-preview/MarkdownSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ define(function (require, exports, module) {
let _cursorUndoStack = [];
let _cursorRedoStack = [];

const DEBOUNCE_TO_IFRAME_MS = 150;
const DEBOUNCE_TO_IFRAME_MS = 50;
const SCROLL_SYNC_DEBOUNCE_MS = 16;
const SELECTION_SYNC_DEBOUNCE_MS = 200;

Expand Down Expand Up @@ -131,6 +131,14 @@ define(function (require, exports, module) {
break;
case "mdviewrCursorSyncToggle":
_cursorSyncEnabled = !!data.enabled;
// Clear CM line highlight when cursor sync is disabled
if (!_cursorSyncEnabled) {
const cm = _getCM();
if (cm && _highlightLineHandle) {
cm.removeLineClass(_highlightLineHandle, "background", "cm-cursor-sync-highlight");
_highlightLineHandle = null;
}
}
break;
case "mdviewrThemeToggle":
sendThemeOverride(data.theme);
Expand Down
5 changes: 3 additions & 2 deletions src/view/PanelView.js
Original file line number Diff line number Diff line change
Expand Up @@ -842,9 +842,10 @@ define(function (require, exports, module) {
_toggleMaximize();
});

// Double-click on tab bar toggles maximize (exclude action buttons and add button)
// Double-click on empty tab bar area toggles maximize.
// Exclude tabs themselves, action buttons, and the add button.
_$tabBar.on("dblclick", function (e) {
if ($(e.target).closest(".bottom-panel-tab-close-btn, .bottom-panel-hide-btn, .bottom-panel-maximize-btn, .bottom-panel-add-btn").length) {
if ($(e.target).closest(".bottom-panel-tab, .bottom-panel-tab-close-btn, .bottom-panel-hide-btn, .bottom-panel-maximize-btn, .bottom-panel-add-btn").length) {
return;
}
_toggleMaximize();
Expand Down
Loading