Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

docs.tsx 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. import { getDocLanguage } from '@/i18n-config/language'
  8. // Documentation command dependency types - no external dependencies needed
  9. type DocDeps = Record<string, never>
  10. /**
  11. * Documentation command - Opens help documentation
  12. */
  13. export const docsCommand: SlashCommandHandler<DocDeps> = {
  14. name: 'docs',
  15. description: 'Open documentation',
  16. mode: 'direct',
  17. // Direct execution function
  18. execute: () => {
  19. const currentLocale = i18n.language
  20. const docLanguage = getDocLanguage(currentLocale)
  21. const url = `${defaultDocBaseUrl}/${docLanguage}`
  22. window.open(url, '_blank', 'noopener,noreferrer')
  23. },
  24. async search(args: string, locale: string = 'en') {
  25. return [{
  26. id: 'doc',
  27. title: i18n.t('common.userProfile.helpCenter', { lng: locale }),
  28. description: i18n.t('app.gotoAnything.actions.docDesc', { lng: locale }) || 'Open help documentation',
  29. type: 'command' as const,
  30. icon: (
  31. <div className='flex h-6 w-6 items-center justify-center rounded-md border-[0.5px] border-divider-regular bg-components-panel-bg'>
  32. <RiBookOpenLine className='h-4 w-4 text-text-tertiary' />
  33. </div>
  34. ),
  35. data: { command: 'navigation.doc', args: {} },
  36. }]
  37. },
  38. register(_deps: DocDeps) {
  39. registerCommands({
  40. 'navigation.doc': async (_args) => {
  41. // Get the current language from i18n
  42. const currentLocale = i18n.language
  43. const docLanguage = getDocLanguage(currentLocale)
  44. const url = `${defaultDocBaseUrl}/${docLanguage}`
  45. window.open(url, '_blank', 'noopener,noreferrer')
  46. },
  47. })
  48. },
  49. unregister() {
  50. unregisterCommands(['navigation.doc'])
  51. },
  52. }