Skip to content

Commit 9635f4b

Browse files
committed
feat(editor): delete page
1 parent ce37de4 commit 9635f4b

File tree

9 files changed

+60
-9
lines changed

9 files changed

+60
-9
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22

33
A editor for creative writers.
44

5-
## Tasks for v0.1.0
5+
## Tasks
66

77
- [X] Initial Page Entry-Text
88
- [X] Simple Parser Style-Raw
99
- [X] Final Text Defines
1010
- [ ] Grammar Corrections
1111
- [X] Project Control Pages
12-
- [ ] Aside Graph-Tree
13-
- [ ] PDF Generator + Customization
12+
- [X] Aside Graph-Tree
13+
14+
### PDF
15+
16+
- [ ] Generator
17+
- [ ] Page Types
18+
- [ ] Customization
1419

1520
## Setup
1621

src/components/editor/aside/AsideBar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
</HeroIcon>
212212
</template>
213213
<AsideProjectNew />
214-
<AsidePageNew />
214+
<AsidePageNew v-if="store.state.project.name !== '__NOT_CREATED__'" />
215215
</AsideBarItem>
216216
</template>
217217

src/components/editor/main/EditorBase.vue

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@
1212
rgba(0, 0, 0, 0.05) 0px 1px 1px 0px;
1313
"
1414
>
15+
<div class="flex w-full justify-end items-center">
16+
<HeroIcon
17+
class="relative wb-icon inline-flex"
18+
@click.prevent="onDeletePage"
19+
>
20+
<svg
21+
xmlns="http://www.w3.org/2000/svg"
22+
class="h-4 w-4"
23+
viewBox="0 0 20 20"
24+
fill="currentColor"
25+
>
26+
<path d="M4 3a2 2 0 100 4h12a2 2 0 100-4H4z" />
27+
<path
28+
fill-rule="evenodd"
29+
d="M3 8h14v7a2 2 0 01-2 2H5a2 2 0 01-2-2V8zm5 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z"
30+
clip-rule="evenodd"
31+
/>
32+
</svg>
33+
</HeroIcon>
34+
</div>
1535
<EditorBaseBlocked
1636
v-if="store.state.project.name === '__NOT_CREATED__'"
1737
/>
@@ -61,6 +81,15 @@
6181
6282
entry.value = ''
6383
}
84+
85+
const onDeletePage = async () => {
86+
if (store.state.project.pages.length <= 1) return
87+
88+
store.commit('project/deletePage', store.state.context)
89+
await nextTick
90+
91+
store.commit('context/load', store.state.project.pages[0])
92+
}
6493
</script>
6594

6695
<style scoped>

src/components/editor/text/TextShow.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
:position="props.entity.id"
1212
/>
1313
<div class="w-full" @click.prevent="onEdit">
14-
<p
14+
<div
1515
v-if="!edit"
1616
ref="show"
1717
class="overflow-hidden w-full"

src/lang/br.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default {
3535
confirm: 'Criar',
3636
content: {
3737
name: 'Um Novo Projeto Incrível',
38+
nameNew: 'Sem Título',
3839
version: '0.1.0',
3940
},
4041
},

src/lang/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default {
3535
confirm: 'Create',
3636
content: {
3737
name: 'Nice New Project',
38+
nameNew: 'Untitled',
3839
version: '0.1.0',
3940
},
4041
},

src/store/module/context.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export default {
4343

4444
const index = state.entity.indexOf(content)
4545

46-
state.totalEntityCreated--
4746
state.entity.splice(index, 1)
4847
},
4948
switchInPage(state: any, obj: Record<any, any>) {

src/store/module/project.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { ProjectState } from '@/types/project'
22
import { useText } from '@/use/text'
33
import { useFormat } from '@/use/format'
4-
import { ContextState } from '@/types/context'
4+
import { ContextState, ContextStatePageContent } from '@/types/context'
5+
import { useI18n } from 'vue-i18n'
56

67
export default {
78
namespaced: true,
@@ -66,13 +67,13 @@ export default {
6667

6768
const init: ContextState = {
6869
id: state.totalPagesCreated,
69-
totalEntityCreated: 0,
70+
totalEntityCreated: 2,
7071
onlyHeadingOne: false,
7172
entity: [
7273
{
7374
id: 0,
7475
type: 'heading-one',
75-
raw: state.nameRaw,
76+
raw: 'Untitled',
7677
createdAt: useFormat().actually(),
7778
updatedAt: useFormat().actually(),
7879
},
@@ -89,6 +90,17 @@ export default {
8990
state.pageLoaded = init.id
9091
state.pages.push(init)
9192
},
93+
deletePage(state: any, context: ContextState) {
94+
const content = state.pages.find(
95+
(content: ContextStatePageContent) => content.id === context.id
96+
)
97+
98+
if (!content) return
99+
100+
const index = state.pages.indexOf(content)
101+
102+
state.pages.splice(index, 1)
103+
},
92104
},
93105
actions: {},
94106
getters: {},

src/tailwind.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
@apply text-black dark:text-gray-200;
2222
}
2323

24+
.wb-icon {
25+
@apply text-black dark:text-gray-200 hover:text-gray-700 dark:hover:text-white;
26+
}
27+
2428
.wb-background-color {
2529
@apply bg-gray-100 dark:bg-gray-700;
2630
}

0 commit comments

Comments
 (0)