@fiduswriter/frontend 0.1.64 → 0.1.66

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.
Files changed (55) hide show
  1. package/dist/api/index.d.ts +1 -1
  2. package/dist/api/index.d.ts.map +1 -1
  3. package/dist/css/document-template-editor/document_template_designer.css +68 -68
  4. package/dist/css/editor/editor.css +39 -3
  5. package/dist/css/fwtoolkit/content_menu.css +4 -1
  6. package/dist/css/fwtoolkit/dialog.css +27 -0
  7. package/dist/css/fwtoolkit/fwtoolkit.css +49 -2
  8. package/dist/css/fwtoolkit/pulldown.css +10 -1
  9. package/dist/css/fwtoolkit/pulldown_menu.css +8 -0
  10. package/dist/css/image-manager/dialog_usermedia.css +41 -41
  11. package/dist/documents/importer/native/import.d.ts.map +1 -1
  12. package/dist/documents/importer/native/import.js +16 -3
  13. package/dist/documents/importer/native/import.js.map +1 -1
  14. package/dist/documents/overview/actions.d.ts.map +1 -1
  15. package/dist/documents/overview/actions.js +13 -2
  16. package/dist/documents/overview/actions.js.map +1 -1
  17. package/dist/documents/overview/index.js +1 -1
  18. package/dist/documents/revisions/index.js +6 -6
  19. package/dist/maintenance/index.js +4 -4
  20. package/dist/user/auth/two_factor.d.ts.map +1 -1
  21. package/dist/user/auth/two_factor.js +52 -4
  22. package/dist/user/auth/two_factor.js.map +1 -1
  23. package/dist/user/profile/index.d.ts.map +1 -1
  24. package/dist/user/profile/index.js +2 -2
  25. package/dist/user/profile/index.js.map +1 -1
  26. package/locale/ar/messages.json +10 -10
  27. package/locale/bg/messages.json +10 -10
  28. package/locale/cs/messages.json +10 -10
  29. package/locale/da/messages.json +10 -10
  30. package/locale/de/messages.json +10 -10
  31. package/locale/en/messages.json +10 -10
  32. package/locale/en_US/messages.json +10 -10
  33. package/locale/es/messages.json +10 -10
  34. package/locale/fr/messages.json +10 -10
  35. package/locale/it/messages.json +10 -10
  36. package/locale/ja/messages.json +10 -10
  37. package/locale/ko/messages.json +10 -10
  38. package/locale/nb/messages.json +10 -10
  39. package/locale/nl/messages.json +10 -10
  40. package/locale/pl/messages.json +10 -10
  41. package/locale/pt_BR/messages.json +10 -10
  42. package/locale/pt_PT/messages.json +10 -10
  43. package/locale/ru/messages.json +10 -10
  44. package/locale/sv/messages.json +10 -10
  45. package/locale/tr/messages.json +10 -10
  46. package/locale/zh_Hans/messages.json +10 -10
  47. package/package.json +4 -4
  48. package/src/api/index.ts +1 -1
  49. package/src/documents/importer/native/import.ts +22 -3
  50. package/src/documents/overview/actions.ts +16 -2
  51. package/src/documents/overview/index.ts +1 -1
  52. package/src/documents/revisions/index.ts +6 -6
  53. package/src/maintenance/index.ts +4 -4
  54. package/src/user/auth/two_factor.ts +79 -7
  55. package/src/user/profile/index.ts +4 -2
@@ -41,7 +41,7 @@ export class DocumentRevisionsDialog {
41
41
  return Promise.reject(new Error("Document not found"))
42
42
  }
43
43
  this.dialog = new Dialog({
44
- title: `${gettext("Saved revisions of")} ${escapeText(shortFileTitle(doc.title as string, doc.path as string))}`,
44
+ title: `${gettext("Saved snapshots of")} ${escapeText(shortFileTitle(doc.title as string, doc.path as string))}`,
45
45
  id: "revisions-dialog",
46
46
  width: 620,
47
47
  height: 480,
@@ -96,7 +96,7 @@ export class DocumentRevisionsDialog {
96
96
  longFilePath(
97
97
  doc.title as string,
98
98
  doc.path as string,
99
- `${gettext("Revision of")} `
99
+ `${gettext("Snapshot of")} `
100
100
  ),
101
101
  false,
102
102
  [],
@@ -151,7 +151,7 @@ export class DocumentRevisionsDialog {
151
151
  id: "confirmdeletion",
152
152
  title: gettext("Confirm deletion"),
153
153
  icon: "exclamation-triangle",
154
- body: `${gettext("Do you really want to delete the revision?")}`,
154
+ body: `${gettext("Do you really want to delete the snapshot?")}`,
155
155
  height: 80,
156
156
  buttons
157
157
  } as any)
@@ -172,7 +172,7 @@ export class DocumentRevisionsDialog {
172
172
  d => d.id === Number.parseInt(documentId!)
173
173
  )
174
174
  thisTr.parentElement!.removeChild(thisTr)
175
- addAlert("success", gettext("Revision deleted"))
175
+ addAlert("success", gettext("Snapshot deleted"))
176
176
  return Promise.resolve({
177
177
  action: "deleted-revision",
178
178
  id,
@@ -180,8 +180,8 @@ export class DocumentRevisionsDialog {
180
180
  })
181
181
  })
182
182
  .catch(() => {
183
- addAlert("error", gettext("Could not delete revision."))
184
- return Promise.reject(new Error("Could not delete revision."))
183
+ addAlert("error", gettext("Could not delete snapshot."))
184
+ return Promise.reject(new Error("Could not delete snapshot."))
185
185
  })
186
186
  }
187
187
  }
@@ -181,13 +181,13 @@ export class DocMaintenance {
181
181
  }
182
182
 
183
183
  updateRevisions(): void {
184
- addAlert("info", gettext("Updating saved revisions."))
184
+ addAlert("info", gettext("Updating saved snapshots."))
185
185
  this.app.apiConnectors.maintenance.getAllRevisionIds().then((json: RevisionIdsResponse) => {
186
186
  this.revSavesLeft = json.revision_ids.length
187
187
  if (this.revSavesLeft) {
188
188
  json.revision_ids.forEach((revId: number) => this.updateRevision(revId))
189
189
  } else {
190
- addAlert("info", gettext("No document revisions to update."))
190
+ addAlert("info", gettext("No document snapshots to update."))
191
191
  this.done()
192
192
  }
193
193
  })
@@ -242,7 +242,7 @@ export class DocMaintenance {
242
242
  this.app.apiConnectors.maintenance.updateRevision(id, blob).then(() => {
243
243
  addAlert(
244
244
  "success",
245
- gettext("The document revision has been updated: ") + id
245
+ gettext("The document snapshot has been updated: ") + id
246
246
  )
247
247
  this.revSavesLeft--
248
248
  if (this.revSavesLeft === 0) {
@@ -254,7 +254,7 @@ export class DocMaintenance {
254
254
 
255
255
  done(): void {
256
256
  ;(document.querySelector("input#update") as HTMLInputElement).value = gettext(
257
- "All documents, document templates and document revisions updated!"
257
+ "All documents, document templates and document snapshots updated!"
258
258
  )
259
259
  }
260
260
  }
@@ -134,8 +134,28 @@ export const twoFactorDisableDialog = (app: FrontendApp): any => {
134
134
  text: gettext("Disable 2FA"),
135
135
  classes: "fw-orange",
136
136
  click: () => {
137
+ const passwordInput = document.getElementById(
138
+ "two-factor-disable-password"
139
+ ) as HTMLInputElement | null
140
+ const codeInput = document.getElementById(
141
+ "two-factor-disable-code"
142
+ ) as HTMLInputElement | null
143
+ const password = passwordInput ? passwordInput.value : ""
144
+ const code = codeInput ? codeInput.value.trim() : ""
145
+
146
+ if (password.length === 0) {
147
+ addAlert("error", gettext("Please enter your password."))
148
+ return
149
+ }
150
+
151
+ if (code.length !== 6) {
152
+ addAlert("error", gettext("Please enter a 6-digit code."))
153
+ return
154
+ }
155
+
137
156
  activateWait()
138
- app.apiConnectors.auth.twoFactorDisable()
157
+ app.apiConnectors.auth
158
+ .twoFactorDisable({password, code})
139
159
  .then((json: TwoFactorVerifyResponse) => {
140
160
  if (json.status === "success") {
141
161
  addAlert("success", json.message)
@@ -145,11 +165,38 @@ export const twoFactorDisableDialog = (app: FrontendApp): any => {
145
165
  addAlert("error", json.message)
146
166
  }
147
167
  })
148
- .catch(() => {
149
- addAlert(
150
- "error",
151
- gettext("Could not disable two-factor authentication.")
152
- )
168
+ .catch((errorResponse: unknown) => {
169
+ // The server rejects missing/invalid re-authentication
170
+ // with a 4xx carrying a JSON message.
171
+ const response = errorResponse as Response | undefined
172
+ if (response && typeof response.json === "function") {
173
+ response
174
+ .json()
175
+ .then((json: {message?: string}) => {
176
+ addAlert(
177
+ "error",
178
+ json.message ||
179
+ gettext(
180
+ "Could not disable two-factor authentication."
181
+ )
182
+ )
183
+ })
184
+ .catch(() => {
185
+ addAlert(
186
+ "error",
187
+ gettext(
188
+ "Could not disable two-factor authentication."
189
+ )
190
+ )
191
+ })
192
+ } else {
193
+ addAlert(
194
+ "error",
195
+ gettext(
196
+ "Could not disable two-factor authentication."
197
+ )
198
+ )
199
+ }
153
200
  })
154
201
  .then(() => {
155
202
  deactivateWait()
@@ -162,12 +209,37 @@ export const twoFactorDisableDialog = (app: FrontendApp): any => {
162
209
  const dialog = new Dialog({
163
210
  id: "two-factor-disable-dialog",
164
211
  title: gettext("Disable Two-Factor Authentication"),
165
- body: `<p>${gettext("Are you sure you want to disable two-factor authentication? This will reduce the security of your account.")}</p>`,
212
+ body: `<p>${gettext("Are you sure you want to disable two-factor authentication? This will reduce the security of your account.")}</p>
213
+ <p>${gettext("Confirm with your account password and a code from your authenticator app:")}</p>
214
+ <div class="two-factor-verify-section">
215
+ <label for="two-factor-disable-password">${gettext("Password")}</label>
216
+ <input type="password" id="two-factor-disable-password" class="fw-button fw-large" autocomplete="current-password" data-1p-ignore data-lpignore="true" data-form-type="other" />
217
+ </div>
218
+ <div class="two-factor-verify-section">
219
+ <label for="two-factor-disable-code">${gettext("Authenticator code")}</label>
220
+ <input type="text" id="two-factor-disable-code" placeholder="123456" maxlength="6" class="fw-button fw-large" autocomplete="one-time-code" />
221
+ </div>`,
166
222
  buttons,
167
223
  icon: "exclamation-triangle"
168
224
  })
169
225
 
170
226
  dialog.open()
227
+
228
+ const disableCodeInput = dialog.dialogEl.querySelector(
229
+ "#two-factor-disable-code"
230
+ )
231
+ if (disableCodeInput) {
232
+ ;(disableCodeInput as HTMLElement).addEventListener(
233
+ "keypress",
234
+ (event: Event) => {
235
+ if ((event as KeyboardEvent).key === "Enter") {
236
+ event.preventDefault()
237
+ buttons[0].click!()
238
+ }
239
+ }
240
+ )
241
+ }
242
+
171
243
  return dialog
172
244
  }
173
245
 
@@ -311,7 +311,8 @@ export class Profile {
311
311
  const {newRecoveryKey} =
312
312
  await PassphraseManager.recoverWithRecoveryKey(
313
313
  recoverResult.recoveryKey,
314
- recoverResult.newPassphrase
314
+ recoverResult.newPassphrase,
315
+ recoverResult.accountPassword
315
316
  )
316
317
  await new Promise<void>(resolve => {
317
318
  showRecoveryKeyDialog(newRecoveryKey, resolve)
@@ -339,7 +340,8 @@ export class Profile {
339
340
  try {
340
341
  await PassphraseManager.changePassphrase(
341
342
  changeResult.oldPassphrase,
342
- changeResult.newPassphrase
343
+ changeResult.newPassphrase,
344
+ changeResult.accountPassword
343
345
  )
344
346
  addAlert("success", gettext("Passphrase changed successfully."))
345
347
  } catch (e: any) {