@helping-ai-workflow/md2doc 3.15.0 → 3.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/md2doc.js +80 -2
- package/package.json +1 -1
package/lib/md2doc.js
CHANGED
|
@@ -467,6 +467,7 @@ const READER_ICONS = {
|
|
|
467
467
|
x: ICON_SVG_OPEN + '<path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>',
|
|
468
468
|
copy: ICON_SVG_OPEN + '<rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',
|
|
469
469
|
check: ICON_SVG_OPEN + '<path d="M20 6 9 17l-5-5"/></svg>',
|
|
470
|
+
camera: ICON_SVG_OPEN + '<path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"/><circle cx="12" cy="13" r="3"/></svg>',
|
|
470
471
|
};
|
|
471
472
|
|
|
472
473
|
async function renderMarkdown(mdText, srcPath, opts = {}) {
|
|
@@ -1492,7 +1493,8 @@ ${itemsHtml}
|
|
|
1492
1493
|
<div class="toc-header-actions">
|
|
1493
1494
|
<button id="toc-expand-all" type="button" aria-label="Expand all" title="Expand all">${READER_ICONS.unfold}</button>
|
|
1494
1495
|
<button id="toc-collapse-all" type="button" aria-label="Collapse all" title="Collapse all">${READER_ICONS.fold}</button>
|
|
1495
|
-
<button id="
|
|
1496
|
+
${opts.editMode ? '' : ` <button id="capture-mode-toggle" type="button" aria-label="Screenshot mode" title="Screenshot mode (Esc to exit)">${READER_ICONS.camera}</button>
|
|
1497
|
+
`} <button id="toc-collapse-toggle" type="button" aria-label="Collapse table of contents" title="Collapse / expand sidebar">${READER_ICONS.panel}</button>
|
|
1496
1498
|
</div>
|
|
1497
1499
|
<div class="toc-breadcrumb" data-toc-breadcrumb aria-label="Current location"></div>
|
|
1498
1500
|
</div>
|
|
@@ -2411,7 +2413,8 @@ const html = `<!DOCTYPE html>
|
|
|
2411
2413
|
TOC-list buttons (no list to act on) and shrink padding so the toggle
|
|
2412
2414
|
fits inside the rail instead of being clipped by overflow:hidden. */
|
|
2413
2415
|
body[data-toc-collapsed] #toc-expand-all,
|
|
2414
|
-
body[data-toc-collapsed] #toc-collapse-all
|
|
2416
|
+
body[data-toc-collapsed] #toc-collapse-all,
|
|
2417
|
+
body[data-toc-collapsed] #capture-mode-toggle {
|
|
2415
2418
|
display: none;
|
|
2416
2419
|
}
|
|
2417
2420
|
body[data-toc-collapsed] .toc {
|
|
@@ -2881,6 +2884,42 @@ const html = `<!DOCTYPE html>
|
|
|
2881
2884
|
min-width: 0;
|
|
2882
2885
|
flex: 1 1 auto;
|
|
2883
2886
|
}
|
|
2887
|
+
/* Screenshot mode (v3.16.0). A scroll-and-stitch full-page capture
|
|
2888
|
+
(FireShot and the like) glues one slice per screen, so whatever stays put
|
|
2889
|
+
while the page scrolls lands on every slice: hide all of it, and keep the
|
|
2890
|
+
column at the width it was read at (--md2doc-capture-w, measured on
|
|
2891
|
+
entry), centred, so its lines break as they did. */
|
|
2892
|
+
body[data-capture-mode] .reader-sidebar,
|
|
2893
|
+
body[data-capture-mode] .sidebar-splitter,
|
|
2894
|
+
body[data-capture-mode] .sidebar-scrim,
|
|
2895
|
+
body[data-capture-mode] .mobile-bar,
|
|
2896
|
+
body[data-capture-mode] .md2doc-theme-toggle {
|
|
2897
|
+
display: none;
|
|
2898
|
+
}
|
|
2899
|
+
body[data-capture-mode] .page-layout {
|
|
2900
|
+
display: block;
|
|
2901
|
+
}
|
|
2902
|
+
body[data-capture-mode] main.content {
|
|
2903
|
+
box-sizing: border-box;
|
|
2904
|
+
width: var(--md2doc-capture-w, auto);
|
|
2905
|
+
max-width: 100%;
|
|
2906
|
+
margin: 0 auto;
|
|
2907
|
+
}
|
|
2908
|
+
.capture-toast {
|
|
2909
|
+
position: fixed;
|
|
2910
|
+
top: 16px;
|
|
2911
|
+
left: 50%;
|
|
2912
|
+
transform: translateX(-50%);
|
|
2913
|
+
z-index: 300;
|
|
2914
|
+
padding: 8px 16px;
|
|
2915
|
+
border-radius: 999px;
|
|
2916
|
+
background: #24292e;
|
|
2917
|
+
color: #ffffff;
|
|
2918
|
+
font-size: 14px;
|
|
2919
|
+
line-height: 1.4;
|
|
2920
|
+
box-shadow: 0 4px 14px rgba(0,0,0,0.18);
|
|
2921
|
+
pointer-events: none;
|
|
2922
|
+
}
|
|
2884
2923
|
.content p,
|
|
2885
2924
|
.content li,
|
|
2886
2925
|
.content blockquote,
|
|
@@ -5057,6 +5096,45 @@ ${mermaidInitTag}`)
|
|
|
5057
5096
|
setSidebarOpen(false);
|
|
5058
5097
|
}
|
|
5059
5098
|
});
|
|
5099
|
+
|
|
5100
|
+
// ── Screenshot mode (v3.16.0): only the document, for a full-page capture ──
|
|
5101
|
+
// The CSS beside '.capture-toast' hides everything that stays put while the
|
|
5102
|
+
// page scrolls. The column keeps the width measured here, so nothing reflows
|
|
5103
|
+
// and the reading position holds. Esc leaves; a reload never comes back in it.
|
|
5104
|
+
const captureBtn = document.getElementById('capture-mode-toggle');
|
|
5105
|
+
let captureToastTimer = 0;
|
|
5106
|
+
function setCaptureMode(on) {
|
|
5107
|
+
clearTimeout(captureToastTimer);
|
|
5108
|
+
const oldToast = document.querySelector('.capture-toast');
|
|
5109
|
+
if (oldToast) oldToast.remove();
|
|
5110
|
+
if (!on) {
|
|
5111
|
+
document.body.removeAttribute('data-capture-mode');
|
|
5112
|
+
document.body.style.removeProperty('--md2doc-capture-w');
|
|
5113
|
+
return;
|
|
5114
|
+
}
|
|
5115
|
+
setSidebarOpen(false);
|
|
5116
|
+
const w = document.querySelector('main.content').getBoundingClientRect().width;
|
|
5117
|
+
document.body.style.setProperty('--md2doc-capture-w', w + 'px');
|
|
5118
|
+
document.body.setAttribute('data-capture-mode', '');
|
|
5119
|
+
const toast = document.createElement('div');
|
|
5120
|
+
toast.className = 'capture-toast';
|
|
5121
|
+
toast.setAttribute('role', 'status');
|
|
5122
|
+
toast.textContent = 'Screenshot mode — press Esc or reload to exit';
|
|
5123
|
+
document.body.appendChild(toast);
|
|
5124
|
+
// Gone before the capture tool scrolls, or it would be on every slice too.
|
|
5125
|
+
captureToastTimer = setTimeout(() => toast.remove(), 2000);
|
|
5126
|
+
}
|
|
5127
|
+
if (captureBtn) {
|
|
5128
|
+
captureBtn.addEventListener('click', () => setCaptureMode(true));
|
|
5129
|
+
}
|
|
5130
|
+
// Registered ahead of the lightbox's own Esc handler, which closes the
|
|
5131
|
+
// diagram: while one is open, its Esc is the lightbox's and the mode stays.
|
|
5132
|
+
document.addEventListener('keydown', (event) => {
|
|
5133
|
+
if (lightboxIsOpen()) return;
|
|
5134
|
+
if (event.key === 'Escape' && document.body.hasAttribute('data-capture-mode')) {
|
|
5135
|
+
setCaptureMode(false);
|
|
5136
|
+
}
|
|
5137
|
+
});
|
|
5060
5138
|
document.addEventListener('click', (event) => {
|
|
5061
5139
|
if (!document.body.hasAttribute('data-sidebar-open')) return;
|
|
5062
5140
|
if (!event.target || !event.target.closest) return;
|