@manuscripts/body-editor 1.7.25-LEAN-3368-0 → 1.7.25

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.
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.selectedSuggestionKey = exports.CLEAR_SUGGESTION_ID = exports.SET_SUGGESTION_ID = void 0;
18
+ exports.selectedSuggestionKey = exports.SET_SUGGESTION_ID = void 0;
19
19
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
20
20
  const lodash_1 = require("lodash");
21
21
  const prosemirror_state_1 = require("prosemirror-state");
@@ -81,7 +81,7 @@ const getTrackChangesData = (node) => {
81
81
  return (_a = trackChangesMark === null || trackChangesMark === void 0 ? void 0 : trackChangesMark.attrs) === null || _a === void 0 ? void 0 : _a.dataTracked;
82
82
  };
83
83
  exports.SET_SUGGESTION_ID = 'SET_SELECTED_SUGGESTION_ID';
84
- exports.CLEAR_SUGGESTION_ID = 'CLEAR_SUGGESTION_ID';
84
+ const CLEAR_SUGGESTION_ID = 'CLEAR_SUGGESTION_ID';
85
85
  exports.selectedSuggestionKey = new prosemirror_state_1.PluginKey('selected_suggestion');
86
86
  exports.default = (props) => new prosemirror_state_1.Plugin({
87
87
  key: exports.selectedSuggestionKey,
@@ -93,7 +93,7 @@ exports.default = (props) => new prosemirror_state_1.Plugin({
93
93
  if (suggestionId) {
94
94
  return buildSelectedSuggestionDecoration(suggestionId, state, props);
95
95
  }
96
- if (tr.getMeta(exports.CLEAR_SUGGESTION_ID)) {
96
+ if (tr.getMeta(CLEAR_SUGGESTION_ID)) {
97
97
  props.setEditorSelectedSuggestion(undefined);
98
98
  return prosemirror_view_1.DecorationSet.empty;
99
99
  }
@@ -105,7 +105,7 @@ exports.default = (props) => new prosemirror_state_1.Plugin({
105
105
  const nodeClicked = view.state.doc.nodeAt(pos);
106
106
  const trackChangesData = nodeClicked && getTrackChangesData(nodeClicked);
107
107
  if (!trackChangesData) {
108
- view.dispatch(view.state.tr.setMeta(exports.CLEAR_SUGGESTION_ID, true));
108
+ view.dispatch(view.state.tr.setMeta(CLEAR_SUGGESTION_ID, true));
109
109
  props.setEditorSelectedSuggestion(undefined);
110
110
  }
111
111
  },
@@ -28,9 +28,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.BibliographyElementBlockView = void 0;
31
- const style_guide_1 = require("@manuscripts/style-guide");
32
31
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
33
32
  const transform_1 = require("@manuscripts/transform");
33
+ const assets_1 = require("../assets");
34
34
  const dompurify_1 = require("../lib/dompurify");
35
35
  const track_changes_utils_1 = require("../lib/track-changes-utils");
36
36
  const view_1 = require("../lib/view");
@@ -45,9 +45,8 @@ class BibliographyElementBlockView extends block_view_1.default {
45
45
  constructor() {
46
46
  super(...arguments);
47
47
  this.decoder = new transform_1.Decoder(new Map());
48
- this.clickedElementId = null;
48
+ this.gutterButtons = () => [];
49
49
  this.showPopper = (id) => {
50
- this.props.popper.destroy();
51
50
  const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
52
51
  const componentProps = {
53
52
  items: Array.from(bib.bibliographyItems.values()),
@@ -61,52 +60,6 @@ class BibliographyElementBlockView extends block_view_1.default {
61
60
  };
62
61
  this.stopEvent = () => true;
63
62
  this.ignoreMutation = () => true;
64
- this.handleEdit = (citationId) => {
65
- this.showPopper(citationId);
66
- };
67
- this.handleComment = (citationId) => {
68
- this.props.setComment((0, transform_1.buildComment)(citationId));
69
- };
70
- this.showContextMenu = (elementId) => {
71
- this.props.popper.destroy();
72
- this.clickedElementId = null;
73
- const can = this.props.getCapabilities();
74
- const element = document.getElementById(elementId);
75
- const componentProps = {
76
- actions: [],
77
- };
78
- if (can.editCitationsAndRefs) {
79
- componentProps.actions.push({
80
- label: 'Edit',
81
- action: () => this.handleEdit(elementId),
82
- icon: 'EditIcon',
83
- });
84
- }
85
- componentProps.actions.push({
86
- label: 'Comment',
87
- action: () => this.handleComment(elementId),
88
- icon: 'AddComment',
89
- });
90
- this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
91
- this.props.popper.show(element, this.contextMenu, 'right-start');
92
- };
93
- this.onClickHandler = (elementId, dataTracked) => {
94
- var _a;
95
- this.clickedElementId = elementId;
96
- const isSelectedSuggestion = !!((_a = selected_suggestion_ui_1.selectedSuggestionKey
97
- .getState(this.view.state)) === null || _a === void 0 ? void 0 : _a.find(this.getPos(), this.getPos() + this.node.nodeSize).length);
98
- if (dataTracked && dataTracked.status !== track_changes_plugin_1.CHANGE_STATUS.rejected) {
99
- this.view.dispatch(this.view.state.tr.setMeta(selected_suggestion_ui_1.SET_SUGGESTION_ID, dataTracked.id));
100
- }
101
- else {
102
- if (isSelectedSuggestion) {
103
- this.view.dispatch(this.view.state.tr.setMeta(selected_suggestion_ui_1.CLEAR_SUGGESTION_ID, true));
104
- }
105
- else {
106
- this.showContextMenu(elementId);
107
- }
108
- }
109
- };
110
63
  this.updateContents = () => __awaiter(this, void 0, void 0, function* () {
111
64
  const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
112
65
  const commentsDecorationSet = comment_annotation_1.commentAnnotation.getState(this.view.state);
@@ -141,6 +94,28 @@ class BibliographyElementBlockView extends block_view_1.default {
141
94
  const id = meta.entry_ids[i];
142
95
  const fragment = bibliography[i];
143
96
  const element = (0, dompurify_1.sanitize)(`<div id="${id}" class="bib-item"><div class="csl-bib-body">${fragment}</div></div>`).firstElementChild;
97
+ const doubleButton = document.createElement('div');
98
+ const editButton = document.createElement('button');
99
+ const commentButton = document.createElement('button');
100
+ doubleButton.className = 'bibliography-double-button';
101
+ editButton.className = 'bibliography-edit-button';
102
+ commentButton.className = 'bibliography-comment-button';
103
+ commentButton.addEventListener('click', (e) => {
104
+ e.preventDefault();
105
+ this.props.setComment((0, transform_1.buildComment)(element.id));
106
+ });
107
+ editButton.addEventListener('click', (e) => {
108
+ e.preventDefault();
109
+ this.showPopper(element.id);
110
+ });
111
+ editButton.innerHTML = assets_1.editIcon;
112
+ commentButton.innerHTML = assets_1.commentIcon;
113
+ doubleButton.append(editButton, commentButton);
114
+ if (can.seeReferencesButtons &&
115
+ !element.querySelector('.bibliography-double-button')) {
116
+ element.appendChild(doubleButton);
117
+ }
118
+ editButton.disabled = !can.editCitationsAndRefs;
144
119
  const commentElement = commentElementMap.get(element.id);
145
120
  if (commentElement) {
146
121
  element.appendChild(commentElement);
@@ -148,14 +123,16 @@ class BibliographyElementBlockView extends block_view_1.default {
148
123
  const dataTracked = dataTrackedMap.get(element.id);
149
124
  if (dataTracked) {
150
125
  element.classList.add('attrs-track-mark', ...(0, track_changes_utils_1.getChangeClasses)([dataTracked]));
126
+ if (dataTracked.status === track_changes_plugin_1.CHANGE_STATUS.pending &&
127
+ dataTracked.operation === track_changes_plugin_1.CHANGE_OPERATION.set_node_attributes) {
128
+ element.appendChild((0, track_changes_utils_1.getAttrsTrackingButton)(dataTracked.id));
129
+ }
130
+ this.addClickListenerToBibItem(element, dataTracked);
151
131
  }
152
132
  if (selectedBibItemSuggestion &&
153
133
  selectedBibItemSuggestion === element.id) {
154
134
  element.classList.add('selected-suggestion');
155
135
  }
156
- if (can.seeReferencesButtons) {
157
- element.addEventListener('click', () => this.onClickHandler(element.id, dataTracked));
158
- }
159
136
  wrapper.append(element);
160
137
  }
161
138
  const oldContent = this.container.querySelector('.contents');
@@ -165,9 +142,6 @@ class BibliographyElementBlockView extends block_view_1.default {
165
142
  else {
166
143
  this.container.appendChild(wrapper);
167
144
  }
168
- if (this.clickedElementId) {
169
- this.showContextMenu(this.clickedElementId);
170
- }
171
145
  });
172
146
  this.createElement = () => {
173
147
  this.container = document.createElement('div');
@@ -183,6 +157,13 @@ class BibliographyElementBlockView extends block_view_1.default {
183
157
  this.handleDelete = (item) => {
184
158
  (0, view_1.deleteNode)(this.view, item._id);
185
159
  };
160
+ this.addClickListenerToBibItem = (element, dataTracked) => {
161
+ if (dataTracked.status !== track_changes_plugin_1.CHANGE_STATUS.rejected) {
162
+ element.addEventListener('click', () => {
163
+ this.view.dispatch(this.view.state.tr.setMeta(selected_suggestion_ui_1.SET_SUGGESTION_ID, dataTracked.id));
164
+ });
165
+ }
166
+ };
186
167
  }
187
168
  }
188
169
  exports.BibliographyElementBlockView = BibliographyElementBlockView;
@@ -14,9 +14,15 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
17
20
  Object.defineProperty(exports, "__esModule", { value: true });
18
21
  exports.CitationView = void 0;
19
22
  const prosemirror_model_1 = require("prosemirror-model");
23
+ const react_1 = require("react");
24
+ const react_dom_1 = __importDefault(require("react-dom"));
25
+ const TrackChangesReview_1 = require("../components/track-changes/TrackChangesReview");
20
26
  const dompurify_1 = require("../lib/dompurify");
21
27
  const track_changes_utils_1 = require("../lib/track-changes-utils");
22
28
  const bibliography_1 = require("../plugins/bibliography");
@@ -55,8 +61,24 @@ class CitationView extends base_node_view_1.BaseNodeView {
55
61
  this.dom.className = 'citation-wrapper';
56
62
  this.dom.innerHTML = '';
57
63
  this.dom.appendChild(element);
64
+ if ((0, track_changes_utils_1.isPendingSetAttrs)(this.node) &&
65
+ !(0, track_changes_utils_1.isDeleted)(this.node) &&
66
+ citation.embeddedCitationItems.length) {
67
+ this.dom.appendChild(this.renderTrackChangesReview());
68
+ }
58
69
  this.setDomAttrs(this.node, this.dom, ['rids', 'contents', 'selectedText']);
59
70
  };
71
+ this.renderTrackChangesReview = () => {
72
+ const { popper } = this.props;
73
+ const el = document.createElement('span');
74
+ el.classList.add('track-changes-review');
75
+ react_dom_1.default.render((0, react_1.createElement)(TrackChangesReview_1.TrackChangesReview, {
76
+ node: this.node,
77
+ popper,
78
+ target: el,
79
+ }), el);
80
+ return el;
81
+ };
60
82
  this.getCitation = () => {
61
83
  const citation = (0, bibliography_utils_1.getCitation)(this.node);
62
84
  if (!citation) {
@@ -29,7 +29,6 @@ const citation_sources_1 = require("../citation-sources");
29
29
  const track_changes_utils_1 = require("../lib/track-changes-utils");
30
30
  const view_1 = require("../lib/view");
31
31
  const bibliography_1 = require("../plugins/bibliography");
32
- const selected_suggestion_ui_1 = require("../plugins/selected-suggestion-ui");
33
32
  const citation_1 = require("./citation");
34
33
  const CitationEditorWrapper_1 = require("./CitationEditorWrapper");
35
34
  const creators_1 = require("./creators");
@@ -43,28 +42,14 @@ class CitationEditableView extends citation_1.CitationView {
43
42
  super(...arguments);
44
43
  this.decoder = new transform_1.Decoder(new Map());
45
44
  this.selectNode = () => {
46
- var _a;
47
- const dataTracked = this.node.attrs.dataTracked;
48
- const isSelectedSuggestion = !!((_a = selected_suggestion_ui_1.selectedSuggestionKey
49
- .getState(this.view.state)) === null || _a === void 0 ? void 0 : _a.find(this.getPos(), this.getPos() + this.node.nodeSize).length);
50
- this.dom.classList.add('ProseMirror-selectednode');
51
- if (dataTracked && !isSelectedSuggestion) {
52
- this.view.dispatch(this.view.state.tr.setMeta(selected_suggestion_ui_1.SET_SUGGESTION_ID, dataTracked[0].id));
53
- }
54
- else {
55
- if (!(0, track_changes_utils_1.isDeleted)(this.node)) {
56
- const citation = this.getCitation();
57
- const rids = citation.embeddedCitationItems.map((i) => i.bibliographyItem);
58
- if (!rids.length) {
59
- this.showPopper();
60
- }
61
- else {
62
- this.showContextMenu();
63
- }
64
- }
45
+ if (!(0, track_changes_utils_1.isDeleted)(this.node)) {
46
+ this.showPopper();
47
+ this.dom.classList.add('ProseMirror-selectednode');
65
48
  }
66
49
  };
67
50
  this.deselectNode = () => {
51
+ var _a;
52
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.remove();
68
53
  this.dom.classList.remove('ProseMirror-selectednode');
69
54
  this.props.popper.destroy();
70
55
  };
@@ -73,18 +58,7 @@ class CitationEditableView extends citation_1.CitationView {
73
58
  (_a = this.editor) === null || _a === void 0 ? void 0 : _a.remove();
74
59
  this.props.popper.destroy();
75
60
  };
76
- this.showContextMenu = () => {
77
- const componentProps = {
78
- actions: [
79
- { label: 'Edit', action: this.handleEdit, icon: 'EditIcon' },
80
- { label: 'Comment', action: this.handleComment, icon: 'AddComment' },
81
- ],
82
- };
83
- this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
84
- this.props.popper.show(this.dom, this.contextMenu, 'right-start', false);
85
- };
86
61
  this.showPopper = () => {
87
- this.props.popper.destroy();
88
62
  const can = this.props.getCapabilities();
89
63
  const citation = this.getCitation();
90
64
  const rids = citation.embeddedCitationItems.map((i) => i.bibliographyItem);
@@ -117,9 +91,6 @@ class CitationEditableView extends citation_1.CitationView {
117
91
  }
118
92
  this.props.popper.show(this.dom, this.editor, 'right');
119
93
  };
120
- this.handleEdit = () => {
121
- this.showPopper();
122
- };
123
94
  this.handleCancel = () => {
124
95
  const selection = prosemirror_state_1.TextSelection.create(this.view.state.tr.doc, this.getPos() + 1);
125
96
  this.view.dispatch(this.view.state.tr.setSelection(selection));
@@ -43,6 +43,10 @@ class LinkEditableView extends link_1.LinkView {
43
43
  if (!this.props.getCapabilities().editArticle) {
44
44
  return;
45
45
  }
46
+ if (!this.popperContainer) {
47
+ this.popperContainer = document.createElement('div');
48
+ this.popperContainer.className = 'link-editor';
49
+ }
46
50
  const originalValue = {
47
51
  href: this.node.attrs.href,
48
52
  title: this.node.attrs.title,
@@ -54,7 +58,7 @@ class LinkEditableView extends link_1.LinkView {
54
58
  handleRemove: this.handleRemove,
55
59
  handleSave: this.handleSave,
56
60
  };
57
- this.popperContainer = (0, ReactSubView_1.default)(this.props, LinkForm_1.LinkForm, componentProps, this.node, this.getPos, this.view, 'link-editor');
61
+ this.popperContainer = (0, ReactSubView_1.default)(this.props, LinkForm_1.LinkForm, componentProps, this.node, this.getPos, this.view);
58
62
  this.props.popper.show(this.dom, this.popperContainer, 'bottom');
59
63
  };
60
64
  this.handleCancel = () => {
@@ -78,7 +78,7 @@ const getTrackChangesData = (node) => {
78
78
  return (_a = trackChangesMark === null || trackChangesMark === void 0 ? void 0 : trackChangesMark.attrs) === null || _a === void 0 ? void 0 : _a.dataTracked;
79
79
  };
80
80
  export const SET_SUGGESTION_ID = 'SET_SELECTED_SUGGESTION_ID';
81
- export const CLEAR_SUGGESTION_ID = 'CLEAR_SUGGESTION_ID';
81
+ const CLEAR_SUGGESTION_ID = 'CLEAR_SUGGESTION_ID';
82
82
  export const selectedSuggestionKey = new PluginKey('selected_suggestion');
83
83
  export default (props) => new Plugin({
84
84
  key: selectedSuggestionKey,
@@ -22,15 +22,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
22
22
  step((generator = generator.apply(thisArg, _arguments || [])).next());
23
23
  });
24
24
  };
25
- import { ContextMenu } from '@manuscripts/style-guide';
26
- import { CHANGE_STATUS } from '@manuscripts/track-changes-plugin';
25
+ import { CHANGE_OPERATION, CHANGE_STATUS, } from '@manuscripts/track-changes-plugin';
27
26
  import { buildComment, Decoder, } from '@manuscripts/transform';
27
+ import { commentIcon, editIcon } from '../assets';
28
28
  import { sanitize } from '../lib/dompurify';
29
- import { getChangeClasses } from '../lib/track-changes-utils';
29
+ import { getAttrsTrackingButton, getChangeClasses, } from '../lib/track-changes-utils';
30
30
  import { deleteNode, updateNode } from '../lib/view';
31
31
  import { getBibliographyPluginState } from '../plugins/bibliography';
32
32
  import { commentAnnotation } from '../plugins/comment_annotation';
33
- import { CLEAR_SUGGESTION_ID, selectedSuggestionKey, SET_SUGGESTION_ID, } from '../plugins/selected-suggestion-ui';
33
+ import { selectedSuggestionKey, SET_SUGGESTION_ID, } from '../plugins/selected-suggestion-ui';
34
34
  import BlockView from './block_view';
35
35
  import { createNodeView } from './creators';
36
36
  import ReactSubView from './ReactSubView';
@@ -39,9 +39,8 @@ export class BibliographyElementBlockView extends BlockView {
39
39
  constructor() {
40
40
  super(...arguments);
41
41
  this.decoder = new Decoder(new Map());
42
- this.clickedElementId = null;
42
+ this.gutterButtons = () => [];
43
43
  this.showPopper = (id) => {
44
- this.props.popper.destroy();
45
44
  const bib = getBibliographyPluginState(this.view.state);
46
45
  const componentProps = {
47
46
  items: Array.from(bib.bibliographyItems.values()),
@@ -55,52 +54,6 @@ export class BibliographyElementBlockView extends BlockView {
55
54
  };
56
55
  this.stopEvent = () => true;
57
56
  this.ignoreMutation = () => true;
58
- this.handleEdit = (citationId) => {
59
- this.showPopper(citationId);
60
- };
61
- this.handleComment = (citationId) => {
62
- this.props.setComment(buildComment(citationId));
63
- };
64
- this.showContextMenu = (elementId) => {
65
- this.props.popper.destroy();
66
- this.clickedElementId = null;
67
- const can = this.props.getCapabilities();
68
- const element = document.getElementById(elementId);
69
- const componentProps = {
70
- actions: [],
71
- };
72
- if (can.editCitationsAndRefs) {
73
- componentProps.actions.push({
74
- label: 'Edit',
75
- action: () => this.handleEdit(elementId),
76
- icon: 'EditIcon',
77
- });
78
- }
79
- componentProps.actions.push({
80
- label: 'Comment',
81
- action: () => this.handleComment(elementId),
82
- icon: 'AddComment',
83
- });
84
- this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
85
- this.props.popper.show(element, this.contextMenu, 'right-start');
86
- };
87
- this.onClickHandler = (elementId, dataTracked) => {
88
- var _a;
89
- this.clickedElementId = elementId;
90
- const isSelectedSuggestion = !!((_a = selectedSuggestionKey
91
- .getState(this.view.state)) === null || _a === void 0 ? void 0 : _a.find(this.getPos(), this.getPos() + this.node.nodeSize).length);
92
- if (dataTracked && dataTracked.status !== CHANGE_STATUS.rejected) {
93
- this.view.dispatch(this.view.state.tr.setMeta(SET_SUGGESTION_ID, dataTracked.id));
94
- }
95
- else {
96
- if (isSelectedSuggestion) {
97
- this.view.dispatch(this.view.state.tr.setMeta(CLEAR_SUGGESTION_ID, true));
98
- }
99
- else {
100
- this.showContextMenu(elementId);
101
- }
102
- }
103
- };
104
57
  this.updateContents = () => __awaiter(this, void 0, void 0, function* () {
105
58
  const bib = getBibliographyPluginState(this.view.state);
106
59
  const commentsDecorationSet = commentAnnotation.getState(this.view.state);
@@ -135,6 +88,28 @@ export class BibliographyElementBlockView extends BlockView {
135
88
  const id = meta.entry_ids[i];
136
89
  const fragment = bibliography[i];
137
90
  const element = sanitize(`<div id="${id}" class="bib-item"><div class="csl-bib-body">${fragment}</div></div>`).firstElementChild;
91
+ const doubleButton = document.createElement('div');
92
+ const editButton = document.createElement('button');
93
+ const commentButton = document.createElement('button');
94
+ doubleButton.className = 'bibliography-double-button';
95
+ editButton.className = 'bibliography-edit-button';
96
+ commentButton.className = 'bibliography-comment-button';
97
+ commentButton.addEventListener('click', (e) => {
98
+ e.preventDefault();
99
+ this.props.setComment(buildComment(element.id));
100
+ });
101
+ editButton.addEventListener('click', (e) => {
102
+ e.preventDefault();
103
+ this.showPopper(element.id);
104
+ });
105
+ editButton.innerHTML = editIcon;
106
+ commentButton.innerHTML = commentIcon;
107
+ doubleButton.append(editButton, commentButton);
108
+ if (can.seeReferencesButtons &&
109
+ !element.querySelector('.bibliography-double-button')) {
110
+ element.appendChild(doubleButton);
111
+ }
112
+ editButton.disabled = !can.editCitationsAndRefs;
138
113
  const commentElement = commentElementMap.get(element.id);
139
114
  if (commentElement) {
140
115
  element.appendChild(commentElement);
@@ -142,14 +117,16 @@ export class BibliographyElementBlockView extends BlockView {
142
117
  const dataTracked = dataTrackedMap.get(element.id);
143
118
  if (dataTracked) {
144
119
  element.classList.add('attrs-track-mark', ...getChangeClasses([dataTracked]));
120
+ if (dataTracked.status === CHANGE_STATUS.pending &&
121
+ dataTracked.operation === CHANGE_OPERATION.set_node_attributes) {
122
+ element.appendChild(getAttrsTrackingButton(dataTracked.id));
123
+ }
124
+ this.addClickListenerToBibItem(element, dataTracked);
145
125
  }
146
126
  if (selectedBibItemSuggestion &&
147
127
  selectedBibItemSuggestion === element.id) {
148
128
  element.classList.add('selected-suggestion');
149
129
  }
150
- if (can.seeReferencesButtons) {
151
- element.addEventListener('click', () => this.onClickHandler(element.id, dataTracked));
152
- }
153
130
  wrapper.append(element);
154
131
  }
155
132
  const oldContent = this.container.querySelector('.contents');
@@ -159,9 +136,6 @@ export class BibliographyElementBlockView extends BlockView {
159
136
  else {
160
137
  this.container.appendChild(wrapper);
161
138
  }
162
- if (this.clickedElementId) {
163
- this.showContextMenu(this.clickedElementId);
164
- }
165
139
  });
166
140
  this.createElement = () => {
167
141
  this.container = document.createElement('div');
@@ -177,6 +151,13 @@ export class BibliographyElementBlockView extends BlockView {
177
151
  this.handleDelete = (item) => {
178
152
  deleteNode(this.view, item._id);
179
153
  };
154
+ this.addClickListenerToBibItem = (element, dataTracked) => {
155
+ if (dataTracked.status !== CHANGE_STATUS.rejected) {
156
+ element.addEventListener('click', () => {
157
+ this.view.dispatch(this.view.state.tr.setMeta(SET_SUGGESTION_ID, dataTracked.id));
158
+ });
159
+ }
160
+ };
180
161
  }
181
162
  }
182
163
  export default createNodeView(BibliographyElementBlockView);
@@ -14,8 +14,11 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { DOMSerializer } from 'prosemirror-model';
17
+ import { createElement } from 'react';
18
+ import ReactDOM from 'react-dom';
19
+ import { TrackChangesReview } from '../components/track-changes/TrackChangesReview';
17
20
  import { sanitize } from '../lib/dompurify';
18
- import { getChangeClasses } from '../lib/track-changes-utils';
21
+ import { getChangeClasses, isDeleted, isPendingSetAttrs, } from '../lib/track-changes-utils';
19
22
  import { getBibliographyPluginState } from '../plugins/bibliography';
20
23
  import { getCitation } from '../plugins/bibliography/bibliography-utils';
21
24
  import { BaseNodeView } from './base_node_view';
@@ -52,8 +55,24 @@ export class CitationView extends BaseNodeView {
52
55
  this.dom.className = 'citation-wrapper';
53
56
  this.dom.innerHTML = '';
54
57
  this.dom.appendChild(element);
58
+ if (isPendingSetAttrs(this.node) &&
59
+ !isDeleted(this.node) &&
60
+ citation.embeddedCitationItems.length) {
61
+ this.dom.appendChild(this.renderTrackChangesReview());
62
+ }
55
63
  this.setDomAttrs(this.node, this.dom, ['rids', 'contents', 'selectedText']);
56
64
  };
65
+ this.renderTrackChangesReview = () => {
66
+ const { popper } = this.props;
67
+ const el = document.createElement('span');
68
+ el.classList.add('track-changes-review');
69
+ ReactDOM.render(createElement(TrackChangesReview, {
70
+ node: this.node,
71
+ popper,
72
+ target: el,
73
+ }), el);
74
+ return el;
75
+ };
57
76
  this.getCitation = () => {
58
77
  const citation = getCitation(this.node);
59
78
  if (!citation) {
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { ObjectTypes, } from '@manuscripts/json-schema';
17
17
  import { findMatchingBibliographyItem } from '@manuscripts/library';
18
- import { CitationViewer, ContextMenu, } from '@manuscripts/style-guide';
18
+ import { CitationViewer, } from '@manuscripts/style-guide';
19
19
  import { buildComment, Decoder, schema, } from '@manuscripts/transform';
20
20
  import { TextSelection } from 'prosemirror-state';
21
21
  import { findChildren, findChildrenByType } from 'prosemirror-utils';
@@ -23,7 +23,6 @@ import { crossref } from '../citation-sources';
23
23
  import { isDeleted } from '../lib/track-changes-utils';
24
24
  import { deleteNode, updateNodeAttrs } from '../lib/view';
25
25
  import { getBibliographyPluginState } from '../plugins/bibliography';
26
- import { selectedSuggestionKey, SET_SUGGESTION_ID, } from '../plugins/selected-suggestion-ui';
27
26
  import { CitationView } from './citation';
28
27
  import { CitationEditorWrapper } from './CitationEditorWrapper';
29
28
  import { createEditableNodeView } from './creators';
@@ -37,28 +36,14 @@ export class CitationEditableView extends CitationView {
37
36
  super(...arguments);
38
37
  this.decoder = new Decoder(new Map());
39
38
  this.selectNode = () => {
40
- var _a;
41
- const dataTracked = this.node.attrs.dataTracked;
42
- const isSelectedSuggestion = !!((_a = selectedSuggestionKey
43
- .getState(this.view.state)) === null || _a === void 0 ? void 0 : _a.find(this.getPos(), this.getPos() + this.node.nodeSize).length);
44
- this.dom.classList.add('ProseMirror-selectednode');
45
- if (dataTracked && !isSelectedSuggestion) {
46
- this.view.dispatch(this.view.state.tr.setMeta(SET_SUGGESTION_ID, dataTracked[0].id));
47
- }
48
- else {
49
- if (!isDeleted(this.node)) {
50
- const citation = this.getCitation();
51
- const rids = citation.embeddedCitationItems.map((i) => i.bibliographyItem);
52
- if (!rids.length) {
53
- this.showPopper();
54
- }
55
- else {
56
- this.showContextMenu();
57
- }
58
- }
39
+ if (!isDeleted(this.node)) {
40
+ this.showPopper();
41
+ this.dom.classList.add('ProseMirror-selectednode');
59
42
  }
60
43
  };
61
44
  this.deselectNode = () => {
45
+ var _a;
46
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.remove();
62
47
  this.dom.classList.remove('ProseMirror-selectednode');
63
48
  this.props.popper.destroy();
64
49
  };
@@ -67,18 +52,7 @@ export class CitationEditableView extends CitationView {
67
52
  (_a = this.editor) === null || _a === void 0 ? void 0 : _a.remove();
68
53
  this.props.popper.destroy();
69
54
  };
70
- this.showContextMenu = () => {
71
- const componentProps = {
72
- actions: [
73
- { label: 'Edit', action: this.handleEdit, icon: 'EditIcon' },
74
- { label: 'Comment', action: this.handleComment, icon: 'AddComment' },
75
- ],
76
- };
77
- this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
78
- this.props.popper.show(this.dom, this.contextMenu, 'right-start', false);
79
- };
80
55
  this.showPopper = () => {
81
- this.props.popper.destroy();
82
56
  const can = this.props.getCapabilities();
83
57
  const citation = this.getCitation();
84
58
  const rids = citation.embeddedCitationItems.map((i) => i.bibliographyItem);
@@ -111,9 +85,6 @@ export class CitationEditableView extends CitationView {
111
85
  }
112
86
  this.props.popper.show(this.dom, this.editor, 'right');
113
87
  };
114
- this.handleEdit = () => {
115
- this.showPopper();
116
- };
117
88
  this.handleCancel = () => {
118
89
  const selection = TextSelection.create(this.view.state.tr.doc, this.getPos() + 1);
119
90
  this.view.dispatch(this.view.state.tr.setSelection(selection));
@@ -37,6 +37,10 @@ export class LinkEditableView extends LinkView {
37
37
  if (!this.props.getCapabilities().editArticle) {
38
38
  return;
39
39
  }
40
+ if (!this.popperContainer) {
41
+ this.popperContainer = document.createElement('div');
42
+ this.popperContainer.className = 'link-editor';
43
+ }
40
44
  const originalValue = {
41
45
  href: this.node.attrs.href,
42
46
  title: this.node.attrs.title,
@@ -48,7 +52,7 @@ export class LinkEditableView extends LinkView {
48
52
  handleRemove: this.handleRemove,
49
53
  handleSave: this.handleSave,
50
54
  };
51
- this.popperContainer = ReactSubView(this.props, LinkForm, componentProps, this.node, this.getPos, this.view, 'link-editor');
55
+ this.popperContainer = ReactSubView(this.props, LinkForm, componentProps, this.node, this.getPos, this.view);
52
56
  this.props.popper.show(this.dom, this.popperContainer, 'bottom');
53
57
  };
54
58
  this.handleCancel = () => {
@@ -19,7 +19,6 @@ interface SelectedSuggestionProps {
19
19
  setEditorSelectedSuggestion: (id?: string) => void;
20
20
  }
21
21
  export declare const SET_SUGGESTION_ID = "SET_SELECTED_SUGGESTION_ID";
22
- export declare const CLEAR_SUGGESTION_ID = "CLEAR_SUGGESTION_ID";
23
22
  export declare const selectedSuggestionKey: PluginKey<DecorationSet>;
24
23
  declare const _default: (props: SelectedSuggestionProps) => Plugin<DecorationSet>;
25
24
  export default _default;
@@ -23,20 +23,16 @@ interface BibliographyElementViewProps extends BaseNodeProps {
23
23
  export declare class BibliographyElementBlockView<PropsType extends BibliographyElementViewProps & EditableBlockProps> extends BlockView<PropsType> {
24
24
  private container;
25
25
  private editor;
26
- private contextMenu;
27
26
  private decoder;
28
- private clickedElementId;
27
+ gutterButtons: () => HTMLElement[];
29
28
  showPopper: (id: string) => void;
30
29
  stopEvent: () => boolean;
31
30
  ignoreMutation: () => boolean;
32
- private handleEdit;
33
- private handleComment;
34
- showContextMenu: (elementId: string) => void;
35
- private onClickHandler;
36
31
  updateContents: () => Promise<void>;
37
32
  createElement: () => void;
38
33
  private handleSave;
39
34
  private handleDelete;
35
+ private addClickListenerToBibItem;
40
36
  }
41
37
  declare const _default: (props: BaseNodeProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<BibliographyElementBlockView<any>>;
42
38
  export default _default;
@@ -19,6 +19,7 @@ export declare class CitationView<PropsType extends BaseNodeProps> extends BaseN
19
19
  ignoreMutation: () => boolean;
20
20
  initialise: () => this;
21
21
  updateContents: () => void;
22
+ renderTrackChangesReview: () => HTMLSpanElement;
22
23
  getCitation: () => import("@manuscripts/json-schema/dist/types").Citation;
23
24
  }
24
25
  declare const _default: (props: BaseNodeProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<CitationView<any>>;
@@ -18,13 +18,10 @@ import { EditableBlockProps } from './editable_block';
18
18
  export declare class CitationEditableView extends CitationView<EditableBlockProps> {
19
19
  private decoder;
20
20
  private editor;
21
- private contextMenu;
22
21
  selectNode: () => void;
23
22
  deselectNode: () => void;
24
23
  destroy: () => void;
25
- showContextMenu: () => void;
26
24
  showPopper: () => void;
27
- private handleEdit;
28
25
  private handleCancel;
29
26
  private handleSave;
30
27
  private handleUncite;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/body-editor",
3
3
  "description": "Prosemirror components for editing and viewing manuscripts",
4
- "version": "1.7.25-LEAN-3368-0",
4
+ "version": "1.7.25",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -31,7 +31,7 @@
31
31
  "@manuscripts/assets": "^0.6.4",
32
32
  "@manuscripts/json-schema": "^2.2.6",
33
33
  "@manuscripts/library": "^1.3.5",
34
- "@manuscripts/style-guide": "1.8.2",
34
+ "@manuscripts/style-guide": "1.8.1",
35
35
  "@manuscripts/track-changes-plugin": "1.7.8",
36
36
  "@manuscripts/transform": "^2.1.6",
37
37
  "astrocite-eutils": "^0.16.4",
@@ -112,4 +112,4 @@
112
112
  "@types/react": "^17.0.2",
113
113
  "prosemirror-tables": "^1.3.5"
114
114
  }
115
- }
115
+ }
@@ -741,7 +741,6 @@ Next levels are shifted 'up' by 1
741
741
  .citation-wrapper {
742
742
  position: relative;
743
743
  }
744
-
745
744
  .track-changes-review {
746
745
  display: none;
747
746
  height: 36px;
package/styles/Editor.css CHANGED
@@ -671,10 +671,6 @@
671
671
  cursor: ns-resize;
672
672
  opacity: 0;
673
673
  transition: 0.2s all;
674
- }
675
-
676
- .ProseMirror .block-section_title .block-gutter,
677
- .ProseMirror .block-paragraph .block-gutter {
678
674
  margin-top: 16px;
679
675
  }
680
676
 
package/styles/popper.css CHANGED
@@ -1,10 +1,11 @@
1
1
  .popper {
2
2
  color: #353535;
3
3
  font-family: 'PT Sans', sans-serif;
4
- /* min-width: 100px; */
4
+ min-width: 100px;
5
5
  position: absolute;
6
6
  width: auto;
7
7
  z-index: 5;
8
+ /*opacity: 0.9;*/
8
9
  }
9
10
 
10
11
  .popper-arrow {
@@ -135,8 +136,7 @@
135
136
  .popper .cross-reference-editor,
136
137
  .popper .citation-references,
137
138
  .popper .track-changes-review-panel,
138
- .popper .table-footnote-editor,
139
- .popper .context-menu {
139
+ .popper .table-footnote-editor {
140
140
  background: #fff;
141
141
  border: 1px solid #e2e2e2;
142
142
  border-radius: 8px;
@@ -144,11 +144,6 @@
144
144
  height: auto;
145
145
  }
146
146
 
147
- .popper .context-menu {
148
- width: auto;
149
- top: -12px;
150
- }
151
-
152
147
  .popper .conflict-dropdown {
153
148
  background: #fff;
154
149
  box-shadow: 0 4px 9px 0 rgba(84, 83, 83, 0.3);