@cccarv82/freya 1.0.59 → 1.0.60
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/cli/web-ui.css +3 -0
- package/cli/web-ui.js +40 -15
- package/package.json +1 -1
package/cli/web-ui.css
CHANGED
|
@@ -352,6 +352,9 @@ body {
|
|
|
352
352
|
outline: none;
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
+
.reportPreview strong { font-weight: 700; }
|
|
356
|
+
.reportPreview em { font-style: italic; }
|
|
357
|
+
|
|
355
358
|
.reportRaw { display: none; width: 100%; overflow: hidden; resize: none; }
|
|
356
359
|
.reportCard.raw .reportPreview { display: none; }
|
|
357
360
|
.reportCard.raw .reportRaw { display: block; }
|
package/cli/web-ui.js
CHANGED
|
@@ -71,8 +71,10 @@
|
|
|
71
71
|
codes.push(c);
|
|
72
72
|
return `@@CODE${idx}@@`;
|
|
73
73
|
});
|
|
74
|
-
out = out.replace(/\*\*(
|
|
75
|
-
out = out.replace(
|
|
74
|
+
out = out.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>');
|
|
75
|
+
out = out.replace(/__(.+?)__/g, '<strong>$1</strong>');
|
|
76
|
+
out = out.replace(/\*(.+?)\*/g, '<em>$1</em>');
|
|
77
|
+
out = out.replace(/_(.+?)_/g, '<em>$1</em>');
|
|
76
78
|
out = out.replace(/@@CODE(\d+)@@/g, (_, i) => `<code class="md-inline">${codes[Number(i)]}</code>`);
|
|
77
79
|
return out;
|
|
78
80
|
};
|
|
@@ -516,13 +518,24 @@
|
|
|
516
518
|
|
|
517
519
|
function downloadReportPdf(item) {
|
|
518
520
|
const text = state.reportTexts[item.relPath] || '';
|
|
519
|
-
const html = `<!doctype html><html><head><meta charset="utf-8" /><title>${escapeHtml(item.name)}</title><style>body{font-family:Arial, sans-serif; padding:32px; color:#111;} h1,h2,h3{margin:16px 0 8px;} pre{background:#f5f5f5; padding:12px; border-radius:8px;}</style></head><body>${renderMarkdown(text)}</body></html>`;
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
521
|
+
const html = `<!doctype html><html><head><meta charset="utf-8" /><title>${escapeHtml(item.name)}</title><style>body{font-family:Arial, sans-serif; padding:32px; color:#111; line-height:1.5;} h1,h2,h3{margin:16px 0 8px;} ul{padding-left:18px;} code{font-family:monospace;} pre{background:#f5f5f5; padding:12px; border-radius:8px;}</style></head><body>${renderMarkdown(text)}</body></html>`;
|
|
522
|
+
const frame = document.createElement('iframe');
|
|
523
|
+
frame.style.position = 'fixed';
|
|
524
|
+
frame.style.right = '0';
|
|
525
|
+
frame.style.bottom = '0';
|
|
526
|
+
frame.style.width = '0';
|
|
527
|
+
frame.style.height = '0';
|
|
528
|
+
frame.style.border = '0';
|
|
529
|
+
document.body.appendChild(frame);
|
|
530
|
+
const doc = frame.contentWindow.document;
|
|
531
|
+
doc.open();
|
|
532
|
+
doc.write(html);
|
|
533
|
+
doc.close();
|
|
534
|
+
frame.onload = () => {
|
|
535
|
+
frame.contentWindow.focus();
|
|
536
|
+
frame.contentWindow.print();
|
|
537
|
+
setTimeout(() => frame.remove(), 1000);
|
|
538
|
+
};
|
|
526
539
|
}
|
|
527
540
|
|
|
528
541
|
function renderReportsPage() {
|
|
@@ -571,31 +584,43 @@
|
|
|
571
584
|
raw.addEventListener('input', () => {
|
|
572
585
|
state.reportTexts[item.relPath] = raw.value;
|
|
573
586
|
autoGrowTextarea(raw);
|
|
587
|
+
if (state.reportModes[item.relPath] !== 'raw' && preview && !preview.dataset.editing) {
|
|
588
|
+
preview.innerHTML = renderMarkdown(raw.value);
|
|
589
|
+
}
|
|
574
590
|
});
|
|
575
591
|
}
|
|
576
592
|
|
|
577
593
|
if (preview) {
|
|
578
|
-
preview.addEventListener('
|
|
579
|
-
|
|
594
|
+
preview.addEventListener('focus', () => {
|
|
595
|
+
preview.dataset.editing = '1';
|
|
596
|
+
preview.textContent = state.reportTexts[item.relPath] || '';
|
|
597
|
+
});
|
|
598
|
+
preview.addEventListener('blur', () => {
|
|
599
|
+
preview.dataset.editing = '';
|
|
600
|
+
const val = preview.textContent || '';
|
|
580
601
|
state.reportTexts[item.relPath] = val;
|
|
581
602
|
if (raw) {
|
|
582
603
|
raw.value = val;
|
|
583
604
|
autoGrowTextarea(raw);
|
|
584
605
|
}
|
|
606
|
+
preview.innerHTML = renderMarkdown(val);
|
|
585
607
|
});
|
|
586
608
|
}
|
|
587
609
|
|
|
588
610
|
const toggleBtn = card.querySelector('[data-action="toggle"]');
|
|
589
611
|
if (toggleBtn) {
|
|
590
|
-
toggleBtn.onclick = () => {
|
|
612
|
+
toggleBtn.onclick = (ev) => {
|
|
613
|
+
ev.stopPropagation();
|
|
591
614
|
state.reportModes[item.relPath] = (state.reportModes[item.relPath] === 'raw') ? 'preview' : 'raw';
|
|
615
|
+
state.reportExpanded[item.relPath] = true;
|
|
592
616
|
renderReportsPage();
|
|
593
617
|
};
|
|
594
618
|
}
|
|
595
619
|
|
|
596
620
|
const saveBtn = card.querySelector('[data-action="save"]');
|
|
597
621
|
if (saveBtn) {
|
|
598
|
-
saveBtn.onclick = async () => {
|
|
622
|
+
saveBtn.onclick = async (ev) => {
|
|
623
|
+
ev.stopPropagation();
|
|
599
624
|
try {
|
|
600
625
|
const content = (raw && typeof raw.value === 'string') ? raw.value : (state.reportTexts[item.relPath] || '');
|
|
601
626
|
setPill('run', 'salvando…');
|
|
@@ -620,8 +645,8 @@
|
|
|
620
645
|
|
|
621
646
|
const head = card.querySelector('[data-action="expand"]');
|
|
622
647
|
if (head) {
|
|
623
|
-
head.onclick = () => {
|
|
624
|
-
|
|
648
|
+
head.onclick = (ev) => {
|
|
649
|
+
if (ev.target && ev.target.closest('.reportHeadActions')) return;
|
|
625
650
|
state.reportExpanded[item.relPath] = !state.reportExpanded[item.relPath];
|
|
626
651
|
renderReportsPage();
|
|
627
652
|
};
|