Skip to content

Commit

Permalink
fix(annotations): ignore delete last folder in only-annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Mar 27, 2023
1 parent 4163e57 commit 74536ea
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/better-write-plugin-annotations/src/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export const PluginAnnotationsSet = (
const reset = (force: boolean = false) => {
document.querySelector('.milkdown')?.remove()

if (force) stores.PROJECT.base = stores.PROJECT.type === 'only-annotations' ? 'annotations' : 'chapter'
if (force)
stores.PROJECT.base =
stores.PROJECT.type === 'only-annotations' ? 'annotations' : 'chapter'
}

const setFile = (id: ID<string>, value: any) => {
Expand Down Expand Up @@ -67,6 +69,12 @@ export const PluginAnnotationsSet = (
}

const deleteFolder = (folder: ProjectStateAnnotationFolder) => {
if (
stores.PROJECT.type === 'only-annotations' &&
stores.PROJECT.annotations.folders.length === 1
)
return

reset(true)

stores.PROJECT.annotations.folders =
Expand Down

0 comments on commit 74536ea

Please sign in to comment.