overtype 1.0.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/LICENSE +21 -0
- package/README.md +441 -0
- package/dist/overtype.esm.js +2576 -0
- package/dist/overtype.esm.js.map +7 -0
- package/dist/overtype.js +2599 -0
- package/dist/overtype.js.map +7 -0
- package/dist/overtype.min.js +546 -0
- package/package.json +50 -0
- package/src/icons.js +77 -0
- package/src/index.js +4 -0
- package/src/overtype.js +781 -0
- package/src/parser.js +222 -0
- package/src/shortcuts.js +125 -0
- package/src/styles.js +486 -0
- package/src/themes.js +124 -0
- package/src/toolbar.js +221 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/parser.js", "../node_modules/markdown-actions/src/core/formats.js", "../node_modules/markdown-actions/src/debug.js", "../node_modules/markdown-actions/src/core/insertion.js", "../node_modules/markdown-actions/src/core/selection.js", "../node_modules/markdown-actions/src/operations/block.js", "../node_modules/markdown-actions/src/operations/list.js", "../node_modules/markdown-actions/src/core/detection.js", "../node_modules/markdown-actions/src/index.js", "../src/shortcuts.js", "../src/themes.js", "../src/styles.js", "../src/icons.js", "../src/toolbar.js", "../src/overtype.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * MarkdownParser - Parses markdown into HTML while preserving character alignment\n * \n * Key principles:\n * - Every character must occupy the exact same position as in the textarea\n * - No font-size changes, no padding/margin on inline elements\n * - Markdown tokens remain visible but styled\n */\nexport class MarkdownParser {\n /**\n * Escape HTML special characters\n * @param {string} text - Raw text to escape\n * @returns {string} Escaped HTML-safe text\n */\n static escapeHtml(text) {\n const map = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": '''\n };\n return text.replace(/[&<>\"']/g, m => map[m]);\n }\n\n /**\n * Preserve leading spaces as non-breaking spaces\n * @param {string} html - HTML string\n * @param {string} originalLine - Original line with spaces\n * @returns {string} HTML with preserved indentation\n */\n static preserveIndentation(html, originalLine) {\n const leadingSpaces = originalLine.match(/^(\\s*)/)[1];\n const indentation = leadingSpaces.replace(/ /g, ' ');\n return html.replace(/^\\s*/, indentation);\n }\n\n /**\n * Parse headers (h1-h3 only)\n * @param {string} html - HTML line to parse\n * @returns {string} Parsed HTML with header styling\n */\n static parseHeader(html) {\n return html.replace(/^(#{1,3})\\s(.+)$/, (match, hashes, content) => {\n const level = hashes.length;\n const levelClasses = ['h1', 'h2', 'h3'];\n return `<span class=\"header ${levelClasses[level-1]}\"><span class=\"syntax-marker\">${hashes}</span> ${content}</span>`;\n });\n }\n\n /**\n * Parse horizontal rules\n * @param {string} html - HTML line to parse\n * @returns {string|null} Parsed horizontal rule or null\n */\n static parseHorizontalRule(html) {\n if (html.match(/^(-{3,}|\\*{3,}|_{3,})$/)) {\n return `<div><span class=\"hr-marker\">${html}</span></div>`;\n }\n return null;\n }\n\n /**\n * Parse blockquotes\n * @param {string} html - HTML line to parse\n * @returns {string} Parsed blockquote\n */\n static parseBlockquote(html) {\n return html.replace(/^> (.+)$/, (match, content) => {\n return `<span class=\"blockquote\"><span class=\"syntax-marker\">></span> ${content}</span>`;\n });\n }\n\n /**\n * Parse bullet lists\n * @param {string} html - HTML line to parse\n * @returns {string} Parsed bullet list item\n */\n static parseBulletList(html) {\n return html.replace(/^((?: )*)([-*])\\s(.+)$/, (match, indent, marker, content) => {\n return `${indent}<span class=\"syntax-marker\">${marker}</span> ${content}`;\n });\n }\n\n /**\n * Parse numbered lists\n * @param {string} html - HTML line to parse\n * @returns {string} Parsed numbered list item\n */\n static parseNumberedList(html) {\n return html.replace(/^((?: )*)(\\d+\\.)\\s(.+)$/, (match, indent, marker, content) => {\n return `${indent}<span class=\"syntax-marker\">${marker}</span> ${content}`;\n });\n }\n\n /**\n * Parse code blocks (markers only)\n * @param {string} html - HTML line to parse\n * @returns {string|null} Parsed code fence or null\n */\n static parseCodeBlock(html) {\n if (html.startsWith('```')) {\n return `<div><span class=\"code-fence\">${html}</span></div>`;\n }\n return null;\n }\n\n /**\n * Parse bold text\n * @param {string} html - HTML with potential bold markdown\n * @returns {string} HTML with bold styling\n */\n static parseBold(html) {\n html = html.replace(/\\*\\*(.+?)\\*\\*/g, '<strong><span class=\"syntax-marker\">**</span>$1<span class=\"syntax-marker\">**</span></strong>');\n html = html.replace(/__(.+?)__/g, '<strong><span class=\"syntax-marker\">__</span>$1<span class=\"syntax-marker\">__</span></strong>');\n return html;\n }\n\n /**\n * Parse italic text\n * Note: Uses lookbehind assertions - requires modern browsers\n * @param {string} html - HTML with potential italic markdown\n * @returns {string} HTML with italic styling\n */\n static parseItalic(html) {\n html = html.replace(/(?<!\\*)\\*(?!\\*)(.+?)(?<!\\*)\\*(?!\\*)/g, '<em><span class=\"syntax-marker\">*</span>$1<span class=\"syntax-marker\">*</span></em>');\n html = html.replace(/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g, '<em><span class=\"syntax-marker\">_</span>$1<span class=\"syntax-marker\">_</span></em>');\n return html;\n }\n\n /**\n * Parse inline code\n * @param {string} html - HTML with potential code markdown\n * @returns {string} HTML with code styling\n */\n static parseInlineCode(html) {\n return html.replace(/`(.+?)`/g, '<code><span class=\"syntax-marker\">`</span>$1<span class=\"syntax-marker\">`</span></code>');\n }\n\n /**\n * Parse links\n * @param {string} html - HTML with potential link markdown\n * @returns {string} HTML with link styling\n */\n static parseLinks(html) {\n return html.replace(/\\[(.+?)\\]\\((.+?)\\)/g, '<a href=\"$2\"><span class=\"syntax-marker\">[</span>$1<span class=\"syntax-marker\">](</span><span class=\"syntax-marker\">$2</span><span class=\"syntax-marker\">)</span></a>');\n }\n\n /**\n * Parse all inline elements in correct order\n * @param {string} text - Text with potential inline markdown\n * @returns {string} HTML with all inline styling\n */\n static parseInlineElements(text) {\n let html = text;\n // Order matters: parse code first to avoid conflicts\n html = this.parseInlineCode(html);\n html = this.parseLinks(html);\n html = this.parseBold(html);\n html = this.parseItalic(html);\n return html;\n }\n\n /**\n * Parse a single line of markdown\n * @param {string} line - Raw markdown line\n * @returns {string} Parsed HTML line\n */\n static parseLine(line) {\n let html = this.escapeHtml(line);\n \n // Preserve indentation\n html = this.preserveIndentation(html, line);\n \n // Check for block elements first\n const horizontalRule = this.parseHorizontalRule(html);\n if (horizontalRule) return horizontalRule;\n \n const codeBlock = this.parseCodeBlock(html);\n if (codeBlock) return codeBlock;\n \n // Parse block elements\n html = this.parseHeader(html);\n html = this.parseBlockquote(html);\n html = this.parseBulletList(html);\n html = this.parseNumberedList(html);\n \n // Parse inline elements\n html = this.parseInlineElements(html);\n \n // Wrap in div to maintain line structure\n if (html.trim() === '') {\n return '<div> </div>';\n }\n \n return `<div>${html}</div>`;\n }\n\n /**\n * Parse full markdown text\n * @param {string} text - Full markdown text\n * @param {number} activeLine - Currently active line index (optional)\n * @param {boolean} showActiveLineRaw - Show raw markdown on active line\n * @returns {string} Parsed HTML\n */\n static parse(text, activeLine = -1, showActiveLineRaw = false) {\n const lines = text.split('\\n');\n const parsedLines = lines.map((line, index) => {\n // Show raw markdown on active line if requested\n if (showActiveLineRaw && index === activeLine) {\n const content = this.escapeHtml(line) || ' ';\n return `<div class=\"raw-line\">${content}</div>`;\n }\n \n // Otherwise, parse the markdown normally\n return this.parseLine(line);\n });\n \n // Join without newlines to prevent extra spacing\n return parsedLines.join('');\n }\n}", "/**\n * Format definitions for markdown syntax\n */\n\nexport const FORMATS = {\n bold: {\n prefix: '**',\n suffix: '**',\n trimFirst: true\n },\n italic: {\n prefix: '_',\n suffix: '_',\n trimFirst: true\n },\n code: {\n prefix: '`',\n suffix: '`',\n blockPrefix: '```',\n blockSuffix: '```'\n },\n link: {\n prefix: '[',\n suffix: '](url)',\n replaceNext: 'url',\n scanFor: 'https?://'\n },\n bulletList: {\n prefix: '- ',\n multiline: true,\n unorderedList: true\n },\n numberedList: {\n prefix: '1. ',\n multiline: true,\n orderedList: true\n },\n quote: {\n prefix: '> ',\n multiline: true,\n surroundWithNewlines: true\n },\n taskList: {\n prefix: '- [ ] ',\n multiline: true,\n surroundWithNewlines: true\n },\n header1: { prefix: '# ' },\n header2: { prefix: '## ' },\n header3: { prefix: '### ' },\n header4: { prefix: '#### ' },\n header5: { prefix: '##### ' },\n header6: { prefix: '###### ' }\n}\n\n/**\n * Default style configuration\n */\nexport function getDefaultStyle() {\n return {\n prefix: '',\n suffix: '',\n blockPrefix: '',\n blockSuffix: '',\n multiline: false,\n replaceNext: '',\n prefixSpace: false,\n scanFor: '',\n surroundWithNewlines: false,\n orderedList: false,\n unorderedList: false,\n trimFirst: false\n }\n}\n\n/**\n * Merge format with defaults\n */\nexport function mergeWithDefaults(format) {\n return { ...getDefaultStyle(), ...format }\n}", "/**\n * Debug utilities for markdown-actions\n * Add console logging to track what's happening\n */\n\n// Debug mode flag - disabled by default\nlet debugMode = false;\n\n/**\n * Enable or disable debug mode\n * @param {boolean} enabled - Whether to enable debug mode\n */\nexport function setDebugMode(enabled) {\n debugMode = enabled;\n}\n\n/**\n * Get current debug mode status\n * @returns {boolean} Whether debug mode is enabled\n */\nexport function getDebugMode() {\n return debugMode;\n}\n\nexport function debugLog(funcName, message, data) {\n if (!debugMode) return;\n \n console.group(`\uD83D\uDD0D ${funcName}`);\n console.log(message);\n if (data) {\n console.log('Data:', data);\n }\n console.groupEnd();\n}\n\nexport function debugSelection(textarea, label) {\n if (!debugMode) return;\n \n const selected = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd);\n console.group(`\uD83D\uDCCD Selection: ${label}`);\n console.log('Position:', `${textarea.selectionStart}-${textarea.selectionEnd}`);\n console.log('Selected text:', JSON.stringify(selected));\n console.log('Length:', selected.length);\n \n // Show context around selection\n const before = textarea.value.slice(Math.max(0, textarea.selectionStart - 10), textarea.selectionStart);\n const after = textarea.value.slice(textarea.selectionEnd, Math.min(textarea.value.length, textarea.selectionEnd + 10));\n console.log('Context:', JSON.stringify(before) + '[SELECTION]' + JSON.stringify(after));\n console.groupEnd();\n}\n\nexport function debugResult(result) {\n if (!debugMode) return;\n \n console.group('\uD83D\uDCDD Result');\n console.log('Text to insert:', JSON.stringify(result.text));\n console.log('New selection:', `${result.selectionStart}-${result.selectionEnd}`);\n console.groupEnd();\n}", "/**\n * Text insertion system with undo/redo support\n * Extracted and adapted from GitHub's markdown-toolbar-element\n */\n\nimport { getDebugMode } from '../debug.js'\n\nlet canInsertText = null\n\n/**\n * Insert text at current position with undo/redo support\n * @param {HTMLTextAreaElement} textarea - Target textarea\n * @param {Object} options - Text and selection options\n * @param {string} options.text - Text to insert\n * @param {number} [options.selectionStart] - New selection start\n * @param {number} [options.selectionEnd] - New selection end\n */\nexport function insertText(textarea, { text, selectionStart, selectionEnd }) {\n const debugMode = getDebugMode();\n \n if (debugMode) {\n console.group('\uD83D\uDD27 insertText');\n console.log('Current selection:', `${textarea.selectionStart}-${textarea.selectionEnd}`);\n console.log('Text to insert:', JSON.stringify(text));\n console.log('New selection to set:', selectionStart, '-', selectionEnd);\n }\n \n // Make sure the textarea is focused\n textarea.focus();\n \n const originalSelectionStart = textarea.selectionStart\n const originalSelectionEnd = textarea.selectionEnd\n const before = textarea.value.slice(0, originalSelectionStart)\n const after = textarea.value.slice(originalSelectionEnd)\n \n if (debugMode) {\n console.log('Before text (last 20):', JSON.stringify(before.slice(-20)));\n console.log('After text (first 20):', JSON.stringify(after.slice(0, 20)));\n console.log('Selected text being replaced:', JSON.stringify(textarea.value.slice(originalSelectionStart, originalSelectionEnd)));\n }\n \n // Store the original value to check if execCommand actually changed it\n const originalValue = textarea.value\n\n // Only try execCommand if there's no selection (just inserting at cursor)\n // For replacements, we should use manual mode\n const hasSelection = originalSelectionStart !== originalSelectionEnd\n \n if (!hasSelection && (canInsertText === null || canInsertText === true)) {\n textarea.contentEditable = 'true'\n try {\n canInsertText = document.execCommand('insertText', false, text)\n } catch (error) {\n canInsertText = false\n }\n textarea.contentEditable = 'false'\n } else if (hasSelection) {\n if (debugMode) console.log('Has selection, skipping execCommand and using manual mode');\n canInsertText = false\n }\n\n if (debugMode) {\n console.log('canInsertText before:', canInsertText);\n console.log('execCommand result:', canInsertText);\n }\n \n // Check if execCommand actually worked by comparing the value\n if (canInsertText) {\n const expectedValue = before + text + after\n const actualValue = textarea.value\n \n if (debugMode) {\n console.log('Expected length:', expectedValue.length);\n console.log('Actual length:', actualValue.length);\n }\n \n if (actualValue !== expectedValue) {\n if (debugMode) {\n console.log('execCommand changed the value but not as expected');\n console.log('Expected:', JSON.stringify(expectedValue.slice(0, 100)));\n console.log('Actual:', JSON.stringify(actualValue.slice(0, 100)));\n }\n // Don't set canInsertText to false here - execCommand did work\n // We just need to not double-insert\n }\n }\n\n if (!canInsertText) {\n if (debugMode) console.log('Using manual insertion');\n // Only do manual insertion if execCommand didn't change the value\n if (textarea.value === originalValue) {\n if (debugMode) console.log('Value unchanged, doing manual replacement');\n try {\n document.execCommand('ms-beginUndoUnit')\n } catch (e) {\n // Do nothing.\n }\n textarea.value = before + text + after\n try {\n document.execCommand('ms-endUndoUnit')\n } catch (e) {\n // Do nothing.\n }\n textarea.dispatchEvent(new CustomEvent('input', { bubbles: true, cancelable: true }))\n } else {\n if (debugMode) console.log('Value was changed by execCommand, skipping manual insertion');\n }\n }\n\n if (debugMode) console.log('Setting selection range:', selectionStart, selectionEnd);\n if (selectionStart != null && selectionEnd != null) {\n textarea.setSelectionRange(selectionStart, selectionEnd)\n } else {\n textarea.setSelectionRange(originalSelectionStart, textarea.selectionEnd)\n }\n \n if (debugMode) {\n console.log('Final value length:', textarea.value.length);\n console.groupEnd();\n }\n}\n\n/**\n * Configure undo method\n * @param {'native' | 'manual' | 'auto'} method - Undo method to use\n */\nexport function setUndoMethod(method) {\n switch (method) {\n case 'native':\n canInsertText = true\n break\n case 'manual':\n canInsertText = false\n break\n case 'auto':\n canInsertText = null\n break\n }\n}", "/**\n * Core selection utilities extracted and adapted from GitHub's markdown-toolbar-element\n */\n\n/**\n * Check if string contains multiple lines\n */\nexport function isMultipleLines(string) {\n return string.trim().split('\\n').length > 1\n}\n\n/**\n * Find the start of the word at position i\n */\nexport function wordSelectionStart(text, i) {\n let index = i\n while (text[index] && text[index - 1] != null && !text[index - 1].match(/\\s/)) {\n index--\n }\n return index\n}\n\n/**\n * Find the end of the word at position i\n */\nexport function wordSelectionEnd(text, i, multiline) {\n let index = i\n const breakpoint = multiline ? /\\n/ : /\\s/\n while (text[index] && !text[index].match(breakpoint)) {\n index++\n }\n return index\n}\n\n/**\n * Expand selection to line boundaries\n */\nexport function expandSelectionToLine(textarea) {\n const lines = textarea.value.split('\\n')\n let counter = 0\n for (let index = 0; index < lines.length; index++) {\n const lineLength = lines[index].length + 1\n if (textarea.selectionStart >= counter && textarea.selectionStart < counter + lineLength) {\n textarea.selectionStart = counter\n }\n if (textarea.selectionEnd >= counter && textarea.selectionEnd < counter + lineLength) {\n // For the last line, don't go past the actual text length\n if (index === lines.length - 1) {\n textarea.selectionEnd = Math.min(counter + lines[index].length, textarea.value.length)\n } else {\n textarea.selectionEnd = counter + lineLength - 1\n }\n }\n counter += lineLength\n }\n}\n\n/**\n * Expand selected text with smart boundary detection\n */\nexport function expandSelectedText(textarea, prefixToUse, suffixToUse, multiline = false) {\n if (textarea.selectionStart === textarea.selectionEnd) {\n textarea.selectionStart = wordSelectionStart(textarea.value, textarea.selectionStart)\n textarea.selectionEnd = wordSelectionEnd(textarea.value, textarea.selectionEnd, multiline)\n } else {\n const expandedSelectionStart = textarea.selectionStart - prefixToUse.length\n const expandedSelectionEnd = textarea.selectionEnd + suffixToUse.length\n const beginsWithPrefix = textarea.value.slice(expandedSelectionStart, textarea.selectionStart) === prefixToUse\n const endsWithSuffix = textarea.value.slice(textarea.selectionEnd, expandedSelectionEnd) === suffixToUse\n if (beginsWithPrefix && endsWithSuffix) {\n textarea.selectionStart = expandedSelectionStart\n textarea.selectionEnd = expandedSelectionEnd\n }\n }\n return textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n}\n\n/**\n * Calculate newlines needed to surround selected text\n */\nexport function newlinesToSurroundSelectedText(textarea) {\n const beforeSelection = textarea.value.slice(0, textarea.selectionStart)\n const afterSelection = textarea.value.slice(textarea.selectionEnd)\n\n const breaksBefore = beforeSelection.match(/\\n*$/)\n const breaksAfter = afterSelection.match(/^\\n*/)\n const newlinesBeforeSelection = breaksBefore ? breaksBefore[0].length : 0\n const newlinesAfterSelection = breaksAfter ? breaksAfter[0].length : 0\n\n let newlinesToAppend = ''\n let newlinesToPrepend = ''\n\n if (beforeSelection.match(/\\S/) && newlinesBeforeSelection < 2) {\n newlinesToAppend = '\\n'.repeat(2 - newlinesBeforeSelection)\n }\n\n if (afterSelection.match(/\\S/) && newlinesAfterSelection < 2) {\n newlinesToPrepend = '\\n'.repeat(2 - newlinesAfterSelection)\n }\n\n return { newlinesToAppend, newlinesToPrepend }\n}\n\n/**\n * Utility to preserve selection during operations\n */\nexport function preserveSelection(textarea, callback) {\n const start = textarea.selectionStart\n const end = textarea.selectionEnd\n const scrollTop = textarea.scrollTop\n \n callback()\n \n textarea.selectionStart = start\n textarea.selectionEnd = end\n textarea.scrollTop = scrollTop\n}\n\n/**\n * Apply a line-based operation with cursor preservation\n * This function handles expanding to line boundaries and preserving cursor position\n * @param {HTMLTextAreaElement} textarea - The textarea element\n * @param {Function} operation - The operation to perform (receives textarea and returns result)\n * @param {Object} options - Options for the operation\n * @param {string} options.prefix - The prefix being added/removed (for cursor adjustment)\n * @param {Function} options.adjustSelection - Custom selection adjustment function\n * @returns {Object} The result from the operation with adjusted cursor position\n */\nexport function applyLineOperation(textarea, operation, options = {}) {\n // Save original cursor position AND selection before any expansion\n const originalStart = textarea.selectionStart\n const originalEnd = textarea.selectionEnd\n const noInitialSelection = originalStart === originalEnd\n \n // Store the line start position to calculate offset later\n const value = textarea.value\n let lineStart = originalStart\n \n // Find start of the line containing the selection start\n while (lineStart > 0 && value[lineStart - 1] !== '\\n') {\n lineStart--\n }\n \n // Expand selection to line boundaries for the operation\n if (noInitialSelection) {\n // Expand to current line when no selection\n let lineEnd = originalStart\n \n // Find end of current line\n while (lineEnd < value.length && value[lineEnd] !== '\\n') {\n lineEnd++\n }\n \n textarea.selectionStart = lineStart\n textarea.selectionEnd = lineEnd\n } else {\n // For selections, expand to full lines\n expandSelectionToLine(textarea)\n }\n \n // Apply the operation\n const result = operation(textarea)\n \n // Restore original selection/cursor with prefix adjustment\n if (options.adjustSelection) {\n // Use custom selection adjustment logic\n const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n const isRemoving = selectedText.startsWith(options.prefix)\n const adjusted = options.adjustSelection(isRemoving, originalStart, originalEnd, lineStart)\n result.selectionStart = adjusted.start\n result.selectionEnd = adjusted.end\n } else if (options.prefix) {\n // Use default prefix-based adjustment\n const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n const isRemoving = selectedText.startsWith(options.prefix)\n \n if (noInitialSelection) {\n // No selection - just restore cursor position\n if (isRemoving) {\n // When removing prefix, adjust cursor position\n result.selectionStart = Math.max(originalStart - options.prefix.length, lineStart)\n result.selectionEnd = result.selectionStart\n } else {\n // When adding prefix, adjust cursor position\n result.selectionStart = originalStart + options.prefix.length\n result.selectionEnd = result.selectionStart\n }\n } else {\n // Had a selection - restore it with adjustment\n if (isRemoving) {\n // When removing prefix, shift selection back\n result.selectionStart = Math.max(originalStart - options.prefix.length, lineStart)\n result.selectionEnd = Math.max(originalEnd - options.prefix.length, lineStart)\n } else {\n // When adding prefix, shift selection forward\n result.selectionStart = originalStart + options.prefix.length\n result.selectionEnd = originalEnd + options.prefix.length\n }\n }\n }\n \n return result\n}", "/**\n * Block-level text formatting operations\n * Handles inline formats like bold, italic, code, and links\n */\n\nimport { expandSelectedText, newlinesToSurroundSelectedText, isMultipleLines } from '../core/selection.js'\nimport { insertText } from '../core/insertion.js'\n\n/**\n * Apply block-level styling to selected text\n */\nexport function blockStyle(textarea, style) {\n let newlinesToAppend\n let newlinesToPrepend\n\n const { prefix, suffix, blockPrefix, blockSuffix, replaceNext, prefixSpace, scanFor, surroundWithNewlines, trimFirst } = style\n const originalSelectionStart = textarea.selectionStart\n const originalSelectionEnd = textarea.selectionEnd\n\n let selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n let prefixToUse = isMultipleLines(selectedText) && blockPrefix && blockPrefix.length > 0 ? `${blockPrefix}\\n` : prefix\n let suffixToUse = isMultipleLines(selectedText) && blockSuffix && blockSuffix.length > 0 ? `\\n${blockSuffix}` : suffix\n\n if (prefixSpace) {\n const beforeSelection = textarea.value[textarea.selectionStart - 1]\n if (textarea.selectionStart !== 0 && beforeSelection != null && !beforeSelection.match(/\\s/)) {\n prefixToUse = ` ${prefixToUse}`\n }\n }\n \n selectedText = expandSelectedText(textarea, prefixToUse, suffixToUse, style.multiline)\n let selectionStart = textarea.selectionStart\n let selectionEnd = textarea.selectionEnd\n const hasReplaceNext = replaceNext && replaceNext.length > 0 && suffixToUse.indexOf(replaceNext) > -1 && selectedText.length > 0\n \n if (surroundWithNewlines) {\n const ref = newlinesToSurroundSelectedText(textarea)\n newlinesToAppend = ref.newlinesToAppend\n newlinesToPrepend = ref.newlinesToPrepend\n prefixToUse = newlinesToAppend + prefix\n suffixToUse += newlinesToPrepend\n }\n\n // Check if we should remove formatting (toggle off)\n if (selectedText.startsWith(prefixToUse) && selectedText.endsWith(suffixToUse)) {\n const replacementText = selectedText.slice(prefixToUse.length, selectedText.length - suffixToUse.length)\n if (originalSelectionStart === originalSelectionEnd) {\n let position = originalSelectionStart - prefixToUse.length\n position = Math.max(position, selectionStart)\n position = Math.min(position, selectionStart + replacementText.length)\n selectionStart = selectionEnd = position\n } else {\n selectionEnd = selectionStart + replacementText.length\n }\n return { text: replacementText, selectionStart, selectionEnd }\n } else if (!hasReplaceNext) {\n // Add formatting\n let replacementText = prefixToUse + selectedText + suffixToUse\n selectionStart = originalSelectionStart + prefixToUse.length\n selectionEnd = originalSelectionEnd + prefixToUse.length\n const whitespaceEdges = selectedText.match(/^\\s*|\\s*$/g)\n if (trimFirst && whitespaceEdges) {\n const leadingWhitespace = whitespaceEdges[0] || ''\n const trailingWhitespace = whitespaceEdges[1] || ''\n replacementText = leadingWhitespace + prefixToUse + selectedText.trim() + suffixToUse + trailingWhitespace\n selectionStart += leadingWhitespace.length\n selectionEnd -= trailingWhitespace.length\n }\n return { text: replacementText, selectionStart, selectionEnd }\n } else if (scanFor && scanFor.length > 0 && selectedText.match(scanFor)) {\n // Handle link/image with URL detection\n suffixToUse = suffixToUse.replace(replaceNext, selectedText)\n const replacementText = prefixToUse + suffixToUse\n selectionStart = selectionEnd = selectionStart + prefixToUse.length\n return { text: replacementText, selectionStart, selectionEnd }\n } else {\n // Handle link/image with placeholder\n const replacementText = prefixToUse + selectedText + suffixToUse\n selectionStart = selectionStart + prefixToUse.length + selectedText.length + suffixToUse.indexOf(replaceNext)\n selectionEnd = selectionStart + replaceNext.length\n return { text: replacementText, selectionStart, selectionEnd }\n }\n}\n\n/**\n * Apply style to selected text in textarea\n */\nexport function styleSelectedText(textarea, style) {\n const text = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n \n let result\n if (style.orderedList || style.unorderedList) {\n // Will be handled by list operations\n return\n } else if (style.multiline && isMultipleLines(text)) {\n result = multilineStyle(textarea, style)\n } else {\n result = blockStyle(textarea, style)\n }\n\n insertText(textarea, result)\n}\n\n/**\n * Apply multiline styling (quotes, task lists, etc)\n * Note: This does NOT expand selection to line - that should be done by the caller if needed\n */\nexport function multilineStyle(textarea, style) {\n const { prefix, suffix, surroundWithNewlines } = style\n let text = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n let selectionStart = textarea.selectionStart\n let selectionEnd = textarea.selectionEnd\n const lines = text.split('\\n')\n \n // Check if we need to undo (all lines have the format)\n const undoStyle = lines.every(line => line.startsWith(prefix) && (!suffix || line.endsWith(suffix)))\n\n if (undoStyle) {\n // Remove the formatting\n text = lines.map(line => {\n let result = line.slice(prefix.length)\n if (suffix) {\n result = result.slice(0, result.length - suffix.length)\n }\n return result\n }).join('\\n')\n selectionEnd = selectionStart + text.length\n } else {\n // Apply the formatting\n text = lines.map(line => prefix + line + (suffix || '')).join('\\n')\n if (surroundWithNewlines) {\n const { newlinesToAppend, newlinesToPrepend } = newlinesToSurroundSelectedText(textarea)\n selectionStart += newlinesToAppend.length\n selectionEnd = selectionStart + text.length\n text = newlinesToAppend + text + newlinesToPrepend\n }\n }\n\n return { text, selectionStart, selectionEnd }\n}", "/**\n * List operations for bullet and numbered lists\n */\n\nimport { expandSelectionToLine, newlinesToSurroundSelectedText, applyLineOperation } from '../core/selection.js'\nimport { insertText } from '../core/insertion.js'\n\n/**\n * Undo ordered list formatting\n */\nfunction undoOrderedListStyle(text) {\n const lines = text.split('\\n')\n const orderedListRegex = /^\\d+\\.\\s+/\n const shouldUndoOrderedList = lines.every(line => orderedListRegex.test(line))\n let result = lines\n if (shouldUndoOrderedList) {\n result = lines.map(line => line.replace(orderedListRegex, ''))\n }\n\n return {\n text: result.join('\\n'),\n processed: shouldUndoOrderedList\n }\n}\n\n/**\n * Undo unordered list formatting\n */\nfunction undoUnorderedListStyle(text) {\n const lines = text.split('\\n')\n const unorderedListPrefix = '- '\n const shouldUndoUnorderedList = lines.every(line => line.startsWith(unorderedListPrefix))\n let result = lines\n if (shouldUndoUnorderedList) {\n result = lines.map(line => line.slice(unorderedListPrefix.length))\n }\n\n return {\n text: result.join('\\n'),\n processed: shouldUndoUnorderedList\n }\n}\n\n/**\n * Make prefix for list item\n */\nfunction makePrefix(index, unorderedList) {\n if (unorderedList) {\n return '- '\n } else {\n return `${index + 1}. `\n }\n}\n\n/**\n * Clear existing list style\n */\nfunction clearExistingListStyle(style, selectedText) {\n let undoResult\n let undoResultOppositeList\n let pristineText\n \n if (style.orderedList) {\n undoResult = undoOrderedListStyle(selectedText)\n undoResultOppositeList = undoUnorderedListStyle(undoResult.text)\n pristineText = undoResultOppositeList.text\n } else {\n undoResult = undoUnorderedListStyle(selectedText)\n undoResultOppositeList = undoOrderedListStyle(undoResult.text)\n pristineText = undoResultOppositeList.text\n }\n \n return [undoResult, undoResultOppositeList, pristineText]\n}\n\n/**\n * Apply list styling to selected text\n */\nexport function listStyle(textarea, style) {\n const noInitialSelection = textarea.selectionStart === textarea.selectionEnd\n let selectionStart = textarea.selectionStart\n let selectionEnd = textarea.selectionEnd\n\n // Select whole line\n expandSelectionToLine(textarea)\n\n const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n\n // Clear any existing list formatting\n const [undoResult, undoResultOppositeList, pristineText] = clearExistingListStyle(style, selectedText)\n\n const prefixedLines = pristineText.split('\\n').map((value, index) => {\n return `${makePrefix(index, style.unorderedList)}${value}`\n })\n\n const totalPrefixLength = prefixedLines.reduce((previousValue, _currentValue, currentIndex) => {\n return previousValue + makePrefix(currentIndex, style.unorderedList).length\n }, 0)\n\n const totalPrefixLengthOppositeList = prefixedLines.reduce((previousValue, _currentValue, currentIndex) => {\n return previousValue + makePrefix(currentIndex, !style.unorderedList).length\n }, 0)\n\n // If we're undoing the same list type, just return the pristine text\n if (undoResult.processed) {\n if (noInitialSelection) {\n selectionStart = Math.max(selectionStart - makePrefix(0, style.unorderedList).length, 0)\n selectionEnd = selectionStart\n } else {\n selectionStart = textarea.selectionStart\n selectionEnd = textarea.selectionEnd - totalPrefixLength\n }\n return { text: pristineText, selectionStart, selectionEnd }\n }\n\n // Apply new list formatting\n const { newlinesToAppend, newlinesToPrepend } = newlinesToSurroundSelectedText(textarea)\n const text = newlinesToAppend + prefixedLines.join('\\n') + newlinesToPrepend\n\n if (noInitialSelection) {\n selectionStart = Math.max(selectionStart + makePrefix(0, style.unorderedList).length + newlinesToAppend.length, 0)\n selectionEnd = selectionStart\n } else {\n if (undoResultOppositeList.processed) {\n // Converting from one list type to another\n selectionStart = Math.max(textarea.selectionStart + newlinesToAppend.length, 0)\n selectionEnd = textarea.selectionEnd + newlinesToAppend.length + totalPrefixLength - totalPrefixLengthOppositeList\n } else {\n // Adding list formatting to plain text\n selectionStart = Math.max(textarea.selectionStart + newlinesToAppend.length, 0)\n selectionEnd = textarea.selectionEnd + newlinesToAppend.length + totalPrefixLength\n }\n }\n\n return { text, selectionStart, selectionEnd }\n}\n\n/**\n * Apply list style to textarea\n */\nexport function applyListStyle(textarea, style) {\n // Use applyLineOperation for consistent selection preservation\n const result = applyLineOperation(\n textarea,\n (ta) => listStyle(ta, style),\n {\n // Custom selection adjustment for lists\n adjustSelection: (isRemoving, selStart, selEnd, lineStart) => {\n // Get the current line to check if we're removing\n const currentLine = textarea.value.slice(lineStart, textarea.selectionEnd)\n const orderedListRegex = /^\\d+\\.\\s+/\n const unorderedListRegex = /^- /\n \n // Check if we're removing a list\n const hasOrderedList = orderedListRegex.test(currentLine)\n const hasUnorderedList = unorderedListRegex.test(currentLine)\n const isRemovingCurrent = (style.orderedList && hasOrderedList) || (style.unorderedList && hasUnorderedList)\n \n if (selStart === selEnd) {\n // No selection - cursor position\n if (isRemovingCurrent) {\n // Removing list - adjust cursor back\n const prefixMatch = currentLine.match(style.orderedList ? orderedListRegex : unorderedListRegex)\n const prefixLength = prefixMatch ? prefixMatch[0].length : 0\n return {\n start: Math.max(selStart - prefixLength, lineStart),\n end: Math.max(selStart - prefixLength, lineStart)\n }\n } else if (hasOrderedList || hasUnorderedList) {\n // Converting from one list type to another\n const oldPrefixMatch = currentLine.match(hasOrderedList ? orderedListRegex : unorderedListRegex)\n const oldPrefixLength = oldPrefixMatch ? oldPrefixMatch[0].length : 0\n const newPrefixLength = style.unorderedList ? 2 : 3 // \"- \" or \"1. \"\n const adjustment = newPrefixLength - oldPrefixLength\n return {\n start: selStart + adjustment,\n end: selStart + adjustment\n }\n } else {\n // Adding new list\n const prefixLength = style.unorderedList ? 2 : 3 // \"- \" or \"1. \"\n return {\n start: selStart + prefixLength,\n end: selStart + prefixLength\n }\n }\n } else {\n // Has selection - preserve it\n if (isRemovingCurrent) {\n // Removing current list type\n const prefixMatch = currentLine.match(style.orderedList ? orderedListRegex : unorderedListRegex)\n const prefixLength = prefixMatch ? prefixMatch[0].length : 0\n return {\n start: Math.max(selStart - prefixLength, lineStart),\n end: Math.max(selEnd - prefixLength, lineStart)\n }\n } else if (hasOrderedList || hasUnorderedList) {\n // Converting from one list type to another\n const oldPrefixMatch = currentLine.match(hasOrderedList ? orderedListRegex : unorderedListRegex)\n const oldPrefixLength = oldPrefixMatch ? oldPrefixMatch[0].length : 0\n const newPrefixLength = style.unorderedList ? 2 : 3 // \"- \" or \"1. \"\n const adjustment = newPrefixLength - oldPrefixLength\n return {\n start: selStart + adjustment,\n end: selEnd + adjustment\n }\n } else {\n // Adding new list\n const prefixLength = style.unorderedList ? 2 : 3 // \"- \" or \"1. \"\n return {\n start: selStart + prefixLength,\n end: selEnd + prefixLength\n }\n }\n }\n }\n }\n )\n \n insertText(textarea, result)\n}", "/**\n * Format detection utilities\n */\n\nimport { FORMATS } from './formats.js'\n\n/**\n * Check if text has a specific format applied\n */\nfunction hasFormatApplied(text, format) {\n if (!format.prefix) return false\n \n if (format.suffix) {\n return text.startsWith(format.prefix) && text.endsWith(format.suffix)\n } else {\n return text.startsWith(format.prefix)\n }\n}\n\n/**\n * Get active formats at cursor position\n */\nexport function getActiveFormats(textarea) {\n if (!textarea) return []\n \n const formats = []\n const { selectionStart, selectionEnd, value } = textarea\n \n // Get current line for line-based formats\n const lines = value.split('\\n')\n let lineStart = 0\n let currentLine = ''\n \n for (const line of lines) {\n if (selectionStart >= lineStart && selectionStart <= lineStart + line.length) {\n currentLine = line\n break\n }\n lineStart += line.length + 1\n }\n \n // Check line-based formats\n if (currentLine.startsWith('- ')) {\n if (currentLine.startsWith('- [ ] ') || currentLine.startsWith('- [x] ')) {\n formats.push('task-list')\n } else {\n formats.push('bullet-list')\n }\n }\n \n if (/^\\d+\\.\\s/.test(currentLine)) {\n formats.push('numbered-list')\n }\n \n if (currentLine.startsWith('> ')) {\n formats.push('quote')\n }\n \n if (currentLine.startsWith('# ')) formats.push('header')\n if (currentLine.startsWith('## ')) formats.push('header-2')\n if (currentLine.startsWith('### ')) formats.push('header-3')\n \n // Check inline formats by looking around cursor\n const lookBehind = Math.max(0, selectionStart - 10)\n const lookAhead = Math.min(value.length, selectionEnd + 10)\n const surrounding = value.slice(lookBehind, lookAhead)\n \n // Check for bold\n if (surrounding.includes('**')) {\n const beforeCursor = value.slice(Math.max(0, selectionStart - 100), selectionStart)\n const afterCursor = value.slice(selectionEnd, Math.min(value.length, selectionEnd + 100))\n const lastOpenBold = beforeCursor.lastIndexOf('**')\n const nextCloseBold = afterCursor.indexOf('**')\n if (lastOpenBold !== -1 && nextCloseBold !== -1) {\n formats.push('bold')\n }\n }\n \n // Check for italic\n if (surrounding.includes('_')) {\n const beforeCursor = value.slice(Math.max(0, selectionStart - 100), selectionStart)\n const afterCursor = value.slice(selectionEnd, Math.min(value.length, selectionEnd + 100))\n const lastOpenItalic = beforeCursor.lastIndexOf('_')\n const nextCloseItalic = afterCursor.indexOf('_')\n if (lastOpenItalic !== -1 && nextCloseItalic !== -1) {\n formats.push('italic')\n }\n }\n \n // Check for code\n if (surrounding.includes('`')) {\n const beforeCursor = value.slice(Math.max(0, selectionStart - 100), selectionStart)\n const afterCursor = value.slice(selectionEnd, Math.min(value.length, selectionEnd + 100))\n if (beforeCursor.includes('`') && afterCursor.includes('`')) {\n formats.push('code')\n }\n }\n \n // Check for link\n if (surrounding.includes('[') && surrounding.includes(']')) {\n const beforeCursor = value.slice(Math.max(0, selectionStart - 100), selectionStart)\n const afterCursor = value.slice(selectionEnd, Math.min(value.length, selectionEnd + 100))\n const lastOpenBracket = beforeCursor.lastIndexOf('[')\n const nextCloseBracket = afterCursor.indexOf(']')\n if (lastOpenBracket !== -1 && nextCloseBracket !== -1) {\n const afterBracket = value.slice(selectionEnd + nextCloseBracket + 1, selectionEnd + nextCloseBracket + 10)\n if (afterBracket.startsWith('(')) {\n formats.push('link')\n }\n }\n }\n \n return formats\n}\n\n/**\n * Check if specific format is active at cursor\n */\nexport function hasFormat(textarea, format) {\n const activeFormats = getActiveFormats(textarea)\n return activeFormats.includes(format)\n}\n\n/**\n * Expand selection based on options\n */\nexport function expandSelection(textarea, options = {}) {\n if (!textarea) return\n \n const { toWord, toLine, toFormat } = options\n const { selectionStart, selectionEnd, value } = textarea\n \n if (toLine) {\n // Find line boundaries\n const lines = value.split('\\n')\n let lineStart = 0\n let lineEnd = 0\n let currentPos = 0\n \n for (const line of lines) {\n if (selectionStart >= currentPos && selectionStart <= currentPos + line.length) {\n lineStart = currentPos\n lineEnd = currentPos + line.length\n break\n }\n currentPos += line.length + 1\n }\n \n textarea.selectionStart = lineStart\n textarea.selectionEnd = lineEnd\n } else if (toWord && selectionStart === selectionEnd) {\n // Find word boundaries\n let start = selectionStart\n let end = selectionEnd\n \n // Move start back to word boundary\n while (start > 0 && !/\\s/.test(value[start - 1])) {\n start--\n }\n \n // Move end forward to word boundary\n while (end < value.length && !/\\s/.test(value[end])) {\n end++\n }\n \n textarea.selectionStart = start\n textarea.selectionEnd = end\n }\n}", "/**\n * markdown-actions - Lightweight markdown toolbar functionality\n * Based on GitHub's markdown-toolbar-element\n */\n\nimport { FORMATS, mergeWithDefaults } from './core/formats.js'\nimport { insertText, setUndoMethod } from './core/insertion.js'\nimport { preserveSelection, isMultipleLines, expandSelectionToLine, applyLineOperation } from './core/selection.js'\nimport { blockStyle, multilineStyle } from './operations/block.js'\nimport { applyListStyle } from './operations/list.js'\nimport { getActiveFormats as getActive, hasFormat as has, expandSelection as expand } from './core/detection.js'\nimport { debugLog, debugSelection, debugResult, setDebugMode, getDebugMode } from './debug.js'\n\n/**\n * Toggle bold formatting\n */\nexport function toggleBold(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n debugLog('toggleBold', 'Starting');\n debugSelection(textarea, 'Before');\n \n const style = mergeWithDefaults(FORMATS.bold)\n const result = blockStyle(textarea, style)\n \n debugResult(result);\n \n insertText(textarea, result)\n \n debugSelection(textarea, 'After');\n}\n\n/**\n * Toggle italic formatting\n */\nexport function toggleItalic(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n const style = mergeWithDefaults(FORMATS.italic)\n const result = blockStyle(textarea, style)\n insertText(textarea, result)\n}\n\n/**\n * Toggle code formatting\n */\nexport function toggleCode(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n // blockStyle already handles both inline and block code correctly\n const style = mergeWithDefaults(FORMATS.code)\n const result = blockStyle(textarea, style)\n insertText(textarea, result)\n}\n\n/**\n * Insert or toggle link formatting\n */\nexport function insertLink(textarea, options = {}) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n let style = mergeWithDefaults(FORMATS.link)\n \n // Check if selected text is a URL\n const isURL = selectedText && selectedText.match(/^https?:\\/\\//)\n \n if (isURL && !options.url) {\n // If selected text is a URL, use it as both link text and URL\n style.suffix = `](${selectedText})`\n style.replaceNext = ''\n // Don't change the selected text, it becomes the link text\n } else if (options.url) {\n // Override with custom URL if provided\n style.suffix = `](${options.url})`\n style.replaceNext = ''\n }\n \n // Override with custom text if provided\n if (options.text && !selectedText) {\n // Insert the text and select it\n const pos = textarea.selectionStart\n textarea.value = textarea.value.slice(0, pos) + options.text + textarea.value.slice(pos)\n textarea.selectionStart = pos\n textarea.selectionEnd = pos + options.text.length\n }\n \n const result = blockStyle(textarea, style)\n insertText(textarea, result)\n}\n\n/**\n * Toggle bullet list formatting\n */\nexport function toggleBulletList(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n const style = mergeWithDefaults(FORMATS.bulletList)\n applyListStyle(textarea, style)\n}\n\n/**\n * Toggle numbered list formatting\n */\nexport function toggleNumberedList(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n const style = mergeWithDefaults(FORMATS.numberedList)\n applyListStyle(textarea, style)\n}\n\n/**\n * Toggle quote formatting\n * Matches GitHub's implementation for quotes\n */\nexport function toggleQuote(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n debugLog('toggleQuote', 'Starting');\n debugSelection(textarea, 'Initial');\n \n const style = mergeWithDefaults(FORMATS.quote)\n \n // Use the reusable line operation helper\n const result = applyLineOperation(\n textarea,\n (ta) => multilineStyle(ta, style),\n { prefix: style.prefix }\n )\n \n debugResult(result);\n insertText(textarea, result)\n debugSelection(textarea, 'Final');\n}\n\n/**\n * Toggle task list formatting\n * Matches GitHub's implementation for task lists\n */\nexport function toggleTaskList(textarea) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n const style = mergeWithDefaults(FORMATS.taskList)\n \n // Use the reusable line operation helper\n const result = applyLineOperation(\n textarea,\n (ta) => multilineStyle(ta, style),\n { prefix: style.prefix }\n )\n \n insertText(textarea, result)\n}\n\n/**\n * Insert or toggle header with specific level\n */\nexport function insertHeader(textarea, level = 1, toggle = false) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n if (level < 1 || level > 6) level = 1\n \n debugLog('insertHeader', `============ START ============`);\n debugLog('insertHeader', `Level: ${level}, Toggle: ${toggle}`);\n debugLog('insertHeader', `Initial cursor: ${textarea.selectionStart}-${textarea.selectionEnd}`);\n \n const headerKey = `header${level === 1 ? '1' : level}`\n const style = mergeWithDefaults(FORMATS[headerKey] || FORMATS.header1)\n debugLog('insertHeader', `Style prefix: \"${style.prefix}\"`);\n \n // Save original positions and get line info BEFORE applyLineOperation\n const value = textarea.value\n const originalStart = textarea.selectionStart\n const originalEnd = textarea.selectionEnd\n \n // Find the current line boundaries to check existing header\n let lineStart = originalStart\n while (lineStart > 0 && value[lineStart - 1] !== '\\n') {\n lineStart--\n }\n let lineEnd = originalEnd\n while (lineEnd < value.length && value[lineEnd] !== '\\n') {\n lineEnd++\n }\n \n // Get current line and check for existing header\n const currentLineContent = value.slice(lineStart, lineEnd)\n debugLog('insertHeader', `Current line (before): \"${currentLineContent}\"`);\n \n const existingHeaderMatch = currentLineContent.match(/^(#{1,6})\\s*/)\n const existingLevel = existingHeaderMatch ? existingHeaderMatch[1].length : 0\n const existingPrefixLength = existingHeaderMatch ? existingHeaderMatch[0].length : 0\n \n debugLog('insertHeader', `Existing header check:`);\n debugLog('insertHeader', ` - Match: ${existingHeaderMatch ? `\"${existingHeaderMatch[0]}\"` : 'none'}`);\n debugLog('insertHeader', ` - Existing level: ${existingLevel}`);\n debugLog('insertHeader', ` - Existing prefix length: ${existingPrefixLength}`);\n debugLog('insertHeader', ` - Target level: ${level}`);\n \n // Determine if we're toggling off\n const shouldToggleOff = toggle && existingLevel === level\n debugLog('insertHeader', `Should toggle OFF: ${shouldToggleOff} (toggle=${toggle}, existingLevel=${existingLevel}, level=${level})`);\n \n // Use applyLineOperation for consistent behavior\n const result = applyLineOperation(\n textarea,\n (ta) => {\n const currentLine = ta.value.slice(ta.selectionStart, ta.selectionEnd)\n debugLog('insertHeader', `Line in operation: \"${currentLine}\"`);\n \n // Remove any existing header formatting\n const cleanedLine = currentLine.replace(/^#{1,6}\\s*/, '')\n debugLog('insertHeader', `Cleaned line: \"${cleanedLine}\"`);\n \n let newLine\n \n if (shouldToggleOff) {\n // Toggle off - just use the cleaned line\n debugLog('insertHeader', 'ACTION: Toggling OFF - removing header');\n newLine = cleanedLine\n } else if (existingLevel > 0) {\n // Replace existing header with new one\n debugLog('insertHeader', `ACTION: Replacing H${existingLevel} with H${level}`);\n newLine = style.prefix + cleanedLine\n } else {\n // Add new header\n debugLog('insertHeader', 'ACTION: Adding new header');\n newLine = style.prefix + cleanedLine\n }\n \n debugLog('insertHeader', `New line: \"${newLine}\"`);\n \n return {\n text: newLine,\n selectionStart: ta.selectionStart,\n selectionEnd: ta.selectionEnd\n }\n },\n {\n prefix: style.prefix,\n // Custom selection adjustment for headers\n adjustSelection: (isRemoving, selStart, selEnd, lineStartPos) => {\n debugLog('insertHeader', `Adjusting selection:`);\n debugLog('insertHeader', ` - isRemoving param: ${isRemoving}`);\n debugLog('insertHeader', ` - shouldToggleOff: ${shouldToggleOff}`);\n debugLog('insertHeader', ` - selStart: ${selStart}, selEnd: ${selEnd}`);\n debugLog('insertHeader', ` - lineStartPos: ${lineStartPos}`);\n \n if (shouldToggleOff) {\n // Removing the header entirely\n const adjustment = Math.max(selStart - existingPrefixLength, lineStartPos)\n debugLog('insertHeader', ` - Removing header, adjusting by -${existingPrefixLength}`);\n return {\n start: adjustment,\n end: selStart === selEnd ? adjustment : Math.max(selEnd - existingPrefixLength, lineStartPos)\n }\n } else if (existingPrefixLength > 0) {\n // Replacing existing header with new one\n const prefixDiff = style.prefix.length - existingPrefixLength\n debugLog('insertHeader', ` - Replacing header, adjusting by ${prefixDiff}`);\n return {\n start: selStart + prefixDiff,\n end: selEnd + prefixDiff\n }\n } else {\n // Adding new header\n debugLog('insertHeader', ` - Adding header, adjusting by +${style.prefix.length}`);\n return {\n start: selStart + style.prefix.length,\n end: selEnd + style.prefix.length\n }\n }\n }\n }\n )\n \n debugLog('insertHeader', `Final result: text=\"${result.text}\", cursor=${result.selectionStart}-${result.selectionEnd}`);\n debugLog('insertHeader', `============ END ============`);\n \n insertText(textarea, result)\n}\n\n/**\n * Toggle H1 header\n */\nexport function toggleH1(textarea) {\n insertHeader(textarea, 1, true)\n}\n\n/**\n * Toggle H2 header\n */\nexport function toggleH2(textarea) {\n insertHeader(textarea, 2, true)\n}\n\n/**\n * Toggle H3 header\n */\nexport function toggleH3(textarea) {\n insertHeader(textarea, 3, true)\n}\n\n/**\n * Get active formats at cursor position\n */\nexport function getActiveFormats(textarea) {\n return getActive(textarea)\n}\n\n/**\n * Check if format is active at cursor\n */\nexport function hasFormat(textarea, format) {\n return has(textarea, format)\n}\n\n/**\n * Expand selection based on options\n */\nexport function expandSelection(textarea, options = {}) {\n expand(textarea, options)\n}\n\n/**\n * Apply custom format\n */\nexport function applyCustomFormat(textarea, format) {\n if (!textarea || textarea.disabled || textarea.readOnly) return\n \n const style = mergeWithDefaults(format)\n let result\n \n if (style.multiline) {\n const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n if (isMultipleLines(selectedText)) {\n result = multilineStyle(textarea, style)\n } else {\n result = blockStyle(textarea, style)\n }\n } else {\n result = blockStyle(textarea, style)\n }\n \n insertText(textarea, result)\n}\n\n/**\n * Preserve selection during callback\n */\nexport { preserveSelection }\n\n/**\n * Configure undo method\n */\nexport { setUndoMethod }\n\n/**\n * Debug mode control\n */\nexport { setDebugMode, getDebugMode }\n\n/**\n * Default export with all functions\n */\nexport default {\n toggleBold,\n toggleItalic,\n toggleCode,\n insertLink,\n toggleBulletList,\n toggleNumberedList,\n toggleQuote,\n toggleTaskList,\n insertHeader,\n toggleH1,\n toggleH2,\n toggleH3,\n getActiveFormats,\n hasFormat,\n expandSelection,\n applyCustomFormat,\n preserveSelection,\n setUndoMethod,\n setDebugMode,\n getDebugMode\n}", "/**\n * Keyboard shortcuts handler for OverType editor\n * Uses the same handleAction method as toolbar for consistency\n */\n\nimport * as markdownActions from 'markdown-actions';\n\n/**\n * ShortcutsManager - Handles keyboard shortcuts for the editor\n */\nexport class ShortcutsManager {\n constructor(editor) {\n this.editor = editor;\n this.textarea = editor.textarea;\n // No need to add our own listener - OverType will call handleKeydown\n }\n\n /**\n * Handle keydown events - called by OverType\n * @param {KeyboardEvent} event - The keyboard event\n * @returns {boolean} Whether the event was handled\n */\n handleKeydown(event) {\n const isMac = navigator.platform.toLowerCase().includes('mac');\n const modKey = isMac ? event.metaKey : event.ctrlKey;\n\n if (!modKey) return false;\n\n let action = null;\n\n // Map keyboard shortcuts to toolbar actions\n switch(event.key.toLowerCase()) {\n case 'b':\n if (!event.shiftKey) {\n action = 'toggleBold';\n }\n break;\n\n case 'i':\n if (!event.shiftKey) {\n action = 'toggleItalic';\n }\n break;\n\n case 'k':\n if (!event.shiftKey) {\n action = 'insertLink';\n }\n break;\n\n case '7':\n if (event.shiftKey) {\n action = 'toggleNumberedList';\n }\n break;\n\n case '8':\n if (event.shiftKey) {\n action = 'toggleBulletList';\n }\n break;\n }\n\n // If we have an action, handle it exactly like the toolbar does\n if (action) {\n event.preventDefault();\n \n // If toolbar exists, use its handleAction method (exact same code path)\n if (this.editor.toolbar) {\n this.editor.toolbar.handleAction(action);\n } else {\n // Fallback: duplicate the toolbar's handleAction logic\n this.handleAction(action);\n }\n \n return true;\n }\n\n return false;\n }\n\n /**\n * Handle action - fallback when no toolbar exists\n * This duplicates toolbar.handleAction for consistency\n */\n async handleAction(action) {\n const textarea = this.textarea;\n if (!textarea) return;\n\n // Focus textarea\n textarea.focus();\n \n try {\n switch (action) {\n case 'toggleBold':\n markdownActions.toggleBold(textarea);\n break;\n case 'toggleItalic':\n markdownActions.toggleItalic(textarea);\n break;\n case 'insertLink':\n markdownActions.insertLink(textarea);\n break;\n case 'toggleBulletList':\n markdownActions.toggleBulletList(textarea);\n break;\n case 'toggleNumberedList':\n markdownActions.toggleNumberedList(textarea);\n break;\n }\n\n // Trigger input event to update preview\n textarea.dispatchEvent(new Event('input', { bubbles: true }));\n } catch (error) {\n console.error('Error in markdown action:', error);\n }\n }\n\n /**\n * Cleanup\n */\n destroy() {\n // Nothing to clean up since we don't add our own listener\n }\n}", "/**\n * Built-in themes for OverType editor\n * Each theme provides a complete color palette for the editor\n */\n\n/**\n * Solar theme - Light, warm and bright\n */\nexport const solar = {\n name: 'solar',\n colors: {\n bgPrimary: '#faf0ca', // Lemon Chiffon - main background\n bgSecondary: '#ffffff', // White - editor background\n text: '#0d3b66', // Yale Blue - main text\n h1: '#f95738', // Tomato - h1 headers\n h2: '#ee964b', // Sandy Brown - h2 headers \n h3: '#3d8a51', // Forest green - h3 headers\n strong: '#ee964b', // Sandy Brown - bold text\n em: '#f95738', // Tomato - italic text\n link: '#0d3b66', // Yale Blue - links\n code: '#0d3b66', // Yale Blue - inline code\n codeBg: 'rgba(244, 211, 94, 0.4)', // Naples Yellow with transparency\n blockquote: '#5a7a9b', // Muted blue - blockquotes\n hr: '#5a7a9b', // Muted blue - horizontal rules\n syntaxMarker: 'rgba(13, 59, 102, 0.52)', // Yale Blue with transparency\n cursor: '#f95738', // Tomato - cursor\n selection: 'rgba(244, 211, 94, 0.4)', // Naples Yellow with transparency\n listMarker: '#ee964b', // Sandy Brown - list markers\n // Toolbar colors\n toolbarBg: '#ffffff', // White - toolbar background\n toolbarBorder: 'rgba(13, 59, 102, 0.15)', // Yale Blue border\n toolbarIcon: '#0d3b66', // Yale Blue - icon color\n toolbarHover: '#f5f5f5', // Light gray - hover background\n toolbarActive: '#faf0ca', // Lemon Chiffon - active button background\n }\n};\n\n/**\n * Cave theme - Dark ocean depths\n */\nexport const cave = {\n name: 'cave',\n colors: {\n bgPrimary: '#141E26', // Deep ocean - main background\n bgSecondary: '#1D2D3E', // Darker charcoal - editor background\n text: '#c5dde8', // Light blue-gray - main text\n h1: '#d4a5ff', // Rich lavender - h1 headers\n h2: '#f6ae2d', // Hunyadi Yellow - h2 headers\n h3: '#9fcfec', // Brighter blue - h3 headers\n strong: '#f6ae2d', // Hunyadi Yellow - bold text\n em: '#9fcfec', // Brighter blue - italic text\n link: '#9fcfec', // Brighter blue - links\n code: '#c5dde8', // Light blue-gray - inline code\n codeBg: '#1a232b', // Very dark blue - code background\n blockquote: '#9fcfec', // Brighter blue - same as italic\n hr: '#c5dde8', // Light blue-gray - horizontal rules\n syntaxMarker: 'rgba(159, 207, 236, 0.73)', // Brighter blue semi-transparent\n cursor: '#f26419', // Orange Pantone - cursor\n selection: 'rgba(51, 101, 138, 0.4)', // Lapis Lazuli with transparency\n listMarker: '#f6ae2d', // Hunyadi Yellow - list markers\n // Toolbar colors for dark theme\n toolbarBg: '#1D2D3E', // Darker charcoal - toolbar background\n toolbarBorder: 'rgba(197, 221, 232, 0.1)', // Light blue-gray border\n toolbarIcon: '#c5dde8', // Light blue-gray - icon color\n toolbarHover: '#243546', // Slightly lighter charcoal - hover background\n toolbarActive: '#2a3f52', // Even lighter - active button background\n }\n};\n\n/**\n * Default themes registry\n */\nexport const themes = {\n solar,\n cave,\n // Aliases for backward compatibility\n light: solar,\n dark: cave\n};\n\n/**\n * Get theme by name or return custom theme object\n * @param {string|Object} theme - Theme name or custom theme object\n * @returns {Object} Theme configuration\n */\nexport function getTheme(theme) {\n if (typeof theme === 'string') {\n const themeObj = themes[theme] || themes.solar;\n // Preserve the requested theme name (important for 'light' and 'dark' aliases)\n return { ...themeObj, name: theme };\n }\n return theme;\n}\n\n/**\n * Apply theme colors to CSS variables\n * @param {Object} colors - Theme colors object\n * @returns {string} CSS custom properties string\n */\nexport function themeToCSSVars(colors) {\n const vars = [];\n for (const [key, value] of Object.entries(colors)) {\n // Convert camelCase to kebab-case\n const varName = key.replace(/([A-Z])/g, '-$1').toLowerCase();\n vars.push(`--${varName}: ${value};`);\n }\n return vars.join('\\n');\n}\n\n/**\n * Merge custom colors with base theme\n * @param {Object} baseTheme - Base theme object\n * @param {Object} customColors - Custom color overrides\n * @returns {Object} Merged theme object\n */\nexport function mergeTheme(baseTheme, customColors = {}) {\n return {\n ...baseTheme,\n colors: {\n ...baseTheme.colors,\n ...customColors\n }\n };\n}", "/**\n * CSS styles for OverType editor\n * Embedded in JavaScript to ensure single-file distribution\n */\n\nimport { themeToCSSVars } from './themes.js';\n\n/**\n * Generate the complete CSS for the editor\n * @param {Object} options - Configuration options\n * @returns {string} Complete CSS string\n */\nexport function generateStyles(options = {}) {\n const {\n fontSize = '14px',\n lineHeight = 1.6,\n fontFamily = \"'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace\",\n padding = '20px',\n theme = null,\n mobile = {}\n } = options;\n\n // Generate mobile overrides\n const mobileStyles = Object.keys(mobile).length > 0 ? `\n @media (max-width: 640px) {\n .overtype-wrapper .overtype-input,\n .overtype-wrapper .overtype-preview {\n ${Object.entries(mobile)\n .map(([prop, val]) => {\n const cssProp = prop.replace(/([A-Z])/g, '-$1').toLowerCase();\n return `${cssProp}: ${val} !important;`;\n })\n .join('\\n ')}\n }\n }\n ` : '';\n\n // Generate theme variables if provided\n const themeVars = theme && theme.colors ? themeToCSSVars(theme.colors) : '';\n\n return `\n /* OverType Editor Styles */\n .overtype-container {\n position: relative !important;\n width: 100% !important;\n height: 100% !important;\n ${themeVars ? `\n /* Theme Variables */\n ${themeVars}` : ''}\n }\n \n .overtype-wrapper {\n position: relative !important;\n width: 100% !important;\n height: 100% !important;\n overflow: hidden !important;\n background: var(--bg-secondary, #ffffff) !important;\n }\n\n /* Critical alignment styles - must be identical for both layers */\n .overtype-wrapper .overtype-input,\n .overtype-wrapper .overtype-preview {\n /* Positioning - must be identical */\n position: absolute !important;\n top: 0 !important;\n left: 0 !important;\n width: 100% !important;\n height: 100% !important;\n \n /* Font properties - any difference breaks alignment */\n font-family: ${fontFamily} !important;\n font-size: var(--instance-font-size, ${fontSize}) !important;\n line-height: var(--instance-line-height, ${lineHeight}) !important;\n font-weight: normal !important;\n font-style: normal !important;\n font-variant: normal !important;\n font-stretch: normal !important;\n font-kerning: none !important;\n font-feature-settings: normal !important;\n \n /* Box model - must match exactly */\n padding: var(--instance-padding, ${padding}) !important;\n margin: 0 !important;\n border: none !important;\n outline: none !important;\n box-sizing: border-box !important;\n \n /* Text layout - critical for character positioning */\n white-space: pre-wrap !important;\n word-wrap: break-word !important;\n word-break: normal !important;\n overflow-wrap: break-word !important;\n tab-size: 2 !important;\n -moz-tab-size: 2 !important;\n text-align: left !important;\n text-indent: 0 !important;\n letter-spacing: normal !important;\n word-spacing: normal !important;\n \n /* Text rendering */\n text-transform: none !important;\n text-rendering: auto !important;\n -webkit-font-smoothing: auto !important;\n -webkit-text-size-adjust: 100% !important;\n \n /* Direction and writing */\n direction: ltr !important;\n writing-mode: horizontal-tb !important;\n unicode-bidi: normal !important;\n text-orientation: mixed !important;\n \n /* Visual effects that could shift perception */\n text-shadow: none !important;\n filter: none !important;\n transform: none !important;\n zoom: 1 !important;\n \n /* Vertical alignment */\n vertical-align: baseline !important;\n \n /* Size constraints */\n min-width: 0 !important;\n min-height: 0 !important;\n max-width: none !important;\n max-height: none !important;\n \n /* Overflow */\n overflow-y: auto !important;\n overflow-x: auto !important;\n scrollbar-width: auto !important;\n scrollbar-gutter: auto !important;\n \n /* Animation/transition - disabled to prevent movement */\n animation: none !important;\n transition: none !important;\n }\n\n /* Input layer styles */\n .overtype-wrapper .overtype-input {\n /* Layer positioning */\n z-index: 1 !important;\n \n /* Text visibility */\n color: transparent !important;\n caret-color: var(--cursor, #f95738) !important;\n background-color: transparent !important;\n \n /* Textarea-specific */\n resize: none !important;\n appearance: none !important;\n -webkit-appearance: none !important;\n -moz-appearance: none !important;\n \n /* Prevent mobile zoom on focus */\n touch-action: manipulation !important;\n \n /* Disable autofill and spellcheck */\n autocomplete: off !important;\n autocorrect: off !important;\n autocapitalize: off !important;\n spellcheck: false !important;\n }\n\n .overtype-wrapper .overtype-input::selection {\n background-color: var(--selection, rgba(244, 211, 94, 0.4));\n }\n\n /* Preview layer styles */\n .overtype-wrapper .overtype-preview {\n /* Layer positioning */\n z-index: 0 !important;\n pointer-events: none !important;\n color: var(--text, #0d3b66) !important;\n background-color: transparent !important;\n \n /* Prevent text selection */\n user-select: none !important;\n -webkit-user-select: none !important;\n -moz-user-select: none !important;\n -ms-user-select: none !important;\n }\n\n /* Defensive styles for preview child divs */\n .overtype-wrapper .overtype-preview div {\n /* Reset any inherited styles */\n margin: 0 !important;\n padding: 0 !important;\n border: none !important;\n text-align: left !important;\n text-indent: 0 !important;\n display: block !important;\n position: static !important;\n transform: none !important;\n min-height: 0 !important;\n max-height: none !important;\n line-height: inherit !important;\n font-size: inherit !important;\n font-family: inherit !important;\n }\n\n /* Markdown element styling - NO SIZE CHANGES */\n .overtype-wrapper .overtype-preview .header {\n font-weight: bold !important;\n }\n\n /* Header colors */\n .overtype-wrapper .overtype-preview .h1 { \n color: var(--h1, #f95738) !important; \n }\n .overtype-wrapper .overtype-preview .h2 { \n color: var(--h2, #ee964b) !important; \n }\n .overtype-wrapper .overtype-preview .h3 { \n color: var(--h3, #3d8a51) !important; \n }\n\n /* Bold text */\n .overtype-wrapper .overtype-preview strong {\n color: var(--strong, #ee964b) !important;\n font-weight: bold !important;\n }\n\n /* Italic text */\n .overtype-wrapper .overtype-preview em {\n color: var(--em, #f95738) !important;\n text-decoration-color: var(--em, #f95738) !important;\n text-decoration-thickness: 1px !important;\n font-style: italic !important;\n }\n\n /* Inline code */\n .overtype-wrapper .overtype-preview code {\n background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;\n color: var(--code, #0d3b66) !important;\n padding: 0 !important;\n border-radius: 2px !important;\n font-family: inherit !important;\n font-weight: normal !important;\n }\n\n /* Code blocks */\n .overtype-wrapper .overtype-preview pre {\n background: #1e1e1e !important;\n padding: 0 !important;\n margin: 0 !important;\n border-radius: 4px !important;\n overflow-x: auto !important;\n }\n\n .overtype-wrapper .overtype-preview pre code {\n background: none !important;\n }\n\n /* Blockquotes */\n .overtype-wrapper .overtype-preview .blockquote {\n color: var(--blockquote, #5a7a9b) !important;\n padding: 0 !important;\n margin: 0 !important;\n border: none !important;\n }\n\n /* Links */\n .overtype-wrapper .overtype-preview a {\n color: var(--link, #0d3b66) !important;\n text-decoration: underline !important;\n font-weight: normal !important;\n }\n\n .overtype-wrapper .overtype-preview a:hover {\n text-decoration: underline !important;\n color: var(--link, #0d3b66) !important;\n }\n\n /* Lists - no list styling */\n .overtype-wrapper .overtype-preview ul,\n .overtype-wrapper .overtype-preview ol {\n list-style: none !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n\n .overtype-wrapper .overtype-preview li {\n margin: 0 !important;\n padding: 0 !important;\n list-style: none !important;\n }\n\n /* Horizontal rules */\n .overtype-wrapper .overtype-preview hr {\n border: none !important;\n color: var(--hr, #5a7a9b) !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n\n .overtype-wrapper .overtype-preview .hr-marker {\n color: var(--hr, #5a7a9b) !important;\n opacity: 0.6 !important;\n }\n\n /* Code fence markers - with background when not in code block */\n .overtype-wrapper .overtype-preview .code-fence {\n color: var(--code, #0d3b66) !important;\n background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;\n }\n \n /* Code block lines - background for entire code block */\n .overtype-wrapper .overtype-preview .code-block-line {\n background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;\n }\n \n /* Remove background from code fence when inside code block line */\n .overtype-wrapper .overtype-preview .code-block-line .code-fence {\n background: transparent !important;\n }\n\n /* Raw markdown line */\n .overtype-wrapper .overtype-preview .raw-line {\n color: var(--raw-line, #5a7a9b) !important;\n font-style: normal !important;\n font-weight: normal !important;\n }\n\n /* Syntax markers */\n .overtype-wrapper .overtype-preview .syntax-marker {\n color: var(--syntax-marker, rgba(13, 59, 102, 0.52)) !important;\n opacity: 0.7 !important;\n }\n\n /* List markers */\n .overtype-wrapper .overtype-preview .list-marker {\n color: var(--list-marker, #ee964b) !important;\n }\n\n /* Stats bar */\n .overtype-wrapper.with-stats {\n padding-bottom: 40px !important;\n }\n \n .overtype-wrapper .overtype-stats {\n position: absolute !important;\n bottom: 0 !important;\n left: 0 !important;\n right: 0 !important;\n height: 40px !important;\n padding: 0 20px !important;\n background: #f8f9fa !important;\n border-top: 1px solid #e0e0e0 !important;\n display: flex !important;\n justify-content: space-between !important;\n align-items: center !important;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;\n font-size: 0.85rem !important;\n color: #666 !important;\n z-index: 2 !important;\n }\n \n /* Dark theme stats bar */\n .overtype-wrapper[data-theme=\"cave\"] .overtype-stats {\n background: var(--bg-secondary, #1D2D3E) !important;\n border-top: 1px solid rgba(197, 221, 232, 0.1) !important;\n color: var(--text, #c5dde8) !important;\n }\n \n .overtype-wrapper .overtype-stats .overtype-stat {\n display: flex !important;\n align-items: center !important;\n gap: 5px !important;\n white-space: nowrap !important;\n }\n \n .overtype-wrapper .overtype-stats .live-dot {\n width: 8px !important;\n height: 8px !important;\n background: #4caf50 !important;\n border-radius: 50% !important;\n animation: pulse 2s infinite !important;\n }\n \n @keyframes pulse {\n 0%, 100% { opacity: 1; transform: scale(1); }\n 50% { opacity: 0.6; transform: scale(1.2); }\n }\n \n /* Adjust textarea and preview for stats bar */\n .overtype-wrapper.with-stats .overtype-input,\n .overtype-wrapper.with-stats .overtype-preview {\n height: calc(100% - 40px) !important;\n }\n\n /* Toolbar Styles */\n .overtype-toolbar {\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 8px;\n background: var(--toolbar-bg, var(--bg-primary, #f8f9fa));\n border: 1px solid var(--toolbar-border, var(--border, #e0e0e0));\n border-bottom: none;\n border-radius: 8px 8px 0 0;\n overflow-x: auto;\n -webkit-overflow-scrolling: touch;\n }\n\n .overtype-toolbar-button {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n padding: 0;\n border: none;\n border-radius: 6px;\n background: transparent;\n color: var(--toolbar-icon, var(--text-secondary, #666));\n cursor: pointer;\n transition: all 0.2s ease;\n flex-shrink: 0;\n }\n\n .overtype-toolbar-button svg {\n width: 20px;\n height: 20px;\n fill: currentColor;\n }\n \n /* Special sizing for code block icon */\n .overtype-toolbar-button[data-action=\"insertCodeBlock\"] svg {\n width: 22px;\n height: 18px;\n fill: transparent !important;\n }\n\n .overtype-toolbar-button:hover {\n background: var(--toolbar-hover, var(--bg-secondary, #e9ecef));\n color: var(--toolbar-icon, var(--text-primary, #333));\n }\n\n .overtype-toolbar-button:active {\n transform: scale(0.95);\n }\n\n .overtype-toolbar-button.active {\n background: var(--toolbar-active, var(--primary, #007bff));\n color: var(--toolbar-icon, var(--text-primary, #333));\n }\n\n .overtype-toolbar-button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .overtype-toolbar-separator {\n width: 1px;\n height: 24px;\n background: var(--border, #e0e0e0);\n margin: 0 4px;\n flex-shrink: 0;\n }\n\n /* Adjust wrapper when toolbar is present */\n .overtype-container .overtype-toolbar + .overtype-wrapper {\n border-radius: 0 0 8px 8px;\n border-top: none;\n }\n\n /* Mobile toolbar adjustments */\n @media (max-width: 640px) {\n .overtype-toolbar {\n padding: 6px;\n gap: 2px;\n }\n\n .overtype-toolbar-button {\n width: 36px;\n height: 36px;\n }\n\n .overtype-toolbar-separator {\n margin: 0 2px;\n }\n }\n\n ${mobileStyles}\n `;\n}", "/**\n * SVG icons for OverType toolbar\n * Quill-style icons with inline styles\n */\n\nexport const boldIcon = `<svg viewBox=\"0 0 18 18\">\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z\"></path>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z\"></path>\n</svg>`;\n\nexport const italicIcon = `<svg viewBox=\"0 0 18 18\">\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"7\" x2=\"13\" y1=\"4\" y2=\"4\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"5\" x2=\"11\" y1=\"14\" y2=\"14\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"8\" x2=\"10\" y1=\"14\" y2=\"4\"></line>\n</svg>`;\n\nexport const h1Icon = `<svg viewBox=\"0 0 18 18\">\n <path fill=\"currentColor\" d=\"M10,4V14a1,1,0,0,1-2,0V10H3v4a1,1,0,0,1-2,0V4A1,1,0,0,1,3,4V8H8V4a1,1,0,0,1,2,0Zm6.06787,9.209H14.98975V7.59863a.54085.54085,0,0,0-.605-.60547h-.62744a1.01119,1.01119,0,0,0-.748.29688L11.645,8.56641a.5435.5435,0,0,0-.022.8584l.28613.30762a.53861.53861,0,0,0,.84717.0332l.09912-.08789a1.2137,1.2137,0,0,0,.2417-.35254h.02246s-.01123.30859-.01123.60547V13.209H12.041a.54085.54085,0,0,0-.605.60547v.43945a.54085.54085,0,0,0,.605.60547h4.02686a.54085.54085,0,0,0,.605-.60547v-.43945A.54085.54085,0,0,0,16.06787,13.209Z\"></path>\n</svg>`;\n\nexport const h2Icon = `<svg viewBox=\"0 0 18 18\">\n <path fill=\"currentColor\" d=\"M16.73975,13.81445v.43945a.54085.54085,0,0,1-.605.60547H11.855a.58392.58392,0,0,1-.64893-.60547V14.0127c0-2.90527,3.39941-3.42187,3.39941-4.55469a.77675.77675,0,0,0-.84717-.78125,1.17684,1.17684,0,0,0-.83594.38477c-.2749.26367-.561.374-.85791.13184l-.4292-.34082c-.30811-.24219-.38525-.51758-.1543-.81445a2.97155,2.97155,0,0,1,2.45361-1.17676,2.45393,2.45393,0,0,1,2.68408,2.40918c0,2.45312-3.1792,2.92676-3.27832,3.93848h2.79443A.54085.54085,0,0,1,16.73975,13.81445ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z\"></path>\n</svg>`;\n\nexport const h3Icon = `<svg viewBox=\"0 0 18 18\">\n <path fill=\"currentColor\" d=\"M16.65186,12.30664a2.6742,2.6742,0,0,1-2.915,2.68457,3.96592,3.96592,0,0,1-2.25537-.6709.56007.56007,0,0,1-.13232-.83594L11.64648,13c.209-.34082.48389-.36328.82471-.1543a2.32654,2.32654,0,0,0,1.12256.33008c.71484,0,1.12207-.35156,1.12207-.78125,0-.61523-.61621-.86816-1.46338-.86816H13.2085a.65159.65159,0,0,1-.68213-.41895l-.05518-.10937a.67114.67114,0,0,1,.14307-.78125l.71533-.86914a8.55289,8.55289,0,0,1,.68213-.7373V8.58887a3.93913,3.93913,0,0,1-.748.05469H11.9873a.54085.54085,0,0,1-.605-.60547V7.59863a.54085.54085,0,0,1,.605-.60547h3.75146a.53773.53773,0,0,1,.60547.59375v.17676a1.03723,1.03723,0,0,1-.27539.748L14.74854,10.0293A2.31132,2.31132,0,0,1,16.65186,12.30664ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z\"></path>\n</svg>`;\n\nexport const linkIcon = `<svg viewBox=\"0 0 18 18\">\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"7\" x2=\"11\" y1=\"7\" y2=\"11\"></line>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z\"></path>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z\"></path>\n</svg>`;\n\nexport const codeIcon = `<svg viewBox=\"0 0 18 18\">\n <polyline stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" points=\"5 7 3 9 5 11\"></polyline>\n <polyline stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" points=\"13 7 15 9 13 11\"></polyline>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"10\" x2=\"8\" y1=\"5\" y2=\"13\"></line>\n</svg>`;\n\nexport const codeBlockIcon = `<svg viewBox=\"0 0 46 33\" fill=\"transparent\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M35 8h3a5 5 0 0 1 5 5v12a5 5 0 0 1-5 5H18a5 5 0 0 1-5-5v-2\" stroke=\"currentColor\" stroke-width=\"4\" stroke-linecap=\"round\"></path>\n <path d=\"m9 2.5-6 6L9 14M20 2.5l6 6-6 5.5\" stroke=\"currentColor\" stroke-width=\"4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path>\n</svg>`;\n\nexport const bulletListIcon = `<svg viewBox=\"0 0 18 18\">\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"6\" x2=\"15\" y1=\"4\" y2=\"4\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"6\" x2=\"15\" y1=\"9\" y2=\"9\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"6\" x2=\"15\" y1=\"14\" y2=\"14\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"3\" x2=\"3\" y1=\"4\" y2=\"4\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"3\" x2=\"3\" y1=\"9\" y2=\"9\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"3\" x2=\"3\" y1=\"14\" y2=\"14\"></line>\n</svg>`;\n\nexport const orderedListIcon = `<svg viewBox=\"0 0 18 18\">\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"7\" x2=\"15\" y1=\"4\" y2=\"4\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"7\" x2=\"15\" y1=\"9\" y2=\"9\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"7\" x2=\"15\" y1=\"14\" y2=\"14\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1\" x1=\"2.5\" x2=\"4.5\" y1=\"5.5\" y2=\"5.5\"></line>\n <path fill=\"currentColor\" d=\"M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z\"></path>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1\" d=\"M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156\"></path>\n <path stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1\" d=\"M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109\"></path>\n</svg>`;\n\nexport const quoteIcon = `<svg viewBox=\"2 2 20 20\">\n <path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M10 10.8182L9 10.8182C8.80222 10.8182 8.60888 10.7649 8.44443 10.665C8.27998 10.5651 8.15181 10.4231 8.07612 10.257C8.00043 10.0909 7.98063 9.90808 8.01922 9.73174C8.0578 9.55539 8.15304 9.39341 8.29289 9.26627C8.43275 9.13913 8.61093 9.05255 8.80491 9.01747C8.99889 8.98239 9.19996 9.00039 9.38268 9.0692C9.56541 9.13801 9.72159 9.25453 9.83147 9.40403C9.94135 9.55353 10 9.72929 10 9.90909L10 12.1818C10 12.664 9.78929 13.1265 9.41421 13.4675C9.03914 13.8084 8.53043 14 8 14\"></path>\n <path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M16 10.8182L15 10.8182C14.8022 10.8182 14.6089 10.7649 14.4444 10.665C14.28 10.5651 14.1518 10.4231 14.0761 10.257C14.0004 10.0909 13.9806 9.90808 14.0192 9.73174C14.0578 9.55539 14.153 9.39341 14.2929 9.26627C14.4327 9.13913 14.6109 9.05255 14.8049 9.01747C14.9989 8.98239 15.2 9.00039 15.3827 9.0692C15.5654 9.13801 15.7216 9.25453 15.8315 9.40403C15.9414 9.55353 16 9.72929 16 9.90909L16 12.1818C16 12.664 15.7893 13.1265 15.4142 13.4675C15.0391 13.8084 14.5304 14 14 14\"></path>\n</svg>`;\n\nexport const taskListIcon = `<svg viewBox=\"0 0 18 18\">\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"8\" x2=\"16\" y1=\"4\" y2=\"4\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"8\" x2=\"16\" y1=\"9\" y2=\"9\"></line>\n <line stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" x1=\"8\" x2=\"16\" y1=\"14\" y2=\"14\"></line>\n <rect stroke=\"currentColor\" fill=\"none\" stroke-width=\"1.5\" x=\"2\" y=\"3\" width=\"3\" height=\"3\" rx=\"0.5\"></rect>\n <rect stroke=\"currentColor\" fill=\"none\" stroke-width=\"1.5\" x=\"2\" y=\"13\" width=\"3\" height=\"3\" rx=\"0.5\"></rect>\n <polyline stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" points=\"2.65 9.5 3.5 10.5 5 8.5\"></polyline>\n</svg>`;", "/**\n * Toolbar component for OverType editor\n * Provides markdown formatting buttons with icons\n */\n\nimport * as icons from './icons.js';\nimport * as markdownActions from 'markdown-actions';\n\nexport class Toolbar {\n constructor(editor) {\n this.editor = editor;\n this.container = null;\n this.buttons = {};\n }\n\n /**\n * Create and attach toolbar to editor\n */\n create() {\n // Create toolbar container\n this.container = document.createElement('div');\n this.container.className = 'overtype-toolbar';\n this.container.setAttribute('role', 'toolbar');\n this.container.setAttribute('aria-label', 'Text formatting');\n\n // Define toolbar buttons\n const buttonConfig = [\n { name: 'bold', icon: icons.boldIcon, title: 'Bold (Ctrl+B)', action: 'toggleBold' },\n { name: 'italic', icon: icons.italicIcon, title: 'Italic (Ctrl+I)', action: 'toggleItalic' },\n { separator: true },\n { name: 'h1', icon: icons.h1Icon, title: 'Heading 1', action: 'insertH1' },\n { name: 'h2', icon: icons.h2Icon, title: 'Heading 2', action: 'insertH2' },\n { name: 'h3', icon: icons.h3Icon, title: 'Heading 3', action: 'insertH3' },\n { separator: true },\n { name: 'link', icon: icons.linkIcon, title: 'Insert Link (Ctrl+K)', action: 'insertLink' },\n { name: 'code', icon: icons.codeIcon, title: 'Inline Code', action: 'toggleCode' },\n { name: 'codeBlock', icon: icons.codeBlockIcon, title: 'Code Block', action: 'insertCodeBlock' },\n { separator: true },\n { name: 'quote', icon: icons.quoteIcon, title: 'Quote', action: 'toggleQuote' },\n { separator: true },\n { name: 'bulletList', icon: icons.bulletListIcon, title: 'Bullet List', action: 'toggleBulletList' },\n { name: 'orderedList', icon: icons.orderedListIcon, title: 'Numbered List', action: 'toggleNumberedList' },\n { name: 'taskList', icon: icons.taskListIcon, title: 'Task List', action: 'toggleTaskList' }\n ];\n\n // Create buttons\n buttonConfig.forEach(config => {\n if (config.separator) {\n const separator = document.createElement('div');\n separator.className = 'overtype-toolbar-separator';\n separator.setAttribute('role', 'separator');\n this.container.appendChild(separator);\n } else {\n const button = this.createButton(config);\n this.buttons[config.name] = button;\n this.container.appendChild(button);\n }\n });\n\n // Insert toolbar into container before editor wrapper\n const container = this.editor.element.querySelector('.overtype-container');\n const wrapper = this.editor.element.querySelector('.overtype-wrapper');\n if (container && wrapper) {\n container.insertBefore(this.container, wrapper);\n }\n\n return this.container;\n }\n\n /**\n * Create individual toolbar button\n */\n createButton(config) {\n const button = document.createElement('button');\n button.className = 'overtype-toolbar-button';\n button.type = 'button';\n button.title = config.title;\n button.setAttribute('aria-label', config.title);\n button.setAttribute('data-action', config.action);\n button.innerHTML = config.icon;\n\n // Add click handler\n button.addEventListener('click', (e) => {\n e.preventDefault();\n this.handleAction(config.action);\n });\n\n return button;\n }\n\n /**\n * Handle toolbar button actions\n */\n async handleAction(action) {\n const textarea = this.editor.textarea;\n if (!textarea) return;\n\n // Focus textarea\n textarea.focus();\n\n try {\n \n switch (action) {\n case 'toggleBold':\n markdownActions.toggleBold(textarea);\n break;\n case 'toggleItalic':\n markdownActions.toggleItalic(textarea);\n break;\n case 'insertH1':\n markdownActions.toggleH1(textarea);\n break;\n case 'insertH2':\n markdownActions.toggleH2(textarea);\n break;\n case 'insertH3':\n markdownActions.toggleH3(textarea);\n break;\n case 'insertLink':\n markdownActions.insertLink(textarea);\n break;\n case 'toggleCode':\n markdownActions.toggleCode(textarea);\n break;\n case 'insertCodeBlock':\n // For code blocks, we'll insert the markdown directly\n const start = textarea.selectionStart;\n const end = textarea.selectionEnd;\n const selectedText = textarea.value.slice(start, end);\n const codeBlock = '```\\n' + selectedText + '\\n```';\n textarea.setRangeText(codeBlock, start, end, 'end');\n break;\n case 'toggleBulletList':\n markdownActions.toggleBulletList(textarea);\n break;\n case 'toggleNumberedList':\n markdownActions.toggleNumberedList(textarea);\n break;\n case 'toggleQuote':\n markdownActions.toggleQuote(textarea);\n break;\n case 'toggleTaskList':\n markdownActions.toggleTaskList(textarea);\n break;\n }\n\n // Trigger input event to update preview\n textarea.dispatchEvent(new Event('input', { bubbles: true }));\n } catch (error) {\n console.error('Error loading markdown-actions:', error);\n }\n }\n\n /**\n * Update toolbar button states based on current selection\n */\n async updateButtonStates() {\n const textarea = this.editor.textarea;\n if (!textarea) return;\n\n try {\n const activeFormats = markdownActions.getActiveFormats(textarea);\n\n // Update button states\n Object.entries(this.buttons).forEach(([name, button]) => {\n let isActive = false;\n \n switch (name) {\n case 'bold':\n isActive = activeFormats.includes('bold');\n break;\n case 'italic':\n isActive = activeFormats.includes('italic');\n break;\n case 'code':\n // Disabled: code detection is unreliable in code blocks\n // isActive = activeFormats.includes('code');\n isActive = false;\n break;\n case 'bulletList':\n isActive = activeFormats.includes('bullet-list');\n break;\n case 'orderedList':\n isActive = activeFormats.includes('numbered-list');\n break;\n case 'quote':\n isActive = activeFormats.includes('quote');\n break;\n case 'taskList':\n isActive = activeFormats.includes('task-list');\n break;\n case 'h1':\n isActive = activeFormats.includes('header');\n break;\n case 'h2':\n isActive = activeFormats.includes('header-2');\n break;\n case 'h3':\n isActive = activeFormats.includes('header-3');\n break;\n }\n\n button.classList.toggle('active', isActive);\n button.setAttribute('aria-pressed', isActive.toString());\n });\n } catch (error) {\n // Silently fail if markdown-actions not available\n }\n }\n\n /**\n * Destroy toolbar\n */\n destroy() {\n if (this.container) {\n this.container.remove();\n this.container = null;\n this.buttons = {};\n }\n }\n}", "/**\n * OverType - A lightweight markdown editor library with perfect WYSIWYG alignment\n * @version 1.0.0\n * @license MIT\n */\n\nimport { MarkdownParser } from './parser.js';\nimport { ShortcutsManager } from './shortcuts.js';\nimport { generateStyles } from './styles.js';\nimport { getTheme, mergeTheme, solar } from './themes.js';\nimport { Toolbar } from './toolbar.js';\n\n/**\n * OverType Editor Class\n */\nclass OverType {\n // Static properties\n static instances = new WeakMap();\n static stylesInjected = false;\n static globalListenersInitialized = false;\n static instanceCount = 0;\n\n /**\n * Constructor - Always returns an array of instances\n * @param {string|Element|NodeList|Array} target - Target element(s)\n * @param {Object} options - Configuration options\n * @returns {Array} Array of OverType instances\n */\n constructor(target, options = {}) {\n // Convert target to array of elements\n let elements;\n \n if (typeof target === 'string') {\n elements = document.querySelectorAll(target);\n if (elements.length === 0) {\n throw new Error(`No elements found for selector: ${target}`);\n }\n elements = Array.from(elements);\n } else if (target instanceof Element) {\n elements = [target];\n } else if (target instanceof NodeList) {\n elements = Array.from(target);\n } else if (Array.isArray(target)) {\n elements = target;\n } else {\n throw new Error('Invalid target: must be selector string, Element, NodeList, or Array');\n }\n\n // Initialize all elements and return array\n const instances = elements.map(element => {\n // Check for existing instance\n if (element.overTypeInstance) {\n // Re-init existing instance\n element.overTypeInstance.reinit(options);\n return element.overTypeInstance;\n }\n\n // Create new instance\n const instance = Object.create(OverType.prototype);\n instance._init(element, options);\n element.overTypeInstance = instance;\n OverType.instances.set(element, instance);\n return instance;\n });\n\n return instances;\n }\n\n /**\n * Internal initialization\n * @private\n */\n _init(element, options = {}) {\n this.element = element;\n this.options = this._mergeOptions(options);\n this.instanceId = ++OverType.instanceCount;\n this.initialized = false;\n\n // Inject styles if needed\n OverType.injectStyles();\n\n // Initialize global listeners\n OverType.initGlobalListeners();\n\n // Check for existing OverType DOM structure\n const container = element.querySelector('.overtype-container');\n const wrapper = element.querySelector('.overtype-wrapper');\n if (container || wrapper) {\n this._recoverFromDOM(container, wrapper);\n } else {\n this._buildFromScratch();\n }\n\n // Setup shortcuts manager\n this.shortcuts = new ShortcutsManager(this);\n\n // Setup toolbar if enabled\n if (this.options.toolbar) {\n this.toolbar = new Toolbar(this);\n this.toolbar.create();\n \n // Update toolbar states on selection change\n this.textarea.addEventListener('selectionchange', () => {\n this.toolbar.updateButtonStates();\n });\n this.textarea.addEventListener('input', () => {\n this.toolbar.updateButtonStates();\n });\n }\n\n // Mark as initialized\n this.initialized = true;\n\n // Call onChange if provided\n if (this.options.onChange) {\n this.options.onChange(this.getValue(), this);\n }\n }\n\n /**\n * Merge user options with defaults\n * @private\n */\n _mergeOptions(options) {\n const defaults = {\n // Typography\n fontSize: '14px',\n lineHeight: 1.6,\n fontFamily: \"'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace\",\n padding: '16px',\n \n // Mobile styles\n mobile: {\n fontSize: '16px', // Prevent zoom on iOS\n padding: '12px',\n lineHeight: 1.5\n },\n \n // Behavior\n autofocus: false,\n placeholder: 'Start typing...',\n value: '',\n \n // Callbacks\n onChange: null,\n onKeydown: null,\n \n // Features\n showActiveLineRaw: false,\n showStats: false,\n toolbar: false,\n statsFormatter: null\n };\n \n // Remove theme and colors from options - these are now global\n const { theme, colors, ...cleanOptions } = options;\n \n return {\n ...defaults,\n ...cleanOptions\n };\n }\n\n /**\n * Recover from existing DOM structure\n * @private\n */\n _recoverFromDOM(container, wrapper) {\n // Handle old structure (wrapper only) or new structure (container + wrapper)\n if (container && container.classList.contains('overtype-container')) {\n this.container = container;\n this.wrapper = container.querySelector('.overtype-wrapper');\n } else if (wrapper) {\n // Old structure - just wrapper, no container\n this.wrapper = wrapper;\n // Wrap it in a container for consistency\n this.container = document.createElement('div');\n this.container.className = 'overtype-container';\n const currentTheme = OverType.currentTheme || solar;\n const themeName = typeof currentTheme === 'string' ? currentTheme : currentTheme.name;\n if (themeName) {\n this.container.setAttribute('data-theme', themeName);\n }\n wrapper.parentNode.insertBefore(this.container, wrapper);\n this.container.appendChild(wrapper);\n }\n \n if (!this.wrapper) {\n // No valid structure found\n if (container) container.remove();\n if (wrapper) wrapper.remove();\n this._buildFromScratch();\n return;\n }\n \n this.textarea = this.wrapper.querySelector('.overtype-input');\n this.preview = this.wrapper.querySelector('.overtype-preview');\n\n if (!this.textarea || !this.preview) {\n // Partial DOM - clear and rebuild\n this.container.remove();\n this._buildFromScratch();\n return;\n }\n\n // Store reference on wrapper\n this.wrapper._instance = this;\n \n // Apply instance-specific styles via CSS custom properties\n if (this.options.fontSize) {\n this.wrapper.style.setProperty('--instance-font-size', this.options.fontSize);\n }\n if (this.options.lineHeight) {\n this.wrapper.style.setProperty('--instance-line-height', String(this.options.lineHeight));\n }\n if (this.options.padding) {\n this.wrapper.style.setProperty('--instance-padding', this.options.padding);\n }\n\n // Disable autofill, spellcheck, and extensions\n this._configureTextarea();\n\n // Apply any new options\n this._applyOptions();\n }\n\n /**\n * Build editor from scratch\n * @private\n */\n _buildFromScratch() {\n // Extract any existing content\n const content = this._extractContent();\n\n // Clear element\n this.element.innerHTML = '';\n\n // Create DOM structure\n this._createDOM();\n\n // Set initial content\n if (content || this.options.value) {\n this.setValue(content || this.options.value);\n }\n\n // Apply options\n this._applyOptions();\n }\n\n /**\n * Extract content from element\n * @private\n */\n _extractContent() {\n // Look for existing OverType textarea\n const textarea = this.element.querySelector('.overtype-input');\n if (textarea) return textarea.value;\n\n // Use element's text content as fallback\n return this.element.textContent || '';\n }\n\n /**\n * Create DOM structure\n * @private\n */\n _createDOM() {\n // Create container that will hold toolbar and editor\n this.container = document.createElement('div');\n this.container.className = 'overtype-container';\n \n // Set current global theme on container\n const currentTheme = OverType.currentTheme || solar;\n const themeName = typeof currentTheme === 'string' ? currentTheme : currentTheme.name;\n if (themeName) {\n this.container.setAttribute('data-theme', themeName);\n }\n \n // Create wrapper for editor\n this.wrapper = document.createElement('div');\n this.wrapper.className = 'overtype-wrapper';\n \n // Add stats wrapper class if stats are enabled\n if (this.options.showStats) {\n this.wrapper.classList.add('with-stats');\n }\n \n // Apply instance-specific styles via CSS custom properties\n if (this.options.fontSize) {\n this.wrapper.style.setProperty('--instance-font-size', this.options.fontSize);\n }\n if (this.options.lineHeight) {\n this.wrapper.style.setProperty('--instance-line-height', String(this.options.lineHeight));\n }\n if (this.options.padding) {\n this.wrapper.style.setProperty('--instance-padding', this.options.padding);\n }\n \n this.wrapper._instance = this;\n\n // Create textarea\n this.textarea = document.createElement('textarea');\n this.textarea.className = 'overtype-input';\n this.textarea.placeholder = this.options.placeholder;\n this._configureTextarea();\n\n // Create preview div\n this.preview = document.createElement('div');\n this.preview.className = 'overtype-preview';\n this.preview.setAttribute('aria-hidden', 'true');\n\n // Assemble DOM\n this.wrapper.appendChild(this.textarea);\n this.wrapper.appendChild(this.preview);\n \n // Add stats bar if enabled\n if (this.options.showStats) {\n this.statsBar = document.createElement('div');\n this.statsBar.className = 'overtype-stats';\n this.wrapper.appendChild(this.statsBar);\n this._updateStats();\n }\n \n // Add wrapper to container\n this.container.appendChild(this.wrapper);\n \n // Add container to element\n this.element.appendChild(this.container);\n }\n\n /**\n * Configure textarea attributes\n * @private\n */\n _configureTextarea() {\n this.textarea.setAttribute('autocomplete', 'off');\n this.textarea.setAttribute('autocorrect', 'off');\n this.textarea.setAttribute('autocapitalize', 'off');\n this.textarea.setAttribute('spellcheck', 'false');\n this.textarea.setAttribute('data-gramm', 'false');\n this.textarea.setAttribute('data-gramm_editor', 'false');\n this.textarea.setAttribute('data-enable-grammarly', 'false');\n }\n\n /**\n * Apply options to the editor\n * @private\n */\n _applyOptions() {\n // Apply autofocus\n if (this.options.autofocus) {\n this.textarea.focus();\n }\n\n // Update preview with initial content\n this.updatePreview();\n }\n\n /**\n * Update preview with parsed markdown\n */\n updatePreview() {\n const text = this.textarea.value;\n const cursorPos = this.textarea.selectionStart;\n const activeLine = this._getCurrentLine(text, cursorPos);\n \n // Parse markdown\n const html = MarkdownParser.parse(text, activeLine, this.options.showActiveLineRaw);\n this.preview.innerHTML = html || '<span style=\"color: #808080;\">Start typing...</span>';\n \n // Apply code block backgrounds\n this._applyCodeBlockBackgrounds();\n \n // Update stats if enabled\n if (this.options.showStats && this.statsBar) {\n this._updateStats();\n }\n \n // Trigger onChange callback\n if (this.options.onChange && this.initialized) {\n this.options.onChange(text, this);\n }\n }\n\n /**\n * Apply background styling to code blocks\n * @private\n */\n _applyCodeBlockBackgrounds() {\n // Find all code fence elements\n const codeFences = this.preview.querySelectorAll('.code-fence');\n \n // Process pairs of code fences\n for (let i = 0; i < codeFences.length - 1; i += 2) {\n const openFence = codeFences[i];\n const closeFence = codeFences[i + 1];\n \n // Get parent divs\n const openParent = openFence.parentElement;\n const closeParent = closeFence.parentElement;\n \n if (!openParent || !closeParent) continue;\n \n // Make fences display: block\n openFence.style.display = 'block';\n closeFence.style.display = 'block';\n \n // Apply class to parent divs\n openParent.classList.add('code-block-line');\n closeParent.classList.add('code-block-line');\n \n // Apply class to all divs between the parent divs\n let currentDiv = openParent.nextElementSibling;\n while (currentDiv && currentDiv !== closeParent) {\n // Apply class to divs between the fences\n if (currentDiv.tagName === 'DIV') {\n currentDiv.classList.add('code-block-line');\n }\n \n // Move to next sibling\n currentDiv = currentDiv.nextElementSibling;\n \n // Safety check to prevent infinite loop\n if (!currentDiv) break;\n }\n }\n }\n\n /**\n * Get current line number from cursor position\n * @private\n */\n _getCurrentLine(text, cursorPos) {\n const lines = text.substring(0, cursorPos).split('\\n');\n return lines.length - 1;\n }\n\n /**\n * Handle input events\n * @private\n */\n handleInput(event) {\n this.updatePreview();\n }\n\n /**\n * Handle keydown events\n * @private\n */\n handleKeydown(event) {\n // Let shortcuts manager handle it first\n const handled = this.shortcuts.handleKeydown(event);\n \n // Call user callback if provided\n if (!handled && this.options.onKeydown) {\n this.options.onKeydown(event, this);\n }\n }\n\n /**\n * Handle scroll events\n * @private\n */\n handleScroll(event) {\n // Sync preview scroll with textarea\n this.preview.scrollTop = this.textarea.scrollTop;\n this.preview.scrollLeft = this.textarea.scrollLeft;\n }\n\n /**\n * Get editor content\n * @returns {string} Current markdown content\n */\n getValue() {\n return this.textarea.value;\n }\n\n /**\n * Set editor content\n * @param {string} value - Markdown content to set\n */\n setValue(value) {\n this.textarea.value = value;\n this.updatePreview();\n }\n\n\n /**\n * Focus the editor\n */\n focus() {\n this.textarea.focus();\n }\n\n /**\n * Blur the editor\n */\n blur() {\n this.textarea.blur();\n }\n\n /**\n * Check if editor is initialized\n * @returns {boolean}\n */\n isInitialized() {\n return this.initialized;\n }\n\n /**\n * Re-initialize with new options\n * @param {Object} options - New options to apply\n */\n reinit(options = {}) {\n this.options = this._mergeOptions({ ...this.options, ...options });\n this._applyOptions();\n this.updatePreview();\n }\n\n /**\n * Update stats bar\n * @private\n */\n _updateStats() {\n if (!this.statsBar) return;\n \n const value = this.textarea.value;\n const lines = value.split('\\n');\n const chars = value.length;\n const words = value.split(/\\s+/).filter(w => w.length > 0).length;\n \n // Calculate line and column\n const selectionStart = this.textarea.selectionStart;\n const beforeCursor = value.substring(0, selectionStart);\n const linesBeforeCursor = beforeCursor.split('\\n');\n const currentLine = linesBeforeCursor.length;\n const currentColumn = linesBeforeCursor[linesBeforeCursor.length - 1].length + 1;\n \n // Use custom formatter if provided\n if (this.options.statsFormatter) {\n this.statsBar.innerHTML = this.options.statsFormatter({\n chars,\n words,\n lines: lines.length,\n line: currentLine,\n column: currentColumn\n });\n } else {\n // Default format with live dot\n this.statsBar.innerHTML = `\n <div class=\"overtype-stat\">\n <span class=\"live-dot\"></span>\n <span>${chars} chars, ${words} words, ${lines.length} lines</span>\n </div>\n <div class=\"overtype-stat\">Line ${currentLine}, Col ${currentColumn}</div>\n `;\n }\n }\n \n /**\n * Show or hide stats bar\n * @param {boolean} show - Whether to show stats\n */\n showStats(show) {\n this.options.showStats = show;\n \n if (show && !this.statsBar) {\n // Create stats bar\n this.statsBar = document.createElement('div');\n this.statsBar.className = 'overtype-stats';\n this.wrapper.appendChild(this.statsBar);\n this.wrapper.classList.add('with-stats');\n this._updateStats();\n } else if (!show && this.statsBar) {\n // Remove stats bar\n this.statsBar.remove();\n this.statsBar = null;\n this.wrapper.classList.remove('with-stats');\n }\n }\n\n /**\n * Destroy the editor instance\n */\n destroy() {\n // Remove instance reference\n this.element.overTypeInstance = null;\n OverType.instances.delete(this.element);\n\n // Cleanup shortcuts\n if (this.shortcuts) {\n this.shortcuts.destroy();\n }\n\n // Remove DOM if created by us\n if (this.wrapper) {\n const content = this.getValue();\n this.wrapper.remove();\n \n // Restore original content\n this.element.textContent = content;\n }\n\n this.initialized = false;\n }\n\n // ===== Static Methods =====\n\n /**\n * Initialize multiple editors (static convenience method)\n * @param {string|Element|NodeList|Array} target - Target element(s)\n * @param {Object} options - Configuration options\n * @returns {Array} Array of OverType instances\n */\n static init(target, options = {}) {\n return new OverType(target, options);\n }\n\n /**\n * Get instance from element\n * @param {Element} element - DOM element\n * @returns {OverType|null} OverType instance or null\n */\n static getInstance(element) {\n return element.overTypeInstance || OverType.instances.get(element) || null;\n }\n\n /**\n * Destroy all instances\n */\n static destroyAll() {\n const elements = document.querySelectorAll('[data-overtype-instance]');\n elements.forEach(element => {\n const instance = OverType.getInstance(element);\n if (instance) {\n instance.destroy();\n }\n });\n }\n\n /**\n * Inject styles into the document\n * @param {boolean} force - Force re-injection\n */\n static injectStyles(force = false) {\n if (OverType.stylesInjected && !force) return;\n\n // Remove any existing OverType styles\n const existing = document.querySelector('style.overtype-styles');\n if (existing) {\n existing.remove();\n }\n\n // Generate and inject new styles with current theme\n const theme = OverType.currentTheme || solar;\n const styles = generateStyles({ theme });\n const styleEl = document.createElement('style');\n styleEl.className = 'overtype-styles';\n styleEl.textContent = styles;\n document.head.appendChild(styleEl);\n\n OverType.stylesInjected = true;\n }\n \n /**\n * Set global theme for all OverType instances\n * @param {string|Object} theme - Theme name or custom theme object\n * @param {Object} customColors - Optional color overrides\n */\n static setTheme(theme, customColors = null) {\n // Process theme\n let themeObj = typeof theme === 'string' ? getTheme(theme) : theme;\n \n // Apply custom colors if provided\n if (customColors) {\n themeObj = mergeTheme(themeObj, customColors);\n }\n \n // Store as current theme\n OverType.currentTheme = themeObj;\n \n // Re-inject styles with new theme\n OverType.injectStyles(true);\n \n // Update all existing instances - update container theme attribute\n document.querySelectorAll('.overtype-container').forEach(container => {\n const themeName = typeof themeObj === 'string' ? themeObj : themeObj.name;\n if (themeName) {\n container.setAttribute('data-theme', themeName);\n }\n });\n \n // Also handle any old-style wrappers without containers\n document.querySelectorAll('.overtype-wrapper').forEach(wrapper => {\n if (!wrapper.closest('.overtype-container')) {\n const themeName = typeof themeObj === 'string' ? themeObj : themeObj.name;\n if (themeName) {\n wrapper.setAttribute('data-theme', themeName);\n }\n }\n \n // Trigger preview update for the instance\n const instance = wrapper._instance;\n if (instance) {\n instance.updatePreview();\n }\n });\n }\n\n /**\n * Initialize global event listeners\n */\n static initGlobalListeners() {\n if (OverType.globalListenersInitialized) return;\n\n // Input event\n document.addEventListener('input', (e) => {\n if (e.target && e.target.classList && e.target.classList.contains('overtype-input')) {\n const wrapper = e.target.closest('.overtype-wrapper');\n const instance = wrapper?._instance;\n if (instance) instance.handleInput(e);\n }\n });\n\n // Keydown event\n document.addEventListener('keydown', (e) => {\n if (e.target && e.target.classList && e.target.classList.contains('overtype-input')) {\n const wrapper = e.target.closest('.overtype-wrapper');\n const instance = wrapper?._instance;\n if (instance) instance.handleKeydown(e);\n }\n });\n\n // Scroll event\n document.addEventListener('scroll', (e) => {\n if (e.target && e.target.classList && e.target.classList.contains('overtype-input')) {\n const wrapper = e.target.closest('.overtype-wrapper');\n const instance = wrapper?._instance;\n if (instance) instance.handleScroll(e);\n }\n }, true);\n\n // Selection change event\n document.addEventListener('selectionchange', (e) => {\n const activeElement = document.activeElement;\n if (activeElement && activeElement.classList.contains('overtype-input')) {\n const wrapper = activeElement.closest('.overtype-wrapper');\n const instance = wrapper?._instance;\n if (instance) {\n // Update stats bar for cursor position\n if (instance.options.showStats && instance.statsBar) {\n instance._updateStats();\n }\n // Debounce updates\n clearTimeout(instance._selectionTimeout);\n instance._selectionTimeout = setTimeout(() => {\n instance.updatePreview();\n }, 50);\n }\n }\n });\n\n OverType.globalListenersInitialized = true;\n }\n}\n\n// Export classes for advanced usage\nOverType.MarkdownParser = MarkdownParser;\nOverType.ShortcutsManager = ShortcutsManager;\n\n// Export theme utilities\nOverType.themes = { solar, cave: getTheme('cave') };\nOverType.getTheme = getTheme;\n\n// Set default theme\nOverType.currentTheme = solar;\n\n// For IIFE builds, esbuild needs the class as the default export\nexport default OverType;\n// Also export as named for ESM compatibility\nexport { OverType };"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAQO,IAAM,iBAAN,MAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA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