Skip to content

Commit

Permalink
fix(project): load supporting substitution
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Apr 26, 2022
1 parent d838b5c commit d73803d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 35 deletions.
70 changes: 37 additions & 33 deletions packages/better-write-app/src/use/defines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,39 +216,43 @@ export const useDefines = () => {
}

const generator = () => {
const substitutions = (): ProjectStateTemplatesSubstitutionsText[] => {
return [
{
active: true,
old: '[[c]]',
new: '©',
},
{
active: true,
old: '[[r]]',
new: '®',
},
{
active: true,
old: '[[tm]]',
new: '™',
},
{
active: true,
old: '[[c/o]]',
new: '℅',
},
{
active: true,
old: '&nbsp',
new: ' ',
},
{
active: true,
old: '&#160',
new: ' ',
},
]
const substitutions = () => {
const text = (): ProjectStateTemplatesSubstitutionsText[] => {
return [
{
active: true,
old: '[[c]]',
new: '©',
},
{
active: true,
old: '[[r]]',
new: '®',
},
{
active: true,
old: '[[tm]]',
new: '™',
},
{
active: true,
old: '[[c/o]]',
new: '℅',
},
{
active: true,
old: '&nbsp',
new: ' ',
},
{
active: true,
old: '&#160',
new: ' ',
},
]
}

return { text }
}

return { substitutions }
Expand Down
4 changes: 2 additions & 2 deletions packages/better-write-app/src/use/populate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const usePopulate = () => {
templates: {
generator: [],
substitutions: {
text: useDefines().generator().substitutions(),
text: useDefines().generator().substitutions().text(),
},
},
},
Expand Down Expand Up @@ -117,7 +117,7 @@ export const usePopulate = () => {
templates: {
generator: [],
substitutions: {
text: useDefines().generator().substitutions(),
text: useDefines().generator().substitutions().text(),
},
},
},
Expand Down
11 changes: 11 additions & 0 deletions packages/better-write-app/src/use/storage/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { nextTick } from 'vue'
import useEmitter from '../emitter'
import { useContextStore } from '@/store/context'
import { useAuthStore } from '@/store/auth'
import { useDefines } from '../defines'

export const useStorage = () => {
const PROJECT = useProjectStore()
Expand All @@ -19,12 +20,22 @@ export const useStorage = () => {

const env = useEnv()
const emitter = useEmitter()
const defines = useDefines()

const support = (project: any) => {
if (!project) return

let _ = project

if (!_.project.templates.substitutions) {
_.project.templates = {
..._.project.templates,
substitutions: {
text: defines.generator().substitutions().text(),
},
}
}

return _
}

Expand Down

0 comments on commit d73803d

Please sign in to comment.