@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.
- package/dist/cjs/commands.js +7 -23
- package/dist/cjs/lib/utils.js +1 -13
- package/dist/cjs/plugins/footnotes/index.js +3 -8
- package/dist/cjs/views/inline_footnote.js +1 -1
- package/dist/es/commands.js +7 -23
- package/dist/es/lib/utils.js +0 -11
- package/dist/es/plugins/footnotes/index.js +4 -8
- package/dist/es/views/inline_footnote.js +1 -1
- package/dist/types/lib/utils.d.ts +0 -1
- package/dist/types/plugins/footnotes/index.d.ts +1 -2
- package/package.json +2 -2
- package/styles/Editor.css +2 -10
package/dist/cjs/commands.js
CHANGED
|
@@ -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
|
|
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(
|
|
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
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
}
|
package/dist/cjs/lib/utils.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
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.
|
|
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,
|
|
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 (
|
|
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.
|
|
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);
|
package/dist/es/commands.js
CHANGED
|
@@ -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
|
|
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(
|
|
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
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
}
|
package/dist/es/lib/utils.js
CHANGED
|
@@ -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
|
|
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 {
|
|
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,
|
|
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 (
|
|
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.
|
|
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 {
|
|
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
|
|
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
|
-
|
|
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
|
|