@manuscripts/body-editor 2.0.48 → 2.0.50

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.
@@ -111,6 +111,10 @@ const DraggableTree = ({ tree, view, depth, can, }) => {
111
111
  const [{ isOver }, dropRef] = (0, react_dnd_1.useDrop)({
112
112
  accept: 'outline',
113
113
  canDrop(item, monitor) {
114
+ if (tree.node.type === transform_1.schema.nodes.bibliography_section ||
115
+ item.node.type === transform_1.schema.nodes.bibliography_section) {
116
+ return false;
117
+ }
114
118
  if (!ref.current) {
115
119
  return false;
116
120
  }
@@ -160,11 +160,20 @@ const ReferencesModal = ({ isOpen, onCancel, items, item, citationCounts, onSave
160
160
  (_a = actionsRef.current) === null || _a === void 0 ? void 0 : _a.reset();
161
161
  setConfirm(false);
162
162
  };
163
+ const isNewItem = (obj, basicProps) => {
164
+ const allKeys = Object.keys(obj);
165
+ const extraKeys = allKeys.filter((key) => !basicProps.includes(key));
166
+ return extraKeys.length > 0;
167
+ };
163
168
  const handleSave = (values) => {
164
169
  if (!values || !selection) {
165
170
  return;
166
171
  }
167
172
  const item = Object.assign(Object.assign({}, selection), values);
173
+ const currentCitationCount = citationCounts.get(item.id);
174
+ if (currentCitationCount === undefined) {
175
+ citationCounts.set(item.id, 1);
176
+ }
168
177
  onSave(item);
169
178
  setSelection(item);
170
179
  setConfirm(false);
@@ -215,6 +224,7 @@ const ReferencesModal = ({ isOpen, onCancel, items, item, citationCounts, onSave
215
224
  (citationCounts.get(item.id) || 0) > 0 ? (react_1.default.createElement(CitationCount, { "data-tooltip-id": "citation-count-tooltip" }, citationCounts.get(item.id))) : (react_1.default.createElement(CitationCount, { className: "unused" }, "0"))),
216
225
  react_1.default.createElement(ReferenceLine_1.ReferenceLine, { item: item }))))),
217
226
  react_1.default.createElement(style_guide_1.Tooltip, { id: "citation-count-tooltip", place: "bottom" }, "Number of times used in the document"))),
218
- react_1.default.createElement(style_guide_1.ScrollableModalContent, null, selection && (react_1.default.createElement(ReferenceForm_1.ReferenceForm, { values: normalize(selection), showDelete: !citationCounts.get(selection.id), onChange: handleChange, onCancel: onCancel, onDelete: handleDelete, onSave: handleSave, actionsRef: actionsRef })))))));
227
+ react_1.default.createElement(style_guide_1.ScrollableModalContent, null, selection && (react_1.default.createElement(ReferenceForm_1.ReferenceForm, { values: normalize(selection), showDelete: !citationCounts.get(selection.id) &&
228
+ isNewItem(selection, ['id', 'type']), onChange: handleChange, onCancel: onCancel, onDelete: handleDelete, onSave: handleSave, actionsRef: actionsRef })))))));
219
229
  };
220
230
  exports.ReferencesModal = ReferencesModal;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MATHJAX_VERSION = exports.VERSION = void 0;
4
- exports.VERSION = '2.0.48';
4
+ exports.VERSION = '2.0.50';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -84,6 +84,10 @@ export const DraggableTree = ({ tree, view, depth, can, }) => {
84
84
  const [{ isOver }, dropRef] = useDrop({
85
85
  accept: 'outline',
86
86
  canDrop(item, monitor) {
87
+ if (tree.node.type === schema.nodes.bibliography_section ||
88
+ item.node.type === schema.nodes.bibliography_section) {
89
+ return false;
90
+ }
87
91
  if (!ref.current) {
88
92
  return false;
89
93
  }
@@ -131,11 +131,20 @@ export const ReferencesModal = ({ isOpen, onCancel, items, item, citationCounts,
131
131
  (_a = actionsRef.current) === null || _a === void 0 ? void 0 : _a.reset();
132
132
  setConfirm(false);
133
133
  };
134
+ const isNewItem = (obj, basicProps) => {
135
+ const allKeys = Object.keys(obj);
136
+ const extraKeys = allKeys.filter((key) => !basicProps.includes(key));
137
+ return extraKeys.length > 0;
138
+ };
134
139
  const handleSave = (values) => {
135
140
  if (!values || !selection) {
136
141
  return;
137
142
  }
138
143
  const item = Object.assign(Object.assign({}, selection), values);
144
+ const currentCitationCount = citationCounts.get(item.id);
145
+ if (currentCitationCount === undefined) {
146
+ citationCounts.set(item.id, 1);
147
+ }
139
148
  onSave(item);
140
149
  setSelection(item);
141
150
  setConfirm(false);
@@ -186,5 +195,6 @@ export const ReferencesModal = ({ isOpen, onCancel, items, item, citationCounts,
186
195
  (citationCounts.get(item.id) || 0) > 0 ? (React.createElement(CitationCount, { "data-tooltip-id": "citation-count-tooltip" }, citationCounts.get(item.id))) : (React.createElement(CitationCount, { className: "unused" }, "0"))),
187
196
  React.createElement(ReferenceLine, { item: item }))))),
188
197
  React.createElement(Tooltip, { id: "citation-count-tooltip", place: "bottom" }, "Number of times used in the document"))),
189
- React.createElement(ScrollableModalContent, null, selection && (React.createElement(ReferenceForm, { values: normalize(selection), showDelete: !citationCounts.get(selection.id), onChange: handleChange, onCancel: onCancel, onDelete: handleDelete, onSave: handleSave, actionsRef: actionsRef })))))));
198
+ React.createElement(ScrollableModalContent, null, selection && (React.createElement(ReferenceForm, { values: normalize(selection), showDelete: !citationCounts.get(selection.id) &&
199
+ isNewItem(selection, ['id', 'type']), onChange: handleChange, onCancel: onCancel, onDelete: handleDelete, onSave: handleSave, actionsRef: actionsRef })))))));
190
200
  };
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.0.48';
1
+ export const VERSION = '2.0.50';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.0.48";
1
+ export declare const VERSION = "2.0.50";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
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": "2.0.48",
4
+ "version": "2.0.50",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",