mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-08-02 09:01:48 +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
|
"dev": true
|
||||||
},
|
},
|
||||||
"topola": {
|
"topola": {
|
||||||
"version": "2.4.0",
|
"version": "2.5.1",
|
||||||
"resolved": "https://registry.npmjs.org/topola/-/topola-2.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/topola/-/topola-2.5.1.tgz",
|
||||||
"integrity": "sha512-ncLg4eDFeF1UNXEcpJvrm8iMnNCtTVsDg8hWHJr83UMSfiV8EwcvklyhoKjB1uRsp/E+eSKOMJb44Acgn5BM1w==",
|
"integrity": "sha512-g1hDeT0X4HHg/p1/Wr/fgUceN9JlP6LC1rIJkfP7lPwWVZcplzfdCDzuyIKPfkrUsE5OZAhw3LoPu6xKv1u/dg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"array-flat-polyfill": "^1.0.1",
|
"array-flat-polyfill": "^1.0.1",
|
||||||
"d3": "^5.4.0",
|
"d3": "^5.4.0",
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
"react-router-dom": "^4.3.1",
|
"react-router-dom": "^4.3.1",
|
||||||
"semantic-ui-css": "^2.4.1",
|
"semantic-ui-css": "^2.4.1",
|
||||||
"semantic-ui-react": "^0.84.0",
|
"semantic-ui-react": "^0.84.0",
|
||||||
"topola": "^2.4.0"
|
"topola": "^2.5.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/array.prototype.flatmap": "^1.2.0",
|
"@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';
|
import {GedcomEntry, parse as parseGedcom} from 'parse-gedcom';
|
||||||
|
|
||||||
export interface GedcomData {
|
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
|
* Removes images that are not HTTP links or do not have known image extensions.
|
||||||
* extensions. Does not modify the input object.
|
* Does not modify the input object.
|
||||||
*/
|
*/
|
||||||
function filterImage(indi: JsonIndi, images: Map<string, string>): JsonIndi {
|
function filterImage(indi: JsonIndi, images: Map<string, string>): JsonIndi {
|
||||||
if (indi.imageUrl) {
|
if (!indi.images || indi.images.length === 0) {
|
||||||
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))
|
|
||||||
) {
|
|
||||||
return indi;
|
return indi;
|
||||||
}
|
}
|
||||||
const newIndi = Object.assign({}, indi);
|
const newImages: JsonImage[] = [];
|
||||||
delete newIndi.imageUrl;
|
indi.images.forEach((image) => {
|
||||||
return newIndi;
|
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