@manuscripts/body-editor 3.6.16 → 3.6.18

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.
@@ -6,7 +6,7 @@ const prosemirror_model_1 = require("prosemirror-model");
6
6
  const lists_1 = require("./lib/lists");
7
7
  const nodes = [
8
8
  {
9
- tag: 'p',
9
+ tag: 'p, div',
10
10
  node: 'paragraph',
11
11
  },
12
12
  {
@@ -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.6.16';
4
+ exports.VERSION = '3.6.18';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.InlineFootnoteView = void 0;
22
22
  const style_guide_1 = require("@manuscripts/style-guide");
23
23
  const prosemirror_state_1 = require("prosemirror-state");
24
+ const commands_1 = require("../commands");
24
25
  const FootnotesSelector_1 = require("../components/views/FootnotesSelector");
25
26
  const footnotes_1 = require("../lib/footnotes");
26
27
  const track_changes_utils_1 = require("../lib/track-changes-utils");
@@ -91,14 +92,12 @@ class InlineFootnoteView extends base_node_view_1.BaseNodeView {
91
92
  const pos = this.getPos();
92
93
  const container = (0, footnotes_1.findFootnotesContainerNode)(state.doc, pos);
93
94
  const fn = (0, footnotes_1.getFootnotesElementState)(state, container.node.attrs.id);
94
- if (!fn) {
95
- return [];
96
- }
97
- const footnotes = fn.footnotes.map((n) => n[0]);
95
+ const footnotes = fn ? fn.footnotes.map((n) => n[0]) : [];
96
+ const labels = fn ? fn.labels : new Map();
98
97
  const props = {
99
98
  footnotes,
100
99
  inlineFootnote: this.node,
101
- labels: fn.labels,
100
+ labels,
102
101
  onCancel: this.handleCancel,
103
102
  onAdd: this.handleAdd,
104
103
  onInsert: this.handleInsert,
@@ -141,14 +140,21 @@ class InlineFootnoteView extends base_node_view_1.BaseNodeView {
141
140
  const pos = this.getPos();
142
141
  const container = (0, footnotes_1.findFootnotesContainerNode)(state.doc, pos);
143
142
  const fn = (0, footnotes_1.getFootnotesElementState)(state, container.node.attrs.id);
144
- if (!fn) {
145
- return;
146
- }
147
143
  const tr = this.view.state.tr;
148
144
  const footnote = (0, footnotes_1.createFootnote)();
149
145
  const rids = this.node.attrs.rids;
150
146
  tr.setNodeAttribute(pos, 'rids', [...rids, footnote.attrs.id]);
151
- const fnPos = fn.element[1] + fn.element[0].nodeSize - 1;
147
+ let fnPos;
148
+ if (fn) {
149
+ fnPos = fn.element[1] + fn.element[0].nodeSize - 1;
150
+ }
151
+ else {
152
+ const [elementNode, elementPos] = (0, commands_1.insertFootnotesElement)(tr, [
153
+ container.node,
154
+ container.pos,
155
+ ]);
156
+ fnPos = elementPos + elementNode.nodeSize - 1;
157
+ }
152
158
  tr.insert(fnPos, footnote);
153
159
  const selection = prosemirror_state_1.TextSelection.create(tr.doc, fnPos + 2);
154
160
  tr.setSelection(selection).scrollIntoView();
@@ -3,7 +3,7 @@ import { DOMParser } from 'prosemirror-model';
3
3
  import { parseCssListStyleType } from './lib/lists';
4
4
  const nodes = [
5
5
  {
6
- tag: 'p',
6
+ tag: 'p, div',
7
7
  node: 'paragraph',
8
8
  },
9
9
  {
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.6.16';
1
+ export const VERSION = '3.6.18';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -15,6 +15,7 @@
15
15
  */
16
16
  import { ContextMenu } from '@manuscripts/style-guide';
17
17
  import { NodeSelection, TextSelection } from 'prosemirror-state';
18
+ import { insertFootnotesElement } from '../commands';
18
19
  import { FootnotesSelector, } from '../components/views/FootnotesSelector';
19
20
  import { createFootnote, findFootnotesContainerNode, getFootnotesElementState, } from '../lib/footnotes';
20
21
  import { isDeleted, isPendingInsert } from '../lib/track-changes-utils';
@@ -85,14 +86,12 @@ export class InlineFootnoteView extends BaseNodeView {
85
86
  const pos = this.getPos();
86
87
  const container = findFootnotesContainerNode(state.doc, pos);
87
88
  const fn = getFootnotesElementState(state, container.node.attrs.id);
88
- if (!fn) {
89
- return [];
90
- }
91
- const footnotes = fn.footnotes.map((n) => n[0]);
89
+ const footnotes = fn ? fn.footnotes.map((n) => n[0]) : [];
90
+ const labels = fn ? fn.labels : new Map();
92
91
  const props = {
93
92
  footnotes,
94
93
  inlineFootnote: this.node,
95
- labels: fn.labels,
94
+ labels,
96
95
  onCancel: this.handleCancel,
97
96
  onAdd: this.handleAdd,
98
97
  onInsert: this.handleInsert,
@@ -135,14 +134,21 @@ export class InlineFootnoteView extends BaseNodeView {
135
134
  const pos = this.getPos();
136
135
  const container = findFootnotesContainerNode(state.doc, pos);
137
136
  const fn = getFootnotesElementState(state, container.node.attrs.id);
138
- if (!fn) {
139
- return;
140
- }
141
137
  const tr = this.view.state.tr;
142
138
  const footnote = createFootnote();
143
139
  const rids = this.node.attrs.rids;
144
140
  tr.setNodeAttribute(pos, 'rids', [...rids, footnote.attrs.id]);
145
- const fnPos = fn.element[1] + fn.element[0].nodeSize - 1;
141
+ let fnPos;
142
+ if (fn) {
143
+ fnPos = fn.element[1] + fn.element[0].nodeSize - 1;
144
+ }
145
+ else {
146
+ const [elementNode, elementPos] = insertFootnotesElement(tr, [
147
+ container.node,
148
+ container.pos,
149
+ ]);
150
+ fnPos = elementPos + elementNode.nodeSize - 1;
151
+ }
146
152
  tr.insert(fnPos, footnote);
147
153
  const selection = TextSelection.create(tr.doc, fnPos + 2);
148
154
  tr.setSelection(selection).scrollIntoView();
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.6.16";
1
+ export declare const VERSION = "3.6.18";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
@@ -21,7 +21,7 @@ export declare class InlineFootnoteView extends BaseNodeView<Trackable<InlineFoo
21
21
  showContextMenu: () => void;
22
22
  handleClick: () => void;
23
23
  scrollToReferencedFootnote: () => void;
24
- showFootnotesSelector: () => never[] | undefined;
24
+ showFootnotesSelector: () => void;
25
25
  updateContents(): void;
26
26
  initialise: () => void;
27
27
  selectNode: () => void;
@@ -33,5 +33,5 @@ export declare class InlineFootnoteView extends BaseNodeView<Trackable<InlineFoo
33
33
  handleAdd: () => void;
34
34
  handleInsert: (footnotes: FootnoteNode[]) => void;
35
35
  }
36
- declare const _default: (props: import("../configs/ManuscriptsEditor").EditorProps, dispatch?: import("..").Dispatch) => import("../types").NodeViewCreator<InlineFootnoteView>;
36
+ declare const _default: (props: import("../configs/ManuscriptsEditor").EditorProps, dispatch?: import("../commands").Dispatch) => import("../types").NodeViewCreator<InlineFootnoteView>;
37
37
  export default _default;
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.6.16",
4
+ "version": "3.6.18",
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
  "@manuscripts/json-schema": "2.2.12",
41
41
  "@manuscripts/style-guide": "3.3.5",
42
42
  "@manuscripts/track-changes-plugin": "2.1.0",
43
- "@manuscripts/transform": "4.3.6",
43
+ "@manuscripts/transform": "4.3.7",
44
44
  "@popperjs/core": "2.11.8",
45
45
  "citeproc": "2.4.63",
46
46
  "codemirror": "5.65.19",