Skip to content

Commit 257cc5d

Browse files
committed
Update Nuxt
1 parent be1aa14 commit 257cc5d

File tree

9 files changed

+1764
-1353
lines changed

9 files changed

+1764
-1353
lines changed

app.vue

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,24 @@ export default defineComponent({
1111
setup() {
1212
const { public: { appName, appTitle } } = useConfig()
1313
const mq = useMq()
14+
const router = useRouter()
1415
const { store } = useVuex()
1516
1617
const isMounted = ref(false)
1718
19+
const flow = computed(() => {
20+
// A param to indicate a user flow (e.g. completing sign-up or sign-in).
21+
return router.currentRoute.value.query.flow
22+
})
23+
24+
const showChangeLog = computed(() => {
25+
return router.currentRoute.value.path === '/docs/new' && !router.currentRoute.value.query.ci
26+
})
27+
28+
const ligatures = computed(() => {
29+
return store.state.settings.editor.ligatures
30+
})
31+
1832
onMounted(async () => {
1933
isMounted.value = true
2034
@@ -50,21 +64,12 @@ export default defineComponent({
5064
})
5165
5266
return {
67+
flow,
68+
ligatures,
69+
showChangeLog,
5370
sizes,
5471
}
5572
},
56-
computed: {
57-
flow() {
58-
// A param to indicate a user flow (e.g. completing sign-up or sign-in).
59-
return this.$route.query.flow
60-
},
61-
showChangeLog() {
62-
return this.$route.path === '/docs/new' && !this.$route.query.ci
63-
},
64-
ligatures() {
65-
return this.$store.state.settings.editor.ligatures
66-
},
67-
},
6873
})
6974
</script>
7075

components/Doc.vue

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default {
2222
allowDiscard: Boolean,
2323
},
2424
setup(props) {
25+
const { store } = useVuex()
2526
const html = computed(() => {
2627
const rawHtml = toHtml(props.text)
2728
@@ -33,23 +34,25 @@ export default {
3334
return rawHtml
3435
})
3536
37+
const updated = computed(() => {
38+
return `Updated on ${moment(props.updatedAt).format('ddd, MMM Do, YYYY [at] h:mm A')}`
39+
})
40+
41+
const discard = () => {
42+
store.dispatch(DISCARD_DOCUMENT, { id: props.id })
43+
}
44+
45+
const restore = () => {
46+
store.dispatch(RESTORE_DOCUMENT, { id: props.id })
47+
}
48+
3649
return {
50+
discard,
3751
html,
52+
restore,
53+
updated,
3854
}
3955
},
40-
computed: {
41-
updated() {
42-
return `Updated on ${moment(this.updatedAt).format('ddd, MMM Do, YYYY [at] h:mm A')}`
43-
},
44-
},
45-
methods: {
46-
discard() {
47-
this.$store.dispatch(DISCARD_DOCUMENT, { id: this.id })
48-
},
49-
restore() {
50-
this.$store.dispatch(RESTORE_DOCUMENT, { id: this.id })
51-
},
52-
},
5356
}
5457
</script>
5558

components/DocEditor.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default defineComponent({
2929
const { user } = useUser()
3030
const coreEditor = ref()
3131
const { isMounted } = useVue()
32+
const { store } = useVuex()
3233
3334
const focus = () => {
3435
// Focus the editor.
@@ -59,6 +60,7 @@ export default defineComponent({
5960
coreEditor,
6061
focus,
6162
isMounted,
63+
store,
6264
uploadFiles,
6365
user,
6466
}
@@ -70,7 +72,7 @@ export default defineComponent({
7072
},
7173
computed: {
7274
docs() {
73-
return this.$store.getters.kept.reduce((docs: any[], doc: any) => {
75+
return this.store.getters.kept.reduce((docs: any[], doc: any) => {
7476
if (doc.id && doc.id !== this.doc?.id && doc.headers.length > 0) {
7577
docs.push({
7678
id: doc.id,
@@ -85,7 +87,7 @@ export default defineComponent({
8587
return this.settings?.readability.maxWidthInChars
8688
},
8789
options(): Options {
88-
const isExperimentalEnabled = this.$store.state.settings.experimental
90+
const isExperimentalEnabled = this.store.state.settings.experimental
8991
const hasLazyPlugins = this.lazyPlugins.length > 0
9092
9193
return {
@@ -134,7 +136,7 @@ export default defineComponent({
134136
return this.settings?.spellcheck
135137
},
136138
tags() {
137-
return this.$store.getters.allTags.filter((tag: string) => {
139+
return this.store.getters.allTags.filter((tag: string) => {
138140
return !this.doc?.tags.includes(tag)
139141
})
140142
},

components/DocList.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export default defineComponent({
1515
emits: ['update:query'],
1616
setup(props) {
1717
const { query } = toRefs(props)
18+
const { store } = useVuex()
19+
const router = useRouter()
1820
1921
const isEditing = ref(false)
2022
const searchQuery = ref(query.value || '')
@@ -57,8 +59,10 @@ export default defineComponent({
5759
searchResults,
5860
finalDocs,
5961
isEditing,
62+
router,
6063
searchQuery,
6164
selectedDocs,
65+
store,
6266
visibleCount,
6367
visibleDocs,
6468
}
@@ -84,7 +88,7 @@ export default defineComponent({
8488
this.visibleCount += 25
8589
},
8690
mergeDocs() {
87-
this.$store.dispatch(MERGE_DOCUMENTS, this.selectedDocs)
91+
this.store.dispatch(MERGE_DOCUMENTS, this.selectedDocs)
8892
8993
this.selectedDocs = []
9094
},
@@ -107,7 +111,7 @@ export default defineComponent({
107111
}
108112
}
109113
} else {
110-
this.$router.push({ path: `/docs/${id}` })
114+
this.router.push({ path: `/docs/${id}` })
111115
}
112116
},
113117
},

components/SettingsEditor.vue

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,94 +14,101 @@ import {
1414
} from '#root/src/store/modules/settings'
1515
1616
export default defineComponent({
17+
setup() {
18+
const { store } = useVuex()
19+
20+
return {
21+
store,
22+
}
23+
},
1724
computed: {
1825
imagesEnabled: {
1926
get() {
20-
return this.$store.state.settings.editor.images.enabled
27+
return this.store.state.settings.editor.images.enabled
2128
},
2229
set(value: any) {
23-
this.$store.dispatch(SET_EDITOR_IMAGES_ENABLED, value)
30+
this.store.dispatch(SET_EDITOR_IMAGES_ENABLED, value)
2431
},
2532
},
2633
ligatures: {
2734
get() {
28-
return this.$store.state.settings.editor.ligatures
35+
return this.store.state.settings.editor.ligatures
2936
},
3037
set(value: any) {
31-
this.$store.commit(SET_EDITOR_LIGATURES, value)
38+
this.store.commit(SET_EDITOR_LIGATURES, value)
3239
},
3340
},
3441
listsEnabled: {
3542
get() {
36-
return this.$store.state.settings.editor.lists.enabled
43+
return this.store.state.settings.editor.lists.enabled
3744
},
3845
set(value: any) {
39-
this.$store.commit(SET_EDITOR_LISTS_ENABLED, value)
46+
this.store.commit(SET_EDITOR_LISTS_ENABLED, value)
4047
},
4148
},
4249
readabilityEnabled: {
4350
get() {
44-
return this.$store.state.settings.editor.readability.enabled
51+
return this.store.state.settings.editor.readability.enabled
4552
},
4653
set(value: any) {
47-
this.$store.commit(SET_EDITOR_READABILITY_ENABLED, value)
54+
this.store.commit(SET_EDITOR_READABILITY_ENABLED, value)
4855
},
4956
},
5057
readabilityMaxWidth: {
5158
get() {
52-
return this.$store.state.settings.editor.readability.maxWidthInChars
59+
return this.store.state.settings.editor.readability.maxWidthInChars
5360
},
5461
set(value: any) {
55-
this.$store.commit(SET_EDITOR_READABILITY_MAX_WIDTH, value)
62+
this.store.commit(SET_EDITOR_READABILITY_MAX_WIDTH, value)
5663
},
5764
},
5865
readabilityWordsPerMinute: {
5966
get() {
60-
return this.$store.state.settings.editor.readability.wordsPerMinute
67+
return this.store.state.settings.editor.readability.wordsPerMinute
6168
},
6269
set(value: any) {
63-
this.$store.commit(SET_EDITOR_READABILITY_WORDS_PER_MINUTE, value)
70+
this.store.commit(SET_EDITOR_READABILITY_WORDS_PER_MINUTE, value)
6471
},
6572
},
6673
showCaptions: {
6774
get() {
68-
return this.$store.state.settings.editor.images.showCaptions
75+
return this.store.state.settings.editor.images.showCaptions
6976
},
7077
set(value: any) {
71-
this.$store.dispatch(SET_EDITOR_IMAGES_SHOW_CAPTIONS, value)
78+
this.store.dispatch(SET_EDITOR_IMAGES_SHOW_CAPTIONS, value)
7279
},
7380
},
7481
spellcheck: {
7582
get() {
76-
return this.$store.state.settings.editor.spellcheck
83+
return this.store.state.settings.editor.spellcheck
7784
},
7885
set(value: any) {
79-
this.$store.commit(SET_EDITOR_SPELLCHECK, value)
86+
this.store.commit(SET_EDITOR_SPELLCHECK, value)
8087
},
8188
},
8289
tabSize: {
8390
get(): number {
84-
return this.$store.state.settings.editor.tabSize
91+
return this.store.state.settings.editor.tabSize
8592
},
8693
set(value: number) {
87-
this.$store.dispatch(SET_EDITOR_TAB_SIZE, value || 2)
94+
this.store.dispatch(SET_EDITOR_TAB_SIZE, value || 2)
8895
},
8996
},
9097
toolbar: {
9198
get() {
92-
return this.$store.state.settings.editor.toolbar
99+
return this.store.state.settings.editor.toolbar
93100
},
94101
set(value: any) {
95-
this.$store.commit(SET_EDITOR_TOOLBAR, value)
102+
this.store.commit(SET_EDITOR_TOOLBAR, value)
96103
},
97104
},
98105
vim: {
99106
// Todo: Use a new setting for Vim.
100107
get() {
101-
return this.$store.state.settings.editor.keyMap === 'vim'
108+
return this.store.state.settings.editor.keyMap === 'vim'
102109
},
103110
set(value: any) {
104-
this.$store.dispatch(SET_EDITOR_KEY_MAP, value ? 'vim' : 'default')
111+
this.store.dispatch(SET_EDITOR_KEY_MAP, value ? 'vim' : 'default')
105112
},
106113
},
107114
},

components/settings/Encryption.vue

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ import { TOUCH_DOCUMENT } from '#root/src/store/actions'
44
import { SET_CRYPTO_ENABLED, SET_CRYPTO_KEYS } from '#root/src/store/modules/settings'
55
66
export default {
7+
setup() {
8+
const { store } = useVuex()
9+
10+
return {
11+
store,
12+
}
13+
},
714
data() {
815
return {
916
togglingCrypto: false,
@@ -15,35 +22,35 @@ export default {
1522
},
1623
privateKey: {
1724
get() {
18-
return this.$store.state.settings.crypto.privateKey ?? ''
25+
return this.store.state.settings.crypto.privateKey ?? ''
1926
},
2027
set(value: string) {
21-
this.$store.commit(SET_CRYPTO_KEYS, {
28+
this.store.commit(SET_CRYPTO_KEYS, {
2229
privateKey: value.trim(),
2330
})
2431
},
2532
},
2633
publicKey: {
2734
get() {
28-
return this.$store.state.settings.crypto.publicKey ?? ''
35+
return this.store.state.settings.crypto.publicKey ?? ''
2936
},
3037
set(value: string) {
31-
this.$store.commit(SET_CRYPTO_KEYS, {
38+
this.store.commit(SET_CRYPTO_KEYS, {
3239
publicKey: value.trim(),
3340
})
3441
},
3542
},
3643
toggleCrypto: {
3744
get() {
38-
return this.$store.state.settings.crypto.enabled
45+
return this.store.state.settings.crypto.enabled
3946
},
4047
async set(value: boolean) {
4148
this.togglingCrypto = true
4249
43-
await this.$store.dispatch(SET_CRYPTO_ENABLED, value)
50+
await this.store.dispatch(SET_CRYPTO_ENABLED, value)
4451
await Promise.all(
45-
this.$store.getters.decrypted.map((doc: any) => {
46-
return this.$store.dispatch(TOUCH_DOCUMENT, doc)
52+
this.store.getters.decrypted.map((doc: any) => {
53+
return this.store.dispatch(TOUCH_DOCUMENT, doc)
4754
}),
4855
)
4956

0 commit comments

Comments
 (0)