@manuscripts/article-editor 3.1.2 → 3.1.3

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.
@@ -3,14 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FileNameText = exports.FileName = void 0;
6
+ exports.FileNameContainer = exports.FileNameText = exports.FileName = void 0;
7
+ const style_guide_1 = require("@manuscripts/style-guide");
7
8
  const react_1 = __importDefault(require("react"));
8
9
  const styled_components_1 = __importDefault(require("styled-components"));
10
+ const files_1 = require("../../lib/files");
9
11
  const FileTypeIcon_1 = require("./FileTypeIcon");
10
12
  const FileName = ({ file }) => {
13
+ const maxBaseNameLength = 30; // Adjust this value as needed
14
+ // Get the trimmed filename
15
+ const trimmedFilename = (0, files_1.trimFilename)(file.name, maxBaseNameLength);
11
16
  return (react_1.default.createElement(react_1.default.Fragment, null,
12
- react_1.default.createElement(FileTypeIcon_1.FileTypeIcon, { file: file }),
13
- react_1.default.createElement(exports.FileNameText, { "data-cy": "filename" }, file.name)));
17
+ react_1.default.createElement(exports.FileNameContainer, { "data-tooltip-id": `${file.id}-file-name-tooltip` },
18
+ react_1.default.createElement(FileTypeIcon_1.FileTypeIcon, { file: file }),
19
+ react_1.default.createElement(exports.FileNameText, { "data-cy": "filename" },
20
+ trimmedFilename,
21
+ react_1.default.createElement(style_guide_1.Tooltip, { id: `${file.id}-file-name-tooltip`, place: "bottom" }, file.name)))));
14
22
  };
15
23
  exports.FileName = FileName;
16
24
  exports.FileNameText = styled_components_1.default.div `
@@ -25,4 +33,11 @@ exports.FileNameText = styled_components_1.default.div `
25
33
  white-space: nowrap;
26
34
  text-overflow: ellipsis;
27
35
  `;
36
+ exports.FileNameContainer = styled_components_1.default.div `
37
+ display: flex;
38
+
39
+ .react-tooltip {
40
+ max-width: 100% !important;
41
+ }
42
+ `;
28
43
  //# sourceMappingURL=FileName.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileName.js","sourceRoot":"","sources":["../../../../src/components/FileManager/FileName.tsx"],"names":[],"mappings":";;;;;;AAYA,kDAAyB;AACzB,0EAAsC;AAEtC,iDAA6C;AAEtC,MAAM,QAAQ,GAEhB,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAChB,OAAO,CACL;QACE,8BAAC,2BAAY,IAAC,IAAI,EAAE,IAAI,GAAI;QAC5B,8BAAC,oBAAY,eAAS,UAAU,IAAE,IAAI,CAAC,IAAI,CAAgB,CAC1D,CACJ,CAAA;AACH,CAAC,CAAA;AATY,QAAA,QAAQ,YASpB;AAEY,QAAA,YAAY,GAAG,2BAAM,CAAC,GAAG,CAAA;iBACrB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;eACzC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM;iBACrC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK;iBAC5C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;WAC/C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;iBACpC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;;;;;CAKpD,CAAA"}
1
+ {"version":3,"file":"FileName.js","sourceRoot":"","sources":["../../../../src/components/FileManager/FileName.tsx"],"names":[],"mappings":";;;;;;AAYA,0DAAkD;AAClD,kDAAyB;AACzB,0EAAsC;AAEtC,2CAA8C;AAC9C,iDAA6C;AAEtC,MAAM,QAAQ,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AAG,CAAA;;;;;;CAM1C,CAAA"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.trimFilename = void 0;
4
+ /*!
5
+ * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
6
+ *
7
+ * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
8
+ *
9
+ * The Original Code is manuscripts-frontend.
10
+ *
11
+ * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
12
+ *
13
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
14
+ */
15
+ const trimFilename = (filename, maxLength) => {
16
+ const lastDotIndex = filename.lastIndexOf('.');
17
+ if (lastDotIndex === -1) {
18
+ // No extension found, return the original filename
19
+ return filename;
20
+ }
21
+ const baseName = filename.substring(0, lastDotIndex);
22
+ const extension = filename.substring(lastDotIndex); // Includes the dot
23
+ if (baseName.length > maxLength) {
24
+ // Trim the base name and add ellipsis
25
+ const truncatedBaseName = baseName.substring(0, maxLength - 3); // Leave space for ellipsis
26
+ return `${truncatedBaseName}...${extension}`;
27
+ }
28
+ return filename;
29
+ };
30
+ exports.trimFilename = trimFilename;
31
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/lib/files.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACI,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAE,SAAiB,EAAE,EAAE;IAClE,MAAM,YAAY,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IAE9C,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE;QACvB,mDAAmD;QACnD,OAAO,QAAQ,CAAA;KAChB;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,YAAY,CAAC,CAAA;IACpD,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,YAAY,CAAC,CAAA,CAAC,mBAAmB;IAEtE,IAAI,QAAQ,CAAC,MAAM,GAAG,SAAS,EAAE;QAC/B,sCAAsC;QACtC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,CAAA,CAAC,2BAA2B;QAC1F,OAAO,GAAG,iBAAiB,MAAM,SAAS,EAAE,CAAA;KAC7C;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAlBY,QAAA,YAAY,gBAkBxB"}
@@ -1,10 +1,18 @@
1
+ import { Tooltip } from '@manuscripts/style-guide';
1
2
  import React from 'react';
2
3
  import styled from 'styled-components';
4
+ import { trimFilename } from '../../lib/files';
3
5
  import { FileTypeIcon } from './FileTypeIcon';
4
6
  export const FileName = ({ file }) => {
7
+ const maxBaseNameLength = 30; // Adjust this value as needed
8
+ // Get the trimmed filename
9
+ const trimmedFilename = trimFilename(file.name, maxBaseNameLength);
5
10
  return (React.createElement(React.Fragment, null,
6
- React.createElement(FileTypeIcon, { file: file }),
7
- React.createElement(FileNameText, { "data-cy": "filename" }, file.name)));
11
+ React.createElement(FileNameContainer, { "data-tooltip-id": `${file.id}-file-name-tooltip` },
12
+ React.createElement(FileTypeIcon, { file: file }),
13
+ React.createElement(FileNameText, { "data-cy": "filename" },
14
+ trimmedFilename,
15
+ React.createElement(Tooltip, { id: `${file.id}-file-name-tooltip`, place: "bottom" }, file.name)))));
8
16
  };
9
17
  export const FileNameText = styled.div `
10
18
  font-family: ${(props) => props.theme.font.family.Lato};
@@ -18,4 +26,11 @@ export const FileNameText = styled.div `
18
26
  white-space: nowrap;
19
27
  text-overflow: ellipsis;
20
28
  `;
29
+ export const FileNameContainer = styled.div `
30
+ display: flex;
31
+
32
+ .react-tooltip {
33
+ max-width: 100% !important;
34
+ }
35
+ `;
21
36
  //# sourceMappingURL=FileName.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileName.js","sourceRoot":"","sources":["../../../../src/components/FileManager/FileName.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,MAAM,CAAC,MAAM,QAAQ,GAEhB,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAChB,OAAO,CACL;QACE,oBAAC,YAAY,IAAC,IAAI,EAAE,IAAI,GAAI;QAC5B,oBAAC,YAAY,eAAS,UAAU,IAAE,IAAI,CAAC,IAAI,CAAgB,CAC1D,CACJ,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA;iBACrB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;eACzC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM;iBACrC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK;iBAC5C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;WAC/C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;iBACpC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,C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AC,UAAU,CAAC,KAAK;iBAC5C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;WAC/C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;iBACpC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;;;;;CAKpD,CAAA;AACD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;CAM1C,CAAA"}
@@ -0,0 +1,27 @@
1
+ /*!
2
+ * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
3
+ *
4
+ * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
5
+ *
6
+ * The Original Code is manuscripts-frontend.
7
+ *
8
+ * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
+ *
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
11
+ */
12
+ export const trimFilename = (filename, maxLength) => {
13
+ const lastDotIndex = filename.lastIndexOf('.');
14
+ if (lastDotIndex === -1) {
15
+ // No extension found, return the original filename
16
+ return filename;
17
+ }
18
+ const baseName = filename.substring(0, lastDotIndex);
19
+ const extension = filename.substring(lastDotIndex); // Includes the dot
20
+ if (baseName.length > maxLength) {
21
+ // Trim the base name and add ellipsis
22
+ const truncatedBaseName = baseName.substring(0, maxLength - 3); // Leave space for ellipsis
23
+ return `${truncatedBaseName}...${extension}`;
24
+ }
25
+ return filename;
26
+ };
27
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/lib/files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAE,SAAiB,EAAE,EAAE;IAClE,MAAM,YAAY,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IAE9C,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE;QACvB,mDAAmD;QACnD,OAAO,QAAQ,CAAA;KAChB;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,YAAY,CAAC,CAAA;IACpD,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,YAAY,CAAC,CAAA,CAAC,mBAAmB;IAEtE,IAAI,QAAQ,CAAC,MAAM,GAAG,SAAS,EAAE;QAC/B,sCAAsC;QACtC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,CAAA,CAAC,2BAA2B;QAC1F,OAAO,GAAG,iBAAiB,MAAM,SAAS,EAAE,CAAA;KAC7C;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA"}
@@ -15,3 +15,4 @@ export declare const FileName: React.FC<{
15
15
  file: FileAttachment;
16
16
  }>;
17
17
  export declare const FileNameText: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
18
+ export declare const FileNameContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://mpapp-public.gitlab.io/manuscripts-frontend/LICENSE. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
3
+ *
4
+ * Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
5
+ *
6
+ * The Original Code is manuscripts-frontend.
7
+ *
8
+ * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
9
+ *
10
+ * All portions of the code written by Atypon Systems LLC are Copyright (c) 2024 Atypon Systems LLC. All Rights Reserved.
11
+ */
12
+ export declare const trimFilename: (filename: string, maxLength: number) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manuscripts/article-editor",
3
- "version": "3.1.2",
3
+ "version": "3.1.3",
4
4
  "license": "CPAL-1.0",
5
5
  "description": "React components for editing and viewing manuscripts",
6
6
  "repository": "github:Atypon-OpenSource/manuscripts-article-editor",
@@ -108,4 +108,4 @@
108
108
  "resolutions": {
109
109
  "@types/react": "^18.3.1"
110
110
  }
111
- }
111
+ }