@manuscripts/body-editor 2.7.21 → 2.7.24

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,6 +145,9 @@ 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;
148
151
  case state.schema.nodes.listing_element:
149
152
  node = state.schema.nodes.listing_element.create({}, [
150
153
  state.schema.nodes.listing.create(),
@@ -990,6 +993,9 @@ const createAndFillFigcaptionElement = (state) => state.schema.nodes.figcaption.
990
993
  state.schema.nodes.caption_title.create(),
991
994
  state.schema.nodes.caption.create(),
992
995
  ]);
996
+ const createImageElement = (state) => state.schema.nodes.image_element.create({}, [
997
+ state.schema.nodes.figure.create(),
998
+ ]);
993
999
  const getParentNode = (selection) => {
994
1000
  var _a;
995
1001
  const parentNode = (0, utils_1.findParentNodeWithId)(selection);
@@ -44,7 +44,6 @@ 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,
48
47
  ];
49
48
  const childrenExcludedTypes = [
50
49
  transform_1.schema.nodes.pullquote_element,
@@ -70,6 +70,7 @@ 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),
73
74
  footnote: (0, footnote_1.default)(props),
74
75
  footnotes_element: (0, footnotes_element_1.default)(props),
75
76
  general_table_footnote: (0, general_table_footnote_1.default)(props, dispatch),
@@ -52,7 +52,9 @@ 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 && node.attrs.id !== gaID) {
55
+ if ((node.type === transform_1.schema.nodes.figure_element ||
56
+ node.type === transform_1.schema.nodes.image_element) &&
57
+ node.attrs.id !== gaID) {
56
58
  figures.push(getFigureElementFiles(node, pos));
57
59
  }
58
60
  if (node.type === transform_1.schema.nodes.supplement) {
package/dist/cjs/menus.js CHANGED
@@ -199,6 +199,12 @@ 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
+ },
202
208
  {
203
209
  id: 'insert-table-element',
204
210
  label: 'Table',
@@ -23,6 +23,7 @@ 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" }));
26
27
  const icons = new Map([
27
28
  [nodes.manuscript, style_guide_1.OutlineManuscriptIcon],
28
29
  [nodes.bibliography_section, style_guide_1.OutlineSectionIcon],
@@ -36,6 +37,7 @@ const icons = new Map([
36
37
  [nodes.table_element, style_guide_1.OutlineTableIcon],
37
38
  [nodes.graphical_abstract_section, style_guide_1.OutlineSectionIcon],
38
39
  [nodes.footnotes_section, style_guide_1.OutlineSectionIcon],
40
+ [nodes.image_element, OutlineImageIcon],
39
41
  ]);
40
42
  const nodeTypeIcon = (nodeType, listType) => {
41
43
  if (nodeType === transform_1.schema.nodes.list) {
@@ -46,15 +46,21 @@ exports.default = () => {
46
46
  if (target && !isInGraphicalAbstract) {
47
47
  const labelNode = document.createElement('span');
48
48
  labelNode.className = 'figure-label';
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
- });
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
+ }
58
64
  }
59
65
  }
60
66
  });
@@ -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.21';
4
+ exports.VERSION = '2.7.24';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -135,6 +135,9 @@ 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;
138
141
  case state.schema.nodes.listing_element:
139
142
  node = state.schema.nodes.listing_element.create({}, [
140
143
  state.schema.nodes.listing.create(),
@@ -941,6 +944,9 @@ const createAndFillFigcaptionElement = (state) => state.schema.nodes.figcaption.
941
944
  state.schema.nodes.caption_title.create(),
942
945
  state.schema.nodes.caption.create(),
943
946
  ]);
947
+ const createImageElement = (state) => state.schema.nodes.image_element.create({}, [
948
+ state.schema.nodes.figure.create(),
949
+ ]);
944
950
  const getParentNode = (selection) => {
945
951
  var _a;
946
952
  const parentNode = findParentNodeWithId(selection);
@@ -18,7 +18,6 @@ const excludedTypes = [
18
18
  schema.nodes.contributors,
19
19
  schema.nodes.author_notes,
20
20
  schema.nodes.title,
21
- schema.nodes.image_element,
22
21
  ];
23
22
  const childrenExcludedTypes = [
24
23
  schema.nodes.pullquote_element,
@@ -65,6 +65,7 @@ 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),
68
69
  footnote: footnote(props),
69
70
  footnotes_element: footnotesElement(props),
70
71
  general_table_footnote: generalTableFootnote(props, dispatch),
@@ -49,7 +49,9 @@ 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 && node.attrs.id !== gaID) {
52
+ if ((node.type === schema.nodes.figure_element ||
53
+ node.type === schema.nodes.image_element) &&
54
+ node.attrs.id !== gaID) {
53
55
  figures.push(getFigureElementFiles(node, pos));
54
56
  }
55
57
  if (node.type === schema.nodes.supplement) {
package/dist/es/menus.js CHANGED
@@ -196,6 +196,12 @@ 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
+ },
199
205
  {
200
206
  id: 'insert-table-element',
201
207
  label: 'Table',
@@ -13,10 +13,11 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { OutlineBlockQuoteIcon, OutlineEmbedIcon, OutlineEquationIcon, OutlineFigureIcon, OutlineManuscriptIcon, OutlineOrderedListIcon, OutlineParagraphIcon, OutlinePullQuoteIcon, OutlineSectionIcon, OutlineTableIcon, OutlineUnorderedListIcon, } from '@manuscripts/style-guide';
16
+ import { FileImageIcon, 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" }));
20
21
  const icons = new Map([
21
22
  [nodes.manuscript, OutlineManuscriptIcon],
22
23
  [nodes.bibliography_section, OutlineSectionIcon],
@@ -30,6 +31,7 @@ const icons = new Map([
30
31
  [nodes.table_element, OutlineTableIcon],
31
32
  [nodes.graphical_abstract_section, OutlineSectionIcon],
32
33
  [nodes.footnotes_section, OutlineSectionIcon],
34
+ [nodes.image_element, OutlineImageIcon],
33
35
  ]);
34
36
  export const nodeTypeIcon = (nodeType, listType) => {
35
37
  if (nodeType === schema.nodes.list) {
@@ -43,15 +43,21 @@ export default () => {
43
43
  if (target && !isInGraphicalAbstract) {
44
44
  const labelNode = document.createElement('span');
45
45
  labelNode.className = 'figure-label';
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
- });
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
+ }
55
61
  }
56
62
  }
57
63
  });
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.7.21';
1
+ export const VERSION = '2.7.24';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -104,6 +104,32 @@ 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>;
107
133
  footnote: import("../types").NodeViewCreator<import("../views/footnote").FootnoteView>;
108
134
  footnotes_element: import("../types").NodeViewCreator<import("../views/footnotes_element").FootnotesElementView>;
109
135
  general_table_footnote: import("../types").NodeViewCreator<import("../views/general_table_footnote").GeneralTableFootnoteView>;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.7.21";
1
+ export declare const VERSION = "2.7.24";
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.21",
4
+ "version": "2.7.24",
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.36",
37
+ "@manuscripts/transform": "3.0.37",
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,10 +348,17 @@
348
348
 
349
349
  .ProseMirror .figure-label {
350
350
  font-weight: bold;
351
+ font-size: 14px;
351
352
  margin-right: 5px;
352
353
  white-space: nowrap;
353
354
  }
354
355
 
356
+ .block-image_element .figure-label {
357
+ text-align: center;
358
+ grid-column-start: 1;
359
+ grid-column-end: -1;
360
+ }
361
+
355
362
  .ProseMirror .executable-container {
356
363
  width: 100%;
357
364
  position: relative;