44 data-heap-id ="markdown-dropdown-toggle "
55 >
66 < span > Copy page</ span >
7- < svg
8- class ="h-2 w-2 transform transition-transform group-open:rotate-180 "
9- xmlns ="http://www.w3.org/2000/svg "
10- fill ="none "
11- viewBox ="0 0 24 24 "
12- stroke ="currentColor "
13- >
7+ < span class ="icon-svg transition-transform group-open:rotate-180 ">
8+ {{ partialCached "icon" "arrow_drop_down" "arrow_drop_down" }}
9+ </ span >
1410 < path stroke-linecap ="round " stroke-linejoin ="round " stroke-width ="2 " d ="M19 9l-7 7-7-7 " />
1511 </ svg >
1612 </ summary >
2824 < span class ="icon-svg mt-[2px] text-base leading-none ">
2925 {{ partial "icon" "content_copy" }}
3026 </ span >
27+ < span class ="icon-svg hidden mt-[2px] text-base leading-none ">
28+ {{ partial "icon" "check_circle" }}
29+ </ span >
3130 < div class ="leading-tight ">
32- < div class ="text-base font-bold "> Copy page</ div >
31+ < div class ="text-base "> Copy page</ div >
3332 < div class ="text-sm text-gray-light-500 dark:text-gray-dark-500 ">
3433 Copy this page as Markdown for LLMs
3534 </ div >
4544 {{ partial "icon" "description" }}
4645 </ span >
4746 < div class ="leading-tight ">
48- < div class ="text-base font-bold "> View as Markdown</ div >
47+ < div class ="text-base "> View as Markdown</ div >
4948 < div class ="text-sm text-gray-light-500 dark:text-gray-dark-500 ">
5049 View this page as plain text
5150 </ div >
6160 {{ partial "icon" "search" }}
6261 </ span >
6362 < div class ="leading-tight ">
64- < div class ="text-base font-bold " > Search Docs AI</ div >
63+ < div class ="text-base " > Ask AI</ div >
6564 < div class ="text-sm text-gray-light-500 dark:text-gray-dark-500 ">
6665 Ask questions with Docs AI
6766 </ div >
7069 </ div >
7170 </ details >
7271
73- < script >
74- function getCurrentPlaintextUrl ( ) {
75- const url = window . location . href . split ( "#" ) [ 0 ] . replace ( / \/ $ / , "" ) ;
76- return `${ url } /index.md` ;
77- }
72+ < script >
73+ function getCurrentPlaintextUrl ( ) {
74+ const url = window . location . href . split ( "#" ) [ 0 ] . replace ( / \/ $ / , "" ) ;
75+ return `${ url } /index.md` ;
76+ }
7877
79- function copyMarkdown ( ) {
80- fetch ( getCurrentPlaintextUrl ( ) )
81- . then ( ( response ) => response . text ( ) )
82- . then ( ( text ) => {
83- navigator . clipboard
84- . writeText ( text )
85- . then ( ( ) => alert ( "Markdown copied to clipboard!" ) )
86- . catch ( ( err ) => alert ( "Failed to copy markdown: " + err ) ) ;
87- } )
88- . catch ( ( err ) => alert ( "Error fetching markdown: " + err ) ) ;
89- }
78+ function copyMarkdown ( ) {
79+ fetch ( getCurrentPlaintextUrl ( ) )
80+ . then ( ( response ) => response . text ( ) )
81+ . then ( ( text ) => {
82+ navigator . clipboard . writeText ( text ) . then ( ( ) => {
83+ const button = document . querySelector ( '[data-heap-id="copy-markdown-button"]' ) ;
84+ if ( ! button ) return ;
9085
91- function viewPlainText ( ) {
92- window . open ( getCurrentPlaintextUrl ( ) , "_blank" ) ;
93- }
86+ const icons = button . querySelectorAll ( ".icon-svg" ) ;
87+ const copyIcon = icons [ 0 ] ;
88+ const checkIcon = icons [ 1 ] ;
9489
95- function openInDocsAI ( ) {
96- const kapaButton = document . querySelector ( ".open-kapa-widget" ) ;
97- if ( kapaButton ) {
98- kapaButton . click ( ) ;
99- } else {
100- alert ( "Couldn't find Docs AI." ) ;
90+ copyIcon . classList . add ( "hidden" ) ;
91+ checkIcon . classList . remove ( "hidden" ) ;
92+
93+ setTimeout ( ( ) => {
94+ copyIcon . classList . remove ( "hidden" ) ;
95+ checkIcon . classList . add ( "hidden" ) ;
96+ } , 2000 ) ;
97+ } ) ;
98+ } )
99+ . catch ( ( err ) => {
100+ console . error ( "Error copying markdown:" , err ) ;
101+ } ) ;
101102 }
102- }
103103
104- document . addEventListener ( 'click' , function ( event ) {
105- const dropdown = document . getElementById ( 'markdownDropdown' ) ;
104+ function viewPlainText ( ) {
105+ window . open ( getCurrentPlaintextUrl ( ) , "_blank" ) ;
106+ }
106107
107- if ( ! dropdown ) return ;
108+ function openInDocsAI ( ) {
109+ const kapaButton = document . querySelector ( ".open-kapa-widget" ) ;
110+ if ( kapaButton ) {
111+ kapaButton . click ( ) ;
112+ } else {
113+ alert ( "Couldn't find Docs AI." ) ;
114+ }
115+ }
108116
109- const isClickInside = dropdown . contains ( event . target ) ;
117+ document . addEventListener ( "click" , function ( event ) {
118+ const dropdown = document . getElementById ( "markdownDropdown" ) ;
110119
111- // If dropdown is open and click was outside, close it
112- if ( ! isClickInside && dropdown . hasAttribute ( 'open' ) ) {
113- dropdown . removeAttribute ( 'open' ) ;
114- }
115- } ) ;
116- </ script >
120+ if ( ! dropdown ) return ;
121+
122+ const isClickInside = dropdown . contains ( event . target ) ;
123+
124+ if ( ! isClickInside && dropdown . hasAttribute ( "open" ) ) {
125+ dropdown . removeAttribute ( "open" ) ;
126+ }
127+ } ) ;
128+ </ script >
0 commit comments