@helping-ai-workflow/md2doc 3.16.0 → 3.16.1
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 +68 -0
- package/package.json +1 -1
package/lib/md2doc.js
CHANGED
|
@@ -2905,6 +2905,34 @@ const html = `<!DOCTYPE html>
|
|
|
2905
2905
|
max-width: 100%;
|
|
2906
2906
|
margin: 0 auto;
|
|
2907
2907
|
}
|
|
2908
|
+
/* v3.16.1: a capture tool hides every sticky element after its first slice,
|
|
2909
|
+
so a sticky first column came out blank from the second screen down. The
|
|
2910
|
+
runtime also widens each box that scrolls sideways (fitWideBoxes); the
|
|
2911
|
+
rules below are its last resort, for a box still wider than the screen. */
|
|
2912
|
+
body[data-capture-mode] .content table tbody td:first-child,
|
|
2913
|
+
body[data-capture-mode] .content table thead th:first-child {
|
|
2914
|
+
position: static;
|
|
2915
|
+
}
|
|
2916
|
+
body[data-capture-mode] .content table.capture-wrap th:not(.cell-narrow),
|
|
2917
|
+
body[data-capture-mode] .content table.capture-wrap td:not(.cell-narrow),
|
|
2918
|
+
body[data-capture-mode] .content table.capture-wrap td:not(.cell-narrow) code {
|
|
2919
|
+
white-space: normal;
|
|
2920
|
+
overflow-wrap: break-word;
|
|
2921
|
+
min-width: 0;
|
|
2922
|
+
}
|
|
2923
|
+
body[data-capture-mode] .content table.capture-wrap th,
|
|
2924
|
+
body[data-capture-mode] .content table.capture-wrap td {
|
|
2925
|
+
padding: 0.4em 0.6em;
|
|
2926
|
+
}
|
|
2927
|
+
body[data-capture-mode] .content pre.capture-wrap,
|
|
2928
|
+
body[data-capture-mode] .content pre.capture-wrap code {
|
|
2929
|
+
white-space: pre-wrap;
|
|
2930
|
+
overflow-wrap: anywhere;
|
|
2931
|
+
}
|
|
2932
|
+
body[data-capture-mode] .content .diagram-scroll.capture-wrap > svg {
|
|
2933
|
+
max-width: 100% !important;
|
|
2934
|
+
height: auto;
|
|
2935
|
+
}
|
|
2908
2936
|
.capture-toast {
|
|
2909
2937
|
position: fixed;
|
|
2910
2938
|
top: 16px;
|
|
@@ -5103,11 +5131,49 @@ ${mermaidInitTag}`)
|
|
|
5103
5131
|
// and the reading position holds. Esc leaves; a reload never comes back in it.
|
|
5104
5132
|
const captureBtn = document.getElementById('capture-mode-toggle');
|
|
5105
5133
|
let captureToastTimer = 0;
|
|
5134
|
+
// A capture tool only sees the part of a sideways-scrolling box that is in
|
|
5135
|
+
// view, so each one (a wide table, a long code line, a wide diagram) is
|
|
5136
|
+
// widened to its full width, centred on the screen, at most the screen less
|
|
5137
|
+
// a 16px gutter each side; the prose keeps its reading width. One still too
|
|
5138
|
+
// wide wraps (.capture-wrap), and a table still too wide after that gets
|
|
5139
|
+
// smaller type. Each box's own style attribute is kept and put back on exit.
|
|
5140
|
+
let captureFitted = [];
|
|
5141
|
+
function fitWideBoxes() {
|
|
5142
|
+
const vw = document.documentElement.clientWidth;
|
|
5143
|
+
const boxes = document.querySelectorAll('main.content table, main.content pre, main.content .diagram-scroll');
|
|
5144
|
+
for (const el of boxes) {
|
|
5145
|
+
if (el.scrollWidth <= el.clientWidth + 1) continue;
|
|
5146
|
+
captureFitted.push({ el: el, style: el.getAttribute('style') });
|
|
5147
|
+
const w = Math.min(el.scrollWidth, vw - 32);
|
|
5148
|
+
el.style.boxSizing = 'border-box';
|
|
5149
|
+
el.style.width = w + 'px';
|
|
5150
|
+
el.style.maxWidth = 'none';
|
|
5151
|
+
const margin = parseFloat(getComputedStyle(el).marginLeft) || 0;
|
|
5152
|
+
el.style.marginLeft = (margin + (vw - w) / 2 - el.getBoundingClientRect().left) + 'px';
|
|
5153
|
+
if (el.scrollWidth > el.clientWidth + 1) el.classList.add('capture-wrap');
|
|
5154
|
+
// Many columns on a narrow screen can stay too wide even wrapped: shrink
|
|
5155
|
+
// the table's type (the wrap rule's cell padding is in em) until it fits.
|
|
5156
|
+
let size = parseFloat(getComputedStyle(el).fontSize);
|
|
5157
|
+
for (let i = 0; i < 8 && el.tagName === 'TABLE' && el.scrollWidth > el.clientWidth + 1; i++) {
|
|
5158
|
+
size = size * el.clientWidth / el.scrollWidth * 0.98;
|
|
5159
|
+
el.style.fontSize = size + 'px';
|
|
5160
|
+
}
|
|
5161
|
+
}
|
|
5162
|
+
}
|
|
5163
|
+
function unfitWideBoxes() {
|
|
5164
|
+
for (const f of captureFitted) {
|
|
5165
|
+
f.el.classList.remove('capture-wrap');
|
|
5166
|
+
if (f.style === null) f.el.removeAttribute('style');
|
|
5167
|
+
else f.el.setAttribute('style', f.style);
|
|
5168
|
+
}
|
|
5169
|
+
captureFitted = [];
|
|
5170
|
+
}
|
|
5106
5171
|
function setCaptureMode(on) {
|
|
5107
5172
|
clearTimeout(captureToastTimer);
|
|
5108
5173
|
const oldToast = document.querySelector('.capture-toast');
|
|
5109
5174
|
if (oldToast) oldToast.remove();
|
|
5110
5175
|
if (!on) {
|
|
5176
|
+
unfitWideBoxes();
|
|
5111
5177
|
document.body.removeAttribute('data-capture-mode');
|
|
5112
5178
|
document.body.style.removeProperty('--md2doc-capture-w');
|
|
5113
5179
|
return;
|
|
@@ -5116,6 +5182,8 @@ ${mermaidInitTag}`)
|
|
|
5116
5182
|
const w = document.querySelector('main.content').getBoundingClientRect().width;
|
|
5117
5183
|
document.body.style.setProperty('--md2doc-capture-w', w + 'px');
|
|
5118
5184
|
document.body.setAttribute('data-capture-mode', '');
|
|
5185
|
+
unfitWideBoxes();
|
|
5186
|
+
fitWideBoxes();
|
|
5119
5187
|
const toast = document.createElement('div');
|
|
5120
5188
|
toast.className = 'capture-toast';
|
|
5121
5189
|
toast.setAttribute('role', 'status');
|