Skip to content

Commit

Permalink
fix(history): unshift in exact index value for instant tick
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Aug 27, 2022
1 parent 8583986 commit 888c11a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/better-write-app/src/store/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { GlobalState } from 'better-write-types'
import { useProjectStore } from './project'
import { useContextStore } from './context'
import { useDOCXStore } from './docx'
import { useHistoryStore } from './history'

export const useGlobalStore = defineStore('global', {
state: (): GlobalState => {
Expand All @@ -19,13 +20,15 @@ export const useGlobalStore = defineStore('global', {
const docx = useDOCXStore()
const absolute = useAbsoluteStore()
const project = useProjectStore()
const history = useHistoryStore()

context.$reset()
absolute.$reset()
editor.$reset()
pdf.resetStyles()
docx.$reset()
project.$reset()
history.$reset()
},
},
})
14 changes: 13 additions & 1 deletion packages/better-write-app/src/use/block/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export const useBlockText = ({
type: 'insert',
},
{
index: value + 1,
index: value,
entity: paragraph,
type: 'insert',
},
Expand Down Expand Up @@ -489,6 +489,18 @@ export const useBlockText = ({
position: 'auto',
})

await nextTick

HISTORY.add({
items: [
{
index: index.value + 1,
entity: props.entity,
type: 'insert',
},
],
})

return
}

Expand Down

0 comments on commit 888c11a

Please sign in to comment.