@manuscripts/body-editor 2.8.79-test-multiple-images.1 → 2.8.79

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.
@@ -54,7 +54,7 @@ const isHeaderCellSelected = (state) => {
54
54
  }
55
55
  return (((_a = state.doc.nodeAt(state.selection.from)) === null || _a === void 0 ? void 0 : _a.type) === transform_1.schema.nodes.table_header);
56
56
  };
57
- const TableChangeWarningDialog = ({ isOpen, primaryAction, secondaryAction }) => (react_1.default.createElement(style_guide_1.Dialog, { isOpen: isOpen, category: style_guide_1.Category.confirmation, header: "This change can't be tracked", message: "This action won't be marked as chnage. Do you want to continue?", actions: {
57
+ const TableChangeWarningDialog = ({ isOpen, primaryAction, secondaryAction }) => (react_1.default.createElement(style_guide_1.Dialog, { isOpen: isOpen, category: style_guide_1.Category.confirmation, header: "This change can't be tracked", message: "This action won't be marked as change. Do you want to continue?", actions: {
58
58
  primary: { action: primaryAction, title: 'Ok' },
59
59
  secondary: { action: secondaryAction, title: 'Cancel' },
60
60
  } }));
@@ -57,11 +57,11 @@ exports.default = (props) => {
57
57
  (0, track_changes_plugin_1.trackChangesPlugin)({
58
58
  userID: props.userID,
59
59
  debug: props.debug,
60
- initialStatus: props.getCapabilities().editWithoutTracking
61
- ? track_changes_plugin_1.TrackChangesStatus.disabled
62
- : props.getCapabilities().editArticle
63
- ? track_changes_plugin_1.TrackChangesStatus.enabled
64
- : track_changes_plugin_1.TrackChangesStatus.viewSnapshots,
60
+ initialStatus: props.isViewingMode
61
+ ? track_changes_plugin_1.TrackChangesStatus.viewSnapshots
62
+ : props.getCapabilities().editWithoutTracking
63
+ ? track_changes_plugin_1.TrackChangesStatus.disabled
64
+ : track_changes_plugin_1.TrackChangesStatus.enabled,
65
65
  }),
66
66
  (0, section_title_1.default)(),
67
67
  (0, tables_cursor_fix_1.default)(),
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.groupFiles = void 0;
4
4
  const transform_1 = require("@manuscripts/transform");
5
+ const prosemirror_utils_1 = require("prosemirror-utils");
5
6
  const track_changes_utils_1 = require("./track-changes-utils");
6
7
  const MISSING_FILE = {
7
8
  id: '',
@@ -25,29 +26,14 @@ const groupFiles = (doc, files) => {
25
26
  };
26
27
  const getFigureElementFiles = (node, pos) => {
27
28
  const figureFiles = [];
28
- if (node.type === transform_1.schema.nodes.figure_element) {
29
- node.forEach((child, offset) => {
30
- if (child.type === transform_1.schema.nodes.figure) {
31
- const src = child.attrs.src;
32
- if (typeof src === 'string' && src) {
33
- figureFiles.push({
34
- node: child,
35
- pos: pos + offset + 1,
36
- file: getFile(src),
37
- });
38
- }
39
- else if (Array.isArray(src)) {
40
- src.forEach((id) => {
41
- if (id) {
42
- figureFiles.push({
43
- node: child,
44
- pos: pos + offset + 1,
45
- file: getFile(id),
46
- });
47
- }
48
- });
49
- }
50
- }
29
+ for (const figure of (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.figure)) {
30
+ if ((0, track_changes_utils_1.isHidden)(figure.node)) {
31
+ continue;
32
+ }
33
+ figureFiles.push({
34
+ node: figure.node,
35
+ pos: pos + figure.pos + 1,
36
+ file: getFile(figure.node.attrs.src),
51
37
  });
52
38
  }
53
39
  return {
@@ -77,7 +77,7 @@ const useEditor = (externalProps) => {
77
77
  }, 250, !tr.isGeneric || !tr.docChanged || !tr.getMeta(search_replace_1.searchReplaceKey));
78
78
  return nextState;
79
79
  }, []);
80
- const canEdit = props.getCapabilities().editArticle;
80
+ const isViewingMode = props.isViewingMode;
81
81
  const onRender = (0, react_1.useCallback)((el) => {
82
82
  if (!el) {
83
83
  return;
@@ -85,7 +85,7 @@ const useEditor = (externalProps) => {
85
85
  const freshState = (0, ManuscriptsEditor_1.createEditorState)(props);
86
86
  view.current = (0, ManuscriptsEditor_1.createEditorView)(props, el, freshState || state, dispatch);
87
87
  setState(view.current.state);
88
- }, [canEdit]);
88
+ }, [isViewingMode]);
89
89
  const isCommandValid = (0, react_1.useCallback)((command) => command(state), [state]);
90
90
  const doCommand = (0, react_1.useCallback)((command) => command(state, dispatch, view.current), [state, dispatch]);
91
91
  const replaceState = (0, react_1.useCallback)((state) => {
@@ -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.8.79-test-multiple-images.1';
4
+ exports.VERSION = '2.8.79';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -31,7 +31,6 @@ exports.FigureEditableView = exports.figurePositions = void 0;
31
31
  const style_guide_1 = require("@manuscripts/style-guide");
32
32
  const transform_1 = require("@manuscripts/transform");
33
33
  const prosemirror_state_1 = require("prosemirror-state");
34
- const prosemirror_utils_1 = require("prosemirror-utils");
35
34
  const react_1 = require("react");
36
35
  const server_1 = require("react-dom/server");
37
36
  const FigureDropdown_1 = require("../components/views/FigureDropdown");
@@ -51,146 +50,60 @@ var figurePositions;
51
50
  class FigureEditableView extends figure_1.FigureView {
52
51
  constructor() {
53
52
  super(...arguments);
54
- this.addImageButton = null;
55
- this.imageToolContainers = new Map();
56
- this.upload = (file, index = 0) => __awaiter(this, void 0, void 0, function* () {
57
- try {
58
- const result = yield this.props.fileManagement.upload(file);
59
- this.addImage(result.id, index);
60
- }
61
- catch (error) {
62
- console.error('Upload failed:', error);
63
- throw error;
64
- }
53
+ this.upload = (file) => __awaiter(this, void 0, void 0, function* () {
54
+ const result = yield this.props.fileManagement.upload(file);
55
+ this.setSrc(result.id);
65
56
  });
66
- this.createImg = (src) => {
67
- const img = document.createElement('img');
68
- img.classList.add('figure-image');
69
- img.src = src;
70
- return img;
71
- };
72
- this.createPlaceholder = (index) => {
73
- const element = document.createElement('div');
74
- element.classList.add('figure', 'placeholder');
75
- element.dataset.index = index.toString();
76
- const instructions = document.createElement('div');
77
- instructions.classList.add('instructions');
78
- instructions.innerHTML = `
79
- <p>Drag or click here to upload image <br>
80
- or drag items here from the file inspector tabs <br>
81
- <a data-action='open-other-files'>'Other files'</a> |
82
- <a data-action='open-supplement-files'>'Supplements'</a></p>
83
- `;
84
- const can = this.props.getCapabilities();
85
- if (can.uploadFile && !(0, track_changes_utils_1.isDeleted)(this.node)) {
86
- const handlePlaceholderClick = (event) => {
87
- var _a;
88
- const target = event.target;
89
- if ((_a = target.dataset) === null || _a === void 0 ? void 0 : _a.action) {
90
- return;
91
- }
92
- const triggerUpload = (0, figure_uploader_1.figureUploader)((file) => this.upload(file, index));
93
- triggerUpload();
94
- };
95
- element.addEventListener('click', handlePlaceholderClick);
96
- element.addEventListener('dragenter', (event) => {
97
- event.preventDefault();
98
- event.stopPropagation();
99
- element.classList.add('drag-over');
100
- });
101
- element.addEventListener('dragover', (event) => {
102
- event.preventDefault();
103
- event.stopPropagation();
104
- element.classList.add('drag-over');
105
- if (event.dataTransfer) {
106
- event.dataTransfer.dropEffect = 'copy';
107
- }
108
- });
109
- element.addEventListener('dragleave', (event) => {
110
- event.preventDefault();
111
- event.stopPropagation();
112
- element.classList.remove('drag-over');
113
- });
114
- element.addEventListener('drop', (event) => __awaiter(this, void 0, void 0, function* () {
115
- var _a, _b;
116
- event.preventDefault();
117
- event.stopPropagation();
118
- element.classList.remove('drag-over');
119
- if ((_b = (_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b.length) {
120
- const originalContent = instructions.innerHTML;
121
- instructions.innerHTML = '<p>Uploading image...</p>';
122
- try {
123
- yield this.upload(event.dataTransfer.files[0], index);
124
- }
125
- catch (error) {
126
- console.error('Upload failed:', error);
127
- instructions.innerHTML = originalContent;
128
- }
129
- }
130
- }));
131
- element.addEventListener('mouseenter', () => {
132
- element.classList.add('over');
133
- });
134
- element.addEventListener('mouseleave', () => {
135
- element.classList.remove('over');
136
- });
137
- }
138
- element.appendChild(instructions);
139
- return element;
57
+ this.setSrc = (src) => {
58
+ const { tr } = this.view.state;
59
+ const pos = this.getPos();
60
+ tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, this.node.attrs), { src: src }));
61
+ tr.setSelection(prosemirror_state_1.NodeSelection.create(tr.doc, pos));
62
+ this.view.dispatch(tr);
140
63
  };
141
- this.createUnsupportedFormat = (file, index) => {
64
+ this.createUnsupportedFormat = (name) => {
142
65
  var _a;
143
66
  const element = document.createElement('div');
144
67
  element.classList.add('figure', 'placeholder');
145
- element.dataset.fileId = file.id;
146
- element.dataset.index = index.toString();
147
68
  const instructions = document.createElement('div');
148
69
  instructions.classList.add('instructions');
149
70
  const iconHtml = (0, server_1.renderToStaticMarkup)((0, react_1.createElement)(style_guide_1.FileCorruptedIcon, { className: 'icon' }));
150
71
  instructions.innerHTML = `
151
72
  <div>
152
73
  <div class="unsupported-icon-wrapper">${iconHtml}</div>
153
- <div>${file.name}</div>
74
+ <div>${name}</div>
154
75
  <div class="unsupported-format-label">
155
76
  Unsupported file format
156
77
  </div>
157
78
  <div>
158
79
  ${((_a = this.props.getCapabilities()) === null || _a === void 0 ? void 0 : _a.editArticle)
159
- ? 'Click to replace with supported image'
160
- : 'Unsupported file format'}
80
+ ? 'Click to add image'
81
+ : 'No image here yet…'}
161
82
  </div>
162
83
  </div>
163
84
  `;
164
- const can = this.props.getCapabilities();
165
- if (can.uploadFile && !(0, track_changes_utils_1.isDeleted)(this.node)) {
166
- element.addEventListener('click', (event) => {
167
- var _a;
168
- const target = event.target;
169
- if ((_a = target.dataset) === null || _a === void 0 ? void 0 : _a.action) {
170
- return;
171
- }
172
- const triggerUpload = (0, figure_uploader_1.figureUploader)((newFile) => {
173
- this.detachImage(index);
174
- return this.upload(newFile, index);
175
- });
176
- triggerUpload();
177
- });
178
- element.addEventListener('mouseenter', () => {
179
- element.classList.add('over');
180
- });
181
- element.addEventListener('mouseleave', () => {
182
- element.classList.remove('over');
183
- });
184
- }
185
85
  element.appendChild(instructions);
186
86
  return element;
187
87
  };
188
- this.setSrc = (src) => {
189
- const { tr } = this.view.state;
190
- const pos = this.getPos();
191
- tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, this.node.attrs), { src: src }));
192
- tr.setSelection(prosemirror_state_1.NodeSelection.create(tr.doc, pos));
193
- this.view.dispatch(tr);
88
+ this.createImg = (src) => {
89
+ const img = document.createElement('img');
90
+ img.classList.add('figure-image');
91
+ img.src = src;
92
+ return img;
93
+ };
94
+ this.createPlaceholder = () => {
95
+ const element = document.createElement('div');
96
+ element.classList.add('figure', 'placeholder');
97
+ const instructions = document.createElement('div');
98
+ instructions.classList.add('instructions');
99
+ instructions.innerHTML = `
100
+ <p>Drag or click here to upload image <br>
101
+ or drag items here from the file inspector tabs <br>
102
+ <a data-action='open-other-files'>'Other files'</a> |
103
+ <a data-action='open-supplement-files'>'Supplements'</a></p>
104
+ `;
105
+ element.appendChild(instructions);
106
+ return element;
194
107
  };
195
108
  this.createPositionMenuWrapper = () => {
196
109
  const can = this.props.getCapabilities();
@@ -263,120 +176,109 @@ class FigureEditableView extends figure_1.FigureView {
263
176
  }
264
177
  updateContents() {
265
178
  super.updateContents();
266
- const src = this.node.attrs.src || '';
267
- const images = Array.isArray(src) ? src : [src];
179
+ const src = this.node.attrs.src;
268
180
  const files = this.props.getFiles();
181
+ const file = src && files.filter((f) => f.id === src)[0];
269
182
  this.figurePosition = this.node.attrs.type;
270
- const can = this.props.getCapabilities();
271
183
  this.container.innerHTML = '';
272
- this.imageToolContainers.clear();
273
- this.imagesContainer = document.createElement('div');
274
- this.imagesContainer.classList.add('figure-images-container');
275
- images.forEach((imageSrc, index) => {
276
- const file = imageSrc && files.find((f) => f.id === imageSrc);
277
- const imgContainer = document.createElement('div');
278
- imgContainer.classList.add('figure-image-container');
279
- const imgElement = imageSrc
280
- ? file
281
- ? this.props.fileManagement.previewLink(file)
282
- ? this.createImg(this.props.fileManagement.previewLink(file))
283
- : this.createUnsupportedFormat(file, index)
284
- : this.createPlaceholder(index)
285
- : this.createPlaceholder(index);
286
- imgContainer.appendChild(imgElement);
287
- if (can.editArticle && !(0, track_changes_utils_1.isDeleted)(this.node) && file) {
288
- const toolContainer = this.createImageToolContainer(index, file);
289
- imgContainer.appendChild(toolContainer);
290
- this.imageToolContainers.set(index, toolContainer);
291
- }
292
- this.imagesContainer.appendChild(imgContainer);
293
- });
184
+ const can = this.props.getCapabilities();
185
+ const link = file && this.props.fileManagement.previewLink(file);
186
+ const img = link
187
+ ? this.createImg(link)
188
+ : file
189
+ ? this.createUnsupportedFormat(file.name)
190
+ : this.createPlaceholder();
294
191
  if (can.uploadFile && !(0, track_changes_utils_1.isDeleted)(this.node)) {
295
- const lastImage = images[images.length - 1];
296
- const isLastPlaceholderEmpty = lastImage === '' || !lastImage;
297
- const parent = (0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)(this.view.state.tr.doc.resolve(this.getPos()), transform_1.schema.nodes.figure_element);
298
- if (!this.addImageButton) {
299
- this.addImageButton = document.createElement('button');
300
- this.addImageButton.classList.add('add-image-button');
301
- this.addImageButton.innerHTML = (0, server_1.renderToStaticMarkup)((0, react_1.createElement)(style_guide_1.PlusIcon, { className: 'icon' }));
302
- this.addImageButton.title = 'Add another image';
303
- this.addImageButton.addEventListener('click', () => {
304
- this.addNewImagePlaceholder();
305
- });
306
- }
307
- if (isLastPlaceholderEmpty) {
308
- this.addImageButton.classList.add('disabled');
309
- }
310
- else {
311
- this.addImageButton.classList.remove('disabled');
312
- }
313
- if (!this.imagesContainer.contains(this.addImageButton) &&
314
- (parent === null || parent === void 0 ? void 0 : parent.node.type) === transform_1.schema.nodes.figure_element) {
315
- this.imagesContainer.appendChild(this.addImageButton);
316
- }
317
- }
318
- else {
319
- if (this.addImageButton) {
320
- this.addImageButton.remove();
321
- this.addImageButton = null;
322
- }
192
+ const handlePlaceholderClick = (event) => {
193
+ const target = event.target;
194
+ if (target.dataset && target.dataset.action) {
195
+ return;
196
+ }
197
+ const triggerUpload = (0, figure_uploader_1.figureUploader)(this.upload);
198
+ triggerUpload();
199
+ };
200
+ img.addEventListener('click', handlePlaceholderClick);
201
+ img.addEventListener('mouseenter', () => {
202
+ img.classList.toggle('over', true);
203
+ });
204
+ img.addEventListener('mouseleave', () => {
205
+ img.classList.toggle('over', false);
206
+ });
207
+ img.addEventListener('dragenter', (event) => {
208
+ event.preventDefault();
209
+ img.classList.toggle('over', true);
210
+ });
211
+ img.addEventListener('dragleave', () => {
212
+ img.classList.toggle('over', false);
213
+ });
214
+ img.addEventListener('dragover', (e) => {
215
+ if (e.dataTransfer && e.dataTransfer.items) {
216
+ for (const item of e.dataTransfer.items) {
217
+ if (item.kind === 'file' && item.type.startsWith('image/')) {
218
+ e.preventDefault();
219
+ e.dataTransfer.dropEffect = 'copy';
220
+ }
221
+ }
222
+ }
223
+ });
224
+ img.addEventListener('drop', (e) => __awaiter(this, void 0, void 0, function* () {
225
+ if (e.dataTransfer && e.dataTransfer.files.length) {
226
+ e.preventDefault();
227
+ yield this.upload(e.dataTransfer.files[0]);
228
+ }
229
+ }));
323
230
  }
324
- this.container.appendChild(this.imagesContainer);
231
+ this.container.innerHTML = '';
232
+ this.container.appendChild(img);
325
233
  this.addTools();
326
234
  }
327
- createImageToolContainer(index, file) {
328
- const toolContainer = document.createElement('div');
329
- toolContainer.classList.add('image-tool-container');
330
- const can = this.props.getCapabilities();
235
+ addTools() {
236
+ this.manageReactTools();
237
+ this.container.appendChild(this.createPositionMenuWrapper());
238
+ }
239
+ manageReactTools() {
240
+ var _a;
241
+ let handleDownload;
242
+ let handleUpload;
243
+ let handleReplace;
244
+ let handleDetach;
245
+ const src = this.node.attrs.src;
331
246
  const files = this.props.getFiles();
332
- const doc = this.view.state.doc;
333
- if (file) {
247
+ const file = src && files.filter((f) => f.id === src)[0];
248
+ const can = this.props.getCapabilities();
249
+ if (src) {
250
+ if (file) {
251
+ handleDownload = () => {
252
+ this.props.fileManagement.download(file);
253
+ };
254
+ }
255
+ handleDetach = () => {
256
+ this.setSrc('');
257
+ };
258
+ }
259
+ if (can.replaceFile) {
260
+ handleReplace = (file) => {
261
+ this.setSrc(file.id);
262
+ };
263
+ }
264
+ if (can.uploadFile) {
265
+ handleUpload = (0, figure_uploader_1.figureUploader)(this.upload);
266
+ }
267
+ (_a = this.reactTools) === null || _a === void 0 ? void 0 : _a.remove();
268
+ if (this.props.dispatch && this.props.theme) {
269
+ const files = this.props.getFiles();
270
+ const doc = this.view.state.doc;
334
271
  const componentProps = {
335
272
  can,
336
273
  files: (0, files_1.groupFiles)(doc, files),
337
- onDownload: () => this.props.fileManagement.download(file),
338
- onUpload: () => {
339
- const triggerUpload = (0, figure_uploader_1.figureUploader)((file) => this.upload(file, index));
340
- triggerUpload();
341
- },
342
- onDetach: () => this.detachImage(index),
343
- onReplace: (newFile) => this.addImage(newFile.id, index),
274
+ onDownload: handleDownload,
275
+ onUpload: handleUpload,
276
+ onDetach: handleDetach,
277
+ onReplace: handleReplace,
344
278
  };
345
- const reactTools = (0, ReactSubView_1.default)(this.props, FigureDropdown_1.FigureOptions, componentProps, this.node, this.getPos, this.view);
346
- toolContainer.appendChild(reactTools);
279
+ this.reactTools = (0, ReactSubView_1.default)(this.props, FigureDropdown_1.FigureOptions, componentProps, this.node, this.getPos, this.view);
280
+ this.dom.insertBefore(this.reactTools, this.dom.firstChild);
347
281
  }
348
- return toolContainer;
349
- }
350
- addNewImagePlaceholder() {
351
- const currentImages = this.getCurrentImages();
352
- this.setImages([...currentImages, '']);
353
- }
354
- addImage(src, index) {
355
- const currentImages = this.getCurrentImages();
356
- const newImages = [...currentImages];
357
- newImages[index] = src;
358
- this.setImages(newImages);
359
- }
360
- detachImage(index) {
361
- const currentImages = this.getCurrentImages();
362
- const newImages = [...currentImages];
363
- newImages[index] = '';
364
- this.setImages(newImages);
365
- }
366
- getCurrentImages() {
367
- const src = this.node.attrs.src || '';
368
- return Array.isArray(src) ? src : [src];
369
- }
370
- setImages(images) {
371
- const src = images.length === 1 ? images[0] : images;
372
- const { tr } = this.view.state;
373
- const pos = this.getPos();
374
- tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, this.node.attrs), { src }));
375
- tr.setSelection(prosemirror_state_1.NodeSelection.create(tr.doc, pos));
376
- this.view.dispatch(tr);
377
- }
378
- addTools() {
379
- this.container.appendChild(this.createPositionMenuWrapper());
380
282
  }
381
283
  }
382
284
  exports.FigureEditableView = FigureEditableView;
@@ -25,7 +25,7 @@ const isHeaderCellSelected = (state) => {
25
25
  }
26
26
  return (((_a = state.doc.nodeAt(state.selection.from)) === null || _a === void 0 ? void 0 : _a.type) === schema.nodes.table_header);
27
27
  };
28
- const TableChangeWarningDialog = ({ isOpen, primaryAction, secondaryAction }) => (React.createElement(Dialog, { isOpen: isOpen, category: Category.confirmation, header: "This change can't be tracked", message: "This action won't be marked as chnage. Do you want to continue?", actions: {
28
+ const TableChangeWarningDialog = ({ isOpen, primaryAction, secondaryAction }) => (React.createElement(Dialog, { isOpen: isOpen, category: Category.confirmation, header: "This change can't be tracked", message: "This action won't be marked as change. Do you want to continue?", actions: {
29
29
  primary: { action: primaryAction, title: 'Ok' },
30
30
  secondary: { action: secondaryAction, title: 'Cancel' },
31
31
  } }));
@@ -52,11 +52,11 @@ export default (props) => {
52
52
  trackChangesPlugin({
53
53
  userID: props.userID,
54
54
  debug: props.debug,
55
- initialStatus: props.getCapabilities().editWithoutTracking
56
- ? TrackChangesStatus.disabled
57
- : props.getCapabilities().editArticle
58
- ? TrackChangesStatus.enabled
59
- : TrackChangesStatus.viewSnapshots,
55
+ initialStatus: props.isViewingMode
56
+ ? TrackChangesStatus.viewSnapshots
57
+ : props.getCapabilities().editWithoutTracking
58
+ ? TrackChangesStatus.disabled
59
+ : TrackChangesStatus.enabled,
60
60
  }),
61
61
  section_title(),
62
62
  table_editing_fix(),
@@ -1,4 +1,5 @@
1
1
  import { schema } from '@manuscripts/transform';
2
+ import { findChildrenByType } from 'prosemirror-utils';
2
3
  import { isHidden } from './track-changes-utils';
3
4
  const MISSING_FILE = {
4
5
  id: '',
@@ -22,29 +23,14 @@ export const groupFiles = (doc, files) => {
22
23
  };
23
24
  const getFigureElementFiles = (node, pos) => {
24
25
  const figureFiles = [];
25
- if (node.type === schema.nodes.figure_element) {
26
- node.forEach((child, offset) => {
27
- if (child.type === schema.nodes.figure) {
28
- const src = child.attrs.src;
29
- if (typeof src === 'string' && src) {
30
- figureFiles.push({
31
- node: child,
32
- pos: pos + offset + 1,
33
- file: getFile(src),
34
- });
35
- }
36
- else if (Array.isArray(src)) {
37
- src.forEach((id) => {
38
- if (id) {
39
- figureFiles.push({
40
- node: child,
41
- pos: pos + offset + 1,
42
- file: getFile(id),
43
- });
44
- }
45
- });
46
- }
47
- }
26
+ for (const figure of findChildrenByType(node, schema.nodes.figure)) {
27
+ if (isHidden(figure.node)) {
28
+ continue;
29
+ }
30
+ figureFiles.push({
31
+ node: figure.node,
32
+ pos: pos + figure.pos + 1,
33
+ file: getFile(figure.node.attrs.src),
48
34
  });
49
35
  }
50
36
  return {
@@ -74,7 +74,7 @@ export const useEditor = (externalProps) => {
74
74
  }, 250, !tr.isGeneric || !tr.docChanged || !tr.getMeta(searchReplaceKey));
75
75
  return nextState;
76
76
  }, []);
77
- const canEdit = props.getCapabilities().editArticle;
77
+ const isViewingMode = props.isViewingMode;
78
78
  const onRender = useCallback((el) => {
79
79
  if (!el) {
80
80
  return;
@@ -82,7 +82,7 @@ export const useEditor = (externalProps) => {
82
82
  const freshState = createEditorState(props);
83
83
  view.current = createEditorView(props, el, freshState || state, dispatch);
84
84
  setState(view.current.state);
85
- }, [canEdit]);
85
+ }, [isViewingMode]);
86
86
  const isCommandValid = useCallback((command) => command(state), [state]);
87
87
  const doCommand = useCallback((command) => command(state, dispatch, view.current), [state, dispatch]);
88
88
  const replaceState = useCallback((state) => {
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.8.79-test-multiple-images.1';
1
+ export const VERSION = '2.8.79';
2
2
  export const MATHJAX_VERSION = '3.2.2';