@manuscripts/article-editor 1.9.4 → 1.9.5-LEAN-3083-2

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.
Files changed (121) hide show
  1. package/dist/cjs/src/components/Sidebar/Sidebar.js +1 -2
  2. package/dist/cjs/src/components/Sidebar/Sidebar.js.map +1 -1
  3. package/dist/cjs/src/components/metadata/AuthorModalViews.js +7 -3
  4. package/dist/cjs/src/components/metadata/AuthorModalViews.js.map +1 -1
  5. package/dist/cjs/src/components/metadata/AuthorsPage.js +1 -11
  6. package/dist/cjs/src/components/metadata/AuthorsPage.js.map +1 -1
  7. package/dist/cjs/src/components/projects/ManuscriptPageContainer.js +0 -14
  8. package/dist/cjs/src/components/projects/ManuscriptPageContainer.js.map +1 -1
  9. package/dist/cjs/src/hooks/use-create-editor.js +2 -22
  10. package/dist/cjs/src/hooks/use-create-editor.js.map +1 -1
  11. package/dist/cjs/src/hooks/use-tracked-model-management.js +10 -0
  12. package/dist/cjs/src/hooks/use-tracked-model-management.js.map +1 -1
  13. package/dist/cjs/src/lib/authors.js +3 -1
  14. package/dist/cjs/src/lib/authors.js.map +1 -1
  15. package/dist/es/src/components/Sidebar/Sidebar.js +1 -2
  16. package/dist/es/src/components/Sidebar/Sidebar.js.map +1 -1
  17. package/dist/es/src/components/metadata/AuthorModalViews.js +7 -3
  18. package/dist/es/src/components/metadata/AuthorModalViews.js.map +1 -1
  19. package/dist/es/src/components/metadata/AuthorsPage.js +0 -9
  20. package/dist/es/src/components/metadata/AuthorsPage.js.map +1 -1
  21. package/dist/es/src/components/projects/ManuscriptPageContainer.js +0 -14
  22. package/dist/es/src/components/projects/ManuscriptPageContainer.js.map +1 -1
  23. package/dist/es/src/hooks/use-create-editor.js +2 -22
  24. package/dist/es/src/hooks/use-create-editor.js.map +1 -1
  25. package/dist/es/src/hooks/use-tracked-model-management.js +10 -0
  26. package/dist/es/src/hooks/use-tracked-model-management.js.map +1 -1
  27. package/dist/es/src/lib/authors.js +3 -1
  28. package/dist/es/src/lib/authors.js.map +1 -1
  29. package/dist/types/src/components/metadata/AuthorsPage.d.ts +0 -1
  30. package/dist/types/src/store/useStore.d.ts +1 -1
  31. package/package.json +5 -6
  32. package/dist/cjs/src/components/SelectField.js +0 -24
  33. package/dist/cjs/src/components/SelectField.js.map +0 -1
  34. package/dist/cjs/src/components/library/BibliographyImportButton.js +0 -149
  35. package/dist/cjs/src/components/library/BibliographyImportButton.js.map +0 -1
  36. package/dist/cjs/src/components/library/CitationEditor.js +0 -227
  37. package/dist/cjs/src/components/library/CitationEditor.js.map +0 -1
  38. package/dist/cjs/src/components/library/CitationModal.js +0 -262
  39. package/dist/cjs/src/components/library/CitationModal.js.map +0 -1
  40. package/dist/cjs/src/components/library/CitationSearch.js +0 -214
  41. package/dist/cjs/src/components/library/CitationSearch.js.map +0 -1
  42. package/dist/cjs/src/components/library/CitationSearchSection.js +0 -133
  43. package/dist/cjs/src/components/library/CitationSearchSection.js.map +0 -1
  44. package/dist/cjs/src/components/library/CitationViewer.js +0 -53
  45. package/dist/cjs/src/components/library/CitationViewer.js.map +0 -1
  46. package/dist/cjs/src/components/library/ReferenceForm.js +0 -419
  47. package/dist/cjs/src/components/library/ReferenceForm.js.map +0 -1
  48. package/dist/cjs/src/components/library/ReferencesEditor.js +0 -70
  49. package/dist/cjs/src/components/library/ReferencesEditor.js.map +0 -1
  50. package/dist/cjs/src/components/library/ReferencesViewer.js +0 -33
  51. package/dist/cjs/src/components/library/ReferencesViewer.js.map +0 -1
  52. package/dist/cjs/src/components/library/SearchResults.js +0 -126
  53. package/dist/cjs/src/components/library/SearchResults.js.map +0 -1
  54. package/dist/cjs/src/components/metadata/AuthorsInlineViewContainer.js +0 -94
  55. package/dist/cjs/src/components/metadata/AuthorsInlineViewContainer.js.map +0 -1
  56. package/dist/cjs/src/components/projects/icons/DeleteIcon.js +0 -27
  57. package/dist/cjs/src/components/projects/icons/DeleteIcon.js.map +0 -1
  58. package/dist/cjs/src/components/projects/icons/GroupIcon.js +0 -29
  59. package/dist/cjs/src/components/projects/icons/GroupIcon.js.map +0 -1
  60. package/dist/cjs/src/components/projects/icons/LinkIcon.js +0 -23
  61. package/dist/cjs/src/components/projects/icons/LinkIcon.js.map +0 -1
  62. package/dist/cjs/src/components/projects/icons/TemplateIcon.js +0 -23
  63. package/dist/cjs/src/components/projects/icons/TemplateIcon.js.map +0 -1
  64. package/dist/cjs/src/lib/select-styles.js +0 -40
  65. package/dist/cjs/src/lib/select-styles.js.map +0 -1
  66. package/dist/cjs/src/lib/sources.js +0 -36
  67. package/dist/cjs/src/lib/sources.js.map +0 -1
  68. package/dist/es/src/components/SelectField.js +0 -17
  69. package/dist/es/src/components/SelectField.js.map +0 -1
  70. package/dist/es/src/components/library/BibliographyImportButton.js +0 -120
  71. package/dist/es/src/components/library/BibliographyImportButton.js.map +0 -1
  72. package/dist/es/src/components/library/CitationEditor.js +0 -198
  73. package/dist/es/src/components/library/CitationEditor.js.map +0 -1
  74. package/dist/es/src/components/library/CitationModal.js +0 -232
  75. package/dist/es/src/components/library/CitationModal.js.map +0 -1
  76. package/dist/es/src/components/library/CitationSearch.js +0 -184
  77. package/dist/es/src/components/library/CitationSearch.js.map +0 -1
  78. package/dist/es/src/components/library/CitationSearchSection.js +0 -103
  79. package/dist/es/src/components/library/CitationSearchSection.js.map +0 -1
  80. package/dist/es/src/components/library/CitationViewer.js +0 -46
  81. package/dist/es/src/components/library/CitationViewer.js.map +0 -1
  82. package/dist/es/src/components/library/ReferenceForm.js +0 -389
  83. package/dist/es/src/components/library/ReferenceForm.js.map +0 -1
  84. package/dist/es/src/components/library/ReferencesEditor.js +0 -43
  85. package/dist/es/src/components/library/ReferencesEditor.js.map +0 -1
  86. package/dist/es/src/components/library/ReferencesViewer.js +0 -26
  87. package/dist/es/src/components/library/ReferencesViewer.js.map +0 -1
  88. package/dist/es/src/components/library/SearchResults.js +0 -119
  89. package/dist/es/src/components/library/SearchResults.js.map +0 -1
  90. package/dist/es/src/components/metadata/AuthorsInlineViewContainer.js +0 -65
  91. package/dist/es/src/components/metadata/AuthorsInlineViewContainer.js.map +0 -1
  92. package/dist/es/src/components/projects/icons/DeleteIcon.js +0 -20
  93. package/dist/es/src/components/projects/icons/DeleteIcon.js.map +0 -1
  94. package/dist/es/src/components/projects/icons/GroupIcon.js +0 -22
  95. package/dist/es/src/components/projects/icons/GroupIcon.js.map +0 -1
  96. package/dist/es/src/components/projects/icons/LinkIcon.js +0 -16
  97. package/dist/es/src/components/projects/icons/LinkIcon.js.map +0 -1
  98. package/dist/es/src/components/projects/icons/TemplateIcon.js +0 -16
  99. package/dist/es/src/components/projects/icons/TemplateIcon.js.map +0 -1
  100. package/dist/es/src/lib/select-styles.js +0 -37
  101. package/dist/es/src/lib/select-styles.js.map +0 -1
  102. package/dist/es/src/lib/sources.js +0 -33
  103. package/dist/es/src/lib/sources.js.map +0 -1
  104. package/dist/types/src/components/SelectField.d.ts +0 -23
  105. package/dist/types/src/components/library/BibliographyImportButton.d.ts +0 -23
  106. package/dist/types/src/components/library/CitationEditor.d.ts +0 -30
  107. package/dist/types/src/components/library/CitationModal.d.ts +0 -17
  108. package/dist/types/src/components/library/CitationSearch.d.ts +0 -22
  109. package/dist/types/src/components/library/CitationSearchSection.d.ts +0 -34
  110. package/dist/types/src/components/library/CitationViewer.d.ts +0 -18
  111. package/dist/types/src/components/library/ReferenceForm.d.ts +0 -51
  112. package/dist/types/src/components/library/ReferencesEditor.d.ts +0 -22
  113. package/dist/types/src/components/library/ReferencesViewer.d.ts +0 -9
  114. package/dist/types/src/components/library/SearchResults.d.ts +0 -26
  115. package/dist/types/src/components/metadata/AuthorsInlineViewContainer.d.ts +0 -23
  116. package/dist/types/src/components/projects/icons/DeleteIcon.d.ts +0 -13
  117. package/dist/types/src/components/projects/icons/GroupIcon.d.ts +0 -15
  118. package/dist/types/src/components/projects/icons/LinkIcon.d.ts +0 -13
  119. package/dist/types/src/components/projects/icons/TemplateIcon.d.ts +0 -13
  120. package/dist/types/src/lib/select-styles.d.ts +0 -13
  121. package/dist/types/src/lib/sources.d.ts +0 -25
@@ -1,198 +0,0 @@
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) 2019 Atypon Systems LLC. All Rights Reserved.
11
- */
12
- import AnnotationEdit from '@manuscripts/assets/react/AnnotationEdit';
13
- import CloseIconDark from '@manuscripts/assets/react/CloseIconDark';
14
- import { ObjectTypes, } from '@manuscripts/json-schema';
15
- import { shortLibraryItemMetadata } from '@manuscripts/library';
16
- import { AddComment, ButtonGroup, Category, Dialog, IconButton, IconTextButton, PrimaryButton, SecondaryButton, } from '@manuscripts/style-guide';
17
- import { Title } from '@manuscripts/title-editor';
18
- import { buildBibliographyItem, buildComment, getModelsByType, } from '@manuscripts/transform';
19
- import React, { useCallback, useMemo, useRef, useState } from 'react';
20
- import styled, { css } from 'styled-components';
21
- import { CitationModal } from './CitationModal';
22
- import { CitationSearch } from './CitationSearch';
23
- const CitedItem = styled.div `
24
- padding: ${(props) => props.theme.grid.unit * 4}px 0;
25
-
26
- &:not(:last-of-type) {
27
- border-bottom: 1px solid ${(props) => props.theme.colors.border.secondary};
28
- }
29
- `;
30
- const textOverflow = css `
31
- text-overflow: ellipsis;
32
- white-space: nowrap;
33
- overflow: hidden;
34
- `;
35
- export const CitedItemTitle = styled(Title) `
36
- ${(props) => props.withOverflow && textOverflow}
37
- `;
38
- export const CitedItemMetadata = styled.div `
39
- color: ${(props) => props.theme.colors.text.secondary};
40
- flex: 1;
41
- font-weight: ${(props) => props.theme.font.weight.light};
42
- margin-top: ${(props) => props.theme.grid.unit}px;
43
- ${textOverflow}
44
- `;
45
- const CitedItemActionLine = styled.div `
46
- display: flex;
47
- align-items: center;
48
- justify-content: space-between;
49
- white-space: nowrap;
50
- `;
51
- const CitedItemActions = styled.span `
52
- display: inline-flex;
53
- align-items: center;
54
- flex-shrink: 0;
55
-
56
- svg.remove-icon {
57
- height: ${(props) => props.theme.grid.unit * 4}px;
58
- width: ${(props) => props.theme.grid.unit * 4}px;
59
- }
60
- `;
61
- const CitedItems = styled.div `
62
- padding: 0 ${(props) => props.theme.grid.unit * 4}px;
63
- font-family: ${(props) => props.theme.font.family.sans};
64
- max-height: 70vh;
65
- min-height: 100px;
66
- overflow-y: auto;
67
- `;
68
- const ActionButton = styled(IconButton).attrs({
69
- size: 24,
70
- }) `
71
- :disabled {
72
- background-color: transparent !important;
73
- border-color: transparent !important;
74
- color: rgb(255, 255, 255);
75
- path,
76
- g {
77
- fill: ${(props) => props.theme.colors.background.tertiary} !important;
78
- }
79
- }
80
- :not(:disabled):focus,
81
- :not(:disabled):hover {
82
- path,
83
- g {
84
- fill: ${(props) => props.theme.colors.brand.medium} !important;
85
- }
86
- }
87
- `;
88
- const Actions = styled.div `
89
- margin: ${(props) => props.theme.grid.unit * 4}px;
90
- display: flex;
91
- justify-content: space-between;
92
- align-items: center;
93
- `;
94
- const CitationEditor = ({ items, modelMap: initModelMap, saveModel, deleteModel, handleCancel, handleCite, handleClose, handleRemove, selectedText, setComment, importItems, insertBibliographyNode, citation, updatePopper, canEdit, }) => {
95
- const [searching, setSearching] = useState(false);
96
- const [modelMap, setModelMap] = useState(initModelMap);
97
- const saveCallback = useCallback(async (item) => {
98
- await saveModel({ ...item, objectType: ObjectTypes.BibliographyItem });
99
- setModelMap(new Map([
100
- ...modelMap,
101
- [item._id, { ...item, objectType: ObjectTypes.BibliographyItem }],
102
- ]));
103
- updatePopper();
104
- }, [modelMap, saveModel, updatePopper]);
105
- const [showEditModel, setShowEditModel] = useState(false);
106
- const [selectedItem, setSelectedItem] = useState();
107
- const referenceIdRef = useRef('');
108
- const onCitationEditClick = useCallback((e) => {
109
- const itemId = e.currentTarget.value;
110
- const reference = modelMap.get(itemId);
111
- setSelectedItem(reference);
112
- setShowEditModel(true);
113
- referenceIdRef.current = reference._id;
114
- }, [modelMap]);
115
- const deleteReferenceCallback = useCallback(async () => {
116
- if (selectedItem) {
117
- await deleteModel(selectedItem._id);
118
- modelMap.delete(selectedItem._id);
119
- setModelMap(new Map([...modelMap]));
120
- setSelectedItem(modelMap.get(referenceIdRef.current));
121
- }
122
- }, [selectedItem, modelMap, deleteModel, referenceIdRef]);
123
- const [deleteDialog, setDeleteDialog] = useState({ show: false });
124
- const addCitationCallback = useCallback(async () => {
125
- const item = buildBibliographyItem({
126
- title: 'Untitled',
127
- type: 'article-journal',
128
- });
129
- setSearching(false);
130
- setSelectedItem(item);
131
- setShowEditModel(true);
132
- insertBibliographyNode(item);
133
- setModelMap(new Map([...modelMap, [item._id, { ...item }]]));
134
- }, [insertBibliographyNode, modelMap]);
135
- const addCommentCallback = useCallback(() => setComment(buildComment(citation._id)), [citation._id, setComment]);
136
- const bibliographyItems = useMemo(() => {
137
- const citedReferencesSet = new Set(items.map((item) => item._id));
138
- return new Map(getModelsByType(modelMap, ObjectTypes.BibliographyItem)
139
- .filter((model) => !citedReferencesSet.has(model._id))
140
- .map((model) => [model._id, model]));
141
- }, [items, modelMap]);
142
- if (searching) {
143
- return (React.createElement(CitationSearch, { query: selectedText, bibliographyItems: bibliographyItems, importItems: importItems, handleCite: handleCite, addCitation: addCitationCallback, handleCancel: () => setSearching(false) }));
144
- }
145
- if (!items.length) {
146
- return (React.createElement("div", null,
147
- React.createElement(CitationSearch, { query: selectedText, bibliographyItems: bibliographyItems, importItems: importItems, handleCite: handleCite, addCitation: addCitationCallback, handleCancel: handleCancel }),
148
- React.createElement(CitationModal, { editCitation: showEditModel, modelMap: modelMap, saveCallback: saveCallback, selectedItem: selectedItem, deleteCallback: deleteReferenceCallback, setSelectedItem: setSelectedItem, setShowEditModel: setShowEditModel })));
149
- }
150
- return (React.createElement("div", null,
151
- React.createElement(Dialog, { isOpen: deleteDialog.show, category: Category.confirmation, header: "Remove cited item", message: "Are you sure you want to remove this cited item? It will still exist in the reference list.", actions: {
152
- secondary: {
153
- action: () => {
154
- if (deleteDialog.id) {
155
- handleRemove(deleteDialog.id);
156
- setDeleteDialog({ show: false });
157
- }
158
- },
159
- title: 'Remove',
160
- },
161
- primary: {
162
- action: () => setDeleteDialog({ show: false }),
163
- title: 'Cancel',
164
- },
165
- } }),
166
- React.createElement(CitedItems, null, items.map((item) => (React.createElement(CitedItem, { key: item._id, style: {
167
- color: item.title === '[missing library item]' ? 'red' : 'inherit',
168
- } },
169
- React.createElement(CitedItemTitle, { value: item.title || 'Untitled' }),
170
- React.createElement(CitedItemActionLine, null,
171
- React.createElement(CitedItemMetadata, null, shortLibraryItemMetadata(item)),
172
- React.createElement(CitedItemActions, null,
173
- React.createElement(EditCitationButton, { value: item._id, onClick: onCitationEditClick, disabled: !canEdit },
174
- React.createElement(AnnotationEdit, { color: '#6E6E6E' })),
175
- React.createElement(ActionButton, { disabled: !canEdit, onClick: () => setDeleteDialog({ show: true, id: item._id }) },
176
- React.createElement(CloseIconDark, { className: 'remove-icon' })))))))),
177
- React.createElement(CitationModal, { editCitation: showEditModel, modelMap: modelMap, saveCallback: saveCallback, selectedItem: selectedItem, deleteCallback: deleteReferenceCallback, setSelectedItem: setSelectedItem, setShowEditModel: setShowEditModel }),
178
- React.createElement(Actions, null,
179
- React.createElement(IconTextButton, { onClick: addCommentCallback },
180
- React.createElement(AddComment, null),
181
- React.createElement(AddCommentButtonText, null, "Add Comment")),
182
- React.createElement(ButtonGroup, null,
183
- React.createElement(SecondaryButton, { onClick: () => handleClose() }, "Done"),
184
- React.createElement(PrimaryButton, { disabled: !canEdit, onClick: () => setSearching(true) }, "Add Citation")))));
185
- };
186
- export default CitationEditor;
187
- const EditCitationButton = styled(ActionButton) `
188
- margin-right: ${(props) => props.theme.grid.unit * 3}px;
189
- `;
190
- const AddCommentButtonText = styled.div `
191
- display: contents;
192
- font-family: ${(props) => props.theme.font.family.sans};
193
- font-weight: ${(props) => props.theme.font.weight.normal};
194
- font-size: ${(props) => props.theme.font.size.small};
195
- line-height: ${(props) => props.theme.font.lineHeight.large};
196
- color: ${(props) => props.theme.colors.text.primary};
197
- `;
198
- //# sourceMappingURL=CitationEditor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CitationEditor.js","sourceRoot":"","sources":["../../../../../src/components/library/CitationEditor.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,cAAc,MAAM,0CAA0C,CAAA;AACrE,OAAO,aAAa,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAKL,WAAW,GACZ,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EACL,UAAU,EACV,WAAW,EACX,QAAQ,EACR,MAAM,EACN,UAAU,EACV,cAAc,EACd,aAAa,EACb,eAAe,GAChB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AACjD,OAAO,EAEL,qBAAqB,EACrB,YAAY,EACZ,eAAe,GAChB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACrE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,cAA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AAe,EAChC,gBAAgB,EAAE,gBAAgB,GAClC;QACF,oBAAC,OAAO;YACN,oBAAC,cAAc,IAAC,OAAO,EAAE,kBAAkB;gBACzC,oBAAC,UAAU,OAAG;gBACd,oBAAC,oBAAoB,sBAAmC,CACzC;YAEjB,oBAAC,WAAW;gBACV,oBAAC,eAAe,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,WAAwB;gBACrE,oBAAC,aAAa,IAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,mBAEpD,CACJ,CACN,CACN,CACP,CAAA;AACH,CAAC,CAAA;AAED,eAAe,cAAc,CAAA;AAE7B,MAAM,kBAAkB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;kBAC7B,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;CACrD,CAAA;AAED,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAA;;iBAEtB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;iBACvC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;eAC3C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;iBACpC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK;WAClD,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;CACpD,CAAA"}
@@ -1,232 +0,0 @@
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) 2022 Atypon Systems LLC. All Rights Reserved.
11
- */
12
- import ReferenceLibraryIcon from '@manuscripts/assets/react/ReferenceLibraryIcon';
13
- import { ObjectTypes, } from '@manuscripts/json-schema';
14
- import { shortLibraryItemMetadata } from '@manuscripts/library';
15
- import { Category, CloseButton, Dialog, ModalContainer, ModalHeader, StyledModal, } from '@manuscripts/style-guide';
16
- import { getModelsByType } from '@manuscripts/transform';
17
- import { isEqual } from 'lodash-es';
18
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
19
- import ReactTooltip from 'react-tooltip';
20
- import styled, { css } from 'styled-components';
21
- import { useScrollDetection } from '../../hooks/use-scroll-detection';
22
- import { ScrollableModalMain } from '../metadata/AuthorsModals';
23
- import { GroupIcon } from '../projects/icons/GroupIcon';
24
- import { ModalBody, ModalSidebar, SidebarContent, SidebarHeader, } from '../Sidebar';
25
- import { CitedItemMetadata, CitedItemTitle } from './CitationEditor';
26
- import ReferenceForm, { buildInitialValues, } from './ReferenceForm';
27
- export const CitationModal = ({ editCitation, modelMap, saveCallback, selectedItem, setSelectedItem, setShowEditModel, deleteCallback, }) => {
28
- const stopEditing = useCallback(() => setShowEditModel(false), [setShowEditModel]);
29
- const formMikRef = useRef(null);
30
- const [{ referenceCount, references }, setReferences] = useState({
31
- referenceCount: new Map(),
32
- references: [],
33
- });
34
- const [showPendingChangeDialog, setShowPendingChangeDialog] = useState(false);
35
- const onSelectReference = useCallback((e) => {
36
- const other = formMikRef.current?.values;
37
- if (!selectedItem || isEqual(buildInitialValues(selectedItem), other)) {
38
- setSelectedItem(references.find(({ _id }) => _id === e.currentTarget.id));
39
- }
40
- else {
41
- setShowPendingChangeDialog(true);
42
- }
43
- }, [references, selectedItem, setSelectedItem]);
44
- useEffect(() => {
45
- if (editCitation) {
46
- const references = getModelsByType(modelMap, ObjectTypes.BibliographyItem);
47
- const referenceCount = new Map();
48
- getModelsByType(modelMap, ObjectTypes.Citation).map(({ embeddedCitationItems }) => embeddedCitationItems.map(({ bibliographyItem }) => {
49
- let value = referenceCount.get(bibliographyItem);
50
- referenceCount.set(bibliographyItem, (value && ++value) || 1);
51
- }));
52
- setReferences({ references, referenceCount });
53
- }
54
- }, [editCitation, modelMap]);
55
- const modelDeleteCallback = useCallback(() => {
56
- deleteCallback();
57
- setReferences({
58
- referenceCount,
59
- references: [
60
- ...references.filter(({ _id }) => _id !== selectedItem?._id),
61
- ],
62
- });
63
- }, [deleteCallback, referenceCount, references, selectedItem?._id]);
64
- const modelSaveCallback = useCallback((item) => {
65
- saveCallback(item);
66
- setSelectedItem(item);
67
- setReferences({
68
- referenceCount,
69
- references: [
70
- ...references.map((ref) => (ref._id === item?._id ? item : ref)),
71
- ],
72
- });
73
- }, [referenceCount, references, saveCallback, setSelectedItem]);
74
- const disableDelete = ((selectedItem?._id && referenceCount.get(selectedItem._id)) || 0) > 0;
75
- const selectedReferenceNode = useRef(null);
76
- const selectedIndex = useMemo(() => selectedItem
77
- ? references.findIndex((i) => selectedItem?._id == i._id)
78
- : 0, [selectedItem, references]);
79
- useEffect(() => {
80
- setTimeout(() => {
81
- selectedReferenceNode.current?.scrollIntoView({
82
- block: 'center',
83
- behavior: 'auto',
84
- });
85
- }, 100);
86
- }, [selectedIndex]);
87
- const selectedItemTopOffset = 10; // to be able to place the selected item in the middle and allow for some scroll at the top
88
- const pageItemsCount = 12;
89
- const topTrigger = 0.2; // says: notify when x% of the offsetHeight remains hidden at the top
90
- const bottomTrigger = 0.8; // says: notify when x% of the offsetHeight remains hidden at the bottom
91
- const dropLimit = pageItemsCount * 3; // basically maximum amount of items that can exist at the same time
92
- const { ref, triggers } = useScrollDetection(topTrigger, bottomTrigger);
93
- const [firstDisplayIndex, setFirstDisplayIndex] = useState(Math.max(0, selectedIndex - selectedItemTopOffset));
94
- const [lastDisplayIndex, setLastDisplayIndex] = useState(pageItemsCount);
95
- useEffect(() => {
96
- const base = Math.max(0, selectedIndex - selectedItemTopOffset);
97
- setFirstDisplayIndex(base);
98
- setLastDisplayIndex(Math.min(references.length - 1, base + pageItemsCount));
99
- // eslint-disable-next-line react-hooks/exhaustive-deps
100
- }, [references.length]); // this has to run only on start and never on selection change
101
- useEffect(() => {
102
- if (triggers.top) {
103
- const newFirst = Math.max(0, firstDisplayIndex - pageItemsCount);
104
- setFirstDisplayIndex(newFirst);
105
- setLastDisplayIndex(Math.min(newFirst + dropLimit, lastDisplayIndex));
106
- }
107
- if (triggers.bottom) {
108
- const newLast = Math.min(references.length - 1, lastDisplayIndex + pageItemsCount);
109
- setLastDisplayIndex(newLast);
110
- setFirstDisplayIndex(Math.max(newLast - dropLimit, firstDisplayIndex));
111
- }
112
- // eslint-disable-next-line react-hooks/exhaustive-deps
113
- }, [dropLimit, pageItemsCount, triggers, references]);
114
- const displayableRefs = useMemo(() => {
115
- const refs = new Map();
116
- if (references.length) {
117
- for (let i = firstDisplayIndex; i <= lastDisplayIndex; i++) {
118
- references[i] && refs.set(i, references[i]);
119
- }
120
- }
121
- return refs;
122
- }, [firstDisplayIndex, lastDisplayIndex, references]);
123
- if (references.length <= 0) {
124
- return React.createElement(React.Fragment, null);
125
- }
126
- return (React.createElement(StyledModal, { "data-cy": "citations-modal", isOpen: editCitation, onRequestClose: stopEditing, shouldCloseOnOverlayClick: true },
127
- React.createElement(Dialog, { isOpen: showPendingChangeDialog, category: Category.confirmation, header: "You've made changes to this option", message: "Would you like to save or discard your changes?", actions: {
128
- secondary: {
129
- action: () => {
130
- formMikRef.current?.resetForm();
131
- setShowPendingChangeDialog(false);
132
- },
133
- title: 'Discard',
134
- },
135
- primary: {
136
- action: () => {
137
- modelSaveCallback(formMikRef.current?.values);
138
- setShowPendingChangeDialog(false);
139
- },
140
- title: 'Save',
141
- },
142
- } }),
143
- React.createElement(ModalContainer, null,
144
- React.createElement(ModalHeader, null,
145
- React.createElement(CloseButton, { onClick: stopEditing })),
146
- React.createElement(ModalBody, null,
147
- React.createElement(ReferencesSidebar, null,
148
- React.createElement(SidebarHeader, { title: 'References' }),
149
- React.createElement(ReferencesSidebarContent, { ref: ref },
150
- React.createElement(ReferencesInnerWrapper, { "data-cy": "references-list", style: { paddingTop: '0px' } }, [...displayableRefs.entries()].map(([index, item]) => (React.createElement(ReferenceButton, { key: index, id: item._id, onClick: onSelectReference, selected: selectedItem?._id === item._id, ref: selectedItem?._id === item._id
151
- ? selectedReferenceNode
152
- : null },
153
- React.createElement(IconContainer, { "data-tip": true, "data-for": 'group-icon' },
154
- React.createElement(ReferenceLibraryIcon, null),
155
- React.createElement(GroupIcon, { numberOfCitations: referenceCount.get(item._id) || 0 }),
156
- React.createElement(ReactTooltip, { disable: (referenceCount.get(item._id) || 0) < 1, id: 'group-icon', place: "bottom", effect: "solid", offset: { top: 40 }, className: "tooltip" }, "Number of times used in the document")),
157
- React.createElement(Grid, null,
158
- React.createElement(CitedItemTitle, { value: item.title || 'Untitled', withOverflow: true }),
159
- React.createElement(CitedItemMetadata, null, shortLibraryItemMetadata(item))))))))),
160
- React.createElement(ScrollableModalMain, null, selectedItem && (React.createElement(ReferenceForm, { item: selectedItem, formMikRef: formMikRef, disableDelete: disableDelete, deleteCallback: modelDeleteCallback, handleCancel: stopEditing, saveCallback: modelSaveCallback })))))));
161
- };
162
- const ReferencesInnerWrapper = styled.div `
163
- width: 100%;
164
- `;
165
- const ReferencesSidebar = styled(ModalSidebar) `
166
- width: 70%;
167
- `;
168
- const ReferencesSidebarContent = styled(SidebarContent) `
169
- overflow-y: auto;
170
- `;
171
- const Grid = styled.div `
172
- display: grid;
173
- `;
174
- export const Legend = styled.legend `
175
- font: ${(props) => props.theme.font.weight.normal}
176
- ${(props) => props.theme.font.size.xlarge} /
177
- ${(props) => props.theme.font.lineHeight.large}
178
- ${(props) => props.theme.font.family.sans};
179
- letter-spacing: -0.4px;
180
- color: ${(props) => props.theme.colors.text.secondary};
181
- `;
182
- export const Fields = styled.div `
183
- padding: 16px;
184
- `;
185
- export const Label = styled.label `
186
- display: flex;
187
- flex-direction: column;
188
- margin-bottom: 10px;
189
- `;
190
- export const Container = styled.div `
191
- display: flex;
192
- justify-content: space-between;
193
- `;
194
- export const Fieldset = styled.fieldset `
195
- border: none;
196
-
197
- &:not(:last-child) {
198
- margin-bottom: 16px;
199
- }
200
- `;
201
- const selectedReferenceStyle = css `
202
- background: ${(props) => props.theme.colors.background.info};
203
- border-top: 1px solid #bce7f6;
204
- border-bottom: 1px solid #bce7f6;
205
- `;
206
- const ReferenceButton = styled.div `
207
- cursor: pointer;
208
- display: flex;
209
- justify-content: flex-start;
210
- padding: ${(props) => props.theme.grid.unit * 4}px 0;
211
-
212
- path {
213
- fill: #c9c9c9;
214
- }
215
-
216
- :hover {
217
- background: ${(props) => props.theme.colors.background.info};
218
- }
219
-
220
- ${(props) => props.selected && selectedReferenceStyle}
221
-
222
- .tooltip {
223
- max-width: ${(props) => props.theme.grid.unit * 25}px;
224
- padding: ${(props) => props.theme.grid.unit * 2}px;
225
- border-radius: 6px;
226
- }
227
- `;
228
- const IconContainer = styled.div `
229
- padding-right: ${(props) => props.theme.grid.unit * 5}px;
230
- position: relative;
231
- `;
232
- //# sourceMappingURL=CitationModal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CitationModal.js","sourceRoot":"","sources":["../../../../../src/components/library/CitationModal.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,oBAAoB,MAAM,gDAAgD,CAAA;AAC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AAI;;;CAG5D,CAAA;AAED,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAuB;;;;aAI5C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;;;;;;;kBAO/B,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI;;;IAG3D,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,IAAI,sBAAsB;;;iBAGtC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE;eACvC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;;;CAGlD,CAAA;AAED,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA;mBACb,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;;CAEtD,CAAA"}
@@ -1,184 +0,0 @@
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) 2019 Atypon Systems LLC. All Rights Reserved.
11
- */
12
- import { crossref } from '@manuscripts/body-editor';
13
- import { estimateID } from '@manuscripts/library';
14
- import { ButtonGroup, IconTextButton, PrimaryButton, SecondaryButton, Tip, UploadIcon, } from '@manuscripts/style-guide';
15
- import { buildBibliographyItem } from '@manuscripts/transform';
16
- import axios from 'axios';
17
- import { debounce } from 'lodash-es';
18
- import React, { useCallback, useEffect, useState } from 'react';
19
- import styled from 'styled-components';
20
- import { filterLibrary } from '../../lib/search-library';
21
- import { TemplateIcon } from '../projects/icons/TemplateIcon';
22
- import Search, { SearchWrapper } from '../Search';
23
- import { BibliographyImportButton } from './BibliographyImportButton';
24
- import { CitationSearchSection } from './CitationSearchSection';
25
- const Results = styled.div `
26
- max-height: 400px;
27
- overflow-y: auto;
28
- `;
29
- const Actions = styled(ButtonGroup) `
30
- align-items: center;
31
- box-shadow: 0 -2px 12px 0 rgba(216, 216, 216, 0.26);
32
- display: flex;
33
- justify-content: space-between;
34
- padding: ${(props) => props.theme.grid.unit * 4}px;
35
- `;
36
- const Container = styled.div `
37
- flex: 1;
38
- font-family: ${(props) => props.theme.font.family.sans};
39
- `;
40
- const ImportButton = ({ importItems, importing, }) => (React.createElement(IconTextButton, { onClick: importItems },
41
- React.createElement(Tip, { title: 'Import bibliography data from a BibTeX or RIS file', placement: 'top' }, importing ? ('Importing…') : (React.createElement(React.Fragment, null,
42
- React.createElement(UploadIcon, null),
43
- "Import from file")))));
44
- export const CitationSearch = ({ bibliographyItems, handleCite, addCitation, importItems: _importItems, query: initialQuery, handleCancel, }) => {
45
- const [error, setError] = useState();
46
- const [selectedSource, setSelectedSource] = useState();
47
- const [query, setQuery] = useState(initialQuery);
48
- const [selected, setSelected] = useState(new Map());
49
- const [fetching, setFetching] = useState(new Set());
50
- const [sources, setSources] = useState();
51
- const [updated, setUpdated] = useState(Date.now());
52
- const searchLibrary = useCallback((query, params) => {
53
- return filterLibrary(bibliographyItems, query).then((items) => ({
54
- items: items.slice(0, params.rows),
55
- total: items.length,
56
- }));
57
- }, [bibliographyItems]);
58
- const [cancelTokenSource, setCancelTokenSource] = useState();
59
- const apiSearchCallback = useCallback((query, params, mailto) => {
60
- cancelTokenSource?.cancel();
61
- const sourceToken = axios.CancelToken.source();
62
- setCancelTokenSource(sourceToken);
63
- return crossref.search(query, params.rows, mailto, sourceToken.token);
64
- }, [cancelTokenSource]);
65
- useEffect(() => {
66
- const sources = [
67
- {
68
- id: 'library',
69
- title: 'Document',
70
- search: searchLibrary,
71
- },
72
- ];
73
- if (query.trim().length > 2) {
74
- sources.push({
75
- id: 'crossref',
76
- title: 'External sources',
77
- search: apiSearchCallback,
78
- });
79
- }
80
- setSources(sources);
81
- }, [apiSearchCallback, query, searchLibrary]);
82
- const addToSelection = useCallback((id, data) => {
83
- if (selected.has(id)) {
84
- selected.delete(id); // remove item
85
- setSelected(new Map([...selected]));
86
- }
87
- else if (data._id) {
88
- selected.set(id, data); // re-use existing data model
89
- setSelected(new Map([...selected]));
90
- }
91
- else {
92
- setFetching((fetching) => {
93
- fetching.add(id);
94
- return new Set([...fetching]);
95
- });
96
- // fetch Citeproc JSON
97
- crossref
98
- .fetch(data)
99
- .then((result) => {
100
- // remove DOI URLs
101
- if (result.URL &&
102
- result.URL.match(/^https?:\/\/(dx\.)?doi\.org\//)) {
103
- delete result.URL;
104
- }
105
- setSelected((selected) => {
106
- selected.set(id, buildBibliographyItem({
107
- ...result,
108
- type: result.type == 'journal-article'
109
- ? 'article-journal'
110
- : result.type,
111
- }));
112
- return new Map([...selected]);
113
- });
114
- window.setTimeout(() => {
115
- setFetching((fetching) => {
116
- fetching.delete(id);
117
- return new Set([...fetching]);
118
- });
119
- }, 100);
120
- })
121
- .catch((error) => {
122
- setError(error.message);
123
- });
124
- }
125
- }, [selected]);
126
- const handleCiteClick = useCallback(() => {
127
- const items = Array.from(selected.values());
128
- return handleCite(items);
129
- }, [handleCite, selected]);
130
- const debouncedCallback = debounce((value) => setQuery(value.trim()), 800);
131
- const debouncedSetQuery = useCallback((event) => debouncedCallback(event.target.value), [debouncedCallback]);
132
- const importItems = useCallback((items) => {
133
- return _importItems(items).then((newItems) => {
134
- setSelected((selected) => {
135
- // if there's a single new imported item, select it
136
- if (newItems.length === 1) {
137
- const [newItem] = newItems;
138
- const estimatedID = estimateID(newItem);
139
- selected.set(estimatedID, newItem);
140
- }
141
- return new Map([...selected]);
142
- });
143
- // clear the query after importing items
144
- setQuery('');
145
- // ensure that the filters re-run
146
- setUpdated(Date.now());
147
- return newItems;
148
- });
149
- }, [_importItems]);
150
- if (!sources) {
151
- return null;
152
- }
153
- return (React.createElement(Container, null,
154
- React.createElement(SearchWrapper, null,
155
- React.createElement(Search, { autoComplete: 'off', handleSearchChange: debouncedSetQuery, placeholder: 'Search', defaultValue: initialQuery, type: 'search' })),
156
- React.createElement(Results, null,
157
- error && React.createElement("div", null, error),
158
- sources.map((source) => (React.createElement(CitationSearchSection, { key: `${source.id}-${updated}`, source: source, addToSelection: addToSelection, selectSource: () => setSelectedSource(source.id), selected: selected, fetching: fetching, query: query, rows: selectedSource === source.id ? 25 : 3 })))),
159
- React.createElement(Actions, null,
160
- React.createElement(AddCitationActions, null,
161
- React.createElement(BibliographyImportButton, { importItems: importItems, component: ImportButton }),
162
- React.createElement(IconTextButton, { onClick: addCitation },
163
- React.createElement(TemplateIcon, null),
164
- "Add new")),
165
- React.createElement(ButtonGroup, null,
166
- React.createElement(SecondaryButton, { onClick: handleCancel }, "Close"),
167
- React.createElement(PrimaryButton, { onClick: handleCiteClick, disabled: selected.size === 0 }, "Cite")))));
168
- };
169
- const AddCitationActions = styled(ButtonGroup) `
170
- button {
171
- margin-right: ${(props) => props.theme.grid.unit * 8}px;
172
- }
173
-
174
- button:hover,
175
- button:active {
176
- path {
177
- stroke: ${(props) => props.theme.colors.brand.medium};
178
- }
179
- rect {
180
- stroke: ${(props) => props.theme.colors.brand.medium};
181
- }
182
- }
183
- `;
184
- //# sourceMappingURL=CitationSearch.js.map