@manuscripts/body-editor 2.6.2-LEAN-4073.1 → 2.6.2

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.
@@ -52,7 +52,7 @@ const createEditorView = (props, root, state, dispatch) => {
52
52
  transformPasted: paste_1.transformPasted,
53
53
  handlePaste: paste_1.handlePaste,
54
54
  clipboardParser: clipboard_1.clipboardParser,
55
- handleScrollToSelection: helpers_1.handleScrollToSelectedElement,
55
+ handleScrollToSelection: helpers_1.handleScrollToBibliographyItem,
56
56
  transformCopied: copy_1.transformCopied,
57
57
  handleClickOn: (view, pos, node, nodePos, event) => {
58
58
  if ((event === null || event === void 0 ? void 0 : event.target) &&
package/dist/cjs/index.js CHANGED
@@ -56,7 +56,6 @@ __exportStar(require("./lib/utils"), exports);
56
56
  __exportStar(require("./lib/track-changes-utils"), exports);
57
57
  __exportStar(require("./useEditor"), exports);
58
58
  __exportStar(require("./lib/math"), exports);
59
- __exportStar(require("./lib/helpers"), exports);
60
59
  var objects_1 = require("./plugins/objects");
61
60
  Object.defineProperty(exports, "objectsPluginKey", { enumerable: true, get: function () { return objects_1.objectsKey; } });
62
61
  var footnotes_1 = require("./plugins/footnotes");
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.findWordBoundaries = exports.handleScrollToSelectedElement = exports.mergeSimilarItems = exports.nearestAncestor = exports.isNodeOfType = void 0;
18
+ exports.findWordBoundaries = exports.handleScrollToBibliographyItem = exports.mergeSimilarItems = exports.nearestAncestor = exports.isNodeOfType = void 0;
19
19
  const transform_1 = require("@manuscripts/transform");
20
20
  const isNodeOfType = (...type) => (node) => {
21
21
  const [head, ...tail] = type;
@@ -51,38 +51,30 @@ const mergeSimilarItems = (compareFunc, mergeFunc) => (items) => {
51
51
  }, []);
52
52
  };
53
53
  exports.mergeSimilarItems = mergeSimilarItems;
54
- const scrollToElement = (element) => {
55
- const elementRect = element.getBoundingClientRect();
56
- const editorBodyElement = document.querySelector('.editor-body');
57
- const parentRect = editorBodyElement.getBoundingClientRect();
58
- if (elementRect.bottom > window.innerHeight || elementRect.top < 150) {
59
- let childTopOffset = elementRect.top - parentRect.top;
60
- childTopOffset =
61
- childTopOffset - (window.innerHeight - elementRect.height) / 2;
62
- const scrollToTop = editorBodyElement.scrollTop + childTopOffset;
63
- editorBodyElement.scrollTo({ top: scrollToTop, behavior: 'smooth' });
64
- }
65
- };
66
- const handleScrollToSelectedElement = (view, targetHtmlElement) => {
54
+ const handleScrollToBibliographyItem = (view) => {
67
55
  const tr = view.state.tr;
68
56
  const node = tr.doc.nodeAt(tr.selection.$from.pos);
69
- if (!node) {
57
+ if (!node || node.type !== transform_1.schema.nodes.bibliography_item) {
70
58
  return false;
71
59
  }
72
- if (node.type === transform_1.schema.nodes.bibliography_item) {
73
- const bibliographyItemElement = document.querySelector(`[id="${node.attrs.id}"]`);
74
- if (bibliographyItemElement) {
75
- scrollToElement(bibliographyItemElement);
76
- return true;
77
- }
60
+ const bibliographyItemElement = document.querySelector(`[id="${node.attrs.id}"]`);
61
+ if (!bibliographyItemElement) {
62
+ return false;
78
63
  }
79
- if (targetHtmlElement) {
80
- scrollToElement(targetHtmlElement);
81
- return true;
64
+ const bibliographyItemRect = bibliographyItemElement.getBoundingClientRect();
65
+ const editorBodyElement = document.querySelector('.editor-body');
66
+ const parentRect = editorBodyElement.getBoundingClientRect();
67
+ if (bibliographyItemRect.bottom > window.innerHeight ||
68
+ bibliographyItemRect.top < 150) {
69
+ let childTopOffset = bibliographyItemRect.top - parentRect.top;
70
+ childTopOffset =
71
+ childTopOffset - (window.innerHeight - bibliographyItemRect.height) / 2;
72
+ const scrollToTop = editorBodyElement.scrollTop + childTopOffset;
73
+ editorBodyElement.scrollTo({ top: scrollToTop, behavior: 'smooth' });
82
74
  }
83
- return false;
75
+ return true;
84
76
  };
85
- exports.handleScrollToSelectedElement = handleScrollToSelectedElement;
77
+ exports.handleScrollToBibliographyItem = handleScrollToBibliographyItem;
86
78
  const findWordBoundaries = (state, position) => {
87
79
  let start = position;
88
80
  let end = position;
@@ -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 = '2.6.2-LEAN-4073.1';
4
+ exports.VERSION = '2.6.2';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -19,7 +19,7 @@ import { EditorState } from 'prosemirror-state';
19
19
  import { EditorView } from 'prosemirror-view';
20
20
  import { clipboardParser } from '../clipboard';
21
21
  import { transformCopied } from '../lib/copy';
22
- import { handleScrollToSelectedElement } from '../lib/helpers';
22
+ import { handleScrollToBibliographyItem } from '../lib/helpers';
23
23
  import { handlePaste, transformPasted } from '../lib/paste';
24
24
  import { INIT_META } from '../lib/plugins';
25
25
  import plugins from './editor-plugins';
@@ -45,7 +45,7 @@ export const createEditorView = (props, root, state, dispatch) => {
45
45
  transformPasted,
46
46
  handlePaste,
47
47
  clipboardParser,
48
- handleScrollToSelection: handleScrollToSelectedElement,
48
+ handleScrollToSelection: handleScrollToBibliographyItem,
49
49
  transformCopied,
50
50
  handleClickOn: (view, pos, node, nodePos, event) => {
51
51
  if ((event === null || event === void 0 ? void 0 : event.target) &&
package/dist/es/index.js CHANGED
@@ -33,7 +33,6 @@ export * from './lib/utils';
33
33
  export * from './lib/track-changes-utils';
34
34
  export * from './useEditor';
35
35
  export * from './lib/math';
36
- export * from './lib/helpers';
37
36
  export { objectsKey as objectsPluginKey } from './plugins/objects';
38
37
  export { footnotesKey as footnotesPluginKey } from './plugins/footnotes';
39
38
  export { bibliographyKey as bibliographyPluginKey } from './plugins/bibliography';
@@ -45,36 +45,28 @@ export const mergeSimilarItems = (compareFunc, mergeFunc) => (items) => {
45
45
  ];
46
46
  }, []);
47
47
  };
48
- const scrollToElement = (element) => {
49
- const elementRect = element.getBoundingClientRect();
50
- const editorBodyElement = document.querySelector('.editor-body');
51
- const parentRect = editorBodyElement.getBoundingClientRect();
52
- if (elementRect.bottom > window.innerHeight || elementRect.top < 150) {
53
- let childTopOffset = elementRect.top - parentRect.top;
54
- childTopOffset =
55
- childTopOffset - (window.innerHeight - elementRect.height) / 2;
56
- const scrollToTop = editorBodyElement.scrollTop + childTopOffset;
57
- editorBodyElement.scrollTo({ top: scrollToTop, behavior: 'smooth' });
58
- }
59
- };
60
- export const handleScrollToSelectedElement = (view, targetHtmlElement) => {
48
+ export const handleScrollToBibliographyItem = (view) => {
61
49
  const tr = view.state.tr;
62
50
  const node = tr.doc.nodeAt(tr.selection.$from.pos);
63
- if (!node) {
51
+ if (!node || node.type !== schema.nodes.bibliography_item) {
64
52
  return false;
65
53
  }
66
- if (node.type === schema.nodes.bibliography_item) {
67
- const bibliographyItemElement = document.querySelector(`[id="${node.attrs.id}"]`);
68
- if (bibliographyItemElement) {
69
- scrollToElement(bibliographyItemElement);
70
- return true;
71
- }
54
+ const bibliographyItemElement = document.querySelector(`[id="${node.attrs.id}"]`);
55
+ if (!bibliographyItemElement) {
56
+ return false;
72
57
  }
73
- if (targetHtmlElement) {
74
- scrollToElement(targetHtmlElement);
75
- return true;
58
+ const bibliographyItemRect = bibliographyItemElement.getBoundingClientRect();
59
+ const editorBodyElement = document.querySelector('.editor-body');
60
+ const parentRect = editorBodyElement.getBoundingClientRect();
61
+ if (bibliographyItemRect.bottom > window.innerHeight ||
62
+ bibliographyItemRect.top < 150) {
63
+ let childTopOffset = bibliographyItemRect.top - parentRect.top;
64
+ childTopOffset =
65
+ childTopOffset - (window.innerHeight - bibliographyItemRect.height) / 2;
66
+ const scrollToTop = editorBodyElement.scrollTop + childTopOffset;
67
+ editorBodyElement.scrollTo({ top: scrollToTop, behavior: 'smooth' });
76
68
  }
77
- return false;
69
+ return true;
78
70
  };
79
71
  export const findWordBoundaries = (state, position) => {
80
72
  let start = position;
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.6.2-LEAN-4073.1';
1
+ export const VERSION = '2.6.2';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -34,7 +34,6 @@ export * from './lib/utils';
34
34
  export * from './lib/track-changes-utils';
35
35
  export * from './useEditor';
36
36
  export * from './lib/math';
37
- export * from './lib/helpers';
38
37
  export { objectsKey as objectsPluginKey } from './plugins/objects';
39
38
  export { footnotesKey as footnotesPluginKey } from './plugins/footnotes';
40
39
  export { bibliographyKey as bibliographyPluginKey } from './plugins/bibliography';
@@ -19,7 +19,7 @@ import { EditorView } from 'prosemirror-view';
19
19
  export declare const isNodeOfType: (...type: string[]) => (node: Node) => boolean;
20
20
  export declare const nearestAncestor: (func: (node: ManuscriptNode) => boolean) => ($pos: ResolvedPos) => number | null;
21
21
  export declare const mergeSimilarItems: <T>(compareFunc: (a: T, b: T) => boolean, mergeFunc: (a: T, b: T) => T) => (items: T[]) => T[];
22
- export declare const handleScrollToSelectedElement: (view: EditorView, targetHtmlElement?: HTMLElement) => boolean;
22
+ export declare const handleScrollToBibliographyItem: (view: EditorView) => boolean;
23
23
  export declare const findWordBoundaries: (state: ManuscriptEditorState, position: number) => {
24
24
  from: number;
25
25
  to: number;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.6.2-LEAN-4073.1";
1
+ export declare const VERSION = "2.6.2";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
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": "2.6.2-LEAN-4073.1",
4
+ "version": "2.6.2",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -32,7 +32,7 @@
32
32
  "@iarna/word-count": "^1.1.2",
33
33
  "@manuscripts/json-schema": "2.2.11",
34
34
  "@manuscripts/library": "1.3.11",
35
- "@manuscripts/style-guide": "2.0.22",
35
+ "@manuscripts/style-guide": "2.0.23",
36
36
  "@manuscripts/track-changes-plugin": "1.8.1",
37
37
  "@manuscripts/transform": "3.0.12",
38
38
  "@popperjs/core": "^2.11.8",