|
1 | | -<div class="ml-3 relative inline-block" x-data="{ open: false }" @click.outside="open = false"> |
2 | | - <div class="flex shadow rounded-sm overflow-hidden border border-gray-200 dark:border-gray-700"> |
3 | | - <!-- Primary copy button --> |
| 1 | +<div class="not-prose mt-4"> |
| 2 | + <div class="flex flex-wrap items-center gap-x-6 gap-y-2 text-sm"> |
| 3 | + <button |
| 4 | + onclick="askGordon()" |
| 5 | + data-heap-id="ask-gordon-button" |
| 6 | + class="inline-flex cursor-pointer items-center gap-1.5 text-gray-600 transition-colors hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100" |
| 7 | + > |
| 8 | + <span class="icon-svg icon-sm -translate-y-px"> |
| 9 | + {{ partialCached "icon" "icons/gordon.svg" "icons/gordon.svg" }} |
| 10 | + </span> |
| 11 | + <span>Ask Gordon</span> |
| 12 | + </button> |
| 13 | + |
4 | 14 | <button |
5 | 15 | onclick="copyMarkdown()" |
6 | 16 | data-heap-id="copy-markdown-button" |
7 | | - class="bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 flex cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors whitespace-nowrap text-gray-900 dark:text-white" |
| 17 | + class="inline-flex cursor-pointer items-center gap-1.5 text-gray-600 transition-colors hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100" |
8 | 18 | > |
9 | | - <span class="icon-svg icon-sm"> |
| 19 | + <span class="icon-svg icon-sm -translate-y-px"> |
10 | 20 | {{ partialCached "icon" "content_copy" "content_copy" }} |
11 | 21 | </span> |
12 | | - <span class="icon-svg icon-sm hidden"> |
| 22 | + <span class="icon-svg icon-sm hidden -translate-y-px"> |
13 | 23 | {{ partialCached "icon" "check_circle" "check_circle" }} |
14 | 24 | </span> |
15 | | - <span>Copy as Markdown</span> |
16 | | - </button> |
17 | | - |
18 | | - <!-- Dropdown toggle --> |
19 | | - <button |
20 | | - @click="open = !open" |
21 | | - type="button" |
22 | | - data-heap-id="markdown-dropdown-toggle" |
23 | | - class="bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 flex items-center justify-center px-2 border-l border-gray-200 dark:border-gray-700 transition-colors text-gray-900 dark:text-white" |
24 | | - aria-label="More options" |
25 | | - > |
26 | | - <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
27 | | - <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path> |
28 | | - </svg> |
| 25 | + <span>Copy Markdown</span> |
29 | 26 | </button> |
30 | | - </div> |
31 | 27 |
|
32 | | - <!-- Dropdown menu --> |
33 | | - <div |
34 | | - x-show="open" |
35 | | - x-collapse |
36 | | - x-cloak |
37 | | - class="absolute right-0 top-full mt-1 min-w-full bg-white dark:bg-gray-800 rounded-sm shadow-lg overflow-hidden z-50 border border-gray-200 dark:border-gray-700" |
38 | | - data-heap-id="markdown-dropdown-menu" |
39 | | - > |
40 | 28 | <button |
41 | 29 | onclick="viewPlainText()" |
42 | 30 | data-heap-id="view-markdown-button" |
43 | | - class="flex w-full items-center gap-2 px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 whitespace-nowrap" |
| 31 | + class="inline-flex cursor-pointer items-center gap-1.5 text-gray-600 transition-colors hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100" |
44 | 32 | > |
45 | | - <span class="icon-svg icon-sm"> |
| 33 | + <span class="icon-svg icon-sm -translate-y-px"> |
46 | 34 | {{ partialCached "icon" "open_in_new" "open_in_new" }} |
47 | 35 | </span> |
48 | | - <span>Open Markdown</span> |
49 | | - </button> |
50 | | - |
51 | | - <button |
52 | | - onclick="openInDocsAI()" |
53 | | - data-heap-id="search-docs-ai-button" |
54 | | - class="flex w-full items-center gap-2 px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 whitespace-nowrap" |
55 | | - > |
56 | | - <span class="icon-svg icon-sm"> |
57 | | - {{ partialCached "icon" "search" "search" }} |
58 | | - </span> |
59 | | - <span>Ask Docs AI</span> |
60 | | - </button> |
61 | | - <button |
62 | | - onclick="openInClaude()" |
63 | | - data-heap-id="open-claude-button" |
64 | | - class="flex w-full items-center gap-2 px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 whitespace-nowrap" |
65 | | - > |
66 | | - <span class="icon-svg icon-sm"> |
67 | | - {{ partialCached "icon" "/icons/claude.svg" "claude" }} |
68 | | - </span> |
69 | | - <span>Open in Claude</span> |
| 36 | + <span>View Markdown</span> |
70 | 37 | </button> |
71 | 38 | </div> |
| 39 | + <hr class="mt-4 mb-6 border-t border-gray-200 dark:border-gray-700" /> |
72 | 40 | </div> |
73 | 41 |
|
74 | 42 | <script> |
75 | | - function getCurrentPlaintextUrl() { |
76 | | - const url = window.location.href.split("#")[0].replace(/\/$/, ""); |
77 | | - return `${url}.md`; |
78 | | - } |
| 43 | + function getCurrentPlaintextUrl() { |
| 44 | + const url = window.location.href.split("#")[0].replace(/\/$/, ""); |
| 45 | + return `${url}.md`; |
| 46 | + } |
79 | 47 |
|
80 | | - function copyMarkdown() { |
81 | | - fetch(getCurrentPlaintextUrl()) |
82 | | - .then((response) => response.text()) |
83 | | - .then((text) => { |
84 | | - navigator.clipboard.writeText(text).then(() => { |
85 | | - const button = document.querySelector('[data-heap-id="copy-markdown-button"]'); |
86 | | - if (!button) return; |
| 48 | + function copyMarkdown() { |
| 49 | + fetch(getCurrentPlaintextUrl()) |
| 50 | + .then((response) => response.text()) |
| 51 | + .then((text) => { |
| 52 | + navigator.clipboard.writeText(text).then(() => { |
| 53 | + const button = document.querySelector( |
| 54 | + '[data-heap-id="copy-markdown-button"]', |
| 55 | + ); |
| 56 | + if (!button) return; |
87 | 57 |
|
88 | | - const icons = button.querySelectorAll(".icon-svg"); |
89 | | - const copyIcon = icons[0]; |
90 | | - const checkIcon = icons[1]; |
| 58 | + const icons = button.querySelectorAll(".icon-svg"); |
| 59 | + const copyIcon = icons[0]; |
| 60 | + const checkIcon = icons[1]; |
91 | 61 |
|
92 | | - copyIcon.classList.add("hidden"); |
93 | | - checkIcon.classList.remove("hidden"); |
| 62 | + copyIcon.classList.add("hidden"); |
| 63 | + checkIcon.classList.remove("hidden"); |
94 | 64 |
|
95 | | - setTimeout(() => { |
96 | | - copyIcon.classList.remove("hidden"); |
97 | | - checkIcon.classList.add("hidden"); |
98 | | - }, 2000); |
99 | | - }); |
100 | | - }) |
101 | | - .catch((err) => { |
102 | | - console.error("Error copying markdown:", err); |
| 65 | + setTimeout(() => { |
| 66 | + copyIcon.classList.remove("hidden"); |
| 67 | + checkIcon.classList.add("hidden"); |
| 68 | + }, 2000); |
103 | 69 | }); |
104 | | - } |
| 70 | + }) |
| 71 | + .catch((err) => { |
| 72 | + console.error("Error copying markdown:", err); |
| 73 | + }); |
| 74 | + } |
105 | 75 |
|
106 | | - function viewPlainText() { |
107 | | - window.open(getCurrentPlaintextUrl(), "_blank"); |
108 | | - } |
109 | | - |
110 | | - function openInDocsAI() { |
111 | | - const kapaButton = document.querySelector(".open-kapa-widget"); |
112 | | - if (kapaButton) { |
113 | | - kapaButton.click(); |
114 | | - } else { |
115 | | - alert("Couldn't find Docs AI."); |
116 | | - } |
117 | | - } |
| 76 | + function viewPlainText() { |
| 77 | + window.open(getCurrentPlaintextUrl(), "_blank"); |
| 78 | + } |
118 | 79 |
|
119 | | - function openInClaude() { |
120 | | - const markdownUrl = getCurrentPlaintextUrl(); |
121 | | - const prompt = `Read ${markdownUrl} so I can ask questions about it.`; |
122 | | - const encodedText = encodeURIComponent(prompt); |
123 | | - const claudeUrl = `https://claude.ai/new?q=${encodedText}`; |
124 | | - window.open(claudeUrl, '_blank'); |
| 80 | + function askGordon() { |
| 81 | + if (window.Alpine && window.Alpine.store("gordon")) { |
| 82 | + window.Alpine.store("gordon").toggle(); |
125 | 83 | } |
126 | | - </script> |
| 84 | + } |
| 85 | +</script> |
0 commit comments