@manuscripts/body-editor 3.12.54 → 3.12.56

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.
@@ -60,6 +60,10 @@ const createLanguageMenu = (props, selectedCode, onSelect) => {
60
60
  });
61
61
  return { menu, destroy };
62
62
  };
63
+ const getInsertionPos = (doc, nodePos) => {
64
+ const node = doc.nodeAt(nodePos);
65
+ return node ? nodePos + node.nodeSize : null;
66
+ };
63
67
  exports.default = (props) => new prosemirror_state_1.Plugin({
64
68
  props: {
65
69
  decorations: (state) => {
@@ -83,7 +87,7 @@ exports.default = (props) => new prosemirror_state_1.Plugin({
83
87
  (0, commands_1.insertTransGraphicalAbstract)(category)(state)
84
88
  : canEditTransAbstract;
85
89
  if (canEdit) {
86
- widgets.push(prosemirror_view_1.Decoration.widget(pos + 2, (view) => {
90
+ widgets.push(prosemirror_view_1.Decoration.widget(pos + 1, (view) => {
87
91
  const $span = document.createElement('span');
88
92
  $span.tabIndex = 0;
89
93
  $span.className = 'add-trans-abstract';
@@ -92,17 +96,21 @@ exports.default = (props) => new prosemirror_state_1.Plugin({
92
96
  const handleActivate = (event) => {
93
97
  event.preventDefault();
94
98
  event.stopPropagation();
99
+ const insertPos = getInsertionPos(view.state.doc, pos);
100
+ if (insertPos == null) {
101
+ return;
102
+ }
95
103
  if (isGraphical && category) {
96
- (0, commands_1.insertTransGraphicalAbstract)(category, pos + node.nodeSize)(view.state, view.dispatch, view);
104
+ (0, commands_1.insertTransGraphicalAbstract)(category, insertPos)(view.state, view.dispatch, view);
97
105
  }
98
106
  else {
99
- (0, commands_1.insertTransAbstract)(view.state, view.dispatch, node.attrs.category, pos + node.nodeSize);
107
+ (0, commands_1.insertTransAbstract)(view.state, view.dispatch, node.attrs.category, insertPos);
100
108
  }
101
109
  };
102
110
  $span.addEventListener('mousedown', handleActivate);
103
111
  $span.addEventListener('keydown', (0, navigation_utils_1.handleEnterKey)(handleActivate));
104
112
  return $span;
105
- }, { key: `add-trans-${node.attrs.id || pos}`, side: -1 }));
113
+ }, { key: `add-trans-${node.attrs.id}-${pos}` }));
106
114
  }
107
115
  }
108
116
  const isTransNode = node.type === transform_1.schema.nodes.trans_abstract ||
@@ -111,7 +119,7 @@ exports.default = (props) => new prosemirror_state_1.Plugin({
111
119
  const canEdit = node.type === transform_1.schema.nodes.trans_abstract
112
120
  ? canEditTransAbstract
113
121
  : canEditTransGraphicalAbstract;
114
- widgets.push(prosemirror_view_1.Decoration.widget(pos + 2, (view) => {
122
+ widgets.push(prosemirror_view_1.Decoration.widget(pos + 1, (view) => {
115
123
  const $btn = document.createElement('span');
116
124
  $btn.className = 'language-selector-btn';
117
125
  $btn.setAttribute('data-cy', 'language-selector-btn');
@@ -148,7 +156,9 @@ exports.default = (props) => new prosemirror_state_1.Plugin({
148
156
  $btn.addEventListener('mousedown', handleOpenMenu);
149
157
  }
150
158
  return $btn;
151
- }, { key: `lang-selector-${node.attrs.id}`, side: -1 }));
159
+ }, {
160
+ key: `lang-selector-${node.attrs.id}-${pos}-${node.attrs.lang}`,
161
+ }));
152
162
  }
153
163
  });
154
164
  return prosemirror_view_1.DecorationSet.create(state.doc, widgets);
@@ -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.12.54';
4
+ exports.VERSION = '3.12.56';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -58,6 +58,10 @@ const createLanguageMenu = (props, selectedCode, onSelect) => {
58
58
  });
59
59
  return { menu, destroy };
60
60
  };
61
+ const getInsertionPos = (doc, nodePos) => {
62
+ const node = doc.nodeAt(nodePos);
63
+ return node ? nodePos + node.nodeSize : null;
64
+ };
61
65
  export default (props) => new Plugin({
62
66
  props: {
63
67
  decorations: (state) => {
@@ -81,7 +85,7 @@ export default (props) => new Plugin({
81
85
  insertTransGraphicalAbstract(category)(state)
82
86
  : canEditTransAbstract;
83
87
  if (canEdit) {
84
- widgets.push(Decoration.widget(pos + 2, (view) => {
88
+ widgets.push(Decoration.widget(pos + 1, (view) => {
85
89
  const $span = document.createElement('span');
86
90
  $span.tabIndex = 0;
87
91
  $span.className = 'add-trans-abstract';
@@ -90,17 +94,21 @@ export default (props) => new Plugin({
90
94
  const handleActivate = (event) => {
91
95
  event.preventDefault();
92
96
  event.stopPropagation();
97
+ const insertPos = getInsertionPos(view.state.doc, pos);
98
+ if (insertPos == null) {
99
+ return;
100
+ }
93
101
  if (isGraphical && category) {
94
- insertTransGraphicalAbstract(category, pos + node.nodeSize)(view.state, view.dispatch, view);
102
+ insertTransGraphicalAbstract(category, insertPos)(view.state, view.dispatch, view);
95
103
  }
96
104
  else {
97
- insertTransAbstract(view.state, view.dispatch, node.attrs.category, pos + node.nodeSize);
105
+ insertTransAbstract(view.state, view.dispatch, node.attrs.category, insertPos);
98
106
  }
99
107
  };
100
108
  $span.addEventListener('mousedown', handleActivate);
101
109
  $span.addEventListener('keydown', handleEnterKey(handleActivate));
102
110
  return $span;
103
- }, { key: `add-trans-${node.attrs.id || pos}`, side: -1 }));
111
+ }, { key: `add-trans-${node.attrs.id}-${pos}` }));
104
112
  }
105
113
  }
106
114
  const isTransNode = node.type === schema.nodes.trans_abstract ||
@@ -109,7 +117,7 @@ export default (props) => new Plugin({
109
117
  const canEdit = node.type === schema.nodes.trans_abstract
110
118
  ? canEditTransAbstract
111
119
  : canEditTransGraphicalAbstract;
112
- widgets.push(Decoration.widget(pos + 2, (view) => {
120
+ widgets.push(Decoration.widget(pos + 1, (view) => {
113
121
  const $btn = document.createElement('span');
114
122
  $btn.className = 'language-selector-btn';
115
123
  $btn.setAttribute('data-cy', 'language-selector-btn');
@@ -146,7 +154,9 @@ export default (props) => new Plugin({
146
154
  $btn.addEventListener('mousedown', handleOpenMenu);
147
155
  }
148
156
  return $btn;
149
- }, { key: `lang-selector-${node.attrs.id}`, side: -1 }));
157
+ }, {
158
+ key: `lang-selector-${node.attrs.id}-${pos}-${node.attrs.lang}`,
159
+ }));
150
160
  }
151
161
  });
152
162
  return DecorationSet.create(state.doc, widgets);
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.12.54';
1
+ export const VERSION = '3.12.56';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.12.54";
1
+ export declare const VERSION = "3.12.56";
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": "3.12.54",
4
+ "version": "3.12.56",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -40,7 +40,7 @@
40
40
  "@citation-js/plugin-pubmed": "0.3.0",
41
41
  "@citation-js/plugin-ris": "0.7.18",
42
42
  "@iarna/word-count": "1.1.2",
43
- "@manuscripts/style-guide": "3.5.25",
43
+ "@manuscripts/style-guide": "3.5.26",
44
44
  "@manuscripts/track-changes-plugin": "2.3.13",
45
45
  "@manuscripts/transform": "4.3.51",
46
46
  "@popperjs/core": "2.11.8",
@@ -1880,11 +1880,23 @@ th:hover > .table-context-menu-button,
1880
1880
  position: relative;
1881
1881
  }
1882
1882
 
1883
+ /* Right padding so abstract titles do not run under translation widgets.
1884
+ * If we later block editing these titles, this padding can go away.
1885
+ */
1886
+ .ProseMirror .abstracts .block-section .block-section_title h1,
1887
+ .ProseMirror .abstracts .block-trans_abstract .block-section_title h1{
1888
+ padding-right: 150px;
1889
+ }
1890
+
1883
1891
  .ProseMirror .add-trans-abstract {
1884
- display: inline-flex;
1892
+ display: flex;
1885
1893
  align-items: center;
1886
- float: right;
1887
1894
  gap: 8px;
1895
+ margin: 8px 0;
1896
+ padding: 6px 12px;
1897
+ position: absolute;
1898
+ right: 50px;
1899
+ top: 0;
1888
1900
  z-index: 5;
1889
1901
  cursor: pointer;
1890
1902
  background: unset;
@@ -1920,13 +1932,18 @@ th:hover > .table-context-menu-button,
1920
1932
  }
1921
1933
  .ProseMirror .block-trans_abstract .language-selector-btn,
1922
1934
  .ProseMirror .block-trans_graphical_abstract .language-selector-btn {
1923
- display: inline-flex;
1924
- float: right;
1935
+ display: flex;
1936
+ position: absolute;
1937
+ top: 14px;
1938
+ right: 50px;
1925
1939
  line-height: 1.6;
1926
1940
  background: unset;
1927
1941
  border: none;
1942
+ padding: 0;
1943
+ margin: 0 6px;
1928
1944
  cursor: pointer;
1929
1945
  z-index: 10;
1946
+ align-items: end;
1930
1947
  gap: 8px;
1931
1948
  font-size: 14px;
1932
1949
  color: #6e6e6e;