From d658ae21ef80dd6afbd61ff86b3786ec36dee5b7 Mon Sep 17 00:00:00 2001 From: Richard McCorkle Date: Sun, 17 May 2026 21:23:50 +0200 Subject: [PATCH] refactor: remove Copy template button (drops navigator.clipboard use) Co-Authored-By: Claude Sonnet 4.6 --- main.ts | 85 --------------------------------------------------------- 1 file changed, 85 deletions(-) diff --git a/main.ts b/main.ts index a915921..aea23cd 100644 --- a/main.ts +++ b/main.ts @@ -6340,91 +6340,6 @@ class TemplateViewModal extends Modal { cls: 'tubesage-divider' }); - // Create a container for the copy button - const copyContainer = contentEl.createDiv({ - cls: ['tubesage-template-view-copy-container', 'tubesage-row-end'] - }); - - // Add copy text - copyContainer.createSpan({ - text: 'Copy template', - cls: 'tubesage-template-view-copy-text' - }); - - // Copy icon button - const copyButton = copyContainer.createEl('button', { - cls: 'tubesage-icon-button' // Reuse existing class - }); - - // Create an SVG for the copy icon - const svgNamespace = "http://www.w3.org/2000/svg"; - const copySvg = activeDocument.createElementNS(svgNamespace, "svg"); - copySvg.setAttrs({ - viewBox: "0 0 24 24", - width: "16", - height: "16", - stroke: "currentColor", - fill: "none", - 'stroke-width': "2", - 'stroke-linecap': "round", - 'stroke-linejoin': "round" - }); - - // Create the copy icon paths - const copyRect = activeDocument.createElementNS(svgNamespace, "rect"); - copyRect.setAttrs({ x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }); - copySvg.appendChild(copyRect); - - const copyPath = activeDocument.createElementNS(svgNamespace, "path"); - copyPath.setAttr("d", "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"); - copySvg.appendChild(copyPath); - - // Add the SVG to the button - copyButton.appendChild(copySvg); - - // Add hover effect - copyButton.addEventListener('mouseenter', () => { - copyButton.addClass('tubesage-icon-button-hover'); // Reuse hover class logic - }); - - copyButton.addEventListener('mouseleave', () => { - copyButton.removeClass('tubesage-icon-button-hover'); // Reuse hover class logic - }); - - // Make the text also clickable - const copyTextElement = copyContainer.querySelector('span'); - - // Function to handle copy - const handleCopy = () => { - navigator.clipboard.writeText(templateContent) - .then(() => { - // Show success state - if (copyTextElement) { - const originalText = copyTextElement.textContent; - copyTextElement.textContent = 'Copied'; - window.setTimeout(() => { - copyTextElement.textContent = originalText; - }, 2000); - } - }) - .catch(err => { - logger.error('Failed to copy template:', err); - // Show error state - if (copyTextElement) { - copyTextElement.textContent = 'Failed to copy'; - window.setTimeout(() => { - copyTextElement.textContent = 'Copy template'; - }, 2000); - } - }); - }; - - // Add click handlers to both text and button - copyButton.addEventListener('click', handleCopy); - if (copyTextElement) { - copyTextElement.addEventListener('click', handleCopy); - } - // Display the content with syntax highlighting templateContainer.createEl('pre', { cls: 'language-markdown',