Skip to content

Commit

Permalink
refactor: de-couple TextEditor translations
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Jun 19, 2024
1 parent 7b4158a commit 666be14
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import '@toast-ui/editor/dist/theme/toastui-editor-dark.css'
// @ts-ignore
import { Editor, EditorCore, EditorOptions } from '@toast-ui/editor'
import { useGettext } from 'vue3-gettext'
import { useThemeStore } from '../composables'
import { AppConfigObject } from '../apps'
import AppLoadingSpinner from './AppLoadingSpinner.vue'
import { useThemeStore } from '../../composables'
import { AppConfigObject } from '../../apps'
import AppLoadingSpinner from './../AppLoadingSpinner.vue'
export default defineComponent({
name: 'TextEditor',
Expand Down Expand Up @@ -50,32 +50,6 @@ export default defineComponent({
)
})
const loadTranslations = () => {
return Promise.all([
import('@toast-ui/editor/dist/i18n/ar'),
import('@toast-ui/editor/dist/i18n/cs-cz'),
import('@toast-ui/editor/dist/i18n/de-de'),
import('@toast-ui/editor/dist/i18n/en-us'),
import('@toast-ui/editor/dist/i18n/es-es'),
import('@toast-ui/editor/dist/i18n/fi-fi'),
import('@toast-ui/editor/dist/i18n/fr-fr'),
import('@toast-ui/editor/dist/i18n/gl-es'),
import('@toast-ui/editor/dist/i18n/hr-hr'),
import('@toast-ui/editor/dist/i18n/it-it'),
import('@toast-ui/editor/dist/i18n/ja-jp'),
import('@toast-ui/editor/dist/i18n/ko-kr'),
import('@toast-ui/editor/dist/i18n/nb-no'),
import('@toast-ui/editor/dist/i18n/nl-nl'),
import('@toast-ui/editor/dist/i18n/pl-pl'),
import('@toast-ui/editor/dist/i18n/ru-ru'),
import('@toast-ui/editor/dist/i18n/sv-se'),
import('@toast-ui/editor/dist/i18n/tr-tr'),
import('@toast-ui/editor/dist/i18n/uk-ua'),
import('@toast-ui/editor/dist/i18n/zh-cn'),
import('@toast-ui/editor/dist/i18n/zh-tw')
])
}
const loadSyntaxHighlighting = async () => {
const [plugin] = await Promise.all([
import(
Expand All @@ -98,7 +72,7 @@ export default defineComponent({
codeSyntaxHighlight = await loadSyntaxHighlighting()
if (!props.isReadOnly) {
await loadTranslations()
await import('./l18n')
}
}
Expand Down
6 changes: 6 additions & 0 deletions packages/web-pkg/src/components/TextEditor/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineAsyncComponent } from 'vue'

// async component to avoid loading the huge toastjs package on page load
export const TextEditor = defineAsyncComponent(
async () => (await import('./TextEditor.vue')).default
)
23 changes: 23 additions & 0 deletions packages/web-pkg/src/components/TextEditor/l18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import('@toast-ui/editor/dist/i18n/ar')
import('@toast-ui/editor/dist/i18n/cs-cz')
import('@toast-ui/editor/dist/i18n/de-de')
import('@toast-ui/editor/dist/i18n/en-us')
import('@toast-ui/editor/dist/i18n/es-es')
import('@toast-ui/editor/dist/i18n/fi-fi')
import('@toast-ui/editor/dist/i18n/fr-fr')
import('@toast-ui/editor/dist/i18n/gl-es')
import('@toast-ui/editor/dist/i18n/hr-hr')
import('@toast-ui/editor/dist/i18n/it-it')
import('@toast-ui/editor/dist/i18n/ja-jp')
import('@toast-ui/editor/dist/i18n/ko-kr')
import('@toast-ui/editor/dist/i18n/nb-no')
import('@toast-ui/editor/dist/i18n/nl-nl')
import('@toast-ui/editor/dist/i18n/pl-pl')
import('@toast-ui/editor/dist/i18n/ru-ru')
import('@toast-ui/editor/dist/i18n/sv-se')
import('@toast-ui/editor/dist/i18n/tr-tr')
import('@toast-ui/editor/dist/i18n/uk-ua')
import('@toast-ui/editor/dist/i18n/zh-cn')
import('@toast-ui/editor/dist/i18n/zh-tw')

export default {}
8 changes: 1 addition & 7 deletions packages/web-pkg/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { defineAsyncComponent } from 'vue'

export * from './AppBar'
export * from './AppTemplates'
export * from './ContextActions'
Expand All @@ -9,6 +7,7 @@ export * from './Modals'
export * from './SideBar'
export * from './Search'
export * from './Spaces'
export * from './TextEditor'

export { default as AppBanner } from './AppBanner.vue'
export { default as AppLoadingSpinner } from './AppLoadingSpinner.vue'
Expand All @@ -28,8 +27,3 @@ export { default as ViewOptions } from './ViewOptions.vue'
export { default as PortalTarget } from './PortalTarget.vue'
export { default as CreateShortcutModal } from './CreateShortcutModal.vue'
export { default as CreateLinkModal } from './CreateLinkModal.vue'

// async component to avoid loading the huge toastjs package on page load
export const TextEditor = defineAsyncComponent(
async () => (await import('./TextEditor.vue')).default
)

0 comments on commit 666be14

Please sign in to comment.