@manuscripts/body-editor 3.10.14 → 3.10.16

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.
@@ -28,7 +28,10 @@ const upsertSupplementsSection = (tr, supplement) => {
28
28
  return { node: supplements.node, pos };
29
29
  }
30
30
  const pos = (0, utils_1.findInsertionPosition)(transform_1.schema.nodes.supplements, doc);
31
- const node = transform_1.schema.nodes.supplements.createAndFill({ id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.supplements) }, [supplement]);
31
+ const node = transform_1.schema.nodes.supplements.createAndFill({ id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.supplements) }, [
32
+ transform_1.schema.nodes.section_title.create(undefined, transform_1.schema.text('Supplements')),
33
+ supplement,
34
+ ]);
32
35
  tr.insert(pos, node);
33
36
  return {
34
37
  node,
@@ -22,7 +22,7 @@ class PopperManager {
22
22
  constructor() {
23
23
  this.isActive = () => !!this.activePopper;
24
24
  }
25
- show(target, contents, placement = 'bottom', showArrow = true, modifiers = []) {
25
+ show(target, contents, placement = 'bottom', showArrow = true, modifiers = [], autoFocus = true) {
26
26
  this.destroy();
27
27
  this.triggerElement = target;
28
28
  window.requestAnimationFrame(() => {
@@ -73,7 +73,7 @@ class PopperManager {
73
73
  modifiers,
74
74
  onFirstUpdate: () => {
75
75
  this.addContainerClass(target);
76
- this.focusInput(container);
76
+ this.focusInput(container, autoFocus);
77
77
  },
78
78
  });
79
79
  this.handleDocumentClick = (e) => {
@@ -109,12 +109,15 @@ class PopperManager {
109
109
  this.activePopper.update();
110
110
  }
111
111
  }
112
- focusInput(container) {
112
+ focusInput(container, autoFocus = true) {
113
113
  const input = container.querySelector('input');
114
- const button = container.querySelector('button:not([disabled])');
115
- const element = input || button;
116
- if (element) {
117
- element.focus();
114
+ if (input) {
115
+ input.focus();
116
+ return;
117
+ }
118
+ if (autoFocus) {
119
+ const button = container.querySelector('button:not([disabled])');
120
+ button?.focus();
118
121
  }
119
122
  }
120
123
  addContainerClass(referenceElement) {
@@ -206,6 +206,7 @@ const getDecorationPos = (node, pos) => {
206
206
  case transform_1.schema.nodes.embed:
207
207
  case transform_1.schema.nodes.contributors:
208
208
  case transform_1.schema.nodes.hero_image:
209
+ case transform_1.schema.nodes.supplements:
209
210
  return pos;
210
211
  case transform_1.schema.nodes.keywords:
211
212
  return pos + 2;
@@ -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.10.14';
4
+ exports.VERSION = '3.10.16';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -48,7 +48,7 @@ class CitationEditableView extends citation_1.CitationView {
48
48
  element.classList.contains('comment-icon') ||
49
49
  element.parentElement?.classList.contains('comment-icon'));
50
50
  };
51
- this.handleClick = () => {
51
+ this.handleClick = (fromKeyboard) => {
52
52
  if (!this.can.seeReferencesButtons ||
53
53
  this.dom.classList.contains('inconsistency-highlight')) {
54
54
  this.showPopper();
@@ -56,7 +56,7 @@ class CitationEditableView extends citation_1.CitationView {
56
56
  else if (!(0, track_changes_utils_1.isDeleted)(this.node)) {
57
57
  const attrs = this.node.attrs;
58
58
  if (attrs.rids.length) {
59
- this.showContextMenu();
59
+ this.showContextMenu(fromKeyboard);
60
60
  }
61
61
  }
62
62
  };
@@ -75,7 +75,7 @@ class CitationEditableView extends citation_1.CitationView {
75
75
  this.editor?.remove();
76
76
  this.props.popper.destroy();
77
77
  };
78
- this.showContextMenu = () => {
78
+ this.showContextMenu = (autoFocus = true) => {
79
79
  this.props.popper.destroy();
80
80
  const can = this.props.getCapabilities();
81
81
  const actions = [
@@ -96,7 +96,7 @@ class CitationEditableView extends citation_1.CitationView {
96
96
  actions,
97
97
  };
98
98
  this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
99
- this.props.popper.show(this.dom, this.contextMenu, 'right-start', false);
99
+ this.props.popper.show(this.dom, this.contextMenu, 'right-start', false, [], autoFocus);
100
100
  };
101
101
  this.showPopper = () => {
102
102
  this.props.popper.destroy();
@@ -197,8 +197,8 @@ class CitationEditableView extends citation_1.CitationView {
197
197
  }
198
198
  createDOM() {
199
199
  super.createDOM();
200
- this.dom.addEventListener('mouseup', this.handleClick);
201
- this.dom.addEventListener('keydown', (0, navigation_utils_1.handleEnterKey)(() => this.handleClick()));
200
+ this.dom.addEventListener('mouseup', () => this.handleClick(false));
201
+ this.dom.addEventListener('keydown', (0, navigation_utils_1.handleEnterKey)(() => this.handleClick(true)));
202
202
  }
203
203
  insertBibliographyNode(attrs) {
204
204
  const { doc, tr } = this.view.state;
@@ -24,7 +24,10 @@ export const upsertSupplementsSection = (tr, supplement) => {
24
24
  return { node: supplements.node, pos };
25
25
  }
26
26
  const pos = findInsertionPosition(schema.nodes.supplements, doc);
27
- const node = schema.nodes.supplements.createAndFill({ id: generateNodeID(schema.nodes.supplements) }, [supplement]);
27
+ const node = schema.nodes.supplements.createAndFill({ id: generateNodeID(schema.nodes.supplements) }, [
28
+ schema.nodes.section_title.create(undefined, schema.text('Supplements')),
29
+ supplement,
30
+ ]);
28
31
  tr.insert(pos, node);
29
32
  return {
30
33
  node,
@@ -19,7 +19,7 @@ export class PopperManager {
19
19
  constructor() {
20
20
  this.isActive = () => !!this.activePopper;
21
21
  }
22
- show(target, contents, placement = 'bottom', showArrow = true, modifiers = []) {
22
+ show(target, contents, placement = 'bottom', showArrow = true, modifiers = [], autoFocus = true) {
23
23
  this.destroy();
24
24
  this.triggerElement = target;
25
25
  window.requestAnimationFrame(() => {
@@ -70,7 +70,7 @@ export class PopperManager {
70
70
  modifiers,
71
71
  onFirstUpdate: () => {
72
72
  this.addContainerClass(target);
73
- this.focusInput(container);
73
+ this.focusInput(container, autoFocus);
74
74
  },
75
75
  });
76
76
  this.handleDocumentClick = (e) => {
@@ -106,12 +106,15 @@ export class PopperManager {
106
106
  this.activePopper.update();
107
107
  }
108
108
  }
109
- focusInput(container) {
109
+ focusInput(container, autoFocus = true) {
110
110
  const input = container.querySelector('input');
111
- const button = container.querySelector('button:not([disabled])');
112
- const element = input || button;
113
- if (element) {
114
- element.focus();
111
+ if (input) {
112
+ input.focus();
113
+ return;
114
+ }
115
+ if (autoFocus) {
116
+ const button = container.querySelector('button:not([disabled])');
117
+ button?.focus();
115
118
  }
116
119
  }
117
120
  addContainerClass(referenceElement) {
@@ -201,6 +201,7 @@ const getDecorationPos = (node, pos) => {
201
201
  case schema.nodes.embed:
202
202
  case schema.nodes.contributors:
203
203
  case schema.nodes.hero_image:
204
+ case schema.nodes.supplements:
204
205
  return pos;
205
206
  case schema.nodes.keywords:
206
207
  return pos + 2;
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.10.14';
1
+ export const VERSION = '3.10.16';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -42,7 +42,7 @@ export class CitationEditableView extends CitationView {
42
42
  element.classList.contains('comment-icon') ||
43
43
  element.parentElement?.classList.contains('comment-icon'));
44
44
  };
45
- this.handleClick = () => {
45
+ this.handleClick = (fromKeyboard) => {
46
46
  if (!this.can.seeReferencesButtons ||
47
47
  this.dom.classList.contains('inconsistency-highlight')) {
48
48
  this.showPopper();
@@ -50,7 +50,7 @@ export class CitationEditableView extends CitationView {
50
50
  else if (!isDeleted(this.node)) {
51
51
  const attrs = this.node.attrs;
52
52
  if (attrs.rids.length) {
53
- this.showContextMenu();
53
+ this.showContextMenu(fromKeyboard);
54
54
  }
55
55
  }
56
56
  };
@@ -69,7 +69,7 @@ export class CitationEditableView extends CitationView {
69
69
  this.editor?.remove();
70
70
  this.props.popper.destroy();
71
71
  };
72
- this.showContextMenu = () => {
72
+ this.showContextMenu = (autoFocus = true) => {
73
73
  this.props.popper.destroy();
74
74
  const can = this.props.getCapabilities();
75
75
  const actions = [
@@ -90,7 +90,7 @@ export class CitationEditableView extends CitationView {
90
90
  actions,
91
91
  };
92
92
  this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
93
- this.props.popper.show(this.dom, this.contextMenu, 'right-start', false);
93
+ this.props.popper.show(this.dom, this.contextMenu, 'right-start', false, [], autoFocus);
94
94
  };
95
95
  this.showPopper = () => {
96
96
  this.props.popper.destroy();
@@ -191,8 +191,8 @@ export class CitationEditableView extends CitationView {
191
191
  }
192
192
  createDOM() {
193
193
  super.createDOM();
194
- this.dom.addEventListener('mouseup', this.handleClick);
195
- this.dom.addEventListener('keydown', handleEnterKey(() => this.handleClick()));
194
+ this.dom.addEventListener('mouseup', () => this.handleClick(false));
195
+ this.dom.addEventListener('keydown', handleEnterKey(() => this.handleClick(true)));
196
196
  }
197
197
  insertBibliographyNode(attrs) {
198
198
  const { doc, tr } = this.view.state;
@@ -19,7 +19,7 @@ export declare class PopperManager {
19
19
  private handleDocumentClick?;
20
20
  private triggerElement?;
21
21
  private container?;
22
- show(target: Element, contents: HTMLElement, placement?: Placement, showArrow?: boolean, modifiers?: Array<Partial<StrictModifiers>>): void;
22
+ show(target: Element, contents: HTMLElement, placement?: Placement, showArrow?: boolean, modifiers?: Array<Partial<StrictModifiers>>, autoFocus?: boolean): void;
23
23
  destroy(): void;
24
24
  getContainer(): HTMLElement | undefined;
25
25
  update(): void;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.10.14";
1
+ export declare const VERSION = "3.10.16";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
@@ -20,10 +20,10 @@ export declare class CitationEditableView extends CitationView {
20
20
  private can;
21
21
  createDOM(): void;
22
22
  stopEvent: (event: Event) => boolean;
23
- handleClick: () => void;
23
+ handleClick: (fromKeyboard: boolean) => void;
24
24
  selectNode: () => void;
25
25
  destroy: () => void;
26
- showContextMenu: () => void;
26
+ showContextMenu: (autoFocus?: boolean) => void;
27
27
  showPopper: () => void;
28
28
  private handleEdit;
29
29
  private handleCancel;
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.10.14",
4
+ "version": "3.10.16",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -555,7 +555,8 @@ ProseMirror .block-embed .position-menu {
555
555
 
556
556
  .comment-marker:has(+ .block-contributors),
557
557
  .comment-marker:has(+ .block-affiliations),
558
- .comment-marker:has(+ .block-hero_image) {
558
+ .comment-marker:has(+ .block-hero_image),
559
+ .comment-marker:has(+ .block-supplements) {
559
560
  height: 0;
560
561
  top: 0;
561
562
  right: 60px;
@@ -563,6 +564,11 @@ ProseMirror .block-embed .position-menu {
563
564
  float: right;
564
565
  }
565
566
 
567
+ .comment-marker:has(+ .block-hero_image),
568
+ .comment-marker:has(+ .block-supplements) {
569
+ right: 50px;
570
+ }
571
+
566
572
  .block-subtitles .comment-marker {
567
573
  top: 0;
568
574
  left: -10px;