@manuscripts/article-editor 1.9.15 → 1.9.16

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 (50) hide show
  1. package/dist/cjs/components/metadata/AuthorModalViews.js +5 -3
  2. package/dist/cjs/components/metadata/AuthorModalViews.js.map +1 -1
  3. package/dist/cjs/components/metadata/AuthorsModalContainer.js +1 -0
  4. package/dist/cjs/components/metadata/AuthorsModalContainer.js.map +1 -1
  5. package/dist/cjs/components/projects/ManuscriptPageContainer.js +10 -18
  6. package/dist/cjs/components/projects/ManuscriptPageContainer.js.map +1 -1
  7. package/dist/cjs/hooks/use-create-editor.js +2 -4
  8. package/dist/cjs/hooks/use-create-editor.js.map +1 -1
  9. package/dist/cjs/hooks/use-handle-snapshot.js +1 -1
  10. package/dist/cjs/hooks/use-handle-snapshot.js.map +1 -1
  11. package/dist/cjs/lib/authors.js +3 -1
  12. package/dist/cjs/lib/authors.js.map +1 -1
  13. package/dist/cjs/tracked-models/adapt-tracked-data.js +93 -0
  14. package/dist/cjs/tracked-models/adapt-tracked-data.js.map +1 -0
  15. package/dist/cjs/tracked-models/creators.js +131 -0
  16. package/dist/cjs/tracked-models/creators.js.map +1 -0
  17. package/dist/cjs/tracked-models/use-tracked-model-management.js +123 -0
  18. package/dist/cjs/tracked-models/use-tracked-model-management.js.map +1 -0
  19. package/dist/es/components/metadata/AuthorModalViews.js +5 -3
  20. package/dist/es/components/metadata/AuthorModalViews.js.map +1 -1
  21. package/dist/es/components/metadata/AuthorsModalContainer.js +1 -0
  22. package/dist/es/components/metadata/AuthorsModalContainer.js.map +1 -1
  23. package/dist/es/components/projects/ManuscriptPageContainer.js +11 -19
  24. package/dist/es/components/projects/ManuscriptPageContainer.js.map +1 -1
  25. package/dist/es/hooks/use-create-editor.js +2 -4
  26. package/dist/es/hooks/use-create-editor.js.map +1 -1
  27. package/dist/es/hooks/use-handle-snapshot.js +1 -1
  28. package/dist/es/hooks/use-handle-snapshot.js.map +1 -1
  29. package/dist/es/lib/authors.js +3 -1
  30. package/dist/es/lib/authors.js.map +1 -1
  31. package/dist/es/tracked-models/adapt-tracked-data.js +88 -0
  32. package/dist/es/tracked-models/adapt-tracked-data.js.map +1 -0
  33. package/dist/es/tracked-models/creators.js +124 -0
  34. package/dist/es/tracked-models/creators.js.map +1 -0
  35. package/dist/es/tracked-models/use-tracked-model-management.js +121 -0
  36. package/dist/es/tracked-models/use-tracked-model-management.js.map +1 -0
  37. package/dist/types/store/useStore.d.ts +1 -1
  38. package/dist/types/tracked-models/adapt-tracked-data.d.ts +13 -0
  39. package/dist/types/tracked-models/creators.d.ts +19 -0
  40. package/package.json +4 -4
  41. package/dist/cjs/components/metadata/AuthorsInlineViewContainer.js +0 -94
  42. package/dist/cjs/components/metadata/AuthorsInlineViewContainer.js.map +0 -1
  43. package/dist/cjs/hooks/use-tracked-model-management.js +0 -251
  44. package/dist/cjs/hooks/use-tracked-model-management.js.map +0 -1
  45. package/dist/es/components/metadata/AuthorsInlineViewContainer.js +0 -65
  46. package/dist/es/components/metadata/AuthorsInlineViewContainer.js.map +0 -1
  47. package/dist/es/hooks/use-tracked-model-management.js +0 -249
  48. package/dist/es/hooks/use-tracked-model-management.js.map +0 -1
  49. package/dist/types/components/metadata/AuthorsInlineViewContainer.d.ts +0 -23
  50. /package/dist/types/{hooks → tracked-models}/use-tracked-model-management.d.ts +0 -0
@@ -0,0 +1,124 @@
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 { schema } from '@manuscripts/transform';
13
+ export const createContributorNode = (model, view, doc, state) => {
14
+ if (!view) {
15
+ throw Error('View not available');
16
+ }
17
+ const { tr } = state;
18
+ doc.descendants((node, pos) => {
19
+ if (node.type === schema.nodes.contributors) {
20
+ tr.insert(pos + node.nodeSize - 1, schema.nodes.contributor.create({
21
+ ...model,
22
+ id: model._id,
23
+ }, schema.text('_')
24
+ /*
25
+ quarterback as it is now works incorrectly with empty nodes and updating attributes on them is misinterpreted as deletion.
26
+ We either need to update quarterback to work correctly with empty nodes attributes or provide some content for these nodes or
27
+ implement a mechanism that would detect attributes updates on empty nodes and setMeta as we do for metaNodes
28
+ */
29
+ ));
30
+ view.dispatch(tr);
31
+ return false;
32
+ }
33
+ });
34
+ };
35
+ export const createAffiliationNode = (model, view, doc, state) => {
36
+ if (!view) {
37
+ throw Error('View not available');
38
+ }
39
+ const { tr } = state;
40
+ doc.descendants((node, pos) => {
41
+ if (node.type === schema.nodes.affiliations) {
42
+ tr.insert(pos + node.nodeSize - 1, schema.nodes.affiliation.create({
43
+ ...model,
44
+ id: model._id,
45
+ }, schema.text('_')));
46
+ view.dispatch(tr);
47
+ return false;
48
+ }
49
+ });
50
+ };
51
+ export const saveComment = (comment, view, doc, state, modelMap) => {
52
+ if (!view) {
53
+ throw Error('View not available');
54
+ }
55
+ const documentComment = {
56
+ id: comment._id,
57
+ contents: comment.contents,
58
+ target: comment.target,
59
+ selector: comment.selector,
60
+ contributions: comment.contributions,
61
+ resolved: comment.resolved,
62
+ originalText: comment.originalText,
63
+ };
64
+ const isNewComment = !modelMap.has(comment._id);
65
+ const isHighlightComment = comment.selector && comment.selector.from !== comment.selector.to;
66
+ const { tr } = state;
67
+ doc.descendants((node, pos) => {
68
+ if (isNewComment || isHighlightComment) {
69
+ /** for new comments will update target comments array with the comment id
70
+ * and add comment node to the comment list node
71
+ * */
72
+ if (node.attrs.id === comment.target && !isHighlightComment) {
73
+ tr.setNodeMarkup(pos, undefined, {
74
+ ...node.attrs,
75
+ comments: [...(node.attrs.comments || []), comment._id],
76
+ });
77
+ }
78
+ if (node.type === schema.nodes.comments) {
79
+ tr.replaceWith(pos, pos + node.nodeSize, node.content.addToEnd(schema.nodes.comment.create(documentComment)));
80
+ tr.setMeta('track-changes-skip-tracking', true);
81
+ view.dispatch(tr);
82
+ return false;
83
+ }
84
+ }
85
+ else {
86
+ if (node.attrs.id === comment._id) {
87
+ tr.setNodeMarkup(pos, undefined, {
88
+ ...documentComment,
89
+ });
90
+ tr.setMeta('track-changes-skip-tracking', true);
91
+ view.dispatch(tr);
92
+ return false;
93
+ }
94
+ }
95
+ });
96
+ return Promise.resolve(comment);
97
+ };
98
+ export const deleteComment = (comment, view, doc, state) => {
99
+ if (!view) {
100
+ throw Error('View not available');
101
+ }
102
+ const { tr } = state;
103
+ const isHighlightComment = comment.selector && comment.selector.from !== comment.selector.to;
104
+ doc.descendants((node, pos) => {
105
+ if (node.attrs.id === comment.target &&
106
+ node.attrs.comments &&
107
+ !isHighlightComment) {
108
+ tr.setNodeMarkup(pos, undefined, {
109
+ ...node.attrs,
110
+ comments: [
111
+ ...node.attrs.comments.filter((id) => id != comment._id),
112
+ ],
113
+ });
114
+ }
115
+ if (node.attrs.id === comment._id && node.type === schema.nodes.comment) {
116
+ tr.delete(pos, pos + node.nodeSize);
117
+ tr.setMeta('track-changes-skip-tracking', true);
118
+ view.dispatch(tr);
119
+ return false;
120
+ }
121
+ });
122
+ return Promise.resolve(comment._id);
123
+ };
124
+ //# sourceMappingURL=creators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creators.js","sourceRoot":"","sources":["../../../src/tracked-models/creators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GA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E;QACT,MAAM,KAAK,CAAC,oBAAoB,CAAC,CAAA;KAClC;IAED,MAAM,EAAE,EAAE,EAAE,GAAG,KAAK,CAAA;IACpB,MAAM,kBAAkB,GACtB,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAA;IAEnE,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QAC5B,IACE,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,OAAO,CAAC,MAAM;YAChC,IAAI,CAAC,KAAK,CAAC,QAAQ;YACnB,CAAC,kBAAkB,EACnB;YACA,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE;gBAC/B,GAAG,IAAI,CAAC,KAAK;gBACb,QAAQ,EAAE;oBACR,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC;iBACjE;aACF,CAAC,CAAA;SACH;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE;YACvE,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAA;YACnC,EAAE,CAAC,OAAO,CAAC,6BAA6B,EAAE,IAAI,CAAC,CAAA;YAC/C,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;YACjB,OAAO,KAAK,CAAA;SACb;IACH,CAAC,CAAC,CAAA;IACF,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;AACrC,CAAC,CAAA"}
@@ -0,0 +1,121 @@
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 { ObjectTypes, } from '@manuscripts/json-schema';
13
+ import { Decoder, encode, schema, } from '@manuscripts/transform';
14
+ import { useCallback, useMemo } from 'react';
15
+ import { setNodeAttrs } from '../lib/node-attrs';
16
+ import { useStore } from '../store';
17
+ import { adaptTrackedData } from './adapt-tracked-data';
18
+ import { createAffiliationNode, createContributorNode, deleteComment, saveComment, } from './creators';
19
+ const useTrackedModelManagement = (doc, view, state, dispatch, saveModel, deleteModel, finalModelMap) => {
20
+ const modelMap = useMemo(() => {
21
+ const adaptedDoc = adaptTrackedData(doc.toJSON());
22
+ const modelsFromPM = encode(schema.nodeFromJSON(adaptedDoc));
23
+ // adding supplements from final model map as they are meta (not PM presentable)
24
+ finalModelMap.forEach((model) => {
25
+ if (model.objectType === ObjectTypes.Supplement) {
26
+ modelsFromPM.set(model._id, model);
27
+ }
28
+ });
29
+ return modelsFromPM;
30
+ // eslint-disable-next-line react-hooks/exhaustive-deps
31
+ }, [doc, finalModelMap]);
32
+ const [, dispatchStore] = useStore();
33
+ const saveCommentNode = useCallback((comment) => saveComment(comment, view, doc, state, modelMap), [doc, modelMap, state, view]);
34
+ const deleteCommentNode = useCallback((comment) => deleteComment(comment, view, doc, state), [doc, state, view]);
35
+ const saveTrackModel = useCallback((model) => {
36
+ if (model.objectType === ObjectTypes.CommentAnnotation) {
37
+ return saveCommentNode(model);
38
+ }
39
+ if (model._id) {
40
+ const currentModel = modelMap.get(model._id);
41
+ if (currentModel) {
42
+ modelMap.set(model._id, { ...currentModel, ...model });
43
+ }
44
+ else {
45
+ modelMap.set(model._id, model);
46
+ }
47
+ let foundInDoc = false;
48
+ if (view) {
49
+ doc.descendants((node, pos) => {
50
+ if (node.attrs.id === model._id) {
51
+ const decoder = new Decoder(modelMap, true); // as node ids are unique it will always occur just once (or never) so it's safe to keep in the loop
52
+ const newDoc = decoder.createArticleNode();
53
+ newDoc.descendants((newNode, pos) => {
54
+ if (newNode.attrs.id === node.attrs.id) {
55
+ setNodeAttrs(view.state, view.dispatch, node.attrs.id, {
56
+ ...newNode.attrs,
57
+ id: node.attrs.id,
58
+ });
59
+ }
60
+ });
61
+ foundInDoc = true;
62
+ }
63
+ });
64
+ }
65
+ if (!foundInDoc) {
66
+ if (model.objectType === ObjectTypes.Contributor) {
67
+ createContributorNode(model, view, doc, state);
68
+ }
69
+ else if (model.objectType === ObjectTypes.Affiliation) {
70
+ createAffiliationNode(model, view, doc, state);
71
+ }
72
+ else {
73
+ // ...that is if there is no node in the prosemirror doc for that id,
74
+ // that update final model.
75
+ // This is needed until we move all the data into prosemirror
76
+ saveModel(model);
77
+ }
78
+ }
79
+ }
80
+ return Promise.resolve(model);
81
+ },
82
+ // eslint-disable-next-line react-hooks/exhaustive-deps
83
+ [modelMap, saveModel, doc, view]);
84
+ const deleteTrackModel = useCallback((id) => {
85
+ if (modelMap.get(id)?.objectType === ObjectTypes.CommentAnnotation) {
86
+ return deleteCommentNode(modelMap.get(id));
87
+ }
88
+ if (modelMap.has(id)) {
89
+ doc.descendants((node, pos) => {
90
+ if (node.attrs.id === id) {
91
+ const { tr } = state;
92
+ tr.delete(pos, pos + node.nodeSize);
93
+ dispatch(tr);
94
+ }
95
+ });
96
+ }
97
+ else {
98
+ deleteModel(id);
99
+ }
100
+ return Promise.resolve(id);
101
+ },
102
+ // eslint-disable-next-line react-hooks/exhaustive-deps
103
+ [
104
+ modelMap,
105
+ deleteCommentNode,
106
+ doc,
107
+ state,
108
+ dispatch,
109
+ dispatchStore,
110
+ deleteModel,
111
+ ]);
112
+ const getTrackModel = useCallback((id) => modelMap.get(id), [modelMap]);
113
+ return {
114
+ saveTrackModel,
115
+ deleteTrackModel,
116
+ trackModelMap: modelMap,
117
+ getTrackModel,
118
+ };
119
+ };
120
+ export default useTrackedModelManagement;
121
+ //# sourceMappingURL=use-tracked-model-management.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-tracked-model-management.js","sourceRoot":"","sources":["../../../src/tracked-models/use-tracked-model-management.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAKL,WAAW,GACZ,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAEL,OAAO,EACP,MAAM,EAGN,MAAM,GACP,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,WAAW,GACZ,MAAM,YAAY,CAAA;AAEnB,MAAM,yBAAyB,GAAG,CAChC,GAAmB,EACnB,IAAsC,EACtC,KAAkB,EAClB,QAA0C,EAC1C,SAA4E,EAC5E,WAA4C,EAC5C,aAAiC,EACjC,EAAE;IACF,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE;QAC5B,MAAM,UAAU,GAAG,gBAAgB,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAA;QACjD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,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C,CACX,CAAA;IAED,OAAO;QACL,cAAc;QACd,gBAAgB;QAChB,aAAa,EAAE,QAAQ;QACvB,aAAa;KACd,CAAA;AACH,CAAC,CAAA;AAED,eAAe,yBAAyB,CAAA"}
@@ -1,2 +1,2 @@
1
1
  import { dispatch, GenericStore, state } from './Store';
2
- export declare const useStore: <T>(selector?: (r: state) => state | T) => [T, dispatch, () => state, (fn: (state: state, prev: state) => void) => () => void];
2
+ export declare const useStore: <T>(selector?: (r: state) => T | state) => [T, dispatch, () => state, (fn: (state: state, prev: state) => void) => () => void];
@@ -0,0 +1,13 @@
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
+ export declare const filterNodesWithTrackingData: (node: any) => any;
13
+ export declare const adaptTrackedData: (docJSONed: unknown) => {};
@@ -0,0 +1,19 @@
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 { Affiliation, CommentAnnotation, Contributor, Model } from '@manuscripts/json-schema';
13
+ import { Node as ProsemirrorNode } from 'prosemirror-model';
14
+ import { EditorState } from 'prosemirror-state';
15
+ import { EditorView } from 'prosemirror-view';
16
+ export declare const createContributorNode: (model: Partial<Contributor>, view: EditorView | undefined, doc: ProsemirrorNode, state: EditorState) => void;
17
+ export declare const createAffiliationNode: (model: Partial<Affiliation>, view: EditorView | undefined, doc: ProsemirrorNode, state: EditorState) => void;
18
+ export declare const saveComment: (comment: CommentAnnotation, view: EditorView | undefined, doc: ProsemirrorNode, state: EditorState, modelMap: Map<string, Model>) => Promise<Model>;
19
+ export declare const deleteComment: (comment: CommentAnnotation, view: EditorView | undefined, doc: ProsemirrorNode, state: EditorState) => Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manuscripts/article-editor",
3
- "version": "1.9.15",
3
+ "version": "1.9.16",
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",
@@ -36,13 +36,13 @@
36
36
  "@fontsource/pt-sans": "^4.5.11",
37
37
  "@fontsource/pt-serif": "^4.5.11",
38
38
  "@manuscripts/assets": "^0.6.4",
39
- "@manuscripts/body-editor": "1.6.20",
39
+ "@manuscripts/body-editor": "1.7.0",
40
40
  "@manuscripts/json-schema": "^2.2.2",
41
41
  "@manuscripts/library": "1.3.2",
42
- "@manuscripts/style-guide": "1.7.3",
42
+ "@manuscripts/style-guide": "1.7.4",
43
43
  "@manuscripts/title-editor": "^1.1.0",
44
44
  "@manuscripts/track-changes-plugin": "^1.7.5",
45
- "@manuscripts/transform": "2.0.4",
45
+ "@manuscripts/transform": "2.1.1",
46
46
  "@microsoft/fetch-event-source": "^2.0.1",
47
47
  "@reach/tabs": "^0.18.0",
48
48
  "autotrack": "^2.4.1",
@@ -1,94 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.ExpanderButton = void 0;
30
- /*!
31
- * 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.
32
- *
33
- * 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.
34
- *
35
- * The Original Code is manuscripts-frontend.
36
- *
37
- * The Original Developer is the Initial Developer. The Initial Developer of the Original Code is Atypon Systems LLC.
38
- *
39
- * All portions of the code written by Atypon Systems LLC are Copyright (c) 2019 Atypon Systems LLC. All Rights Reserved.
40
- */
41
- const style_guide_1 = require("@manuscripts/style-guide");
42
- const react_1 = __importStar(require("react"));
43
- const styled_components_1 = __importDefault(require("styled-components"));
44
- exports.ExpanderButton = (0, styled_components_1.default)(style_guide_1.IconButton).attrs(() => ({
45
- size: 20,
46
- defaultColor: true,
47
- })) `
48
- border: none;
49
- border-radius: 50%;
50
-
51
- &:focus,
52
- &:hover {
53
- &:not([disabled]) {
54
- background: ${(props) => props.theme.colors.background.fifth};
55
- }
56
- }
57
-
58
- svg circle {
59
- stroke: ${(props) => props.theme.colors.border.secondary};
60
- }
61
- `;
62
- const HeaderContainer = styled_components_1.default.header `
63
- padding: 0 64px;
64
- `;
65
- const Header = styled_components_1.default.div `
66
- font-family: 'PT Sans';
67
- font-size: ${(props) => props.theme.font.size.medium};
68
- line-height: ${(props) => props.theme.font.lineHeight.large};
69
- color: ${(props) => props.theme.colors.text.primary};
70
-
71
- ${exports.ExpanderButton} {
72
- display: none;
73
- }
74
-
75
- &:hover ${exports.ExpanderButton} {
76
- display: initial;
77
- }
78
- `;
79
- const AuthorsInlineViewContainer = (props) => {
80
- const [store, setStore] = (0, react_1.useState)();
81
- (0, react_1.useEffect)(() => {
82
- props.subscribe((store) => {
83
- setStore(store);
84
- });
85
- }, [props]);
86
- if (!store || !store.trackedAuthorsAndAffiliations) {
87
- return null;
88
- }
89
- return (react_1.default.createElement(HeaderContainer, null,
90
- react_1.default.createElement(Header, null,
91
- react_1.default.createElement(style_guide_1.AuthorsContainer, { authorData: store.trackedAuthorsAndAffiliations, startEditing: store.startEditing, showEditButton: props.showAuthorEditButton, disableEditButton: props.disableEditButton, selectAuthor: store.selectAuthor }))));
92
- };
93
- exports.default = AuthorsInlineViewContainer;
94
- //# sourceMappingURL=AuthorsInlineViewContainer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuthorsInlineViewContainer.js","sourceRoot":"","sources":["../../../../src/components/metadata/AuthorsInlineViewContainer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;GAUG;AACH,0DAAuE;AACvE,+CAAkD;AAClD,0EAAsC;AAIzB,QAAA,cAAc,GAAG,IAAA,2BAAM,EAAC,wBAAU,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IAC5D,IAAI,EAAE,EAAE;IACR,YAAY,EAAE,IAAI;CACnB,CAAC,CAAC,CAAA;;;;;;;oBAOiB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK;;;;;cAKpD,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS;;CAE3D,CAAA;AAED,MAAM,eAAe,GAAG,2BAAM,CAAC,MAAM,CAAA;;CAEpC,CAAA;AAED,MAAM,MAAM,GAAG,2BAAM,CAAC,GAAG,CAAA;;eAEV,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;WAClD,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;;IAEjD,sBAAc;;;;YAIN,sBAAc;;;CAGzB,CAAA;AAQD,MAAM,0BAA0B,GAAoB,CAAC,KAAK,EAAE,EAAE;IAC5D,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAA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