@manuscripts/style-guide 0.31.18 → 0.31.19
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.
- package/dist/cjs/components/FileManager/FileManager.js +3 -17
- package/dist/cjs/hooks/use-deep-compare.js +31 -0
- package/dist/cjs/hooks/use-files.js +44 -0
- package/dist/cjs/index.js +6 -4
- package/dist/cjs/lib/inlineFiles.js +6 -18
- package/dist/es/components/FileManager/FileManager.js +4 -18
- package/dist/es/hooks/use-deep-compare.js +26 -0
- package/dist/es/hooks/use-files.js +39 -0
- package/dist/es/index.js +2 -1
- package/dist/es/lib/inlineFiles.js +7 -17
- package/dist/types/hooks/use-deep-compare.d.ts +17 -0
- package/dist/types/hooks/use-files.d.ts +10 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/lib/inlineFiles.d.ts +4 -5
- package/package.json +1 -1
|
@@ -35,7 +35,7 @@ exports.FileManager = exports.PermissionsContext = void 0;
|
|
|
35
35
|
const manuscript_transform_1 = require("@manuscripts/manuscript-transform");
|
|
36
36
|
const react_1 = __importStar(require("react"));
|
|
37
37
|
const react_tooltip_1 = __importDefault(require("react-tooltip"));
|
|
38
|
-
const
|
|
38
|
+
const index_1 = require("../../index");
|
|
39
39
|
const Inspector_1 = require("../Inspector");
|
|
40
40
|
const InspectorSection_1 = require("../InspectorSection");
|
|
41
41
|
const DraggableFileSectionItem_1 = require("./FileSectionItem/DraggableFileSectionItem");
|
|
@@ -97,27 +97,13 @@ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManageme
|
|
|
97
97
|
}
|
|
98
98
|
}), [modelMap, saveModel]);
|
|
99
99
|
const attachments = getAttachments();
|
|
100
|
-
const
|
|
101
|
-
const supplementFiles = (0, react_1.useMemo)(() => (0, inlineFiles_1.getSupplementFiles)(modelMap, attachments), [attachments, modelMap.size]);
|
|
102
|
-
const excludedAttachmentsIds = (0, react_1.useMemo)(() => {
|
|
103
|
-
const attachmentsIDs = new Set();
|
|
104
|
-
inlineFiles.map(({ attachments }) => {
|
|
105
|
-
if (attachments) {
|
|
106
|
-
attachments.map((attachment) => attachmentsIDs.add(attachment.id));
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
supplementFiles.map(({ id }) => attachmentsIDs.add(id));
|
|
110
|
-
return attachmentsIDs;
|
|
111
|
-
}, [inlineFiles, supplementFiles]);
|
|
100
|
+
const { otherFiles, supplementFiles, inlineFiles } = (0, index_1.useFiles)(modelMap, attachments);
|
|
112
101
|
const getFileSectionExternalFile = (fileSection) => {
|
|
113
102
|
const isSupplementOrOtherFilesTab = fileSection === util_1.FileSectionType.Supplements ||
|
|
114
103
|
fileSection === util_1.FileSectionType.OtherFile;
|
|
115
104
|
const isOtherFilesTab = fileSection === util_1.FileSectionType.OtherFile;
|
|
116
105
|
const itemsData = (fileSection === util_1.FileSectionType.Supplements && supplementFiles) ||
|
|
117
|
-
|
|
118
|
-
const designation = util_1.namesWithDesignationMap.get(element.type.label);
|
|
119
|
-
return (designation !== undefined && !excludedAttachmentsIds.has(element.id));
|
|
120
|
-
});
|
|
106
|
+
otherFiles;
|
|
121
107
|
const itemsDataWithTitle = (0, util_1.generateAttachmentsTitles)(itemsData, fileSection);
|
|
122
108
|
const filesItems = itemsDataWithTitle.map((element) => {
|
|
123
109
|
const itemProps = {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2022 Atypon Systems LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.useDeepCompareCallback = exports.useDeepCompareMemo = void 0;
|
|
19
|
+
const lodash_1 = require("lodash");
|
|
20
|
+
const react_1 = require("react");
|
|
21
|
+
const useDeepCompare = (deps) => {
|
|
22
|
+
const ref = (0, react_1.useRef)(deps);
|
|
23
|
+
if (!(0, lodash_1.isEqual)(deps, ref.current)) {
|
|
24
|
+
ref.current = deps;
|
|
25
|
+
}
|
|
26
|
+
return ref.current;
|
|
27
|
+
};
|
|
28
|
+
const useDeepCompareMemo = (callback, deps) => (0, react_1.useMemo)(callback, [useDeepCompare(deps), callback]);
|
|
29
|
+
exports.useDeepCompareMemo = useDeepCompareMemo;
|
|
30
|
+
const useDeepCompareCallback = (callback, deps) => (0, react_1.useCallback)(callback, [useDeepCompare(deps), callback]);
|
|
31
|
+
exports.useDeepCompareCallback = useDeepCompareCallback;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const manuscript_transform_1 = require("@manuscripts/manuscript-transform");
|
|
7
|
+
const manuscripts_json_schema_1 = require("@manuscripts/manuscripts-json-schema");
|
|
8
|
+
const inlineFiles_1 = __importDefault(require("../lib/inlineFiles"));
|
|
9
|
+
const use_deep_compare_1 = require("./use-deep-compare");
|
|
10
|
+
const getSupplementFiles = (modelMap, attachments, filePredicate) => {
|
|
11
|
+
const supplements = new Map((0, manuscript_transform_1.getModelsByType)(modelMap, manuscripts_json_schema_1.ObjectTypes.Supplement).map((supplement) => { var _a; return [(_a = supplement.href) === null || _a === void 0 ? void 0 : _a.replace('attachment:', ''), supplement]; }));
|
|
12
|
+
return attachments.filter((attachment) => {
|
|
13
|
+
if (supplements.has(attachment.id) && filePredicate) {
|
|
14
|
+
return filePredicate(attachment.name);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return supplements.has(attachment.id);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const getOtherFiles = (inlineFiles, supplementFiles, attachments, filePredicate) => {
|
|
22
|
+
const inlineFilesAttachmentIds = inlineFiles
|
|
23
|
+
.map(({ attachments }) => (attachments === null || attachments === void 0 ? void 0 : attachments.map(({ id }) => ({ id }))) || [])
|
|
24
|
+
.flat();
|
|
25
|
+
const excludedAttachmentsIds = new Set([...inlineFilesAttachmentIds, ...supplementFiles].map(({ id }) => id));
|
|
26
|
+
return attachments.filter(({ id, name }) => {
|
|
27
|
+
if (!excludedAttachmentsIds.has(id) && filePredicate) {
|
|
28
|
+
return filePredicate(name);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return !excludedAttachmentsIds.has(id);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
exports.default = (modelMap, attachments, filePredicate) => (0, use_deep_compare_1.useDeepCompareMemo)(() => {
|
|
36
|
+
const inlineFiles = (0, inlineFiles_1.default)(modelMap, attachments);
|
|
37
|
+
const supplementFiles = getSupplementFiles(modelMap, attachments, filePredicate);
|
|
38
|
+
const otherFiles = getOtherFiles(inlineFiles, supplementFiles, attachments, filePredicate);
|
|
39
|
+
return {
|
|
40
|
+
otherFiles,
|
|
41
|
+
supplementFiles,
|
|
42
|
+
inlineFiles,
|
|
43
|
+
};
|
|
44
|
+
}, [...Array.from(modelMap.values()), ...attachments]);
|
package/dist/cjs/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
29
|
};
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.SelectDialogDesignation = exports.errorsDecoder = exports.
|
|
31
|
+
exports.SelectDialogDesignation = exports.errorsDecoder = exports.useDeepCompareCallback = exports.useDeepCompareMemo = exports.useFiles = exports.PdfPreview = void 0;
|
|
32
32
|
__exportStar(require("./components/AffiliationsEditor"), exports);
|
|
33
33
|
__exportStar(require("./components/AffiliationsList"), exports);
|
|
34
34
|
__exportStar(require("./components/AuthorForm"), exports);
|
|
@@ -60,14 +60,16 @@ __exportStar(require("./components/Tip"), exports);
|
|
|
60
60
|
__exportStar(require("./components/icons"), exports);
|
|
61
61
|
__exportStar(require("./components/Inspector"), exports);
|
|
62
62
|
__exportStar(require("./components/InspectorSection"), exports);
|
|
63
|
-
var inlineFiles_1 = require("./lib/inlineFiles");
|
|
64
|
-
Object.defineProperty(exports, "inlineFiles", { enumerable: true, get: function () { return __importDefault(inlineFiles_1).default; } });
|
|
65
|
-
Object.defineProperty(exports, "getSupplementFiles", { enumerable: true, get: function () { return inlineFiles_1.getSupplementFiles; } });
|
|
66
63
|
var PdfPreview_1 = require("./components/PdfPreview");
|
|
67
64
|
Object.defineProperty(exports, "PdfPreview", { enumerable: true, get: function () { return __importDefault(PdfPreview_1).default; } });
|
|
68
65
|
__exportStar(require("./components/SubmissionInspector"), exports);
|
|
69
66
|
__exportStar(require("./components/Dropdown"), exports);
|
|
70
67
|
__exportStar(require("./hooks/use-dropdown"), exports);
|
|
68
|
+
var use_files_1 = require("./hooks/use-files");
|
|
69
|
+
Object.defineProperty(exports, "useFiles", { enumerable: true, get: function () { return __importDefault(use_files_1).default; } });
|
|
70
|
+
var use_deep_compare_1 = require("./hooks/use-deep-compare");
|
|
71
|
+
Object.defineProperty(exports, "useDeepCompareMemo", { enumerable: true, get: function () { return use_deep_compare_1.useDeepCompareMemo; } });
|
|
72
|
+
Object.defineProperty(exports, "useDeepCompareCallback", { enumerable: true, get: function () { return use_deep_compare_1.useDeepCompareCallback; } });
|
|
71
73
|
__exportStar(require("./lib/authors"), exports);
|
|
72
74
|
__exportStar(require("./lib/capabilities"), exports);
|
|
73
75
|
var lw_errors_decoder_1 = require("./lib/lw-errors-decoder");
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSupplementFiles = void 0;
|
|
4
3
|
const manuscript_transform_1 = require("@manuscripts/manuscript-transform");
|
|
5
4
|
const manuscripts_json_schema_1 = require("@manuscripts/manuscripts-json-schema");
|
|
6
5
|
const util_1 = require("../components/FileManager/util");
|
|
7
|
-
const getCaptionText = (caption) => caption &&
|
|
8
|
-
new DOMParser().parseFromString(caption, 'text/html').documentElement
|
|
9
|
-
.innerText;
|
|
10
6
|
const getAttachment = (externalFileRef, attachmentsMap) => {
|
|
11
7
|
if (!(externalFileRef === null || externalFileRef === void 0 ? void 0 : externalFileRef.url.includes('https://'))) {
|
|
12
8
|
const attachmentId = externalFileRef === null || externalFileRef === void 0 ? void 0 : externalFileRef.url.replace('attachment:', '');
|
|
@@ -33,7 +29,6 @@ const getFigureData = (element, modelMap, attachmentsMap) => {
|
|
|
33
29
|
return {
|
|
34
30
|
id: element._id,
|
|
35
31
|
attachments,
|
|
36
|
-
caption: getCaptionText(element.caption),
|
|
37
32
|
};
|
|
38
33
|
};
|
|
39
34
|
exports.default = (modelMap, attachments) => {
|
|
@@ -60,7 +55,6 @@ exports.default = (modelMap, attachments) => {
|
|
|
60
55
|
label: `Table`,
|
|
61
56
|
type: util_1.FileType.SheetsWorkbooks,
|
|
62
57
|
attachments: [attachment],
|
|
63
|
-
caption: getCaptionText(tableElement.caption),
|
|
64
58
|
});
|
|
65
59
|
}
|
|
66
60
|
});
|
|
@@ -110,19 +104,13 @@ const getAuxiliaryObjects = (modelMap) => {
|
|
|
110
104
|
}
|
|
111
105
|
return {
|
|
112
106
|
graphicalAbstractFigureId,
|
|
113
|
-
figureElement: orderObjects[manuscripts_json_schema_1.ObjectTypes.FigureElement]
|
|
114
|
-
|
|
115
|
-
: figureElementIds,
|
|
116
|
-
tableElement: orderObjects[manuscripts_json_schema_1.ObjectTypes.TableElement]
|
|
117
|
-
? sortAuxiliaryObject(orderObjects[manuscripts_json_schema_1.ObjectTypes.TableElement], tableElementIds)
|
|
118
|
-
: tableElementIds,
|
|
107
|
+
figureElement: sortAuxiliaryObject(figureElementIds, orderObjects[manuscripts_json_schema_1.ObjectTypes.FigureElement]),
|
|
108
|
+
tableElement: sortAuxiliaryObject(tableElementIds, orderObjects[manuscripts_json_schema_1.ObjectTypes.TableElement]),
|
|
119
109
|
};
|
|
120
110
|
};
|
|
121
|
-
const sortAuxiliaryObject = (
|
|
111
|
+
const sortAuxiliaryObject = (auxiliaryObjectIds, orderObject) => {
|
|
112
|
+
if (!orderObject) {
|
|
113
|
+
return auxiliaryObjectIds;
|
|
114
|
+
}
|
|
122
115
|
return auxiliaryObjectIds.sort((a, b) => orderObject.elements.indexOf(a) - orderObject.elements.indexOf(b));
|
|
123
116
|
};
|
|
124
|
-
const getSupplementFiles = (modelMap, attachments) => {
|
|
125
|
-
const supplements = new Map((0, manuscript_transform_1.getModelsByType)(modelMap, manuscripts_json_schema_1.ObjectTypes.Supplement).map((supplement) => { var _a; return [(_a = supplement.href) === null || _a === void 0 ? void 0 : _a.replace('attachment:', ''), supplement]; }));
|
|
126
|
-
return attachments.filter((attachment) => supplements.has(attachment.id));
|
|
127
|
-
};
|
|
128
|
-
exports.getSupplementFiles = getSupplementFiles;
|
|
@@ -8,9 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { buildSupplementaryMaterial, } from '@manuscripts/manuscript-transform';
|
|
11
|
-
import React, { createContext, useCallback,
|
|
11
|
+
import React, { createContext, useCallback, useReducer } from 'react';
|
|
12
12
|
import ReactTooltip from 'react-tooltip';
|
|
13
|
-
import
|
|
13
|
+
import { useFiles } from '../../index';
|
|
14
14
|
import { InspectorTab, InspectorTabList, InspectorTabPanel, InspectorTabPanels, InspectorTabs, } from '../Inspector';
|
|
15
15
|
import { InspectorSection } from '../InspectorSection';
|
|
16
16
|
import { DraggableFileSectionItem } from './FileSectionItem/DraggableFileSectionItem';
|
|
@@ -72,27 +72,13 @@ export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileM
|
|
|
72
72
|
}
|
|
73
73
|
}), [modelMap, saveModel]);
|
|
74
74
|
const attachments = getAttachments();
|
|
75
|
-
const
|
|
76
|
-
const supplementFiles = useMemo(() => getSupplementFiles(modelMap, attachments), [attachments, modelMap.size]);
|
|
77
|
-
const excludedAttachmentsIds = useMemo(() => {
|
|
78
|
-
const attachmentsIDs = new Set();
|
|
79
|
-
inlineFiles.map(({ attachments }) => {
|
|
80
|
-
if (attachments) {
|
|
81
|
-
attachments.map((attachment) => attachmentsIDs.add(attachment.id));
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
supplementFiles.map(({ id }) => attachmentsIDs.add(id));
|
|
85
|
-
return attachmentsIDs;
|
|
86
|
-
}, [inlineFiles, supplementFiles]);
|
|
75
|
+
const { otherFiles, supplementFiles, inlineFiles } = useFiles(modelMap, attachments);
|
|
87
76
|
const getFileSectionExternalFile = (fileSection) => {
|
|
88
77
|
const isSupplementOrOtherFilesTab = fileSection === FileSectionType.Supplements ||
|
|
89
78
|
fileSection === FileSectionType.OtherFile;
|
|
90
79
|
const isOtherFilesTab = fileSection === FileSectionType.OtherFile;
|
|
91
80
|
const itemsData = (fileSection === FileSectionType.Supplements && supplementFiles) ||
|
|
92
|
-
|
|
93
|
-
const designation = namesWithDesignationMap.get(element.type.label);
|
|
94
|
-
return (designation !== undefined && !excludedAttachmentsIds.has(element.id));
|
|
95
|
-
});
|
|
81
|
+
otherFiles;
|
|
96
82
|
const itemsDataWithTitle = generateAttachmentsTitles(itemsData, fileSection);
|
|
97
83
|
const filesItems = itemsDataWithTitle.map((element) => {
|
|
98
84
|
const itemProps = {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2022 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { isEqual } from 'lodash';
|
|
17
|
+
import { useCallback, useMemo, useRef } from 'react';
|
|
18
|
+
const useDeepCompare = (deps) => {
|
|
19
|
+
const ref = useRef(deps);
|
|
20
|
+
if (!isEqual(deps, ref.current)) {
|
|
21
|
+
ref.current = deps;
|
|
22
|
+
}
|
|
23
|
+
return ref.current;
|
|
24
|
+
};
|
|
25
|
+
export const useDeepCompareMemo = (callback, deps) => useMemo(callback, [useDeepCompare(deps), callback]);
|
|
26
|
+
export const useDeepCompareCallback = (callback, deps) => useCallback(callback, [useDeepCompare(deps), callback]);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { getModelsByType } from '@manuscripts/manuscript-transform';
|
|
2
|
+
import { ObjectTypes, } from '@manuscripts/manuscripts-json-schema';
|
|
3
|
+
import getInlineFiles from '../lib/inlineFiles';
|
|
4
|
+
import { useDeepCompareMemo } from './use-deep-compare';
|
|
5
|
+
const getSupplementFiles = (modelMap, attachments, filePredicate) => {
|
|
6
|
+
const supplements = new Map(getModelsByType(modelMap, ObjectTypes.Supplement).map((supplement) => { var _a; return [(_a = supplement.href) === null || _a === void 0 ? void 0 : _a.replace('attachment:', ''), supplement]; }));
|
|
7
|
+
return attachments.filter((attachment) => {
|
|
8
|
+
if (supplements.has(attachment.id) && filePredicate) {
|
|
9
|
+
return filePredicate(attachment.name);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return supplements.has(attachment.id);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
const getOtherFiles = (inlineFiles, supplementFiles, attachments, filePredicate) => {
|
|
17
|
+
const inlineFilesAttachmentIds = inlineFiles
|
|
18
|
+
.map(({ attachments }) => (attachments === null || attachments === void 0 ? void 0 : attachments.map(({ id }) => ({ id }))) || [])
|
|
19
|
+
.flat();
|
|
20
|
+
const excludedAttachmentsIds = new Set([...inlineFilesAttachmentIds, ...supplementFiles].map(({ id }) => id));
|
|
21
|
+
return attachments.filter(({ id, name }) => {
|
|
22
|
+
if (!excludedAttachmentsIds.has(id) && filePredicate) {
|
|
23
|
+
return filePredicate(name);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return !excludedAttachmentsIds.has(id);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
export default (modelMap, attachments, filePredicate) => useDeepCompareMemo(() => {
|
|
31
|
+
const inlineFiles = getInlineFiles(modelMap, attachments);
|
|
32
|
+
const supplementFiles = getSupplementFiles(modelMap, attachments, filePredicate);
|
|
33
|
+
const otherFiles = getOtherFiles(inlineFiles, supplementFiles, attachments, filePredicate);
|
|
34
|
+
return {
|
|
35
|
+
otherFiles,
|
|
36
|
+
supplementFiles,
|
|
37
|
+
inlineFiles,
|
|
38
|
+
};
|
|
39
|
+
}, [...Array.from(modelMap.values()), ...attachments]);
|
package/dist/es/index.js
CHANGED
|
@@ -44,11 +44,12 @@ export * from './components/Tip';
|
|
|
44
44
|
export * from './components/icons';
|
|
45
45
|
export * from './components/Inspector';
|
|
46
46
|
export * from './components/InspectorSection';
|
|
47
|
-
export { default as inlineFiles, getSupplementFiles } from './lib/inlineFiles';
|
|
48
47
|
export { default as PdfPreview } from './components/PdfPreview';
|
|
49
48
|
export * from './components/SubmissionInspector';
|
|
50
49
|
export * from './components/Dropdown';
|
|
51
50
|
export * from './hooks/use-dropdown';
|
|
51
|
+
export { default as useFiles } from './hooks/use-files';
|
|
52
|
+
export { useDeepCompareMemo, useDeepCompareCallback, } from './hooks/use-deep-compare';
|
|
52
53
|
export * from './lib/authors';
|
|
53
54
|
export * from './lib/capabilities';
|
|
54
55
|
export { default as errorsDecoder } from './lib/lw-errors-decoder';
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hasObjectType } from '@manuscripts/manuscript-transform';
|
|
2
2
|
import { ObjectTypes, } from '@manuscripts/manuscripts-json-schema';
|
|
3
3
|
import { FileType } from '../components/FileManager/util';
|
|
4
|
-
const getCaptionText = (caption) => caption &&
|
|
5
|
-
new DOMParser().parseFromString(caption, 'text/html').documentElement
|
|
6
|
-
.innerText;
|
|
7
4
|
const getAttachment = (externalFileRef, attachmentsMap) => {
|
|
8
5
|
if (!(externalFileRef === null || externalFileRef === void 0 ? void 0 : externalFileRef.url.includes('https://'))) {
|
|
9
6
|
const attachmentId = externalFileRef === null || externalFileRef === void 0 ? void 0 : externalFileRef.url.replace('attachment:', '');
|
|
@@ -30,7 +27,6 @@ const getFigureData = (element, modelMap, attachmentsMap) => {
|
|
|
30
27
|
return {
|
|
31
28
|
id: element._id,
|
|
32
29
|
attachments,
|
|
33
|
-
caption: getCaptionText(element.caption),
|
|
34
30
|
};
|
|
35
31
|
};
|
|
36
32
|
export default (modelMap, attachments) => {
|
|
@@ -57,7 +53,6 @@ export default (modelMap, attachments) => {
|
|
|
57
53
|
label: `Table`,
|
|
58
54
|
type: FileType.SheetsWorkbooks,
|
|
59
55
|
attachments: [attachment],
|
|
60
|
-
caption: getCaptionText(tableElement.caption),
|
|
61
56
|
});
|
|
62
57
|
}
|
|
63
58
|
});
|
|
@@ -107,18 +102,13 @@ const getAuxiliaryObjects = (modelMap) => {
|
|
|
107
102
|
}
|
|
108
103
|
return {
|
|
109
104
|
graphicalAbstractFigureId,
|
|
110
|
-
figureElement: orderObjects[ObjectTypes.FigureElement]
|
|
111
|
-
|
|
112
|
-
: figureElementIds,
|
|
113
|
-
tableElement: orderObjects[ObjectTypes.TableElement]
|
|
114
|
-
? sortAuxiliaryObject(orderObjects[ObjectTypes.TableElement], tableElementIds)
|
|
115
|
-
: tableElementIds,
|
|
105
|
+
figureElement: sortAuxiliaryObject(figureElementIds, orderObjects[ObjectTypes.FigureElement]),
|
|
106
|
+
tableElement: sortAuxiliaryObject(tableElementIds, orderObjects[ObjectTypes.TableElement]),
|
|
116
107
|
};
|
|
117
108
|
};
|
|
118
|
-
const sortAuxiliaryObject = (
|
|
109
|
+
const sortAuxiliaryObject = (auxiliaryObjectIds, orderObject) => {
|
|
110
|
+
if (!orderObject) {
|
|
111
|
+
return auxiliaryObjectIds;
|
|
112
|
+
}
|
|
119
113
|
return auxiliaryObjectIds.sort((a, b) => orderObject.elements.indexOf(a) - orderObject.elements.indexOf(b));
|
|
120
114
|
};
|
|
121
|
-
export const getSupplementFiles = (modelMap, attachments) => {
|
|
122
|
-
const supplements = new Map(getModelsByType(modelMap, ObjectTypes.Supplement).map((supplement) => { var _a; return [(_a = supplement.href) === null || _a === void 0 ? void 0 : _a.replace('attachment:', ''), supplement]; }));
|
|
123
|
-
return attachments.filter((attachment) => supplements.has(attachment.id));
|
|
124
|
-
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2022 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export declare const useDeepCompareMemo: <T, D>(callback: () => T, deps: D) => T;
|
|
17
|
+
export declare const useDeepCompareCallback: <T, D>(callback: () => T, deps: D) => () => T;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Model } from '@manuscripts/manuscripts-json-schema';
|
|
2
|
+
import { SubmissionAttachment } from '../components/FileManager/FileSectionItem/FileSectionItem';
|
|
3
|
+
import { InlineFile } from '../lib/inlineFiles';
|
|
4
|
+
declare type FilePredicate = (fileName: string) => boolean;
|
|
5
|
+
declare const _default: (modelMap: Map<string, Model>, attachments: SubmissionAttachment[], filePredicate?: FilePredicate | undefined) => {
|
|
6
|
+
otherFiles: SubmissionAttachment[];
|
|
7
|
+
supplementFiles: SubmissionAttachment[];
|
|
8
|
+
inlineFiles: InlineFile[];
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -45,11 +45,12 @@ export * from './components/Tip';
|
|
|
45
45
|
export * from './components/icons';
|
|
46
46
|
export * from './components/Inspector';
|
|
47
47
|
export * from './components/InspectorSection';
|
|
48
|
-
export { default as inlineFiles, getSupplementFiles } from './lib/inlineFiles';
|
|
49
48
|
export { default as PdfPreview } from './components/PdfPreview';
|
|
50
49
|
export * from './components/SubmissionInspector';
|
|
51
50
|
export * from './components/Dropdown';
|
|
52
51
|
export * from './hooks/use-dropdown';
|
|
52
|
+
export { default as useFiles } from './hooks/use-files';
|
|
53
|
+
export { useDeepCompareMemo, useDeepCompareCallback, } from './hooks/use-deep-compare';
|
|
53
54
|
export * from './lib/authors';
|
|
54
55
|
export * from './lib/capabilities';
|
|
55
56
|
export { default as errorsDecoder } from './lib/lw-errors-decoder';
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Model } from '@manuscripts/manuscripts-json-schema';
|
|
2
2
|
import { SubmissionAttachment } from '../components/FileManager/FileSectionItem/FileSectionItem';
|
|
3
3
|
import { FileType } from '../components/FileManager/util';
|
|
4
|
-
declare
|
|
4
|
+
export declare type InlineFile = {
|
|
5
5
|
id: string;
|
|
6
6
|
label: string;
|
|
7
7
|
type: FileType;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
attachments?: SubmissionAttachment[];
|
|
9
|
+
};
|
|
10
|
+
declare const _default: (modelMap: Map<string, Model>, attachments: SubmissionAttachment[]) => InlineFile[];
|
|
11
11
|
export default _default;
|
|
12
|
-
export declare const getSupplementFiles: (modelMap: Map<string, Model>, attachments: SubmissionAttachment[]) => SubmissionAttachment[];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/style-guide",
|
|
3
3
|
"description": "Shared components for Manuscripts applications",
|
|
4
|
-
"version": "0.31.
|
|
4
|
+
"version": "0.31.19",
|
|
5
5
|
"repository": "gitlab:atypon-opensource/manuscripts-style-guide",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|