@manuscripts/body-editor 3.13.11 → 3.13.12

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.
@@ -119,6 +119,14 @@ const FigureOptions = ({ can, getDoc, getFiles, onDownload, onUpload, onDetach,
119
119
  }
120
120
  }, [isOpen, container.classList]);
121
121
  useDropdownKeyboardNav(isOpen, dropdownRef, toggleOpen);
122
+ const hasAnyActions = !!showDownload ||
123
+ !!showUpload ||
124
+ !!showDetach ||
125
+ !!showReplace ||
126
+ showDelete();
127
+ if (!hasAnyActions) {
128
+ return null;
129
+ }
122
130
  const isEmbedMode = !!onReplaceEmbed;
123
131
  const groupFiles = (0, files_1.memoGroupFiles)();
124
132
  return (react_1.default.createElement(DropdownWrapper, { ref: wrapperRef },
@@ -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.13.11';
4
+ exports.VERSION = '3.13.12';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -37,7 +37,6 @@ class AccessibilityElementView extends block_view_1.default {
37
37
  createElement() {
38
38
  super.createElement();
39
39
  this.contentDOM.className = 'accessibility_element_input';
40
- this.contentDOM.setAttribute('contenteditable', 'true');
41
40
  this.contentDOM.tabIndex = this.node.type === transform_1.schema.nodes.alt_text ? 0 : -1;
42
41
  this.removeKeydownListener = (0, navigation_utils_1.createKeyboardInteraction)({
43
42
  container: this.contentDOM,
@@ -120,7 +120,6 @@ class AffiliationsView extends block_view_1.default {
120
120
  this.container = document.createElement('div');
121
121
  this.container.classList.add('affiliations', 'block');
122
122
  this.container.contentEditable = 'false';
123
- this.container.addEventListener('click', this.handleClick);
124
123
  this.dom.setAttribute('contenteditable', 'false');
125
124
  this.dom.appendChild(this.container);
126
125
  }
@@ -140,6 +139,11 @@ class AffiliationsView extends block_view_1.default {
140
139
  this.updateSelection();
141
140
  }
142
141
  buildAffiliations(affs) {
142
+ const can = this.props.getCapabilities();
143
+ this.container.removeEventListener('click', this.handleClick);
144
+ if (can.editMetadata) {
145
+ this.container.addEventListener('click', this.handleClick);
146
+ }
143
147
  const elements = [];
144
148
  for (const affiliation of affs.affiliations) {
145
149
  const index = affs.indexedAffiliationIds.get(affiliation.id);
@@ -28,7 +28,6 @@ class CaptionView extends base_node_view_1.BaseNodeView {
28
28
  createDOM() {
29
29
  this.dom = document.createElement('caption');
30
30
  this.dom.className = 'caption-description placeholder';
31
- this.dom.contentEditable = 'true';
32
31
  this.contentDOM = this.dom;
33
32
  }
34
33
  }
@@ -28,7 +28,6 @@ class CaptionTitleView extends base_node_view_1.BaseNodeView {
28
28
  createDOM() {
29
29
  this.dom = document.createElement('label');
30
30
  this.dom.className = 'caption-title placeholder';
31
- this.dom.contentEditable = 'true';
32
31
  this.contentDOM = this.dom;
33
32
  }
34
33
  }
@@ -25,6 +25,7 @@ const creators_1 = require("./creators");
25
25
  class SupplementView extends base_node_view_1.BaseNodeView {
26
26
  constructor() {
27
27
  super(...arguments);
28
+ this.dragAndDropInitialized = false;
28
29
  this.ignoreMutation = () => true;
29
30
  this.createElement = () => {
30
31
  this.dom = document.createElement('div');
@@ -43,11 +44,25 @@ class SupplementView extends base_node_view_1.BaseNodeView {
43
44
  initialise() {
44
45
  this.createElement();
45
46
  this.updateContents();
46
- this.setupDragAndDrop();
47
47
  }
48
48
  updateContents() {
49
49
  super.updateContents();
50
50
  this.refreshFileInfo();
51
+ const can = this.props.getCapabilities();
52
+ this.dom.draggable = can.editArticle;
53
+ if (can.editArticle) {
54
+ if (!this.dragAndDropInitialized) {
55
+ this.setupDragAndDrop();
56
+ this.dragAndDropInitialized = true;
57
+ }
58
+ if (!this.dragIcon) {
59
+ this.addDragIcon();
60
+ }
61
+ }
62
+ else {
63
+ this.dragIcon?.remove();
64
+ this.dragIcon = undefined;
65
+ }
51
66
  }
52
67
  getDropSide(element, clientY) {
53
68
  const { top, bottom } = element.getBoundingClientRect();
@@ -80,6 +80,14 @@ export const FigureOptions = ({ can, getDoc, getFiles, onDownload, onUpload, onD
80
80
  }
81
81
  }, [isOpen, container.classList]);
82
82
  useDropdownKeyboardNav(isOpen, dropdownRef, toggleOpen);
83
+ const hasAnyActions = !!showDownload ||
84
+ !!showUpload ||
85
+ !!showDetach ||
86
+ !!showReplace ||
87
+ showDelete();
88
+ if (!hasAnyActions) {
89
+ return null;
90
+ }
83
91
  const isEmbedMode = !!onReplaceEmbed;
84
92
  const groupFiles = memoGroupFiles();
85
93
  return (React.createElement(DropdownWrapper, { ref: wrapperRef },
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.13.11';
1
+ export const VERSION = '3.13.12';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -31,7 +31,6 @@ export class AccessibilityElementView extends BlockView {
31
31
  createElement() {
32
32
  super.createElement();
33
33
  this.contentDOM.className = 'accessibility_element_input';
34
- this.contentDOM.setAttribute('contenteditable', 'true');
35
34
  this.contentDOM.tabIndex = this.node.type === schema.nodes.alt_text ? 0 : -1;
36
35
  this.removeKeydownListener = createKeyboardInteraction({
37
36
  container: this.contentDOM,
@@ -114,7 +114,6 @@ export class AffiliationsView extends BlockView {
114
114
  this.container = document.createElement('div');
115
115
  this.container.classList.add('affiliations', 'block');
116
116
  this.container.contentEditable = 'false';
117
- this.container.addEventListener('click', this.handleClick);
118
117
  this.dom.setAttribute('contenteditable', 'false');
119
118
  this.dom.appendChild(this.container);
120
119
  }
@@ -134,6 +133,11 @@ export class AffiliationsView extends BlockView {
134
133
  this.updateSelection();
135
134
  }
136
135
  buildAffiliations(affs) {
136
+ const can = this.props.getCapabilities();
137
+ this.container.removeEventListener('click', this.handleClick);
138
+ if (can.editMetadata) {
139
+ this.container.addEventListener('click', this.handleClick);
140
+ }
137
141
  const elements = [];
138
142
  for (const affiliation of affs.affiliations) {
139
143
  const index = affs.indexedAffiliationIds.get(affiliation.id);
@@ -25,7 +25,6 @@ export class CaptionView extends BaseNodeView {
25
25
  createDOM() {
26
26
  this.dom = document.createElement('caption');
27
27
  this.dom.className = 'caption-description placeholder';
28
- this.dom.contentEditable = 'true';
29
28
  this.contentDOM = this.dom;
30
29
  }
31
30
  }
@@ -25,7 +25,6 @@ export class CaptionTitleView extends BaseNodeView {
25
25
  createDOM() {
26
26
  this.dom = document.createElement('label');
27
27
  this.dom.className = 'caption-title placeholder';
28
- this.dom.contentEditable = 'true';
29
28
  this.contentDOM = this.dom;
30
29
  }
31
30
  }
@@ -22,6 +22,7 @@ import { createNodeView } from './creators';
22
22
  export class SupplementView extends BaseNodeView {
23
23
  constructor() {
24
24
  super(...arguments);
25
+ this.dragAndDropInitialized = false;
25
26
  this.ignoreMutation = () => true;
26
27
  this.createElement = () => {
27
28
  this.dom = document.createElement('div');
@@ -40,11 +41,25 @@ export class SupplementView extends BaseNodeView {
40
41
  initialise() {
41
42
  this.createElement();
42
43
  this.updateContents();
43
- this.setupDragAndDrop();
44
44
  }
45
45
  updateContents() {
46
46
  super.updateContents();
47
47
  this.refreshFileInfo();
48
+ const can = this.props.getCapabilities();
49
+ this.dom.draggable = can.editArticle;
50
+ if (can.editArticle) {
51
+ if (!this.dragAndDropInitialized) {
52
+ this.setupDragAndDrop();
53
+ this.dragAndDropInitialized = true;
54
+ }
55
+ if (!this.dragIcon) {
56
+ this.addDragIcon();
57
+ }
58
+ }
59
+ else {
60
+ this.dragIcon?.remove();
61
+ this.dragIcon = undefined;
62
+ }
48
63
  }
49
64
  getDropSide(element, clientY) {
50
65
  const { top, bottom } = element.getBoundingClientRect();
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.13.11";
1
+ export declare const VERSION = "3.13.12";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
@@ -20,6 +20,7 @@ export declare class SupplementView extends BaseNodeView<Trackable<SupplementNod
20
20
  private supplementInfoEl;
21
21
  private static currentDragSupplementId;
22
22
  private dragIcon;
23
+ private dragAndDropInitialized;
23
24
  ignoreMutation: () => boolean;
24
25
  initialise(): void;
25
26
  createElement: () => void;
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.13.11",
4
+ "version": "3.13.12",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -184,6 +184,17 @@ export const FigureOptions: React.FC<WrappedProps> = ({
184
184
 
185
185
  useDropdownKeyboardNav(isOpen, dropdownRef, toggleOpen)
186
186
 
187
+ const hasAnyActions =
188
+ !!showDownload ||
189
+ !!showUpload ||
190
+ !!showDetach ||
191
+ !!showReplace ||
192
+ showDelete()
193
+
194
+ if (!hasAnyActions) {
195
+ return null
196
+ }
197
+
187
198
  const isEmbedMode = !!onReplaceEmbed
188
199
 
189
200
  const groupFiles = memoGroupFiles()
package/src/versions.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  //THIS FILE WAS GENERATED BY versions.mjs
2
- export const VERSION = '3.13.11';
2
+ export const VERSION = '3.13.12';
3
3
  export const MATHJAX_VERSION = '3.2.2';
@@ -52,7 +52,6 @@ export class AccessibilityElementView extends BlockView<LongDescNode> {
52
52
  public createElement() {
53
53
  super.createElement()
54
54
  this.contentDOM.className = 'accessibility_element_input'
55
- this.contentDOM.setAttribute('contenteditable', 'true')
56
55
 
57
56
  this.contentDOM.tabIndex = this.node.type === schema.nodes.alt_text ? 0 : -1
58
57
 
@@ -52,7 +52,6 @@ export class AffiliationsView extends BlockView<Trackable<AffiliationNode>> {
52
52
  this.container = document.createElement('div')
53
53
  this.container.classList.add('affiliations', 'block')
54
54
  this.container.contentEditable = 'false'
55
- this.container.addEventListener('click', this.handleClick)
56
55
  this.dom.setAttribute('contenteditable', 'false')
57
56
  this.dom.appendChild(this.container)
58
57
  }
@@ -75,6 +74,12 @@ export class AffiliationsView extends BlockView<Trackable<AffiliationNode>> {
75
74
  }
76
75
 
77
76
  private buildAffiliations(affs: PluginState) {
77
+ const can = this.props.getCapabilities()
78
+ this.container.removeEventListener('click', this.handleClick)
79
+ if (can.editMetadata) {
80
+ this.container.addEventListener('click', this.handleClick)
81
+ }
82
+
78
83
  const elements = []
79
84
  for (const affiliation of affs.affiliations) {
80
85
  const index = affs.indexedAffiliationIds.get(affiliation.id)
@@ -29,7 +29,6 @@ export class CaptionView
29
29
  protected createDOM() {
30
30
  this.dom = document.createElement('caption')
31
31
  this.dom.className = 'caption-description placeholder'
32
- this.dom.contentEditable = 'true'
33
32
  this.contentDOM = this.dom
34
33
  }
35
34
  }
@@ -26,7 +26,6 @@ export class CaptionTitleView extends BaseNodeView<CaptionTitleNode> {
26
26
  protected createDOM() {
27
27
  this.dom = document.createElement('label')
28
28
  this.dom.className = 'caption-title placeholder'
29
- this.dom.contentEditable = 'true'
30
29
  this.contentDOM = this.dom
31
30
  }
32
31
  }
@@ -28,13 +28,12 @@ export class SupplementView extends BaseNodeView<Trackable<SupplementNode>> {
28
28
  private supplementInfoEl: HTMLDivElement
29
29
  private static currentDragSupplementId: string | null = null
30
30
  private dragIcon: HTMLDivElement | undefined
31
-
31
+ private dragAndDropInitialized = false
32
32
  public ignoreMutation = () => true
33
33
 
34
34
  public initialise() {
35
35
  this.createElement()
36
36
  this.updateContents()
37
- this.setupDragAndDrop()
38
37
  }
39
38
 
40
39
  public createElement = () => {
@@ -56,6 +55,20 @@ export class SupplementView extends BaseNodeView<Trackable<SupplementNode>> {
56
55
  public updateContents() {
57
56
  super.updateContents()
58
57
  this.refreshFileInfo()
58
+ const can = this.props.getCapabilities()
59
+ this.dom.draggable = can.editArticle
60
+ if (can.editArticle) {
61
+ if (!this.dragAndDropInitialized) {
62
+ this.setupDragAndDrop()
63
+ this.dragAndDropInitialized = true
64
+ }
65
+ if (!this.dragIcon) {
66
+ this.addDragIcon()
67
+ }
68
+ } else {
69
+ this.dragIcon?.remove()
70
+ this.dragIcon = undefined
71
+ }
59
72
  }
60
73
 
61
74
  private getDropSide(element: Element, clientY: number): 'before' | 'after' {
package/styles/Editor.css CHANGED
@@ -1320,7 +1320,7 @@
1320
1320
  z-index: 1000;
1321
1321
  }
1322
1322
 
1323
- .ProseMirror .supplement-item:hover {
1323
+ .ProseMirror .supplement-item[draggable="true"]:hover {
1324
1324
  background-color: #f2f2f2 !important;
1325
1325
  cursor: move;
1326
1326
  }