@manuscripts/body-editor 3.2.3 → 3.2.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 (38) hide show
  1. package/dist/cjs/components/references/ReferenceForm/ReferenceForm.js +13 -2
  2. package/dist/cjs/components/references/ReferenceLine.js +1 -1
  3. package/dist/cjs/components/views/FigureDropdown.js +16 -8
  4. package/dist/cjs/configs/editor-views.js +2 -1
  5. package/dist/cjs/icons.js +2 -1
  6. package/dist/cjs/lib/files.js +15 -1
  7. package/dist/cjs/lib/references.js +1 -1
  8. package/dist/cjs/versions.js +1 -1
  9. package/dist/cjs/views/bibliography_element.js +21 -1
  10. package/dist/cjs/views/citation.js +5 -1
  11. package/dist/cjs/views/figure_editable.js +31 -4
  12. package/dist/cjs/views/figure_element.js +36 -12
  13. package/dist/cjs/views/image_element.js +40 -0
  14. package/dist/cjs/views/image_element_editable.js +21 -0
  15. package/dist/es/components/references/ReferenceForm/ReferenceForm.js +13 -2
  16. package/dist/es/components/references/ReferenceLine.js +1 -1
  17. package/dist/es/components/views/FigureDropdown.js +16 -8
  18. package/dist/es/configs/editor-views.js +2 -1
  19. package/dist/es/icons.js +1 -0
  20. package/dist/es/lib/files.js +13 -0
  21. package/dist/es/lib/references.js +1 -1
  22. package/dist/es/versions.js +1 -1
  23. package/dist/es/views/bibliography_element.js +21 -1
  24. package/dist/es/views/citation.js +5 -1
  25. package/dist/es/views/figure_editable.js +31 -4
  26. package/dist/es/views/figure_element.js +36 -9
  27. package/dist/es/views/image_element.js +33 -0
  28. package/dist/es/views/image_element_editable.js +19 -0
  29. package/dist/types/components/views/FigureDropdown.d.ts +5 -2
  30. package/dist/types/icons.d.ts +1 -0
  31. package/dist/types/lib/files.d.ts +1 -0
  32. package/dist/types/versions.d.ts +1 -1
  33. package/dist/types/views/figure_element.d.ts +4 -5
  34. package/dist/types/views/image_element.d.ts +25 -0
  35. package/dist/types/views/image_element_editable.d.ts +44 -0
  36. package/package.json +1 -1
  37. package/styles/AdvancedEditor.css +152 -1
  38. package/styles/Editor.css +0 -114
@@ -64,8 +64,15 @@ const ReferenceForm = ({ values, showDelete, onChange, onDelete, onCancel, onSav
64
64
  const [showDeleteDialog, setShowDeleteDialog] = (0, react_1.useState)(false);
65
65
  const validateReference = (values) => {
66
66
  const errors = {};
67
- if (!values.title?.trim()) {
68
- errors.title = 'Title is required';
67
+ if (values.type === 'literal') {
68
+ if (!values.literal?.trim()) {
69
+ errors.literal = 'Literal is required for unstructured references';
70
+ }
71
+ }
72
+ else {
73
+ if (!values.title?.trim()) {
74
+ errors.title = 'Title is required';
75
+ }
69
76
  }
70
77
  return errors;
71
78
  };
@@ -110,6 +117,10 @@ const ReferenceForm = ({ values, showDelete, onChange, onDelete, onCancel, onSav
110
117
  react_1.default.createElement(styled_components_1.LabelContainer, null,
111
118
  react_1.default.createElement(styled_components_1.Label, null, "Title")),
112
119
  react_1.default.createElement(formik_1.Field, { name: 'title' }, (props) => (react_1.default.createElement(styled_components_1.ReferenceTextArea, { id: 'title', ...props.field }))))),
120
+ (0, utils_1.shouldRenderField)('literal', formik.values.type) && (react_1.default.createElement(styled_components_1.FormField, null,
121
+ react_1.default.createElement(styled_components_1.LabelContainer, null,
122
+ react_1.default.createElement(styled_components_1.Label, null, "Text")),
123
+ react_1.default.createElement(formik_1.Field, { name: 'literal' }, (props) => (react_1.default.createElement(styled_components_1.ReferenceTextArea, { id: 'literal', ...props.field }))))),
113
124
  (0, utils_1.shouldRenderField)('std', formik.values.type) && (react_1.default.createElement(styled_components_1.FormField, null,
114
125
  react_1.default.createElement(styled_components_1.LabelContainer, null,
115
126
  react_1.default.createElement(styled_components_1.Label, { htmlFor: 'std' }, "Standard")),
@@ -32,6 +32,6 @@ exports.MetadataContainer = styled_components_1.default.div `
32
32
  flex: 1;
33
33
  `;
34
34
  const ReferenceLine = ({ item }) => (react_1.default.createElement(exports.MetadataContainer, null,
35
- react_1.default.createElement("div", { "data-cy": 'reference-title' }, item.title || 'Untitled'),
35
+ react_1.default.createElement("div", { "data-cy": 'reference-title' }, item.title || item.literal || 'Untitled'),
36
36
  react_1.default.createElement(exports.Metadata, null, (0, references_1.metadata)(item))));
37
37
  exports.ReferenceLine = ReferenceLine;
@@ -7,33 +7,41 @@ exports.FigureOptions = void 0;
7
7
  const style_guide_1 = require("@manuscripts/style-guide");
8
8
  const react_1 = __importDefault(require("react"));
9
9
  const styled_components_1 = __importDefault(require("styled-components"));
10
- const FigureOptions = ({ can, files, onDownload, onUpload, onDetach, onReplace, }) => {
11
- const { isOpen, toggleOpen, wrapperRef } = (0, style_guide_1.useDropdown)();
12
- const supplements = files.supplements
13
- .map((s) => s.file)
10
+ const files_1 = require("../../lib/files");
11
+ function getSupplements(getFiles, getDoc, groupFiles) {
12
+ return groupFiles(getDoc(), getFiles())
13
+ .supplements.map((s) => s.file)
14
14
  .filter((f) => (0, style_guide_1.isImageFile)(f.name));
15
- const otherFiles = files.others.filter((f) => (0, style_guide_1.isImageFile)(f.name));
15
+ }
16
+ function getOtherFiles(getFiles, getDoc, groupFiles) {
17
+ return groupFiles(getDoc(), getFiles()).others.filter((f) => (0, style_guide_1.isImageFile)(f.name));
18
+ }
19
+ const FigureOptions = ({ can, getDoc, getFiles, onDownload, onUpload, onDetach, onReplace, onDelete, }) => {
20
+ const { isOpen, toggleOpen, wrapperRef } = (0, style_guide_1.useDropdown)();
16
21
  const showDownload = onDownload && can.downloadFiles;
17
22
  const showUpload = onUpload && can.uploadFile;
18
23
  const showDetach = onDetach && can.detachFile;
19
24
  const showReplace = onReplace && can.replaceFile;
20
25
  const replaceBtnText = onDownload ? 'Replace' : 'Choose file';
26
+ const showDelete = onDelete && can.detachFile;
27
+ const groupFiles = (0, files_1.memoGroupFiles)();
21
28
  return (react_1.default.createElement(DropdownWrapper, { ref: wrapperRef },
22
29
  react_1.default.createElement(OptionsButton, { className: 'options-button', onClick: toggleOpen },
23
30
  react_1.default.createElement(style_guide_1.DotsIcon, null)),
24
31
  isOpen && (react_1.default.createElement(OptionsDropdownList, { direction: 'right', width: 128, top: 5 },
25
32
  react_1.default.createElement(NestedDropdown, { disabled: !showReplace, parentToggleOpen: toggleOpen, buttonText: replaceBtnText, moveLeft: true, list: react_1.default.createElement(react_1.default.Fragment, null,
26
- supplements.map((file, index) => (react_1.default.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
33
+ getSupplements(getFiles, getDoc, groupFiles).map((file, index) => (react_1.default.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
27
34
  (0, style_guide_1.getFileIcon)(file.name),
28
35
  react_1.default.createElement(ListItemText, null, file.name)))),
29
- otherFiles.map((file, index) => (react_1.default.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
36
+ getOtherFiles(getFiles, getDoc, groupFiles).map((file, index) => (react_1.default.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
30
37
  (0, style_guide_1.getFileIcon)(file.name),
31
38
  react_1.default.createElement(ListItemText, null, file.name)))),
32
39
  react_1.default.createElement(UploadButton, { onClick: onUpload, disabled: !showUpload },
33
40
  react_1.default.createElement(style_guide_1.UploadIcon, null),
34
41
  " Upload new...")) }),
35
42
  react_1.default.createElement(ListItemButton, { onClick: onDownload, disabled: !showDownload }, "Download"),
36
- react_1.default.createElement(ListItemButton, { onClick: onDetach, disabled: !showDetach }, "Detach")))));
43
+ react_1.default.createElement(ListItemButton, { onClick: onDetach, disabled: !showDetach }, "Detach"),
44
+ showDelete && (react_1.default.createElement(ListItemButton, { onClick: onDelete }, "Delete"))))));
37
45
  };
38
46
  exports.FigureOptions = FigureOptions;
39
47
  const NestedDropdown = ({ parentToggleOpen, buttonText, disabled, list, moveLeft }) => {
@@ -26,6 +26,7 @@ const footnote_1 = __importDefault(require("../views/footnote"));
26
26
  const footnotes_element_1 = __importDefault(require("../views/footnotes_element"));
27
27
  const general_table_footnote_1 = __importDefault(require("../views/general_table_footnote"));
28
28
  const hero_image_editable_1 = __importDefault(require("../views/hero_image_editable"));
29
+ const image_element_editable_1 = __importDefault(require("../views/image_element_editable"));
29
30
  const inline_equation_editable_1 = __importDefault(require("../views/inline_equation_editable"));
30
31
  const inline_footnote_editable_1 = __importDefault(require("../views/inline_footnote_editable"));
31
32
  const keyword_1 = __importDefault(require("../views/keyword"));
@@ -65,7 +66,7 @@ exports.default = (props, dispatch) => {
65
66
  equation_element: (0, equation_element_editable_1.default)(props),
66
67
  figure: (0, figure_editable_1.default)(props, dispatch),
67
68
  figure_element: (0, figure_element_editable_1.default)(props, dispatch),
68
- image_element: (0, figure_element_editable_1.default)(props, dispatch),
69
+ image_element: (0, image_element_editable_1.default)(props, dispatch),
69
70
  footnote: (0, footnote_1.default)(props),
70
71
  footnotes_element: (0, footnotes_element_1.default)(props),
71
72
  general_table_footnote: (0, general_table_footnote_1.default)(props, dispatch),
package/dist/cjs/icons.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.plusIcon = exports.lockIcon = exports.scrollIcon = exports.sectionCategoryIcon = exports.editIcon = exports.deleteIcon = exports.alertIcon = exports.arrowUp = exports.arrowDown = void 0;
3
+ exports.addFigureBtnIcon = exports.plusIcon = exports.lockIcon = exports.scrollIcon = exports.sectionCategoryIcon = exports.editIcon = exports.deleteIcon = exports.alertIcon = exports.arrowUp = exports.arrowDown = void 0;
4
4
  const style_guide_1 = require("@manuscripts/style-guide");
5
5
  const react_1 = require("react");
6
6
  const server_1 = require("react-dom/server");
@@ -14,3 +14,4 @@ exports.sectionCategoryIcon = renderIcon(style_guide_1.SectionCategoryIcon);
14
14
  exports.scrollIcon = (0, server_1.renderToStaticMarkup)((0, react_1.createElement)(style_guide_1.ScrollIcon));
15
15
  exports.lockIcon = (0, server_1.renderToStaticMarkup)((0, react_1.createElement)(style_guide_1.LockIcon));
16
16
  exports.plusIcon = renderIcon(style_guide_1.PlusIcon);
17
+ exports.addFigureBtnIcon = (0, server_1.renderToStaticMarkup)((0, react_1.createElement)(style_guide_1.PlusIcon));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.groupFiles = void 0;
3
+ exports.groupFiles = exports.memoGroupFiles = void 0;
4
4
  const transform_1 = require("@manuscripts/transform");
5
5
  const prosemirror_utils_1 = require("prosemirror-utils");
6
6
  const track_changes_utils_1 = require("./track-changes-utils");
@@ -13,6 +13,20 @@ const figureTypes = [
13
13
  transform_1.schema.nodes.image_element,
14
14
  transform_1.schema.nodes.hero_image,
15
15
  ];
16
+ function memoGroupFiles() {
17
+ let prevFiles = [];
18
+ let prevDoc = undefined;
19
+ let result;
20
+ return function (doc, files) {
21
+ if (result && prevDoc === doc && prevFiles === files) {
22
+ return result;
23
+ }
24
+ prevDoc = doc;
25
+ prevFiles = files;
26
+ return (0, exports.groupFiles)(doc, files);
27
+ };
28
+ }
29
+ exports.memoGroupFiles = memoGroupFiles;
16
30
  const groupFiles = (doc, files) => {
17
31
  const fileMap = new Map(files.map((f) => [f.id, f]));
18
32
  const figures = [];
@@ -88,5 +88,5 @@ exports.bibliographyItemTypes = [
88
88
  ['standard', 'Standard'],
89
89
  ['dataset', 'Dataset'],
90
90
  ['preprint', 'Preprint'],
91
- ['literal', 'Literal'],
91
+ ['literal', 'Unstructured'],
92
92
  ];
@@ -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 = '3.2.3';
4
+ exports.VERSION = '3.2.5';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -174,8 +174,28 @@ class BibliographyElementBlockView extends block_view_1.default {
174
174
  for (let i = 0; i < bibliography.length; i++) {
175
175
  const id = meta.entry_ids[i][0];
176
176
  const fragment = bibliography[i];
177
- const element = (0, dompurify_1.sanitize)(`<div id="${id}" class="bib-item"><div class="csl-bib-body">${fragment}</div></div>`).firstElementChild;
178
177
  const node = nodes.get(id);
178
+ const isUnstructured = node.attrs.type === 'literal';
179
+ const tempDiv = document.createElement('div');
180
+ tempDiv.innerHTML = fragment;
181
+ if (isUnstructured) {
182
+ const cslLeftMarginDiv = tempDiv.querySelector('.csl-left-margin');
183
+ let cslRightInlineDiv = tempDiv.querySelector('.csl-right-inline');
184
+ const cslEntry = tempDiv.querySelector('.csl-entry');
185
+ if (cslRightInlineDiv) {
186
+ cslRightInlineDiv.textContent = node.attrs.literal ?? '';
187
+ }
188
+ else if (cslLeftMarginDiv) {
189
+ cslRightInlineDiv = document.createElement('div');
190
+ cslRightInlineDiv.classList.add('csl-right-inline');
191
+ cslRightInlineDiv.textContent = node.attrs.literal ?? '';
192
+ cslLeftMarginDiv.after(cslRightInlineDiv);
193
+ }
194
+ else if (cslEntry) {
195
+ cslEntry.textContent = node.attrs.literal ?? '';
196
+ }
197
+ }
198
+ const element = (0, dompurify_1.sanitize)(`<div id="${id}" class="bib-item"><div class="csl-bib-body">${tempDiv.innerHTML}</div></div>`).firstElementChild;
179
199
  const comment = (0, comments_1.createCommentMarker)('div', id);
180
200
  element.prepend(comment);
181
201
  (0, track_changes_utils_1.addTrackChangesAttributes)(node.attrs, element);
@@ -41,7 +41,11 @@ class CitationView extends base_node_view_1.BaseNodeView {
41
41
  }
42
42
  const id = this.node.attrs.id;
43
43
  const text = bib.renderedCitations.get(id);
44
- const fragment = (0, dompurify_1.sanitize)(text && text !== '[NO_PRINTED_FORM]' ? text : ' ', {
44
+ const fragment = (0, dompurify_1.sanitize)(text === '(n.d.)'
45
+ ? 'Missing citation data'
46
+ : text && text !== '[NO_PRINTED_FORM]'
47
+ ? text
48
+ : ' ', {
45
49
  ALLOWED_TAGS: ['i', 'b', 'span', 'sup', 'sub', '#text'],
46
50
  });
47
51
  this.dom.innerHTML = '';
@@ -22,10 +22,10 @@ exports.FigureEditableView = exports.figurePositions = void 0;
22
22
  const style_guide_1 = require("@manuscripts/style-guide");
23
23
  const transform_1 = require("@manuscripts/transform");
24
24
  const prosemirror_state_1 = require("prosemirror-state");
25
+ const prosemirror_utils_1 = require("prosemirror-utils");
25
26
  const react_1 = require("react");
26
27
  const server_1 = require("react-dom/server");
27
28
  const FigureDropdown_1 = require("../components/views/FigureDropdown");
28
- const files_1 = require("../lib/files");
29
29
  const track_changes_utils_1 = require("../lib/track-changes-utils");
30
30
  const view_1 = require("../lib/view");
31
31
  const creators_1 = require("./creators");
@@ -243,6 +243,7 @@ class FigureEditableView extends figure_1.FigureView {
243
243
  let handleUpload;
244
244
  let handleReplace;
245
245
  let handleDetach;
246
+ let handleDelete;
246
247
  const src = this.node.attrs.src;
247
248
  const files = this.props.getFiles();
248
249
  const file = src && files.filter((f) => f.id === src)[0];
@@ -265,17 +266,43 @@ class FigureEditableView extends figure_1.FigureView {
265
266
  if (can.uploadFile) {
266
267
  handleUpload = (0, figure_uploader_1.figureUploader)(this.upload);
267
268
  }
269
+ if (can.detachFile) {
270
+ const countFigures = () => {
271
+ const element = (0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)(this.view.state.doc.resolve(this.getPos()), transform_1.schema.nodes.figure_element);
272
+ let count = 0;
273
+ element?.node.descendants((node) => {
274
+ if (node.type === transform_1.schema.nodes.figure && !(0, track_changes_utils_1.isDeleted)(node)) {
275
+ count++;
276
+ }
277
+ });
278
+ return count;
279
+ };
280
+ const figureCount = countFigures();
281
+ handleDelete =
282
+ figureCount > 1
283
+ ? () => {
284
+ const currentCount = countFigures();
285
+ const pos = this.getPos();
286
+ if (currentCount <= 1) {
287
+ return;
288
+ }
289
+ const tr = this.view.state.tr;
290
+ tr.delete(pos, pos + this.node.nodeSize);
291
+ this.view.dispatch(tr);
292
+ }
293
+ : undefined;
294
+ }
268
295
  this.reactTools?.remove();
269
296
  if (this.props.dispatch && this.props.theme) {
270
- const files = this.props.getFiles();
271
- const doc = this.view.state.doc;
272
297
  const componentProps = {
273
298
  can,
274
- files: (0, files_1.groupFiles)(doc, files),
299
+ getDoc: () => this.view.state.doc,
300
+ getFiles: this.props.getFiles,
275
301
  onDownload: handleDownload,
276
302
  onUpload: handleUpload,
277
303
  onDetach: handleDetach,
278
304
  onReplace: handleReplace,
305
+ onDelete: handleDelete,
279
306
  };
280
307
  this.reactTools = (0, ReactSubView_1.default)(this.props, FigureDropdown_1.FigureOptions, componentProps, this.node, this.getPos, this.view);
281
308
  this.dom.insertBefore(this.reactTools, this.dom.firstChild);
@@ -14,26 +14,50 @@
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
- };
20
17
  Object.defineProperty(exports, "__esModule", { value: true });
21
18
  exports.FigureElementView = void 0;
22
- const block_view_1 = __importDefault(require("./block_view"));
19
+ const transform_1 = require("@manuscripts/transform");
20
+ const icons_1 = require("../icons");
23
21
  const creators_1 = require("./creators");
24
- class FigureElementView extends block_view_1.default {
22
+ const image_element_1 = require("./image_element");
23
+ class FigureElementView extends image_element_1.ImageElementView {
25
24
  constructor() {
26
25
  super(...arguments);
27
26
  this.ignoreMutation = () => true;
28
27
  this.createElement = () => {
29
- this.container = document.createElement('div');
30
- this.container.classList.add('block');
31
- this.dom.appendChild(this.container);
32
- this.contentDOM = document.createElement('figure');
33
- this.contentDOM.classList.add('figure-block');
34
- this.contentDOM.setAttribute('id', this.node.attrs.id);
35
- this.container.appendChild(this.contentDOM);
28
+ super.createElement();
29
+ this.addFigureElementButtons();
36
30
  };
31
+ this.addFigure = () => {
32
+ const { state } = this.view;
33
+ const { tr } = state;
34
+ const figureElementPos = this.getPos();
35
+ let insertPos = figureElementPos + 1;
36
+ let lastFigureEndPos = insertPos;
37
+ let hasFigures = false;
38
+ this.node.forEach((node) => {
39
+ if (node.type === transform_1.schema.nodes.figure) {
40
+ lastFigureEndPos = insertPos + node.nodeSize;
41
+ hasFigures = true;
42
+ }
43
+ insertPos += node.nodeSize;
44
+ });
45
+ const finalInsertPos = hasFigures ? lastFigureEndPos : figureElementPos + 1;
46
+ const figureNode = state.schema.nodes.figure.create();
47
+ tr.insert(finalInsertPos, figureNode);
48
+ this.view.dispatch(tr);
49
+ };
50
+ }
51
+ addFigureElementButtons() {
52
+ if (this.props.getCapabilities()?.editArticle) {
53
+ const addFigureBtn = Object.assign(document.createElement('button'), {
54
+ className: 'add-figure-button',
55
+ innerHTML: icons_1.addFigureBtnIcon,
56
+ title: 'Add figure',
57
+ });
58
+ addFigureBtn.addEventListener('click', () => this.addFigure());
59
+ this.container.prepend(addFigureBtn);
60
+ }
37
61
  }
38
62
  }
39
63
  exports.FigureElementView = FigureElementView;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2025 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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.ImageElementView = void 0;
22
+ const block_view_1 = __importDefault(require("./block_view"));
23
+ const creators_1 = require("./creators");
24
+ class ImageElementView extends block_view_1.default {
25
+ constructor() {
26
+ super(...arguments);
27
+ this.ignoreMutation = () => true;
28
+ }
29
+ createElement() {
30
+ this.container = document.createElement('div');
31
+ this.container.classList.add('block');
32
+ this.dom.appendChild(this.container);
33
+ this.contentDOM = document.createElement('figure');
34
+ this.contentDOM.classList.add('figure-block');
35
+ this.contentDOM.setAttribute('id', this.node.attrs.id);
36
+ this.container.appendChild(this.contentDOM);
37
+ }
38
+ }
39
+ exports.ImageElementView = ImageElementView;
40
+ exports.default = (0, creators_1.createNodeView)(ImageElementView);
@@ -0,0 +1,21 @@
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
+ const creators_1 = require("./creators");
19
+ const editable_block_1 = require("./editable_block");
20
+ const image_element_1 = require("./image_element");
21
+ exports.default = (0, creators_1.createEditableNodeView)((0, editable_block_1.EditableBlock)(image_element_1.ImageElementView));
@@ -38,8 +38,15 @@ export const ReferenceForm = ({ values, showDelete, onChange, onDelete, onCancel
38
38
  const [showDeleteDialog, setShowDeleteDialog] = useState(false);
39
39
  const validateReference = (values) => {
40
40
  const errors = {};
41
- if (!values.title?.trim()) {
42
- errors.title = 'Title is required';
41
+ if (values.type === 'literal') {
42
+ if (!values.literal?.trim()) {
43
+ errors.literal = 'Literal is required for unstructured references';
44
+ }
45
+ }
46
+ else {
47
+ if (!values.title?.trim()) {
48
+ errors.title = 'Title is required';
49
+ }
43
50
  }
44
51
  return errors;
45
52
  };
@@ -84,6 +91,10 @@ export const ReferenceForm = ({ values, showDelete, onChange, onDelete, onCancel
84
91
  React.createElement(LabelContainer, null,
85
92
  React.createElement(Label, null, "Title")),
86
93
  React.createElement(Field, { name: 'title' }, (props) => (React.createElement(ReferenceTextArea, { id: 'title', ...props.field }))))),
94
+ shouldRenderField('literal', formik.values.type) && (React.createElement(FormField, null,
95
+ React.createElement(LabelContainer, null,
96
+ React.createElement(Label, null, "Text")),
97
+ React.createElement(Field, { name: 'literal' }, (props) => (React.createElement(ReferenceTextArea, { id: 'literal', ...props.field }))))),
87
98
  shouldRenderField('std', formik.values.type) && (React.createElement(FormField, null,
88
99
  React.createElement(LabelContainer, null,
89
100
  React.createElement(Label, { htmlFor: 'std' }, "Standard")),
@@ -26,5 +26,5 @@ export const MetadataContainer = styled.div `
26
26
  flex: 1;
27
27
  `;
28
28
  export const ReferenceLine = ({ item }) => (React.createElement(MetadataContainer, null,
29
- React.createElement("div", { "data-cy": 'reference-title' }, item.title || 'Untitled'),
29
+ React.createElement("div", { "data-cy": 'reference-title' }, item.title || item.literal || 'Untitled'),
30
30
  React.createElement(Metadata, null, metadata(item))));
@@ -1,33 +1,41 @@
1
1
  import { DotsIcon, DropdownList, getFileIcon, IconButton, IconTextButton, isImageFile, TriangleCollapsedIcon, UploadIcon, useDropdown, } from '@manuscripts/style-guide';
2
2
  import React from 'react';
3
3
  import styled from 'styled-components';
4
- export const FigureOptions = ({ can, files, onDownload, onUpload, onDetach, onReplace, }) => {
5
- const { isOpen, toggleOpen, wrapperRef } = useDropdown();
6
- const supplements = files.supplements
7
- .map((s) => s.file)
4
+ import { memoGroupFiles, } from '../../lib/files';
5
+ function getSupplements(getFiles, getDoc, groupFiles) {
6
+ return groupFiles(getDoc(), getFiles())
7
+ .supplements.map((s) => s.file)
8
8
  .filter((f) => isImageFile(f.name));
9
- const otherFiles = files.others.filter((f) => isImageFile(f.name));
9
+ }
10
+ function getOtherFiles(getFiles, getDoc, groupFiles) {
11
+ return groupFiles(getDoc(), getFiles()).others.filter((f) => isImageFile(f.name));
12
+ }
13
+ export const FigureOptions = ({ can, getDoc, getFiles, onDownload, onUpload, onDetach, onReplace, onDelete, }) => {
14
+ const { isOpen, toggleOpen, wrapperRef } = useDropdown();
10
15
  const showDownload = onDownload && can.downloadFiles;
11
16
  const showUpload = onUpload && can.uploadFile;
12
17
  const showDetach = onDetach && can.detachFile;
13
18
  const showReplace = onReplace && can.replaceFile;
14
19
  const replaceBtnText = onDownload ? 'Replace' : 'Choose file';
20
+ const showDelete = onDelete && can.detachFile;
21
+ const groupFiles = memoGroupFiles();
15
22
  return (React.createElement(DropdownWrapper, { ref: wrapperRef },
16
23
  React.createElement(OptionsButton, { className: 'options-button', onClick: toggleOpen },
17
24
  React.createElement(DotsIcon, null)),
18
25
  isOpen && (React.createElement(OptionsDropdownList, { direction: 'right', width: 128, top: 5 },
19
26
  React.createElement(NestedDropdown, { disabled: !showReplace, parentToggleOpen: toggleOpen, buttonText: replaceBtnText, moveLeft: true, list: React.createElement(React.Fragment, null,
20
- supplements.map((file, index) => (React.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
27
+ getSupplements(getFiles, getDoc, groupFiles).map((file, index) => (React.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
21
28
  getFileIcon(file.name),
22
29
  React.createElement(ListItemText, null, file.name)))),
23
- otherFiles.map((file, index) => (React.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
30
+ getOtherFiles(getFiles, getDoc, groupFiles).map((file, index) => (React.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
24
31
  getFileIcon(file.name),
25
32
  React.createElement(ListItemText, null, file.name)))),
26
33
  React.createElement(UploadButton, { onClick: onUpload, disabled: !showUpload },
27
34
  React.createElement(UploadIcon, null),
28
35
  " Upload new...")) }),
29
36
  React.createElement(ListItemButton, { onClick: onDownload, disabled: !showDownload }, "Download"),
30
- React.createElement(ListItemButton, { onClick: onDetach, disabled: !showDetach }, "Detach")))));
37
+ React.createElement(ListItemButton, { onClick: onDetach, disabled: !showDetach }, "Detach"),
38
+ showDelete && (React.createElement(ListItemButton, { onClick: onDelete }, "Delete"))))));
31
39
  };
32
40
  const NestedDropdown = ({ parentToggleOpen, buttonText, disabled, list, moveLeft }) => {
33
41
  const { isOpen, toggleOpen, wrapperRef } = useDropdown();
@@ -21,6 +21,7 @@ import footnote from '../views/footnote';
21
21
  import footnotesElement from '../views/footnotes_element';
22
22
  import generalTableFootnote from '../views/general_table_footnote';
23
23
  import heroImage from '../views/hero_image_editable';
24
+ import imageElement from '../views/image_element_editable';
24
25
  import inlineEquation from '../views/inline_equation_editable';
25
26
  import inlineFootnote from '../views/inline_footnote_editable';
26
27
  import keyword from '../views/keyword';
@@ -60,7 +61,7 @@ export default (props, dispatch) => {
60
61
  equation_element: equationElement(props),
61
62
  figure: figure(props, dispatch),
62
63
  figure_element: figureElement(props, dispatch),
63
- image_element: figureElement(props, dispatch),
64
+ image_element: imageElement(props, dispatch),
64
65
  footnote: footnote(props),
65
66
  footnotes_element: footnotesElement(props),
66
67
  general_table_footnote: generalTableFootnote(props, dispatch),
package/dist/es/icons.js CHANGED
@@ -11,3 +11,4 @@ export const sectionCategoryIcon = renderIcon(SectionCategoryIcon);
11
11
  export const scrollIcon = renderToStaticMarkup(createElement(ScrollIcon));
12
12
  export const lockIcon = renderToStaticMarkup(createElement(LockIcon));
13
13
  export const plusIcon = renderIcon(PlusIcon);
14
+ export const addFigureBtnIcon = renderToStaticMarkup(createElement(PlusIcon));
@@ -10,6 +10,19 @@ const figureTypes = [
10
10
  schema.nodes.image_element,
11
11
  schema.nodes.hero_image,
12
12
  ];
13
+ export function memoGroupFiles() {
14
+ let prevFiles = [];
15
+ let prevDoc = undefined;
16
+ let result;
17
+ return function (doc, files) {
18
+ if (result && prevDoc === doc && prevFiles === files) {
19
+ return result;
20
+ }
21
+ prevDoc = doc;
22
+ prevFiles = files;
23
+ return groupFiles(doc, files);
24
+ };
25
+ }
13
26
  export const groupFiles = (doc, files) => {
14
27
  const fileMap = new Map(files.map((f) => [f.id, f]));
15
28
  const figures = [];
@@ -58,5 +58,5 @@ export const bibliographyItemTypes = [
58
58
  ['standard', 'Standard'],
59
59
  ['dataset', 'Dataset'],
60
60
  ['preprint', 'Preprint'],
61
- ['literal', 'Literal'],
61
+ ['literal', 'Unstructured'],
62
62
  ];
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.2.3';
1
+ export const VERSION = '3.2.5';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -168,8 +168,28 @@ export class BibliographyElementBlockView extends BlockView {
168
168
  for (let i = 0; i < bibliography.length; i++) {
169
169
  const id = meta.entry_ids[i][0];
170
170
  const fragment = bibliography[i];
171
- const element = sanitize(`<div id="${id}" class="bib-item"><div class="csl-bib-body">${fragment}</div></div>`).firstElementChild;
172
171
  const node = nodes.get(id);
172
+ const isUnstructured = node.attrs.type === 'literal';
173
+ const tempDiv = document.createElement('div');
174
+ tempDiv.innerHTML = fragment;
175
+ if (isUnstructured) {
176
+ const cslLeftMarginDiv = tempDiv.querySelector('.csl-left-margin');
177
+ let cslRightInlineDiv = tempDiv.querySelector('.csl-right-inline');
178
+ const cslEntry = tempDiv.querySelector('.csl-entry');
179
+ if (cslRightInlineDiv) {
180
+ cslRightInlineDiv.textContent = node.attrs.literal ?? '';
181
+ }
182
+ else if (cslLeftMarginDiv) {
183
+ cslRightInlineDiv = document.createElement('div');
184
+ cslRightInlineDiv.classList.add('csl-right-inline');
185
+ cslRightInlineDiv.textContent = node.attrs.literal ?? '';
186
+ cslLeftMarginDiv.after(cslRightInlineDiv);
187
+ }
188
+ else if (cslEntry) {
189
+ cslEntry.textContent = node.attrs.literal ?? '';
190
+ }
191
+ }
192
+ const element = sanitize(`<div id="${id}" class="bib-item"><div class="csl-bib-body">${tempDiv.innerHTML}</div></div>`).firstElementChild;
173
193
  const comment = createCommentMarker('div', id);
174
194
  element.prepend(comment);
175
195
  addTrackChangesAttributes(node.attrs, element);
@@ -38,7 +38,11 @@ export class CitationView extends BaseNodeView {
38
38
  }
39
39
  const id = this.node.attrs.id;
40
40
  const text = bib.renderedCitations.get(id);
41
- const fragment = sanitize(text && text !== '[NO_PRINTED_FORM]' ? text : ' ', {
41
+ const fragment = sanitize(text === '(n.d.)'
42
+ ? 'Missing citation data'
43
+ : text && text !== '[NO_PRINTED_FORM]'
44
+ ? text
45
+ : ' ', {
42
46
  ALLOWED_TAGS: ['i', 'b', 'span', 'sup', 'sub', '#text'],
43
47
  });
44
48
  this.dom.innerHTML = '';
@@ -16,10 +16,10 @@
16
16
  import { ContextMenu, FileCorruptedIcon, ImageDefaultIcon, ImageLeftIcon, ImageRightIcon, } from '@manuscripts/style-guide';
17
17
  import { schema } from '@manuscripts/transform';
18
18
  import { NodeSelection } from 'prosemirror-state';
19
+ import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
19
20
  import { createElement } from 'react';
20
21
  import { renderToStaticMarkup } from 'react-dom/server';
21
22
  import { FigureOptions, } from '../components/views/FigureDropdown';
22
- import { groupFiles } from '../lib/files';
23
23
  import { isDeleted } from '../lib/track-changes-utils';
24
24
  import { updateNodeAttrs } from '../lib/view';
25
25
  import { createEditableNodeView } from './creators';
@@ -237,6 +237,7 @@ export class FigureEditableView extends FigureView {
237
237
  let handleUpload;
238
238
  let handleReplace;
239
239
  let handleDetach;
240
+ let handleDelete;
240
241
  const src = this.node.attrs.src;
241
242
  const files = this.props.getFiles();
242
243
  const file = src && files.filter((f) => f.id === src)[0];
@@ -259,17 +260,43 @@ export class FigureEditableView extends FigureView {
259
260
  if (can.uploadFile) {
260
261
  handleUpload = figureUploader(this.upload);
261
262
  }
263
+ if (can.detachFile) {
264
+ const countFigures = () => {
265
+ const element = findParentNodeOfTypeClosestToPos(this.view.state.doc.resolve(this.getPos()), schema.nodes.figure_element);
266
+ let count = 0;
267
+ element?.node.descendants((node) => {
268
+ if (node.type === schema.nodes.figure && !isDeleted(node)) {
269
+ count++;
270
+ }
271
+ });
272
+ return count;
273
+ };
274
+ const figureCount = countFigures();
275
+ handleDelete =
276
+ figureCount > 1
277
+ ? () => {
278
+ const currentCount = countFigures();
279
+ const pos = this.getPos();
280
+ if (currentCount <= 1) {
281
+ return;
282
+ }
283
+ const tr = this.view.state.tr;
284
+ tr.delete(pos, pos + this.node.nodeSize);
285
+ this.view.dispatch(tr);
286
+ }
287
+ : undefined;
288
+ }
262
289
  this.reactTools?.remove();
263
290
  if (this.props.dispatch && this.props.theme) {
264
- const files = this.props.getFiles();
265
- const doc = this.view.state.doc;
266
291
  const componentProps = {
267
292
  can,
268
- files: groupFiles(doc, files),
293
+ getDoc: () => this.view.state.doc,
294
+ getFiles: this.props.getFiles,
269
295
  onDownload: handleDownload,
270
296
  onUpload: handleUpload,
271
297
  onDetach: handleDetach,
272
298
  onReplace: handleReplace,
299
+ onDelete: handleDelete,
273
300
  };
274
301
  this.reactTools = ReactSubView(this.props, FigureOptions, componentProps, this.node, this.getPos, this.view);
275
302
  this.dom.insertBefore(this.reactTools, this.dom.firstChild);
@@ -13,21 +13,48 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import BlockView from './block_view';
16
+ import { schema } from '@manuscripts/transform';
17
+ import { addFigureBtnIcon } from '../icons';
17
18
  import { createNodeView } from './creators';
18
- export class FigureElementView extends BlockView {
19
+ import { ImageElementView } from './image_element';
20
+ export class FigureElementView extends ImageElementView {
19
21
  constructor() {
20
22
  super(...arguments);
21
23
  this.ignoreMutation = () => true;
22
24
  this.createElement = () => {
23
- this.container = document.createElement('div');
24
- this.container.classList.add('block');
25
- this.dom.appendChild(this.container);
26
- this.contentDOM = document.createElement('figure');
27
- this.contentDOM.classList.add('figure-block');
28
- this.contentDOM.setAttribute('id', this.node.attrs.id);
29
- this.container.appendChild(this.contentDOM);
25
+ super.createElement();
26
+ this.addFigureElementButtons();
30
27
  };
28
+ this.addFigure = () => {
29
+ const { state } = this.view;
30
+ const { tr } = state;
31
+ const figureElementPos = this.getPos();
32
+ let insertPos = figureElementPos + 1;
33
+ let lastFigureEndPos = insertPos;
34
+ let hasFigures = false;
35
+ this.node.forEach((node) => {
36
+ if (node.type === schema.nodes.figure) {
37
+ lastFigureEndPos = insertPos + node.nodeSize;
38
+ hasFigures = true;
39
+ }
40
+ insertPos += node.nodeSize;
41
+ });
42
+ const finalInsertPos = hasFigures ? lastFigureEndPos : figureElementPos + 1;
43
+ const figureNode = state.schema.nodes.figure.create();
44
+ tr.insert(finalInsertPos, figureNode);
45
+ this.view.dispatch(tr);
46
+ };
47
+ }
48
+ addFigureElementButtons() {
49
+ if (this.props.getCapabilities()?.editArticle) {
50
+ const addFigureBtn = Object.assign(document.createElement('button'), {
51
+ className: 'add-figure-button',
52
+ innerHTML: addFigureBtnIcon,
53
+ title: 'Add figure',
54
+ });
55
+ addFigureBtn.addEventListener('click', () => this.addFigure());
56
+ this.container.prepend(addFigureBtn);
57
+ }
31
58
  }
32
59
  }
33
60
  export default createNodeView(FigureElementView);
@@ -0,0 +1,33 @@
1
+ /*!
2
+ * © 2025 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import BlockView from './block_view';
17
+ import { createNodeView } from './creators';
18
+ export class ImageElementView extends BlockView {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.ignoreMutation = () => true;
22
+ }
23
+ createElement() {
24
+ this.container = document.createElement('div');
25
+ this.container.classList.add('block');
26
+ this.dom.appendChild(this.container);
27
+ this.contentDOM = document.createElement('figure');
28
+ this.contentDOM.classList.add('figure-block');
29
+ this.contentDOM.setAttribute('id', this.node.attrs.id);
30
+ this.container.appendChild(this.contentDOM);
31
+ }
32
+ }
33
+ export default createNodeView(ImageElementView);
@@ -0,0 +1,19 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { createEditableNodeView } from './creators';
17
+ import { EditableBlock } from './editable_block';
18
+ import { ImageElementView } from './image_element';
19
+ export default createEditableNodeView(EditableBlock(ImageElementView));
@@ -1,15 +1,18 @@
1
1
  import { Capabilities } from '@manuscripts/style-guide';
2
+ import { Node as ManuscriptNode } from 'prosemirror-model';
2
3
  import React from 'react';
3
- import { FileAttachment, ManuscriptFiles } from '../../lib/files';
4
+ import { FileAttachment } from '../../lib/files';
4
5
  export interface FigureDropdownProps {
5
6
  can: Capabilities;
6
- files: ManuscriptFiles;
7
+ getFiles: () => FileAttachment[];
7
8
  }
8
9
  export interface FigureOptionsProps extends FigureDropdownProps {
9
10
  onDownload?: () => void;
10
11
  onUpload?: () => void;
11
12
  onDetach?: () => void;
12
13
  onReplace?: (file: FileAttachment) => void;
14
+ getDoc: () => ManuscriptNode;
15
+ onDelete?: () => void;
13
16
  }
14
17
  export interface FigureElementOptionsProps extends FigureDropdownProps {
15
18
  onAdd: (file: FileAttachment) => Promise<void>;
@@ -7,3 +7,4 @@ export declare const sectionCategoryIcon: string;
7
7
  export declare const scrollIcon: string;
8
8
  export declare const lockIcon: string;
9
9
  export declare const plusIcon: string;
10
+ export declare const addFigureBtnIcon: string;
@@ -28,4 +28,5 @@ export type FileManagement = {
28
28
  download: Download;
29
29
  previewLink: PreviewLink;
30
30
  };
31
+ export declare function memoGroupFiles(): (doc: ManuscriptNode, files: FileAttachment[]) => ManuscriptFiles;
31
32
  export declare const groupFiles: (doc: ManuscriptNode, files: FileAttachment[]) => ManuscriptFiles;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.2.3";
1
+ export declare const VERSION = "3.2.5";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
@@ -13,13 +13,12 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { FigureElementNode } from '@manuscripts/transform';
17
- import { Trackable } from '../types';
18
- import BlockView from './block_view';
19
- export declare class FigureElementView extends BlockView<Trackable<FigureElementNode>> {
20
- private container;
16
+ import { ImageElementView } from './image_element';
17
+ export declare class FigureElementView extends ImageElementView {
21
18
  ignoreMutation: () => boolean;
22
19
  createElement: () => void;
20
+ private addFigureElementButtons;
21
+ private addFigure;
23
22
  }
24
23
  declare const _default: (props: import("../configs/ManuscriptsEditor").EditorProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<FigureElementView>;
25
24
  export default _default;
@@ -0,0 +1,25 @@
1
+ /*!
2
+ * © 2025 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { FigureElementNode } from '@manuscripts/transform';
17
+ import { Trackable } from '../types';
18
+ import BlockView from './block_view';
19
+ export declare class ImageElementView extends BlockView<Trackable<FigureElementNode>> {
20
+ container: HTMLElement;
21
+ ignoreMutation: () => boolean;
22
+ createElement(): void;
23
+ }
24
+ declare const _default: (props: import("../configs/ManuscriptsEditor").EditorProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<ImageElementView>;
25
+ export default _default;
@@ -0,0 +1,44 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { ImageElementView } from './image_element';
17
+ declare const _default: (props: import("../configs/ManuscriptsEditor").EditorProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<{
18
+ gutterButtons(): HTMLElement[];
19
+ actionGutterButtons(): never[];
20
+ createAddButton(): HTMLAnchorElement | null;
21
+ createEditButton(): HTMLElement | null;
22
+ createMenu: () => import("../lib/context-menu").ContextMenu;
23
+ initialise(): void;
24
+ updateContents(): void;
25
+ handleTrackChanges(): void;
26
+ updateClasses(): void;
27
+ updatePlaceholder(): void;
28
+ createElement(): void;
29
+ createDOM(): void;
30
+ gutter: Record<string, HTMLElement>;
31
+ createGutter(className: string, buttons: HTMLElement[]): void;
32
+ dom: HTMLElement;
33
+ contentDOM?: HTMLElement | undefined;
34
+ elementType: string;
35
+ readonly props: import("../configs/ManuscriptsEditor").EditorProps;
36
+ node: import("prosemirror-model").Node;
37
+ readonly view: import("prosemirror-view").EditorView;
38
+ readonly getPos: () => number;
39
+ update(newNode: import("prosemirror-model").Node): boolean;
40
+ selectNode(): void;
41
+ deselectNode(): void;
42
+ destroy(): void;
43
+ } & ImageElementView>;
44
+ export default _default;
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": "3.2.3",
4
+ "version": "3.2.5",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -122,6 +122,8 @@
122
122
  text-indent: 0pt;
123
123
  }
124
124
 
125
+ /* Figures */
126
+
125
127
  .ProseMirror .figure-block {
126
128
  width: 100%;
127
129
  border: 1px solid #f2f2f2;
@@ -132,6 +134,11 @@
132
134
 
133
135
  grid-template-columns: repeat(3, auto) !important;
134
136
  grid-template-rows: repeat(1, minmax(min-content, max-content)) [caption listing] auto !important;
137
+
138
+ margin: 16px 0 0 !important;
139
+ box-sizing: border-box;
140
+ justify-self: center;
141
+ position: relative;
135
142
  }
136
143
 
137
144
  .ProseMirror .figure-group {
@@ -144,8 +151,140 @@
144
151
  width: 100%;
145
152
  position: relative;
146
153
  grid-column: 1/-1;
154
+ margin: 0;
155
+ display: flex;
156
+ flex-direction: column;
157
+ justify-content: flex-end;
158
+ align-items: center;
159
+ }
160
+
161
+ .ProseMirror .figure-images-container .figure-image-container {
162
+ position: relative;
163
+ margin-bottom: 30px;
164
+ }
165
+
166
+ .ProseMirror .block-figure_element .add-figure-button {
167
+ border: 0px;
168
+ left: 53px;
169
+ width: 25px;
170
+ z-index: 1;
171
+ height: 25px;
172
+ bottom: 220px;
173
+ cursor: pointer;
174
+ position: absolute;
175
+ border-radius: 50%;
176
+ background-color: #6E6E6E;
177
+ }
178
+
179
+ .ProseMirror .block-figure_element .add-figure-button.disabled {
180
+ background-color: #E2E2E2 !important;
181
+ }
182
+
183
+ .ProseMirror .block-figure_element .add-figure-button svg path {
184
+ fill: #FFFFFF !important;
185
+ }
186
+
187
+
188
+ .ProseMirror .figure-block:hover .options-button {
189
+ visibility: visible;
190
+ }
191
+
192
+ .ProseMirror .block:focus-within .figure-block,
193
+ .ProseMirror .block:hover .figure-block {
194
+ border-color: #e2e2e2;
195
+ }
196
+
197
+ .ProseMirror .figure-block[data-alignment='left'] {
198
+ justify-self: flex-start;
199
+ }
200
+
201
+ .ProseMirror .figure-block[data-alignment='right'] {
202
+ justify-self: flex-end;
203
+ }
204
+
205
+ .ProseMirror .figure-block .expanded-listing .executable-attachments {
206
+ display: block;
207
+ }
208
+
209
+ .ProseMirror .figure-block > .listing {
210
+ grid-column-start: 1;
211
+ grid-column-end: -1;
212
+ padding: 0;
213
+ min-height: 0;
214
+ overflow: visible;
215
+ width: 100%;
216
+ }
217
+
218
+ .ProseMirror .figure-block figure {
219
+ padding-bottom: 20px;
220
+ }
221
+
222
+ .ProseMirror .figure-block > figcaption {
223
+ grid-column-start: 1;
224
+ grid-column-end: -1;
225
+ margin-top: 30px;
226
+ }
227
+
228
+ .ProseMirror .figure-caption {
229
+ display: none;
230
+ }
231
+
232
+ .ProseMirror .figure.placeholder {
233
+ align-items: center;
234
+ border-radius: 16px;
235
+ border: 1px dashed #e2e2e2;
236
+ background-color: #fafafa;
237
+ cursor: pointer;
238
+ display: flex;
239
+ justify-content: center;
240
+ text-align: center;
241
+ padding: 64px 32px;
242
+ max-width: 210px;
243
+ min-height: 100px;
244
+ white-space: normal;
245
+ font-size: 14px;
147
246
  }
148
247
 
248
+ .ProseMirror .figure.placeholder a {
249
+ text-decoration: underline;
250
+ }
251
+
252
+ .ProseMirror .figure.placeholder.over {
253
+ border-color: #bce7f6;
254
+ }
255
+
256
+ .ProseMirror .figure-image {
257
+ max-width: 100%;
258
+ object-fit: contain;
259
+ }
260
+
261
+ .ProseMirror .figure-embed {
262
+ width: 640px;
263
+ max-width: 90%;
264
+ position: relative;
265
+ padding-top: 56.25%; /* Player ratio: 100 / (1280 / 720) */
266
+ }
267
+
268
+ .ProseMirror .figure-embed .figure-embed-object {
269
+ position: absolute;
270
+ top: 0;
271
+ left: 0;
272
+ border: none;
273
+ }
274
+
275
+ .ProseMirror figcaption {
276
+ background: white;
277
+ font-size: 14px;
278
+ margin-top: 1em;
279
+ text-align: center;
280
+ word-wrap: break-word;
281
+ }
282
+
283
+ .ProseMirror .block-table_element figcaption {
284
+ text-align: left;
285
+ }
286
+
287
+
149
288
  .ProseMirror .figure-block > figcaption .figure-label {
150
289
  display: initial !important;
151
290
  }
@@ -683,6 +822,10 @@ span.comment-marker {
683
822
  text-decoration: line-through;
684
823
  }
685
824
 
825
+ .tracking-visible .ProseMirror figure.deleted {
826
+ display: flex;
827
+ }
828
+
686
829
  .tracking-visible .ProseMirror .block.deleted {
687
830
  display: block;
688
831
  }
@@ -794,10 +937,18 @@ figure.block:has(.equation.selected-suggestion) {
794
937
  .tracking-visible
795
938
  .ProseMirror
796
939
  [data-track-status='pending'][data-track-op='delete']
797
- .block {
940
+ .block, .tracking-visible
941
+ .ProseMirror .figure-block
942
+ figure[data-track-status='pending'].deleted img {
798
943
  box-shadow: inset 3px 0 0 var(--deleted-color);
799
944
  }
800
945
 
946
+ .tracking-visible
947
+ .ProseMirror .figure-block
948
+ figure[data-track-status='pending'].deleted img {
949
+ padding-left: 3px;
950
+ }
951
+
801
952
  .selected-suggestion[data-track-status='pending'][data-track-op='delete']
802
953
  .block,
803
954
  .selected-suggestion[data-track-status='pending'][data-track-op='delete']
package/styles/Editor.css CHANGED
@@ -277,120 +277,6 @@
277
277
  background-color: #bce7f6;
278
278
  }
279
279
 
280
- .ProseMirror .figure-block {
281
- border: 1px solid transparent;
282
- border-radius: 4px;
283
- display: grid;
284
- gap: 20px 40px;
285
- margin: 16px 0 0;
286
- box-sizing: border-box;
287
- justify-self: center;
288
- position: relative;
289
- }
290
-
291
- .ProseMirror .figure-block:hover .options-button {
292
- visibility: visible;
293
- }
294
-
295
- .ProseMirror .block:focus-within .figure-block,
296
- .ProseMirror .block:hover .figure-block {
297
- border-color: #e2e2e2;
298
- }
299
-
300
- .ProseMirror .figure-block[data-alignment='left'] {
301
- justify-self: flex-start;
302
- }
303
-
304
- .ProseMirror .figure-block[data-alignment='right'] {
305
- justify-self: flex-end;
306
- }
307
-
308
- .ProseMirror .figure-block .expanded-listing .executable-attachments {
309
- display: block;
310
- }
311
-
312
- .ProseMirror .figure-block figure {
313
- margin: 0;
314
- display: flex;
315
- flex-direction: column;
316
- justify-content: flex-end;
317
- align-items: center;
318
- }
319
-
320
- .ProseMirror .figure-block > .listing {
321
- grid-column-start: 1;
322
- grid-column-end: -1;
323
- padding: 0;
324
- min-height: 0;
325
- overflow: visible;
326
- width: 100%;
327
- }
328
-
329
- .ProseMirror .figure-block > figcaption {
330
- grid-column-start: 1;
331
- grid-column-end: -1;
332
- margin-top: 0;
333
- }
334
-
335
- .ProseMirror .figure-caption {
336
- display: none;
337
- }
338
-
339
- .ProseMirror .figure.placeholder {
340
- align-items: center;
341
- border-radius: 16px;
342
- border: 1px dashed #e2e2e2;
343
- background-color: #fafafa;
344
- cursor: pointer;
345
- display: flex;
346
- justify-content: center;
347
- text-align: center;
348
- padding: 64px 32px;
349
- max-width: 210px;
350
- min-height: 100px;
351
- white-space: normal;
352
- font-size: 14px;
353
- }
354
-
355
- .ProseMirror .figure.placeholder a {
356
- text-decoration: underline;
357
- }
358
-
359
- .ProseMirror .figure.placeholder.over {
360
- border-color: #bce7f6;
361
- }
362
-
363
- .ProseMirror .figure-image {
364
- max-width: 100%;
365
- object-fit: contain;
366
- }
367
-
368
- .ProseMirror .figure-embed {
369
- width: 640px;
370
- max-width: 90%;
371
- position: relative;
372
- padding-top: 56.25%; /* Player ratio: 100 / (1280 / 720) */
373
- }
374
-
375
- .ProseMirror .figure-embed .figure-embed-object {
376
- position: absolute;
377
- top: 0;
378
- left: 0;
379
- border: none;
380
- }
381
-
382
- .ProseMirror figcaption {
383
- background: white;
384
- font-size: 14px;
385
- margin-top: 1em;
386
- text-align: center;
387
- word-wrap: break-word;
388
- }
389
-
390
- .ProseMirror .block-table_element figcaption {
391
- text-align: left;
392
- }
393
-
394
280
  .ProseMirror .block-table_element .block-gutter {
395
281
  padding-top: 1em;
396
282
  }