1+ < details id ="markdownDropdown " class ="group relative z-10 inline-block " data-heap-id ="markdown-dropdown ">
2+ < summary
3+ class ="inline-flex cursor-pointer items-center gap-2 rounded border border-gray-light-200 bg-gray-light-200 px-4 py-2 text-base font-semibold text-black transition-colors hover:bg-gray-light-300 dark:border-gray-dark-200 dark:bg-gray-dark-300 dark:text-white dark:hover:bg-gray-dark-400 "
4+ data-heap-id ="markdown-dropdown-toggle "
5+ >
6+ < span > Page options</ span >
7+ < span class ="icon-svg transition-transform group-open:rotate-180 ">
8+ {{ partialCached "icon" "arrow_drop_down" "arrow_drop_down" }}
9+ </ span >
10+ < path stroke-linecap ="round " stroke-linejoin ="round " stroke-width ="2 " d ="M19 9l-7 7-7-7 " />
11+ </ svg >
12+ </ summary >
13+
14+ <!-- Dropdown menu -->
15+ < div
16+ class ="absolute right-0 z-50 mt-2 w-56 origin-top-right rounded border border-gray-light-200 bg-gray-light-200 p-2 text-sm text-black shadow-md [display:none] group-open:[display:block] dark:border-gray-dark-200 dark:bg-gray-dark-300 dark:text-white "
17+ data-heap-id ="markdown-dropdown-menu "
18+ >
19+ < button
20+ onclick ="copyMarkdown() "
21+ data-heap-id ="copy-markdown-button "
22+ class ="flex w-full items-start gap-2 rounded px-2 py-2 text-left transition-colors hover:bg-gray-light-300 dark:hover:bg-gray-dark-400 "
23+ >
24+ < span class ="icon-svg mt-[2px] text-base leading-none ">
25+ {{ partial "icon" "content_copy" }}
26+ </ span >
27+ < span class ="icon-svg hidden mt-[2px] text-base leading-none ">
28+ {{ partial "icon" "check_circle" }}
29+ </ span >
30+ < div class ="leading-tight ">
31+ < div class ="text-base "> Copy page as Markdown for LLMs</ div >
32+ </ div >
33+ </ button >
34+
35+ < button
36+ onclick ="viewPlainText() "
37+ data-heap-id ="view-markdown-button "
38+ class ="flex w-full items-start gap-2 rounded px-2 py-2 text-left transition-colors hover:bg-gray-light-300 dark:hover:bg-gray-dark-400 "
39+ >
40+ < span class ="icon-svg mt-[2px] text-base leading-none ">
41+ {{ partial "icon" "description" }}
42+ </ span >
43+ < div class ="leading-tight ">
44+ < div class ="text-base "> View page as plain text</ div >
45+ </ div >
46+ </ button >
47+
48+ < button
49+ onclick ="openInDocsAI() "
50+ data-heap-id ="search-docs-ai-button "
51+ class ="flex w-full items-start gap-2 rounded px-2 py-2 text-left transition-colors hover:bg-gray-light-300 dark:hover:bg-gray-dark-400 "
52+ >
53+ < span class ="icon-svg mt-[2px] text-base leading-none ">
54+ {{ partial "icon" "search" }}
55+ </ span >
56+ < div class ="leading-tight ">
57+ < div class ="text-base "> Ask questions with Docs AI</ div >
58+ </ div >
59+ </ button >
60+ </ div >
61+ </ details >
62+
63+ < script >
64+ function getCurrentPlaintextUrl ( ) {
65+ const url = window . location . href . split ( "#" ) [ 0 ] . replace ( / \/ $ / , "" ) ;
66+ return `${ url } /index.md` ;
67+ }
68+
69+ function copyMarkdown ( ) {
70+ fetch ( getCurrentPlaintextUrl ( ) )
71+ . then ( ( response ) => response . text ( ) )
72+ . then ( ( text ) => {
73+ navigator . clipboard . writeText ( text ) . then ( ( ) => {
74+ const button = document . querySelector ( '[data-heap-id="copy-markdown-button"]' ) ;
75+ if ( ! button ) return ;
76+
77+ const icons = button . querySelectorAll ( ".icon-svg" ) ;
78+ const copyIcon = icons [ 0 ] ;
79+ const checkIcon = icons [ 1 ] ;
80+
81+ copyIcon . classList . add ( "hidden" ) ;
82+ checkIcon . classList . remove ( "hidden" ) ;
83+
84+ setTimeout ( ( ) => {
85+ copyIcon . classList . remove ( "hidden" ) ;
86+ checkIcon . classList . add ( "hidden" ) ;
87+ } , 2000 ) ;
88+ } ) ;
89+ } )
90+ . catch ( ( err ) => {
91+ console . error ( "Error copying markdown:" , err ) ;
92+ } ) ;
93+ }
94+
95+ function viewPlainText ( ) {
96+ window . open ( getCurrentPlaintextUrl ( ) , "_blank" ) ;
97+ }
98+
99+ function openInDocsAI ( ) {
100+ const kapaButton = document . querySelector ( ".open-kapa-widget" ) ;
101+ if ( kapaButton ) {
102+ kapaButton . click ( ) ;
103+ } else {
104+ alert ( "Couldn't find Docs AI." ) ;
105+ }
106+ }
107+
108+ document . addEventListener ( "click" , function ( event ) {
109+ const dropdown = document . getElementById ( "markdownDropdown" ) ;
110+
111+ if ( ! dropdown ) return ;
112+
113+ const isClickInside = dropdown . contains ( event . target ) ;
114+
115+ if ( ! isClickInside && dropdown . hasAttribute ( "open" ) ) {
116+ dropdown . removeAttribute ( "open" ) ;
117+ }
118+ } ) ;
119+ </ script >
0 commit comments