Skip to content

Commit 43d3826

Browse files
committed
chore: lint
1 parent d117e8b commit 43d3826

11 files changed

Lines changed: 167 additions & 80 deletions

File tree

packages/app/src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@
3434
EntityHistoryPlugin(),
3535
CharactersPlugin(),
3636
ProgressBarPlugin(),
37-
EditorWindowPlugin()
37+
EditorWindowPlugin(),
3838
]).init()
3939
</script>
Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<template>
22
<div @mouseleave="n = false" @mouseenter="n = true">
3-
<span
4-
class="wb-header-button"
5-
:class="[n ? 'text-theme-icon-active' : '']"
6-
>
3+
<span class="wb-header-button" :class="[n ? 'text-theme-icon-active' : '']">
74
<div class="flex items-center pointer-events-none">
85
<HeroIcon class="h-9 w-9 lg:(w-7 h-7) mr-0 md:mr-1">
96
<slot name="icon" />
@@ -21,8 +18,8 @@
2118

2219
<script setup lang="ts">
2320
import { useToggle } from '@vueuse/core'
24-
import { On, usePlugin } from 'better-write-plugin-core';
25-
import { onMounted } from 'vue';
21+
import { On, usePlugin } from 'better-write-plugin-core'
22+
import { onMounted } from 'vue'
2623
2724
const props = defineProps<{
2825
type: 'create' | 'externals' | 'help' | 'project' | 'vault'
@@ -33,41 +30,46 @@
3330
3431
onMounted(() => {
3532
switch (props.type) {
36-
case 'create': On.editor().PluginEditorHeaderCreateOpen(emitter, [
33+
case 'create':
34+
On.editor().PluginEditorHeaderCreateOpen(emitter, [
3735
() => {
3836
n.value = !n.value
3937
},
40-
() => {}
41-
])
42-
break;
43-
case 'externals': On.editor().PluginEditorHeaderExternalsOpen(emitter, [
44-
() => {
45-
n.value = !n.value
46-
},
47-
() => {}
48-
])
49-
break;
50-
case 'help': On.editor().PluginEditorHeaderHelpOpen(emitter, [
51-
() => {
52-
n.value = !n.value
53-
},
54-
() => {}
55-
])
56-
break;
57-
case 'project': On.editor().PluginEditorHeaderProjectOpen(emitter, [
58-
() => {
59-
n.value = !n.value
60-
},
61-
() => {}
62-
])
63-
break;
64-
case 'vault': On.editor().PluginEditorHeaderProjectOpen(emitter, [
65-
() => {
66-
n.value = !n.value
67-
},
68-
() => {}
69-
])
70-
break;
38+
() => {},
39+
])
40+
break
41+
case 'externals':
42+
On.editor().PluginEditorHeaderExternalsOpen(emitter, [
43+
() => {
44+
n.value = !n.value
45+
},
46+
() => {},
47+
])
48+
break
49+
case 'help':
50+
On.editor().PluginEditorHeaderHelpOpen(emitter, [
51+
() => {
52+
n.value = !n.value
53+
},
54+
() => {},
55+
])
56+
break
57+
case 'project':
58+
On.editor().PluginEditorHeaderProjectOpen(emitter, [
59+
() => {
60+
n.value = !n.value
61+
},
62+
() => {},
63+
])
64+
break
65+
case 'vault':
66+
On.editor().PluginEditorHeaderProjectOpen(emitter, [
67+
() => {
68+
n.value = !n.value
69+
},
70+
() => {},
71+
])
72+
break
7173
}
7274
})
7375
</script>

packages/app/src/components/page/editor/header/items/EditorBaseHeaderCreate.vue

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@
2525
@action="ABSOLUTE.pdf.bionicReading = !ABSOLUTE.pdf.bionicReading"
2626
>
2727
<template #icon>
28-
<IconPDF class="mr-2 w-6 h-6" :class="ABSOLUTE.pdf.bionicReading ? 'text-theme-editor-header-list-text-active' : 'opacity-40'" />
28+
<IconPDF
29+
class="mr-2 w-6 h-6"
30+
:class="
31+
ABSOLUTE.pdf.bionicReading
32+
? 'text-theme-editor-header-list-text-active'
33+
: 'opacity-40'
34+
"
35+
/>
2936
</template>
3037
</EditorHeaderItem>
3138
<EditorHeaderItem
@@ -50,7 +57,14 @@
5057
@action="ABSOLUTE.docx.bionicReading = !ABSOLUTE.docx.bionicReading"
5158
>
5259
<template #icon>
53-
<IconDOCX class="mr-2 w-6 h-6" :class="ABSOLUTE.docx.bionicReading ? 'text-theme-editor-header-list-text-active' : 'opacity-40'" />
60+
<IconDOCX
61+
class="mr-2 w-6 h-6"
62+
:class="
63+
ABSOLUTE.docx.bionicReading
64+
? 'text-theme-editor-header-list-text-active'
65+
: 'opacity-40'
66+
"
67+
/>
5468
</template>
5569
</EditorHeaderItem>
5670
<EditorHeaderItem
@@ -63,7 +77,11 @@
6377
</EditorHeaderItem>
6478
<EditorHeaderItem
6579
:text="t('editor.bar.docx.generate')"
66-
@action="plugin.emit('plugin-docx-generate', { bionicReading: ABSOLUTE.docx.bionicReading })"
80+
@action="
81+
plugin.emit('plugin-docx-generate', {
82+
bionicReading: ABSOLUTE.docx.bionicReading,
83+
})
84+
"
6785
>
6886
<template #icon>
6987
<IconDOCX class="mr-2 w-6 h-6" />
@@ -75,7 +93,14 @@
7593
@action="ABSOLUTE.epub.bionicReading = !ABSOLUTE.epub.bionicReading"
7694
>
7795
<template #icon>
78-
<IconEPUB class="mr-2 w-6 h-6" :class="ABSOLUTE.epub.bionicReading ? 'text-theme-editor-header-list-text-active' : 'opacity-40'" />
96+
<IconEPUB
97+
class="mr-2 w-6 h-6"
98+
:class="
99+
ABSOLUTE.epub.bionicReading
100+
? 'text-theme-editor-header-list-text-active'
101+
: 'opacity-40'
102+
"
103+
/>
79104
</template>
80105
</EditorHeaderItem>
81106
<EditorHeaderItem
@@ -145,7 +170,9 @@
145170
const onEPUBGenerate = async () => {
146171
await storage.normalize()
147172
148-
plugin.emit('plugin-epub-generate', { bionicReading: ABSOLUTE.epub.bionicReading })
173+
plugin.emit('plugin-epub-generate', {
174+
bionicReading: ABSOLUTE.epub.bionicReading,
175+
})
149176
}
150177
151178
const onPDFGenerate = async () => {

packages/app/src/components/page/editor/header/items/EditorBaseHeaderProject.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,20 @@
6262
@action="ABSOLUTE.bw.encryptOnExport = !ABSOLUTE.bw.encryptOnExport"
6363
>
6464
<template #icon>
65-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="mr-2 w-6 h-6" :class="ABSOLUTE.bw.encryptOnExport ? 'text-theme-editor-header-list-text-active' : 'opacity-40'">
66-
<path fill="currentColor" d="M12 1a5 5 0 0 1 5 5v2h1a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2h1V6a5 5 0 0 1 5-5zm0 11a2 2 0 0 0-1 3.732V18h2v-2.268A2 2 0 0 0 12 12zm0-9a3 3 0 0 0-3 3v2h6V6a3 3 0 0 0-3-3z"/>
65+
<svg
66+
xmlns="http://www.w3.org/2000/svg"
67+
viewBox="0 0 24 24"
68+
class="mr-2 w-6 h-6"
69+
:class="
70+
ABSOLUTE.bw.encryptOnExport
71+
? 'text-theme-editor-header-list-text-active'
72+
: 'opacity-40'
73+
"
74+
>
75+
<path
76+
fill="currentColor"
77+
d="M12 1a5 5 0 0 1 5 5v2h1a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2h1V6a5 5 0 0 1 5-5zm0 11a2 2 0 0 0-1 3.732V18h2v-2.268A2 2 0 0 0 12 12zm0-9a3 3 0 0 0-3 3v2h6V6a3 3 0 0 0-3-3z"
78+
/>
6779
</svg>
6880
</template>
6981
</EditorHeaderItem>

packages/app/src/use/block/text.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ export const useBlockText = ({
5151
const save = (target: number, raw: string) => {
5252
if (raw === null) return
5353

54-
const clean = raw
55-
.replaceAll(/<br\s*\/?>/gi, '')
56-
.replaceAll('&amp;', '&')
54+
const clean = raw.replaceAll(/<br\s*\/?>/gi, '').replaceAll('&amp;', '&')
5755

5856
CONTEXT.entities[target].raw = clean
5957

packages/extension/src/index.ts

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ const PBKDF2_ITERATIONS = 200_000
4040
const SALT_LEN = 16
4141
const IV_LEN = 12
4242

43-
const deriveKey = async (password: string, salt: Uint8Array): Promise<CryptoKey> => {
43+
const deriveKey = async (
44+
password: string,
45+
salt: Uint8Array,
46+
): Promise<CryptoKey> => {
4447
const keyMaterial = await crypto.subtle.importKey(
4548
'raw',
4649
new TextEncoder().encode(password),
@@ -50,18 +53,26 @@ const deriveKey = async (password: string, salt: Uint8Array): Promise<CryptoKey>
5053
)
5154

5255
return crypto.subtle.deriveKey(
53-
{ name: 'PBKDF2', salt: salt.buffer as ArrayBuffer, iterations: PBKDF2_ITERATIONS, hash: 'SHA-256' },
56+
{
57+
name: 'PBKDF2',
58+
salt: salt.buffer as ArrayBuffer,
59+
iterations: PBKDF2_ITERATIONS,
60+
hash: 'SHA-256',
61+
},
5462
keyMaterial,
5563
{ name: 'AES-GCM', length: 256 },
5664
false,
5765
['encrypt', 'decrypt'],
5866
)
5967
}
6068

61-
export const encryptBW = async (data: string, password: string): Promise<Blob> => {
69+
export const encryptBW = async (
70+
data: string,
71+
password: string,
72+
): Promise<Blob> => {
6273
const salt = crypto.getRandomValues(new Uint8Array(SALT_LEN))
63-
const iv = crypto.getRandomValues(new Uint8Array(IV_LEN))
64-
const key = await deriveKey(password, salt)
74+
const iv = crypto.getRandomValues(new Uint8Array(IV_LEN))
75+
const key = await deriveKey(password, salt)
6576

6677
const ciphertext = new Uint8Array(
6778
await crypto.subtle.encrypt(
@@ -77,10 +88,13 @@ export const encryptBW = async (data: string, password: string): Promise<Blob> =
7788
payload.set(iv, SALT_LEN)
7889
payload.set(ciphertext, SALT_LEN + IV_LEN)
7990

80-
const blobWriter = new BlobWriter()
81-
const zipWriter = new ZipWriter(blobWriter)
91+
const blobWriter = new BlobWriter()
92+
const zipWriter = new ZipWriter(blobWriter)
8293

83-
await zipWriter.add('meta.json', new TextReader(JSON.stringify({ encrypted: true, version: 1 })))
94+
await zipWriter.add(
95+
'meta.json',
96+
new TextReader(JSON.stringify({ encrypted: true, version: 1 })),
97+
)
8498
await zipWriter.add('encrypted.bin', new BlobReader(new Blob([payload])))
8599
await zipWriter.add('mimetype', writeMimetype())
86100
await zipWriter.close()
@@ -94,27 +108,34 @@ const isEncryptedZip = async (zipReader: ZipReader<Blob>): Promise<boolean> => {
94108
return entries.some((e: Entry) => e.filename === 'meta.json')
95109
}
96110

97-
export const decryptBW = async (blob: Blob, password: string): Promise<ProjectObject> => {
111+
export const decryptBW = async (
112+
blob: Blob,
113+
password: string,
114+
): Promise<ProjectObject> => {
98115
const zipReader = new ZipReader(new BlobReader(blob))
99-
const entries = await zipReader.getEntries()
116+
const entries = await zipReader.getEntries()
100117

101118
const encEntry = entries.find((e) => e.filename === 'encrypted.bin')
102119

103120
if (!encEntry) throw new Error('encrypted.bin not found')
104121

105122
const payloadBlob = await (encEntry as FileEntry).getData(new BlobWriter())
106-
const payload = new Uint8Array(await payloadBlob.arrayBuffer())
123+
const payload = new Uint8Array(await payloadBlob.arrayBuffer())
107124

108-
const salt = payload.slice(0, SALT_LEN)
109-
const iv = payload.slice(SALT_LEN, SALT_LEN + IV_LEN)
125+
const salt = payload.slice(0, SALT_LEN)
126+
const iv = payload.slice(SALT_LEN, SALT_LEN + IV_LEN)
110127
const ciphertext = payload.slice(SALT_LEN + IV_LEN)
111128

112129
const key = await deriveKey(password, salt)
113130

114131
let plaintext: ArrayBuffer
115132

116133
try {
117-
plaintext = await crypto.subtle.decrypt({ name: 'AES-GCM', iv }, key, ciphertext)
134+
plaintext = await crypto.subtle.decrypt(
135+
{ name: 'AES-GCM', iv },
136+
key,
137+
ciphertext,
138+
)
118139
} catch {
119140
throw new Error('wrong-password')
120141
}
@@ -124,14 +145,18 @@ export const decryptBW = async (blob: Blob, password: string): Promise<ProjectOb
124145
return destr(new TextDecoder().decode(plaintext))
125146
}
126147

127-
export const readBW = async (blob: Blob, getPassword?: () => Promise<string | null>): Promise<ProjectObject> => {
148+
export const readBW = async (
149+
blob: Blob,
150+
getPassword?: () => Promise<string | null>,
151+
): Promise<ProjectObject> => {
128152
// peek at entries to decide the path
129-
const peekReader = new ZipReader(new BlobReader(blob))
130-
const encrypted = await isEncryptedZip(peekReader)
153+
const peekReader = new ZipReader(new BlobReader(blob))
154+
const encrypted = await isEncryptedZip(peekReader)
131155
await peekReader.close()
132156

133157
if (encrypted) {
134-
if (!getPassword) throw new Error('File is encrypted but no password provider was given')
158+
if (!getPassword)
159+
throw new Error('File is encrypted but no password provider was given')
135160

136161
const password = await getPassword()
137162

@@ -142,9 +167,9 @@ export const readBW = async (blob: Blob, getPassword?: () => Promise<string | nu
142167

143168
// original unencrypted path
144169
const zipFileReader = new BlobReader(blob)
145-
const writer = new TextWriter()
146-
const zipReader = new ZipReader(zipFileReader)
147-
const firstEntry = (await zipReader.getEntries()).shift()
170+
const writer = new TextWriter()
171+
const zipReader = new ZipReader(zipFileReader)
172+
const firstEntry = (await zipReader.getEntries()).shift()
148173

149174
// @ts-expect-error
150175
const data = await firstEntry.getData(writer)

packages/plugin-editor-window/src/drop.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export const PluginDropSet = (
3131
hooks.project.onLoadProject(data, false)
3232
} catch (e: any) {
3333
if (e?.message === 'wrong-password') {
34-
hooks.toast.error(hooks.i18n.t('toast.project.bw.passwordWrong'))
34+
hooks.toast.error(
35+
hooks.i18n.t('toast.project.bw.passwordWrong'),
36+
)
3537
} else if (e?.message !== 'cancelled') {
3638
hooks.toast.error(hooks.i18n.t('toast.generics.error'))
3739
}

packages/plugin-exporter-docx/src/set.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ export const PluginDocxSet = (
3030
) => {
3131
const { isLoading } = hooks.vueuse.integration.progress
3232

33-
const purge = (raw: string, custom: Record<string, any>, bionicReading = false): DocxPurge => {
33+
const purge = (
34+
raw: string,
35+
custom: Record<string, any>,
36+
bionicReading = false,
37+
): DocxPurge => {
3438
const arr: DocxPurge = []
3539

3640
const ast = parse(hooks.substitution.purge(raw))

0 commit comments

Comments
 (0)