Skip to content

Commit

Permalink
feat(project): not insert a heading one in blank template
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Oct 18, 2021
1 parent 767927d commit 619b5fb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/store/module/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,33 @@ export default {
state.pageLoaded = init.id
state.pages.push(init)
},
createBlank(state: ProjectState, payload: Record<any, any>) {
state.name = useText().kebab(payload.name)
state.nameRaw = payload.name
state.version = payload.version
state.creator = payload.creator
state.subject = payload.subject
state.type = payload.type
state.totalPagesCreated = 1
state.main = {}
state.summary = {}
state.pages = []

const init: ContextState = {
id: state.totalPagesCreated,
entity: [
{
type: 'paragraph',
raw: payload.subject,
createdAt: useFormat().actually(),
updatedAt: useFormat().actually(),
},
],
}

state.pageLoaded = init.id
state.pages.push(init)
},
newPage(state: ProjectState) {
state.totalPagesCreated++

Expand Down
6 changes: 5 additions & 1 deletion src/use/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ export const useProject = () => {
const { t } = i18n.global

const create = async (project: Record<string, any>) => {
store.commit('project/create', project)
project.type === 'blank'
? store.commit('project/createBlank', project)
: store.commit('project/create', project)

await nextTick

store.commit('context/load', store.state.project.pages[0])

toast.success(t('toast.project.create'))
Expand Down

0 comments on commit 619b5fb

Please sign in to comment.