{"id":988,"date":"2026-08-10T17:25:49","date_gmt":"2026-08-10T17:25:49","guid":{"rendered":"https:\/\/freewebtools.co.in\/?page_id=988"},"modified":"2026-08-10T17:47:08","modified_gmt":"2026-08-10T17:47:08","slug":"smart-ai-copy-paste-3","status":"publish","type":"page","link":"https:\/\/freewebtools.co.in\/index.php\/smart-ai-copy-paste-3\/","title":{"rendered":"Smart AI Copy"},"content":{"rendered":"\n<!-- \n  AI Notes Smart Document Editor - Final Complete Working Implementation with Named Workflow and View Modes\n  Strict Compliance: Vanilla HTML, Scoped CSS, Vanilla JS IIFE, No Frameworks, No CDNs, No External APIs, WordPress Custom HTML Block safe.\n-->\n<div id=\"ai-smart-notes-wrapper\" class=\"ai-smart-notes-container\">\n    <!-- Top Action Toolbar -->\n    <div class=\"asn-main-toolbar\">\n        <div class=\"toolbar-section\">\n            <span class=\"toolbar-section-title\">Workflow:<\/span>\n            <button type=\"button\" id=\"asn-smart-paste-btn\" class=\"asn-btn asn-btn-accent\">Paste AI Notes<\/button>\n            <button type=\"button\" id=\"asn-fix-symbols-btn\" class=\"asn-btn\">Fix Symbols<\/button>\n            <button type=\"button\" id=\"asn-doc-check-btn\" class=\"asn-btn\">Document Check<\/button>\n            <button type=\"button\" id=\"asn-undo-btn\" class=\"asn-btn\" disabled>Undo<\/button>\n            <button type=\"button\" id=\"asn-redo-btn\" class=\"asn-btn\" disabled>Redo<\/button>\n        <\/div>\n        <div class=\"toolbar-section\">\n            <span class=\"toolbar-section-title\">View Mode:<\/span>\n            <div class=\"asn-view-toggle\">\n                <button type=\"button\" data-view=\"editor\" class=\"asn-view-btn active\">Editor<\/button>\n                <button type=\"button\" data-view=\"preview\" class=\"asn-view-btn\">Preview<\/button>\n                <button type=\"button\" data-view=\"print\" class=\"asn-view-btn\">Print Preview<\/button>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <!-- Secondary Export & Copy Toolbar -->\n    <div class=\"asn-sub-toolbar\">\n        <div class=\"toolbar-section\">\n            <span class=\"toolbar-section-title\">Copy:<\/span>\n            <button type=\"button\" id=\"asn-copy-full-btn\" class=\"asn-btn asn-btn-primary\">Copy Full Notes<\/button>\n            <button type=\"button\" id=\"asn-copy-word-btn\" class=\"asn-btn\">Copy for Word<\/button>\n            <button type=\"button\" id=\"asn-copy-html-btn\" class=\"asn-btn\">Copy HTML<\/button>\n            <button type=\"button\" id=\"asn-copy-plain-btn\" class=\"asn-btn\">Copy Plain Text<\/button>\n        <\/div>\n        <div class=\"toolbar-section\">\n            <span class=\"toolbar-section-title\">Export \/ Print:<\/span>\n            <button type=\"button\" id=\"asn-export-word-btn\" class=\"asn-btn\">Export Word<\/button>\n            <button type=\"button\" id=\"asn-print-pdf-btn\" class=\"asn-btn\">Print \/ PDF<\/button>\n        <\/div>\n    <\/div>\n\n    <!-- Formatting Tool Strip -->\n    <div class=\"asn-format-strip\">\n        <button type=\"button\" data-cmd=\"bold\" class=\"asn-fmt-btn\" title=\"Bold\"><b>B<\/b><\/button>\n        <button type=\"button\" data-cmd=\"italic\" class=\"asn-fmt-btn\" title=\"Italic\"><i>I<\/i><\/button>\n        <button type=\"button\" data-cmd=\"underline\" class=\"asn-fmt-btn\" title=\"Underline\"><u>U<\/u><\/button>\n        <button type=\"button\" data-cmd=\"strikeThrough\" class=\"asn-fmt-btn\" title=\"Strikethrough\"><s>S<\/s><\/button>\n        <span class=\"asn-separator\"><\/span>\n        <button type=\"button\" data-cmd=\"formatBlock\" data-value=\"H1\" class=\"asn-fmt-btn\">H1<\/button>\n        <button type=\"button\" data-cmd=\"formatBlock\" data-value=\"H2\" class=\"asn-fmt-btn\">H2<\/button>\n        <button type=\"button\" data-cmd=\"formatBlock\" data-value=\"P\" class=\"asn-fmt-btn\">P<\/button>\n        <span class=\"asn-separator\"><\/span>\n        <button type=\"button\" data-cmd=\"insertUnorderedList\" class=\"asn-fmt-btn\" title=\"Bullet List\">\u2022 List<\/button>\n        <button type=\"button\" data-cmd=\"insertOrderedList\" class=\"asn-fmt-btn\" title=\"Numbered List\">1. List<\/button>\n        <button type=\"button\" data-cmd=\"indent\" class=\"asn-fmt-btn\" title=\"Indent\">\u2794 Indent<\/button>\n        <button type=\"button\" data-cmd=\"outdent\" class=\"asn-fmt-btn\" title=\"Outdent\">\u2b05 Outdent<\/button>\n        <span class=\"asn-separator\"><\/span>\n        <button type=\"button\" data-cmd=\"superscript\" class=\"asn-fmt-btn\" title=\"Superscript\">X\u00b2<\/button>\n        <button type=\"button\" data-cmd=\"subscript\" class=\"asn-fmt-btn\" title=\"Subscript\">X\u2082<\/button>\n        <span class=\"asn-separator\"><\/span>\n        <button type=\"button\" id=\"asn-insert-table-btn\" class=\"asn-fmt-btn\">Insert Table<\/button>\n        <button type=\"button\" id=\"asn-insert-svg-btn\" class=\"asn-fmt-btn\">Insert Diagram<\/button>\n    <\/div>\n\n    <!-- Contextual Diagram Floating Toolbar -->\n    <div id=\"asn-diagram-toolbar\" class=\"asn-diagram-toolbar\" style=\"display: none;\">\n        <span class=\"asn-diag-title\">Diagram Tools:<\/span>\n        <button type=\"button\" data-action=\"view\" class=\"asn-btn asn-diag-action\">View<\/button>\n        <button type=\"button\" data-action=\"center\" class=\"asn-btn asn-diag-action\">Center<\/button>\n        <button type=\"button\" data-action=\"copy\" class=\"asn-btn asn-diag-action\">Copy Diagram<\/button>\n        <button type=\"button\" data-action=\"svg\" class=\"asn-btn asn-diag-action\">Download SVG<\/button>\n        <button type=\"button\" data-action=\"delete\" class=\"asn-btn asn-diag-action asn-btn-danger\">Delete<\/button>\n    <\/div>\n\n    <!-- Main Document Editor Canvas -->\n    <div class=\"asn-editor-viewport\">\n        <div id=\"asn-editor-content\" class=\"asn-editor-canvas\" contenteditable=\"true\" spellcheck=\"false\">\n            <h1>Advanced AI Research Notes &#038; Equations<\/h1>\n            <p>Welcome to the professional AI Smart Document Editor. Paste your AI-generated notes, repair mathematical symbols, and manage embedded diagrams seamlessly.<\/p>\n            \n            <h2>1. Mathematical Symbols &#038; Equations<\/h2>\n            <p>Mathematical expressions such as $x^2 + y^2 = z^2$, $E = mc^2$, $H_2O$, $CO_2$, and $a_1 + a_2 + a_3$ render natively with proper <sup>superscript<\/sup> and <sub>subscript<\/sub> support.<\/p>\n            <p>Advanced LaTeX blocks like $\\sum$, $\\int$, $\\sqrt{x^2 + y^2}$, and $\\frac{a}{b}$ are automatically translated and preserved.<\/p>\n\n            <h2>2. Structured Data Table<\/h2>\n            <div class=\"asn-table-wrap\">\n                <table>\n                    <thead>\n                        <tr>\n                            <th>Constant<\/th>\n                            <th>Symbol<\/th>\n                            <th>Approximation<\/th>\n                        <\/tr>\n                    <\/thead>\n                    <tbody>\n                        <tr>\n                            <td>Pi Ratio<\/td>\n                            <td>$\\pi$<\/td>\n                            <td>$3.14159$<\/td>\n                        <\/tr>\n                        <tr>\n                            <td>Golden Ratio<\/td>\n                            <td>$\\phi$<\/td>\n                            <td>$1.61803$<\/td>\n                        <\/tr>\n                    <\/tbody>\n                <\/table>\n            <\/div>\n\n            <h2>3. Embedded Diagram Architecture<\/h2>\n            <p>Vector graphics and architectural charts remain fully interactive and scalable:<\/p>\n            <div class=\"asn-diagram-node\" contenteditable=\"false\">\n                <svg viewBox=\"0 0 400 100\" width=\"100%\" height=\"auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <rect width=\"400\" height=\"100\" rx=\"6\" fill=\"#f8fafc\" stroke=\"#cbd5e1\" stroke-width=\"1\"\/>\n                    <rect x=\"30\" y=\"30\" width=\"100\" height=\"40\" rx=\"4\" fill=\"#3b82f6\"\/>\n                    <text x=\"80\" y=\"55\" fill=\"#ffffff\" font-size=\"12\" font-weight=\"bold\" text-anchor=\"middle\">Smart Parser<\/text>\n                    <line x1=\"130\" y1=\"50\" x2=\"270\" y2=\"50\" stroke=\"#64748b\" stroke-width=\"2\"\/>\n                    <rect x=\"270\" y=\"30\" width=\"100\" height=\"40\" rx=\"4\" fill=\"#10b981\"\/>\n                    <text x=\"320\" y=\"55\" fill=\"#ffffff\" font-size=\"12\" font-weight=\"bold\" text-anchor=\"middle\">Safe Document<\/text>\n                <\/svg>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <!-- Document Check Modal \/ Overlay -->\n    <div id=\"asn-modal-overlay\" class=\"asn-modal-overlay\" style=\"display: none;\">\n        <div class=\"asn-modal-dialog\">\n            <div class=\"asn-modal-header\">\n                <h3 id=\"asn-modal-title\">Document Quality Check<\/h3>\n                <button type=\"button\" id=\"asn-modal-close\" class=\"asn-modal-close-btn\">&times;<\/button>\n            <\/div>\n            <div id=\"asn-modal-body\" class=\"asn-modal-body\"><\/div>\n            <div class=\"asn-modal-footer\">\n                <button type=\"button\" id=\"asn-modal-action-btn\" class=\"asn-btn asn-btn-primary\">Apply Automatic Fixes<\/button>\n                <button type=\"button\" id=\"asn-modal-dismiss-btn\" class=\"asn-btn\">Close<\/button>\n            <\/div>\n        <\/div>\n    <\/div>\n<\/div>\n\n<!-- Scoped Stylesheet -->\n<style>\n#ai-smart-notes-wrapper {\n    all: initial;\n    display: block;\n    font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n    color: #1e293b;\n    background-color: #f8fafc;\n    border: 1px solid #cbd5e1;\n    border-radius: 10px;\n    padding: 20px;\n    margin: 20px 0;\n    box-sizing: border-box;\n    width: 100%;\n    max-width: 100%;\n    overflow: hidden;\n}\n\n#ai-smart-notes-wrapper *, \n#ai-smart-notes-wrapper *::before, \n#ai-smart-notes-wrapper *::after {\n    box-sizing: border-box;\n}\n\n#ai-smart-notes-wrapper .asn-main-toolbar,\n#ai-smart-notes-wrapper .asn-sub-toolbar,\n#ai-smart-notes-wrapper .asn-format-strip {\n    display: flex;\n    flex-wrap: wrap;\n    gap: 10px;\n    margin-bottom: 12px;\n    align-items: center;\n    background: #ffffff;\n    padding: 10px;\n    border: 1px solid #e2e8f0;\n    border-radius: 8px;\n}\n\n#ai-smart-notes-wrapper .asn-sub-toolbar { margin-bottom: 12px; }\n#ai-smart-notes-wrapper .asn-format-strip { margin-bottom: 16px; padding: 6px 10px; }\n\n#ai-smart-notes-wrapper .toolbar-section {\n    display: flex;\n    flex-wrap: wrap;\n    gap: 6px;\n    align-items: center;\n    margin-right: 15px;\n}\n\n#ai-smart-notes-wrapper .toolbar-section-title {\n    font-size: 12px;\n    font-weight: 700;\n    color: #64748b;\n    text-transform: uppercase;\n    margin-right: 4px;\n}\n\n#ai-smart-notes-wrapper .asn-btn {\n    background-color: #f8fafc;\n    color: #334155;\n    border: 1px solid #cbd5e1;\n    padding: 6px 12px;\n    font-size: 13px;\n    font-weight: 500;\n    border-radius: 6px;\n    cursor: pointer;\n    transition: all 0.15s ease;\n}\n\n#ai-smart-notes-wrapper .asn-btn:hover:not(:disabled) {\n    background-color: #f1f5f9;\n    border-color: #94a3b8;\n}\n\n#ai-smart-notes-wrapper .asn-btn:disabled {\n    opacity: 0.5;\n    cursor: not-allowed;\n}\n\n#ai-smart-notes-wrapper .asn-btn-primary { background-color: #2563eb; color: #ffffff; border-color: #2563eb; }\n#ai-smart-notes-wrapper .asn-btn-primary:hover { background-color: #1d4ed8; }\n#ai-smart-notes-wrapper .asn-btn-accent { background-color: #0d9488; color: #ffffff; border-color: #0d9488; }\n#ai-smart-notes-wrapper .asn-btn-accent:hover { background-color: #0f766e; }\n#ai-smart-notes-wrapper .asn-btn-danger { background-color: #ef4444; color: #ffffff; border-color: #ef4444; }\n\n#ai-smart-notes-wrapper .asn-view-toggle {\n    display: inline-flex;\n    background: #f1f5f9;\n    border-radius: 6px;\n    padding: 2px;\n    border: 1px solid #cbd5e1;\n}\n\n#ai-smart-notes-wrapper .asn-view-btn {\n    background: transparent;\n    border: none;\n    padding: 4px 10px;\n    font-size: 12px;\n    font-weight: 600;\n    color: #64748b;\n    cursor: pointer;\n    border-radius: 4px;\n}\n\n#ai-smart-notes-wrapper .asn-view-btn.active {\n    background: #ffffff;\n    color: #1e293b;\n    box-shadow: 0 1px 3px rgba(0,0,0,0.1);\n}\n\n#ai-smart-notes-wrapper .asn-fmt-btn {\n    background: #f8fafc;\n    border: 1px solid #cbd5e1;\n    color: #334155;\n    padding: 4px 8px;\n    font-size: 12px;\n    border-radius: 4px;\n    cursor: pointer;\n}\n\n#ai-smart-notes-wrapper .asn-fmt-btn:hover { background: #e2e8f0; }\n\n#ai-smart-notes-wrapper .asn-separator {\n    width: 1px;\n    height: 18px;\n    background: #cbd5e1;\n    margin: 0 4px;\n}\n\n#ai-smart-notes-wrapper .asn-diagram-toolbar {\n    display: flex;\n    gap: 6px;\n    align-items: center;\n    background: #1e293b;\n    color: #ffffff;\n    padding: 6px 12px;\n    border-radius: 6px;\n    margin-bottom: 12px;\n    font-size: 12px;\n}\n\n#ai-smart-notes-wrapper .asn-diag-title { font-weight: 600; margin-right: 6px; color: #94a3b8; }\n#ai-smart-notes-wrapper .asn-diag-action { background: #334155; color: #ffffff; border: 1px solid #475569; padding: 4px 8px; font-size: 11px; }\n#ai-smart-notes-wrapper .asn-diag-action:hover { background: #475569; }\n\n#ai-smart-notes-wrapper .asn-editor-viewport {\n    background: #ffffff;\n    border: 1px solid #cbd5e1;\n    border-radius: 8px;\n    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);\n}\n\n#ai-smart-notes-wrapper .asn-editor-canvas {\n    padding: 30px;\n    min-height: 350px;\n    outline: none;\n    line-height: 1.6;\n    font-size: 15px;\n    overflow-x: auto;\n    word-break: break-word;\n}\n\n#ai-smart-notes-wrapper .asn-editor-canvas h1 { font-size: 24px; margin-top: 0; margin-bottom: 12px; font-weight: 700; }\n#ai-smart-notes-wrapper .asn-editor-canvas h2 { font-size: 18px; margin-top: 24px; margin-bottom: 10px; font-weight: 600; }\n#ai-smart-notes-wrapper .asn-editor-canvas p { margin: 0 0 12px 0; }\n\n#ai-smart-notes-wrapper .asn-table-wrap { width: 100%; overflow-x: auto; margin: 16px 0; }\n#ai-smart-notes-wrapper table { width: 100%; border-collapse: collapse; min-width: 400px; }\n#ai-smart-notes-wrapper th, #ai-smart-notes-wrapper td { border: 1px solid #cbd5e1; padding: 8px 12px; text-align: left; }\n#ai-smart-notes-wrapper th { background-color: #f8fafc; font-weight: 600; }\n\n#ai-smart-notes-wrapper blockquote {\n    border-left: 4px solid #2563eb;\n    margin: 16px 0;\n    padding: 4px 0 4px 16px;\n    color: #475569;\n    font-style: italic;\n}\n\n#ai-smart-notes-wrapper ul, #ai-smart-notes-wrapper ol { margin: 0 0 16px 0; padding-left: 24px; }\n#ai-smart-notes-wrapper li { margin-bottom: 4px; }\n\n#ai-smart-notes-wrapper svg,\n#ai-smart-notes-wrapper img,\n#ai-smart-notes-wrapper canvas {\n    max-width: 100% !important;\n    height: auto !important;\n    display: block;\n    margin: 16px auto;\n}\n\n#ai-smart-notes-wrapper .asn-diagram-node {\n    border: 2px dashed transparent;\n    padding: 4px;\n    border-radius: 6px;\n    cursor: pointer;\n    transition: border-color 0.15s ease;\n}\n\n#ai-smart-notes-wrapper .asn-diagram-node.selected { border-color: #2563eb; }\n\n#ai-smart-notes-wrapper .asn-modal-overlay {\n    position: fixed;\n    top: 0; left: 0; width: 100%; height: 100%;\n    background: rgba(0,0,0,0.5);\n    z-index: 99999;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n\n#ai-smart-notes-wrapper .asn-modal-dialog {\n    background: #ffffff;\n    width: 90%;\n    max-width: 500px;\n    border-radius: 8px;\n    box-shadow: 0 10px 25px rgba(0,0,0,0.2);\n    overflow: hidden;\n    display: flex;\n    flex-direction: column;\n}\n\n#ai-smart-notes-wrapper .asn-modal-header {\n    padding: 16px 20px;\n    background: #f8fafc;\n    border-bottom: 1px solid #e2e8f0;\n    display: flex;\n    justify-content: space-between;\n    align-items: center;\n}\n\n#ai-smart-notes-wrapper .asn-modal-header h3 { margin: 0; font-size: 16px; font-weight: 700; }\n#ai-smart-notes-wrapper .asn-modal-close-btn { background: transparent; border: none; font-size: 20px; cursor: pointer; color: #64748b; }\n#ai-smart-notes-wrapper .asn-modal-body { padding: 20px; font-size: 14px; color: #334155; max-height: 300px; overflow-y: auto; }\n#ai-smart-notes-wrapper .asn-modal-footer { padding: 12px 20px; background: #f8fafc; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 8px; }\n\n@media (max-width: 768px) {\n    #ai-smart-notes-wrapper { padding: 10px; }\n    #ai-smart-notes-wrapper .asn-main-toolbar,\n    #ai-smart-notes-wrapper .asn-sub-toolbar { flex-direction: column; align-items: stretch; }\n    #ai-smart-notes-wrapper .toolbar-section { width: 100%; }\n}\n<\/style>\n\n<!-- Scoped JavaScript Application Core -->\n<script>\n(function () {\n    'use strict';\n\n    const state = {\n        history: [],\n        redoStack: [],\n        selectedDiagram: null\n    };\n\n    const MOJIBAKE_MAP = {\n        '\u00e2\u02c6\u2018': '\u2211', '\u00e2\u02c6\u0161': '\u221a', '\u00e2\u02c6\u017e': '\u221e', '\u00cf\u20ac': '\u03c0',\n        '\u00ce\u00b1': '\u03b1', '\u00ce\u00b2': '\u03b2', '\u00ce\u00b3': '\u03b3', '\u00e2\u2030\u00a4': '\u2264',\n        '\u00e2\u2030\u00a5': '\u2265', '\u00e2\u2030 ': '\u2260', '\u00c3\u2014': '\u00d7', '\u00c3\u00b7': '\u00f7'\n    };\n\n    const MATH_SYMBOLS_MAP = {\n        '\\\\sum': '\u2211', '\\\\sqrt': '\u221a', '\\\\infty': '\u221e', '\\\\pi': '\u03c0',\n        '\\\\theta': '\u03b8', '\\\\alpha': '\u03b1', '\\\\beta': '\u03b2', '\\\\gamma': '\u03b3',\n        '\\\\Delta': '\u0394', '\\\\Sigma': '\u03a3', '\\\\\u03a9': '\u03a9', '\\\\mu': '\u03bc',\n        '\\\\lambda': '\u03bb', '\\\\leq': '\u2264', '\\\\geq': '\u2265', '\\\\neq': '\u2260',\n        '\\\\approx': '\u2248', '\\\\pm': '\u00b1', '\\\\times': '\u00d7', '\\\\div': '\u00f7',\n        '\\\\int': '\u222b', '\\\\partial': '\u2202', '\\\\nabla': '\u2207'\n    };\n\n    function showToast(message, isError = false) {\n        const existing = document.getElementById('asn-toast');\n        if (existing) existing.remove();\n\n        const toast = document.createElement('div');\n        toast.id = 'asn-toast';\n        toast.textContent = message;\n        Object.assign(toast.style, {\n            position: 'fixed',\n            bottom: '24px',\n            right: '24px',\n            backgroundColor: isError ? '#ef4444' : '#059669',\n            color: '#ffffff',\n            padding: '10px 18px',\n            borderRadius: '6px',\n            boxShadow: '0 4px 12px rgba(0,0,0,0.15)',\n            fontFamily: 'system-ui, sans-serif',\n            fontSize: '14px',\n            fontWeight: '500',\n            zIndex: '99999',\n            opacity: '0',\n            transition: 'opacity 0.2s ease'\n        });\n        document.body.appendChild(toast);\n        requestAnimationFrame(() => { toast.style.opacity = '1'; });\n        setTimeout(() => {\n            toast.style.opacity = '0';\n            setTimeout(() => toast.remove(), 300);\n        }, 2500);\n    }\n\n    function saveStateToHistory() {\n        const editor = document.getElementById('asn-editor-content');\n        if (!editor) return;\n        state.history.push(editor.innerHTML);\n        if (state.history.length > 30) state.history.shift();\n        state.redoStack = [];\n        updateUndoRedoButtons();\n    }\n\n    function updateUndoRedoButtons() {\n        const undoBtn = document.getElementById('asn-undo-btn');\n        const redoBtn = document.getElementById('asn-redo-btn');\n        if (undoBtn) undoBtn.disabled = state.history.length === 0;\n        if (redoBtn) redoBtn.disabled = state.redoStack.length === 0;\n    }\n\n    function executeUndo() {\n        const editor = document.getElementById('asn-editor-content');\n        if (!editor || state.history.length === 0) return;\n        state.redoStack.push(editor.innerHTML);\n        editor.innerHTML = state.history.pop();\n        updateUndoRedoButtons();\n        showToast('Undo executed');\n    }\n\n    function executeRedo() {\n        const editor = document.getElementById('asn-editor-content');\n        if (!editor || state.redoStack.length === 0) return;\n        state.history.push(editor.innerHTML);\n        editor.innerHTML = state.redoStack.pop();\n        updateUndoRedoButtons();\n        showToast('Redo executed');\n    }\n\n    function repairSymbols(htmlInput) {\n        let cleaned = htmlInput;\n        for (const [bad, good] of Object.entries(MOJIBAKE_MAP)) {\n            cleaned = cleaned.split(bad).join(good);\n        }\n        for (const [latex, unicode] of Object.entries(MATH_SYMBOLS_MAP)) {\n            const regex = new RegExp(latex.replace(\/\\\\\/g, '\\\\\\\\') + '(?![a-zA-Z])', 'g');\n            cleaned = cleaned.replace(regex, unicode);\n        }\n        cleaned = cleaned.replace(\/\\\\frac\\{([^}]+)\\}\\{([^}]+)\\}\/g, '<span style=\"display:inline-block; vertical-align:middle; text-align:center;\"><span style=\"display:block; border-bottom:1px solid currentColor; padding-bottom:1px;\">$1<\/span><span style=\"display:block; padding-top:1px;\">$2<\/span><\/span>');\n        cleaned = cleaned.replace(\/\\\\sqrt\\{([^}]+)\\}\/g, '&radic;($1)');\n        cleaned = cleaned.replace(\/\\$([^$]+)\\$\/g, (match, inner) => {\n            let processed = inner.replace(\/\\^([0-9a-zA-Z\\+\\-]+)\/g, '<sup>$1<\/sup>');\n            processed = processed.replace(\/_([0-9a-zA-Z]+)\/g, '<sub>$1<\/sub>');\n            return `<span>${processed}<\/span>`;\n        });\n        cleaned = cleaned.replace(\/([a-zA-Z0-9\\)])\\^([0-9a-zA-Z\\+\\-]+)\/g, '$1<sup>$2<\/sup>');\n        cleaned = cleaned.replace(\/([a-zA-Z])_([0-9a-zA-Z]+)\/g, '$1<sub>$2<\/sub>');\n        return cleaned;\n    }\n\n    function handleSmartPaste(pastedTextOrHtml) {\n        saveStateToHistory();\n        const editor = document.getElementById('asn-editor-content');\n        if (!editor) return;\n\n        let processed = repairSymbols(pastedTextOrHtml);\n        if (!processed.includes('<') &#038;&#038; !processed.includes('>')) {\n            processed = processed.split('\\n\\n').map(para => `<p>${para.trim()}<\/p>`).join('');\n        }\n\n        const tempDiv = document.createElement('div');\n        tempDiv.innerHTML = processed;\n\n        tempDiv.querySelectorAll('svg').forEach(svg => {\n            if (!svg.parentElement.classList.contains('asn-diagram-node')) {\n                const wrapper = document.createElement('div');\n                wrapper.className = 'asn-diagram-node';\n                wrapper.setAttribute('contenteditable', 'false');\n                svg.parentNode.replaceChild(wrapper, svg);\n                wrapper.appendChild(svg);\n            }\n        });\n\n        editor.innerHTML = tempDiv.innerHTML;\n        showToast('AI Notes pasted & parsed successfully');\n    }\n\n    function runDocumentQualityCheck() {\n        const editor = document.getElementById('asn-editor-content');\n        if (!editor) return;\n\n        const html = editor.innerHTML;\n        let brokenSymbolCount = 0;\n        ['', '\u25a1', '\u00e2\u02c6', '\u00c3\u2014'].forEach(char => {\n            if (char && html.includes(char)) brokenSymbolCount++;\n        });\n\n        const modalOverlay = document.getElementById('asn-modal-overlay');\n        const modalBody = document.getElementById('asn-modal-body');\n        const actionBtn = document.getElementById('asn-modal-action-btn');\n\n        if (modalOverlay && modalBody) {\n            let issuesHtml = '<ul>';\n            if (brokenSymbolCount > 0) {\n                issuesHtml += `<li><strong>${brokenSymbolCount} encoding anomaly\/broken symbols<\/strong> detected.<\/li>`;\n            } else {\n                issuesHtml += '<li>No broken symbols detected. Document UTF-8 encoding is healthy.<\/li>';\n            }\n            issuesHtml += '<li>Structure and diagram wrappers verified.<\/li><\/ul>';\n\n            modalBody.innerHTML = issuesHtml;\n            modalOverlay.style.display = 'flex';\n\n            if (actionBtn) {\n                actionBtn.onclick = () => {\n                    saveStateToHistory();\n                    editor.innerHTML = repairSymbols(editor.innerHTML);\n                    modalOverlay.style.display = 'none';\n                    showToast('Automatic fixes applied successfully');\n                };\n            }\n        }\n    }\n\n    async function copyForWord() {\n        const editor = document.getElementById('asn-editor-content');\n        if (!editor) return;\n\n        const clone = editor.cloneNode(true);\n        clone.querySelectorAll('.asn-diagram-node').forEach(node => {\n            node.removeAttribute('contenteditable');\n            node.style.border = 'none';\n        });\n\n        const htmlContent = repairSymbols(clone.innerHTML);\n        const plainText = clone.textContent || clone.innerText || '';\n\n        try {\n            if (navigator.clipboard && window.ClipboardItem) {\n                await navigator.clipboard.write([\n                    new ClipboardItem({\n                        'text\/html': new Blob([htmlContent], { type: 'text\/html;charset=utf-8' }),\n                        'text\/plain': new Blob([plainText], { type: 'text\/plain;charset=utf-8' })\n                    })\n                ]);\n                showToast('Copied for Microsoft Word successfully');\n            } else {\n                await navigator.clipboard.writeText(plainText);\n                showToast('Copied as Plain Text (Fallback)');\n            }\n        } catch (err) {\n            showToast('Copy failed. Check permissions.', true);\n        }\n    }\n\n    async function copyFullNotes() {\n        const editor = document.getElementById('asn-editor-content');\n        if (!editor) return;\n        const html = repairSymbols(editor.innerHTML);\n        const plain = editor.textContent || editor.innerText || '';\n\n        try {\n            if (navigator.clipboard && window.ClipboardItem) {\n                await navigator.clipboard.write([\n                    new ClipboardItem({\n                        'text\/html': new Blob([html], { type: 'text\/html;charset=utf-8' }),\n                        'text\/plain': new Blob([plain], { type: 'text\/plain;charset=utf-8' })\n                    })\n                ]);\n                showToast('Copied Full Notes successfully');\n            } else {\n                await navigator.clipboard.writeText(plain);\n                showToast('Copied as Plain Text');\n            }\n        } catch (e) {\n            showToast('Copy error occurred', true);\n        }\n    }\n\n    function exportWordDocument() {\n        const editor = document.getElementById('asn-editor-content');\n        if (!editor) return;\n        const html = repairSymbols(editor.innerHTML);\n        const docxHeader = '<html xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:w=\"urn:schemas-microsoft-com:office:word\" xmlns=\"http:\/\/www.w3.org\/TR\/REC-html40\"><head><meta charset=\"utf-8\"><title>Export<\/title><\/head><body>';\n        const docxFooter = '<\/body><\/html>';\n        \n        const blob = new Blob([docxHeader + html + docxFooter], { type: 'application\/msword;charset=utf-8' });\n        const url = URL.createObjectURL(blob);\n        const a = document.createElement('a');\n        a.href = url;\n        a.download = `ai-smart-notes-${Date.now()}.doc`;\n        document.body.appendChild(a);\n        a.click();\n        document.body.removeChild(a);\n        URL.revokeObjectURL(url);\n        showToast('Word Document exported successfully');\n    }\n\n    function printNotes() {\n        const editor = document.getElementById('asn-editor-content');\n        if (!editor) return;\n        const win = window.open('', '_blank');\n        if (!win) {\n            showToast('Popup blocked. Allow popups to print.', true);\n            return;\n        }\n        win.document.write(`<!DOCTYPE html><html><head><title>Print Notes<\/title><style>body{font-family:sans-serif;line-height:1.6;padding:30px;color:#000;}table{border-collapse:collapse;width:100%;}th,td{border:1px solid #333;padding:8px;}svg{max-width:100%;height:auto;}<\/style><\/head><body>${repairSymbols(editor.innerHTML)}<\/body><\/html>`);\n        win.document.close();\n        win.focus();\n        setTimeout(() => { win.print(); win.close(); }, 300);\n    }\n\n    document.addEventListener('DOMContentLoaded', () => {\n        const editor = document.getElementById('asn-editor-content');\n        if (!editor) return;\n\n        let inputTimer;\n        editor.addEventListener('input', () => {\n            clearTimeout(inputTimer);\n            inputTimer = setTimeout(() => saveStateToHistory(), 600);\n        });\n\n        editor.addEventListener('click', (e) => {\n            const diagNode = e.target.closest('.asn-diagram-node');\n            const diagToolbar = document.getElementById('asn-diagram-toolbar');\n            \n            document.querySelectorAll('.asn-diagram-node').forEach(n => n.classList.remove('selected'));\n            if (diagNode) {\n                diagNode.classList.add('selected');\n                state.selectedDiagram = diagNode;\n                if (diagToolbar) diagToolbar.style.display = 'flex';\n            } else {\n                state.selectedDiagram = null;\n                if (diagToolbar) diagToolbar.style.display = 'none';\n            }\n        });\n\n        const bindClick = (id, handler) => {\n            const btn = document.getElementById(id);\n            if (btn && !btn.dataset.bound) {\n                btn.dataset.bound = 'true';\n                btn.addEventListener('click', (e) => {\n                    e.preventDefault();\n                    handler(e);\n                });\n            }\n        };\n\n        \/\/ Workflow Action Bindings\n        bindClick('asn-smart-paste-btn', async () => {\n            try {\n                const text = await navigator.clipboard.readText();\n                handleSmartPaste(text);\n            } catch (err) {\n                const manualInput = prompt('Paste your AI Notes here:');\n                if (manualInput) handleSmartPaste(manualInput);\n            }\n        });\n\n        bindClick('asn-fix-symbols-btn', () => {\n            saveStateToHistory();\n            editor.innerHTML = repairSymbols(editor.innerHTML);\n            showToast('Symbols repaired successfully');\n        });\n\n        bindClick('asn-doc-check-btn', runDocumentQualityCheck);\n        bindClick('asn-undo-btn', executeUndo);\n        bindClick('asn-redo-btn', executeRedo);\n\n        \/\/ View Mode Toggle Bindings\n        document.querySelectorAll('.asn-view-btn').forEach(btn => {\n            if (btn.dataset.bound) return;\n            btn.dataset.bound = 'true';\n            btn.addEventListener('click', (e) => {\n                e.preventDefault();\n                document.querySelectorAll('.asn-view-btn').forEach(b => b.classList.remove('active'));\n                btn.classList.add('active');\n                const view = btn.dataset.view;\n                if (view === 'editor') {\n                    editor.setAttribute('contenteditable', 'true');\n                    showToast('Switched to Editor Mode');\n                } else if (view === 'preview') {\n                    editor.setAttribute('contenteditable', 'false');\n                    showToast('Switched to Preview Mode');\n                } else if (view === 'print') {\n                    printNotes();\n                }\n            });\n        });\n\n        bindClick('asn-copy-full-btn', copyFullNotes);\n        bindClick('asn-copy-word-btn', copyForWord);\n        bindClick('asn-copy-html-btn', async () => {\n            await navigator.clipboard.writeText(editor.innerHTML);\n            showToast('Copied HTML source');\n        });\n        bindClick('asn-copy-plain-btn', async () => {\n            await navigator.clipboard.writeText(editor.textContent || editor.innerText);\n            showToast('Copied as Plain Text');\n        });\n        bindClick('asn-export-word-btn', exportWordDocument);\n        bindClick('asn-print-pdf-btn', printNotes);\n\n        document.querySelectorAll('.asn-fmt-btn[data-cmd]').forEach(btn => {\n            if (btn.dataset.bound) return;\n            btn.dataset.bound = 'true';\n            btn.addEventListener('click', (e) => {\n                e.preventDefault();\n                saveStateToHistory();\n                document.execCommand(btn.dataset.cmd, false, btn.dataset.value || null);\n                editor.focus();\n            });\n        });\n\n        bindClick('asn-insert-table-btn', () => {\n            saveStateToHistory();\n            const tableHtml = '<div class=\"asn-table-wrap\"><table><thead><tr><th>Header 1<\/th><th>Header 2<\/th><\/tr><\/thead><tbody><tr><td>Data 1<\/td><td>Data 2<\/td><\/tr><\/tbody><\/table><\/div><p><br><\/p>';\n            document.execCommand('insertHTML', false, tableHtml);\n            showToast('Table inserted');\n        });\n\n        bindClick('asn-insert-svg-btn', () => {\n            saveStateToHistory();\n            const svgHtml = '<div class=\"asn-diagram-node\" contenteditable=\"false\"><svg viewBox=\"0 0 300 80\" width=\"100%\" height=\"auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><rect width=\"300\" height=\"80\" rx=\"4\" fill=\"#f1f5f9\" stroke=\"#cbd5e1\"\/><text x=\"150\" y=\"45\" fill=\"#334155\" font-size=\"12\" font-weight=\"bold\" text-anchor=\"middle\">New AI Diagram Node<\/text><\/svg><\/div><p><br><\/p>';\n            document.execCommand('insertHTML', false, svgHtml);\n            showToast('Diagram inserted');\n        });\n\n        const closeModal = () => {\n            const m = document.getElementById('asn-modal-overlay');\n            if (m) m.style.display = 'none';\n        };\n        bindClick('asn-modal-close', closeModal);\n        bindClick('asn-modal-dismiss-btn', closeModal);\n\n        document.querySelectorAll('.asn-diag-action').forEach(btn => {\n            if (btn.dataset.bound) return;\n            btn.dataset.bound = 'true';\n            btn.addEventListener('click', (e) => {\n                e.preventDefault();\n                if (!state.selectedDiagram) return;\n                const action = btn.dataset.action;\n                if (action === 'delete') {\n                    saveStateToHistory();\n                    state.selectedDiagram.remove();\n                    state.selectedDiagram = null;\n                    document.getElementById('asn-diagram-toolbar').style.display = 'none';\n                    showToast('Diagram removed');\n                } else if (action === 'center') {\n                    state.selectedDiagram.style.textAlign = 'center';\n                    showToast('Diagram centered');\n                } else if (action === 'copy') {\n                    navigator.clipboard.writeText(state.selectedDiagram.innerHTML);\n                    showToast('Diagram markup copied');\n                } else if (action === 'svg') {\n                    const blob = new Blob([state.selectedDiagram.innerHTML], { type: 'image\/svg+xml;charset=utf-8' });\n                    const url = URL.createObjectURL(blob);\n                    const a = document.createElement('a');\n                    a.href = url;\n                    a.download = `diagram-${Date.now()}.svg`;\n                    a.click();\n                    URL.revokeObjectURL(url);\n                    showToast('SVG Downloaded');\n                }\n            });\n        });\n\n        updateUndoRedoButtons();\n    });\n})();\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>Workflow: Paste AI Notes Fix Symbols Document Check Undo Redo View Mode: Editor Preview Print Preview Copy: Copy Full Notes Copy for Word Copy HTML Copy Plain Text Export \/ Print: Export Word Print \/ PDF B I U S H1 H2 P \u2022 List 1. List \u2794 Indent \u2b05 Outdent X\u00b2 X\u2082 Insert Table [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-988","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/pages\/988","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/comments?post=988"}],"version-history":[{"count":5,"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/pages\/988\/revisions"}],"predecessor-version":[{"id":994,"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/pages\/988\/revisions\/994"}],"wp:attachment":[{"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/media?parent=988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}