Repository: Hestenb62/_legacy_backup
Author: Hesten Berger
Commit Message: url updates
URL: https://github.com/Hestenb62/_legacy_backup/commit/10e5203ac0a962802c7182a8da882721847d674c
Code Changes:
diff --git a/assets/css/components/fixed-tools.css b/assets/css/components/fixed-tools.css
index 6d53392..b424321 100644
--- a/assets/css/components/fixed-tools.css
+++ b/assets/css/components/fixed-tools.css
@@ -985,6 +985,17 @@
transform: translateY(-1px);
}
+ .math-chip-btn mjx-container {
+ margin: 0 !important;
+ vertical-align: middle !important;
+ }
+
+ .math-chip-btn mjx-container svg {
+ max-height: 1.45em;
+ width: auto;
+ vertical-align: middle;
+ }
+
.math-preview-header {
display: flex;
justify-content: space-between;
@@ -1119,6 +1130,60 @@
}
}
+ /* ==========================================================================
+ Scratchpad Isolated Print Layout Standard (@media print)
+ ========================================================================== */
+ @media print {
+ body.printing-scratchpad > *:not(#scratchpad-panel) {
+ display: none !important;
+ }
+ body.printing-scratchpad #scratchpad-panel {
+ position: static !important;
+ display: block !important;
+ background: transparent !important;
+ box-shadow: none !important;
+ width: 100% !important;
+ max-width: 100% !important;
+ height: auto !important;
+ padding: 0 !important;
+ margin: 0 !important;
+ z-index: 1 !important;
+ }
+ body.printing-scratchpad .scratchpad-backdrop,
+ body.printing-scratchpad .scratchpad-notebook-bar,
+ body.printing-scratchpad .scratchpad-header-actions,
+ body.printing-scratchpad .scratchpad-tabs-bar,
+ body.printing-scratchpad .scratchpad-format-bar,
+ body.printing-scratchpad .scratchpad-search-wrap,
+ body.printing-scratchpad .scratchpad-typography-bar,
+ body.printing-scratchpad .scratchpad-templates-bar,
+ body.printing-scratchpad .scratchpad-canvas-ribbon,
+ body.printing-scratchpad .scratchpad-math-palette,
+ body.printing-scratchpad .scratchpad-footer {
+ display: none !important;
+ }
+ body.printing-scratchpad .scratchpad-content {
+ box-shadow: none !important;
+ border: none !important;
+ width: 100% !important;
+ max-width: 100% !important;
+ height: auto !important;
+ padding: 0 !important;
+ background: #ffffff !important;
+ color: #000000 !important;
+ }
+ body.printing-scratchpad .scratchpad-notes-area {
+ border: none !important;
+ box-shadow: none !important;
+ font-size: 11pt !important;
+ color: #000000 !important;
+ height: auto !important;
+ resize: none !important;
+ overflow: visible !important;
+ background: transparent !important;
+ }
+ }
+
/* Citation Panel Overlay */
.citation-panel-overlay {
position: fixed;
diff --git a/assets/js/scratchpad-studio.js b/assets/js/scratchpad-studio.js
index ac4025b..071b37d 100644
--- a/assets/js/scratchpad-studio.js
+++ b/assets/js/scratchpad-studio.js
@@ -35,6 +35,7 @@
// State Management
let notebook = [];
let activeNoteId = null;
+ let currentTab = 'notes'; // 'notes', 'whiteboard', 'math'
let saveDebounceTimer = null;
let mathjaxDebounceTimer = null;
@@ -601,7 +602,10 @@
dom.mathjaxPreview.innerHTML = previewHtml;
- // Trigger universal MathJax rendering standard
+ // Trigger universal MathJax rendering standard with clean re-typeset cache
+ if (window.MathJax && window.MathJax.typesetClear && dom.mathjaxPreview) {
+ try { window.MathJax.typesetClear([dom.mathjaxPreview]); } catch (e) {}
+ }
if (window.ensureMathJax) {
window.ensureMathJax(dom.mathjaxPreview);
} else if (window.MathJax && window.MathJax.typesetPromise) {
@@ -624,6 +628,7 @@
// Tab Navigation & Window Modes
// =========================================================================
function switchTab(mode) {
+ currentTab = mode;
const tabs = [
{ id: 'notes', tab: dom.tabNotes, pane: dom.paneNotes },
{ id: 'whiteboard', tab: dom.tabWhiteboard, pane: dom.paneWhiteboard },
@@ -648,6 +653,9 @@
if (mode === 'whiteboard') {
setTimeout(resizeCanvas, 100);
} else if (mode === 'math') {
+ if (window.ensureMathJax && dom.paneMath) {
+ window.ensureMathJax(dom.paneMath);
+ }
renderMathJaxPreview();
}
@@ -700,6 +708,10 @@
if (dom.textarea) dom.textarea.focus();
}, 150);
+ if (window.ensureMathJax) {
+ window.ensureMathJax();
+ }
+
if (window.HLSound && window.HLSound.playToggle) window.HLSound.playToggle();
announceStatus('Scratchpad opened.');
}
@@ -936,6 +948,540 @@
} catch (e) {}
}
+ // =========================================================================
+ // Scratchpad-Only Formatted Printing Engine
+ // =========================================================================
+ function hasCanvasDrawing() {
+ if (!canvas || !ctx) return false;
+ try {
+ const d = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
+ for (let i = 3; i < d.length; i += 40) {
+ if (d[i] > 0) return true;
+ }
+ } catch (e) {}
+ return false;
+ }
+
+ function formatInlineForPrint(str) {
+ return str
+ .replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
+ .replace(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g, '<em>$1</em>')
+ .replace(/`([^`]+)`/g, '<code class="print-code-inline">$1</code>');
+ }
+
+ function formatMarkdownForPrint(md) {
+ if (!md || !md.trim()) {
+ return '<p style="color: #64748b; font-style: italic;">No written notes recorded for this notebook page.</p>';
+ }
+
+ let safe = md
+ .replace(/&/g, '&')
+ .replace(/</g, '<')
+ .replace(/>/g, '>');
+
+ // Fenced Code Blocks
+ safe = safe.replace(/```([\s\S]*?)```/g, (match, code) => {
+ return `<pre class="print-code-block"><code>${code.trim()}</code></pre>`;
+ });
+
+ const lines = safe.split('\n');
+ let inList = false;
+ let inNumberedList = false;
+ let html = '';
+
+ const closeLists = () => {
+ if (inList) { html += '</ul>\n'; inList = false; }
+ if (inNumberedList) { html += '</ol>\n'; inNumberedList = false; }
+ };
+
+ for (let i = 0; i < lines.length; i++) {
+ const line = lines[i].trim();
+
+ if (!line) {
+ closeLists();
+ continue;
+ }
+
+ if (line.startsWith('<pre class="print-code-block">')) {
+ closeLists();
+ html += line + '\n';
+ continue;
+ }
+
+ if (/^###\s+(.+)$/.test(line)) {
+ closeLists();
+ html += `<h3>${formatInlineForPrint(line.replace(/^###\s+/, ''))}</h3>\n`;
+ continue;
+ }
+ if (/^##\s+(.+)$/.test(line)) {
+ closeLists();
+ html += `<h2>${formatInlineForPrint(line.replace(/^##\s+/, ''))}</h2>\n`;
+ continue;
+ }
+ if (/^#\s+(.+)$/.test(line)) {
+ closeLists();
+ html += `<h1>${formatInlineForPrint(line.replace(/^#\s+/, ''))}</h1>\n`;
+ continue;
+ }
+
+ if (/^(\-{3,}|\*{3,}|_{3,})$/.test(line)) {
+ closeLists();
+ html += '<hr class="print-divider">\n';
+ continue;
+ }
+
+ if (/^[\*\-\+]\s+(.+)$/.test(line)) {
+ if (inNumberedList) { html += '</ol>\n'; inNumberedList = false; }
+ if (!inList) { html += '<ul class="print-list">\n'; inList = true; }
+ const item = line.replace(/^[\*\-\+]\s+/, '');
+ html += `<li>${formatInlineForPrint(item)}</li>\n`;
+ continue;
+ }
+
+ if (/^\d+\.\s+(.+)$/.test(line)) {
+ if (inList) { html += '</ul>\n'; inList = false; }
+ if (!inNumberedList) { html += '<ol class="print-list">\n'; inNumberedList = true; }
+ const item = line.replace(/^\d+\.\s+/, '');
+ html += `<li>${formatInlineForPrint(item)}</li>\n`;
+ continue;
+ }
+
+ if (/^(>|>)\s*(.+)$/.test(line)) {
+ closeLists();
+ const quoteText = line.replace(/^(>|>)\s*/, '');
+ html += `<blockquote class="print-quote">${formatInlineForPrint(quoteText)}</blockquote>\n`;
+ continue;
+ }
+
+ closeLists();
+ html += `<p>${formatInlineForPrint(line)}</p>\n`;
+ }
+
+ closeLists();
+ return html;
+ }
+
+ function printScratchpad() {
+ const cur = getActiveNote();
+ const noteTitle = (cur && cur.title) ? cur.title : 'Study Notes';
+ const rawContent = dom.textarea ? dom.textarea.value : '';
+ const templateKey = (cur && cur.template) ? cur.template : '';
+ const templateLabel = templateKey ? templateKey.toUpperCase() : '';
+
+ const wordCount = rawContent.trim() ? rawContent.trim().split(/\s+/).length : 0;
+ const charCount = rawContent.length;
+
+ const dateStr = new Date().toLocaleDateString('en-US', {
+ weekday: 'long',
+ year: 'numeric',
+ month: 'long',
+ day: 'numeric'
+ });
+ const timeStr = new Date().toLocaleTimeString('en-US', {
+ hour: '2-digit',
+ minute: '2-digit'
+ });
+
+ const activeTab = (typeof currentTab !== 'undefined' && currentTab) ? currentTab : (dom.tabWhiteboard && dom.tabWhiteboard.classList.contains('active') ? 'whiteboard' : (dom.tabMath && dom.tabMath.classList.contains('active') ? 'math' : 'notes'));
+ const isWhiteboardTab = activeTab === 'whiteboard';
+ const isMathTab = activeTab === 'math';
+
+ // Check canvas drawing
+ let canvasDataUrl = null;
+ if (hasCanvasDrawing()) {
+ try {
+ canvasDataUrl = canvas.toDataURL('image/png');
+ } catch (e) {}
+ } else if (cur && cur.canvasData) {
+ canvasDataUrl = cur.canvasData;
+ }
+
+ const formattedNotesHtml = formatMarkdownForPrint(rawContent);
+
+ // MathJax rendered block if math tab or if math equations detected
+ let mathHtml = '';
+ if (dom.mathjaxPreview && (isMathTab || /(\$\$[\s\S]+?\$\$|\$[^\$\n]+?\$|\\\[[\s\S]+?\\\]|\\\([^\n]+?\\\))/.test(rawContent))) {
+ const renderTargets = dom.mathjaxPreview.querySelectorAll('.mathjax-render-target');
+ if (renderTargets.length > 0) {
+ mathHtml = `
+ <div class="print-math-section">
+ <h3 class="print-section-title"><span class="print-icon">∑</span> Mathematical Equations & Formulas</h3>
+ <div class="print-math-grid">
+ `;