11<script setup lang="ts">
22import type { OutlineAction } from ' ../types'
3+ import { Separator } from ' reka-ui'
34import { useData } from ' vitepress'
45import { computed , ref } from ' vue'
56import { useSourceCode } from ' ../composables/useSourceCode'
@@ -34,7 +35,7 @@ const allActions = computed(() => {
3435 return [... actions , ... customActions .value ]
3536})
3637
37- const dropdownOptions = computed (() => {
38+ const nativeOptions = computed (() => {
3839 const options: OutlineAction [] = []
3940
4041 if (copyOptionsConfig .value .markdownLink ) {
@@ -59,6 +60,12 @@ const dropdownOptions = computed(() => {
5960 })
6061 }
6162
63+ return options
64+ })
65+
66+ const externalOptions = computed (() => {
67+ const options: OutlineAction [] = []
68+
6269 if (copyOptionsConfig .value .chatgpt ) {
6370 options .push ({
6471 icon: ' i-local:openai' ,
@@ -86,7 +93,7 @@ const dropdownOptions = computed(() => {
8693 return options
8794})
8895
89- const hasDropdown = computed (() => dropdownOptions .value .length > 0 )
96+ const hasDropdown = computed (() => nativeOptions . value . length > 0 || externalOptions .value .length > 0 )
9097
9198function toggleExpanded() {
9299 isExpanded .value = ! isExpanded .value
@@ -117,9 +124,16 @@ function toggleExpanded() {
117124 leave-from-class =" opacity-100 scale-100"
118125 leave-to-class =" opacity-0 scale-95"
119126 >
120- <div v-if =" isExpanded" absolute right-0 top =" [calc(100%+4px)]" min-w-200 bg-white rounded-8 shadow-lg border =" 1 neutral-200" z-50 py-4 @click =" isExpanded = false" >
121- <div v-for =" (option, idx) in dropdownOptions" :key =" idx" flex =" ~ items-center gap-8" px-12 py-8 cursor-pointer hover:bg-neutral-100 transition-colors f-text-xs text-neutral-700 @click =" option.onClick" >
122- <div :class =" option.icon" />
127+ <div v-if =" isExpanded" absolute right-0 top =" [calc(100%+4px)]" min-w-200 bg-white rounded-8 shadow-lg border =" 1 neutral-200" z-50 py-6 @click =" isExpanded = false" >
128+ <div v-for =" (option, idx) in nativeOptions" :key =" `native-${idx}`" flex =" ~ items-center gap-8" px-10 py-6 cursor-pointer hover:bg-neutral-100 transition-colors f-text-xs text-neutral-800 @click =" option.onClick" >
129+ <div :class =" option.icon" text-14 />
130+ <span >{{ option.label }}</span >
131+ </div >
132+
133+ <Separator v-if =" nativeOptions.length > 0 && externalOptions.length > 0" my-4 h-1 bg-neutral-200 />
134+
135+ <div v-for =" (option, idx) in externalOptions" :key =" `external-${idx}`" flex =" ~ items-center gap-8" px-10 py-6 cursor-pointer hover:bg-neutral-100 transition-colors f-text-xs text-neutral-700 @click =" option.onClick" >
136+ <div :class =" option.icon" text-14 />
123137 <span >{{ option.label }}</span >
124138 </div >
125139 </div >
0 commit comments