@fiduswriter/frontend 0.1.72 → 0.1.73

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 (53) hide show
  1. package/css/login.css +268 -0
  2. package/css/show_profile.css +111 -40
  3. package/dist/app/index.d.ts.map +1 -1
  4. package/dist/app/index.js +1 -0
  5. package/dist/app/index.js.map +1 -1
  6. package/dist/common/user_util.d.ts +8 -1
  7. package/dist/common/user_util.d.ts.map +1 -1
  8. package/dist/common/user_util.js +24 -0
  9. package/dist/common/user_util.js.map +1 -1
  10. package/dist/css/fwtoolkit/data_table.css +31 -6
  11. package/dist/css/fwtoolkit/dialog.css +51 -0
  12. package/dist/css/fwtoolkit/fwtoolkit.css +157 -26
  13. package/dist/css/fwtoolkit/inline_tools.css +5 -8
  14. package/dist/css/fwtoolkit/overview_menu.css +70 -12
  15. package/dist/css/login.css +268 -0
  16. package/dist/css/manifest.json +1 -0
  17. package/dist/css/show_profile.css +111 -40
  18. package/dist/feedback/index.d.ts.map +1 -1
  19. package/dist/feedback/index.js +6 -1
  20. package/dist/feedback/index.js.map +1 -1
  21. package/dist/menu/index.d.ts.map +1 -1
  22. package/dist/menu/index.js +16 -2
  23. package/dist/menu/index.js.map +1 -1
  24. package/dist/user/auth/login.d.ts +14 -0
  25. package/dist/user/auth/login.d.ts.map +1 -1
  26. package/dist/user/auth/login.js +253 -131
  27. package/dist/user/auth/login.js.map +1 -1
  28. package/dist/user/profile/dialog.d.ts +72 -0
  29. package/dist/user/profile/dialog.d.ts.map +1 -0
  30. package/dist/user/profile/dialog.js +436 -0
  31. package/dist/user/profile/dialog.js.map +1 -0
  32. package/dist/user/profile/dialogs.d.ts +6 -6
  33. package/dist/user/profile/dialogs.d.ts.map +1 -1
  34. package/dist/user/profile/dialogs.js +29 -14
  35. package/dist/user/profile/dialogs.js.map +1 -1
  36. package/dist/user/profile/index.d.ts +12 -14
  37. package/dist/user/profile/index.d.ts.map +1 -1
  38. package/dist/user/profile/index.js +35 -236
  39. package/dist/user/profile/index.js.map +1 -1
  40. package/dist/user/profile/templates.d.ts +14 -1
  41. package/dist/user/profile/templates.d.ts.map +1 -1
  42. package/dist/user/profile/templates.js +178 -191
  43. package/dist/user/profile/templates.js.map +1 -1
  44. package/package.json +3 -2
  45. package/src/app/index.ts +1 -0
  46. package/src/common/user_util.ts +26 -1
  47. package/src/feedback/index.ts +8 -1
  48. package/src/menu/index.ts +19 -2
  49. package/src/user/auth/login.ts +338 -153
  50. package/src/user/profile/dialog.ts +609 -0
  51. package/src/user/profile/dialogs.ts +51 -14
  52. package/src/user/profile/index.ts +37 -334
  53. package/src/user/profile/templates.ts +222 -223
@@ -68,237 +68,236 @@ export const changePwdDialogTemplate = ({username}: {username: string}): string
68
68
  <tr><td><span id="fw-password-change-error" class="fw-warning"></span></td></tr>
69
69
  </tbody></table>`
70
70
 
71
- export const profileContents = (
71
+ /** "Basics" tab: name fields, password action, 2FA and E2EE passphrase. */
72
+ export const profileBasicsTemplate = (
72
73
  user: Record<string, any>,
73
- socialaccount_providers: Array<Record<string, unknown>>,
74
- settings: Record<string, unknown> = {},
75
- pluginTemplates: string[] = []
74
+ settings: Record<string, unknown> = {}
76
75
  ): string =>
77
- `<div id="profile-wrapper" class="fw-clearfix fw-dialog ui-dialog-fullpage">
78
- <div id="profile-avatar">
79
- ${avatarTemplate({user})}
80
- <div id="avatar-pulldown-wrapper">
81
- <span id="edit-avatar-btn" class="fw-link-text">
82
- ${gettext("Edit profile picture")}
83
- </span>
84
- <select id="edit-avatar-pulldown">
85
- <option value="change">${gettext("Change picture")}</option>
86
- ${user.avatar ? `<option value="delete">${gettext("Delete picture")}</option>` : ""}
87
- </select>
76
+ `<form>
77
+ <div class="profile-data-row">
78
+ <div class="fw-floating-field">
79
+ <label for="username">${gettext("Username")}</label>
80
+ <input type="text" name="username" id="username" placeholder=" " autocomplete="username" value="${escapeText(user.username)}" />
88
81
  </div>
89
82
  </div>
90
- <div id="profile-data">
91
- <form>
92
- <div class="profile-data-row">
93
- <label class="form-label">${gettext("Username")}</label>
94
- <input type="text" name="username" id="username" autocomplete="username" value="${escapeText(user.username)}" />
95
- </div>
96
- <div class="profile-data-row">
97
- <label class="form-label">${gettext("First name")}</label>
98
- <input type="text" name="firstname" id="first_name" autocomplete="given-name" value="${escapeText(user.first_name)}" />
99
- </div>
100
- <div class="profile-data-row">
101
- <label class="form-label">${gettext("Last name")}</label>
102
- <input type="text" name="lastname" id="last_name" autocomplete="family-name" value="${escapeText(user.last_name)}" />
103
- </div>
104
- <div class="profile-data-row">
105
- <label class="form-label">${gettext("Password")}</label>
106
- <input type="password" value="******" autocomplete="new-password" readonly disabled />
107
- <span id="fw-edit-profile-pwd" class="fw-link-text"><i class="fa fa-pencil-alt"></i></span>
108
- </div>
109
- </form>
110
- ${
111
- settings.TWO_FACTOR_ENABLED
112
- ? `<div class="profile-data-row">
113
- <label class="form-label">${gettext("Two-Factor Authentication")}</label>
114
- <div id="two-factor-status">
115
- <span id="two-factor-enabled-status" style="display: none;">
116
- <i class="fa fa-check"></i>
117
- ${gettext("Enabled")}
118
- </span>
119
- <span id="two-factor-disabled-status" style="display: none;">
120
- <i class="fa fa-times"></i>
121
- ${gettext("Disabled")}
122
- </span>
123
- </div>
124
- <span id="setup-two-factor" class="fw-link-text" style="display: none;">
125
- <i class="fa fa-shield-alt"></i>
126
- ${gettext("Enable 2FA")}
127
- </span>
128
- <span id="disable-two-factor" class="fw-link-text" style="display: none;">
129
- <i class="fa fa-shield-alt"></i>
130
- ${gettext("Disable 2FA")}
131
- </span>
132
- </div>`
133
- : ""
134
- }
135
- ${
136
- settings.E2EE_MODE && settings.E2EE_MODE !== "disabled"
137
- ? `<div class="profile-data-row">
138
- <label class="form-label">${gettext("End-to-End Encryption")}</label>
139
- <div id="e2ee-passphrase-status">
140
- <span id="e2ee-passphrase-enabled-status" style="display: none;">
141
- <i class="fa fa-check"></i>
142
- ${gettext("Personal passphrase set up")}
143
- </span>
144
- <span id="e2ee-passphrase-disabled-status" style="display: none;">
145
- <i class="fa fa-times"></i>
146
- ${gettext("Not set up")}
147
- </span>
148
- </div>
149
- <span id="setup-e2ee-passphrase" class="fw-link-text" style="display: none;">
150
- <i class="fa fa-lock"></i>
151
- ${gettext("Set up encryption passphrase")}
152
- </span>
153
- <span id="change-e2ee-passphrase" class="fw-link-text" style="display: none;">
154
- <i class="fa fa-pencil-alt"></i>
155
- ${gettext("Change passphrase")}
156
- </span>
157
- <span id="recover-e2ee-passphrase" class="fw-link-text" style="display: none;">
158
- <i class="fa fa-key"></i>
159
- ${gettext("Recover with recovery key")}
160
- </span>
161
- </div>`
162
- : ""
163
- }
164
- <div class="profile-data-row">
165
- <table class="fw-data-table profile-email-table">
166
- <thead class="fw-data-table-header">
167
- <tr>
168
- <th>${gettext("Email")}</th>
169
- <th>${gettext("Primary address")}</th>
170
- <th>${gettext("Verified")}</th>
171
- <th>&nbsp;&nbsp;&nbsp;&nbsp;</th>
172
- </tr>
173
- </thead>
174
- <tbody>
175
- ${(user.emails as Array<Record<string, unknown>>)
176
- .map(
177
- (email: any) => `<tr${email.primary ? ' class="primary-email-tr"' : ""}>
178
- <td class="emailaddress">${email.address}</td>
179
- <td>
180
- ${
181
- email.verified
182
- ? `<input type="radio" class="primary-email-radio" value="${email.address}"
183
- name="primaryemail"${email.primary ? " checked" : ""} />`
184
- : ""
185
- }
186
- </td>
187
- <td>
188
- ${email.verified ? '<i class="fa fa-check"></i>' : ""}
189
- </td>
190
- <td class="profile-email-action">
191
- ${
192
- email.primary
193
- ? "&nbsp;"
194
- : `<span class="delete-email fw-link-text" data-email="${email.address}">` +
195
- '<i class="fa fa-trash-alt"></i>' +
196
- "</span>"
197
- }
198
- </td>
199
- </tr>`
200
- )
201
- .join("")}
202
- <tr>
203
- <td colspan="3"></td>
204
- <td class="profile-email-action">
205
- <span class="fw-link-text" id="add-profile-email">
206
- <i class="fa fa-plus-circle"></i>
207
- </span>
208
- </td>
209
- </tr>
210
- </tbody>
211
- </table>
83
+ <div class="profile-data-row">
84
+ <div class="fw-floating-field">
85
+ <label for="first_name">${gettext("First name")}</label>
86
+ <input type="text" name="firstname" id="first_name" placeholder=" " autocomplete="given-name" value="${escapeText(user.first_name)}" />
212
87
  </div>
213
- <div class="profile-data-row">
214
- <label class="form-label">${gettext("Language")}</label>
215
- <select name="language" id="language" class="entry-form dk fw-button fw-large">
216
- <option value="">${gettext("Default language")}</option>
217
- ${((settings.LANGUAGES as Array<[string, string]>) || [])
218
- .map(
219
- ([code, _name]) =>
220
- `<option value="${code}" ${user.language === code ? "selected" : ""}>${langName(code)}</option>`
221
- )
222
- .join("")}
223
- </select>
224
- <div class="fw-select-arrow fa fa-caret-down"></div>
88
+ </div>
89
+ <div class="profile-data-row">
90
+ <div class="fw-floating-field">
91
+ <label for="last_name">${gettext("Last name")}</label>
92
+ <input type="text" name="lastname" id="last_name" placeholder=" " autocomplete="family-name" value="${escapeText(user.last_name)}" />
225
93
  </div>
226
- <div class="profile-data-row">
227
- <label class="form-label">${gettext("Editor")}</label>
228
- <div class="profile-editor-settings">
229
- <label class="checkable-label">
230
- <input type="checkbox" id="inline-references" ${user.preferences?.inline_references ? "checked" : ""} />
231
- ${gettext("Enable inline reference typing (@)")}
232
- </label>
233
- <p class="inline-editor-hint">${gettext("Type @ in the editor to insert a citation or cross-reference:")}</p>
234
- <ul class="inline-editor-hint">
235
- <li>${gettext("Citation: @entry_key – optional suffix: @entry_key[prefix][locator]. Textual citation: @@entry_key. Multiple sources: @key1;key2")}</li>
236
- <li>${gettext("Cross-reference: @#target-id")}</li>
237
- </ul>
238
- <label class="checkable-label">
239
- <input type="checkbox" id="inline-math" ${user.preferences?.inline_math ? "checked" : ""} />
240
- ${gettext("Enable inline math typing ($)")}
241
- </label>
242
- <p class="inline-editor-hint">${gettext("Type $ in the editor followed by LaTeX math to insert an equation inline, e.g. $x^2. Press Enter or Tab to confirm.")}</p>
243
- <label class="checkable-label">
244
- <input type="checkbox" id="grammar-check-continuous" ${user.preferences?.grammar_check_continuous ? "checked" : ""} />
245
- ${gettext("Continuous spell and grammar checking")}
246
- </label>
247
- <p class="inline-editor-hint">${gettext("Check spelling and grammar while typing with the built-in LingoTweaker checker. It runs entirely in your browser; no external server is needed.")}</p>
248
-
249
- </div>
94
+ </div>
95
+ <div class="profile-data-row profile-password-row">
96
+ <div class="fw-floating-field">
97
+ <label for="profile-password-display">${gettext("Password")}</label>
98
+ <input type="password" id="profile-password-display" value="******" autocomplete="new-password" readonly disabled />
99
+ </div>
100
+ <button type="button" id="fw-edit-profile-pwd" class="fw-profile-action-btn" title="${gettext("Change password")}" aria-label="${gettext("Change password")}">
101
+ <i class="fa fa-check"></i>
102
+ </button>
103
+ </div>
104
+ </form>
105
+ ${
106
+ settings.TWO_FACTOR_ENABLED
107
+ ? `<div class="profile-data-row profile-switch-row">
108
+ <span class="form-label">${gettext("Two-Factor Authentication")}</span>
109
+ <div id="two-factor-status">
110
+ <span id="two-factor-enabled-status" style="display: none;">
111
+ <i class="fa fa-check"></i>
112
+ ${gettext("Enabled")}
113
+ </span>
114
+ <span id="two-factor-disabled-status" style="display: none;">
115
+ <i class="fa fa-times"></i>
116
+ ${gettext("Disabled")}
117
+ </span>
250
118
  </div>
251
- ${
252
- socialaccount_providers.length
253
- ? `<div class="profile-data-row">
254
- <table class="fw-data-table profile-social-accounts-table">
255
- <thead class="fw-data-table-header">
256
- <tr>
257
- <th>${gettext("Social Account Provider")}</th>
258
- <th>${gettext("Username")}</th>
259
- <th>&nbsp;&nbsp;&nbsp;&nbsp;</th>
260
- </tr>
261
- </thead>
262
- <tbody>
263
- ${socialaccount_providers
264
- .map((provider: any) => {
265
- const account =
266
- user.socialaccounts.find(
267
- (saccount: any) =>
268
- saccount.provider ===
269
- provider.id
270
- )
271
- if (account) {
272
- return `<tr>
273
- <td>${escapeText(provider.name)}</td>
274
- <td>${escapeText(account.name)}</td>
275
- <td>
276
- <span class="delete-socialaccount fw-link-text" data-socialaccount="${account.id}" data-provider="${escapeText(provider.name)}">
277
- <i class="fa fa-trash-alt"></i>
278
- </span>
279
- </td>
280
- </tr>`
281
- } else {
282
- return `<tr>
283
- <td>${escapeText(provider.name)}</td>
284
- <td>&nbsp;</td>
285
- <td><a href="${provider.login_url}?process=connect">${gettext("Connect")}</a></td>
286
- </tr>`
287
- }
288
- })
289
- .join("")}
290
- </tbody>
291
- </table>
292
- </div>`
293
- : ""
294
- }
295
- ${pluginTemplates.join("")}
296
- <div id="profile-submit-wrapper">
297
- <span id="submit-profile" class="fw-button fw-dark">
298
- ${gettext("Submit")}
119
+ <div id="two-factor-switch-host"></div>
120
+ </div>`
121
+ : ""
122
+ }
123
+ ${
124
+ settings.E2EE_MODE && settings.E2EE_MODE !== "disabled"
125
+ ? `<div class="profile-data-row">
126
+ <span class="form-label">${gettext("End-to-End Encryption")}</span>
127
+ <div id="e2ee-passphrase-status">
128
+ <span id="e2ee-passphrase-enabled-status" style="display: none;">
129
+ <i class="fa fa-check"></i>
130
+ ${gettext("Personal passphrase set up")}
299
131
  </span>
300
- <span id="delete-account" data-username="${user.username}" class="fw-button fw-orange">
301
- ${gettext("Delete account")}
132
+ <span id="e2ee-passphrase-disabled-status" style="display: none;">
133
+ <i class="fa fa-times"></i>
134
+ ${gettext("Not set up")}
302
135
  </span>
303
136
  </div>
137
+ <span id="setup-e2ee-passphrase" class="fw-link-text" style="display: none;">
138
+ <i class="fa fa-lock"></i>
139
+ ${gettext("Set up encryption passphrase")}
140
+ </span>
141
+ <span id="change-e2ee-passphrase" class="fw-link-text" style="display: none;">
142
+ <i class="fa fa-pencil-alt"></i>
143
+ ${gettext("Change passphrase")}
144
+ </span>
145
+ <span id="recover-e2ee-passphrase" class="fw-link-text" style="display: none;">
146
+ <i class="fa fa-key"></i>
147
+ ${gettext("Recover with recovery key")}
148
+ </span>
149
+ </div>`
150
+ : ""
151
+ }`
152
+
153
+ /** "Profile image" tab. */
154
+ export const profileAvatarTemplate = (user: Record<string, any>): string =>
155
+ `<div id="profile-avatar">
156
+ ${avatarTemplate({user})}
157
+ <div id="avatar-pulldown-wrapper">
158
+ <span id="edit-avatar-btn" class="fw-link-text">
159
+ ${gettext("Edit profile picture")}
160
+ </span>
161
+ <select id="edit-avatar-pulldown">
162
+ <option value="change">${gettext("Change picture")}</option>
163
+ ${user.avatar ? `<option value="delete">${gettext("Delete picture")}</option>` : ""}
164
+ </select>
165
+ </div>
304
166
  </div>`
167
+
168
+ /** "E-mail address" tab. */
169
+ export const profileEmailsTemplate = (user: Record<string, any>): string =>
170
+ `<table class="fw-data-table profile-email-table">
171
+ <thead class="fw-data-table-header">
172
+ <tr>
173
+ <th>${gettext("Email")}</th>
174
+ <th>${gettext("Primary address")}</th>
175
+ <th>${gettext("Verified")}</th>
176
+ <th>&nbsp;&nbsp;&nbsp;&nbsp;</th>
177
+ </tr>
178
+ </thead>
179
+ <tbody>
180
+ ${(user.emails as Array<Record<string, unknown>>)
181
+ .map(
182
+ (email: any) => `<tr${email.primary ? ' class="primary-email-tr"' : ""}>
183
+ <td class="emailaddress">${email.address}</td>
184
+ <td>
185
+ ${
186
+ email.verified
187
+ ? `<input type="radio" class="primary-email-radio" value="${email.address}"
188
+ name="primaryemail"${email.primary ? " checked" : ""} />`
189
+ : ""
190
+ }
191
+ </td>
192
+ <td>
193
+ ${email.verified ? '<i class="fa fa-check"></i>' : ""}
194
+ </td>
195
+ <td class="profile-email-action">
196
+ ${
197
+ email.primary
198
+ ? "&nbsp;"
199
+ : `<span class="delete-email fw-link-text" data-email="${email.address}">` +
200
+ '<i class="fa fa-trash-alt"></i>' +
201
+ "</span>"
202
+ }
203
+ </td>
204
+ </tr>`
205
+ )
206
+ .join("")}
207
+ <tr>
208
+ <td colspan="3"></td>
209
+ <td class="profile-email-action">
210
+ <span class="fw-link-text" id="add-profile-email">
211
+ <i class="fa fa-plus-circle"></i>
212
+ </span>
213
+ </td>
214
+ </tr>
215
+ </tbody>
216
+ </table>`
217
+
218
+ /** "Language" tab. */
219
+ export const profileLanguageTemplate = (
220
+ user: Record<string, any>,
221
+ settings: Record<string, unknown> = {}
222
+ ): string =>
223
+ `<div class="profile-data-row">
224
+ <label class="form-label" for="language">${gettext("Language")}</label>
225
+ <select name="language" id="language" class="entry-form dk fw-button fw-large">
226
+ <option value="">${gettext("Default language")}</option>
227
+ ${((settings.LANGUAGES as Array<[string, string]>) || [])
228
+ .map(
229
+ ([code, _name]) =>
230
+ `<option value="${code}" ${user.language === code ? "selected" : ""}>${langName(code)}</option>`
231
+ )
232
+ .join("")}
233
+ </select>
234
+ </div>`
235
+
236
+ /** "Editor" tab. */
237
+ export const profileEditorTemplate = (user: Record<string, any>): string =>
238
+ `<div class="profile-editor-settings">
239
+ <label class="checkable-label">
240
+ <input type="checkbox" id="inline-references" ${user.preferences?.inline_references ? "checked" : ""} />
241
+ ${gettext("Enable inline reference typing (@)")}
242
+ </label>
243
+ <p class="inline-editor-hint">${gettext("Type @ in the editor to insert a citation or cross-reference:")}</p>
244
+ <ul class="inline-editor-hint">
245
+ <li>${gettext("Citation: @entry_key – optional suffix: @entry_key[prefix][locator]. Textual citation: @@entry_key. Multiple sources: @key1;key2")}</li>
246
+ <li>${gettext("Cross-reference: @#target-id")}</li>
247
+ </ul>
248
+ <label class="checkable-label">
249
+ <input type="checkbox" id="inline-math" ${user.preferences?.inline_math ? "checked" : ""} />
250
+ ${gettext("Enable inline math typing ($)")}
251
+ </label>
252
+ <p class="inline-editor-hint">${gettext("Type $ in the editor followed by LaTeX math to insert an equation inline, e.g. $x^2. Press Enter or Tab to confirm.")}</p>
253
+ <label class="checkable-label">
254
+ <input type="checkbox" id="grammar-check-continuous" ${user.preferences?.grammar_check_continuous ? "checked" : ""} />
255
+ ${gettext("Continuous spell and grammar checking")}
256
+ </label>
257
+ <p class="inline-editor-hint">${gettext("Check spelling and grammar while typing with the built-in LingoTweaker checker. It runs entirely in your browser; no external server is needed.")}</p>
258
+ </div>`
259
+
260
+ /** "Social account providers" tab. */
261
+ export const profileSocialAccountsTemplate = (
262
+ user: Record<string, any>,
263
+ socialaccount_providers: Array<Record<string, unknown>>
264
+ ): string =>
265
+ `<table class="fw-data-table profile-social-accounts-table">
266
+ <thead class="fw-data-table-header">
267
+ <tr>
268
+ <th>${gettext("Social Account Provider")}</th>
269
+ <th>${gettext("Username")}</th>
270
+ <th>&nbsp;&nbsp;&nbsp;&nbsp;</th>
271
+ </tr>
272
+ </thead>
273
+ <tbody>
274
+ ${socialaccount_providers
275
+ .map((provider: any) => {
276
+ const account = user.socialaccounts.find(
277
+ (saccount: any) => saccount.provider === provider.id
278
+ )
279
+ if (account) {
280
+ return `<tr>
281
+ <td>${escapeText(provider.name)}</td>
282
+ <td>${escapeText(account.name)}</td>
283
+ <td>
284
+ <span class="delete-socialaccount fw-link-text" data-socialaccount="${account.id}" data-provider="${escapeText(provider.name)}">
285
+ <i class="fa fa-trash-alt"></i>
286
+ </span>
287
+ </td>
288
+ </tr>`
289
+ } else {
290
+ return `<tr>
291
+ <td>${escapeText(provider.name)}</td>
292
+ <td>&nbsp;</td>
293
+ <td><a href="${provider.login_url}?process=connect">${gettext("Connect")}</a></td>
294
+ </tr>`
295
+ }
296
+ })
297
+ .join("")}
298
+ </tbody>
299
+ </table>`
300
+
301
+ /** Tab containing plugin-provided profile content. */
302
+ export const profilePluginTemplate = (pluginTemplates: string[]): string =>
303
+ pluginTemplates.join("")