@manuscripts/body-editor 3.2.26 → 3.2.29

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.2.26';
4
+ exports.VERSION = '3.2.29';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -51,7 +51,6 @@ class FigureElementView extends image_element_1.ImageElementView {
51
51
  }
52
52
  initialise() {
53
53
  super.initialise();
54
- requestAnimationFrame(() => this.updateButtonPosition());
55
54
  this.setupResizeObserver();
56
55
  }
57
56
  setupResizeObserver() {
@@ -90,17 +89,45 @@ class FigureElementView extends image_element_1.ImageElementView {
90
89
  const relativeTop = lastFigureRect.bottom - containerRect.top + 20;
91
90
  this.addFigureBtn.style.top = `${relativeTop}px`;
92
91
  }
92
+ updateAddButtonState() {
93
+ if (!this.addFigureBtn) {
94
+ return;
95
+ }
96
+ let hasEmptyFigure = false;
97
+ this.node.forEach((node) => {
98
+ if (node.type === transform_1.schema.nodes.figure) {
99
+ const src = node.attrs.src || '';
100
+ if (src.trim().length === 0) {
101
+ hasEmptyFigure = true;
102
+ }
103
+ }
104
+ });
105
+ if (hasEmptyFigure) {
106
+ this.addFigureBtn.classList.add('disabled');
107
+ this.addFigureBtn.disabled = true;
108
+ }
109
+ else {
110
+ this.addFigureBtn.classList.remove('disabled');
111
+ this.addFigureBtn.disabled = false;
112
+ }
113
+ }
93
114
  update(node) {
94
115
  const handledBySuper = super.update(node);
95
116
  if (handledBySuper) {
96
117
  this.setupResizeObserver();
97
- requestAnimationFrame(() => this.updateButtonPosition());
118
+ requestAnimationFrame(() => {
119
+ this.updateButtonPosition();
120
+ this.updateAddButtonState();
121
+ });
98
122
  }
99
123
  return handledBySuper;
100
124
  }
101
125
  updateContents() {
102
126
  super.updateContents();
103
- requestAnimationFrame(() => this.updateButtonPosition());
127
+ requestAnimationFrame(() => {
128
+ this.updateButtonPosition();
129
+ this.updateAddButtonState();
130
+ });
104
131
  }
105
132
  destroy() {
106
133
  if (this.resizeObserver) {
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.2.26';
1
+ export const VERSION = '3.2.29';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -48,7 +48,6 @@ export class FigureElementView extends ImageElementView {
48
48
  }
49
49
  initialise() {
50
50
  super.initialise();
51
- requestAnimationFrame(() => this.updateButtonPosition());
52
51
  this.setupResizeObserver();
53
52
  }
54
53
  setupResizeObserver() {
@@ -87,17 +86,45 @@ export class FigureElementView extends ImageElementView {
87
86
  const relativeTop = lastFigureRect.bottom - containerRect.top + 20;
88
87
  this.addFigureBtn.style.top = `${relativeTop}px`;
89
88
  }
89
+ updateAddButtonState() {
90
+ if (!this.addFigureBtn) {
91
+ return;
92
+ }
93
+ let hasEmptyFigure = false;
94
+ this.node.forEach((node) => {
95
+ if (node.type === schema.nodes.figure) {
96
+ const src = node.attrs.src || '';
97
+ if (src.trim().length === 0) {
98
+ hasEmptyFigure = true;
99
+ }
100
+ }
101
+ });
102
+ if (hasEmptyFigure) {
103
+ this.addFigureBtn.classList.add('disabled');
104
+ this.addFigureBtn.disabled = true;
105
+ }
106
+ else {
107
+ this.addFigureBtn.classList.remove('disabled');
108
+ this.addFigureBtn.disabled = false;
109
+ }
110
+ }
90
111
  update(node) {
91
112
  const handledBySuper = super.update(node);
92
113
  if (handledBySuper) {
93
114
  this.setupResizeObserver();
94
- requestAnimationFrame(() => this.updateButtonPosition());
115
+ requestAnimationFrame(() => {
116
+ this.updateButtonPosition();
117
+ this.updateAddButtonState();
118
+ });
95
119
  }
96
120
  return handledBySuper;
97
121
  }
98
122
  updateContents() {
99
123
  super.updateContents();
100
- requestAnimationFrame(() => this.updateButtonPosition());
124
+ requestAnimationFrame(() => {
125
+ this.updateButtonPosition();
126
+ this.updateAddButtonState();
127
+ });
101
128
  }
102
129
  destroy() {
103
130
  if (this.resizeObserver) {
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.2.26";
1
+ export declare const VERSION = "3.2.29";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
@@ -24,6 +24,7 @@ export declare class FigureElementView extends ImageElementView {
24
24
  private setupResizeObserver;
25
25
  private addFigureElementButtons;
26
26
  private updateButtonPosition;
27
+ private updateAddButtonState;
27
28
  update(node: Node): boolean;
28
29
  updateContents(): void;
29
30
  private addFigure;
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.2.26",
4
+ "version": "3.2.29",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -38,9 +38,9 @@
38
38
  "@citation-js/plugin-pubmed": "0.3.0",
39
39
  "@citation-js/plugin-ris": "0.7.18",
40
40
  "@manuscripts/json-schema": "2.2.12",
41
- "@manuscripts/style-guide": "3.1.5",
42
- "@manuscripts/track-changes-plugin": "2.0.4",
43
- "@manuscripts/transform": "4.2.7",
41
+ "@manuscripts/style-guide": "3.1.6",
42
+ "@manuscripts/track-changes-plugin": "2.0.5",
43
+ "@manuscripts/transform": "4.2.9",
44
44
  "@popperjs/core": "2.11.8",
45
45
  "citeproc": "2.4.63",
46
46
  "codemirror": "5.65.19",
@@ -56,7 +56,7 @@
56
56
  "prosemirror-commands": "1.7.1",
57
57
  "prosemirror-history": "1.4.1",
58
58
  "prosemirror-keymap": "1.2.3",
59
- "prosemirror-model": "1.25.1",
59
+ "prosemirror-model": "1.25.0",
60
60
  "prosemirror-state": "1.4.3",
61
61
  "prosemirror-view": "1.40.0",
62
62
  "prosemirror-collab": "1.3.1",