@crowdin/app-project-module 0.94.3 → 0.95.0
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.
|
@@ -10,8 +10,21 @@ const util_1 = require("../../util");
|
|
|
10
10
|
function register({ config, app }) {
|
|
11
11
|
var _a, _b;
|
|
12
12
|
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
13
|
-
if (
|
|
14
|
-
|
|
13
|
+
if (!config.contextMenu) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(config.contextMenu)) {
|
|
17
|
+
config.contextMenu.forEach((contextMenu) => {
|
|
18
|
+
if ((contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.uiPath) || (contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.formSchema)) {
|
|
19
|
+
app.use(`/context-${contextMenu.key}`, (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: contextMenu.key }), (0, render_ui_module_1.default)(contextMenu));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
// backward compatibility will be removed after migration
|
|
25
|
+
if (((_a = config.contextMenu) === null || _a === void 0 ? void 0 : _a.uiPath) || ((_b = config.contextMenu) === null || _b === void 0 ? void 0 : _b.formSchema)) {
|
|
26
|
+
app.use('/context', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.contextMenu.key }), (0, render_ui_module_1.default)(config.contextMenu));
|
|
27
|
+
}
|
|
15
28
|
}
|
|
16
29
|
}
|
|
17
30
|
exports.register = register;
|
package/out/modules/manifest.js
CHANGED
|
@@ -210,19 +210,35 @@ function handle(config) {
|
|
|
210
210
|
modules['modal'] = modals;
|
|
211
211
|
}
|
|
212
212
|
if (config.contextMenu) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
213
|
+
let contextMenus = [];
|
|
214
|
+
if (Array.isArray(config.contextMenu)) {
|
|
215
|
+
contextMenus = config.contextMenu.map((contextMenu, i) => {
|
|
216
|
+
const moduleKey = contextMenu.key || `${config.identifier}-context-menu-${i}`;
|
|
217
|
+
return Object.assign({ key: moduleKey, name: contextMenu.name || config.name, description: config.description, options: Object.assign(Object.assign({ location: contextMenu.location, type: contextMenu.type }, (contextMenu.module && contextMenu.moduleKey
|
|
218
|
+
? {
|
|
219
|
+
module: {
|
|
220
|
+
[contextMenu.module]: contextMenu.moduleKey,
|
|
221
|
+
},
|
|
222
|
+
}
|
|
223
|
+
: {})), { url: `/context-${moduleKey}/` + (contextMenu.fileName || 'index.html') }), signaturePatterns: contextMenu.signaturePatterns }, (!!contextMenu.environments && {
|
|
224
|
+
environments: normalizeEnvironments(contextMenu.environments),
|
|
225
|
+
}));
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
contextMenus = [
|
|
230
|
+
Object.assign({ key: config.identifier + '-context-menu', name: config.contextMenu.name || config.name, description: config.description, options: Object.assign(Object.assign({ location: config.contextMenu.location, type: config.contextMenu.type }, (config.contextMenu.module
|
|
231
|
+
? {
|
|
232
|
+
module: {
|
|
233
|
+
[config.contextMenu.module]: modules[config.contextMenu.module][0].key,
|
|
234
|
+
},
|
|
235
|
+
}
|
|
236
|
+
: {})), { url: '/context/' + (config.contextMenu.fileName || 'index.html') }), signaturePatterns: config.contextMenu.signaturePatterns }, (!!config.contextMenu.environments && {
|
|
237
|
+
environments: normalizeEnvironments(config.contextMenu.environments),
|
|
238
|
+
})),
|
|
239
|
+
];
|
|
240
|
+
}
|
|
241
|
+
modules['context-menu'] = contextMenus;
|
|
226
242
|
}
|
|
227
243
|
if (config.api) {
|
|
228
244
|
modules['api'] = (0, api_1.getApiManifest)(config, config.api);
|
|
@@ -21,6 +21,7 @@ function register({ config, app }) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
|
+
// backward compatibility will be removed after migration
|
|
24
25
|
if (((_a = config.modal) === null || _a === void 0 ? void 0 : _a.uiPath) || ((_b = config.modal) === null || _b === void 0 ? void 0 : _b.formSchema)) {
|
|
25
26
|
app.use('/modal', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.modal.key }), (0, render_ui_module_1.default)(config.modal));
|
|
26
27
|
}
|
package/out/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Crowdin from '@crowdin/crowdin-api-client';
|
|
2
2
|
import { JwtPayload, VerifyOptions } from '@crowdin/crowdin-apps-functions';
|
|
3
3
|
import { Request } from 'express';
|
|
4
|
-
import {
|
|
4
|
+
import { ContextContent } from './modules/context-menu/types';
|
|
5
5
|
import { CustomMTLogic } from './modules/custom-mt/types';
|
|
6
6
|
import { CustomSpellcheckerModule } from './modules/custom-spell-check/types';
|
|
7
7
|
import { EditorPanels } from './modules/editor-right-panel/types';
|
|
@@ -155,7 +155,7 @@ export interface ClientConfig extends ImagePath {
|
|
|
155
155
|
/**
|
|
156
156
|
* context menu module
|
|
157
157
|
*/
|
|
158
|
-
contextMenu?: ContextModule
|
|
158
|
+
contextMenu?: ContextModule | ContextModule[];
|
|
159
159
|
/**
|
|
160
160
|
* modal module
|
|
161
161
|
*/
|
|
@@ -499,4 +499,6 @@ export declare enum storageFiles {
|
|
|
499
499
|
}
|
|
500
500
|
export interface ModalModule extends ModuleContent, UiModule, Environments {
|
|
501
501
|
}
|
|
502
|
+
export interface ContextModule extends ContextContent, UiModule, Environments {
|
|
503
|
+
}
|
|
502
504
|
export {};
|
package/package.json
CHANGED