@fiduswriter/frontend 0.1.68 → 0.1.70
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/css/two_factor.css +0 -52
- package/css/user_template_manager.css +6 -0
- package/dist/css/bibliography/colors.css +0 -4
- package/dist/css/bibliography/forms.css +3 -61
- package/dist/css/document-template-editor/document_template_designer.css +68 -68
- package/dist/css/fwtoolkit/action_chooser_dialog.css +66 -0
- package/dist/css/fwtoolkit/action_toolbar.css +132 -0
- package/dist/css/fwtoolkit/alerts.css +53 -19
- package/dist/css/fwtoolkit/application_menu_controller.css +28 -0
- package/dist/css/fwtoolkit/attachment_field.css +19 -0
- package/dist/css/fwtoolkit/attachment_list.css +118 -0
- package/dist/css/fwtoolkit/avatar_label.css +80 -0
- package/dist/css/fwtoolkit/boolean_switch.css +128 -0
- package/dist/css/fwtoolkit/buttons.css +181 -85
- package/dist/css/fwtoolkit/category_filter_controller.css +11 -0
- package/dist/css/fwtoolkit/checkable_list.css +39 -6
- package/dist/css/fwtoolkit/colors.css +71 -69
- package/dist/css/fwtoolkit/common.css +49 -17
- package/dist/css/fwtoolkit/content_menu.css +49 -27
- package/dist/css/fwtoolkit/data_table.css +278 -41
- package/dist/css/fwtoolkit/datatable_bulk.css +106 -0
- package/dist/css/fwtoolkit/destination_settings_form.css +67 -0
- package/dist/css/fwtoolkit/dialog.css +100 -25
- package/dist/css/fwtoolkit/dialog_presets.css +157 -0
- package/dist/css/fwtoolkit/dialog_table.css +63 -26
- package/dist/css/fwtoolkit/directory_navigator.css +244 -0
- package/dist/css/fwtoolkit/drop_up.css +36 -24
- package/dist/css/fwtoolkit/faq_dialog.css +28 -4
- package/dist/css/fwtoolkit/file_input_field.css +150 -0
- package/dist/css/fwtoolkit/file_selector.css +265 -12
- package/dist/css/fwtoolkit/form_error_summary.css +53 -0
- package/dist/css/fwtoolkit/forms.css +261 -54
- package/dist/css/fwtoolkit/fwtoolkit.css +6618 -1522
- package/dist/css/fwtoolkit/grid_size_picker.css +119 -0
- package/dist/css/fwtoolkit/icon_button_group.css +110 -0
- package/dist/css/fwtoolkit/image_preview_field.css +156 -0
- package/dist/css/fwtoolkit/inline_status.css +69 -0
- package/dist/css/fwtoolkit/inline_tools.css +47 -16
- package/dist/css/fwtoolkit/input_list.css +33 -2
- package/dist/css/fwtoolkit/loader.css +12 -2
- package/dist/css/fwtoolkit/media_card_grid.css +251 -0
- package/dist/css/fwtoolkit/navigation_drawer.css +172 -0
- package/dist/css/fwtoolkit/one_time_code_field.css +135 -0
- package/dist/css/fwtoolkit/overflow_action_bar.css +28 -0
- package/dist/css/fwtoolkit/overview_menu.css +35 -27
- package/dist/css/fwtoolkit/permission_badge.css +121 -0
- package/dist/css/fwtoolkit/progress_task.css +51 -27
- package/dist/css/fwtoolkit/pulldown.css +50 -22
- package/dist/css/fwtoolkit/pulldown_menu.css +22 -11
- package/dist/css/fwtoolkit/remote_options_field.css +297 -0
- package/dist/css/fwtoolkit/reset.css +4 -3
- package/dist/css/fwtoolkit/resource_field.css +134 -0
- package/dist/css/fwtoolkit/sortable_list.css +160 -0
- package/dist/css/fwtoolkit/text.css +54 -15
- package/dist/css/fwtoolkit/token_input.css +189 -0
- package/dist/css/fwtoolkit/tokens.css +158 -0
- package/dist/css/fwtoolkit/tree_view.css +165 -0
- package/dist/css/fwtoolkit/two_pane_selector.css +150 -9
- package/dist/css/fwtoolkit/ui_tabs.css +41 -13
- package/dist/css/image-manager/dialog_usermedia.css +41 -41
- package/dist/css/manifest.json +29 -0
- package/dist/css/two_factor.css +0 -52
- package/dist/css/user_template_manager.css +6 -0
- package/dist/document_templates/editor.d.ts +3 -0
- package/dist/document_templates/editor.d.ts.map +1 -1
- package/dist/document_templates/editor.js +35 -18
- package/dist/document_templates/editor.js.map +1 -1
- package/dist/user/auth/two_factor.d.ts.map +1 -1
- package/dist/user/auth/two_factor.js +133 -157
- package/dist/user/auth/two_factor.js.map +1 -1
- package/package.json +9 -9
- package/src/document_templates/editor.ts +41 -21
- package/src/user/auth/two_factor.ts +203 -228
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { Dialog, activateWait, addAlert, deactivateWait } from "fwtoolkit";
|
|
1
|
+
import { Dialog, OneTimeCodeField, activateWait, addAlert, deactivateWait, escapeText } from "fwtoolkit";
|
|
2
2
|
import QRCode from "qrcode";
|
|
3
|
+
const reportCodeError = (field, message) => {
|
|
4
|
+
addAlert("error", message);
|
|
5
|
+
field?.setError(message);
|
|
6
|
+
};
|
|
3
7
|
export const twoFactorSetupDialog = (app) => {
|
|
4
8
|
let secretKey = null;
|
|
5
9
|
let deviceId = null;
|
|
6
10
|
activateWait();
|
|
7
|
-
return app.apiConnectors.auth
|
|
11
|
+
return app.apiConnectors.auth
|
|
12
|
+
.twoFactorSetup()
|
|
13
|
+
.then((json) => {
|
|
8
14
|
deactivateWait();
|
|
9
15
|
if (json.status !== "success") {
|
|
10
16
|
const message = json.message || gettext("Two-factor setup failed.");
|
|
@@ -26,44 +32,16 @@ export const twoFactorSetupDialog = (app) => {
|
|
|
26
32
|
}, function (error, canvas) {
|
|
27
33
|
if (error) {
|
|
28
34
|
console.error("QR Code generation error:", error);
|
|
29
|
-
|
|
35
|
+
const message = document.createElement("p");
|
|
36
|
+
message.style.color = "red";
|
|
37
|
+
message.textContent = gettext("Could not generate QR code. Please use the secret key below.");
|
|
38
|
+
qrContainer.replaceChildren(message);
|
|
30
39
|
}
|
|
31
40
|
else {
|
|
32
|
-
qrContainer.
|
|
41
|
+
qrContainer.replaceChildren(canvas);
|
|
33
42
|
}
|
|
34
43
|
});
|
|
35
|
-
|
|
36
|
-
{
|
|
37
|
-
text: gettext("Verify"),
|
|
38
|
-
classes: "fw-dark",
|
|
39
|
-
click: () => {
|
|
40
|
-
const codeInput = document.querySelector("#two-factor-code");
|
|
41
|
-
const code = codeInput.value.trim();
|
|
42
|
-
if (code.length !== 6) {
|
|
43
|
-
addAlert("error", gettext("Please enter a 6-digit code."));
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
app.apiConnectors.auth.twoFactorVerify({
|
|
47
|
-
code,
|
|
48
|
-
device_id: deviceId
|
|
49
|
-
})
|
|
50
|
-
.then((json) => {
|
|
51
|
-
if (json.status === "success") {
|
|
52
|
-
addAlert("success", json.message);
|
|
53
|
-
dialog.close();
|
|
54
|
-
window.location.reload();
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
addAlert("error", json.message);
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
.catch(() => {
|
|
61
|
-
addAlert("error", gettext("Could not verify the code."));
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
{ type: "cancel" }
|
|
66
|
-
];
|
|
44
|
+
let codeField;
|
|
67
45
|
const dialog = new Dialog({
|
|
68
46
|
id: "two-factor-setup-dialog",
|
|
69
47
|
title: gettext("Set Up Two-Factor Authentication"),
|
|
@@ -71,90 +49,56 @@ export const twoFactorSetupDialog = (app) => {
|
|
|
71
49
|
<p>${gettext("Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)")}</p>
|
|
72
50
|
<div class="two-factor-qr-wrapper"></div>
|
|
73
51
|
<p><strong>${gettext("Or enter this code manually:")}</strong></p>
|
|
74
|
-
<code class="two-factor-secret">${secretKey}</code>
|
|
52
|
+
<code class="two-factor-secret">${escapeText(secretKey)}</code>
|
|
75
53
|
<div class="two-factor-verify-section">
|
|
76
|
-
<
|
|
77
|
-
<input type="text" id="two-factor-code" placeholder="123456" maxlength="6" class="fw-button fw-large" autocomplete="one-time-code" />
|
|
54
|
+
<div id="two-factor-code-host"></div>
|
|
78
55
|
</div>
|
|
79
56
|
`,
|
|
80
|
-
buttons,
|
|
57
|
+
buttons: [{ type: "cancel" }],
|
|
58
|
+
onClose: () => codeField?.destroy(),
|
|
81
59
|
icon: "shield-alt",
|
|
82
60
|
width: 500
|
|
83
61
|
});
|
|
84
62
|
dialog.open();
|
|
85
63
|
const qrWrapper = dialog.dialogEl.querySelector(".two-factor-qr-wrapper");
|
|
86
|
-
if (qrWrapper
|
|
64
|
+
if (qrWrapper) {
|
|
87
65
|
qrWrapper.appendChild(qrContainer);
|
|
88
66
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const buttons = [
|
|
103
|
-
{
|
|
104
|
-
text: gettext("Disable 2FA"),
|
|
105
|
-
classes: "fw-orange",
|
|
106
|
-
click: () => {
|
|
107
|
-
const passwordInput = document.getElementById("two-factor-disable-password");
|
|
108
|
-
const codeInput = document.getElementById("two-factor-disable-code");
|
|
109
|
-
const password = passwordInput ? passwordInput.value : "";
|
|
110
|
-
const code = codeInput ? codeInput.value.trim() : "";
|
|
111
|
-
if (password.length === 0) {
|
|
112
|
-
addAlert("error", gettext("Please enter your password."));
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
if (code.length !== 6) {
|
|
116
|
-
addAlert("error", gettext("Please enter a 6-digit code."));
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
activateWait();
|
|
120
|
-
app.apiConnectors.auth
|
|
121
|
-
.twoFactorDisable({ password, code })
|
|
122
|
-
.then((json) => {
|
|
123
|
-
if (json.status === "success") {
|
|
124
|
-
addAlert("success", json.message);
|
|
67
|
+
codeField = new OneTimeCodeField({
|
|
68
|
+
id: "two-factor-code",
|
|
69
|
+
label: gettext("Enter the 6-digit code from your authenticator app to verify:"),
|
|
70
|
+
description: "",
|
|
71
|
+
length: 6,
|
|
72
|
+
onComplete: async (code) => {
|
|
73
|
+
try {
|
|
74
|
+
const response = await app.apiConnectors.auth.twoFactorVerify({
|
|
75
|
+
code,
|
|
76
|
+
device_id: deviceId
|
|
77
|
+
});
|
|
78
|
+
if (response.status === "success") {
|
|
79
|
+
addAlert("success", response.message);
|
|
125
80
|
dialog.close();
|
|
126
81
|
window.location.reload();
|
|
127
82
|
}
|
|
128
83
|
else {
|
|
129
|
-
|
|
84
|
+
reportCodeError(codeField, response.message ||
|
|
85
|
+
gettext("Could not verify the code."));
|
|
130
86
|
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const response = errorResponse;
|
|
136
|
-
if (response && typeof response.json === "function") {
|
|
137
|
-
response
|
|
138
|
-
.json()
|
|
139
|
-
.then((json) => {
|
|
140
|
-
addAlert("error", json.message ||
|
|
141
|
-
gettext("Could not disable two-factor authentication."));
|
|
142
|
-
})
|
|
143
|
-
.catch(() => {
|
|
144
|
-
addAlert("error", gettext("Could not disable two-factor authentication."));
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
addAlert("error", gettext("Could not disable two-factor authentication."));
|
|
149
|
-
}
|
|
150
|
-
})
|
|
151
|
-
.then(() => {
|
|
152
|
-
deactivateWait();
|
|
153
|
-
});
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
reportCodeError(codeField, gettext("Could not verify the code."));
|
|
90
|
+
}
|
|
154
91
|
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
92
|
+
});
|
|
93
|
+
codeField.input.placeholder = "123456";
|
|
94
|
+
dialog.dialogEl
|
|
95
|
+
.querySelector("#two-factor-code-host")
|
|
96
|
+
.appendChild(codeField.element);
|
|
97
|
+
codeField.input.focus();
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
export const twoFactorDisableDialog = (app) => {
|
|
101
|
+
let codeField;
|
|
158
102
|
const dialog = new Dialog({
|
|
159
103
|
id: "two-factor-disable-dialog",
|
|
160
104
|
title: gettext("Disable Two-Factor Authentication"),
|
|
@@ -165,80 +109,112 @@ export const twoFactorDisableDialog = (app) => {
|
|
|
165
109
|
<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" />
|
|
166
110
|
</div>
|
|
167
111
|
<div class="two-factor-verify-section">
|
|
168
|
-
<
|
|
169
|
-
<input type="text" id="two-factor-disable-code" placeholder="123456" maxlength="6" class="fw-button fw-large" autocomplete="one-time-code" />
|
|
112
|
+
<div id="two-factor-disable-code-host"></div>
|
|
170
113
|
</div>`,
|
|
171
|
-
buttons,
|
|
114
|
+
buttons: [{ type: "cancel" }],
|
|
115
|
+
onClose: () => codeField?.destroy(),
|
|
172
116
|
icon: "exclamation-triangle"
|
|
173
117
|
});
|
|
174
118
|
dialog.open();
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
119
|
+
codeField = new OneTimeCodeField({
|
|
120
|
+
id: "two-factor-disable-code",
|
|
121
|
+
label: gettext("Authenticator code"),
|
|
122
|
+
description: "",
|
|
123
|
+
length: 6,
|
|
124
|
+
onComplete: async (code) => {
|
|
125
|
+
const password = dialog.dialogEl.querySelector("#two-factor-disable-password")?.value ?? "";
|
|
126
|
+
if (password.length === 0) {
|
|
127
|
+
addAlert("error", gettext("Please enter your password."));
|
|
128
|
+
return;
|
|
182
129
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
};
|
|
187
|
-
export const twoFactorLoginDialog = ({ login, password, remember, loginPage, app }) => {
|
|
188
|
-
const buttons = [
|
|
189
|
-
{
|
|
190
|
-
text: gettext("Verify"),
|
|
191
|
-
classes: "fw-dark",
|
|
192
|
-
click: () => {
|
|
193
|
-
const twofactorInput = dialog.dialogEl.querySelector("#two-factor-code");
|
|
194
|
-
const twofactor = twofactorInput ? twofactorInput.value.trim() : "";
|
|
195
|
-
if (twofactor.length !== 6) {
|
|
196
|
-
addAlert("error", gettext("Please enter a 6-digit code."));
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
activateWait();
|
|
200
|
-
app.apiConnectors.auth.twoFactorLogin({
|
|
201
|
-
login,
|
|
130
|
+
activateWait();
|
|
131
|
+
try {
|
|
132
|
+
const response = await app.apiConnectors.auth.twoFactorDisable({
|
|
202
133
|
password,
|
|
203
|
-
|
|
204
|
-
twofactor
|
|
205
|
-
})
|
|
206
|
-
.then((json) => {
|
|
207
|
-
deactivateWait();
|
|
208
|
-
dialog.close();
|
|
209
|
-
loginPage.afterLogin(json);
|
|
210
|
-
})
|
|
211
|
-
.catch(() => {
|
|
212
|
-
addAlert("error", gettext("Could not verify the code."));
|
|
213
|
-
deactivateWait();
|
|
134
|
+
code
|
|
214
135
|
});
|
|
136
|
+
if (response.status === "success") {
|
|
137
|
+
addAlert("success", response.message);
|
|
138
|
+
dialog.close();
|
|
139
|
+
window.location.reload();
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
reportCodeError(codeField, response.message);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (errorResponse) {
|
|
146
|
+
let message = gettext("Could not disable two-factor authentication.");
|
|
147
|
+
const response = errorResponse;
|
|
148
|
+
if (response && typeof response.json === "function") {
|
|
149
|
+
try {
|
|
150
|
+
const json = (await response.json());
|
|
151
|
+
message = json.message || message;
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
// Keep the generic message when the response is not JSON.
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
reportCodeError(codeField, message);
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
deactivateWait();
|
|
215
161
|
}
|
|
216
162
|
}
|
|
217
|
-
|
|
163
|
+
});
|
|
164
|
+
codeField.input.placeholder = "123456";
|
|
165
|
+
dialog.dialogEl
|
|
166
|
+
.querySelector("#two-factor-disable-code-host")
|
|
167
|
+
.appendChild(codeField.element);
|
|
168
|
+
dialog.dialogEl.querySelector("#two-factor-disable-password").focus();
|
|
169
|
+
return dialog;
|
|
170
|
+
};
|
|
171
|
+
export const twoFactorLoginDialog = ({ login, password, remember, loginPage, app }) => {
|
|
172
|
+
let codeField;
|
|
218
173
|
const dialog = new Dialog({
|
|
219
174
|
id: "two-factor-login-dialog",
|
|
220
175
|
title: gettext("Two-Factor Authentication"),
|
|
221
176
|
body: `<p>${gettext("Enter the 6-digit code from your authenticator app:")}</p>
|
|
222
|
-
<
|
|
223
|
-
|
|
177
|
+
<div id="two-factor-code-host"></div>`,
|
|
178
|
+
onClose: () => codeField?.destroy(),
|
|
224
179
|
icon: "shield-alt",
|
|
225
180
|
width: 500
|
|
226
181
|
});
|
|
227
182
|
dialog.open();
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
183
|
+
codeField = new OneTimeCodeField({
|
|
184
|
+
id: "two-factor-code",
|
|
185
|
+
label: gettext("Enter the 6-digit code from your authenticator app:"),
|
|
186
|
+
description: "",
|
|
187
|
+
length: 6,
|
|
188
|
+
onComplete: async (twofactor) => {
|
|
189
|
+
activateWait();
|
|
190
|
+
try {
|
|
191
|
+
const response = await app.apiConnectors.auth.twoFactorLogin({
|
|
192
|
+
login,
|
|
193
|
+
password,
|
|
194
|
+
remember,
|
|
195
|
+
twofactor
|
|
196
|
+
});
|
|
197
|
+
dialog.close();
|
|
198
|
+
loginPage.afterLogin(response);
|
|
235
199
|
}
|
|
236
|
-
|
|
237
|
-
|
|
200
|
+
catch {
|
|
201
|
+
reportCodeError(codeField, gettext("Could not verify the code."));
|
|
202
|
+
}
|
|
203
|
+
finally {
|
|
204
|
+
deactivateWait();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
codeField.input.placeholder = "123456";
|
|
209
|
+
dialog.dialogEl
|
|
210
|
+
.querySelector("#two-factor-code-host")
|
|
211
|
+
.appendChild(codeField.element);
|
|
212
|
+
codeField.input.focus();
|
|
238
213
|
return dialog;
|
|
239
214
|
};
|
|
240
215
|
export const checkTwoFactorStatus = (app) => {
|
|
241
|
-
return app.apiConnectors.auth
|
|
216
|
+
return app.apiConnectors.auth
|
|
217
|
+
.twoFactorStatus()
|
|
242
218
|
.then((json) => {
|
|
243
219
|
if (json.status === "success") {
|
|
244
220
|
return json.enabled;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"two_factor.js","sourceRoot":"","sources":["../../../src/user/auth/two_factor.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,cAAc,
|
|
1
|
+
{"version":3,"file":"two_factor.js","sourceRoot":"","sources":["../../../src/user/auth/two_factor.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,MAAM,EACN,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,UAAU,EACb,MAAM,WAAW,CAAA;AAClB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAQ3B,MAAM,eAAe,GAAG,CACpB,KAAmC,EACnC,OAAe,EACX,EAAE;IACN,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC1B,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAgB,EAAgB,EAAE;IACnE,IAAI,SAAS,GAAkB,IAAI,CAAA;IACnC,IAAI,QAAQ,GAAkB,IAAI,CAAA;IAElC,YAAY,EAAE,CAAA;IACd,OAAO,GAAG,CAAC,aAAa,CAAC,IAAI;SACxB,cAAc,EAAE;SAChB,IAAI,CAAC,CAAC,IAA4B,EAAO,EAAE;QACxC,cAAc,EAAE,CAAA;QAEhB,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,OAAO,GACT,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,0BAA0B,CAAC,CAAA;YACvD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YAC1B,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAClC,CAAC;QAED,SAAS,GAAG,IAAI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M,CAAC,QAAQ;SACV,aAAa,CAAC,uBAAuB,CAAE;SACvC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;IACnC,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACvB,OAAO,MAAM,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAgB,EAAoB,EAAE;IACvE,OAAO,GAAG,CAAC,aAAa,CAAC,IAAI;SACxB,eAAe,EAAE;SACjB,IAAI,CAAC,CAAC,IAA6B,EAAE,EAAE;QACpC,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,OAAO,CAAA;QACvB,CAAC;QACD,OAAO,KAAK,CAAA;IAChB,CAAC,CAAC;SACD,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAA;AAC3B,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiduswriter/frontend",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.70",
|
|
4
4
|
"description": "Fidus Writer-specific shared utilities and UI chrome",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fiduswriter",
|
|
@@ -206,18 +206,17 @@
|
|
|
206
206
|
"format": "prettier --write .",
|
|
207
207
|
"format:check": "prettier --check .",
|
|
208
208
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config jest.config.js",
|
|
209
|
-
"install-hooks": "husky"
|
|
210
|
-
"postinstall": "node scripts/aggregate-assets.js"
|
|
209
|
+
"install-hooks": "husky"
|
|
211
210
|
},
|
|
212
211
|
"dependencies": {
|
|
213
|
-
"@fiduswriter/bibliography-manager": "^0.1.
|
|
214
|
-
"@fiduswriter/document": "^0.3.
|
|
215
|
-
"@fiduswriter/document-template-editor": "^0.1.
|
|
216
|
-
"@fiduswriter/editor": "^0.2.
|
|
217
|
-
"@fiduswriter/image-manager": "^0.1.
|
|
212
|
+
"@fiduswriter/bibliography-manager": "^0.1.39",
|
|
213
|
+
"@fiduswriter/document": "^0.3.43",
|
|
214
|
+
"@fiduswriter/document-template-editor": "^0.1.24",
|
|
215
|
+
"@fiduswriter/editor": "^0.2.52",
|
|
216
|
+
"@fiduswriter/image-manager": "^0.1.31",
|
|
218
217
|
"downloadjs": "^1.4.7",
|
|
219
218
|
"fast-deep-equal": "^3.1.3",
|
|
220
|
-
"fwtoolkit": "^0.
|
|
219
|
+
"fwtoolkit": "^1.0.0",
|
|
221
220
|
"jszip": "^3.10.1",
|
|
222
221
|
"prosemirror-history": "^1.3.2",
|
|
223
222
|
"prosemirror-keymap": "^1.2.2",
|
|
@@ -252,6 +251,7 @@
|
|
|
252
251
|
"fwtoolkit": [
|
|
253
252
|
"reset.css",
|
|
254
253
|
"colors.css",
|
|
254
|
+
"tokens.css",
|
|
255
255
|
"forms.css",
|
|
256
256
|
"buttons.css",
|
|
257
257
|
"dialog.css",
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
DocumentTemplateExporter
|
|
5
5
|
} from "@fiduswriter/document-template-editor"
|
|
6
6
|
import {
|
|
7
|
+
ActionToolbar,
|
|
7
8
|
addAlert,
|
|
8
9
|
ensureCSS,
|
|
9
10
|
findTarget,
|
|
@@ -26,6 +27,7 @@ export class DocTemplatesEditor {
|
|
|
26
27
|
template: any
|
|
27
28
|
templateDesigner: any
|
|
28
29
|
dom!: HTMLElement
|
|
30
|
+
private actionToolbar?: ActionToolbar
|
|
29
31
|
|
|
30
32
|
constructor(
|
|
31
33
|
{app, user}: {app: AppLike; user: Record<string, unknown>},
|
|
@@ -73,6 +75,7 @@ export class DocTemplatesEditor {
|
|
|
73
75
|
this.app.apiConnectors.documentTemplate
|
|
74
76
|
)
|
|
75
77
|
this.templateDesigner.init()
|
|
78
|
+
this.initActions()
|
|
76
79
|
this.bind()
|
|
77
80
|
})
|
|
78
81
|
}
|
|
@@ -97,13 +100,8 @@ export class DocTemplatesEditor {
|
|
|
97
100
|
<div class="fw-contents template-editor-wrapper">
|
|
98
101
|
<div id="template-editor"></div>
|
|
99
102
|
<ul class="fw-errorlist"></ul>
|
|
100
|
-
<div class="fw-dialog-buttonset">
|
|
101
|
-
<
|
|
102
|
-
${gettext("Save")}
|
|
103
|
-
</button>
|
|
104
|
-
<button type="button" class="fw-dark fw-button fw-dialog-titlebar-button ui-corner-all ui-widget download">
|
|
105
|
-
${gettext("Download")}
|
|
106
|
-
</button>
|
|
103
|
+
<div class="fw-dialog-buttonset template-editor-actions">
|
|
104
|
+
<div id="template-actions"></div>
|
|
107
105
|
<button type="button" class="fw-orange fw-button fw-dialog-titlebar-button ui-corner-all ui-widget close">
|
|
108
106
|
${gettext("Close")}
|
|
109
107
|
</button>
|
|
@@ -134,12 +132,14 @@ export class DocTemplatesEditor {
|
|
|
134
132
|
this.showErrors(errors)
|
|
135
133
|
return Promise.reject()
|
|
136
134
|
} else {
|
|
137
|
-
return this.app.apiConnectors.documentTemplate
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
135
|
+
return this.app.apiConnectors.documentTemplate
|
|
136
|
+
.save({
|
|
137
|
+
id: this.id,
|
|
138
|
+
value,
|
|
139
|
+
import_id,
|
|
140
|
+
title
|
|
141
|
+
})
|
|
142
|
+
.then(() => addAlert("info", gettext("Saved template")))
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -153,18 +153,38 @@ export class DocTemplatesEditor {
|
|
|
153
153
|
})
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
private initActions(): void {
|
|
157
|
+
const mount = this.dom.querySelector<HTMLElement>("#template-actions")
|
|
158
|
+
if (!mount) {
|
|
159
|
+
return
|
|
160
|
+
}
|
|
161
|
+
this.actionToolbar = new ActionToolbar({
|
|
162
|
+
label: gettext("Template actions"),
|
|
163
|
+
actions: [
|
|
164
|
+
{
|
|
165
|
+
id: "save",
|
|
166
|
+
label: gettext("Save"),
|
|
167
|
+
onActivate: () => this.save()
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
id: "download",
|
|
171
|
+
label: gettext("Download"),
|
|
172
|
+
onActivate: () => this.download()
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
})
|
|
176
|
+
mount.appendChild(this.actionToolbar.element)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
close(): void {
|
|
180
|
+
this.actionToolbar?.destroy()
|
|
181
|
+
this.actionToolbar = undefined
|
|
182
|
+
}
|
|
183
|
+
|
|
156
184
|
bind(): void {
|
|
157
185
|
this.dom.addEventListener("click", (event: Event) => {
|
|
158
186
|
const el: Record<string, any> = {}
|
|
159
187
|
switch (true) {
|
|
160
|
-
case findTarget(event, "button.save", el):
|
|
161
|
-
event.preventDefault()
|
|
162
|
-
this.save()
|
|
163
|
-
break
|
|
164
|
-
case findTarget(event, "button.download", el):
|
|
165
|
-
event.preventDefault()
|
|
166
|
-
this.download()
|
|
167
|
-
break
|
|
168
188
|
case findTarget(event, "button.close, span.close", el):
|
|
169
189
|
event.preventDefault()
|
|
170
190
|
this.app.goTo("/templates/")
|