@manuscripts/body-editor 1.7.3 → 1.7.5

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 (43) hide show
  1. package/dist/cjs/assets.js +25 -1
  2. package/dist/cjs/configs/editor-plugins.js +2 -4
  3. package/dist/cjs/index.js +3 -1
  4. package/dist/cjs/lib/track-changes-utils.js +13 -4
  5. package/dist/cjs/plugins/comment_annotation.js +2 -1
  6. package/dist/cjs/plugins/highlight/findHighlightMarkers.js +1 -7
  7. package/dist/cjs/plugins/selected-suggestion-ui.js +129 -0
  8. package/dist/cjs/views/affiliation.js +2 -1
  9. package/dist/cjs/views/bibliography_element.js +23 -6
  10. package/dist/cjs/views/citation.js +4 -1
  11. package/dist/cjs/views/contributors.js +14 -3
  12. package/dist/cjs/views/cross_reference.js +4 -1
  13. package/dist/cjs/views/keyword.js +17 -7
  14. package/dist/es/assets.js +24 -0
  15. package/dist/es/configs/editor-plugins.js +2 -4
  16. package/dist/es/index.js +1 -0
  17. package/dist/es/lib/track-changes-utils.js +11 -3
  18. package/dist/es/plugins/comment_annotation.js +2 -1
  19. package/dist/es/plugins/highlight/findHighlightMarkers.js +2 -8
  20. package/dist/es/plugins/selected-suggestion-ui.js +126 -0
  21. package/dist/es/views/affiliation.js +2 -1
  22. package/dist/es/views/bibliography_element.js +22 -5
  23. package/dist/es/views/citation.js +4 -1
  24. package/dist/es/views/contributors.js +14 -3
  25. package/dist/es/views/cross_reference.js +4 -1
  26. package/dist/es/views/keyword.js +17 -7
  27. package/dist/types/assets.d.ts +1 -0
  28. package/dist/types/configs/editor-plugins.d.ts +1 -1
  29. package/dist/types/index.d.ts +1 -0
  30. package/dist/types/lib/track-changes-utils.d.ts +3 -1
  31. package/dist/types/plugins/{track-changes-ui.d.ts → selected-suggestion-ui.d.ts} +7 -5
  32. package/dist/types/views/affiliation.d.ts +0 -1
  33. package/dist/types/views/base_node_view.d.ts +1 -0
  34. package/dist/types/views/bibliography_element.d.ts +1 -0
  35. package/dist/types/views/contributors.d.ts +1 -1
  36. package/package.json +1 -1
  37. package/styles/AdvancedEditor.css +18 -3
  38. package/styles/Editor.css +2 -2
  39. package/dist/cjs/plugins/track-changes-ui.js +0 -104
  40. package/dist/cjs/plugins/tracking-mark.js +0 -123
  41. package/dist/es/plugins/track-changes-ui.js +0 -102
  42. package/dist/es/plugins/tracking-mark.js +0 -118
  43. package/dist/types/plugins/tracking-mark.d.ts +0 -7
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.commentIcon = exports.editIcon = void 0;
18
+ exports.editAttrsTrackingIcon = exports.commentIcon = exports.editIcon = void 0;
19
19
  exports.editIcon = `
20
20
  <svg
21
21
  width="14"
@@ -78,3 +78,27 @@ exports.commentIcon = `
78
78
  />
79
79
  </svg>
80
80
  `;
81
+ exports.editAttrsTrackingIcon = `
82
+ <svg
83
+ width="16"
84
+ height="16"
85
+ viewBox="0 0 16 16"
86
+ fill="none"
87
+ xmlns="http://www.w3.org/2000/svg"
88
+ >
89
+ <path
90
+ d="M12 2L14 4L9 9L6 10L7 7L12 2Z"
91
+ stroke="#353535"
92
+ stroke-width="1.5"
93
+ stroke-linecap="round"
94
+ stroke-linejoin="round"
95
+ />
96
+ <path
97
+ d="M13 10V11.5C13 12.328 12.328 13 11.5 13H4.5C3.672 13 3 12.328 3 11.5V4.5C3 3.672 3.672 3 4.5 3H6"
98
+ stroke="#353535"
99
+ stroke-width="1.5"
100
+ stroke-linecap="round"
101
+ stroke-linejoin="round"
102
+ />
103
+ </svg>
104
+ `;
@@ -36,10 +36,9 @@ const paragraphs_1 = __importDefault(require("../plugins/paragraphs"));
36
36
  const persist_1 = __importDefault(require("../plugins/persist"));
37
37
  const placeholder_1 = __importDefault(require("../plugins/placeholder"));
38
38
  const sections_1 = __importDefault(require("../plugins/sections"));
39
+ const selected_suggestion_ui_1 = __importDefault(require("../plugins/selected-suggestion-ui"));
39
40
  const tables_cursor_fix_1 = __importDefault(require("../plugins/tables-cursor-fix"));
40
41
  const toc_1 = __importDefault(require("../plugins/toc"));
41
- const track_changes_ui_1 = __importDefault(require("../plugins/track-changes-ui"));
42
- const tracking_mark_1 = __importDefault(require("../plugins/tracking-mark"));
43
42
  const rules_1 = __importDefault(require("../rules"));
44
43
  exports.default = (props) => {
45
44
  const plugins = props.plugins || [];
@@ -62,8 +61,7 @@ exports.default = (props) => {
62
61
  (0, placeholder_1.default)(),
63
62
  (0, prosemirror_tables_1.tableEditing)(),
64
63
  (0, highlight_1.default)(props),
65
- (0, track_changes_ui_1.default)(props),
66
- (0, tracking_mark_1.default)(),
64
+ (0, selected_suggestion_ui_1.default)(props),
67
65
  (0, footnotes_1.default)(),
68
66
  ];
69
67
  if (props.collabProvider) {
package/dist/cjs/index.js CHANGED
@@ -29,7 +29,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
29
29
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.isHighlightComment = exports.isThereSelector = exports.commentScroll = exports.PopperManager = exports.CollabProvider = exports.LevelSelector = exports.OutlineManuscript = exports.OutlineItemIcon = exports.ManuscriptOutline = void 0;
32
+ exports.SET_SUGGESTION_ID = exports.isHighlightComment = exports.isThereSelector = exports.commentScroll = exports.PopperManager = exports.CollabProvider = exports.LevelSelector = exports.OutlineManuscript = exports.OutlineItemIcon = exports.ManuscriptOutline = void 0;
33
33
  __exportStar(require("./citation-sources"), exports);
34
34
  __exportStar(require("./commands"), exports);
35
35
  var ManuscriptOutline_1 = require("./components/outline/ManuscriptOutline");
@@ -51,6 +51,8 @@ var comment_annotation_1 = require("./plugins/comment_annotation");
51
51
  Object.defineProperty(exports, "commentScroll", { enumerable: true, get: function () { return comment_annotation_1.commentScroll; } });
52
52
  Object.defineProperty(exports, "isThereSelector", { enumerable: true, get: function () { return comment_annotation_1.isThereSelector; } });
53
53
  Object.defineProperty(exports, "isHighlightComment", { enumerable: true, get: function () { return comment_annotation_1.isHighlightComment; } });
54
+ var selected_suggestion_ui_1 = require("./plugins/selected-suggestion-ui");
55
+ Object.defineProperty(exports, "SET_SUGGESTION_ID", { enumerable: true, get: function () { return selected_suggestion_ui_1.SET_SUGGESTION_ID; } });
54
56
  __exportStar(require("./lib/utils"), exports);
55
57
  __exportStar(require("./lib/track-changes-utils"), exports);
56
58
  __exportStar(require("./useEditor"), exports);
@@ -15,7 +15,8 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.getActualAttrs = exports.isTracked = exports.getChangeClasses = exports.isPendingSetAttrs = exports.isPending = exports.isPendingInsert = exports.isDeleted = exports.isRejectedInsert = void 0;
18
+ exports.getAttrsTrackingButton = exports.getActualAttrs = exports.isTracked = exports.getChangeClasses = exports.isPendingSetAttrs = exports.isPending = exports.isPendingInsert = exports.isDeleted = exports.isRejectedInsert = void 0;
19
+ const assets_1 = require("../assets");
19
20
  function isRejectedInsert(node) {
20
21
  if (node.attrs.dataTracked) {
21
22
  const changes = node.attrs.dataTracked;
@@ -56,10 +57,10 @@ function isPendingSetAttrs(node) {
56
57
  return false;
57
58
  }
58
59
  exports.isPendingSetAttrs = isPendingSetAttrs;
59
- function getChangeClasses(node) {
60
+ function getChangeClasses(dataTracked) {
60
61
  const classes = [];
61
- if (node.attrs.dataTracked) {
62
- const changes = node.attrs.dataTracked;
62
+ if (dataTracked) {
63
+ const changes = dataTracked;
63
64
  const operationClasses = new Map([
64
65
  ['insert', 'inserted'],
65
66
  ['delete', 'deleted'],
@@ -90,3 +91,11 @@ function getActualAttrs(node) {
90
91
  return attrs;
91
92
  }
92
93
  exports.getActualAttrs = getActualAttrs;
94
+ const getAttrsTrackingButton = (changeID) => {
95
+ const el = document.createElement('button');
96
+ el.className = 'attrs-popper-button';
97
+ el.value = changeID;
98
+ el.innerHTML = assets_1.editAttrsTrackingIcon;
99
+ return el;
100
+ };
101
+ exports.getAttrsTrackingButton = getAttrsTrackingButton;
@@ -130,7 +130,8 @@ const getCommentIcon = (comment, setSelectedComment) => () => {
130
130
  element.classList.add(location === 'point' ? 'point-comment' : 'inline-citation');
131
131
  }
132
132
  element.classList.add('block-comment-button', elementClass);
133
- element.onclick = () => {
133
+ element.onclick = (e) => {
134
+ e.stopPropagation();
134
135
  setSelectedComment(commentId);
135
136
  (0, exports.commentScroll)(commentId, 'inspector');
136
137
  };
@@ -5,13 +5,7 @@ const transform_1 = require("@manuscripts/transform");
5
5
  function findHighlightMarkers(doc) {
6
6
  const markers = [];
7
7
  let current;
8
- const commentIds = [];
9
8
  doc.descendants((node, pos) => {
10
- if (node.type.name === transform_1.schema.nodes.comments.name) {
11
- node.content.forEach(({ attrs }) => {
12
- commentIds.push(attrs.id);
13
- });
14
- }
15
9
  if ((0, transform_1.isHighlightMarkerNode)(node)) {
16
10
  const { position, tid, id } = node.attrs;
17
11
  if (position === 'start') {
@@ -27,6 +21,6 @@ function findHighlightMarkers(doc) {
27
21
  }
28
22
  }
29
23
  });
30
- return markers.filter((marker) => commentIds.includes(marker.id));
24
+ return markers;
31
25
  }
32
26
  exports.findHighlightMarkers = findHighlightMarkers;
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.selectedSuggestionKey = exports.SET_SUGGESTION_ID = void 0;
19
+ const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
20
+ const lodash_1 = require("lodash");
21
+ const prosemirror_state_1 = require("prosemirror-state");
22
+ const prosemirror_view_1 = require("prosemirror-view");
23
+ class SuggestionView {
24
+ constructor(view) {
25
+ this.listener = (e) => {
26
+ const changeId = e.currentTarget.getAttribute('data-track-id');
27
+ this.view.dispatch(this.view.state.tr.setMeta(exports.SET_SUGGESTION_ID, changeId));
28
+ };
29
+ this.view = view;
30
+ this.addEventListener(view);
31
+ this.update(view, undefined);
32
+ }
33
+ update(view, prevState) {
34
+ var _a, _b;
35
+ this.view = view;
36
+ if (!prevState) {
37
+ return;
38
+ }
39
+ const oldChanges = ((_a = track_changes_plugin_1.trackChangesPluginKey.getState(prevState)) === null || _a === void 0 ? void 0 : _a.changeSet.changes) || [];
40
+ const newChangeSet = (_b = track_changes_plugin_1.trackChangesPluginKey.getState(view.state)) === null || _b === void 0 ? void 0 : _b.changeSet;
41
+ if (newChangeSet && !(0, lodash_1.isEqual)(oldChanges, newChangeSet.changes)) {
42
+ this.addEventListener(view);
43
+ oldChanges.map((change) => {
44
+ var _a;
45
+ if (!newChangeSet.get(change.id) ||
46
+ ((_a = newChangeSet.get(change.id)) === null || _a === void 0 ? void 0 : _a.dataTracked.status) === 'rejected') {
47
+ const dom = view.dom.querySelector(`[data-track-id="${change.id}"]`);
48
+ dom === null || dom === void 0 ? void 0 : dom.removeEventListener('click', this.listener);
49
+ }
50
+ });
51
+ }
52
+ }
53
+ destroy() {
54
+ this.view.dom
55
+ .querySelectorAll('[data-track-status="pending"], [data-track-status="accepted"]')
56
+ .forEach((dom) => {
57
+ var _a, _b;
58
+ if ((_b = (_a = dom.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.classList.contains('keyword')) {
59
+ return;
60
+ }
61
+ dom.removeEventListener('click', this.listener);
62
+ });
63
+ }
64
+ addEventListener(view) {
65
+ view.dom
66
+ .querySelectorAll('[data-track-status="pending"], [data-track-status="accepted"]')
67
+ .forEach((dom) => {
68
+ var _a, _b;
69
+ if ((_b = (_a = dom.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.classList.contains('keyword')) {
70
+ return;
71
+ }
72
+ dom.addEventListener('click', this.listener);
73
+ });
74
+ }
75
+ }
76
+ const getTrackChangesData = (node) => {
77
+ var _a;
78
+ const trackChangesMark = node.marks.find((mark) => (mark.type.name === 'tracked_insert' ||
79
+ mark.type.name === 'tracked_delete') &&
80
+ mark.attrs.dataTracked);
81
+ return (_a = trackChangesMark === null || trackChangesMark === void 0 ? void 0 : trackChangesMark.attrs) === null || _a === void 0 ? void 0 : _a.dataTracked;
82
+ };
83
+ exports.SET_SUGGESTION_ID = 'SET_SELECTED_SUGGESTION_ID';
84
+ const CLEAR_SUGGESTION_ID = 'CLEAR_SUGGESTION_ID';
85
+ exports.selectedSuggestionKey = new prosemirror_state_1.PluginKey('selected_suggestion');
86
+ exports.default = (props) => new prosemirror_state_1.Plugin({
87
+ key: exports.selectedSuggestionKey,
88
+ view: (view) => new SuggestionView(view),
89
+ state: {
90
+ init: () => prosemirror_view_1.DecorationSet.empty,
91
+ apply: (tr, value, _, state) => {
92
+ const suggestionId = tr.getMeta(exports.SET_SUGGESTION_ID);
93
+ if (suggestionId) {
94
+ return buildSelectedSuggestionDecoration(suggestionId, state, props);
95
+ }
96
+ if (tr.getMeta(CLEAR_SUGGESTION_ID) ||
97
+ tr.getMeta('track-changes-refresh-changes')) {
98
+ props.setEditorSelectedSuggestion(undefined);
99
+ return prosemirror_view_1.DecorationSet.empty;
100
+ }
101
+ return value;
102
+ },
103
+ },
104
+ props: {
105
+ handleClick(view, pos) {
106
+ const nodeClicked = view.state.doc.nodeAt(pos);
107
+ const trackChangesData = nodeClicked && getTrackChangesData(nodeClicked);
108
+ if (!trackChangesData) {
109
+ view.dispatch(view.state.tr.setMeta(CLEAR_SUGGESTION_ID, true));
110
+ props.setEditorSelectedSuggestion(undefined);
111
+ }
112
+ },
113
+ decorations: (state) => exports.selectedSuggestionKey.getState(state),
114
+ },
115
+ });
116
+ const buildSelectedSuggestionDecoration = (suggestionId, state, props) => {
117
+ var _a;
118
+ const change = (_a = track_changes_plugin_1.trackChangesPluginKey
119
+ .getState(state)) === null || _a === void 0 ? void 0 : _a.changeSet.get(suggestionId);
120
+ const decorations = [];
121
+ if (change) {
122
+ const decoration = change.type === 'text-change' ? prosemirror_view_1.Decoration.inline : prosemirror_view_1.Decoration.node;
123
+ decorations.push(decoration(change.from, change.to, {
124
+ class: 'selected-suggestion',
125
+ }));
126
+ props.setEditorSelectedSuggestion(change.id);
127
+ }
128
+ return prosemirror_view_1.DecorationSet.create(state.doc, decorations);
129
+ };
@@ -39,10 +39,12 @@ class AffiliationView extends base_node_view_1.BaseNodeView {
39
39
  this.dom.setAttribute('style', 'order: ' + (order || (pluginState === null || pluginState === void 0 ? void 0 : pluginState.affiliations.length) + 1));
40
40
  }
41
41
  if ((_a = attrs.dataTracked) === null || _a === void 0 ? void 0 : _a.length) {
42
+ this.dom.setAttribute('data-track-id', attrs.dataTracked[0].id);
42
43
  this.dom.setAttribute('data-track-status', attrs.dataTracked[0].status);
43
44
  this.dom.setAttribute('data-track-op', attrs.dataTracked[0].operation);
44
45
  }
45
46
  else {
47
+ this.dom.removeAttribute('data-track-id');
46
48
  this.dom.removeAttribute('data-track-status');
47
49
  this.dom.removeAttribute('data-track-type');
48
50
  }
@@ -54,7 +56,6 @@ class AffiliationView extends base_node_view_1.BaseNodeView {
54
56
  this.updateContents();
55
57
  };
56
58
  this.ignoreMutation = () => true;
57
- this.stopEvent = () => true;
58
59
  this.formatAddress = (affiliation) => {
59
60
  const { department, institution, addressLine1, city, county, country, postCode, } = affiliation;
60
61
  return [
@@ -32,9 +32,10 @@ const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
32
32
  const transform_1 = require("@manuscripts/transform");
33
33
  const assets_1 = require("../assets");
34
34
  const dompurify_1 = require("../lib/dompurify");
35
+ const track_changes_utils_1 = require("../lib/track-changes-utils");
35
36
  const bibliography_1 = require("../plugins/bibliography");
36
37
  const comment_annotation_1 = require("../plugins/comment_annotation");
37
- const tracking_mark_1 = require("../plugins/tracking-mark");
38
+ const selected_suggestion_ui_1 = require("../plugins/selected-suggestion-ui");
38
39
  const block_view_1 = __importDefault(require("./block_view"));
39
40
  const creators_1 = require("./creators");
40
41
  const ReactSubView_1 = __importDefault(require("./ReactSubView"));
@@ -61,11 +62,13 @@ class BibliographyElementBlockView extends block_view_1.default {
61
62
  this.updateContents = () => __awaiter(this, void 0, void 0, function* () {
62
63
  const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
63
64
  const commentsDecorationSet = comment_annotation_1.commentAnnotation.getState(this.view.state);
65
+ const selectedSuggestion = selected_suggestion_ui_1.selectedSuggestionKey.getState(this.view.state);
64
66
  const commentElementMap = new Map();
65
67
  const dataTrackedMap = new Map();
68
+ let selectedBibItemSuggestion;
66
69
  this.node.descendants((node, pos) => {
70
+ const nodePosition = this.getPos() + pos + 2;
67
71
  if (commentsDecorationSet) {
68
- const nodePosition = this.getPos() + pos + 2;
69
72
  const commentWidget = commentsDecorationSet.find(nodePosition, nodePosition);
70
73
  if (commentWidget.length) {
71
74
  const commentElement = commentWidget[0].type.toDOM();
@@ -77,6 +80,10 @@ class BibliographyElementBlockView extends block_view_1.default {
77
80
  const lastChange = dataTracked[dataTracked.length - 1];
78
81
  dataTrackedMap.set(node.attrs.id, lastChange);
79
82
  }
83
+ if ((dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.length) &&
84
+ (selectedSuggestion === null || selectedSuggestion === void 0 ? void 0 : selectedSuggestion.find(nodePosition, nodePosition + node.nodeSize).length)) {
85
+ selectedBibItemSuggestion = node.attrs.id;
86
+ }
80
87
  });
81
88
  const can = this.props.getCapabilities();
82
89
  const wrapper = document.createElement('div');
@@ -114,13 +121,16 @@ class BibliographyElementBlockView extends block_view_1.default {
114
121
  }
115
122
  const dataTracked = dataTrackedMap.get(element.id);
116
123
  if (dataTracked) {
117
- element.classList.add('attrs-track-mark');
118
- const decoration = (0, tracking_mark_1.getMarkDecoration)(dataTracked);
119
- decoration.style && element.setAttribute('style', decoration.style);
124
+ element.classList.add('attrs-track-mark', ...(0, track_changes_utils_1.getChangeClasses)([dataTracked]));
120
125
  if (dataTracked.status === track_changes_plugin_1.CHANGE_STATUS.pending &&
121
126
  dataTracked.operation === track_changes_plugin_1.CHANGE_OPERATION.set_node_attributes) {
122
- element.appendChild((0, tracking_mark_1.getAttrsTrackingButton)(dataTracked.id));
127
+ element.appendChild((0, track_changes_utils_1.getAttrsTrackingButton)(dataTracked.id));
123
128
  }
129
+ this.addClickListenerToBibItem(element, dataTracked);
130
+ }
131
+ if (selectedBibItemSuggestion &&
132
+ selectedBibItemSuggestion === element.id) {
133
+ element.classList.add('selected-suggestion');
124
134
  }
125
135
  wrapper.append(element);
126
136
  }
@@ -146,6 +156,13 @@ class BibliographyElementBlockView extends block_view_1.default {
146
156
  this.handleDelete = (item) => {
147
157
  return this.deleteNode(item._id);
148
158
  };
159
+ this.addClickListenerToBibItem = (element, dataTracked) => {
160
+ if (dataTracked.status !== track_changes_plugin_1.CHANGE_STATUS.rejected) {
161
+ element.addEventListener('click', () => {
162
+ this.view.dispatch(this.view.state.tr.setMeta(selected_suggestion_ui_1.SET_SUGGESTION_ID, dataTracked.id));
163
+ });
164
+ }
165
+ };
149
166
  }
150
167
  }
151
168
  exports.BibliographyElementBlockView = BibliographyElementBlockView;
@@ -47,7 +47,10 @@ class CitationView extends base_node_view_1.BaseNodeView {
47
47
  this.updateContents = () => {
48
48
  const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
49
49
  const citation = this.getCitation();
50
- const classes = ['citation', ...(0, track_changes_utils_1.getChangeClasses)(this.node)];
50
+ const classes = [
51
+ 'citation',
52
+ ...(0, track_changes_utils_1.getChangeClasses)(this.node.attrs.dataTracked),
53
+ ];
51
54
  const element = document.createElement('span');
52
55
  element.className = classes.join(' ');
53
56
  const text = bib.renderedCitations.get(citation._id);
@@ -8,6 +8,7 @@ const style_guide_1 = require("@manuscripts/style-guide");
8
8
  const transform_1 = require("@manuscripts/transform");
9
9
  const track_changes_utils_1 = require("../lib/track-changes-utils");
10
10
  const affiliations_1 = require("../plugins/affiliations");
11
+ const selected_suggestion_ui_1 = require("../plugins/selected-suggestion-ui");
11
12
  const block_view_1 = __importDefault(require("./block_view"));
12
13
  const creators_1 = require("./creators");
13
14
  const ReactSubView_1 = __importDefault(require("./ReactSubView"));
@@ -31,12 +32,17 @@ class ContributorsView extends block_view_1.default {
31
32
  };
32
33
  this.buildAuthors = () => {
33
34
  var _a;
35
+ const selectedSuggestion = selected_suggestion_ui_1.selectedSuggestionKey.getState(this.view.state);
36
+ let selectedAuthor;
34
37
  const authors = [];
35
38
  const authorsWrapper = document.createElement('div');
36
39
  authorsWrapper.classList.add('contributors-list');
37
- (_a = this.node.content) === null || _a === void 0 ? void 0 : _a.forEach((node) => {
40
+ (_a = this.node.content) === null || _a === void 0 ? void 0 : _a.forEach((node, offset) => {
38
41
  if ((0, transform_1.isContributorNode)(node)) {
39
42
  authors.push(node);
43
+ if (selectedSuggestion === null || selectedSuggestion === void 0 ? void 0 : selectedSuggestion.find(this.getPos() + offset + 2, this.getPos() + offset + node.nodeSize + 2).length) {
44
+ selectedAuthor = node.attrs.id;
45
+ }
40
46
  }
41
47
  });
42
48
  authors
@@ -46,11 +52,11 @@ class ContributorsView extends block_view_1.default {
46
52
  return;
47
53
  }
48
54
  const jointAuthors = this.isJointFirstAuthor(authors, i);
49
- authorsWrapper.appendChild(this.buildAuthor(author, jointAuthors));
55
+ authorsWrapper.appendChild(this.buildAuthor(author, jointAuthors, selectedAuthor));
50
56
  });
51
57
  this.container.appendChild(authorsWrapper);
52
58
  };
53
- this.buildAuthor = (node, isJointFirstAuthor) => {
59
+ this.buildAuthor = (node, isJointFirstAuthor, selectedAuthor) => {
54
60
  var _a;
55
61
  const pluginState = affiliations_1.affiliationsKey.getState(this.view.state);
56
62
  const attrs = node.attrs;
@@ -60,10 +66,12 @@ class ContributorsView extends block_view_1.default {
60
66
  container.setAttribute('id', attrs.id);
61
67
  container.setAttribute('contenteditable', 'false');
62
68
  if ((_a = attrs.dataTracked) === null || _a === void 0 ? void 0 : _a.length) {
69
+ container.setAttribute('data-track-id', attrs.dataTracked[0].id);
63
70
  container.setAttribute('data-track-status', attrs.dataTracked[0].status);
64
71
  container.setAttribute('data-track-op', attrs.dataTracked[0].operation);
65
72
  }
66
73
  else {
74
+ container.removeAttribute('data-track-id');
67
75
  container.removeAttribute('data-track-status');
68
76
  container.removeAttribute('data-track-type');
69
77
  }
@@ -100,6 +108,9 @@ class ContributorsView extends block_view_1.default {
100
108
  if (displayAttr.isCorresponding) {
101
109
  container.appendChild(this.createNote('*', 'Corresponding author'));
102
110
  }
111
+ if (selectedAuthor && selectedAuthor === attrs.id) {
112
+ container.classList.add('selected-suggestion');
113
+ }
103
114
  return container;
104
115
  };
105
116
  this.initials = (given) => given
@@ -36,7 +36,10 @@ class CrossReferenceView extends base_node_view_1.BaseNodeView {
36
36
  });
37
37
  };
38
38
  this.updateContents = () => {
39
- const nodeClasses = ['cross-reference', ...(0, track_changes_utils_1.getChangeClasses)(this.node)];
39
+ const nodeClasses = [
40
+ 'cross-reference',
41
+ ...(0, track_changes_utils_1.getChangeClasses)(this.node.attrs.dataTracked),
42
+ ];
40
43
  this.dom.className = nodeClasses.join(' ');
41
44
  this.dom.textContent = this.node.attrs.customLabel || this.node.attrs.label;
42
45
  this.dom.addEventListener('click', this.handleClick);
@@ -45,10 +45,14 @@ class KeywordView extends base_node_view_1.BaseNodeView {
45
45
  this.contentDOM = document.createElement('span');
46
46
  };
47
47
  this.updateContents = () => {
48
- const keyword = document.createElement('span');
49
- const classes = ['keyword', ...(0, track_changes_utils_1.getChangeClasses)(this.node)];
50
- keyword.classList.add(...classes);
51
- keyword.appendChild(this.contentDOM);
48
+ var _a;
49
+ const classes = [
50
+ 'keyword',
51
+ ...(0, track_changes_utils_1.getChangeClasses)(this.node.attrs.dataTracked),
52
+ ];
53
+ this.dom.className = classes.join(' ');
54
+ this.dom.innerHTML = '';
55
+ this.dom.appendChild(this.contentDOM);
52
56
  const can = this.props.getCapabilities();
53
57
  if (can.editArticle) {
54
58
  const svg = new DOMParser()
@@ -56,10 +60,16 @@ class KeywordView extends base_node_view_1.BaseNodeView {
56
60
  .querySelector('svg');
57
61
  svg.classList.add('delete-keyword');
58
62
  svg.addEventListener('click', this.showConfirmationDialog);
59
- keyword.appendChild(svg);
63
+ this.dom.appendChild(svg);
64
+ }
65
+ if ((_a = this.node.attrs.dataTracked) === null || _a === void 0 ? void 0 : _a.length) {
66
+ this.dom.setAttribute('data-track-id', this.node.attrs.dataTracked[0].id);
67
+ this.dom.setAttribute('data-track-status', this.node.attrs.dataTracked[0].status);
68
+ }
69
+ else {
70
+ this.dom.removeAttribute('data-track-id');
71
+ this.dom.removeAttribute('data-track-status');
60
72
  }
61
- this.dom.innerHTML = '';
62
- this.dom.appendChild(keyword);
63
73
  };
64
74
  this.showConfirmationDialog = () => {
65
75
  var _a;
package/dist/es/assets.js CHANGED
@@ -75,3 +75,27 @@ export const commentIcon = `
75
75
  />
76
76
  </svg>
77
77
  `;
78
+ export const editAttrsTrackingIcon = `
79
+ <svg
80
+ width="16"
81
+ height="16"
82
+ viewBox="0 0 16 16"
83
+ fill="none"
84
+ xmlns="http://www.w3.org/2000/svg"
85
+ >
86
+ <path
87
+ d="M12 2L14 4L9 9L6 10L7 7L12 2Z"
88
+ stroke="#353535"
89
+ stroke-width="1.5"
90
+ stroke-linecap="round"
91
+ stroke-linejoin="round"
92
+ />
93
+ <path
94
+ d="M13 10V11.5C13 12.328 12.328 13 11.5 13H4.5C3.672 13 3 12.328 3 11.5V4.5C3 3.672 3.672 3 4.5 3H6"
95
+ stroke="#353535"
96
+ stroke-width="1.5"
97
+ stroke-linecap="round"
98
+ stroke-linejoin="round"
99
+ />
100
+ </svg>
101
+ `;
@@ -31,10 +31,9 @@ import paragraphs from '../plugins/paragraphs';
31
31
  import persist from '../plugins/persist';
32
32
  import placeholder from '../plugins/placeholder';
33
33
  import sections from '../plugins/sections';
34
+ import selected_suggestion_ui from '../plugins/selected-suggestion-ui';
34
35
  import table_editing_fix from '../plugins/tables-cursor-fix';
35
36
  import toc from '../plugins/toc';
36
- import track_changes_ui from '../plugins/track-changes-ui';
37
- import tracking_mark from '../plugins/tracking-mark';
38
37
  import rules from '../rules';
39
38
  export default (props) => {
40
39
  const plugins = props.plugins || [];
@@ -57,8 +56,7 @@ export default (props) => {
57
56
  placeholder(),
58
57
  tableEditing(),
59
58
  highlights(props),
60
- track_changes_ui(props),
61
- tracking_mark(),
59
+ selected_suggestion_ui(props),
62
60
  footnotes(),
63
61
  ];
64
62
  if (props.collabProvider) {
package/dist/es/index.js CHANGED
@@ -25,6 +25,7 @@ export { PopperManager } from './lib/popper';
25
25
  export * from './toolbar';
26
26
  export * from './plugins/highlight';
27
27
  export { commentScroll, isThereSelector, isHighlightComment, } from './plugins/comment_annotation';
28
+ export { SET_SUGGESTION_ID } from './plugins/selected-suggestion-ui';
28
29
  export * from './lib/utils';
29
30
  export * from './lib/track-changes-utils';
30
31
  export * from './useEditor';
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { editAttrsTrackingIcon } from '../assets';
16
17
  export function isRejectedInsert(node) {
17
18
  if (node.attrs.dataTracked) {
18
19
  const changes = node.attrs.dataTracked;
@@ -48,10 +49,10 @@ export function isPendingSetAttrs(node) {
48
49
  }
49
50
  return false;
50
51
  }
51
- export function getChangeClasses(node) {
52
+ export function getChangeClasses(dataTracked) {
52
53
  const classes = [];
53
- if (node.attrs.dataTracked) {
54
- const changes = node.attrs.dataTracked;
54
+ if (dataTracked) {
55
+ const changes = dataTracked;
55
56
  const operationClasses = new Map([
56
57
  ['insert', 'inserted'],
57
58
  ['delete', 'deleted'],
@@ -79,3 +80,10 @@ export function getActualAttrs(node) {
79
80
  }
80
81
  return attrs;
81
82
  }
83
+ export const getAttrsTrackingButton = (changeID) => {
84
+ const el = document.createElement('button');
85
+ el.className = 'attrs-popper-button';
86
+ el.value = changeID;
87
+ el.innerHTML = editAttrsTrackingIcon;
88
+ return el;
89
+ };
@@ -124,7 +124,8 @@ const getCommentIcon = (comment, setSelectedComment) => () => {
124
124
  element.classList.add(location === 'point' ? 'point-comment' : 'inline-citation');
125
125
  }
126
126
  element.classList.add('block-comment-button', elementClass);
127
- element.onclick = () => {
127
+ element.onclick = (e) => {
128
+ e.stopPropagation();
128
129
  setSelectedComment(commentId);
129
130
  commentScroll(commentId, 'inspector');
130
131
  };
@@ -1,14 +1,8 @@
1
- import { isHighlightMarkerNode, schema } from '@manuscripts/transform';
1
+ import { isHighlightMarkerNode } from '@manuscripts/transform';
2
2
  export function findHighlightMarkers(doc) {
3
3
  const markers = [];
4
4
  let current;
5
- const commentIds = [];
6
5
  doc.descendants((node, pos) => {
7
- if (node.type.name === schema.nodes.comments.name) {
8
- node.content.forEach(({ attrs }) => {
9
- commentIds.push(attrs.id);
10
- });
11
- }
12
6
  if (isHighlightMarkerNode(node)) {
13
7
  const { position, tid, id } = node.attrs;
14
8
  if (position === 'start') {
@@ -24,5 +18,5 @@ export function findHighlightMarkers(doc) {
24
18
  }
25
19
  }
26
20
  });
27
- return markers.filter((marker) => commentIds.includes(marker.id));
21
+ return markers;
28
22
  }