markdown-actions 1.0.3 → 1.0.5
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/dist/markdown-actions.esm.js +59 -78
- package/dist/markdown-actions.esm.js.map +3 -3
- package/dist/markdown-actions.js +59 -78
- package/dist/markdown-actions.js.map +3 -3
- package/dist/markdown-actions.min.js +20 -22
- package/package.json +1 -1
- package/src/core/selection.js +10 -2
- package/src/index.js +76 -117
package/dist/markdown-actions.js
CHANGED
|
@@ -368,7 +368,13 @@ var markdownActions = (() => {
|
|
|
368
368
|
expandSelectionToLine(textarea);
|
|
369
369
|
}
|
|
370
370
|
const result = operation(textarea);
|
|
371
|
-
if (options.
|
|
371
|
+
if (options.adjustSelection) {
|
|
372
|
+
const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd);
|
|
373
|
+
const isRemoving = selectedText.startsWith(options.prefix);
|
|
374
|
+
const adjusted = options.adjustSelection(isRemoving, originalStart, originalEnd, lineStart);
|
|
375
|
+
result.selectionStart = adjusted.start;
|
|
376
|
+
result.selectionEnd = adjusted.end;
|
|
377
|
+
} else if (options.prefix) {
|
|
372
378
|
const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd);
|
|
373
379
|
const isRemoving = selectedText.startsWith(options.prefix);
|
|
374
380
|
if (noInitialSelection) {
|
|
@@ -720,19 +726,8 @@ ${blockSuffix}` : suffix;
|
|
|
720
726
|
function toggleCode(textarea) {
|
|
721
727
|
if (!textarea || textarea.disabled || textarea.readOnly)
|
|
722
728
|
return;
|
|
723
|
-
const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd);
|
|
724
729
|
const style = mergeWithDefaults(FORMATS.code);
|
|
725
|
-
|
|
726
|
-
if (isMultipleLines(selectedText)) {
|
|
727
|
-
const blockStyle2 = {
|
|
728
|
-
prefix: "```\n",
|
|
729
|
-
suffix: "\n```",
|
|
730
|
-
surroundWithNewlines: true
|
|
731
|
-
};
|
|
732
|
-
result = multilineStyle(textarea, mergeWithDefaults(blockStyle2));
|
|
733
|
-
} else {
|
|
734
|
-
result = blockStyle(textarea, style);
|
|
735
|
-
}
|
|
730
|
+
const result = blockStyle(textarea, style);
|
|
736
731
|
insertText(textarea, result);
|
|
737
732
|
}
|
|
738
733
|
function insertLink(textarea, options = {}) {
|
|
@@ -740,7 +735,11 @@ ${blockSuffix}` : suffix;
|
|
|
740
735
|
return;
|
|
741
736
|
const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd);
|
|
742
737
|
let style = mergeWithDefaults(FORMATS.link);
|
|
743
|
-
|
|
738
|
+
const isURL = selectedText && selectedText.match(/^https?:\/\//);
|
|
739
|
+
if (isURL && !options.url) {
|
|
740
|
+
style.suffix = `](${selectedText})`;
|
|
741
|
+
style.replaceNext = "";
|
|
742
|
+
} else if (options.url) {
|
|
744
743
|
style.suffix = `](${options.url})`;
|
|
745
744
|
style.replaceNext = "";
|
|
746
745
|
}
|
|
@@ -796,76 +795,58 @@ ${blockSuffix}` : suffix;
|
|
|
796
795
|
return;
|
|
797
796
|
if (level < 1 || level > 6)
|
|
798
797
|
level = 1;
|
|
799
|
-
const originalStart = textarea.selectionStart;
|
|
800
|
-
const originalEnd = textarea.selectionEnd;
|
|
801
|
-
const noInitialSelection = originalStart === originalEnd;
|
|
802
798
|
const headerKey = `header${level === 1 ? "1" : level}`;
|
|
803
799
|
const style = mergeWithDefaults(FORMATS[headerKey] || FORMATS.header1);
|
|
804
|
-
const
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
const existingHeaderMatch = currentLine.match(/^(#{1,6})\s*/);
|
|
817
|
-
const existingPrefixLength = existingHeaderMatch ? existingHeaderMatch[0].length : 0;
|
|
818
|
-
const existingLevel = existingHeaderMatch ? existingHeaderMatch[1].length : 0;
|
|
819
|
-
const cleanedLine = currentLine.replace(/^#{1,6}\s*/, "");
|
|
820
|
-
let newLine;
|
|
821
|
-
let isRemoving = false;
|
|
822
|
-
if (toggle && existingLevel === level) {
|
|
823
|
-
newLine = cleanedLine;
|
|
824
|
-
isRemoving = true;
|
|
825
|
-
} else {
|
|
826
|
-
newLine = style.prefix + cleanedLine;
|
|
827
|
-
}
|
|
828
|
-
let selectionStart, selectionEnd;
|
|
829
|
-
if (noInitialSelection) {
|
|
830
|
-
const cursorOffsetInLine = originalStart - lineStart;
|
|
831
|
-
if (isRemoving) {
|
|
832
|
-
if (cursorOffsetInLine < existingPrefixLength) {
|
|
833
|
-
selectionStart = lineStart;
|
|
800
|
+
const originalStart = textarea.selectionStart;
|
|
801
|
+
const originalEnd = textarea.selectionEnd;
|
|
802
|
+
const result = applyLineOperation(
|
|
803
|
+
textarea,
|
|
804
|
+
(ta) => {
|
|
805
|
+
const currentLine = ta.value.slice(ta.selectionStart, ta.selectionEnd);
|
|
806
|
+
const existingHeaderMatch = currentLine.match(/^(#{1,6})\s*/);
|
|
807
|
+
const existingLevel = existingHeaderMatch ? existingHeaderMatch[1].length : 0;
|
|
808
|
+
const cleanedLine = currentLine.replace(/^#{1,6}\s*/, "");
|
|
809
|
+
let newLine;
|
|
810
|
+
if (toggle && existingLevel === level) {
|
|
811
|
+
newLine = cleanedLine;
|
|
834
812
|
} else {
|
|
835
|
-
|
|
813
|
+
newLine = style.prefix + cleanedLine;
|
|
836
814
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
selectionStart
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
815
|
+
return {
|
|
816
|
+
text: newLine,
|
|
817
|
+
selectionStart: ta.selectionStart,
|
|
818
|
+
selectionEnd: ta.selectionEnd
|
|
819
|
+
};
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
prefix: style.prefix,
|
|
823
|
+
// Custom handler for header-specific logic
|
|
824
|
+
adjustSelection: (isRemoving, selStart, selEnd, lineStart) => {
|
|
825
|
+
const currentLine = textarea.value.slice(lineStart, textarea.selectionEnd);
|
|
826
|
+
const existingHeaderMatch = currentLine.match(/^(#{1,6})\s*/);
|
|
827
|
+
const existingPrefixLength = existingHeaderMatch ? existingHeaderMatch[0].length : 0;
|
|
828
|
+
const existingLevel = existingHeaderMatch ? existingHeaderMatch[1].length : 0;
|
|
829
|
+
const actuallyRemoving = toggle && existingLevel === level;
|
|
830
|
+
if (actuallyRemoving) {
|
|
831
|
+
return {
|
|
832
|
+
start: Math.max(selStart - existingPrefixLength, lineStart),
|
|
833
|
+
end: Math.max(selEnd - existingPrefixLength, lineStart)
|
|
834
|
+
};
|
|
835
|
+
} else if (existingPrefixLength > 0) {
|
|
836
|
+
const prefixDiff = style.prefix.length - existingPrefixLength;
|
|
837
|
+
return {
|
|
838
|
+
start: selStart + prefixDiff,
|
|
839
|
+
end: selEnd + prefixDiff
|
|
840
|
+
};
|
|
841
|
+
} else {
|
|
842
|
+
return {
|
|
843
|
+
start: selStart + style.prefix.length,
|
|
844
|
+
end: selEnd + style.prefix.length
|
|
845
|
+
};
|
|
846
|
+
}
|
|
843
847
|
}
|
|
844
|
-
} else {
|
|
845
|
-
selectionStart = originalStart + style.prefix.length;
|
|
846
|
-
}
|
|
847
|
-
selectionStart = Math.min(selectionStart, lineStart + newLine.length);
|
|
848
|
-
selectionEnd = selectionStart;
|
|
849
|
-
} else {
|
|
850
|
-
if (isRemoving) {
|
|
851
|
-
selectionStart = Math.max(originalStart - existingPrefixLength, lineStart);
|
|
852
|
-
selectionEnd = Math.max(originalEnd - existingPrefixLength, lineStart);
|
|
853
|
-
} else if (existingPrefixLength > 0) {
|
|
854
|
-
const prefixDiff = style.prefix.length - existingPrefixLength;
|
|
855
|
-
selectionStart = originalStart + prefixDiff;
|
|
856
|
-
selectionEnd = originalEnd + prefixDiff;
|
|
857
|
-
} else {
|
|
858
|
-
selectionStart = originalStart + style.prefix.length;
|
|
859
|
-
selectionEnd = originalEnd + style.prefix.length;
|
|
860
848
|
}
|
|
861
|
-
|
|
862
|
-
selectionEnd = Math.min(selectionEnd, lineStart + newLine.length);
|
|
863
|
-
}
|
|
864
|
-
const result = {
|
|
865
|
-
text: newLine,
|
|
866
|
-
selectionStart,
|
|
867
|
-
selectionEnd
|
|
868
|
-
};
|
|
849
|
+
);
|
|
869
850
|
insertText(textarea, result);
|
|
870
851
|
}
|
|
871
852
|
function toggleH1(textarea) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.js", "../src/core/formats.js", "../src/debug.js", "../src/core/insertion.js", "../src/core/selection.js", "../src/operations/block.js", "../src/operations/list.js", "../src/core/detection.js"],
|
|
4
|
-
"sourcesContent": ["/**\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 const selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd)\n const style = mergeWithDefaults(FORMATS.code)\n \n // Use block style for single line, multiline style for multiple lines\n let result\n if (isMultipleLines(selectedText)) {\n // For multiline, we want code blocks\n const blockStyle = {\n prefix: '```\\n',\n suffix: '\\n```',\n surroundWithNewlines: true\n }\n result = multilineStyle(textarea, mergeWithDefaults(blockStyle))\n } else {\n result = blockStyle(textarea, style)\n }\n \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 // Override with custom URL if provided\n if (options.url) {\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 // Save original cursor position before any expansion\n const originalStart = textarea.selectionStart\n const originalEnd = textarea.selectionEnd\n const noInitialSelection = originalStart === originalEnd\n \n const headerKey = `header${level === 1 ? '1' : level}`\n const style = mergeWithDefaults(FORMATS[headerKey] || FORMATS.header1)\n \n // Select current line\n const value = textarea.value\n let lineStart = originalStart\n let lineEnd = originalStart\n \n // Find line boundaries\n while (lineStart > 0 && value[lineStart - 1] !== '\\n') {\n lineStart--\n }\n while (lineEnd < value.length && value[lineEnd] !== '\\n') {\n lineEnd++\n }\n \n textarea.selectionStart = lineStart\n textarea.selectionEnd = lineEnd\n \n const currentLine = value.slice(lineStart, lineEnd)\n \n // Check if we're removing or changing existing header\n const existingHeaderMatch = currentLine.match(/^(#{1,6})\\s*/)\n const existingPrefixLength = existingHeaderMatch ? existingHeaderMatch[0].length : 0\n const existingLevel = existingHeaderMatch ? existingHeaderMatch[1].length : 0\n \n // Remove any existing header formatting\n const cleanedLine = currentLine.replace(/^#{1,6}\\s*/, '')\n \n let newLine\n let isRemoving = false\n \n // If toggle mode and current line has the same header level, remove it\n if (toggle && existingLevel === level) {\n newLine = cleanedLine\n isRemoving = true\n } else {\n // Apply new header\n newLine = style.prefix + cleanedLine\n }\n \n let selectionStart, selectionEnd\n \n if (noInitialSelection) {\n // No selection - just restore cursor position\n const cursorOffsetInLine = originalStart - lineStart\n \n if (isRemoving) {\n // We're removing the header\n if (cursorOffsetInLine < existingPrefixLength) {\n // Cursor was in the header prefix, move to start of line\n selectionStart = lineStart\n } else {\n // Cursor was in the text, move back by prefix length\n selectionStart = originalStart - existingPrefixLength\n }\n } else if (existingPrefixLength > 0) {\n // We're replacing an existing header\n if (cursorOffsetInLine < existingPrefixLength) {\n // Cursor was in the header prefix, keep it at the same position\n selectionStart = lineStart + Math.min(cursorOffsetInLine, style.prefix.length)\n } else {\n // Cursor was in the text, adjust by the difference in prefix lengths\n const prefixDiff = style.prefix.length - existingPrefixLength\n selectionStart = originalStart + prefixDiff\n }\n } else {\n // We're adding a new header\n // Move cursor by the length of the new prefix\n selectionStart = originalStart + style.prefix.length\n }\n \n // Ensure cursor doesn't go past end of line\n selectionStart = Math.min(selectionStart, lineStart + newLine.length)\n selectionEnd = selectionStart\n } else {\n // Had a selection - preserve it with adjustment\n if (isRemoving) {\n // When removing header, shift selection back\n selectionStart = Math.max(originalStart - existingPrefixLength, lineStart)\n selectionEnd = Math.max(originalEnd - existingPrefixLength, lineStart)\n } else if (existingPrefixLength > 0) {\n // We're replacing an existing header\n const prefixDiff = style.prefix.length - existingPrefixLength\n selectionStart = originalStart + prefixDiff\n selectionEnd = originalEnd + prefixDiff\n } else {\n // We're adding a new header\n selectionStart = originalStart + style.prefix.length\n selectionEnd = originalEnd + style.prefix.length\n }\n \n // Ensure selection doesn't go past end of line\n selectionStart = Math.min(selectionStart, lineStart + newLine.length)\n selectionEnd = Math.min(selectionEnd, lineStart + newLine.length)\n }\n \n const result = {\n text: newLine,\n selectionStart,\n selectionEnd\n }\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 * 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 * @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.prefix) {\n // Check if we're toggling on or off\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 } 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 // Save the original selection boundaries before expansion\n const originalStart = textarea.selectionStart\n const originalEnd = textarea.selectionEnd\n \n // Get the result which includes expandSelectionToLine\n const result = listStyle(textarea, style)\n \n // At this point, textarea selection has been expanded to full line(s)\n // insertText will use the current (expanded) selection to know what to replace\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}"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAAA;AAAA,IAAA,wBAAAC;AAAA,IAAA;AAAA,qBAAAC;AAAA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,MAAM,UAAU;AAAA,IACrB,MAAM;AAAA,MACJ,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,WAAW;AAAA,IACb;AAAA,IACA,QAAQ;AAAA,MACN,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,WAAW;AAAA,IACb;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,aAAa;AAAA,IACf;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,IACA,YAAY;AAAA,MACV,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,eAAe;AAAA,IACjB;AAAA,IACA,cAAc;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,IACf;AAAA,IACA,OAAO;AAAA,MACL,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,sBAAsB;AAAA,IACxB;AAAA,IACA,UAAU;AAAA,MACR,QAAQ;AAAA,MACR,WAAW;AAAA,MACX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;AAAA,EAChC;AAKO,WAAS,SAAS,UAAU;AACjC,iBAAa,UAAU,GAAG,IAAI;AAAA,EAChC;AAKO,WAAS,SAAS,UAAU;AACjC,iBAAa,UAAU,GAAG,IAAI;AAAA,EAChC;AAKO,WAASC,kBAAiB,UAAU;AACzC,WAAO,iBAAU,QAAQ;AAAA,EAC3B;AAKO,WAASC,WAAU,UAAU,QAAQ;AAC1C,WAAO,UAAI,UAAU,MAAM;AAAA,EAC7B;AAKO,WAASC,iBAAgB,UAAU,UAAU,CAAC,GAAG;AACtD,oBAAO,UAAU,OAAO;AAAA,EAC1B;AAKO,WAAS,kBAAkB,UAAU,QAAQ;AAClD,QAAI,CAAC,YAAY,SAAS,YAAY,SAAS;AAAU;AAEzD,UAAM,QAAQ,kBAAkB,MAAM;AACtC,QAAI;AAEJ,QAAI,MAAM,WAAW;AACnB,YAAM,eAAe,SAAS,MAAM,MAAM,SAAS,gBAAgB,SAAS,YAAY;AACxF,UAAI,gBAAgB,YAAY,GAAG;AACjC,iBAAS,eAAe,UAAU,KAAK;AAAA,MACzC,OAAO;AACL,iBAAS,WAAW,UAAU,KAAK;AAAA,MACrC;AAAA,IACF,OAAO;AACL,eAAS,WAAW,UAAU,KAAK;AAAA,IACrC;AAEA,eAAW,UAAU,MAAM;AAAA,EAC7B;AAoBA,MAAO,cAAQ;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,kBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,iBAAAC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;",
|
|
6
|
-
"names": ["expandSelection", "getActiveFormats", "hasFormat", "debugMode", "
|
|
4
|
+
"sourcesContent": ["/**\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 const headerKey = `header${level === 1 ? '1' : level}`\n const style = mergeWithDefaults(FORMATS[headerKey] || FORMATS.header1)\n \n // Save original positions before any operations\n const originalStart = textarea.selectionStart\n const originalEnd = textarea.selectionEnd\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 \n // Check if we're removing or changing existing header\n const existingHeaderMatch = currentLine.match(/^(#{1,6})\\s*/)\n const existingLevel = existingHeaderMatch ? existingHeaderMatch[1].length : 0\n \n // Remove any existing header formatting\n const cleanedLine = currentLine.replace(/^#{1,6}\\s*/, '')\n \n let newLine\n \n // If toggle mode and current line has the same header level, remove it\n if (toggle && existingLevel === level) {\n newLine = cleanedLine\n } else {\n // Apply new header\n newLine = style.prefix + cleanedLine\n }\n \n return {\n text: newLine,\n selectionStart: ta.selectionStart,\n selectionEnd: ta.selectionEnd\n }\n },\n {\n prefix: style.prefix,\n // Custom handler for header-specific logic\n adjustSelection: (isRemoving, selStart, selEnd, lineStart) => {\n const currentLine = textarea.value.slice(lineStart, textarea.selectionEnd)\n const existingHeaderMatch = currentLine.match(/^(#{1,6})\\s*/)\n const existingPrefixLength = existingHeaderMatch ? existingHeaderMatch[0].length : 0\n const existingLevel = existingHeaderMatch ? existingHeaderMatch[1].length : 0\n \n // Check if we're actually removing (toggle off)\n const actuallyRemoving = toggle && existingLevel === level\n \n if (actuallyRemoving) {\n // Removing the header entirely\n return {\n start: Math.max(selStart - existingPrefixLength, lineStart),\n end: Math.max(selEnd - existingPrefixLength, lineStart)\n }\n } else if (existingPrefixLength > 0) {\n // Replacing existing header with new one\n const prefixDiff = style.prefix.length - existingPrefixLength\n return {\n start: selStart + prefixDiff,\n end: selEnd + prefixDiff\n }\n } else {\n // Adding new header\n return {\n start: selStart + style.prefix.length,\n end: selEnd + style.prefix.length\n }\n }\n }\n }\n )\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 * 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 } 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 // Save the original selection boundaries before expansion\n const originalStart = textarea.selectionStart\n const originalEnd = textarea.selectionEnd\n \n // Get the result which includes expandSelectionToLine\n const result = listStyle(textarea, style)\n \n // At this point, textarea selection has been expanded to full line(s)\n // insertText will use the current (expanded) selection to know what to replace\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}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAAA;AAAA,IAAA,wBAAAC;AAAA,IAAA;AAAA,qBAAAC;AAAA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,MAAM,UAAU;AAAA,IACrB,MAAM;AAAA,MACJ,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,WAAW;AAAA,IACb;AAAA,IACA,QAAQ;AAAA,MACN,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,WAAW;AAAA,IACb;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,aAAa;AAAA,IACf;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,IACA,YAAY;AAAA,MACV,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,eAAe;AAAA,IACjB;AAAA,IACA,cAA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BAAa,UAAU,GAAG,IAAI;AAAA,EAChC;AAKO,WAASC,kBAAiB,UAAU;AACzC,WAAO,iBAAU,QAAQ;AAAA,EAC3B;AAKO,WAASC,WAAU,UAAU,QAAQ;AAC1C,WAAO,UAAI,UAAU,MAAM;AAAA,EAC7B;AAKO,WAASC,iBAAgB,UAAU,UAAU,CAAC,GAAG;AACtD,oBAAO,UAAU,OAAO;AAAA,EAC1B;AAKO,WAAS,kBAAkB,UAAU,QAAQ;AAClD,QAAI,CAAC,YAAY,SAAS,YAAY,SAAS;AAAU;AAEzD,UAAM,QAAQ,kBAAkB,MAAM;AACtC,QAAI;AAEJ,QAAI,MAAM,WAAW;AACnB,YAAM,eAAe,SAAS,MAAM,MAAM,SAAS,gBAAgB,SAAS,YAAY;AACxF,UAAI,gBAAgB,YAAY,GAAG;AACjC,iBAAS,eAAe,UAAU,KAAK;AAAA,MACzC,OAAO;AACL,iBAAS,WAAW,UAAU,KAAK;AAAA,MACrC;AAAA,IACF,OAAO;AACL,eAAS,WAAW,UAAU,KAAK;AAAA,IACrC;AAEA,eAAW,UAAU,MAAM;AAAA,EAC7B;AAoBA,MAAO,cAAQ;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,kBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,iBAAAC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;",
|
|
6
|
+
"names": ["expandSelection", "getActiveFormats", "hasFormat", "debugMode", "getActiveFormats", "hasFormat", "expandSelection", "getActiveFormats", "hasFormat", "expandSelection"]
|
|
7
7
|
}
|