@manuscripts/body-editor 1.7.9 → 1.7.10-LEAN-3338-1
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 +50 -8
- package/dist/cjs/lib/context-menu.js +11 -0
- package/dist/cjs/lib/utils.js +13 -1
- package/dist/cjs/plugins/footnotes/index.js +8 -3
- package/dist/cjs/views/inline_footnote.js +1 -1
- package/dist/es/commands.js +48 -7
- package/dist/es/lib/context-menu.js +12 -1
- package/dist/es/lib/utils.js +11 -0
- package/dist/es/plugins/footnotes/index.js +8 -4
- package/dist/es/views/inline_footnote.js +1 -1
- package/dist/types/commands.d.ts +2 -0
- package/dist/types/lib/utils.d.ts +1 -0
- package/dist/types/plugins/footnotes/index.d.ts +2 -1
- package/package.json +2 -2
- package/styles/Editor.css +10 -2
package/dist/cjs/commands.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.insertTableFootnote = exports.updateCommentAnnotationState = exports.addComment = exports.deleteHighlightMarkers = exports.insertHighlight = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.ifInTableBody = exports.insertTOCSection = exports.insertBibliographySection = exports.insertList = exports.insertSection = exports.insertGraphicalAbstract = exports.insertInlineFootnote = exports.insertInlineEquation = exports.insertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertFileAsFigure = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = void 0;
|
|
18
|
+
exports.insertTableFootnote = exports.updateCommentAnnotationState = exports.addComment = exports.deleteHighlightMarkers = exports.insertHighlight = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.ifInTableBody = exports.insertTOCSection = exports.insertBibliographySection = exports.insertList = exports.insertSection = exports.insertGraphicalAbstract = exports.insertInlineFootnote = exports.insertInlineEquation = exports.insertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertFileAsFigure = exports.insertGeneralFootnote = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = void 0;
|
|
19
19
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
|
|
21
21
|
const transform_1 = require("@manuscripts/transform");
|
|
@@ -122,6 +122,32 @@ const createBlock = (nodeType, position, state, dispatch) => {
|
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
exports.createBlock = createBlock;
|
|
125
|
+
const insertGeneralFootnote = (tableNode, position, view, tableElementFooter) => {
|
|
126
|
+
var _a;
|
|
127
|
+
const { state, dispatch } = view;
|
|
128
|
+
const generalNote = state.schema.nodes.paragraph.create({
|
|
129
|
+
placeholder: 'Add general note here',
|
|
130
|
+
});
|
|
131
|
+
const tr = state.tr;
|
|
132
|
+
const pos = (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length)
|
|
133
|
+
? position + tableElementFooter[0].pos + 2
|
|
134
|
+
: position + (((_a = tableNode.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize) || 0);
|
|
135
|
+
if (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length) {
|
|
136
|
+
tr.insert(pos, generalNote);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
const tableElementFooter = transform_1.schema.nodes.table_element_footer.create({
|
|
140
|
+
id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.TableElementFooter),
|
|
141
|
+
}, [generalNote]);
|
|
142
|
+
tr.insert(pos, tableElementFooter);
|
|
143
|
+
}
|
|
144
|
+
if (dispatch && pos) {
|
|
145
|
+
const selection = (0, exports.createSelection)(state.schema.nodes.paragraph, pos, tr.doc);
|
|
146
|
+
view === null || view === void 0 ? void 0 : view.focus();
|
|
147
|
+
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
exports.insertGeneralFootnote = insertGeneralFootnote;
|
|
125
151
|
const insertFileAsFigure = (file, state, dispatch) => {
|
|
126
152
|
const position = findBlockInsertPosition(state);
|
|
127
153
|
if (position === null || !dispatch) {
|
|
@@ -281,17 +307,18 @@ const insertInlineFootnote = (kind) => (state, dispatch) => {
|
|
|
281
307
|
id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.Footnote),
|
|
282
308
|
kind,
|
|
283
309
|
});
|
|
284
|
-
const insertedAt = state.selection.to;
|
|
285
310
|
const node = state.schema.nodes.inline_footnote.create({
|
|
286
311
|
rids: [footnote.attrs.id],
|
|
287
312
|
});
|
|
288
|
-
const
|
|
313
|
+
const insertedAt = state.selection.to;
|
|
314
|
+
const { tr } = state;
|
|
289
315
|
tr.insert(insertedAt, node);
|
|
290
316
|
const footnotesSection = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.footnotes_section)[0];
|
|
291
317
|
let selectionPos;
|
|
292
318
|
if (!footnotesSection) {
|
|
319
|
+
const sectionTitle = 'Footnotes';
|
|
293
320
|
const section = state.schema.nodes.footnotes_section.create({}, [
|
|
294
|
-
state.schema.nodes.section_title.create({}, state.schema.text(
|
|
321
|
+
state.schema.nodes.section_title.create({}, state.schema.text(sectionTitle)),
|
|
295
322
|
state.schema.nodes.footnotes_element.create({}, footnote),
|
|
296
323
|
]);
|
|
297
324
|
const backmatter = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.backmatter)[0];
|
|
@@ -300,10 +327,25 @@ const insertInlineFootnote = (kind) => (state, dispatch) => {
|
|
|
300
327
|
}
|
|
301
328
|
else {
|
|
302
329
|
const footnoteElement = (0, prosemirror_utils_1.findChildrenByType)(footnotesSection.node, transform_1.schema.nodes.footnotes_element);
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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;
|
|
307
349
|
tr.insert(pos, footnote);
|
|
308
350
|
selectionPos = pos + 2;
|
|
309
351
|
}
|
|
@@ -135,6 +135,7 @@ class ContextMenu {
|
|
|
135
135
|
this.addPopperEventListeners();
|
|
136
136
|
};
|
|
137
137
|
this.showEditMenu = (target) => {
|
|
138
|
+
var _a;
|
|
138
139
|
const menu = document.createElement('div');
|
|
139
140
|
menu.className = 'menu';
|
|
140
141
|
const $pos = this.resolvePos();
|
|
@@ -167,6 +168,16 @@ class ContextMenu {
|
|
|
167
168
|
}
|
|
168
169
|
if (type === transform_1.schema.nodes.table_element) {
|
|
169
170
|
const isInTable = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.table)(this.view.state.selection);
|
|
171
|
+
const tableElementFooter = (0, prosemirror_utils_1.findChildrenByType)(this.node, transform_1.schema.nodes.table_element_footer);
|
|
172
|
+
const hasGeneralNote = tableElementFooter.length &&
|
|
173
|
+
((_a = tableElementFooter[0].node.firstChild) === null || _a === void 0 ? void 0 : _a.type) === transform_1.schema.nodes.paragraph;
|
|
174
|
+
if (!hasGeneralNote) {
|
|
175
|
+
menu.appendChild(this.createMenuSection((section) => {
|
|
176
|
+
section.appendChild(this.createMenuItem('Add General Note', () => {
|
|
177
|
+
(0, commands_1.insertGeneralFootnote)(this.node, this.getPos(), this.view, tableElementFooter);
|
|
178
|
+
}));
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
170
181
|
if (isInTable) {
|
|
171
182
|
menu.appendChild(this.createMenuSection((section) => {
|
|
172
183
|
section.appendChild(this.createMenuItem('Add Reference Note', () => {
|
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.isMetaNode = exports.findParentElement = exports.findParentSection = exports.findParentNodeWithIdValue = exports.findParentNodeWithId = exports.getChildOfType = exports.getMatchingDescendant = exports.getMatchingChild = exports.iterateChildren = void 0;
|
|
18
|
+
exports.createFootnoteLabel = 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,3 +62,15 @@ 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.uncitedFootnoteWidget = exports.buildPluginState = exports.footnotesKey = void 0;
|
|
18
|
+
exports.getFootnotesPluginState = 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, String(++
|
|
39
|
+
labels.set(rid, (0, utils_1.createFootnoteLabel)(String(index++)));
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
});
|
|
@@ -45,8 +45,9 @@ 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;
|
|
48
49
|
const footnote = node;
|
|
49
|
-
if (footnote.attrs.rids.includes(rid)) {
|
|
50
|
+
if ((_a = footnote.attrs.rids) === null || _a === void 0 ? void 0 : _a.includes(rid)) {
|
|
50
51
|
const selection = prosemirror_state_1.NodeSelection.create(view.state.doc, pos);
|
|
51
52
|
view.dispatch(view.state.tr.setSelection(selection).scrollIntoView());
|
|
52
53
|
}
|
|
@@ -148,3 +149,7 @@ exports.default = () => {
|
|
|
148
149
|
},
|
|
149
150
|
});
|
|
150
151
|
};
|
|
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.rids[0] }));
|
|
26
26
|
};
|
|
27
27
|
this.updateContents = () => {
|
|
28
28
|
this.setDomAttrs(this.node, this.dom);
|
package/dist/es/commands.js
CHANGED
|
@@ -113,6 +113,31 @@ export const createBlock = (nodeType, position, state, dispatch) => {
|
|
|
113
113
|
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
|
+
export const insertGeneralFootnote = (tableNode, position, view, tableElementFooter) => {
|
|
117
|
+
var _a;
|
|
118
|
+
const { state, dispatch } = view;
|
|
119
|
+
const generalNote = state.schema.nodes.paragraph.create({
|
|
120
|
+
placeholder: 'Add general note here',
|
|
121
|
+
});
|
|
122
|
+
const tr = state.tr;
|
|
123
|
+
const pos = (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length)
|
|
124
|
+
? position + tableElementFooter[0].pos + 2
|
|
125
|
+
: position + (((_a = tableNode.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize) || 0);
|
|
126
|
+
if (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length) {
|
|
127
|
+
tr.insert(pos, generalNote);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const tableElementFooter = schema.nodes.table_element_footer.create({
|
|
131
|
+
id: generateID(ObjectTypes.TableElementFooter),
|
|
132
|
+
}, [generalNote]);
|
|
133
|
+
tr.insert(pos, tableElementFooter);
|
|
134
|
+
}
|
|
135
|
+
if (dispatch && pos) {
|
|
136
|
+
const selection = createSelection(state.schema.nodes.paragraph, pos, tr.doc);
|
|
137
|
+
view === null || view === void 0 ? void 0 : view.focus();
|
|
138
|
+
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
139
|
+
}
|
|
140
|
+
};
|
|
116
141
|
export const insertFileAsFigure = (file, state, dispatch) => {
|
|
117
142
|
const position = findBlockInsertPosition(state);
|
|
118
143
|
if (position === null || !dispatch) {
|
|
@@ -263,17 +288,18 @@ export const insertInlineFootnote = (kind) => (state, dispatch) => {
|
|
|
263
288
|
id: generateID(ObjectTypes.Footnote),
|
|
264
289
|
kind,
|
|
265
290
|
});
|
|
266
|
-
const insertedAt = state.selection.to;
|
|
267
291
|
const node = state.schema.nodes.inline_footnote.create({
|
|
268
292
|
rids: [footnote.attrs.id],
|
|
269
293
|
});
|
|
270
|
-
const
|
|
294
|
+
const insertedAt = state.selection.to;
|
|
295
|
+
const { tr } = state;
|
|
271
296
|
tr.insert(insertedAt, node);
|
|
272
297
|
const footnotesSection = findChildrenByType(tr.doc, schema.nodes.footnotes_section)[0];
|
|
273
298
|
let selectionPos;
|
|
274
299
|
if (!footnotesSection) {
|
|
300
|
+
const sectionTitle = 'Footnotes';
|
|
275
301
|
const section = state.schema.nodes.footnotes_section.create({}, [
|
|
276
|
-
state.schema.nodes.section_title.create({}, state.schema.text(
|
|
302
|
+
state.schema.nodes.section_title.create({}, state.schema.text(sectionTitle)),
|
|
277
303
|
state.schema.nodes.footnotes_element.create({}, footnote),
|
|
278
304
|
]);
|
|
279
305
|
const backmatter = findChildrenByType(tr.doc, schema.nodes.backmatter)[0];
|
|
@@ -282,10 +308,25 @@ export const insertInlineFootnote = (kind) => (state, dispatch) => {
|
|
|
282
308
|
}
|
|
283
309
|
else {
|
|
284
310
|
const footnoteElement = findChildrenByType(footnotesSection.node, schema.nodes.footnotes_element);
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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;
|
|
289
330
|
tr.insert(pos, footnote);
|
|
290
331
|
selectionPos = pos + 2;
|
|
291
332
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { isInBibliographySection, nodeNames, schema, } from '@manuscripts/transform';
|
|
17
17
|
import { findChildrenByType, hasParentNodeOfType } from 'prosemirror-utils';
|
|
18
|
-
import { addComment, createBlock, insertTableFootnote } from '../commands';
|
|
18
|
+
import { addComment, createBlock, insertGeneralFootnote, insertTableFootnote, } from '../commands';
|
|
19
19
|
import { PopperManager } from './popper';
|
|
20
20
|
const popper = new PopperManager();
|
|
21
21
|
const listTypes = [schema.nodes.ordered_list, schema.nodes.bullet_list];
|
|
@@ -131,6 +131,7 @@ export class ContextMenu {
|
|
|
131
131
|
this.addPopperEventListeners();
|
|
132
132
|
};
|
|
133
133
|
this.showEditMenu = (target) => {
|
|
134
|
+
var _a;
|
|
134
135
|
const menu = document.createElement('div');
|
|
135
136
|
menu.className = 'menu';
|
|
136
137
|
const $pos = this.resolvePos();
|
|
@@ -163,6 +164,16 @@ export class ContextMenu {
|
|
|
163
164
|
}
|
|
164
165
|
if (type === schema.nodes.table_element) {
|
|
165
166
|
const isInTable = hasParentNodeOfType(schema.nodes.table)(this.view.state.selection);
|
|
167
|
+
const tableElementFooter = findChildrenByType(this.node, schema.nodes.table_element_footer);
|
|
168
|
+
const hasGeneralNote = tableElementFooter.length &&
|
|
169
|
+
((_a = tableElementFooter[0].node.firstChild) === null || _a === void 0 ? void 0 : _a.type) === schema.nodes.paragraph;
|
|
170
|
+
if (!hasGeneralNote) {
|
|
171
|
+
menu.appendChild(this.createMenuSection((section) => {
|
|
172
|
+
section.appendChild(this.createMenuItem('Add General Note', () => {
|
|
173
|
+
insertGeneralFootnote(this.node, this.getPos(), this.view, tableElementFooter);
|
|
174
|
+
}));
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
166
177
|
if (isInTable) {
|
|
167
178
|
menu.appendChild(this.createMenuSection((section) => {
|
|
168
179
|
section.appendChild(this.createMenuItem('Add Reference Note', () => {
|
package/dist/es/lib/utils.js
CHANGED
|
@@ -53,3 +53,14 @@ 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 { findParentNodeWithIdValue } from '../../lib/utils';
|
|
22
|
+
import { createFootnoteLabel, 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, String(++
|
|
36
|
+
labels.set(rid, createFootnoteLabel(String(index++)));
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
});
|
|
@@ -41,8 +41,9 @@ export const buildPluginState = (doc) => {
|
|
|
41
41
|
};
|
|
42
42
|
const scrollToInlineFootnote = (rid, view) => {
|
|
43
43
|
view.state.doc.descendants((node, pos) => {
|
|
44
|
+
var _a;
|
|
44
45
|
const footnote = node;
|
|
45
|
-
if (footnote.attrs.rids.includes(rid)) {
|
|
46
|
+
if ((_a = footnote.attrs.rids) === null || _a === void 0 ? void 0 : _a.includes(rid)) {
|
|
46
47
|
const selection = NodeSelection.create(view.state.doc, pos);
|
|
47
48
|
view.dispatch(view.state.tr.setSelection(selection).scrollIntoView());
|
|
48
49
|
}
|
|
@@ -143,3 +144,6 @@ export default () => {
|
|
|
143
144
|
},
|
|
144
145
|
});
|
|
145
146
|
};
|
|
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.rids[0] }));
|
|
23
23
|
};
|
|
24
24
|
this.updateContents = () => {
|
|
25
25
|
this.setDomAttrs(this.node, this.dom);
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { FileAttachment } from '@manuscripts/style-guide';
|
|
|
18
18
|
import { ManuscriptEditorState, ManuscriptEditorView, ManuscriptMarkType, ManuscriptNode, ManuscriptNodeType, ManuscriptTransaction } from '@manuscripts/transform';
|
|
19
19
|
import { ResolvedPos } from 'prosemirror-model';
|
|
20
20
|
import { Command, NodeSelection, Selection, TextSelection, Transaction } from 'prosemirror-state';
|
|
21
|
+
import { NodeWithPos } from 'prosemirror-utils';
|
|
21
22
|
import { EditorAction } from './types';
|
|
22
23
|
export type Dispatch = (tr: ManuscriptTransaction) => void;
|
|
23
24
|
export declare const markActive: (type: ManuscriptMarkType) => (state: ManuscriptEditorState) => boolean;
|
|
@@ -26,6 +27,7 @@ export declare const blockActive: (type: ManuscriptNodeType) => (state: Manuscri
|
|
|
26
27
|
export declare const canInsert: (type: ManuscriptNodeType) => (state: ManuscriptEditorState) => boolean;
|
|
27
28
|
export declare const createSelection: (nodeType: ManuscriptNodeType, position: number, doc: ManuscriptNode) => Selection;
|
|
28
29
|
export declare const createBlock: (nodeType: ManuscriptNodeType, position: number, state: ManuscriptEditorState, dispatch?: Dispatch) => void;
|
|
30
|
+
export declare const insertGeneralFootnote: (tableNode: ManuscriptNode, position: number, view: ManuscriptEditorView, tableElementFooter?: NodeWithPos[]) => void;
|
|
29
31
|
export declare const insertFileAsFigure: (file: FileAttachment, state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
30
32
|
export declare const insertBlock: (nodeType: ManuscriptNodeType) => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
31
33
|
export declare const deleteBlock: (typeToDelete: string) => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
@@ -24,3 +24,4 @@ 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 { Plugin, PluginKey } from 'prosemirror-state';
|
|
17
|
+
import { EditorState, Plugin, PluginKey } from 'prosemirror-state';
|
|
18
18
|
interface PluginState {
|
|
19
19
|
nodes: [InlineFootnoteNode, number][];
|
|
20
20
|
labels: Map<string, string>;
|
|
@@ -24,3 +24,4 @@ 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.
|
|
4
|
+
"version": "1.7.10-LEAN-3338-1",
|
|
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
|
+
.ProseMirror .footnote,
|
|
166
166
|
.ProseMirror .citation,
|
|
167
167
|
.ProseMirror .cross-reference {
|
|
168
168
|
font-weight: bold;
|
|
@@ -991,10 +991,18 @@
|
|
|
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
|
+
|
|
994
1002
|
.ProseMirror .footnote-label {
|
|
1003
|
+
flex: 0 0 auto;
|
|
995
1004
|
vertical-align: super;
|
|
996
1005
|
font-size: 75%;
|
|
997
|
-
margin-right: 8px;
|
|
998
1006
|
cursor: pointer;
|
|
999
1007
|
}
|
|
1000
1008
|
|