Skip to content

TagSpaces is an offline, open source, document manager with tagging support

fix for html extension

Stanimird90278345536
diff --git a/release/app/package-lock.json b/release/app/package-lock.json
index dd344b2cb..358c751f4 100644
--- a/release/app/package-lock.json
+++ b/release/app/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "tagspaces",
- "version": "6.4.9",
+ "version": "6.4.10",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "tagspaces",
- "version": "6.4.9",
+ "version": "6.4.10",
"hasInstallScript": true,
"license": "AGPL-3.0",
"dependencies": {
diff --git a/src/main/extension-utils.ts b/src/main/extension-utils.ts
index f1f5044ab..8d9b66cb3 100644
--- a/src/main/extension-utils.ts
+++ b/src/main/extension-utils.ts
@@ -93,36 +93,47 @@ function processDirs(
} = packageJsonObj['tsextension'];
const extensionId =
- (id ? id : '@tagspaces/extensions/' + dir.name) +
+ (id || '@tagspaces/extensions/' + dir.name) +
(buildFolder ? '/' + buildFolder : '');
if (fileTypes) {
fileTypes.forEach((fileType) => {
- if (fileType.ext) {
- const supportTypes = fileType.types ? fileType.types : types;
- const supportedTypes = supportTypes.map((type) => ({
- [type]: extensionId,
- ...(isExternal && { extensionExternalPath: directoryPath }),
- }));
+ if (!fileType.ext) return;
+ // each fileType may target multiple "types" (viewer/editor etc.)
+ const supportTypes = fileType.types || types;
+ const supportedTypes = supportTypes.map((type) => ({
+ [type]: extensionId,
+ ...(isExternal && { extensionExternalPath: directoryPath }),
+ }));
- const existingItemIndex = supportedFileTypes.findIndex(
- (item) => item.type === fileType.ext,
- );
- if (existingItemIndex !== -1) {
- if (isDefault) {
- // If an item with the same id already exists, update its properties
- supportedFileTypes[existingItemIndex] = {
- ...supportedFileTypes[existingItemIndex],
- ...supportedTypes.reduce((a, b) => ({ ...a, ...b })),
- };
- }
- } else {
- supportedFileTypes.push({
- type: fileType.ext,
- color: fileType.color ? fileType.color : color,
- ...supportedTypes.reduce((a, b) => ({ ...a, ...b })),
+ // find existing slot by extension
+ const idx = supportedFileTypes.findIndex(
+ (item) => item.type === fileType.ext,
+ );
+ if (idx !== -1 && isDefault) {
+ // If an item with the same id already exists, update its properties
+ supportedFileTypes[idx] = {
+ ...supportedFileTypes[idx],
+ ...supportedTypes.reduce((a, b) => ({ ...a, ...b }), {}),
+ };
+ } else if (idx !== -1) {
+ // merge only missing props
+ const existing = supportedFileTypes[idx];
+ // merge in any new role/extension mappings
+ supportedTypes.forEach((st) => {
+ Object.keys(st).forEach((role) => {
+ if (!existing[role]) {
+ existing[role] = st[role];
+ }
});
- }
+ });
+ // color stays as-is, extensions slot keyed by type
+ } else {
+ supportedFileTypes.push({
+ type: fileType.ext,
+ color: fileType.color || color || '',
+ ...supportedTypes.reduce((a, b) => ({ ...a, ...b }), {}),
+ });
}
});
}