Skip to content

Commit

Permalink
fix(generator): purge in heading's
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Apr 26, 2022
1 parent f18840b commit d838b5c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions packages/better-write-app/src/use/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { Session } from '@supabase/supabase-js'
import { computed, watch } from 'vue'
import { useHead } from '@vueuse/head'
import { useExternalsStore } from '@/store/externals'
import { useSubstitution } from './tools/substitution'

export const useStart = () => {
const ABSOLUTE = useAbsoluteStore()
Expand Down Expand Up @@ -195,6 +196,7 @@ export const useStart = () => {
utils: useUtils(),
i18n: useI18n(),
emitter: useEmitter(),
substitution: useSubstitution(),
}
)
plugin.emit('plugin-pdf-init')
Expand Down
10 changes: 6 additions & 4 deletions packages/better-write-plugin-docx/src/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export const PluginDocxSet = (
const final: DocxPurge = []
let set: false | 'bold' | 'italic' = false

const rest = raw.split(hooks.utils.regex().htmlTags())
const rest = hooks.substitution
.purge(raw)
.split(hooks.utils.regex().htmlTags())

rest.forEach((content: string) => {
// italic
Expand Down Expand Up @@ -174,7 +176,7 @@ export const PluginDocxSet = (
const entities = () => {
const headingOne = (raw: string) => {
return new docx.Paragraph({
text: raw,
text: hooks.substitution.purge(raw),
heading: docx.HeadingLevel.HEADING_1,
alignment: docx.AlignmentType.CENTER,
pageBreakBefore: true,
Expand All @@ -183,15 +185,15 @@ export const PluginDocxSet = (

const headingTwo = (raw: string) => {
return new docx.Paragraph({
text: raw,
text: hooks.substitution.purge(raw),
heading: docx.HeadingLevel.HEADING_2,
alignment: docx.AlignmentType.CENTER,
})
}

const headingThree = (raw: string) => {
return new docx.Paragraph({
text: raw,
text: hooks.substitution.purge(raw),
heading: docx.HeadingLevel.HEADING_3,
alignment: docx.AlignmentType.CENTER,
})
Expand Down
8 changes: 5 additions & 3 deletions packages/better-write-plugin-txt/src/set.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { saveAs } from 'file-saver'
import { Entity, PluginTypes } from 'better-write-types'
import { PluginTypes } from 'better-write-types'
import { On } from 'better-write-plugin-core'
import { useNProgress } from '@vueuse/integrations'
import { ContextState } from 'better-write-types'

export const PluginTxtSet = (
emitter: PluginTypes.PluginEmitter,
Expand All @@ -12,7 +11,10 @@ export const PluginTxtSet = (
const { isLoading } = useNProgress()

const purge = (texts: string[]): string => {
return texts.reduce((conc, text) => conc + text + '\n', '')
return texts.reduce(
(conc, text) => hooks.substitution.purge(conc + text) + '\n',
''
)
}

const download = (texts: string[]) => {
Expand Down
1 change: 1 addition & 0 deletions packages/better-write-types/src/types/plugin/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export interface PluginHooks {
utils: PluginHook
i18n: PluginHook
emitter: PluginHook
substitution: PluginHook
}

export type PluginContext = (
Expand Down

0 comments on commit d838b5c

Please sign in to comment.