@manuscripts/body-editor 3.4.5 → 3.4.7

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.
@@ -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.4.5';
4
+ exports.VERSION = '3.4.7';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -60,6 +60,15 @@ class FigureEditableView extends figure_1.FigureView {
60
60
  this.upload = this.upload.bind(this);
61
61
  this.createDOM();
62
62
  this.updateContents();
63
+ const domElement = this.dom;
64
+ domElement.__figureView = this;
65
+ }
66
+ update(newNode) {
67
+ const handledBySuper = super.update(newNode);
68
+ if (handledBySuper) {
69
+ this.addTools();
70
+ }
71
+ return handledBySuper;
63
72
  }
64
73
  clearTargetClass(target, classes = ['drop-target-above', 'drop-target-below']) {
65
74
  target.classList.remove(...classes);
@@ -191,11 +200,14 @@ class FigureEditableView extends figure_1.FigureView {
191
200
  }
192
201
  addTools() {
193
202
  this.manageReactTools();
203
+ const existingDragHandlers = this.container.querySelectorAll('.drag-handler');
204
+ existingDragHandlers.forEach((handler) => handler.remove());
194
205
  const $pos = this.view.state.doc.resolve(this.getPos());
195
206
  const parent = $pos.parent;
196
207
  if (this.props.getCapabilities()?.editArticle &&
197
208
  parent.type === transform_1.schema.nodes.figure_element &&
198
- !(0, track_changes_utils_1.isDeleted)(this.node)) {
209
+ !(0, track_changes_utils_1.isDeleted)(this.node) &&
210
+ this.countFigures() > 1) {
199
211
  const dragHandle = document.createElement('div');
200
212
  dragHandle.className = 'drag-handler';
201
213
  dragHandle.innerHTML = icons_1.draggableIcon;
@@ -118,10 +118,20 @@ class FigureElementView extends image_element_1.ImageElementView {
118
118
  requestAnimationFrame(() => {
119
119
  this.updateButtonPosition();
120
120
  this.updateAddButtonState();
121
+ this.updateChildDragHandlers();
121
122
  });
122
123
  }
123
124
  return handledBySuper;
124
125
  }
126
+ updateChildDragHandlers() {
127
+ const dragHandlers = this.container.querySelectorAll('.drag-handler');
128
+ dragHandlers.forEach((handler) => handler.remove());
129
+ const figureElements = this.container.querySelectorAll('figure');
130
+ figureElements.forEach((figureElement) => {
131
+ const figureView = figureElement.__figureView;
132
+ figureView?.addTools();
133
+ });
134
+ }
125
135
  updateContents() {
126
136
  super.updateContents();
127
137
  requestAnimationFrame(() => {
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.4.5';
1
+ export const VERSION = '3.4.7';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -57,6 +57,15 @@ export class FigureEditableView extends FigureView {
57
57
  this.upload = this.upload.bind(this);
58
58
  this.createDOM();
59
59
  this.updateContents();
60
+ const domElement = this.dom;
61
+ domElement.__figureView = this;
62
+ }
63
+ update(newNode) {
64
+ const handledBySuper = super.update(newNode);
65
+ if (handledBySuper) {
66
+ this.addTools();
67
+ }
68
+ return handledBySuper;
60
69
  }
61
70
  clearTargetClass(target, classes = ['drop-target-above', 'drop-target-below']) {
62
71
  target.classList.remove(...classes);
@@ -188,11 +197,14 @@ export class FigureEditableView extends FigureView {
188
197
  }
189
198
  addTools() {
190
199
  this.manageReactTools();
200
+ const existingDragHandlers = this.container.querySelectorAll('.drag-handler');
201
+ existingDragHandlers.forEach((handler) => handler.remove());
191
202
  const $pos = this.view.state.doc.resolve(this.getPos());
192
203
  const parent = $pos.parent;
193
204
  if (this.props.getCapabilities()?.editArticle &&
194
205
  parent.type === schema.nodes.figure_element &&
195
- !isDeleted(this.node)) {
206
+ !isDeleted(this.node) &&
207
+ this.countFigures() > 1) {
196
208
  const dragHandle = document.createElement('div');
197
209
  dragHandle.className = 'drag-handler';
198
210
  dragHandle.innerHTML = draggableIcon;
@@ -115,10 +115,20 @@ export class FigureElementView extends ImageElementView {
115
115
  requestAnimationFrame(() => {
116
116
  this.updateButtonPosition();
117
117
  this.updateAddButtonState();
118
+ this.updateChildDragHandlers();
118
119
  });
119
120
  }
120
121
  return handledBySuper;
121
122
  }
123
+ updateChildDragHandlers() {
124
+ const dragHandlers = this.container.querySelectorAll('.drag-handler');
125
+ dragHandlers.forEach((handler) => handler.remove());
126
+ const figureElements = this.container.querySelectorAll('figure');
127
+ figureElements.forEach((figureElement) => {
128
+ const figureView = figureElement.__figureView;
129
+ figureView?.addTools();
130
+ });
131
+ }
122
132
  updateContents() {
123
133
  super.updateContents();
124
134
  requestAnimationFrame(() => {
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.4.5";
1
+ export declare const VERSION = "3.4.7";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { ManuscriptNode } from '@manuscripts/transform';
16
17
  import { FigureView } from './figure';
17
18
  export declare class FigureEditableView extends FigureView {
18
19
  reactTools: HTMLDivElement | null;
@@ -22,6 +23,7 @@ export declare class FigureEditableView extends FigureView {
22
23
  private static currentDragFigureId;
23
24
  private dragAndDropInitialized;
24
25
  initialise(): void;
26
+ update(newNode: ManuscriptNode): boolean;
25
27
  private clearTargetClass;
26
28
  private handleDragStart;
27
29
  private setupDragAndDrop;
@@ -29,7 +31,7 @@ export declare class FigureEditableView extends FigureView {
29
31
  private moveFigure;
30
32
  upload: (file: File) => Promise<void>;
31
33
  updateContents(): void;
32
- protected addTools(): void;
34
+ addTools(): void;
33
35
  countFigures(): number;
34
36
  private manageReactTools;
35
37
  protected setSrc: (src: string) => void;
@@ -26,6 +26,7 @@ export declare class FigureElementView extends ImageElementView {
26
26
  private updateButtonPosition;
27
27
  private updateAddButtonState;
28
28
  update(node: Node): boolean;
29
+ private updateChildDragHandlers;
29
30
  updateContents(): void;
30
31
  private addFigure;
31
32
  destroy(): 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.4.5",
4
+ "version": "3.4.7",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -1717,6 +1717,9 @@ th:hover > .table-context-menu-button,
1717
1717
  margin: 4px 0 0 0;
1718
1718
  }
1719
1719
 
1720
+ .prosemirror-dropcursor-block {
1721
+ background-color: transparent !important;
1722
+ }
1720
1723
  .ProseMirror .add-button {
1721
1724
  border: 0px;
1722
1725
  z-index: 1;
@@ -1792,7 +1795,7 @@ th:hover > .table-context-menu-button,
1792
1795
  }
1793
1796
  .ProseMirror .block-trans_abstract section.block.trans-abstract {
1794
1797
  padding: 0 !important;
1795
- }
1798
+ }
1796
1799
  .ProseMirror .abstracts.empty-node .add-translation-container {
1797
1800
  display: none;
1798
1801
  }