@manuscripts/body-editor 1.7.10-LEAN-3338-1 → 1.7.10

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.
@@ -307,18 +307,17 @@ const insertInlineFootnote = (kind) => (state, dispatch) => {
307
307
  id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.Footnote),
308
308
  kind,
309
309
  });
310
+ const insertedAt = state.selection.to;
310
311
  const node = state.schema.nodes.inline_footnote.create({
311
312
  rids: [footnote.attrs.id],
312
313
  });
313
- const insertedAt = state.selection.to;
314
- const { tr } = state;
314
+ const tr = state.tr;
315
315
  tr.insert(insertedAt, node);
316
316
  const footnotesSection = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.footnotes_section)[0];
317
317
  let selectionPos;
318
318
  if (!footnotesSection) {
319
- const sectionTitle = 'Footnotes';
320
319
  const section = state.schema.nodes.footnotes_section.create({}, [
321
- state.schema.nodes.section_title.create({}, state.schema.text(sectionTitle)),
320
+ state.schema.nodes.section_title.create({}, state.schema.text('Notes')),
322
321
  state.schema.nodes.footnotes_element.create({}, footnote),
323
322
  ]);
324
323
  const backmatter = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.backmatter)[0];
@@ -327,25 +326,10 @@ const insertInlineFootnote = (kind) => (state, dispatch) => {
327
326
  }
328
327
  else {
329
328
  const footnoteElement = (0, prosemirror_utils_1.findChildrenByType)(footnotesSection.node, transform_1.schema.nodes.footnotes_element);
330
- let index = 0;
331
- state.doc.slice(0, insertedAt).content.descendants((node) => {
332
- if (node.type === transform_1.schema.nodes.inline_footnote) {
333
- index++;
334
- return false;
335
- }
336
- });
337
- let correctPosition = 0;
338
- if (index != 0) {
339
- footnoteElement[0].node.descendants((node, pos, parent, nodeIndex) => {
340
- if (node.type === transform_1.schema.nodes.footnote) {
341
- if (index > nodeIndex) {
342
- correctPosition = pos + node.nodeSize;
343
- return false;
344
- }
345
- }
346
- });
347
- }
348
- const pos = footnotesSection.pos + footnoteElement[0].pos + correctPosition + 2;
329
+ const pos = footnotesSection.pos +
330
+ footnoteElement[0].pos +
331
+ footnoteElement[0].node.nodeSize -
332
+ 1;
349
333
  tr.insert(pos, footnote);
350
334
  selectionPos = pos + 2;
351
335
  }
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.createFootnoteLabel = exports.isMetaNode = exports.findParentElement = exports.findParentSection = exports.findParentNodeWithIdValue = exports.findParentNodeWithId = exports.getChildOfType = exports.getMatchingDescendant = exports.getMatchingChild = exports.iterateChildren = void 0;
18
+ exports.isMetaNode = exports.findParentElement = exports.findParentSection = exports.findParentNodeWithIdValue = exports.findParentNodeWithId = exports.getChildOfType = exports.getMatchingDescendant = exports.getMatchingChild = exports.iterateChildren = void 0;
19
19
  const transform_1 = require("@manuscripts/transform");
20
20
  const prosemirror_utils_1 = require("prosemirror-utils");
21
21
  function* iterateChildren(node, recurse = false) {
@@ -62,15 +62,3 @@ const isMetaNode = (nodeType) => nodeType === transform_1.schema.nodes.bibliogra
62
62
  nodeType === transform_1.schema.nodes.affiliation.name ||
63
63
  nodeType === transform_1.schema.nodes.contributor.name;
64
64
  exports.isMetaNode = isMetaNode;
65
- const createFootnoteLabel = (id) => {
66
- const _id = parseInt(id, 10) + 1;
67
- const START = 96;
68
- const RANGE = 26;
69
- const id1 = _id % RANGE || RANGE;
70
- const id2 = Math.ceil(_id / RANGE);
71
- const label = id2 === 1
72
- ? String.fromCharCode(START + id1)
73
- : `${String.fromCharCode(START + id2 - 1)}${String.fromCharCode(START + id1)}`;
74
- return label;
75
- };
76
- exports.createFootnoteLabel = createFootnoteLabel;
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.getFootnotesPluginState = exports.uncitedFootnoteWidget = exports.buildPluginState = exports.footnotesKey = void 0;
18
+ exports.uncitedFootnoteWidget = exports.buildPluginState = exports.footnotesKey = void 0;
19
19
  const transform_1 = require("@manuscripts/transform");
20
20
  const lodash_1 = require("lodash");
21
21
  const prosemirror_state_1 = require("prosemirror-state");
@@ -36,7 +36,7 @@ const buildPluginState = (doc) => {
36
36
  parentNode.type !== transform_1.schema.nodes.table_cell) {
37
37
  nodes.push([node, pos]);
38
38
  node.attrs.rids.forEach((rid) => {
39
- labels.set(rid, (0, utils_1.createFootnoteLabel)(String(index++)));
39
+ labels.set(rid, String(++index));
40
40
  });
41
41
  }
42
42
  });
@@ -45,9 +45,8 @@ const buildPluginState = (doc) => {
45
45
  exports.buildPluginState = buildPluginState;
46
46
  const scrollToInlineFootnote = (rid, view) => {
47
47
  view.state.doc.descendants((node, pos) => {
48
- var _a;
49
48
  const footnote = node;
50
- if ((_a = footnote.attrs.rids) === null || _a === void 0 ? void 0 : _a.includes(rid)) {
49
+ if (footnote.attrs.rids.includes(rid)) {
51
50
  const selection = prosemirror_state_1.NodeSelection.create(view.state.doc, pos);
52
51
  view.dispatch(view.state.tr.setSelection(selection).scrollIntoView());
53
52
  }
@@ -149,7 +148,3 @@ exports.default = () => {
149
148
  },
150
149
  });
151
150
  };
152
- const getFootnotesPluginState = (state) => {
153
- return exports.footnotesKey.getState(state);
154
- };
155
- exports.getFootnotesPluginState = getFootnotesPluginState;
@@ -22,7 +22,7 @@ class InlineFootnoteView extends base_node_view_1.BaseNodeView {
22
22
  constructor() {
23
23
  super(...arguments);
24
24
  this.handleClick = () => {
25
- this.props.history.push(Object.assign(Object.assign({}, this.props.history.location), { hash: '#' + this.node.attrs.rids[0] }));
25
+ this.props.history.push(Object.assign(Object.assign({}, this.props.history.location), { hash: '#' + this.node.attrs.rid }));
26
26
  };
27
27
  this.updateContents = () => {
28
28
  this.setDomAttrs(this.node, this.dom);
@@ -288,18 +288,17 @@ export const insertInlineFootnote = (kind) => (state, dispatch) => {
288
288
  id: generateID(ObjectTypes.Footnote),
289
289
  kind,
290
290
  });
291
+ const insertedAt = state.selection.to;
291
292
  const node = state.schema.nodes.inline_footnote.create({
292
293
  rids: [footnote.attrs.id],
293
294
  });
294
- const insertedAt = state.selection.to;
295
- const { tr } = state;
295
+ const tr = state.tr;
296
296
  tr.insert(insertedAt, node);
297
297
  const footnotesSection = findChildrenByType(tr.doc, schema.nodes.footnotes_section)[0];
298
298
  let selectionPos;
299
299
  if (!footnotesSection) {
300
- const sectionTitle = 'Footnotes';
301
300
  const section = state.schema.nodes.footnotes_section.create({}, [
302
- state.schema.nodes.section_title.create({}, state.schema.text(sectionTitle)),
301
+ state.schema.nodes.section_title.create({}, state.schema.text('Notes')),
303
302
  state.schema.nodes.footnotes_element.create({}, footnote),
304
303
  ]);
305
304
  const backmatter = findChildrenByType(tr.doc, schema.nodes.backmatter)[0];
@@ -308,25 +307,10 @@ export const insertInlineFootnote = (kind) => (state, dispatch) => {
308
307
  }
309
308
  else {
310
309
  const footnoteElement = findChildrenByType(footnotesSection.node, schema.nodes.footnotes_element);
311
- let index = 0;
312
- state.doc.slice(0, insertedAt).content.descendants((node) => {
313
- if (node.type === schema.nodes.inline_footnote) {
314
- index++;
315
- return false;
316
- }
317
- });
318
- let correctPosition = 0;
319
- if (index != 0) {
320
- footnoteElement[0].node.descendants((node, pos, parent, nodeIndex) => {
321
- if (node.type === schema.nodes.footnote) {
322
- if (index > nodeIndex) {
323
- correctPosition = pos + node.nodeSize;
324
- return false;
325
- }
326
- }
327
- });
328
- }
329
- const pos = footnotesSection.pos + footnoteElement[0].pos + correctPosition + 2;
310
+ const pos = footnotesSection.pos +
311
+ footnoteElement[0].pos +
312
+ footnoteElement[0].node.nodeSize -
313
+ 1;
330
314
  tr.insert(pos, footnote);
331
315
  selectionPos = pos + 2;
332
316
  }
@@ -53,14 +53,3 @@ export const findParentElement = (selection, validIds) => findParentNode((node)
53
53
  export const isMetaNode = (nodeType) => nodeType === schema.nodes.bibliography_item.name ||
54
54
  nodeType === schema.nodes.affiliation.name ||
55
55
  nodeType === schema.nodes.contributor.name;
56
- export const createFootnoteLabel = (id) => {
57
- const _id = parseInt(id, 10) + 1;
58
- const START = 96;
59
- const RANGE = 26;
60
- const id1 = _id % RANGE || RANGE;
61
- const id2 = Math.ceil(_id / RANGE);
62
- const label = id2 === 1
63
- ? String.fromCharCode(START + id1)
64
- : `${String.fromCharCode(START + id2 - 1)}${String.fromCharCode(START + id1)}`;
65
- return label;
66
- };
@@ -15,11 +15,11 @@
15
15
  */
16
16
  import { isFootnoteNode, isInlineFootnoteNode, schema, } from '@manuscripts/transform';
17
17
  import { isEqual } from 'lodash';
18
- import { NodeSelection, Plugin, PluginKey, } from 'prosemirror-state';
18
+ import { NodeSelection, Plugin, PluginKey } from 'prosemirror-state';
19
19
  import { hasParentNodeOfType } from 'prosemirror-utils';
20
20
  import { Decoration, DecorationSet } from 'prosemirror-view';
21
21
  import { alertIcon } from '../../assets';
22
- import { createFootnoteLabel, findParentNodeWithIdValue } from '../../lib/utils';
22
+ import { findParentNodeWithIdValue } from '../../lib/utils';
23
23
  import { placeholderWidget } from '../placeholder';
24
24
  import { findTableInlineFootnoteIds } from './footnotes-utils';
25
25
  export const footnotesKey = new PluginKey('footnotes');
@@ -33,7 +33,7 @@ export const buildPluginState = (doc) => {
33
33
  parentNode.type !== schema.nodes.table_cell) {
34
34
  nodes.push([node, pos]);
35
35
  node.attrs.rids.forEach((rid) => {
36
- labels.set(rid, createFootnoteLabel(String(index++)));
36
+ labels.set(rid, String(++index));
37
37
  });
38
38
  }
39
39
  });
@@ -41,9 +41,8 @@ export const buildPluginState = (doc) => {
41
41
  };
42
42
  const scrollToInlineFootnote = (rid, view) => {
43
43
  view.state.doc.descendants((node, pos) => {
44
- var _a;
45
44
  const footnote = node;
46
- if ((_a = footnote.attrs.rids) === null || _a === void 0 ? void 0 : _a.includes(rid)) {
45
+ if (footnote.attrs.rids.includes(rid)) {
47
46
  const selection = NodeSelection.create(view.state.doc, pos);
48
47
  view.dispatch(view.state.tr.setSelection(selection).scrollIntoView());
49
48
  }
@@ -144,6 +143,3 @@ export default () => {
144
143
  },
145
144
  });
146
145
  };
147
- export const getFootnotesPluginState = (state) => {
148
- return footnotesKey.getState(state);
149
- };
@@ -19,7 +19,7 @@ export class InlineFootnoteView extends BaseNodeView {
19
19
  constructor() {
20
20
  super(...arguments);
21
21
  this.handleClick = () => {
22
- this.props.history.push(Object.assign(Object.assign({}, this.props.history.location), { hash: '#' + this.node.attrs.rids[0] }));
22
+ this.props.history.push(Object.assign(Object.assign({}, this.props.history.location), { hash: '#' + this.node.attrs.rid }));
23
23
  };
24
24
  this.updateContents = () => {
25
25
  this.setDomAttrs(this.node, this.dom);
@@ -24,4 +24,3 @@ export declare const findParentNodeWithIdValue: (selection: Selection) => import
24
24
  export declare const findParentSection: (selection: Selection) => import("prosemirror-utils").ContentNodeWithPos | undefined;
25
25
  export declare const findParentElement: (selection: Selection, validIds?: string[]) => import("prosemirror-utils").ContentNodeWithPos | undefined;
26
26
  export declare const isMetaNode: (nodeType: string) => boolean;
27
- export declare const createFootnoteLabel: (id: string) => string;
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { InlineFootnoteNode, ManuscriptNode } from '@manuscripts/transform';
17
- import { EditorState, Plugin, PluginKey } from 'prosemirror-state';
17
+ import { Plugin, PluginKey } from 'prosemirror-state';
18
18
  interface PluginState {
19
19
  nodes: [InlineFootnoteNode, number][];
20
20
  labels: Map<string, string>;
@@ -24,4 +24,3 @@ export declare const buildPluginState: (doc: ManuscriptNode) => PluginState;
24
24
  export declare const uncitedFootnoteWidget: () => () => HTMLSpanElement;
25
25
  declare const _default: () => Plugin<PluginState>;
26
26
  export default _default;
27
- export declare const getFootnotesPluginState: (state: EditorState) => PluginState;
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": "1.7.10-LEAN-3338-1",
4
+ "version": "1.7.10",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -109,4 +109,4 @@
109
109
  "resolutions": {
110
110
  "@types/react": "^17.0.2"
111
111
  }
112
- }
112
+ }
package/styles/Editor.css CHANGED
@@ -162,7 +162,7 @@
162
162
  .ProseMirror sub {
163
163
  line-height: 0;
164
164
  }
165
- .ProseMirror .footnote,
165
+
166
166
  .ProseMirror .citation,
167
167
  .ProseMirror .cross-reference {
168
168
  font-weight: bold;
@@ -991,18 +991,10 @@
991
991
  .table-footer > div:has(> p.footnote-selected) > p:last-child {
992
992
  border-bottom: 1px solid #bce7f6;
993
993
  }
994
-
995
- .ProseMirror .footnotes-element .block > div p {
996
- display: flex;
997
- }
998
- .ProseMirror .footnotes-element .block > div p > ins {
999
- flex: 1 0 auto;
1000
- }
1001
-
1002
994
  .ProseMirror .footnote-label {
1003
- flex: 0 0 auto;
1004
995
  vertical-align: super;
1005
996
  font-size: 75%;
997
+ margin-right: 8px;
1006
998
  cursor: pointer;
1007
999
  }
1008
1000