mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-04-21 14:06:15 +00:00
Upgraded topola library version to 2.5.1
This commit is contained in:
6
package-lock.json
generated
6
package-lock.json
generated
@@ -14558,9 +14558,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"topola": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/topola/-/topola-2.4.0.tgz",
|
||||
"integrity": "sha512-ncLg4eDFeF1UNXEcpJvrm8iMnNCtTVsDg8hWHJr83UMSfiV8EwcvklyhoKjB1uRsp/E+eSKOMJb44Acgn5BM1w==",
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/topola/-/topola-2.5.1.tgz",
|
||||
"integrity": "sha512-g1hDeT0X4HHg/p1/Wr/fgUceN9JlP6LC1rIJkfP7lPwWVZcplzfdCDzuyIKPfkrUsE5OZAhw3LoPu6xKv1u/dg==",
|
||||
"requires": {
|
||||
"array-flat-polyfill": "^1.0.1",
|
||||
"d3": "^5.4.0",
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"react-router-dom": "^4.3.1",
|
||||
"semantic-ui-css": "^2.4.1",
|
||||
"semantic-ui-react": "^0.84.0",
|
||||
"topola": "^2.4.0"
|
||||
"topola": "^2.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/array.prototype.flatmap": "^1.2.0",
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import {JsonFam, JsonGedcomData, JsonIndi, gedcomEntriesToJson} from 'topola';
|
||||
import {
|
||||
JsonFam,
|
||||
JsonGedcomData,
|
||||
JsonIndi,
|
||||
gedcomEntriesToJson,
|
||||
JsonImage,
|
||||
} from 'topola';
|
||||
import {GedcomEntry, parse as parseGedcom} from 'parse-gedcom';
|
||||
|
||||
export interface GedcomData {
|
||||
@@ -122,28 +128,24 @@ function isImageFile(fileName: string): boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes imageUrl fields that are not HTTP links or do not have known image
|
||||
* extensions. Does not modify the input object.
|
||||
* Removes images that are not HTTP links or do not have known image extensions.
|
||||
* Does not modify the input object.
|
||||
*/
|
||||
function filterImage(indi: JsonIndi, images: Map<string, string>): JsonIndi {
|
||||
if (indi.imageUrl) {
|
||||
const fileName = indi.imageUrl.match(/[^/\\]*$/)![0];
|
||||
// If the image file has been loaded into memory, use it.
|
||||
if (images.has(fileName)) {
|
||||
const newIndi = Object.assign({}, indi);
|
||||
newIndi.imageUrl = images.get(fileName);
|
||||
return newIndi;
|
||||
}
|
||||
}
|
||||
if (
|
||||
!indi.imageUrl ||
|
||||
(indi.imageUrl.startsWith('http') && isImageFile(indi.imageUrl))
|
||||
) {
|
||||
if (!indi.images || indi.images.length === 0) {
|
||||
return indi;
|
||||
}
|
||||
const newIndi = Object.assign({}, indi);
|
||||
delete newIndi.imageUrl;
|
||||
return newIndi;
|
||||
const newImages: JsonImage[] = [];
|
||||
indi.images.forEach((image) => {
|
||||
const fileName = image.url.match(/[^/\\]*$/)![0];
|
||||
// If the image file has been loaded into memory, use it.
|
||||
if (images.has(fileName)) {
|
||||
newImages.push({url: images.get(fileName)!, title: image.title});
|
||||
} else if (image.url.startsWith('http') && isImageFile(image.url)) {
|
||||
newImages.push(image);
|
||||
}
|
||||
});
|
||||
return Object.assign({}, indi, {images: newImages});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user