@manuscripts/body-editor 3.3.4 → 3.3.6

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.
@@ -78,29 +78,29 @@ const createMediaPlaceholder = (mediaType = 'media', view, getPos) => {
78
78
  return element;
79
79
  };
80
80
  exports.createMediaPlaceholder = createMediaPlaceholder;
81
- const createFileHandlers = (node, view, getPos, props, setHref) => {
81
+ const createFileHandlers = (attrs, fileAttrKey, view, props, setAttr) => {
82
82
  const handlers = {};
83
- const href = node.attrs.href;
83
+ const controlAttr = attrs[fileAttrKey];
84
84
  const files = props.getFiles();
85
- const file = href && files.find((f) => f.id === href);
85
+ const file = controlAttr && files.find((f) => f.id === controlAttr);
86
86
  const can = props.getCapabilities();
87
- if (href && file) {
87
+ if (controlAttr && file) {
88
88
  handlers.handleDownload = () => {
89
89
  props.fileManagement.download(file);
90
90
  };
91
91
  handlers.handleDetach = () => {
92
- setHref('');
92
+ setAttr('');
93
93
  };
94
94
  }
95
95
  if (can.replaceFile) {
96
96
  handlers.handleReplace = (file, isSupplement = false) => {
97
- setHref(file.id);
97
+ setAttr(file.id);
98
98
  if (isSupplement) {
99
99
  const tr = view.state.tr;
100
100
  view.state.doc.descendants((node, pos) => {
101
101
  if (node.type === transform_1.schema.nodes.supplement) {
102
- const href = node.attrs.href;
103
- if (href === file.id) {
102
+ const attr = node.attrs[fileAttrKey];
103
+ if (attr === file.id) {
104
104
  tr.delete(pos, pos + node.nodeSize);
105
105
  view.dispatch(tr);
106
106
  }
@@ -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.3.4';
4
+ exports.VERSION = '3.3.6';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -115,7 +115,7 @@ class EmbedView extends block_view_1.default {
115
115
  let handlers;
116
116
  const can = this.props.getCapabilities();
117
117
  if (this.isUploadedFile()) {
118
- handlers = (0, media_1.createFileHandlers)(this.node, this.view, this.getPos, this.props, this.setHref);
118
+ handlers = (0, media_1.createFileHandlers)(this.node.attrs, 'href', this.view, this.props, this.setHref);
119
119
  if (can.uploadFile) {
120
120
  handlers.handleUpload = (0, media_1.createFileUploader)(this.upload, 'video/*,audio/*');
121
121
  }
@@ -218,7 +218,7 @@ class FigureEditableView extends figure_1.FigureView {
218
218
  }
219
219
  manageReactTools() {
220
220
  this.reactTools?.remove();
221
- const handlers = (0, media_1.createFileHandlers)(this.node, this.view, this.getPos, this.props, this.setSrc);
221
+ const handlers = (0, media_1.createFileHandlers)(this.node.attrs, 'src', this.view, this.props, this.setSrc);
222
222
  const can = this.props.getCapabilities();
223
223
  if (can.uploadFile) {
224
224
  handlers.handleUpload = (0, media_1.createFileUploader)(this.upload, 'image/*');
@@ -70,29 +70,29 @@ export const createMediaPlaceholder = (mediaType = 'media', view, getPos) => {
70
70
  element.appendChild(instructions);
71
71
  return element;
72
72
  };
73
- export const createFileHandlers = (node, view, getPos, props, setHref) => {
73
+ export const createFileHandlers = (attrs, fileAttrKey, view, props, setAttr) => {
74
74
  const handlers = {};
75
- const href = node.attrs.href;
75
+ const controlAttr = attrs[fileAttrKey];
76
76
  const files = props.getFiles();
77
- const file = href && files.find((f) => f.id === href);
77
+ const file = controlAttr && files.find((f) => f.id === controlAttr);
78
78
  const can = props.getCapabilities();
79
- if (href && file) {
79
+ if (controlAttr && file) {
80
80
  handlers.handleDownload = () => {
81
81
  props.fileManagement.download(file);
82
82
  };
83
83
  handlers.handleDetach = () => {
84
- setHref('');
84
+ setAttr('');
85
85
  };
86
86
  }
87
87
  if (can.replaceFile) {
88
88
  handlers.handleReplace = (file, isSupplement = false) => {
89
- setHref(file.id);
89
+ setAttr(file.id);
90
90
  if (isSupplement) {
91
91
  const tr = view.state.tr;
92
92
  view.state.doc.descendants((node, pos) => {
93
93
  if (node.type === schema.nodes.supplement) {
94
- const href = node.attrs.href;
95
- if (href === file.id) {
94
+ const attr = node.attrs[fileAttrKey];
95
+ if (attr === file.id) {
96
96
  tr.delete(pos, pos + node.nodeSize);
97
97
  view.dispatch(tr);
98
98
  }
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.3.4';
1
+ export const VERSION = '3.3.6';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -109,7 +109,7 @@ export class EmbedView extends BlockView {
109
109
  let handlers;
110
110
  const can = this.props.getCapabilities();
111
111
  if (this.isUploadedFile()) {
112
- handlers = createFileHandlers(this.node, this.view, this.getPos, this.props, this.setHref);
112
+ handlers = createFileHandlers(this.node.attrs, 'href', this.view, this.props, this.setHref);
113
113
  if (can.uploadFile) {
114
114
  handlers.handleUpload = createFileUploader(this.upload, 'video/*,audio/*');
115
115
  }
@@ -215,7 +215,7 @@ export class FigureEditableView extends FigureView {
215
215
  }
216
216
  manageReactTools() {
217
217
  this.reactTools?.remove();
218
- const handlers = createFileHandlers(this.node, this.view, this.getPos, this.props, this.setSrc);
218
+ const handlers = createFileHandlers(this.node.attrs, 'src', this.view, this.props, this.setSrc);
219
219
  const can = this.props.getCapabilities();
220
220
  if (can.uploadFile) {
221
221
  handlers.handleUpload = createFileUploader(this.upload, 'image/*');
@@ -27,7 +27,12 @@ export interface FileHandlers {
27
27
  handleDetach?: () => void;
28
28
  handleDelete?: () => void;
29
29
  }
30
- export declare const createFileHandlers: <T extends ManuscriptNode>(node: Trackable<T>, view: ManuscriptEditorView, getPos: () => number, props: EditorProps, setHref: (href: string) => void) => FileHandlers;
30
+ type Handleable = {
31
+ href?: string;
32
+ src?: string;
33
+ };
34
+ export declare const createFileHandlers: <T extends Handleable>(attrs: T, fileAttrKey: keyof Handleable, view: ManuscriptEditorView, props: EditorProps, setAttr: (value: string) => void) => FileHandlers;
31
35
  export declare const createReactTools: <T extends ManuscriptNode>(node: Trackable<T>, view: ManuscriptEditorView, getPos: () => number, props: EditorProps, handlers: FileHandlers, isEmbed: boolean, hasSiblings: () => boolean) => HTMLDivElement | null;
32
36
  export declare const createFileUploader: (handler: (file: File) => Promise<void>, accept?: string) => () => void;
33
37
  export declare const addInteractionHandlers: (element: HTMLElement, uploadFn: (file: File) => Promise<void>, accept?: string) => void;
38
+ export {};
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.3.4";
1
+ export declare const VERSION = "3.3.6";
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": "3.3.4",
4
+ "version": "3.3.6",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -40,7 +40,7 @@
40
40
  "@manuscripts/json-schema": "2.2.12",
41
41
  "@manuscripts/style-guide": "3.2.1",
42
42
  "@manuscripts/track-changes-plugin": "2.0.10",
43
- "@manuscripts/transform": "4.2.12",
43
+ "@manuscripts/transform": "4.2.13",
44
44
  "@popperjs/core": "2.11.8",
45
45
  "citeproc": "2.4.63",
46
46
  "codemirror": "5.65.19",
@@ -212,7 +212,7 @@
212
212
  visibility: visible;
213
213
  }
214
214
 
215
- .ProseMirror .media-preview audio{
215
+ .ProseMirror .media-preview audio {
216
216
  margin-top: 40px;
217
217
  }
218
218
 
@@ -284,7 +284,7 @@
284
284
  white-space: normal;
285
285
  font-size: 14px;
286
286
  }
287
- .ProseMirror .block-embed .media-preview .placeholder {
287
+ .ProseMirror .block-embed .media-preview .placeholder {
288
288
  padding: 16px 32px;
289
289
  }
290
290
 
@@ -371,11 +371,11 @@
371
371
  }
372
372
 
373
373
  .ProseMirror .block-figure_element .position-menu,
374
- .ProseMirror .block-image_element .position-menu,
374
+ .ProseMirror .block-image_element .position-menu,
375
375
  ProseMirror .block-embed .position-menu {
376
376
  position: absolute;
377
- top: 15px;
378
- right: 35px;
377
+ top: 8px;
378
+ right: 21px;
379
379
  z-index: 2;
380
380
  cursor: pointer;
381
381
  padding-left: 100px;