@manuscripts/style-guide 0.31.8 → 0.31.11

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.
@@ -33,10 +33,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  exports.FileManager = exports.PermissionsContext = void 0;
35
35
  const manuscript_transform_1 = require("@manuscripts/manuscript-transform");
36
- const manuscripts_json_schema_1 = require("@manuscripts/manuscripts-json-schema");
37
36
  const react_1 = __importStar(require("react"));
38
37
  const react_tooltip_1 = __importDefault(require("react-tooltip"));
39
- const inlineFiles_1 = __importDefault(require("../../lib/inlineFiles"));
38
+ const inlineFiles_1 = __importStar(require("../../lib/inlineFiles"));
40
39
  const AlertMessage_1 = require("../AlertMessage");
41
40
  const Inspector_1 = require("../Inspector");
42
41
  const InspectorSection_1 = require("../InspectorSection");
@@ -86,25 +85,17 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
86
85
  return handleDownload(publicUrl);
87
86
  }, [handleDownload]);
88
87
  const inlineFiles = (0, react_1.useMemo)(() => (0, inlineFiles_1.default)(modelMap, attachments), [modelMap.values(), attachments]);
89
- const inlineAttachmentsIds = (0, react_1.useMemo)(() => {
88
+ const supplementFiles = (0, react_1.useMemo)(() => (0, inlineFiles_1.getSupplementFiles)(modelMap, attachments), [attachments, modelMap.size]);
89
+ const excludedAttachmentsIds = (0, react_1.useMemo)(() => {
90
90
  const attachmentsIDs = new Set();
91
91
  inlineFiles.map(({ attachments }) => {
92
92
  if (attachments) {
93
93
  attachments.map((attachment) => attachmentsIDs.add(attachment.id));
94
94
  }
95
95
  });
96
+ supplementFiles.map(({ id }) => attachmentsIDs.add(id));
96
97
  return attachmentsIDs;
97
- }, [inlineFiles]);
98
- const supplementFiles = (0, react_1.useMemo)(() => {
99
- const supplements = new Map((0, manuscript_transform_1.getModelsByType)(modelMap, manuscripts_json_schema_1.ObjectTypes.Supplement).map((supplement) => {
100
- var _a;
101
- return [
102
- (_a = supplement.href) === null || _a === void 0 ? void 0 : _a.replace('attachment:', ''),
103
- supplement,
104
- ];
105
- }));
106
- return attachments.filter((attachment) => supplements.has(attachment.id));
107
- }, [attachments, modelMap.size]);
98
+ }, [inlineFiles, supplementFiles]);
108
99
  const getFileSectionExternalFile = (fileSection) => {
109
100
  const isSupplementOrOtherFilesTab = fileSection === util_1.FileSectionType.Supplements ||
110
101
  fileSection === util_1.FileSectionType.OtherFile;
@@ -113,7 +104,7 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
113
104
  const designation = util_1.namesWithDesignationMap.get(element.type.label);
114
105
  return (designation !== undefined &&
115
106
  util_1.designationWithFileSectionsMap.get(designation) === fileSection &&
116
- !inlineAttachmentsIds.has(element.id));
107
+ !excludedAttachmentsIds.has(element.id));
117
108
  });
118
109
  const itemsDataWithTitle = (0, util_1.generateAttachmentsTitles)(itemsData, fileSection);
119
110
  const filesItems = itemsDataWithTitle.map((element) => {
@@ -51,8 +51,7 @@ const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, inlin
51
51
  util_1.fileTypesWithIconMap.get(file.type),
52
52
  react_1.default.createElement(FileInfo_1.FileInfoContainer, null,
53
53
  react_1.default.createElement(FileInfo_1.FileNameTitleContainer, null,
54
- react_1.default.createElement(FileInfo_1.FileTitle, null, file.label)),
55
- file.caption && (react_1.default.createElement(FileInfo_1.FileDescription, null, file.caption))))));
54
+ react_1.default.createElement(FileInfo_1.FileTitle, null, file.label))))));
56
55
  })));
57
56
  };
58
57
  exports.InlineFilesSection = InlineFilesSection;
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.PdfPreview = exports.inlineFiles = void 0;
31
+ exports.SelectDialogDesignation = exports.errorsDecoder = exports.PdfPreview = exports.getSupplementFiles = exports.inlineFiles = void 0;
32
32
  __exportStar(require("./components/AffiliationsEditor"), exports);
33
33
  __exportStar(require("./components/AffiliationsList"), exports);
34
34
  __exportStar(require("./components/AuthorForm"), exports);
@@ -62,6 +62,7 @@ __exportStar(require("./components/Inspector"), exports);
62
62
  __exportStar(require("./components/InspectorSection"), exports);
63
63
  var inlineFiles_1 = require("./lib/inlineFiles");
64
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; } });
65
66
  var PdfPreview_1 = require("./components/PdfPreview");
66
67
  Object.defineProperty(exports, "PdfPreview", { enumerable: true, get: function () { return __importDefault(PdfPreview_1).default; } });
67
68
  __exportStar(require("./components/SubmissionInspector"), exports);
@@ -52,6 +52,7 @@ const getLWCapabilities = (project, profile, lwRole, actions) => {
52
52
  previewAccess: true,
53
53
  editNotTracked: false,
54
54
  accessEditor: true,
55
+ formatArticle: !isViewer(),
55
56
  };
56
57
  };
57
58
  exports.getLWCapabilities = getLWCapabilities;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSupplementFiles = void 0;
3
4
  const manuscript_transform_1 = require("@manuscripts/manuscript-transform");
4
5
  const manuscripts_json_schema_1 = require("@manuscripts/manuscripts-json-schema");
5
6
  const util_1 = require("../components/FileManager/util");
@@ -66,8 +67,8 @@ exports.default = (modelMap, attachments) => {
66
67
  };
67
68
  const getAuxiliaryObjects = (modelMap) => {
68
69
  var _a, _b;
69
- let graphicalAbstractFigureId;
70
- const figureElementIds = [], tableElementIds = [], orderObjects = {};
70
+ let graphicalAbstractFigureId, figureElementIds = [];
71
+ const tableElementIds = [], orderObjects = {};
71
72
  for (const model of modelMap.values()) {
72
73
  switch (model.objectType) {
73
74
  case manuscripts_json_schema_1.ObjectTypes.Section: {
@@ -103,6 +104,9 @@ const getAuxiliaryObjects = (modelMap) => {
103
104
  }
104
105
  }
105
106
  }
107
+ if (graphicalAbstractFigureId) {
108
+ figureElementIds = figureElementIds.filter((id) => id != graphicalAbstractFigureId);
109
+ }
106
110
  return {
107
111
  graphicalAbstractFigureId,
108
112
  figureElement: orderObjects[manuscripts_json_schema_1.ObjectTypes.FigureElement]
@@ -116,3 +120,8 @@ const getAuxiliaryObjects = (modelMap) => {
116
120
  const sortAuxiliaryObject = (orderObject, auxiliaryObjectIds) => {
117
121
  return auxiliaryObjectIds.sort((a, b) => orderObject.elements.indexOf(a) - orderObject.elements.indexOf(b));
118
122
  };
123
+ const getSupplementFiles = (modelMap, attachments) => {
124
+ 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]; }));
125
+ return attachments.filter((attachment) => supplements.has(attachment.id));
126
+ };
127
+ exports.getSupplementFiles = getSupplementFiles;
@@ -7,11 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { buildSupplementaryMaterial, getModelsByType, } from '@manuscripts/manuscript-transform';
11
- import { ObjectTypes, } from '@manuscripts/manuscripts-json-schema';
10
+ import { buildSupplementaryMaterial, } from '@manuscripts/manuscript-transform';
12
11
  import React, { createContext, useCallback, useMemo, useReducer } from 'react';
13
12
  import ReactTooltip from 'react-tooltip';
14
- import getInlineFiles from '../../lib/inlineFiles';
13
+ import getInlineFiles, { getSupplementFiles } from '../../lib/inlineFiles';
15
14
  import { AlertMessage, AlertMessageType } from '../AlertMessage';
16
15
  import { InspectorTab, InspectorTabList, InspectorTabPanel, InspectorTabPanels, InspectorTabs, } from '../Inspector';
17
16
  import { InspectorSection } from '../InspectorSection';
@@ -61,25 +60,17 @@ export const FileManager = ({ submissionId, attachments, modelMap, saveModel, en
61
60
  return handleDownload(publicUrl);
62
61
  }, [handleDownload]);
63
62
  const inlineFiles = useMemo(() => getInlineFiles(modelMap, attachments), [modelMap.values(), attachments]);
64
- const inlineAttachmentsIds = useMemo(() => {
63
+ const supplementFiles = useMemo(() => getSupplementFiles(modelMap, attachments), [attachments, modelMap.size]);
64
+ const excludedAttachmentsIds = useMemo(() => {
65
65
  const attachmentsIDs = new Set();
66
66
  inlineFiles.map(({ attachments }) => {
67
67
  if (attachments) {
68
68
  attachments.map((attachment) => attachmentsIDs.add(attachment.id));
69
69
  }
70
70
  });
71
+ supplementFiles.map(({ id }) => attachmentsIDs.add(id));
71
72
  return attachmentsIDs;
72
- }, [inlineFiles]);
73
- const supplementFiles = useMemo(() => {
74
- const supplements = new Map(getModelsByType(modelMap, ObjectTypes.Supplement).map((supplement) => {
75
- var _a;
76
- return [
77
- (_a = supplement.href) === null || _a === void 0 ? void 0 : _a.replace('attachment:', ''),
78
- supplement,
79
- ];
80
- }));
81
- return attachments.filter((attachment) => supplements.has(attachment.id));
82
- }, [attachments, modelMap.size]);
73
+ }, [inlineFiles, supplementFiles]);
83
74
  const getFileSectionExternalFile = (fileSection) => {
84
75
  const isSupplementOrOtherFilesTab = fileSection === FileSectionType.Supplements ||
85
76
  fileSection === FileSectionType.OtherFile;
@@ -88,7 +79,7 @@ export const FileManager = ({ submissionId, attachments, modelMap, saveModel, en
88
79
  const designation = namesWithDesignationMap.get(element.type.label);
89
80
  return (designation !== undefined &&
90
81
  designationWithFileSectionsMap.get(designation) === fileSection &&
91
- !inlineAttachmentsIds.has(element.id));
82
+ !excludedAttachmentsIds.has(element.id));
92
83
  });
93
84
  const itemsDataWithTitle = generateAttachmentsTitles(itemsData, fileSection);
94
85
  const filesItems = itemsDataWithTitle.map((element) => {
@@ -2,7 +2,7 @@ import React, { useCallback } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { useDropdown } from '../../hooks/use-dropdown';
4
4
  import DotsIcon from '../icons/dots-icon';
5
- import { FileDescription, FileInfoContainer, FileNameTitleContainer, FileTitle, } from './FileSectionItem/FileInfo';
5
+ import { FileInfoContainer, FileNameTitleContainer, FileTitle, } from './FileSectionItem/FileInfo';
6
6
  import { ActionsIcon, Item, } from './FileSectionItem/FileSectionItem';
7
7
  import { ItemActions } from './FileSectionItem/ItemActions';
8
8
  import { extensionsWithFileTypesMap, fileTypesWithIconMap, } from './util';
@@ -26,8 +26,7 @@ export const InlineFilesSection = ({ submissionId, handleReplace, handleDownload
26
26
  fileTypesWithIconMap.get(file.type),
27
27
  React.createElement(FileInfoContainer, null,
28
28
  React.createElement(FileNameTitleContainer, null,
29
- React.createElement(FileTitle, null, file.label)),
30
- file.caption && (React.createElement(FileDescription, null, file.caption))))));
29
+ React.createElement(FileTitle, null, file.label))))));
31
30
  })));
32
31
  };
33
32
  const FileReference = ({ attachment, submissionId, handleReplace, handleDownload, dispatch, }) => {
package/dist/es/index.js CHANGED
@@ -44,7 +44,7 @@ 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 } from './lib/inlineFiles';
47
+ export { default as inlineFiles, getSupplementFiles } from './lib/inlineFiles';
48
48
  export { default as PdfPreview } from './components/PdfPreview';
49
49
  export * from './components/SubmissionInspector';
50
50
  export * from './components/Dropdown';
@@ -46,6 +46,7 @@ export const getLWCapabilities = (project, profile, lwRole, actions) => {
46
46
  previewAccess: true,
47
47
  editNotTracked: false,
48
48
  accessEditor: true,
49
+ formatArticle: !isViewer(),
49
50
  };
50
51
  };
51
52
  export const getAllPermitted = () => {
@@ -1,4 +1,4 @@
1
- import { hasObjectType } from '@manuscripts/manuscript-transform';
1
+ import { getModelsByType, hasObjectType, } from '@manuscripts/manuscript-transform';
2
2
  import { ObjectTypes, } from '@manuscripts/manuscripts-json-schema';
3
3
  import { FileType } from '../components/FileManager/util';
4
4
  const getCaptionText = (caption) => caption &&
@@ -64,8 +64,8 @@ export default (modelMap, attachments) => {
64
64
  };
65
65
  const getAuxiliaryObjects = (modelMap) => {
66
66
  var _a, _b;
67
- let graphicalAbstractFigureId;
68
- const figureElementIds = [], tableElementIds = [], orderObjects = {};
67
+ let graphicalAbstractFigureId, figureElementIds = [];
68
+ const tableElementIds = [], orderObjects = {};
69
69
  for (const model of modelMap.values()) {
70
70
  switch (model.objectType) {
71
71
  case ObjectTypes.Section: {
@@ -101,6 +101,9 @@ const getAuxiliaryObjects = (modelMap) => {
101
101
  }
102
102
  }
103
103
  }
104
+ if (graphicalAbstractFigureId) {
105
+ figureElementIds = figureElementIds.filter((id) => id != graphicalAbstractFigureId);
106
+ }
104
107
  return {
105
108
  graphicalAbstractFigureId,
106
109
  figureElement: orderObjects[ObjectTypes.FigureElement]
@@ -114,3 +117,7 @@ const getAuxiliaryObjects = (modelMap) => {
114
117
  const sortAuxiliaryObject = (orderObject, auxiliaryObjectIds) => {
115
118
  return auxiliaryObjectIds.sort((a, b) => orderObject.elements.indexOf(a) - orderObject.elements.indexOf(b));
116
119
  };
120
+ export const getSupplementFiles = (modelMap, attachments) => {
121
+ 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]; }));
122
+ return attachments.filter((attachment) => supplements.has(attachment.id));
123
+ };
@@ -45,7 +45,7 @@ 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 } from './lib/inlineFiles';
48
+ export { default as inlineFiles, getSupplementFiles } from './lib/inlineFiles';
49
49
  export { default as PdfPreview } from './components/PdfPreview';
50
50
  export * from './components/SubmissionInspector';
51
51
  export * from './components/Dropdown';
@@ -32,6 +32,7 @@ export declare type Capabilities = {
32
32
  previewAccess: boolean;
33
33
  editNotTracked: boolean;
34
34
  accessEditor: boolean;
35
+ formatArticle: boolean;
35
36
  };
36
37
  export interface ProviderProps {
37
38
  project?: Project;
@@ -9,3 +9,4 @@ declare const _default: (modelMap: Map<string, Model>, attachments: SubmissionAt
9
9
  attachments?: SubmissionAttachment[] | undefined;
10
10
  }[];
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.8",
4
+ "version": "0.31.11",
5
5
  "repository": "gitlab:atypon-opensource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",