@fiduswriter/editor 0.1.47 → 0.1.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clipboard/copy/serializers.js.map +1 -1
- package/dist/collab/doc.js.map +1 -1
- package/dist/collab/merge/index.d.ts.map +1 -1
- package/dist/collab/merge/index.js +1 -1
- package/dist/collab/merge/index.js.map +1 -1
- package/dist/comments/editors/comment.d.ts.map +1 -1
- package/dist/comments/editors/comment.js +1 -1
- package/dist/comments/editors/comment.js.map +1 -1
- package/dist/comments/editors/notify.d.ts +2 -1
- package/dist/comments/editors/notify.d.ts.map +1 -1
- package/dist/comments/editors/notify.js +2 -3
- package/dist/comments/editors/notify.js.map +1 -1
- package/dist/comments/interactions.js +2 -2
- package/dist/comments/interactions.js.map +1 -1
- package/dist/contacts/add_dialog.d.ts +3 -1
- package/dist/contacts/add_dialog.d.ts.map +1 -1
- package/dist/contacts/add_dialog.js +11 -8
- package/dist/contacts/add_dialog.js.map +1 -1
- package/dist/databases/images.d.ts.map +1 -1
- package/dist/databases/images.js +8 -5
- package/dist/databases/images.js.map +1 -1
- package/dist/dialogs/citation.js +1 -1
- package/dist/dialogs/citation.js.map +1 -1
- package/dist/dialogs/figure.d.ts.map +1 -1
- package/dist/dialogs/figure.js +2 -1
- package/dist/dialogs/figure.js.map +1 -1
- package/dist/document_template/exporter.d.ts +8 -2
- package/dist/document_template/exporter.d.ts.map +1 -1
- package/dist/document_template/exporter.js +4 -8
- package/dist/document_template/exporter.js.map +1 -1
- package/dist/document_template/index.d.ts.map +1 -1
- package/dist/document_template/index.js +1 -1
- package/dist/document_template/index.js.map +1 -1
- package/dist/documents/access_rights/index.d.ts +9 -2
- package/dist/documents/access_rights/index.d.ts.map +1 -1
- package/dist/documents/access_rights/index.js +25 -12
- package/dist/documents/access_rights/index.js.map +1 -1
- package/dist/e2ee/passphrase_urls.d.ts +14 -0
- package/dist/e2ee/passphrase_urls.d.ts.map +1 -0
- package/dist/e2ee/passphrase_urls.js +27 -0
- package/dist/e2ee/passphrase_urls.js.map +1 -0
- package/dist/exporter/native/copy.d.ts +2 -1
- package/dist/exporter/native/copy.d.ts.map +1 -1
- package/dist/exporter/native/copy.js +11 -10
- package/dist/exporter/native/copy.js.map +1 -1
- package/dist/exporter/native/file.d.ts +8 -1
- package/dist/exporter/native/file.d.ts.map +1 -1
- package/dist/exporter/native/file.js +2 -2
- package/dist/exporter/native/file.js.map +1 -1
- package/dist/exporter/native/revision.js +4 -3
- package/dist/exporter/native/revision.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -15
- package/dist/index.js.map +1 -1
- package/dist/menus/headerbar/model.d.ts.map +1 -1
- package/dist/menus/headerbar/model.js +10 -8
- package/dist/menus/headerbar/model.js.map +1 -1
- package/dist/no_collab_save/index.d.ts +1 -1
- package/dist/no_collab_save/index.d.ts.map +1 -1
- package/dist/no_collab_save/index.js +13 -12
- package/dist/no_collab_save/index.js.map +1 -1
- package/dist/state_plugins/inline_reference/dropup.js.map +1 -1
- package/dist/state_plugins/settings.js.map +1 -1
- package/dist/types.d.ts +128 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +9 -6
- package/src/clipboard/copy/serializers.ts +1 -1
- package/src/collab/doc.ts +1 -1
- package/src/collab/merge/index.ts +1 -0
- package/src/comments/editors/comment.ts +6 -1
- package/src/comments/editors/notify.ts +3 -2
- package/src/comments/interactions.ts +2 -2
- package/src/contacts/add_dialog.ts +15 -8
- package/src/databases/images.ts +21 -18
- package/src/dialogs/citation.ts +3 -3
- package/src/dialogs/figure.ts +29 -29
- package/src/document_template/exporter.ts +10 -8
- package/src/document_template/index.ts +3 -2
- package/src/documents/access_rights/index.ts +44 -23
- package/src/exporter/native/copy.ts +18 -10
- package/src/exporter/native/file.ts +9 -1
- package/src/exporter/native/revision.ts +16 -16
- package/src/index.ts +46 -34
- package/src/menus/headerbar/model.ts +17 -9
- package/src/no_collab_save/index.ts +20 -22
- package/src/state_plugins/inline_reference/dropup.ts +2 -2
- package/src/state_plugins/settings.ts +1 -1
- package/src/types.ts +92 -2
|
@@ -224,7 +224,8 @@ export class ModDocumentTemplate {
|
|
|
224
224
|
"select"
|
|
225
225
|
) as HTMLSelectElement
|
|
226
226
|
).value as any,
|
|
227
|
-
e2eeOptions
|
|
227
|
+
e2eeOptions,
|
|
228
|
+
editor.app.apiConnectors.documentImport
|
|
228
229
|
)
|
|
229
230
|
copier
|
|
230
231
|
.init()
|
|
@@ -232,7 +233,7 @@ export class ModDocumentTemplate {
|
|
|
232
233
|
const url = targetE2EE
|
|
233
234
|
? `/document/${docInfo.id}/?e2ee=1`
|
|
234
235
|
: `/document/${docInfo.id}/`
|
|
235
|
-
|
|
236
|
+
editor.app.goTo(url)
|
|
236
237
|
})
|
|
237
238
|
.catch(() => false)
|
|
238
239
|
selectTemplateDialog.close()
|
|
@@ -6,13 +6,12 @@ import {
|
|
|
6
6
|
enableDatePicker,
|
|
7
7
|
ensureCSS,
|
|
8
8
|
findTarget,
|
|
9
|
-
post,
|
|
10
|
-
postJson,
|
|
11
9
|
setCheckableLabel
|
|
12
10
|
} from "fwtoolkit"
|
|
13
11
|
import type {ContentMenuInit} from "fwtoolkit/content_menu"
|
|
14
12
|
|
|
15
13
|
import {AddContactDialog} from "../../contacts/add_dialog.js"
|
|
14
|
+
import type {EditorContactsApi, EditorDocumentApi} from "../../types.js"
|
|
16
15
|
import {
|
|
17
16
|
collaboratorsTemplate,
|
|
18
17
|
contactsTemplate,
|
|
@@ -66,6 +65,8 @@ interface AccessRightsTabOptions {
|
|
|
66
65
|
onShareSuccess?: (accessRights: AccessRight[]) => void
|
|
67
66
|
settings: Record<string, unknown>
|
|
68
67
|
container?: HTMLElement | null
|
|
68
|
+
documentApi: EditorDocumentApi
|
|
69
|
+
contactsApi: EditorContactsApi
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
interface AccessRightMenuItem {
|
|
@@ -146,6 +147,8 @@ export class AccessRightsTab {
|
|
|
146
147
|
container: HTMLElement | null
|
|
147
148
|
accessRights: AccessRight[]
|
|
148
149
|
dialogTabs!: DialogTabs
|
|
150
|
+
documentApi: EditorDocumentApi
|
|
151
|
+
contactsApi: EditorContactsApi
|
|
149
152
|
|
|
150
153
|
constructor({
|
|
151
154
|
documentIds,
|
|
@@ -155,7 +158,9 @@ export class AccessRightsTab {
|
|
|
155
158
|
documentPassword = "",
|
|
156
159
|
onShareSuccess,
|
|
157
160
|
settings,
|
|
158
|
-
container = null
|
|
161
|
+
container = null,
|
|
162
|
+
documentApi,
|
|
163
|
+
contactsApi
|
|
159
164
|
}: AccessRightsTabOptions) {
|
|
160
165
|
this.documentIds = documentIds
|
|
161
166
|
this.contacts = contacts
|
|
@@ -168,12 +173,15 @@ export class AccessRightsTab {
|
|
|
168
173
|
this.settings = settings
|
|
169
174
|
this.container = container || null
|
|
170
175
|
this.accessRights = []
|
|
176
|
+
this.documentApi = documentApi
|
|
177
|
+
this.contactsApi = contactsApi
|
|
171
178
|
}
|
|
172
179
|
|
|
173
180
|
load(): Promise<void> {
|
|
174
|
-
return
|
|
175
|
-
|
|
176
|
-
|
|
181
|
+
return this.documentApi
|
|
182
|
+
.getAccessRights({
|
|
183
|
+
document_ids: this.documentIds
|
|
184
|
+
})
|
|
177
185
|
.catch(error => {
|
|
178
186
|
addAlert("error", gettext("Cannot load document access data."))
|
|
179
187
|
throw error
|
|
@@ -521,9 +529,8 @@ export class AccessRightsTab {
|
|
|
521
529
|
return
|
|
522
530
|
}
|
|
523
531
|
listEl.innerHTML = `<p class="fw-ar-loading">${gettext("Loading…")}</p>`
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
})
|
|
532
|
+
this.documentApi
|
|
533
|
+
.listShareTokens(this.singleDocumentId as number)
|
|
527
534
|
.then(({json}: {json: unknown}) => {
|
|
528
535
|
const data = json as {tokens: ShareToken[]}
|
|
529
536
|
listEl.innerHTML = shareTokenListTemplate({
|
|
@@ -564,12 +571,13 @@ export class AccessRightsTab {
|
|
|
564
571
|
"#share-token-note"
|
|
565
572
|
) as HTMLInputElement
|
|
566
573
|
).value.trim()
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
574
|
+
this.documentApi
|
|
575
|
+
.createShareToken({
|
|
576
|
+
document_id: this.singleDocumentId,
|
|
577
|
+
rights,
|
|
578
|
+
expires_at: expiresRaw || "",
|
|
579
|
+
note
|
|
580
|
+
} as Record<string, unknown>)
|
|
573
581
|
.then(({json}: {json: unknown}) => {
|
|
574
582
|
const data = json as ShareToken
|
|
575
583
|
let shareUrl = data.share_url
|
|
@@ -624,7 +632,8 @@ export class AccessRightsTab {
|
|
|
624
632
|
}
|
|
625
633
|
|
|
626
634
|
revokeShareToken(tokenId: number, rowEl: HTMLElement): void {
|
|
627
|
-
|
|
635
|
+
this.documentApi
|
|
636
|
+
.revokeShareToken(tokenId)
|
|
628
637
|
.then(({json}: {json: unknown}) => {
|
|
629
638
|
const data = json as {success: boolean}
|
|
630
639
|
if (data.success) {
|
|
@@ -648,10 +657,11 @@ export class AccessRightsTab {
|
|
|
648
657
|
|
|
649
658
|
submit(): Promise<void> {
|
|
650
659
|
const accessRights = collectAccessRights(this.container!)
|
|
651
|
-
return
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
660
|
+
return this.documentApi
|
|
661
|
+
.saveAccessRights({
|
|
662
|
+
document_ids: this.documentIds,
|
|
663
|
+
access_rights: accessRights
|
|
664
|
+
})
|
|
655
665
|
.then(() => {
|
|
656
666
|
addAlert("success", gettext("Access rights have been saved"))
|
|
657
667
|
if (this.onShareSuccess) {
|
|
@@ -676,6 +686,8 @@ export class DocumentAccessRightsDialog {
|
|
|
676
686
|
documentPassword: string
|
|
677
687
|
onShareSuccess?: (accessRights: AccessRight[]) => void
|
|
678
688
|
settings: Record<string, unknown>
|
|
689
|
+
contactsApi: EditorContactsApi
|
|
690
|
+
documentApi: EditorDocumentApi
|
|
679
691
|
tab!: AccessRightsTab
|
|
680
692
|
dialog!: Dialog
|
|
681
693
|
|
|
@@ -686,7 +698,9 @@ export class DocumentAccessRightsDialog {
|
|
|
686
698
|
e2ee: boolean,
|
|
687
699
|
documentPassword = "",
|
|
688
700
|
onShareSuccess?: (accessRights: AccessRight[]) => void,
|
|
689
|
-
settings: Record<string, unknown> = {}
|
|
701
|
+
settings: Record<string, unknown> = {},
|
|
702
|
+
contactsApi?: EditorContactsApi,
|
|
703
|
+
documentApi?: EditorDocumentApi
|
|
690
704
|
) {
|
|
691
705
|
this.documentIds = documentIds
|
|
692
706
|
this.contacts = contacts
|
|
@@ -695,6 +709,8 @@ export class DocumentAccessRightsDialog {
|
|
|
695
709
|
this.documentPassword = documentPassword
|
|
696
710
|
this.onShareSuccess = onShareSuccess
|
|
697
711
|
this.settings = settings
|
|
712
|
+
this.contactsApi = contactsApi as EditorContactsApi
|
|
713
|
+
this.documentApi = documentApi as EditorDocumentApi
|
|
698
714
|
}
|
|
699
715
|
|
|
700
716
|
init(): void {
|
|
@@ -705,7 +721,9 @@ export class DocumentAccessRightsDialog {
|
|
|
705
721
|
e2ee: this.e2ee,
|
|
706
722
|
documentPassword: this.documentPassword,
|
|
707
723
|
onShareSuccess: this.onShareSuccess,
|
|
708
|
-
settings: this.settings
|
|
724
|
+
settings: this.settings,
|
|
725
|
+
documentApi: this.documentApi,
|
|
726
|
+
contactsApi: this.contactsApi
|
|
709
727
|
})
|
|
710
728
|
this.tab.load().then(() => this.createDialog())
|
|
711
729
|
}
|
|
@@ -722,7 +740,10 @@ export class DocumentAccessRightsDialog {
|
|
|
722
740
|
: gettext("Add contact"),
|
|
723
741
|
classes: "fw-light fw-add-button",
|
|
724
742
|
click: () => {
|
|
725
|
-
const dialog = new AddContactDialog(
|
|
743
|
+
const dialog = new AddContactDialog(
|
|
744
|
+
this.settings,
|
|
745
|
+
this.contactsApi
|
|
746
|
+
)
|
|
726
747
|
dialog.init().then(contactsData => {
|
|
727
748
|
;(contactsData as Contact[]).forEach(contactData => {
|
|
728
749
|
if (contactData.id) {
|
|
@@ -9,9 +9,10 @@ import type {
|
|
|
9
9
|
} from "@fiduswriter/document"
|
|
10
10
|
import {SaveCopy as GenericSaveCopy} from "@fiduswriter/document/exporter/native"
|
|
11
11
|
import {NativeImporter} from "@fiduswriter/document/importer/native"
|
|
12
|
-
import {addAlert, addProgress, gettext,
|
|
12
|
+
import {addAlert, addProgress, gettext, shortFileTitle} from "fwtoolkit"
|
|
13
13
|
import {E2EEEncryptor} from "fwtoolkit/e2ee/encryptor"
|
|
14
14
|
import {E2EEKeyManager} from "fwtoolkit/e2ee/key-manager"
|
|
15
|
+
import type {EditorDocumentImportApi} from "../../types.js"
|
|
15
16
|
|
|
16
17
|
type ProgressCallback = (message: string, percentage?: number | null) => void
|
|
17
18
|
|
|
@@ -115,7 +116,8 @@ async function maybeDecryptImage(
|
|
|
115
116
|
|
|
116
117
|
function createNativeImporterBackend(
|
|
117
118
|
_user: User,
|
|
118
|
-
_e2eeOptions: E2EEOptions | null
|
|
119
|
+
_e2eeOptions: E2EEOptions | null,
|
|
120
|
+
documentImportApi: EditorDocumentImportApi
|
|
119
121
|
): NativeImporterBackend {
|
|
120
122
|
return {
|
|
121
123
|
createDoc: (template, importId, path, e2ee, files) => {
|
|
@@ -140,7 +142,8 @@ function createNativeImporterBackend(
|
|
|
140
142
|
jsonData.e2ee_iterations = e2ee.iterations
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
|
-
return
|
|
145
|
+
return documentImportApi
|
|
146
|
+
.createDoc(jsonData, files)
|
|
144
147
|
.then(({json}) => {
|
|
145
148
|
const data = json as Record<string, unknown>
|
|
146
149
|
return {
|
|
@@ -157,9 +160,6 @@ function createNativeImporterBackend(
|
|
|
157
160
|
},
|
|
158
161
|
saveImages: async (images, docId, e2ee) => {
|
|
159
162
|
const isE2EE = e2ee?.enabled
|
|
160
|
-
const endpoint = isE2EE
|
|
161
|
-
? "/api/document/e2ee_image/"
|
|
162
|
-
: "/api/document/import/image/"
|
|
163
163
|
const imageTranslationTable: Record<number | string, number> = {}
|
|
164
164
|
await Promise.all(
|
|
165
165
|
Object.values(images.db).map(async imageEntry => {
|
|
@@ -184,7 +184,9 @@ function createNativeImporterBackend(
|
|
|
184
184
|
filename: entry.image.split("/").pop() as string
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
const {json} =
|
|
187
|
+
const {json} = isE2EE
|
|
188
|
+
? await documentImportApi.saveE2EEImage(jsonData, files)
|
|
189
|
+
: await documentImportApi.saveImage(jsonData, files)
|
|
188
190
|
const response = json as Record<string, unknown>
|
|
189
191
|
imageTranslationTable[entry.id] = response.id as number
|
|
190
192
|
})
|
|
@@ -210,7 +212,8 @@ function createNativeImporterBackend(
|
|
|
210
212
|
e2ee.key
|
|
211
213
|
)
|
|
212
214
|
}
|
|
213
|
-
return
|
|
215
|
+
return documentImportApi
|
|
216
|
+
.saveDocument(saveData)
|
|
214
217
|
.then(({json}) => {
|
|
215
218
|
const data = json as Record<string, unknown>
|
|
216
219
|
return {
|
|
@@ -243,7 +246,8 @@ export class SaveCopy extends GenericSaveCopy {
|
|
|
243
246
|
imageDB: ImageDB,
|
|
244
247
|
newUser: User,
|
|
245
248
|
importId: string | number | null = null,
|
|
246
|
-
e2eeOptions: E2EEOptions | null = null
|
|
249
|
+
e2eeOptions: E2EEOptions | null = null,
|
|
250
|
+
documentImportApi?: EditorDocumentImportApi
|
|
247
251
|
) {
|
|
248
252
|
const title = shortFileTitle(doc.title as string, (doc.path as string) || "")
|
|
249
253
|
const task = addProgress(
|
|
@@ -282,7 +286,11 @@ export class SaveCopy extends GenericSaveCopy {
|
|
|
282
286
|
content: Blob | ArrayBuffer | string
|
|
283
287
|
}>,
|
|
284
288
|
opts.user,
|
|
285
|
-
createNativeImporterBackend(
|
|
289
|
+
createNativeImporterBackend(
|
|
290
|
+
opts.user,
|
|
291
|
+
opts.e2eeOptions ?? null,
|
|
292
|
+
documentImportApi as EditorDocumentImportApi
|
|
293
|
+
),
|
|
286
294
|
{
|
|
287
295
|
importId: opts.importId,
|
|
288
296
|
requestedPath: opts.requestedPath,
|
|
@@ -2,9 +2,17 @@ import type {BibDB, ExportDoc, ImageDB} from "@fiduswriter/document"
|
|
|
2
2
|
import {ExportFidusFile as GenericExportFidusFile} from "@fiduswriter/document/exporter/native"
|
|
3
3
|
import {addProgress, gettext, shortFileTitle} from "fwtoolkit"
|
|
4
4
|
import {DocumentTemplateExporter} from "../../document_template/exporter.js"
|
|
5
|
+
import type {EditorDocumentApi} from "../../types.js"
|
|
6
|
+
|
|
7
|
+
interface ExportFidusFileApp {
|
|
8
|
+
apiConnectors: {
|
|
9
|
+
document: Pick<EditorDocumentApi, "getTemplateForDoc">
|
|
10
|
+
}
|
|
11
|
+
}
|
|
5
12
|
|
|
6
13
|
export class ExportFidusFile extends GenericExportFidusFile {
|
|
7
14
|
constructor(
|
|
15
|
+
app: ExportFidusFileApp,
|
|
8
16
|
doc: ExportDoc,
|
|
9
17
|
bibDB: BibDB,
|
|
10
18
|
imageDB: ImageDB,
|
|
@@ -22,7 +30,7 @@ export class ExportFidusFile extends GenericExportFidusFile {
|
|
|
22
30
|
const getTemplateFiles = (docId: number | string, token: string | boolean) => {
|
|
23
31
|
const templateExporter = new DocumentTemplateExporter(
|
|
24
32
|
docId,
|
|
25
|
-
|
|
33
|
+
app.apiConnectors.document.getTemplateForDoc,
|
|
26
34
|
false,
|
|
27
35
|
token as string | false
|
|
28
36
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {BibDB, ExportDoc, ImageDB, UploadRevision} from "@fiduswriter/document"
|
|
2
2
|
import {SaveRevision as GenericSaveRevision} from "@fiduswriter/document/exporter/native"
|
|
3
3
|
import {createSlug} from "@fiduswriter/document/exporter/tools/file"
|
|
4
|
-
import {addAlert, addProgress, gettext,
|
|
4
|
+
import {addAlert, addProgress, gettext, shortFileTitle} from "fwtoolkit"
|
|
5
5
|
import type {EditorApp} from "../../types.js"
|
|
6
6
|
import {DocumentTemplateExporter} from "../../document_template/exporter.js"
|
|
7
7
|
|
|
@@ -40,7 +40,7 @@ export class SaveRevision extends GenericSaveRevision {
|
|
|
40
40
|
const getTemplateFiles = (docId: number | string, token: string | boolean) => {
|
|
41
41
|
const templateExporter = new DocumentTemplateExporter(
|
|
42
42
|
docId,
|
|
43
|
-
|
|
43
|
+
app.apiConnectors.document.getTemplateForDoc,
|
|
44
44
|
false,
|
|
45
45
|
token as string | false
|
|
46
46
|
)
|
|
@@ -51,21 +51,21 @@ export class SaveRevision extends GenericSaveRevision {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
const uploadRevision: UploadRevision = (blob, doc) => {
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
54
|
+
return app.apiConnectors.document
|
|
55
|
+
.uploadRevision(
|
|
56
|
+
{
|
|
57
|
+
note,
|
|
58
|
+
document_id: doc.id as number
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
file: {
|
|
62
|
+
file: blob,
|
|
63
|
+
filename: `${createSlug(
|
|
64
|
+
shortFileTitle(doc.title as string, doc.path as string)
|
|
65
|
+
)}.fidus`
|
|
66
|
+
}
|
|
66
67
|
}
|
|
67
|
-
|
|
68
|
-
)
|
|
68
|
+
)
|
|
69
69
|
.then(
|
|
70
70
|
() => {},
|
|
71
71
|
() => {
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
addAlert,
|
|
8
8
|
deactivateWait,
|
|
9
9
|
ensureCSS,
|
|
10
|
-
postJson,
|
|
11
10
|
showSystemMessage,
|
|
12
11
|
whenReady
|
|
13
12
|
} from "fwtoolkit"
|
|
@@ -309,19 +308,21 @@ export class Editor {
|
|
|
309
308
|
initPromises.push(this._createE2EEDocument())
|
|
310
309
|
} else {
|
|
311
310
|
initPromises.push(
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
311
|
+
this.app.apiConnectors.document
|
|
312
|
+
.createDocument({
|
|
313
|
+
template_id: this.docInfo.templateId,
|
|
314
|
+
path: this.docInfo.path
|
|
315
|
+
})
|
|
316
|
+
.then(({json}: {json: any}) => {
|
|
317
|
+
this.docInfo.id = json.id
|
|
318
|
+
window.history.replaceState(
|
|
319
|
+
"",
|
|
320
|
+
"",
|
|
321
|
+
`/document/${this.docInfo.id}/`
|
|
322
|
+
)
|
|
323
|
+
delete this.docInfo.templateId
|
|
324
|
+
return Promise.resolve()
|
|
325
|
+
})
|
|
325
326
|
)
|
|
326
327
|
}
|
|
327
328
|
}
|
|
@@ -329,9 +330,9 @@ export class Editor {
|
|
|
329
330
|
if (uuid4Pattern.test(this.docInfo.id)) {
|
|
330
331
|
this.docInfo.token = this.docInfo.id
|
|
331
332
|
initPromises.push(
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
333
|
+
this.app.apiConnectors.document
|
|
334
|
+
.validateShareToken(this.docInfo.token as string)
|
|
335
|
+
.then(({json, status}: {json: any; status: number}) => {
|
|
335
336
|
if (status === 200 && json.document_id) {
|
|
336
337
|
this.docInfo.id = json.document_id
|
|
337
338
|
this.docInfo.access_rights = json.rights
|
|
@@ -362,22 +363,22 @@ export class Editor {
|
|
|
362
363
|
}
|
|
363
364
|
const editorSaveMode = this.app.settings.EDITOR_SAVE_MODE
|
|
364
365
|
const collaborativeEditing = editorSaveMode === "collaborative"
|
|
366
|
+
const documentApi = this.app.apiConnectors.document
|
|
365
367
|
const wsBasePromise = collaborativeEditing
|
|
366
368
|
? this.docInfo.wsBase
|
|
367
369
|
? Promise.resolve({
|
|
368
370
|
json: {ws_base: this.docInfo.wsBase}
|
|
369
371
|
})
|
|
370
|
-
:
|
|
371
|
-
id: this.docInfo.id
|
|
372
|
+
: documentApi.getWebSocketBase({
|
|
373
|
+
id: this.docInfo.id as number,
|
|
374
|
+
token: this.docInfo.token
|
|
372
375
|
})
|
|
373
376
|
: Promise.resolve({json: {ws_base: ""}})
|
|
374
|
-
const stylesPromise =
|
|
375
|
-
|
|
376
|
-
stylesPayload
|
|
377
|
+
const stylesPromise = documentApi.getDocumentStyles(
|
|
378
|
+
stylesPayload as {id: number; token?: string}
|
|
377
379
|
)
|
|
378
|
-
const docDataPromise =
|
|
379
|
-
|
|
380
|
-
stylesPayload
|
|
380
|
+
const docDataPromise = documentApi.getDocumentData(
|
|
381
|
+
stylesPayload as {id: number; token?: string}
|
|
381
382
|
)
|
|
382
383
|
return Promise.all([
|
|
383
384
|
wsBasePromise,
|
|
@@ -538,11 +539,13 @@ export class Editor {
|
|
|
538
539
|
// our version (v) lets the endpoint include the
|
|
539
540
|
// covering diffs as `m` so adjustDocument can
|
|
540
541
|
// do a precise merge.
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
542
|
+
this.app.apiConnectors.document
|
|
543
|
+
.getDocumentData({
|
|
544
|
+
id: this.docInfo.id as number,
|
|
545
|
+
token: this.docInfo.token,
|
|
546
|
+
v: this.docInfo.version as number
|
|
547
|
+
})
|
|
548
|
+
.then(({json}) => {
|
|
546
549
|
this.mod.collab.doc.receiveDocument(
|
|
547
550
|
json
|
|
548
551
|
)
|
|
@@ -707,6 +710,7 @@ export class Editor {
|
|
|
707
710
|
use_current_view: true
|
|
708
711
|
})
|
|
709
712
|
new ExportFidusFile(
|
|
713
|
+
this.app,
|
|
710
714
|
doc,
|
|
711
715
|
this.mod.db.bibDB,
|
|
712
716
|
this.mod.db.imageDB,
|
|
@@ -776,6 +780,7 @@ export class Editor {
|
|
|
776
780
|
handleAccessRightModification(): void {
|
|
777
781
|
// This function when invoked creates a copy of document in FW format and closes editor operation.
|
|
778
782
|
new ExportFidusFile(
|
|
783
|
+
this.app,
|
|
779
784
|
this.getDoc({use_current_view: true}),
|
|
780
785
|
this.mod.db.bibDB,
|
|
781
786
|
this.mod.db.imageDB
|
|
@@ -896,24 +901,25 @@ export class Editor {
|
|
|
896
901
|
)
|
|
897
902
|
|
|
898
903
|
// Create the document on the server with E2EE parameters
|
|
899
|
-
const {json, status} = await
|
|
904
|
+
const {json, status} = await this.app.apiConnectors.document.createDocument({
|
|
900
905
|
template_id: this.docInfo.templateId,
|
|
901
906
|
path: this.docInfo.path,
|
|
902
907
|
e2ee: true,
|
|
903
908
|
e2ee_salt: saltBase64,
|
|
904
909
|
e2ee_iterations: iterations
|
|
905
|
-
})
|
|
910
|
+
})
|
|
906
911
|
|
|
912
|
+
const createData = json as {id: number; error?: string}
|
|
907
913
|
if (status === 403) {
|
|
908
914
|
addAlert(
|
|
909
915
|
"error",
|
|
910
|
-
|
|
916
|
+
createData.error || gettext("E2EE is not enabled on this server.")
|
|
911
917
|
)
|
|
912
918
|
window.location.href = "/"
|
|
913
919
|
return
|
|
914
920
|
}
|
|
915
921
|
|
|
916
|
-
this.docInfo.id =
|
|
922
|
+
this.docInfo.id = createData.id
|
|
917
923
|
window.history.replaceState("", "", `/document/${this.docInfo.id}/`)
|
|
918
924
|
delete this.docInfo.templateId
|
|
919
925
|
|
|
@@ -1310,3 +1316,9 @@ export class Editor {
|
|
|
1310
1316
|
return
|
|
1311
1317
|
}
|
|
1312
1318
|
}
|
|
1319
|
+
|
|
1320
|
+
export type {
|
|
1321
|
+
EditorDocumentApi,
|
|
1322
|
+
EditorDocumentImportApi,
|
|
1323
|
+
EditorContactsApi
|
|
1324
|
+
} from "./types.js"
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
Dialog,
|
|
3
3
|
addAlert,
|
|
4
4
|
addProgress,
|
|
5
|
-
postJson,
|
|
6
5
|
shortFileTitle
|
|
7
6
|
} from "fwtoolkit"
|
|
8
7
|
import type {BibDB, ExportDoc, ImageDB} from "@fiduswriter/document"
|
|
@@ -137,10 +136,11 @@ export const headerbarModel = () => ({
|
|
|
137
136
|
!editor.docInfo.is_owner
|
|
138
137
|
) {
|
|
139
138
|
// TokenUser requesting access
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
editor.app.apiConnectors.document
|
|
140
|
+
.requestAccess({
|
|
141
|
+
document_id: editor.docInfo.id as number,
|
|
142
|
+
rights: "write"
|
|
143
|
+
})
|
|
144
144
|
.then(({json}: {json: unknown}) => {
|
|
145
145
|
const data = json as {
|
|
146
146
|
success?: boolean
|
|
@@ -189,9 +189,10 @@ export const headerbarModel = () => ({
|
|
|
189
189
|
const noPassphraseUsers: string[] = []
|
|
190
190
|
for (const ar of userRecipients) {
|
|
191
191
|
try {
|
|
192
|
+
const holderId = ar.holder?.id as number
|
|
192
193
|
const hasKeys =
|
|
193
194
|
await PassphraseManager.userHasEncryptionKeys(
|
|
194
|
-
|
|
195
|
+
holderId
|
|
195
196
|
)
|
|
196
197
|
if (hasKeys) {
|
|
197
198
|
// Recipient has passphrase keys —
|
|
@@ -199,7 +200,7 @@ export const headerbarModel = () => ({
|
|
|
199
200
|
await PassphraseManager.saveDocumentPassword(
|
|
200
201
|
editor.docInfo.id as number,
|
|
201
202
|
editor.e2ee.password,
|
|
202
|
-
|
|
203
|
+
holderId,
|
|
203
204
|
"user",
|
|
204
205
|
false
|
|
205
206
|
)
|
|
@@ -252,7 +253,9 @@ export const headerbarModel = () => ({
|
|
|
252
253
|
editor.e2ee?.encrypted || false,
|
|
253
254
|
editor.e2ee?.password || "",
|
|
254
255
|
onShareSuccess,
|
|
255
|
-
editor.app.settings
|
|
256
|
+
editor.app.settings,
|
|
257
|
+
editor.app.apiConnectors.contacts,
|
|
258
|
+
editor.app.apiConnectors.document
|
|
256
259
|
)
|
|
257
260
|
shareDialog.init()
|
|
258
261
|
},
|
|
@@ -343,7 +346,10 @@ export const headerbarModel = () => ({
|
|
|
343
346
|
getExportDoc(editor),
|
|
344
347
|
db.bibDB,
|
|
345
348
|
db.imageDB,
|
|
346
|
-
editor.user
|
|
349
|
+
editor.user,
|
|
350
|
+
null,
|
|
351
|
+
null,
|
|
352
|
+
editor.app.apiConnectors.documentImport
|
|
347
353
|
)
|
|
348
354
|
copier
|
|
349
355
|
.init()
|
|
@@ -368,6 +374,7 @@ export const headerbarModel = () => ({
|
|
|
368
374
|
action: (editor: Editor) => {
|
|
369
375
|
const db = getDB(editor)
|
|
370
376
|
new ExportFidusFile(
|
|
377
|
+
editor.app,
|
|
371
378
|
getExportDoc(editor),
|
|
372
379
|
db.bibDB,
|
|
373
380
|
db.imageDB,
|
|
@@ -787,6 +794,7 @@ export const headerbarModel = () => ({
|
|
|
787
794
|
action: (editor: Editor) => {
|
|
788
795
|
const db = getDB(editor)
|
|
789
796
|
new ExportFidusFile(
|
|
797
|
+
editor.app,
|
|
790
798
|
getExportDoc(editor),
|
|
791
799
|
db.bibDB,
|
|
792
800
|
db.imageDB,
|