Skip to content

Commit

Permalink
fix(editor): chapter impact better values
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Mar 30, 2022
1 parent 28c728e commit 64ae38c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</h2>
<InputSelect
v-model="chapter"
:arr="PROJECT.pages.map((page) => page.title)"
:arr="PROJECT.pages.map((page) => page.entities[0].raw)"
/>
</div>
<div class="flex">
Expand Down Expand Up @@ -57,7 +57,7 @@
const PROJECT = useProjectStore()
const chapter = ref<string>(PROJECT.pages[0].title)
const chapter = ref<string>(PROJECT.pages[0].entities[0].raw)
const project = useProject()
const { t } = useI18n()
Expand All @@ -77,7 +77,7 @@
const onSet = () => {
const target = PROJECT.pages.filter(
(page) => page.title === chapter.value
(page) => page.entities[0].raw === chapter.value
)[0]
const result = project.utils().getWordOccurrences(target, state.min)
Expand Down
8 changes: 6 additions & 2 deletions packages/better-write-app/src/use/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,11 @@ export const useProject = () => {

const getChapterAllCharacters = (page: ContextState): number => {
return page.entities.reduce(
(sum, val) => sum + (isValidType(val) ? val.raw.length : 0),
(sum, val) =>
sum +
(isValidType(val) && raw.v2().normalize(val.raw)
? raw.v2().normalize(val.raw)!.length
: 0),
0
)
}
Expand Down Expand Up @@ -358,7 +362,7 @@ export const useProject = () => {
const getWordOccurrences = (page: ContextState, min: number = 0) => {
const map = page.entities
.filter((entity) => isValidType(entity))
.reduce((map, value) => {
.reduce((map: any, value: any) => {
const normalize = raw.v2().normalize(value.raw)

if (!normalize) return
Expand Down
2 changes: 1 addition & 1 deletion packages/better-write-localisation/src/en-US/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export default {
statistics: {
global: 'Global',
characters: 'Characters',
impact: 'Impact by Chapter',
impact: 'Estimated Reading Time',
letters: 'Letters',
words: 'Words',
repeated: 'Repeated Words',
Expand Down
2 changes: 1 addition & 1 deletion packages/better-write-localisation/src/pt-BR/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ export default {
statistics: {
global: 'Global',
characters: 'Caracteres',
impact: 'Impacto por Capítulo',
impact: 'Tempo de Leitura Estimado',
letters: 'Letras',
words: 'Palavras',
repeated: 'Palavras Repetidas',
Expand Down

0 comments on commit 64ae38c

Please sign in to comment.