Skip to content

Commit

Permalink
fix(editor): export project name
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Dec 6, 2021
1 parent 231df53 commit 35c1b8f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/components/editor/pages/drafts/EditorPagesDrafts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@
)
onMounted(() => {
PROJECT.updateContext(CONTEXT.$state)
emitter.on('project-creative-drafts-set-info', (_page: ContextState) => {
page.value = _page
})
Expand Down
4 changes: 3 additions & 1 deletion src/use/docx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { useProjectStore } from '@/store/project'
import { Entity } from '@/types/context'
import { useEnv } from './env'
import { useNProgress } from '@vueuse/integrations'
import { useProject } from './project'

export const useDocx = () => {
const PROJECT = useProjectStore()

const project = useProject()
const env = useEnv()
const { isLoading } = useNProgress()

Expand Down Expand Up @@ -204,7 +206,7 @@ export const useDocx = () => {

docx.Packer.toBlob(doc)
.then((blob) => {
saveAs(blob, PROJECT.nameRaw + '.docx')
saveAs(blob, project.utils().exportName('docx'))
})
.finally(() => {
isLoading.value = false
Expand Down
7 changes: 6 additions & 1 deletion src/use/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const useProject = () => {
new Blob([JSON.stringify(storage.getProjectObject())], {
type: 'application/json',
}),
PROJECT.nameRaw + '.bw'
utils().exportName('bw')
)
})
.finally(() => {
Expand Down Expand Up @@ -230,13 +230,18 @@ export const useProject = () => {
return longest
}

const exportName = (extension: string) => {
return `${PROJECT.name}.${extension}`
}

return {
getChapterLetters,
getChapterAllCharacters,
getChapterParagraphs,
getChapterHeadings,
getChapterFixed,
getParagraphLongest,
exportName,
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/use/storage/dropbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const useDropbox = () => {
accessToken: AUTH.dropbox.accessToken,
})

const path = `/${PROJECT.name}.bw`
const path = `/${project.utils().exportName('bw')}`

toast.info(t('toast.generics.load'))

Expand Down

0 comments on commit 35c1b8f

Please sign in to comment.