@manuscripts/body-editor 2.7.19-LEAN-4231.0 → 2.7.19

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.
@@ -145,9 +145,6 @@ const createBlock = (nodeType, position, state, dispatch, attrs) => {
145
145
  case state.schema.nodes.figure_element:
146
146
  node = createAndFillFigureElement(state);
147
147
  break;
148
- case state.schema.nodes.image_element:
149
- node = createImageElement(state);
150
- break;
151
148
  case state.schema.nodes.listing_element:
152
149
  node = state.schema.nodes.listing_element.create({}, [
153
150
  state.schema.nodes.listing.create(),
@@ -993,9 +990,6 @@ const createAndFillFigcaptionElement = (state) => state.schema.nodes.figcaption.
993
990
  state.schema.nodes.caption_title.create(),
994
991
  state.schema.nodes.caption.create(),
995
992
  ]);
996
- const createImageElement = (state) => state.schema.nodes.image_element.create({}, [
997
- state.schema.nodes.figure.create(),
998
- ]);
999
993
  const getParentNode = (selection) => {
1000
994
  var _a;
1001
995
  const parentNode = (0, utils_1.findParentNodeWithId)(selection);
@@ -311,10 +311,20 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
311
311
  items: [author],
312
312
  });
313
313
  };
314
- const handleMoveAuthor = (from, to) => {
315
- const copy = [...authors];
316
- const order = copy.map((_, i) => (i === from ? to : i));
317
- copy.sort((a, b) => order[authors.indexOf(a)] - order[authors.indexOf(b)]);
314
+ const handleMoveAuthor = (from, to, shift) => {
315
+ const copy = (0, lodash_1.cloneDeep)(authors);
316
+ const order = copy.map((a, i) => {
317
+ if (a.id === from.id) {
318
+ if (to.priority) {
319
+ return to.priority + shift;
320
+ }
321
+ else {
322
+ return authors.findIndex((i) => i === to) + shift;
323
+ }
324
+ }
325
+ return i;
326
+ });
327
+ copy.sort((a, b) => order[copy.indexOf(a)] - order[copy.indexOf(b)]);
318
328
  copy.forEach((a, i) => {
319
329
  if (a.priority !== i) {
320
330
  a.priority = i;
@@ -161,10 +161,8 @@ exports.DraggableAuthor = react_1.default.memo(({ author, isSelected, onClick, o
161
161
  return;
162
162
  }
163
163
  const side = (0, dnd_1.getDropSide)(ref.current, monitor);
164
- const from = item.author.priority;
165
- const to = author.priority;
166
164
  const diff = side === 'before' ? -0.5 : 0.5;
167
- moveAuthor(from, to + diff);
165
+ moveAuthor(item.author, author, diff);
168
166
  },
169
167
  collect: (monitor) => ({
170
168
  isOver: monitor.isOver(),
@@ -44,6 +44,7 @@ const excludedTypes = [
44
44
  transform_1.schema.nodes.contributors,
45
45
  transform_1.schema.nodes.author_notes,
46
46
  transform_1.schema.nodes.title,
47
+ transform_1.schema.nodes.image_element,
47
48
  ];
48
49
  const childrenExcludedTypes = [
49
50
  transform_1.schema.nodes.pullquote_element,
@@ -70,7 +70,6 @@ exports.default = (props, dispatch) => {
70
70
  equation_element: (0, equation_element_editable_1.default)(props),
71
71
  figure: (0, figure_editable_1.default)(props, dispatch),
72
72
  figure_element: (0, figure_element_editable_1.default)(props, dispatch),
73
- image_element: (0, figure_element_editable_1.default)(props, dispatch),
74
73
  footnote: (0, footnote_1.default)(props),
75
74
  footnotes_element: (0, footnotes_element_1.default)(props),
76
75
  general_table_footnote: (0, general_table_footnote_1.default)(props, dispatch),
@@ -52,9 +52,7 @@ const groupFiles = (doc, files) => {
52
52
  figures.push(getFigureElementFiles(element.node, element.pos));
53
53
  }
54
54
  doc.descendants((node, pos) => {
55
- if ((node.type === transform_1.schema.nodes.figure_element ||
56
- node.type === transform_1.schema.nodes.image_element) &&
57
- node.attrs.id !== gaID) {
55
+ if (node.type === transform_1.schema.nodes.figure_element && node.attrs.id !== gaID) {
58
56
  figures.push(getFigureElementFiles(node, pos));
59
57
  }
60
58
  if (node.type === transform_1.schema.nodes.supplement) {
@@ -121,7 +121,10 @@ exports.getActualTextContent = getActualTextContent;
121
121
  function sanitizeAttrsChange(newAttr, currentAttrs) {
122
122
  return Object.keys(newAttr).reduce((acc, attr) => {
123
123
  const key = attr;
124
- if (!currentAttrs[key] && currentAttrs[key] !== 0 && !newAttr[key]) {
124
+ if (!currentAttrs[key] &&
125
+ currentAttrs[key] !== 0 &&
126
+ !newAttr[key] &&
127
+ newAttr[key] !== 0) {
125
128
  return acc;
126
129
  }
127
130
  acc[key] = newAttr[key];
package/dist/cjs/menus.js CHANGED
@@ -199,12 +199,6 @@ const getEditorMenus = (editor) => {
199
199
  isEnabled: isCommandValid((0, commands_1.canInsert)(transform_1.schema.nodes.figure_element)),
200
200
  run: doCommand((0, commands_1.insertBlock)(transform_1.schema.nodes.figure_element)),
201
201
  },
202
- {
203
- id: 'insert-image-element',
204
- label: 'Simple Image',
205
- isEnabled: isCommandValid((0, commands_1.canInsert)(transform_1.schema.nodes.image_element)),
206
- run: doCommand((0, commands_1.insertBlock)(transform_1.schema.nodes.image_element)),
207
- },
208
202
  {
209
203
  id: 'insert-table-element',
210
204
  label: 'Table',
@@ -23,7 +23,6 @@ const style_guide_1 = require("@manuscripts/style-guide");
23
23
  const transform_1 = require("@manuscripts/transform");
24
24
  const react_1 = __importDefault(require("react"));
25
25
  const { nodes } = transform_1.schema;
26
- const OutlineImageIcon = () => (react_1.default.createElement(style_guide_1.FileImageIcon, { width: "11", height: "14" }));
27
26
  const icons = new Map([
28
27
  [nodes.manuscript, style_guide_1.OutlineManuscriptIcon],
29
28
  [nodes.bibliography_section, style_guide_1.OutlineSectionIcon],
@@ -37,7 +36,6 @@ const icons = new Map([
37
36
  [nodes.table_element, style_guide_1.OutlineTableIcon],
38
37
  [nodes.graphical_abstract_section, style_guide_1.OutlineSectionIcon],
39
38
  [nodes.footnotes_section, style_guide_1.OutlineSectionIcon],
40
- [nodes.image_element, OutlineImageIcon],
41
39
  ]);
42
40
  const nodeTypeIcon = (nodeType, listType) => {
43
41
  if (nodeType === transform_1.schema.nodes.list) {
@@ -46,21 +46,15 @@ exports.default = () => {
46
46
  if (target && !isInGraphicalAbstract) {
47
47
  const labelNode = document.createElement('span');
48
48
  labelNode.className = 'figure-label';
49
- if (node.type.name === 'image_element') {
50
- labelNode.textContent = target.label;
51
- decorations.push(prosemirror_view_1.Decoration.widget(pos + node.nodeSize - 1, labelNode));
52
- }
53
- else {
54
- labelNode.textContent = target.label + ':';
55
- node.forEach((child, offset) => {
56
- if (child.type.name === 'figcaption') {
57
- decorations.push(prosemirror_view_1.Decoration.widget(pos + 1 + offset + 1, labelNode, {
58
- side: -1,
59
- key: `figure-label-${id}-${target.label}`,
60
- }));
61
- }
62
- });
63
- }
49
+ labelNode.textContent = target.label + ':';
50
+ node.forEach((child, offset) => {
51
+ if (child.type.name === 'figcaption') {
52
+ decorations.push(prosemirror_view_1.Decoration.widget(pos + 1 + offset + 1, labelNode, {
53
+ side: -1,
54
+ key: `figure-label-${id}-${target.label}`,
55
+ }));
56
+ }
57
+ });
64
58
  }
65
59
  }
66
60
  });
@@ -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.7.19-LEAN-4231.0';
4
+ exports.VERSION = '2.7.19';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -94,10 +94,8 @@ class FigureEditableView extends figure_1.FigureView {
94
94
  var _a;
95
95
  super.updateContents();
96
96
  const attrs = this.node.attrs;
97
- console.log('attrs:', attrs);
98
97
  const src = attrs.src;
99
98
  const files = this.props.getFiles();
100
- console.log('files:', files);
101
99
  const file = src && files.filter((f) => f.id === src)[0];
102
100
  this.container.innerHTML = '';
103
101
  const can = this.props.getCapabilities();
@@ -135,9 +135,6 @@ export const createBlock = (nodeType, position, state, dispatch, attrs) => {
135
135
  case state.schema.nodes.figure_element:
136
136
  node = createAndFillFigureElement(state);
137
137
  break;
138
- case state.schema.nodes.image_element:
139
- node = createImageElement(state);
140
- break;
141
138
  case state.schema.nodes.listing_element:
142
139
  node = state.schema.nodes.listing_element.create({}, [
143
140
  state.schema.nodes.listing.create(),
@@ -944,9 +941,6 @@ const createAndFillFigcaptionElement = (state) => state.schema.nodes.figcaption.
944
941
  state.schema.nodes.caption_title.create(),
945
942
  state.schema.nodes.caption.create(),
946
943
  ]);
947
- const createImageElement = (state) => state.schema.nodes.image_element.create({}, [
948
- state.schema.nodes.figure.create(),
949
- ]);
950
944
  const getParentNode = (selection) => {
951
945
  var _a;
952
946
  const parentNode = findParentNodeWithId(selection);
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { buildBibliographicName, generateID, ObjectTypes, } from '@manuscripts/json-schema';
17
17
  import { AddIcon, AddInstitutionIcon, AuthorPlaceholderIcon, CloseButton, Drawer, ModalBody, ModalContainer, ModalHeader, ModalSidebar, ModalSidebarHeader, ModalSidebarTitle, ScrollableModalContent, SelectedItemsBox, SidebarContent, StyledModal, } from '@manuscripts/style-guide';
18
- import { isEqual, omit } from 'lodash';
18
+ import { cloneDeep, isEqual, omit } from 'lodash';
19
19
  import React, { useEffect, useReducer, useRef, useState } from 'react';
20
20
  import styled from 'styled-components';
21
21
  import { arrayReducer } from '../../lib/array-reducer';
@@ -282,10 +282,20 @@ export const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, a
282
282
  items: [author],
283
283
  });
284
284
  };
285
- const handleMoveAuthor = (from, to) => {
286
- const copy = [...authors];
287
- const order = copy.map((_, i) => (i === from ? to : i));
288
- copy.sort((a, b) => order[authors.indexOf(a)] - order[authors.indexOf(b)]);
285
+ const handleMoveAuthor = (from, to, shift) => {
286
+ const copy = cloneDeep(authors);
287
+ const order = copy.map((a, i) => {
288
+ if (a.id === from.id) {
289
+ if (to.priority) {
290
+ return to.priority + shift;
291
+ }
292
+ else {
293
+ return authors.findIndex((i) => i === to) + shift;
294
+ }
295
+ }
296
+ return i;
297
+ });
298
+ copy.sort((a, b) => order[copy.indexOf(a)] - order[copy.indexOf(b)]);
289
299
  copy.forEach((a, i) => {
290
300
  if (a.priority !== i) {
291
301
  a.priority = i;
@@ -132,10 +132,8 @@ export const DraggableAuthor = React.memo(({ author, isSelected, onClick, onDele
132
132
  return;
133
133
  }
134
134
  const side = getDropSide(ref.current, monitor);
135
- const from = item.author.priority;
136
- const to = author.priority;
137
135
  const diff = side === 'before' ? -0.5 : 0.5;
138
- moveAuthor(from, to + diff);
136
+ moveAuthor(item.author, author, diff);
139
137
  },
140
138
  collect: (monitor) => ({
141
139
  isOver: monitor.isOver(),
@@ -18,6 +18,7 @@ const excludedTypes = [
18
18
  schema.nodes.contributors,
19
19
  schema.nodes.author_notes,
20
20
  schema.nodes.title,
21
+ schema.nodes.image_element,
21
22
  ];
22
23
  const childrenExcludedTypes = [
23
24
  schema.nodes.pullquote_element,
@@ -65,7 +65,6 @@ export default (props, dispatch) => {
65
65
  equation_element: equationElement(props),
66
66
  figure: figure(props, dispatch),
67
67
  figure_element: figureElement(props, dispatch),
68
- image_element: figureElement(props, dispatch),
69
68
  footnote: footnote(props),
70
69
  footnotes_element: footnotesElement(props),
71
70
  general_table_footnote: generalTableFootnote(props, dispatch),
@@ -49,9 +49,7 @@ export const groupFiles = (doc, files) => {
49
49
  figures.push(getFigureElementFiles(element.node, element.pos));
50
50
  }
51
51
  doc.descendants((node, pos) => {
52
- if ((node.type === schema.nodes.figure_element ||
53
- node.type === schema.nodes.image_element) &&
54
- node.attrs.id !== gaID) {
52
+ if (node.type === schema.nodes.figure_element && node.attrs.id !== gaID) {
55
53
  figures.push(getFigureElementFiles(node, pos));
56
54
  }
57
55
  if (node.type === schema.nodes.supplement) {
@@ -108,7 +108,10 @@ export function getActualTextContent(fragment) {
108
108
  export function sanitizeAttrsChange(newAttr, currentAttrs) {
109
109
  return Object.keys(newAttr).reduce((acc, attr) => {
110
110
  const key = attr;
111
- if (!currentAttrs[key] && currentAttrs[key] !== 0 && !newAttr[key]) {
111
+ if (!currentAttrs[key] &&
112
+ currentAttrs[key] !== 0 &&
113
+ !newAttr[key] &&
114
+ newAttr[key] !== 0) {
112
115
  return acc;
113
116
  }
114
117
  acc[key] = newAttr[key];
package/dist/es/menus.js CHANGED
@@ -196,12 +196,6 @@ export const getEditorMenus = (editor) => {
196
196
  isEnabled: isCommandValid(canInsert(schema.nodes.figure_element)),
197
197
  run: doCommand(insertBlock(schema.nodes.figure_element)),
198
198
  },
199
- {
200
- id: 'insert-image-element',
201
- label: 'Simple Image',
202
- isEnabled: isCommandValid(canInsert(schema.nodes.image_element)),
203
- run: doCommand(insertBlock(schema.nodes.image_element)),
204
- },
205
199
  {
206
200
  id: 'insert-table-element',
207
201
  label: 'Table',
@@ -13,11 +13,10 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { FileImageIcon, OutlineBlockQuoteIcon, OutlineEmbedIcon, OutlineEquationIcon, OutlineFigureIcon, OutlineManuscriptIcon, OutlineOrderedListIcon, OutlineParagraphIcon, OutlinePullQuoteIcon, OutlineSectionIcon, OutlineTableIcon, OutlineUnorderedListIcon, } from '@manuscripts/style-guide';
16
+ import { OutlineBlockQuoteIcon, OutlineEmbedIcon, OutlineEquationIcon, OutlineFigureIcon, OutlineManuscriptIcon, OutlineOrderedListIcon, OutlineParagraphIcon, OutlinePullQuoteIcon, OutlineSectionIcon, OutlineTableIcon, OutlineUnorderedListIcon, } from '@manuscripts/style-guide';
17
17
  import { schema } from '@manuscripts/transform';
18
18
  import React from 'react';
19
19
  const { nodes } = schema;
20
- const OutlineImageIcon = () => (React.createElement(FileImageIcon, { width: "11", height: "14" }));
21
20
  const icons = new Map([
22
21
  [nodes.manuscript, OutlineManuscriptIcon],
23
22
  [nodes.bibliography_section, OutlineSectionIcon],
@@ -31,7 +30,6 @@ const icons = new Map([
31
30
  [nodes.table_element, OutlineTableIcon],
32
31
  [nodes.graphical_abstract_section, OutlineSectionIcon],
33
32
  [nodes.footnotes_section, OutlineSectionIcon],
34
- [nodes.image_element, OutlineImageIcon],
35
33
  ]);
36
34
  export const nodeTypeIcon = (nodeType, listType) => {
37
35
  if (nodeType === schema.nodes.list) {
@@ -43,21 +43,15 @@ export default () => {
43
43
  if (target && !isInGraphicalAbstract) {
44
44
  const labelNode = document.createElement('span');
45
45
  labelNode.className = 'figure-label';
46
- if (node.type.name === 'image_element') {
47
- labelNode.textContent = target.label;
48
- decorations.push(Decoration.widget(pos + node.nodeSize - 1, labelNode));
49
- }
50
- else {
51
- labelNode.textContent = target.label + ':';
52
- node.forEach((child, offset) => {
53
- if (child.type.name === 'figcaption') {
54
- decorations.push(Decoration.widget(pos + 1 + offset + 1, labelNode, {
55
- side: -1,
56
- key: `figure-label-${id}-${target.label}`,
57
- }));
58
- }
59
- });
60
- }
46
+ labelNode.textContent = target.label + ':';
47
+ node.forEach((child, offset) => {
48
+ if (child.type.name === 'figcaption') {
49
+ decorations.push(Decoration.widget(pos + 1 + offset + 1, labelNode, {
50
+ side: -1,
51
+ key: `figure-label-${id}-${target.label}`,
52
+ }));
53
+ }
54
+ });
61
55
  }
62
56
  }
63
57
  });
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.7.19-LEAN-4231.0';
1
+ export const VERSION = '2.7.19';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -88,10 +88,8 @@ export class FigureEditableView extends FigureView {
88
88
  var _a;
89
89
  super.updateContents();
90
90
  const attrs = this.node.attrs;
91
- console.log('attrs:', attrs);
92
91
  const src = attrs.src;
93
92
  const files = this.props.getFiles();
94
- console.log('files:', files);
95
93
  const file = src && files.filter((f) => f.id === src)[0];
96
94
  this.container.innerHTML = '';
97
95
  const can = this.props.getCapabilities();
@@ -20,7 +20,7 @@ interface AuthorListProps {
20
20
  authors: ContributorAttrs[];
21
21
  onSelect: (item: ContributorAttrs) => void;
22
22
  onDelete: () => void;
23
- moveAuthor: (index: number, target: number) => void;
23
+ moveAuthor: (from: ContributorAttrs, to: ContributorAttrs, shift: number) => void;
24
24
  lastSavedAuthor: string | null;
25
25
  }
26
26
  export declare const AuthorList: React.FC<AuthorListProps>;
@@ -20,7 +20,7 @@ interface DraggableAuthorProps {
20
20
  isSelected: boolean;
21
21
  onClick: () => void;
22
22
  onDelete: () => void;
23
- moveAuthor: (from: number, to: number) => void;
23
+ moveAuthor: (from: ContributorAttrs, to: ContributorAttrs, shift: number) => void;
24
24
  showSuccessIcon?: boolean;
25
25
  }
26
26
  export declare const DraggableAuthor: React.FC<DraggableAuthorProps>;
@@ -104,32 +104,6 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
104
104
  deselectNode(): void;
105
105
  destroy(): void;
106
106
  } & import("../views/figure_element").FigureElementView>;
107
- image_element: import("../types").NodeViewCreator<{
108
- gutterButtons(): HTMLElement[];
109
- actionGutterButtons(): never[];
110
- createAddButton(): HTMLAnchorElement | null;
111
- createEditButton(): HTMLElement | null;
112
- createMenu: () => import("../lib/context-menu").ContextMenu;
113
- initialise(): void;
114
- updateContents(): void;
115
- handleTrackChanges(): void;
116
- updateClasses(): void;
117
- updatePlaceholder(): void;
118
- createElement(): void;
119
- createDOM(): void;
120
- createGutter(className: string, buttons: HTMLElement[]): void;
121
- dom: HTMLElement;
122
- contentDOM?: HTMLElement | undefined;
123
- elementType: string;
124
- readonly props: EditorProps;
125
- node: import("prosemirror-model").Node;
126
- readonly view: import("prosemirror-view").EditorView;
127
- readonly getPos: () => number;
128
- update(newNode: import("prosemirror-model").Node): boolean;
129
- selectNode(): void;
130
- deselectNode(): void;
131
- destroy(): void;
132
- } & import("../views/figure_element").FigureElementView>;
133
107
  footnote: import("../types").NodeViewCreator<import("../views/footnote").FootnoteView>;
134
108
  footnotes_element: import("../types").NodeViewCreator<import("../views/footnotes_element").FootnotesElementView>;
135
109
  general_table_footnote: import("../types").NodeViewCreator<import("../views/general_table_footnote").GeneralTableFootnoteView>;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.7.19-LEAN-4231.0";
1
+ export declare const VERSION = "2.7.19";
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.7.19-LEAN-4231.0",
4
+ "version": "2.7.19",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -34,7 +34,7 @@
34
34
  "@manuscripts/library": "1.3.11",
35
35
  "@manuscripts/style-guide": "2.0.32",
36
36
  "@manuscripts/track-changes-plugin": "1.9.2",
37
- "@manuscripts/transform": "3.0.37-LEAN-4231.0",
37
+ "@manuscripts/transform": "3.0.36",
38
38
  "@popperjs/core": "^2.11.8",
39
39
  "astrocite-eutils": "^0.16.4",
40
40
  "codemirror": "^5.58.1",
package/styles/Editor.css CHANGED
@@ -348,17 +348,10 @@
348
348
 
349
349
  .ProseMirror .figure-label {
350
350
  font-weight: bold;
351
- font-size: 14px;
352
351
  margin-right: 5px;
353
352
  white-space: nowrap;
354
353
  }
355
354
 
356
- .block-image_element .figure-label {
357
- text-align: center;
358
- grid-column-start: 1;
359
- grid-column-end: -1;
360
- }
361
-
362
355
  .ProseMirror .executable-container {
363
356
  width: 100%;
364
357
  position: relative;