Skip to content

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

add extractPdfcontent method (#2194)

Stanimir93bfe293a28d
diff --git a/package-lock.json b/package-lock.json
index d6332b173..856df19e6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -19,10 +19,10 @@
"@mui/lab": "5.0.0-alpha.170",
"@mui/material": "^5.15.19",
"@mui/x-date-pickers": "^5.0.20",
- "@tagspaces/tagspaces-common": "4.5.25",
- "@tagspaces/tagspaces-common-aws3": "4.5.25",
- "@tagspaces/tagspaces-common-cordova": "4.5.25",
- "@tagspaces/tagspaces-indexer": "4.5.25",
+ "@tagspaces/tagspaces-common": "4.5.33",
+ "@tagspaces/tagspaces-common-aws3": "4.5.33",
+ "@tagspaces/tagspaces-common-cordova": "4.5.33",
+ "@tagspaces/tagspaces-indexer": "4.5.33",
"@tagspaces/tagspaces-md": "4.5.19",
"aws-amplify": "^4.3.8",
"classnames": "^2.3.1",
@@ -52,7 +52,7 @@
"open-location-code": "^1.0.3",
"open-location-code-typescript": "^1.5.0",
"papaparse": "^5.4.1",
- "pdfjs-dist": "^4.3.136",
+ "pdfjs-dist": "^4.7.76",
"picomatch": "^3.0.1",
"qrcode.react": "^3.1.0",
"rc-table": "^7.8.0",
@@ -17185,9 +17185,10 @@
}
},
"node_modules/@tagspaces/tagspaces-common": {
- "version": "4.5.25",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.5.25.tgz",
- "integrity": "sha512-mqJukB/BdB+H1gPJP9FI4LmS0b5MsQ2KDQexRSljFpJr9nuqA0e7WzBiOiLN5pkeMnBklCYhXFra9MBYS+iWKg==",
+ "version": "4.5.33",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.5.33.tgz",
+ "integrity": "sha512-7uYghzX/PSRtrY7Qrx+QDRk4d9EQ2pjo75QqJrRUvLlRb4JUZt2JfwRTylkLb6Kuwo/RJIQD1MlEFHcFeIipNA==",
+ "license": "MIT",
"dependencies": {
"dotenv": "^16.0.2",
"picomatch": "^3.0.1",
@@ -17195,23 +17196,25 @@
}
},
"node_modules/@tagspaces/tagspaces-common-aws3": {
- "version": "4.5.25",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-aws3/-/tagspaces-common-aws3-4.5.25.tgz",
- "integrity": "sha512-qSRyVWqv4BuDIH+Bkj3qG0+6F+sDt37mUB/hdOqDDhywaBtLrawGwHu+OnEsRd0KnuR5heccvnpRy9do5cuuWg==",
+ "version": "4.5.33",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-aws3/-/tagspaces-common-aws3-4.5.33.tgz",
+ "integrity": "sha512-KN4+IXof+FI9swJVFzccjkz5vVcO00cIdPeqah6HDbHWkuFZlTDezvxljR85+Y4a1wLz1yy+u5LlRZo035WCag==",
+ "license": "MIT",
"dependencies": {
"@aws-sdk/client-s3": "^3.665.0",
"@aws-sdk/lib-storage": "^3.665.0",
"@aws-sdk/s3-request-presigner": "^3.665.0",
- "@tagspaces/tagspaces-common": "^4.5.25",
+ "@tagspaces/tagspaces-common": "^4.5.33",
"crypto-js": "^4.2.0"
}
},
"node_modules/@tagspaces/tagspaces-common-cordova": {
- "version": "4.5.25",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-cordova/-/tagspaces-common-cordova-4.5.25.tgz",
- "integrity": "sha512-yP3+SByIgUMEILhp/pbNImqezdhLvgNQ3gzc8Cp/3gdgtfNJKY6SYlN/uyDHXBM5tmRMQgXp/6IqNg0Oa1HX0w==",
+ "version": "4.5.33",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-cordova/-/tagspaces-common-cordova-4.5.33.tgz",
+ "integrity": "sha512-6UBGBQynxi5DmAhqeshkhvGuKN59i3a9I+xJjHxvmTd2x/1qoj6UZIc3Q/dV8+9xHPYVp73LR5I2dYELP7BiFA==",
+ "license": "MIT",
"dependencies": {
- "@tagspaces/tagspaces-common": "^4.5.25"
+ "@tagspaces/tagspaces-common": "^4.5.33"
}
},
"node_modules/@tagspaces/tagspaces-common/node_modules/uuid": {
@@ -17223,11 +17226,12 @@
}
},
"node_modules/@tagspaces/tagspaces-indexer": {
- "version": "4.5.25",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-indexer/-/tagspaces-indexer-4.5.25.tgz",
- "integrity": "sha512-fINQgqxhNgd5QP7XQOcByt0cw/8la/KiXjCuneuIo+AUiDsnSCdIW4j+LBtWfqKOzD150SQlw6ezrlqKpZgdsg==",
+ "version": "4.5.33",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-indexer/-/tagspaces-indexer-4.5.33.tgz",
+ "integrity": "sha512-Hg359ZAAqgkIDbDjeEfcdZjXbVB2jD+1txX1e0vqQOxHMq2D5CePMblTX7MiGN/drTJZx2Tz28GavYfXSlpAhA==",
+ "license": "MIT",
"dependencies": {
- "@tagspaces/tagspaces-common": "^4.5.25"
+ "@tagspaces/tagspaces-common": "^4.5.33"
}
},
"node_modules/@tagspaces/tagspaces-md": {
diff --git a/package.json b/package.json
index b9fbc2805..b861cad9a 100644
--- a/package.json
+++ b/package.json
@@ -166,10 +166,10 @@
"@mui/lab": "5.0.0-alpha.170",
"@mui/material": "^5.15.19",
"@mui/x-date-pickers": "^5.0.20",
- "@tagspaces/tagspaces-common": "4.5.25",
- "@tagspaces/tagspaces-common-aws3": "4.5.25",
- "@tagspaces/tagspaces-common-cordova": "4.5.25",
- "@tagspaces/tagspaces-indexer": "4.5.25",
+ "@tagspaces/tagspaces-common": "4.5.33",
+ "@tagspaces/tagspaces-common-aws3": "4.5.33",
+ "@tagspaces/tagspaces-common-cordova": "4.5.33",
+ "@tagspaces/tagspaces-indexer": "4.5.33",
"@tagspaces/tagspaces-md": "4.5.19",
"aws-amplify": "^4.3.8",
"classnames": "^2.3.1",
@@ -199,7 +199,7 @@
"open-location-code": "^1.0.3",
"open-location-code-typescript": "^1.5.0",
"papaparse": "^5.4.1",
- "pdfjs-dist": "^4.3.136",
+ "pdfjs-dist": "^4.7.76",
"picomatch": "^3.0.1",
"qrcode.react": "^3.1.0",
"rc-table": "^7.8.0",
diff --git a/release/app/package-lock.json b/release/app/package-lock.json
index 12155addf..300241d6f 100644
--- a/release/app/package-lock.json
+++ b/release/app/package-lock.json
@@ -12,8 +12,8 @@
"dependencies": {
"@elife/pm2": "3.6.1",
"@tagspaces/extensions": "1.0.135",
- "@tagspaces/tagspaces-common-node": "4.5.25",
- "@tagspaces/tagspaces-ws": "4.5.25",
+ "@tagspaces/tagspaces-common-node": "4.5.33",
+ "@tagspaces/tagspaces-ws": "4.5.33",
"sharp": "0.32.6",
"ws": "8.16.0"
},
@@ -43,9 +43,9 @@
}
},
"node_modules/@tagspaces/tagspaces-common": {
- "version": "4.5.25",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.5.25.tgz",
- "integrity": "sha512-mqJukB/BdB+H1gPJP9FI4LmS0b5MsQ2KDQexRSljFpJr9nuqA0e7WzBiOiLN5pkeMnBklCYhXFra9MBYS+iWKg==",
+ "version": "4.5.33",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.5.33.tgz",
+ "integrity": "sha512-7uYghzX/PSRtrY7Qrx+QDRk4d9EQ2pjo75QqJrRUvLlRb4JUZt2JfwRTylkLb6Kuwo/RJIQD1MlEFHcFeIipNA==",
"dependencies": {
"dotenv": "^16.0.2",
"picomatch": "^3.0.1",
@@ -53,17 +53,25 @@
}
},
"node_modules/@tagspaces/tagspaces-common-node": {
- "version": "4.5.25",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-node/-/tagspaces-common-node-4.5.25.tgz",
- "integrity": "sha512-RzFk/DTerD39fgcJh4RY+K4UN6ogY52jLFvjV5o9+VyEvIU3voiBsaEqmGgTM2GJ4+xURr+JoQEx4Qy9J8Y2Tg==",
+ "version": "4.5.33",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-node/-/tagspaces-common-node-4.5.33.tgz",
+ "integrity": "sha512-PSMO2bscd8wi6pb3OgQR/FUCKr67ObtZNCs83Q3utH7NeXRCB1ZnqRgjjiG9llP+A8t5+zqKTDXXbBxw4dBsqA==",
"dependencies": {
- "@tagspaces/tagspaces-common": "^4.5.25",
+ "@tagspaces/tagspaces-common": "^4.5.33",
"adm-zip": "0.5.10",
"fs-extra": "^10.0.0",
"klaw": "^4.1.0",
"marked": "^3.0.8"
}
},
+ "node_modules/@tagspaces/tagspaces-pdf-extraction": {
+ "version": "4.5.27",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-pdf-extraction/-/tagspaces-pdf-extraction-4.5.27.tgz",
+ "integrity": "sha512-GfrOKl2JkGwg0lKuGqDZVN3XckoDV0LYaz97UXaJVsTXK943h1dpUksTssnu6tTH5p0GUsTy+CZMluyFBH2BuA==",
+ "dependencies": {
+ "pdf2json": "^3.1.4"
+ }
+ },
"node_modules/@tagspaces/tagspaces-thumbgen-image": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-thumbgen-image/-/tagspaces-thumbgen-image-4.2.3.tgz",
@@ -74,22 +82,24 @@
}
},
"node_modules/@tagspaces/tagspaces-workers": {
- "version": "4.5.25",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-workers/-/tagspaces-workers-4.5.25.tgz",
- "integrity": "sha512-yt4B/8db9ElK81ZccLVULAwSgaxJT8GPlpqDdXs3KlrJrCnImDT//IEo1xWkvMqY/ds2ijw03Ow8y+gmBckJPg==",
+ "version": "4.5.33",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-workers/-/tagspaces-workers-4.5.33.tgz",
+ "integrity": "sha512-0Cuj5IoFm0p9Qa/sk1JMyHdautXA0cBsBWXsOrHLmCEQPXMyc0ZVN4IwFFe4rWdInRTyDl4NxROObYEDeZgNvw==",
"dependencies": {
- "@tagspaces/tagspaces-common": "^4.5.25",
- "@tagspaces/tagspaces-common-node": "^4.5.25",
+ "@tagspaces/tagspaces-common": "^4.5.33",
+ "@tagspaces/tagspaces-common-node": "^4.5.33",
+ "@tagspaces/tagspaces-pdf-extraction": "^4.5.27",
"@tagspaces/tagspaces-thumbgen-image": "^4.2.3",
"fswin": "^3.24.829"
}
},
"node_modules/@tagspaces/tagspaces-ws": {
- "version": "4.5.25",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-ws/-/tagspaces-ws-4.5.25.tgz",
- "integrity": "sha512-GoZ8CQ+EM5u5r8esXVpNbt1JbZf4J1offVf91yxETknR/DZ0M6rq34P6YBUHcN6VNYmoQ11c1uUfddxp2WTbTQ==",
+ "version": "4.5.33",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-ws/-/tagspaces-ws-4.5.33.tgz",
+ "integrity": "sha512-1ndGC+Q1u6mY0PHpmJH0rZZg+dXN5PE2m6vP4YWopzYyt6bi1/adFEk6t/anzFRjE1+U/EkzHIhqYh4lHJUIRA==",
"dependencies": {
- "@tagspaces/tagspaces-workers": "^4.5.25",
+ "@tagspaces/tagspaces-pdf-extraction": "^4.5.27",
+ "@tagspaces/tagspaces-workers": "^4.5.33",
"find-free-ports": "^3.1.1",
"jsonwebtoken": "^8.5.1",
"ws": "^8.15.1"
@@ -713,6 +723,32 @@
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="
},
+ "node_modules/pdf2json": {
+ "version": "3.1.4",
+ "resolved": "https://registry.npmjs.org/pdf2json/-/pdf2json-3.1.4.tgz",
+ "integrity": "sha512-rS+VapXpXZr+5lUpHmRh3ugXdFXp24p1RyG24yP1DMpqP4t0mrYNGpLtpSbWD42PnQ59GIXofxF+yWb7M+3THg==",
+ "bundleDependencies": [
+ "@xmldom/xmldom"
+ ],
+ "dependencies": {
+ "@xmldom/xmldom": "^0.8.10"
+ },
+ "bin": {
+ "pdf2json": "bin/pdf2json.js"
+ },
+ "engines": {
+ "node": ">=18.12.1",
+ "npm": ">=8.19.2"
+ }
+ },
+ "node_modules/pdf2json/node_modules/@xmldom/xmldom": {
+ "version": "0.8.10",
+ "inBundle": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=10.0.0"
+ }
+ },
"node_modules/picomatch": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-3.0.1.tgz",
@@ -1144,9 +1180,9 @@
}
},
"@tagspaces/tagspaces-common": {
- "version": "4.5.25",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.5.25.tgz",
- "integrity": "sha512-mqJukB/BdB+H1gPJP9FI4LmS0b5MsQ2KDQexRSljFpJr9nuqA0e7WzBiOiLN5pkeMnBklCYhXFra9MBYS+iWKg==",
+ "version": "4.5.33",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.5.33.tgz",
+ "integrity": "sha512-7uYghzX/PSRtrY7Qrx+QDRk4d9EQ2pjo75QqJrRUvLlRb4JUZt2JfwRTylkLb6Kuwo/RJIQD1MlEFHcFeIipNA==",
"requires": {
"dotenv": "^16.0.2",
"picomatch": "^3.0.1",
@@ -1154,17 +1190,25 @@
}
},
"@tagspaces/tagspaces-common-node": {
- "version": "4.5.25",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-node/-/tagspaces-common-node-4.5.25.tgz",
- "integrity": "sha512-RzFk/DTerD39fgcJh4RY+K4UN6ogY52jLFvjV5o9+VyEvIU3voiBsaEqmGgTM2GJ4+xURr+JoQEx4Qy9J8Y2Tg==",
+ "version": "4.5.33",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-node/-/tagspaces-common-node-4.5.33.tgz",
+ "integrity": "sha512-PSMO2bscd8wi6pb3OgQR/FUCKr67ObtZNCs83Q3utH7NeXRCB1ZnqRgjjiG9llP+A8t5+zqKTDXXbBxw4dBsqA==",
"requires": {
- "@tagspaces/tagspaces-common": "^4.5.25",
+ "@tagspaces/tagspaces-common": "^4.5.33",
"adm-zip": "0.5.10",
"fs-extra": "^10.0.0",
"klaw": "^4.1.0",
"marked": "^3.0.8"
}
},
+ "@tagspaces/tagspaces-pdf-extraction": {
+ "version": "4.5.27",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-pdf-extraction/-/tagspaces-pdf-extraction-4.5.27.tgz",
+ "integrity": "sha512-GfrOKl2JkGwg0lKuGqDZVN3XckoDV0LYaz97UXaJVsTXK943h1dpUksTssnu6tTH5p0GUsTy+CZMluyFBH2BuA==",
+ "requires": {
+ "pdf2json": "^3.1.4"
+ }
+ },
"@tagspaces/tagspaces-thumbgen-image": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-thumbgen-image/-/tagspaces-thumbgen-image-4.2.3.tgz",
@@ -1175,22 +1219,24 @@
}
},
"@tagspaces/tagspaces-workers": {
- "version": "4.5.25",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-workers/-/tagspaces-workers-4.5.25.tgz",
- "integrity": "sha512-yt4B/8db9ElK81ZccLVULAwSgaxJT8GPlpqDdXs3KlrJrCnImDT//IEo1xWkvMqY/ds2ijw03Ow8y+gmBckJPg==",
+ "version": "4.5.33",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-workers/-/tagspaces-workers-4.5.33.tgz",
+ "integrity": "sha512-0Cuj5IoFm0p9Qa/sk1JMyHdautXA0cBsBWXsOrHLmCEQPXMyc0ZVN4IwFFe4rWdInRTyDl4NxROObYEDeZgNvw==",
"requires": {
- "@tagspaces/tagspaces-common": "^4.5.25",
- "@tagspaces/tagspaces-common-node": "^4.5.25",
+ "@tagspaces/tagspaces-common": "^4.5.33",
+ "@tagspaces/tagspaces-common-node": "^4.5.33",
+ "@tagspaces/tagspaces-pdf-extraction": "^4.5.27",
"@tagspaces/tagspaces-thumbgen-image": "^4.2.3",
"fswin": "^3.24.829"
}
},
"@tagspaces/tagspaces-ws": {
- "version": "4.5.25",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-ws/-/tagspaces-ws-4.5.25.tgz",
- "integrity": "sha512-GoZ8CQ+EM5u5r8esXVpNbt1JbZf4J1offVf91yxETknR/DZ0M6rq34P6YBUHcN6VNYmoQ11c1uUfddxp2WTbTQ==",
+ "version": "4.5.33",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-ws/-/tagspaces-ws-4.5.33.tgz",
+ "integrity": "sha512-1ndGC+Q1u6mY0PHpmJH0rZZg+dXN5PE2m6vP4YWopzYyt6bi1/adFEk6t/anzFRjE1+U/EkzHIhqYh4lHJUIRA==",
"requires": {
- "@tagspaces/tagspaces-workers": "^4.5.25",
+ "@tagspaces/tagspaces-pdf-extraction": "^4.5.27",
+ "@tagspaces/tagspaces-workers": "^4.5.33",
"find-free-ports": "^3.1.1",
"jsonwebtoken": "^8.5.1",
"ws": "^8.15.1"
@@ -1666,6 +1712,20 @@
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="
},
+ "pdf2json": {
+ "version": "3.1.4",
+ "resolved": "https://registry.npmjs.org/pdf2json/-/pdf2json-3.1.4.tgz",
+ "integrity": "sha512-rS+VapXpXZr+5lUpHmRh3ugXdFXp24p1RyG24yP1DMpqP4t0mrYNGpLtpSbWD42PnQ59GIXofxF+yWb7M+3THg==",
+ "requires": {
+ "@xmldom/xmldom": "^0.8.10"
+ },
+ "dependencies": {
+ "@xmldom/xmldom": {
+ "version": "0.8.10",
+ "bundled": true
+ }
+ }
+ },
"picomatch": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-3.0.1.tgz",
diff --git a/release/app/package.json b/release/app/package.json
index 5099fe7b9..6d0d0d328 100644
--- a/release/app/package.json
+++ b/release/app/package.json
@@ -19,8 +19,8 @@
"dependencies": {
"@elife/pm2": "3.6.1",
"@tagspaces/extensions": "1.0.135",
- "@tagspaces/tagspaces-common-node": "4.5.25",
- "@tagspaces/tagspaces-ws": "4.5.25",
+ "@tagspaces/tagspaces-common-node": "4.5.33",
+ "@tagspaces/tagspaces-ws": "4.5.33",
"sharp": "0.32.6",
"ws": "8.16.0"
},
diff --git a/src/main/main.ts b/src/main/main.ts
index 596e4a268..82d18ae73 100644
--- a/src/main/main.ts
+++ b/src/main/main.ts
@@ -353,10 +353,12 @@ function createNewWindowInstance(url?) {
show: true,
center: true,
});
- // @ts-ignore
- mainWindow.fileChanged = false;
- // @ts-ignore
- mainWindow.descriptionChanged = false;
+ if (mainWindow) {
+ // @ts-ignore
+ mainWindow.fileChanged = false;
+ // @ts-ignore
+ mainWindow.descriptionChanged = false;
+ }
newWindowInstance.setMenuBarVisibility(false);
@@ -510,6 +512,7 @@ function startWS() {
const createWindow = async (i18n) => {
let startupParameter = '';
if (startupFilePath) {
+ //console.log(JSON.stringify(process.env));
console.log('Startup file path: ' + startupFilePath);
if (startupFilePath.startsWith('./') || startupFilePath.startsWith('.\\')) {
startupParameter =
diff --git a/src/main/mainEvents.ts b/src/main/mainEvents.ts
index ebf2b23a0..430c88ae7 100644
--- a/src/main/mainEvents.ts
+++ b/src/main/mainEvents.ts
@@ -382,14 +382,13 @@ export default function loadMainEvents() {
);
ipcMain.handle('deleteFilePromise', async (event, path, useTrash) => {
if (useTrash) {
- let ret;
try {
- ret = await shell.trashItem(path);
+ await shell.trashItem(path);
+ return true;
} catch (err) {
console.error('moveToTrash ' + path + 'error:', err);
return false;
}
- return ret;
} else {
const result = await deleteFilePromise(path);
return result;
diff --git a/src/main/preload.ts b/src/main/preload.ts
index 54b264e31..5029a041f 100644
--- a/src/main/preload.ts
+++ b/src/main/preload.ts
@@ -25,6 +25,9 @@ export type Channels =
| 'readMacOSTags'
| 'reloadWindow'
| 'watchFolder'
+ | 'newChatSession'
+ | 'newChatMessage'
+ | 'ChatMessage'
| 'postRequest'
| 'listDirectoryPromise'
| 'listMetaDirectoryPromise'
diff --git a/src/renderer/components/EntryContainer.tsx b/src/renderer/components/EntryContainer.tsx
index b53caf2ca..d377255d3 100644
--- a/src/renderer/components/EntryContainer.tsx
+++ b/src/renderer/components/EntryContainer.tsx
@@ -562,11 +562,15 @@ function EntryContainer() {
const toggleEntryPropertiesHeight = () => {
if (entryPropertiesHeight === 100) {
- setEntryPropertiesHeight(150);
- } else if (entryPropertiesHeight === 150) {
+ setEntryPropertiesHeight(200);
+ } else if (entryPropertiesHeight === 200) {
+ setEntryPropertiesHeight(350);
+ } else if (entryPropertiesHeight === 350) {
setEntryPropertiesHeight(50);
} else if (entryPropertiesHeight === 50) {
setEntryPropertiesHeight(100);
+ } else {
+ setEntryPropertiesHeight(200);
}
};
@@ -780,17 +784,19 @@ function EntryContainer() {
<div
style={{
textAlign: 'center',
- maxHeight: 9,
- minHeight: 9,
+ // maxHeight: 9,
+ minHeight: 8,
+ paddingTop: 2,
backgroundColor: theme.palette.background.default,
borderBottom: '1px solid ' + theme.palette.divider,
+ cursor: 's-resize',
}}
onClick={toggleEntryPropertiesHeight}
>
<div
style={{
- width: '30%',
- border: '1px solid ' + theme.palette.text.secondary,
+ width: '10%',
+ border: '1px dashed ' + theme.palette.text.secondary,
margin: '2px auto',
}}
></div>
diff --git a/src/renderer/hooks/FSWatcherContextProvider.tsx b/src/renderer/hooks/FSWatcherContextProvider.tsx
index bee1cdc49..e62dabc79 100644
--- a/src/renderer/hooks/FSWatcherContextProvider.tsx
+++ b/src/renderer/hooks/FSWatcherContextProvider.tsx
@@ -247,9 +247,11 @@ export const FSWatcherContextProvider = ({
}
function addToIgnored(path: string) {
- const index = ignored.current.indexOf(path);
- if (index === -1) {
- ignored.current.push(path);
+ if (path) {
+ const index = ignored.current.indexOf(path);
+ if (index === -1) {
+ ignored.current.push(path);
+ }
}
}
diff --git a/src/renderer/hooks/IOActionsContextProvider.tsx b/src/renderer/hooks/IOActionsContextProvider.tsx
index 7aadd9b22..18e599aa8 100644
--- a/src/renderer/hooks/IOActionsContextProvider.tsx
+++ b/src/renderer/hooks/IOActionsContextProvider.tsx
@@ -39,6 +39,7 @@ import {
cleanTrailingDirSeparator,
cleanFrontDirSeparator,
generateFileName,
+ getMetaContentFileLocation,
} from '@tagspaces/tagspaces-common/paths';
import { getUuid } from '@tagspaces/tagspaces-common/utils-io';
import { actions as AppActions, AppDispatch } from '-/reducers/app';
@@ -467,7 +468,12 @@ export const IOActionsContextProvider = ({
backupFilePath,
currentLocation?.getDirSeparator(),
);
- // Delete revisions, sidecar file and thumb
+ const metaContentPath = getMetaContentFileLocation(
+ filePath,
+ currentLocation?.getDirSeparator(),
+ );
+
+ // Delete revisions, sidecar file and thumb, pdf content
return deleteEntriesPromise(
currentLocation.toFsEntry(backupPath, false),
currentLocation.toFsEntry(
@@ -485,6 +491,7 @@ export const IOActionsContextProvider = ({
),
true,
),
+ currentLocation.toFsEntry(metaContentPath, true),
)
.then(() => {
console.log(
@@ -1448,6 +1455,16 @@ export const IOActionsContextProvider = ({
false,
),
],
+ [
+ getMetaContentFileLocation(
+ filePath,
+ currentLocation?.getDirSeparator(),
+ ),
+ getMetaContentFileLocation(
+ newFilePath,
+ currentLocation?.getDirSeparator(),
+ ),
+ ],
],
locationID,
undefined,
diff --git a/src/renderer/hooks/LocationIndexContextProvider.tsx b/src/renderer/hooks/LocationIndexContextProvider.tsx
index 885dec999..8a65228c2 100644
--- a/src/renderer/hooks/LocationIndexContextProvider.tsx
+++ b/src/renderer/hooks/LocationIndexContextProvider.tsx
@@ -60,7 +60,7 @@ type LocationIndexContextData = {
cancelDirectoryIndexing: () => void;
createLocationIndex: (location: CommonLocation) => Promise<boolean>;
createLocationsIndexes: (extractText?: boolean) => Promise<boolean>;
- clearDirectoryIndex: () => void;
+ clearDirectoryIndex: (persist?: boolean) => void;
searchLocationIndex: (searchQuery: TS.SearchQuery) => void;
searchAllLocations: (searchQuery: TS.SearchQuery) => void;
setIndex: (i: TS.FileSystemEntry[], location?: CommonLocation) => void;
@@ -111,9 +111,13 @@ export const LocationIndexContextProvider = ({
const indexLoadedOn = useRef<number>(undefined);
const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
const firstRender = useFirstRender();
+ const maxIndexAge = useRef<number>(getMaxIndexAge(currentLocation));
useEffect(() => {
- clearDirectoryIndex();
+ if (currentLocation) {
+ clearDirectoryIndex(false);
+ maxIndexAge.current = getMaxIndexAge(currentLocation);
+ }
}, [currentLocation]);
useEffect(() => {
@@ -136,6 +140,11 @@ export const LocationIndexContextProvider = ({
}
}, [actions]);
+ function getMaxIndexAge(location) {
+ return location && location.maxIndexAge
+ ? location.maxIndexAge
+ : AppConfig.maxIndexAge;
+ }
function setIndex(i, location: CommonLocation = undefined) {
index.current = i;
if (index.current && index.current.length > 0) {
@@ -252,7 +261,7 @@ export const LocationIndexContextProvider = ({
}
function createDirectoryIndex(
- param: string | any,
+ param: any,
extractText = false,
ignorePatterns: Array<string> = [],
enableWS = true,
@@ -263,16 +272,8 @@ export const LocationIndexContextProvider = ({
if (Pro && Pro.Watcher) {
Pro.Watcher.stopWatching();
}
- let directoryPath;
- let locationID;
- if (typeof param === 'object' && param !== null) {
- directoryPath = param.path;
- ({ locationID } = param);
- } else {
- directoryPath = param;
- }
- const loc = findLocation(locationID);
- const dirPath = cleanTrailingDirSeparator(directoryPath);
+ const loc = findLocation(param.locationID);
+ const dirPath = cleanTrailingDirSeparator(param.path);
if (
enableWS &&
!loc.haveObjectStoreSupport() &&
@@ -284,7 +285,7 @@ export const LocationIndexContextProvider = ({
.createDirectoryIndexInWorker(dirPath, extractText, ignorePatterns)
.then((result) => {
if (result && result.success) {
- return loadIndexFromDisk(dirPath, locationID);
+ return loadIndexFromDisk(dirPath, param.locationID);
} else if (result && result.error) {
console.error(
'createDirectoryIndexInWorker failed:' + result.error,
@@ -303,9 +304,11 @@ export const LocationIndexContextProvider = ({
mode.push('extractTextContent');
}
return createIndex(
- param,
- loc.listDirectoryPromise,
- loc.loadTextFilePromise,
+ {
+ ...param,
+ listDirectoryPromise: loc.listDirectoryPromise,
+ getFileContentPromise: loc.getFileContentPromise,
+ },
mode,
ignorePatterns,
isWalking,
@@ -313,11 +316,11 @@ export const LocationIndexContextProvider = ({
.then((directoryIndex) =>
persistIndex(param, directoryIndex).then((success) => {
if (success) {
- console.log('Index generated in folder: ' + directoryPath);
+ console.log('Index generated in folder: ' + dirPath);
return enhanceDirectoryIndex(
directoryIndex,
- locationID,
- directoryPath,
+ param.locationID,
+ param.path,
);
//return enhanceDirectoryIndex(param, directoryIndex, locationID);
}
@@ -328,10 +331,11 @@ export const LocationIndexContextProvider = ({
console.log('Error creating index: ', err);
});
}
+ return Promise.resolve(undefined);
}
function createDirectoryIndexWrapper(
- param: string | any,
+ param: any,
extractText = false,
ignorePatterns: Array<string> = [],
enableWS = true,
@@ -413,9 +417,9 @@ export const LocationIndexContextProvider = ({
return true;
}
- function clearDirectoryIndex() {
+ function clearDirectoryIndex(persist = false) {
isIndexing.current = undefined;
- setIndex([], currentLocation);
+ setIndex([], persist ? currentLocation : undefined);
forceUpdate();
}
@@ -539,28 +543,28 @@ export const LocationIndexContextProvider = ({
);
setTimeout(async () => {
const currentPath = await getLocationPath(currentLocation);
+
if (!index.current || index.current.length < 1) {
const directoryIndex = await loadIndexFromDisk(
currentPath,
currentLocation.uuid,
);
- setIndex(directoryIndex);
+ if (directoryIndex) {
+ setIndex(directoryIndex);
+ }
}
// Workaround used to show the start search notification
const currentTime = new Date().getTime();
const indexAge = indexLoadedOn.current
? currentTime - indexLoadedOn.current
: 0;
- const maxIndexAge = currentLocation.maxIndexAge
- ? currentLocation.maxIndexAge
- : AppConfig.maxIndexAge;
if (
searchQuery.forceIndexing ||
(!currentLocation.disableIndexing &&
(!index.current ||
index.current.length < 1 ||
- indexAge > maxIndexAge))
+ indexAge > maxIndexAge.current))
) {
console.log('Start creating index for : ' + currentPath);
const newIndex = await createDirectoryIndexWrapper(
@@ -737,22 +741,37 @@ export const LocationIndexContextProvider = ({
locationID: string,
): Promise<TS.FileSystemEntry[]> {
const loc = findLocation(locationID);
- const folderIndexPath =
- getMetaDirectoryPath(folderPath) +
- loc.getDirSeparator() +
- AppConfig.folderIndexFile;
- return loc
- .loadTextFilePromise(folderIndexPath)
- .then((jsonContent) => {
- const directoryIndex = loadJSONString(
- jsonContent,
- ) as TS.FileSystemEntry[];
- return enhanceDirectoryIndex(directoryIndex, locationID, folderPath);
- })
- .catch((e) => {
- console.log('cannot load json:' + folderPath, e);
- return undefined;
- });
+ if (loc) {
+ const folderIndexPath =
+ getMetaDirectoryPath(folderPath) +
+ loc.getDirSeparator() +
+ AppConfig.folderIndexFile;
+ return loc
+ .getPropertiesPromise(folderIndexPath)
+ .then((indexFile: TS.FileSystemEntry) => {
+ const indexAge = new Date().getTime() - indexFile.lmdt;
+ if (indexFile && indexAge < maxIndexAge.current) {
+ return loc
+ .loadTextFilePromise(folderIndexPath)
+ .then((jsonContent) => {
+ const directoryIndex = loadJSONString(
+ jsonContent,
+ ) as TS.FileSystemEntry[];
+ return enhanceDirectoryIndex(
+ directoryIndex,
+ locationID,
+ folderPath,
+ );
+ })
+ .catch((e) => {
+ console.log('cannot load json:' + folderPath, e);
+ return undefined;
+ });
+ }
+ return undefined;
+ });
+ }
+ return Promise.resolve(undefined);
}
/*const context = useMemo(() => {
diff --git a/src/renderer/hooks/OpenedEntryContextProvider.tsx b/src/renderer/hooks/OpenedEntryContextProvider.tsx
index 2610b3e49..9ba117bdc 100644
--- a/src/renderer/hooks/OpenedEntryContextProvider.tsx
+++ b/src/renderer/hooks/OpenedEntryContextProvider.tsx
@@ -49,6 +49,7 @@ import {
joinPaths,
normalizePath,
extractFileExtension,
+ getMetaContentFileLocation,
} from '@tagspaces/tagspaces-common/paths';
import {
formatDateTime4Tag,
@@ -69,6 +70,7 @@ import { CommonLocation } from '-/utils/CommonLocation';
import { useFilePropertiesContext } from '-/hooks/useFilePropertiesContext';
import { useIOActionsContext } from '-/hooks/useIOActionsContext';
import ConfirmDialog from '-/components/dialogs/ConfirmDialog';
+import { extractPDFcontent } from '-/services/thumbsgenerator';
type OpenedEntryContextData = {
openedEntry: TS.OpenedEntry;
@@ -641,6 +643,24 @@ export const OpenedEntryContextProvider = ({
) {
setSelectedEntries([fsEntry]);
}
+ if (loc.fullTextIndex && entryForOpening.extension === 'pdf') {
+ //extract text from pdf
+ loc
+ .getFileContentPromise(entryForOpening.path, 'arraybuffer')
+ .then((content) => {
+ extractPDFcontent(content).then((txt) => {
+ loc
+ .saveTextFilePromise(
+ { path: getMetaContentFileLocation(entryForOpening.path) },
+ txt,
+ true,
+ )
+ .then(() =>
+ console.log('Content extracted:' + entryForOpening.path),
+ );
+ });
+ });
+ }
return Promise.resolve(true);
}
diff --git a/src/renderer/hooks/ThumbGenerationContextProvider.tsx b/src/renderer/hooks/ThumbGenerationContextProvider.tsx
index 1caf1e0b4..34a4a4c71 100644
--- a/src/renderer/hooks/ThumbGenerationContextProvider.tsx
+++ b/src/renderer/hooks/ThumbGenerationContextProvider.tsx
@@ -211,6 +211,7 @@ export const ThumbGenerationContextProvider = ({
): Promise<boolean> {
const workerEntries: string[] = [];
const mainEntries: string[] = [];
+ const pdfEntries: string[] = [];
dirEntries.map((entry) => {
if (!entry.isFile) {
return true;
@@ -221,6 +222,16 @@ export const ThumbGenerationContextProvider = ({
const extension = entry.extension
? entry.extension
: extractFileExtension(entry.name, location.getDirSeparator());
+ if (
+ isWorkerAvailable &&
+ enableWS &&
+ location.fullTextIndex &&
+ entry.path.toLowerCase().endsWith('pdf') &&
+ !location.haveObjectStoreSupport() &&
+ !location.haveWebDavSupport()
+ ) {
+ pdfEntries.push(entry.path);
+ }
if (
isWorkerAvailable &&
enableWS &&
@@ -243,9 +254,16 @@ export const ThumbGenerationContextProvider = ({
return true;
});
+ if (pdfEntries.length > 0) {
+ createThumbnailsInWorker(pdfEntries, location.fullTextIndex).catch(
+ (e) => {
+ console.log('createThumbnailsInWorker pdf', e);
+ },
+ );
+ }
if (workerEntries.length > 0) {
setGenThumbs(true);
- return createThumbnailsInWorker(workerEntries)
+ return createThumbnailsInWorker(workerEntries, location.fullTextIndex)
.then(() =>
thumbnailMainGeneration(mainEntries, location).then(() => {
setGenThumbs(false);
diff --git a/src/renderer/reducers/settings.ts b/src/renderer/reducers/settings.ts
index f82a485e5..ba5ddb2e4 100644
--- a/src/renderer/reducers/settings.ts
+++ b/src/renderer/reducers/settings.ts
@@ -68,7 +68,6 @@ export const types = {
SET_REVISIONS_ENABLED: 'SETTINGS/SET_REVISIONS_ENABLED',
SET_PREFIX_TAG_CONTAINER: 'SETTINGS/SET_PREFIX_TAG_CONTAINER',
SET_USEGENERATETHUMBNAILS: 'SETTINGS/SET_USEGENERATETHUMBNAILS',
- SET_USETEXTEXTRACTION: 'SETTINGS/SET_USETEXTEXTRACTION',
SET_TAGCOLOR: 'SETTINGS/SET_TAGCOLOR',
SET_TAGTEXTCOLOR: 'SETTINGS/SET_TAGTEXTCOLOR',
SET_CURRENTTHEME: 'SETTINGS/SET_CURRENTTHEME',
@@ -254,9 +253,6 @@ export default (state: any = defaultSettings, action: any) => {
case types.SET_USEGENERATETHUMBNAILS: {
return { ...state, useGenerateThumbnails: action.useGenerateThumbnails };
}
- case types.SET_USETEXTEXTRACTION: {
- return { ...state, useTextExtraction: action.useTextExtraction };
- }
case types.SET_EMAIL: {
return {
...state,
@@ -669,10 +665,6 @@ export const actions = {
type: types.SET_USEGENERATETHUMBNAILS,
useGenerateThumbnails,
}),
- setUseTextExtraction: (useTextExtraction: boolean) => ({
- type: types.SET_USETEXTEXTRACTION,
- useTextExtraction,
- }),
setAppDataPath: (path: string) => ({
type: types.SET_APPDATAPATH,
path,
@@ -927,8 +919,6 @@ export const getFileNameTagPlace = (state: any): boolean =>
state.settings.filenameTagPlacedAtEnd;
export const getUseGenerateThumbnails = (state: any) =>
state.settings.useGenerateThumbnails;
-export const getUseTextExtraction = (state: any) =>
- state.settings.useTextExtraction;
export const getKeyBindings = (state: any) => state.settings.keyBindings;
export const getKeyBindingObject = (state: any) =>
generateKeyBindingObject(state.settings.keyBindings);
diff --git a/src/renderer/services/thumbsgenerator.ts b/src/renderer/services/thumbsgenerator.ts
index 2c6278ab7..d009d3619 100644
--- a/src/renderer/services/thumbsgenerator.ts
+++ b/src/renderer/services/thumbsgenerator.ts
@@ -30,6 +30,8 @@ const pdfjs = (
) as typeof pdfjsModule;
import('pdfjs-dist/build/pdf.worker.mjs');
+//import pdfjsWorker from 'pdfjs-dist/build/pdf.worker.entry';
+//pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
let maxSize = AppConfig.maxThumbSize;
const thumbnailBackgroundColor = AppConfig.thumbBgColor;
@@ -138,7 +140,9 @@ export function generateThumbnailPromise(
); //fileURLEscaped);
}
} else if (ext === 'pdf') {
- return generatePDFThumbnail(fileURLEscaped, maxSize);
+ return getFileContentPromise({ path: fileURLEscaped }, 'arraybuffer').then(
+ (buffer) => generatePDFThumbnail(buffer, maxSize),
+ );
} else if (Pro && ext === 'html') {
return Pro.ThumbsGenerator.generateHtmlThumbnail(
fileURLEscaped,
@@ -183,26 +187,43 @@ export function generateThumbnailPromise(
return generateDefaultThumbnail();
}
+export async function extractPDFcontent(
+ arrayBuffer: ArrayBuffer,
+): Promise<string> {
+ let extractedText = '';
+ if (arrayBuffer) {
+ try {
+ const pdfDocument = await pdfjs.getDocument(arrayBuffer).promise;
+
+ for (let i = 1; i <= pdfDocument.numPages; i++) {
+ const page = await pdfDocument.getPage(i);
+ const textContent = await page.getTextContent();
+ const pageText = textContent.items.map((item) => item.str).join(' ');
+ extractedText += pageText + '\n';
+ }
+ extractedText += '\r\n';
+ } catch (error) {
+ console.error('Error extracting text from PDF:', error);
+ }
+ }
+ return extractedText;
+}
+
export function generatePDFThumbnail(
- fileURL: string,
+ arrayBuffer: ArrayBuffer,
maxSize: number,
): Promise<string> {
return new Promise((resolve) => {
try {
const errorHandler = (err) => {
- console.log(
- 'Error while generating thumbnail for: ' +
- fileURL +
- ' - ' +
- JSON.stringify(err),
- );
+ console.log('Error while generating thumbnail', err);
resolve('');
};
let canvas: HTMLCanvasElement = document.createElement('canvas');
const ctx = canvas.getContext('2d');
// ensurePDFJS().then(pdfjsLib => {
- const loadingTask = pdfjs.getDocument(fileURL);
+ const loadingTask = pdfjs.getDocument(arrayBuffer);
loadingTask.promise
.then((pdf) => {
pdf
@@ -248,7 +269,7 @@ export function generatePDFThumbnail(
.catch(errorHandler);
return true;
} catch (e) {
- console.log(`Error creating PDF thumb for : ${fileURL} with: ${e}`);
+ console.log('Error creating PDF thumb', e);
resolve('');
}
});
diff --git a/src/renderer/services/utils-io.ts b/src/renderer/services/utils-io.ts
index 0bb66f876..e1d06a79d 100644
--- a/src/renderer/services/utils-io.ts
+++ b/src/renderer/services/utils-io.ts
@@ -893,13 +893,15 @@ export function isWorkerAvailable(): Promise<boolean> {
export function createThumbnailsInWorker(
tmbGenerationList: Array<string>,
+ extractPDFcontent: boolean,
): Promise<any> {
if (AppConfig.isElectron) {
const payload = JSON.stringify(tmbGenerationList);
return window.electronIO.ipcRenderer.invoke(
'postRequest',
payload,
- '/thumb-gen',
+ '/thumb-gen' +
+ (extractPDFcontent ? '?pdfContent=' + extractPDFcontent : ''),
);
}
return Promise.reject(new Error('createThumbnailsInWorker not Electron!'));
diff --git a/src/renderer/utils/CommonLocation.ts b/src/renderer/utils/CommonLocation.ts
index bca69256d..f2608294f 100644
--- a/src/renderer/utils/CommonLocation.ts
+++ b/src/renderer/utils/CommonLocation.ts
@@ -861,7 +861,8 @@ export class CommonLocation implements TS.Location {
return Promise.reject(new Error('loadTextFilePromise: not implemented'));
};
- getFileContentPromise = (filePath: string, type?: string): Promise<any> => {
+ getFileContentPromise = (param: any, type?: string): Promise<any> => {
+ const filePath = this.getPath(param);
if (this.ioAPI) {
if (this.haveObjectStoreSupport()) {
return this.ioAPI.getFileContentPromise(
diff --git a/tests/e2e/hook.js b/tests/e2e/hook.js
index d9058af6d..b7ee0b593 100644
--- a/tests/e2e/hook.js
+++ b/tests/e2e/hook.js
@@ -188,11 +188,21 @@ export async function startTestingApp(extconfig) {
],
bypassCSP: true,
env: {
+ // ...process.env, // Preserve existing environment variables
ELECTRON_ENABLE_LOGGING: true,
ELECTRON_ENABLE_STACK_DUMPING: true,
// NODE_ENV: 'test'
},
});
+ const appPath = await global.app.evaluate(async ({ app }) => {
+ // This runs in the main Electron process, parameter here is always
+ // the result of the require('electron') in the main app script.
+ return app.getAppPath();
+ });
+ console.log('appPath:' + appPath);
+ global.app.on('console', (msg) => {
+ console.log(`[Electron Main] ${msg.type()}: ${msg.text()}`);
+ });
// Get the Electron context.
global.context = await global.app.context();