Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

doc.tsx 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import type { SlashCommandHandler } from './types'
  2. import React from 'react'
  3. import { RiBookOpenLine } from '@remixicon/react'
  4. import i18n from '@/i18n-config/i18next-config'
  5. import { registerCommands, unregisterCommands } from './command-bus'
  6. import { defaultDocBaseUrl } from '@/context/i18n'
  7. // Documentation command dependency types - no external dependencies needed
  8. type DocDeps = Record<string, never>
  9. /**
  10. * Documentation command - Opens help documentation
  11. */
  12. export const docCommand: SlashCommandHandler<DocDeps> = {
  13. name: 'doc',
  14. description: 'Open documentation',
  15. async search(args: string, locale: string = 'en') {
  16. return [{
  17. id: 'doc',
  18. title: i18n.t('common.userProfile.helpCenter', { lng: locale }),
  19. description: i18n.t('app.gotoAnything.actions.docDesc', { lng: locale }) || 'Open help documentation',
  20. type: 'command' as const,
  21. icon: (
  22. <div className='flex h-6 w-6 items-center justify-center rounded-md border-[0.5px] border-divider-regular bg-components-panel-bg'>
  23. <RiBookOpenLine className='h-4 w-4 text-text-tertiary' />
  24. </div>
  25. ),
  26. data: { command: 'navigation.doc', args: {} },
  27. }]
  28. },
  29. register(_deps: DocDeps) {
  30. registerCommands({
  31. 'navigation.doc': async (_args) => {
  32. const url = `${defaultDocBaseUrl}`
  33. window.open(url, '_blank', 'noopener,noreferrer')
  34. },
  35. })
  36. },
  37. unregister() {
  38. unregisterCommands(['navigation.doc'])
  39. },
  40. }