@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {addAlert
|
|
1
|
+
import {addAlert} from "fwtoolkit"
|
|
2
2
|
import {receiveTransaction} from "prosemirror-collab"
|
|
3
3
|
import {recreateTransform} from "../collab/merge/recreate_transform.js"
|
|
4
4
|
import type {Editor} from "../types.js"
|
|
@@ -10,7 +10,7 @@ import type {Node} from "prosemirror-model"
|
|
|
10
10
|
*/
|
|
11
11
|
export class NoCollabSave {
|
|
12
12
|
editor: Editor
|
|
13
|
-
saveInterval:
|
|
13
|
+
saveInterval: number | null
|
|
14
14
|
savePromise: Promise<void> | null
|
|
15
15
|
_beforeUnloadHandler: (() => void) | null
|
|
16
16
|
_lastSaveTime: number
|
|
@@ -126,20 +126,19 @@ export class NoCollabSave {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
try {
|
|
129
|
-
const {json, status} =
|
|
130
|
-
"/api/document/save/",
|
|
129
|
+
const {json, status} = await this.editor.app.apiConnectors.document.saveDocument(
|
|
131
130
|
payload,
|
|
132
|
-
{},
|
|
133
131
|
{keepalive}
|
|
134
|
-
)
|
|
132
|
+
)
|
|
135
133
|
if (status === 409) {
|
|
136
134
|
if (!keepalive) {
|
|
137
135
|
await this._handleVersionConflict()
|
|
138
136
|
}
|
|
139
137
|
return
|
|
140
138
|
}
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
const saveData = json as {version?: number}
|
|
140
|
+
if (saveData.version !== undefined) {
|
|
141
|
+
this.editor.docInfo.version = saveData.version
|
|
143
142
|
}
|
|
144
143
|
this.editor.docInfo.updated = new Date()
|
|
145
144
|
this.editor.docInfo.confirmedDoc = this.editor.view.state.doc
|
|
@@ -167,15 +166,15 @@ export class NoCollabSave {
|
|
|
167
166
|
payload.token = this.editor.docInfo.token
|
|
168
167
|
}
|
|
169
168
|
try {
|
|
170
|
-
const {json} =
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
const {json} = await this.editor.app.apiConnectors.document.getDocumentData(
|
|
170
|
+
payload as {id: number; token?: string}
|
|
171
|
+
)
|
|
172
|
+
const data = json as {
|
|
173
|
+
doc: Record<string, unknown>
|
|
174
|
+
time: string
|
|
175
|
+
}
|
|
174
176
|
const serverDoc = this.editor.schema.nodeFromJSON(
|
|
175
|
-
(
|
|
176
|
-
string,
|
|
177
|
-
unknown
|
|
178
|
-
>
|
|
177
|
+
(data.doc.content as Record<string, unknown>) || {}
|
|
179
178
|
)
|
|
180
179
|
const currentDoc = this.editor.view.state.doc
|
|
181
180
|
const confirmedDoc = this.editor.docInfo.confirmedDoc as Node
|
|
@@ -203,18 +202,17 @@ export class NoCollabSave {
|
|
|
203
202
|
|
|
204
203
|
// Update metadata from server
|
|
205
204
|
;(this.editor.mod.db?.bibDB as {setDB(value: unknown): void}).setDB(
|
|
206
|
-
|
|
205
|
+
data.doc.bibliography
|
|
207
206
|
)
|
|
208
207
|
;(this.editor.mod.db?.imageDB as {setDB(value: unknown): void}).setDB(
|
|
209
|
-
|
|
208
|
+
data.doc.images
|
|
210
209
|
)
|
|
211
210
|
;(this.editor.mod.comments as any).store.loadComments(
|
|
212
|
-
|
|
211
|
+
data.doc.comments
|
|
213
212
|
)
|
|
214
|
-
this.editor.docInfo.version =
|
|
215
|
-
.v as number
|
|
213
|
+
this.editor.docInfo.version = data.doc.v as number
|
|
216
214
|
this.editor.docInfo.confirmedDoc = this.editor.view.state.doc
|
|
217
|
-
this.editor.docInfo.updated = new Date(
|
|
215
|
+
this.editor.docInfo.updated = new Date(data.time)
|
|
218
216
|
;(this.editor.mod.footnotes as any).fnEditor.renderAllFootnotes()
|
|
219
217
|
|
|
220
218
|
// Retry save with the merged document
|
|
@@ -156,8 +156,8 @@ export function buildBibliographyList(editor: Editor): BibliographyEntry[] {
|
|
|
156
156
|
if (editor.mod?.db?.bibDB?.db) {
|
|
157
157
|
addEntries(editor.mod.db.bibDB.db as Record<number, any>, "doc")
|
|
158
158
|
}
|
|
159
|
-
if (
|
|
160
|
-
addEntries(
|
|
159
|
+
if (editor.app.bibDB?.db) {
|
|
160
|
+
addEntries(editor.app.bibDB.db as Record<string, any>, "user")
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
return entries
|
package/src/types.ts
CHANGED
|
@@ -14,13 +14,15 @@ import type {EditorView} from "prosemirror-view"
|
|
|
14
14
|
import type {
|
|
15
15
|
BibDB,
|
|
16
16
|
BibDBEntries,
|
|
17
|
+
BibDBEntry,
|
|
17
18
|
CommentData,
|
|
18
19
|
CSL,
|
|
19
20
|
ImageDB,
|
|
20
21
|
ImageDBEntries
|
|
21
22
|
} from "@fiduswriter/document"
|
|
23
|
+
import type {ImageApi} from "@fiduswriter/image-manager"
|
|
22
24
|
|
|
23
|
-
export type {BibDB, BibDBEntries, CommentData, CSL, ImageDB, ImageDBEntries}
|
|
25
|
+
export type {BibDB, BibDBEntries, BibDBEntry, CommentData, CSL, ImageDB, ImageDBEntries}
|
|
24
26
|
|
|
25
27
|
/** Image database interface used by the editor (document and user DBs). */
|
|
26
28
|
export interface EditorImageDB extends ImageDB {
|
|
@@ -28,16 +30,104 @@ export interface EditorImageDB extends ImageDB {
|
|
|
28
30
|
setImage(id: number, imageData: Record<string, unknown>): void
|
|
29
31
|
}
|
|
30
32
|
|
|
33
|
+
/** Bibliography database interface used by the editor. */
|
|
34
|
+
export interface EditorBibDB {
|
|
35
|
+
db: Record<string, BibDBEntry>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** API connector for document-level operations used by the editor. */
|
|
39
|
+
export interface EditorDocumentApi {
|
|
40
|
+
createDocument(
|
|
41
|
+
data: Record<string, unknown>
|
|
42
|
+
): Promise<{json: unknown; status: number}>
|
|
43
|
+
getWebSocketBase(
|
|
44
|
+
data: {id: number; token?: string}
|
|
45
|
+
): Promise<{json: unknown; status: number}>
|
|
46
|
+
getDocumentStyles(
|
|
47
|
+
data: {id: number; token?: string}
|
|
48
|
+
): Promise<{json: unknown; status: number}>
|
|
49
|
+
getDocumentData(
|
|
50
|
+
data: {id: number; token?: string; v?: number}
|
|
51
|
+
): Promise<{json: unknown; status: number}>
|
|
52
|
+
saveDocument(
|
|
53
|
+
data: Record<string, unknown>,
|
|
54
|
+
options?: {keepalive?: boolean}
|
|
55
|
+
): Promise<{json: unknown; status: number}>
|
|
56
|
+
commentNotify(data: Record<string, unknown>): Promise<unknown>
|
|
57
|
+
requestAccess(
|
|
58
|
+
data: {document_id: number; rights: string}
|
|
59
|
+
): Promise<{json: unknown; status: number}>
|
|
60
|
+
validateShareToken(
|
|
61
|
+
token: string
|
|
62
|
+
): Promise<{json: unknown; status: number}>
|
|
63
|
+
listShareTokens(document_id: number): Promise<{json: unknown; status: number}>
|
|
64
|
+
createShareToken(
|
|
65
|
+
data: Record<string, unknown>
|
|
66
|
+
): Promise<{json: unknown; status: number}>
|
|
67
|
+
revokeShareToken(token_id: number): Promise<{json: unknown; status: number}>
|
|
68
|
+
getAccessRights(
|
|
69
|
+
data: {document_ids: number[]}
|
|
70
|
+
): Promise<{json: unknown; status: number}>
|
|
71
|
+
saveAccessRights(data: {
|
|
72
|
+
document_ids: number[]
|
|
73
|
+
access_rights: unknown[]
|
|
74
|
+
}): Promise<unknown>
|
|
75
|
+
saveE2EEImage(
|
|
76
|
+
data: Record<string, unknown>,
|
|
77
|
+
files?: Record<string, unknown>
|
|
78
|
+
): Promise<{json: unknown; status: number}>
|
|
79
|
+
deleteE2EEImage(data: {doc_id: number; image_id: number}): Promise<unknown>
|
|
80
|
+
uploadRevision(
|
|
81
|
+
data: {note: string; document_id: number},
|
|
82
|
+
files: Record<string, unknown>
|
|
83
|
+
): Promise<unknown>
|
|
84
|
+
getTemplateForDoc(
|
|
85
|
+
id: number | string,
|
|
86
|
+
token: string | false
|
|
87
|
+
): Promise<{json: unknown; status: number}>
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** API connector for contact operations used by the editor. */
|
|
91
|
+
export interface EditorContactsApi {
|
|
92
|
+
add(data: {user_string: string}): Promise<{json: unknown; status: number}>
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** API connector for document import/copy operations used by the editor. */
|
|
96
|
+
export interface EditorDocumentImportApi {
|
|
97
|
+
createDoc(
|
|
98
|
+
data: Record<string, unknown>,
|
|
99
|
+
files?: Record<string, unknown>
|
|
100
|
+
): Promise<{json: unknown; status: number}>
|
|
101
|
+
saveImage(
|
|
102
|
+
data: Record<string, unknown>,
|
|
103
|
+
files: Record<string, unknown>
|
|
104
|
+
): Promise<{json: unknown; status: number}>
|
|
105
|
+
saveE2EEImage(
|
|
106
|
+
data: Record<string, unknown>,
|
|
107
|
+
files: Record<string, unknown>
|
|
108
|
+
): Promise<{json: unknown; status: number}>
|
|
109
|
+
saveDocument(
|
|
110
|
+
data: Record<string, unknown>
|
|
111
|
+
): Promise<{json: unknown; status: number}>
|
|
112
|
+
}
|
|
113
|
+
|
|
31
114
|
/** Minimal app interface — only the fields the Editor actually uses. */
|
|
32
115
|
export interface EditorApp {
|
|
33
116
|
routes: Record<string, {app: string; [key: string]: unknown}>
|
|
34
117
|
goTo: (url: string) => void
|
|
35
118
|
settings: {APPS: string[]; [key: string]: unknown}
|
|
36
119
|
menuPlugins?: Array<[string, Record<string, {new (...args: unknown[]): {init(): void}}>]>
|
|
37
|
-
name
|
|
120
|
+
name: string
|
|
38
121
|
isOffline(): boolean
|
|
39
122
|
csl: CSL
|
|
123
|
+
bibDB?: EditorBibDB
|
|
40
124
|
imageDB: EditorImageDB
|
|
125
|
+
apiConnectors: {
|
|
126
|
+
document: EditorDocumentApi
|
|
127
|
+
documentImport: EditorDocumentImportApi
|
|
128
|
+
image: ImageApi
|
|
129
|
+
contacts: EditorContactsApi
|
|
130
|
+
}
|
|
41
131
|
}
|
|
42
132
|
|
|
43
133
|
/** Document access role constants. */
|