@manuscripts/body-editor 3.10.15 → 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.
@@ -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) {
@@ -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.15';
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;
@@ -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) {
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.10.15';
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.15";
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.15",
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",