@manuscripts/body-editor 1.7.9 → 1.7.10-LEAN-3160-0
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 -15
- package/dist/cjs/lib/context-menu.js +55 -1
- package/dist/cjs/views/editable_block.js +1 -1
- package/dist/es/commands.js +48 -14
- package/dist/es/lib/context-menu.js +53 -2
- package/dist/es/views/editable_block.js +1 -1
- package/dist/types/commands.d.ts +2 -0
- package/dist/types/lib/context-menu.d.ts +3 -1
- package/dist/types/views/editable_block.d.ts +1 -1
- package/package.json +3 -3
- package/styles/popper.css +10 -3
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) {
|
|
@@ -696,28 +722,37 @@ const insertTableFootnote = (node, position, state, dispatch) => {
|
|
|
696
722
|
});
|
|
697
723
|
const insertedAt = state.selection.to;
|
|
698
724
|
const inlineFootnotes = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.inline_footnote);
|
|
725
|
+
const labels = inlineFootnotes.map((nodeWithPos) => nodeWithPos.node.attrs.contents);
|
|
699
726
|
const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
|
|
700
727
|
rids: [footnote.attrs.id],
|
|
701
|
-
contents:
|
|
728
|
+
contents: labels.length ? Math.max(...labels) + 1 : 1,
|
|
702
729
|
});
|
|
703
730
|
const tr = state.tr;
|
|
704
731
|
tr.insert(insertedAt, inlineFootnoteNode);
|
|
705
|
-
const footnoteElement = state.schema.nodes.footnotes_element.create({}, footnote);
|
|
706
|
-
const tableElementFooter = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.table_element_footer);
|
|
707
732
|
let insertionPos;
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
733
|
+
const footnotesElement = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.footnotes_element);
|
|
734
|
+
if (footnotesElement.length) {
|
|
735
|
+
const pos = footnotesElement[0].pos;
|
|
736
|
+
insertionPos = position + pos + footnotesElement[0].node.nodeSize + 1;
|
|
737
|
+
tr.insert(insertionPos, footnote);
|
|
712
738
|
}
|
|
713
739
|
else {
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
const
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
740
|
+
const footnoteElement = state.schema.nodes.footnotes_element.create({}, footnote);
|
|
741
|
+
const tableElementFooter = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.table_element_footer);
|
|
742
|
+
if (tableElementFooter.length) {
|
|
743
|
+
const pos = tableElementFooter[0].pos;
|
|
744
|
+
insertionPos = position + pos + tableElementFooter[0].node.nodeSize + 1;
|
|
745
|
+
tr.insert(insertionPos, footnoteElement);
|
|
746
|
+
}
|
|
747
|
+
else {
|
|
748
|
+
const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
|
|
749
|
+
if (tableSize) {
|
|
750
|
+
insertionPos = position + tableSize + 2;
|
|
751
|
+
const tableElementFooter = transform_1.schema.nodes.table_element_footer.create({
|
|
752
|
+
id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.TableElementFooter),
|
|
753
|
+
}, [footnoteElement]);
|
|
754
|
+
tr.insert(insertionPos, tableElementFooter);
|
|
755
|
+
}
|
|
721
756
|
}
|
|
722
757
|
}
|
|
723
758
|
if (dispatch && insertionPos) {
|
|
@@ -14,11 +14,16 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
17
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
21
|
exports.ContextMenu = exports.sectionLevel = void 0;
|
|
22
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
19
23
|
const transform_1 = require("@manuscripts/transform");
|
|
20
24
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
21
25
|
const commands_1 = require("../commands");
|
|
26
|
+
const ReactSubView_1 = __importDefault(require("../views/ReactSubView"));
|
|
22
27
|
const popper_1 = require("./popper");
|
|
23
28
|
const popper = new popper_1.PopperManager();
|
|
24
29
|
const listTypes = [transform_1.schema.nodes.ordered_list, transform_1.schema.nodes.bullet_list];
|
|
@@ -36,7 +41,7 @@ const hasAny = (set, ...items) => {
|
|
|
36
41
|
return items.some((i) => set.has(i));
|
|
37
42
|
};
|
|
38
43
|
class ContextMenu {
|
|
39
|
-
constructor(node, view, getPos, actions = {}) {
|
|
44
|
+
constructor(node, view, getPos, actions = {}, props) {
|
|
40
45
|
this.showAddMenu = (target, after) => {
|
|
41
46
|
const menu = document.createElement('div');
|
|
42
47
|
menu.className = 'menu';
|
|
@@ -135,6 +140,7 @@ class ContextMenu {
|
|
|
135
140
|
this.addPopperEventListeners();
|
|
136
141
|
};
|
|
137
142
|
this.showEditMenu = (target) => {
|
|
143
|
+
var _a;
|
|
138
144
|
const menu = document.createElement('div');
|
|
139
145
|
menu.className = 'menu';
|
|
140
146
|
const $pos = this.resolvePos();
|
|
@@ -167,14 +173,61 @@ class ContextMenu {
|
|
|
167
173
|
}
|
|
168
174
|
if (type === transform_1.schema.nodes.table_element) {
|
|
169
175
|
const isInTable = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.table)(this.view.state.selection);
|
|
176
|
+
const tableElementFooter = (0, prosemirror_utils_1.findChildrenByType)(this.node, transform_1.schema.nodes.table_element_footer);
|
|
177
|
+
const hasGeneralNote = tableElementFooter.length &&
|
|
178
|
+
((_a = tableElementFooter[0].node.firstChild) === null || _a === void 0 ? void 0 : _a.type) === transform_1.schema.nodes.paragraph;
|
|
179
|
+
if (!hasGeneralNote) {
|
|
180
|
+
menu.appendChild(this.createMenuSection((section) => {
|
|
181
|
+
section.appendChild(this.createMenuItem('Add General Note', () => {
|
|
182
|
+
(0, commands_1.insertGeneralFootnote)(this.node, this.getPos(), this.view, tableElementFooter);
|
|
183
|
+
}));
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
170
186
|
if (isInTable) {
|
|
171
187
|
menu.appendChild(this.createMenuSection((section) => {
|
|
172
188
|
section.appendChild(this.createMenuItem('Add Reference Note', () => {
|
|
189
|
+
var _a;
|
|
173
190
|
const footnotesElement = (0, prosemirror_utils_1.findChildrenByType)(this.node, transform_1.schema.nodes.footnotes_element);
|
|
174
191
|
if (!footnotesElement.length) {
|
|
175
192
|
const { state, dispatch } = this.view;
|
|
176
193
|
(0, commands_1.insertTableFootnote)(this.node, this.getPos(), state, dispatch);
|
|
177
194
|
}
|
|
195
|
+
else {
|
|
196
|
+
const footnotes = (0, prosemirror_utils_1.findChildrenByType)(footnotesElement[0].node, transform_1.schema.nodes.footnote).map((nodeWithPos) => {
|
|
197
|
+
return nodeWithPos.node;
|
|
198
|
+
});
|
|
199
|
+
const targetDom = this.view.domAtPos(this.view.state.selection.from);
|
|
200
|
+
if (targetDom.node instanceof Element && this.props) {
|
|
201
|
+
const popperContainer = (0, ReactSubView_1.default)(Object.assign(Object.assign({}, this.props), { dispatch: this.view.dispatch }), style_guide_1.TableFootnotesSelector, {
|
|
202
|
+
notes: footnotes,
|
|
203
|
+
onAdd: () => {
|
|
204
|
+
var _a;
|
|
205
|
+
const { state, dispatch } = this.view;
|
|
206
|
+
(0, commands_1.insertTableFootnote)(this.node, this.getPos(), state, dispatch);
|
|
207
|
+
(_a = this.props) === null || _a === void 0 ? void 0 : _a.popper.destroy();
|
|
208
|
+
},
|
|
209
|
+
onInsert: (notes) => {
|
|
210
|
+
var _a;
|
|
211
|
+
const insertedAt = this.view.state.selection.to;
|
|
212
|
+
const node = this.view.state.schema.nodes.inline_footnote.create({
|
|
213
|
+
rids: notes.map((note) => note.attrs.id),
|
|
214
|
+
contents: notes
|
|
215
|
+
.map((note) => footnotes.indexOf(note) + 1)
|
|
216
|
+
.join(),
|
|
217
|
+
});
|
|
218
|
+
const tr = this.view.state.tr;
|
|
219
|
+
tr.insert(insertedAt, node);
|
|
220
|
+
this.view.dispatch(tr);
|
|
221
|
+
(_a = this.props) === null || _a === void 0 ? void 0 : _a.popper.destroy();
|
|
222
|
+
},
|
|
223
|
+
onCancel: () => {
|
|
224
|
+
var _a;
|
|
225
|
+
(_a = this.props) === null || _a === void 0 ? void 0 : _a.popper.destroy();
|
|
226
|
+
},
|
|
227
|
+
}, this.node, this.getPos, this.view, 'table-footnote-editor');
|
|
228
|
+
(_a = this.props) === null || _a === void 0 ? void 0 : _a.popper.show(targetDom.node, popperContainer, 'bottom-end');
|
|
229
|
+
}
|
|
230
|
+
}
|
|
178
231
|
}));
|
|
179
232
|
}));
|
|
180
233
|
}
|
|
@@ -295,6 +348,7 @@ class ContextMenu {
|
|
|
295
348
|
this.view = view;
|
|
296
349
|
this.getPos = getPos;
|
|
297
350
|
this.actions = actions;
|
|
351
|
+
this.props = props;
|
|
298
352
|
}
|
|
299
353
|
}
|
|
300
354
|
exports.ContextMenu = ContextMenu;
|
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) {
|
|
@@ -660,28 +685,37 @@ export const insertTableFootnote = (node, position, state, dispatch) => {
|
|
|
660
685
|
});
|
|
661
686
|
const insertedAt = state.selection.to;
|
|
662
687
|
const inlineFootnotes = findChildrenByType(node, schema.nodes.inline_footnote);
|
|
688
|
+
const labels = inlineFootnotes.map((nodeWithPos) => nodeWithPos.node.attrs.contents);
|
|
663
689
|
const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
|
|
664
690
|
rids: [footnote.attrs.id],
|
|
665
|
-
contents:
|
|
691
|
+
contents: labels.length ? Math.max(...labels) + 1 : 1,
|
|
666
692
|
});
|
|
667
693
|
const tr = state.tr;
|
|
668
694
|
tr.insert(insertedAt, inlineFootnoteNode);
|
|
669
|
-
const footnoteElement = state.schema.nodes.footnotes_element.create({}, footnote);
|
|
670
|
-
const tableElementFooter = findChildrenByType(node, schema.nodes.table_element_footer);
|
|
671
695
|
let insertionPos;
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
696
|
+
const footnotesElement = findChildrenByType(node, schema.nodes.footnotes_element);
|
|
697
|
+
if (footnotesElement.length) {
|
|
698
|
+
const pos = footnotesElement[0].pos;
|
|
699
|
+
insertionPos = position + pos + footnotesElement[0].node.nodeSize + 1;
|
|
700
|
+
tr.insert(insertionPos, footnote);
|
|
676
701
|
}
|
|
677
702
|
else {
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
703
|
+
const footnoteElement = state.schema.nodes.footnotes_element.create({}, footnote);
|
|
704
|
+
const tableElementFooter = findChildrenByType(node, schema.nodes.table_element_footer);
|
|
705
|
+
if (tableElementFooter.length) {
|
|
706
|
+
const pos = tableElementFooter[0].pos;
|
|
707
|
+
insertionPos = position + pos + tableElementFooter[0].node.nodeSize + 1;
|
|
708
|
+
tr.insert(insertionPos, footnoteElement);
|
|
709
|
+
}
|
|
710
|
+
else {
|
|
711
|
+
const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
|
|
712
|
+
if (tableSize) {
|
|
713
|
+
insertionPos = position + tableSize + 2;
|
|
714
|
+
const tableElementFooter = schema.nodes.table_element_footer.create({
|
|
715
|
+
id: generateID(ObjectTypes.TableElementFooter),
|
|
716
|
+
}, [footnoteElement]);
|
|
717
|
+
tr.insert(insertionPos, tableElementFooter);
|
|
718
|
+
}
|
|
685
719
|
}
|
|
686
720
|
}
|
|
687
721
|
if (dispatch && insertionPos) {
|
|
@@ -13,9 +13,11 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { TableFootnotesSelector } from '@manuscripts/style-guide';
|
|
16
17
|
import { isInBibliographySection, nodeNames, schema, } from '@manuscripts/transform';
|
|
17
18
|
import { findChildrenByType, hasParentNodeOfType } from 'prosemirror-utils';
|
|
18
|
-
import { addComment, createBlock, insertTableFootnote } from '../commands';
|
|
19
|
+
import { addComment, createBlock, insertGeneralFootnote, insertTableFootnote, } from '../commands';
|
|
20
|
+
import ReactSubView from '../views/ReactSubView';
|
|
19
21
|
import { PopperManager } from './popper';
|
|
20
22
|
const popper = new PopperManager();
|
|
21
23
|
const listTypes = [schema.nodes.ordered_list, schema.nodes.bullet_list];
|
|
@@ -32,7 +34,7 @@ const hasAny = (set, ...items) => {
|
|
|
32
34
|
return items.some((i) => set.has(i));
|
|
33
35
|
};
|
|
34
36
|
export class ContextMenu {
|
|
35
|
-
constructor(node, view, getPos, actions = {}) {
|
|
37
|
+
constructor(node, view, getPos, actions = {}, props) {
|
|
36
38
|
this.showAddMenu = (target, after) => {
|
|
37
39
|
const menu = document.createElement('div');
|
|
38
40
|
menu.className = 'menu';
|
|
@@ -131,6 +133,7 @@ export class ContextMenu {
|
|
|
131
133
|
this.addPopperEventListeners();
|
|
132
134
|
};
|
|
133
135
|
this.showEditMenu = (target) => {
|
|
136
|
+
var _a;
|
|
134
137
|
const menu = document.createElement('div');
|
|
135
138
|
menu.className = 'menu';
|
|
136
139
|
const $pos = this.resolvePos();
|
|
@@ -163,14 +166,61 @@ export class ContextMenu {
|
|
|
163
166
|
}
|
|
164
167
|
if (type === schema.nodes.table_element) {
|
|
165
168
|
const isInTable = hasParentNodeOfType(schema.nodes.table)(this.view.state.selection);
|
|
169
|
+
const tableElementFooter = findChildrenByType(this.node, schema.nodes.table_element_footer);
|
|
170
|
+
const hasGeneralNote = tableElementFooter.length &&
|
|
171
|
+
((_a = tableElementFooter[0].node.firstChild) === null || _a === void 0 ? void 0 : _a.type) === schema.nodes.paragraph;
|
|
172
|
+
if (!hasGeneralNote) {
|
|
173
|
+
menu.appendChild(this.createMenuSection((section) => {
|
|
174
|
+
section.appendChild(this.createMenuItem('Add General Note', () => {
|
|
175
|
+
insertGeneralFootnote(this.node, this.getPos(), this.view, tableElementFooter);
|
|
176
|
+
}));
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
166
179
|
if (isInTable) {
|
|
167
180
|
menu.appendChild(this.createMenuSection((section) => {
|
|
168
181
|
section.appendChild(this.createMenuItem('Add Reference Note', () => {
|
|
182
|
+
var _a;
|
|
169
183
|
const footnotesElement = findChildrenByType(this.node, schema.nodes.footnotes_element);
|
|
170
184
|
if (!footnotesElement.length) {
|
|
171
185
|
const { state, dispatch } = this.view;
|
|
172
186
|
insertTableFootnote(this.node, this.getPos(), state, dispatch);
|
|
173
187
|
}
|
|
188
|
+
else {
|
|
189
|
+
const footnotes = findChildrenByType(footnotesElement[0].node, schema.nodes.footnote).map((nodeWithPos) => {
|
|
190
|
+
return nodeWithPos.node;
|
|
191
|
+
});
|
|
192
|
+
const targetDom = this.view.domAtPos(this.view.state.selection.from);
|
|
193
|
+
if (targetDom.node instanceof Element && this.props) {
|
|
194
|
+
const popperContainer = ReactSubView(Object.assign(Object.assign({}, this.props), { dispatch: this.view.dispatch }), TableFootnotesSelector, {
|
|
195
|
+
notes: footnotes,
|
|
196
|
+
onAdd: () => {
|
|
197
|
+
var _a;
|
|
198
|
+
const { state, dispatch } = this.view;
|
|
199
|
+
insertTableFootnote(this.node, this.getPos(), state, dispatch);
|
|
200
|
+
(_a = this.props) === null || _a === void 0 ? void 0 : _a.popper.destroy();
|
|
201
|
+
},
|
|
202
|
+
onInsert: (notes) => {
|
|
203
|
+
var _a;
|
|
204
|
+
const insertedAt = this.view.state.selection.to;
|
|
205
|
+
const node = this.view.state.schema.nodes.inline_footnote.create({
|
|
206
|
+
rids: notes.map((note) => note.attrs.id),
|
|
207
|
+
contents: notes
|
|
208
|
+
.map((note) => footnotes.indexOf(note) + 1)
|
|
209
|
+
.join(),
|
|
210
|
+
});
|
|
211
|
+
const tr = this.view.state.tr;
|
|
212
|
+
tr.insert(insertedAt, node);
|
|
213
|
+
this.view.dispatch(tr);
|
|
214
|
+
(_a = this.props) === null || _a === void 0 ? void 0 : _a.popper.destroy();
|
|
215
|
+
},
|
|
216
|
+
onCancel: () => {
|
|
217
|
+
var _a;
|
|
218
|
+
(_a = this.props) === null || _a === void 0 ? void 0 : _a.popper.destroy();
|
|
219
|
+
},
|
|
220
|
+
}, this.node, this.getPos, this.view, 'table-footnote-editor');
|
|
221
|
+
(_a = this.props) === null || _a === void 0 ? void 0 : _a.popper.show(targetDom.node, popperContainer, 'bottom-end');
|
|
222
|
+
}
|
|
223
|
+
}
|
|
174
224
|
}));
|
|
175
225
|
}));
|
|
176
226
|
}
|
|
@@ -291,5 +341,6 @@ export class ContextMenu {
|
|
|
291
341
|
this.view = view;
|
|
292
342
|
this.getPos = getPos;
|
|
293
343
|
this.actions = actions;
|
|
344
|
+
this.props = props;
|
|
294
345
|
}
|
|
295
346
|
}
|
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;
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { CommentAnnotation } from '@manuscripts/json-schema';
|
|
17
17
|
import { ManuscriptEditorView, ManuscriptNode } from '@manuscripts/transform';
|
|
18
|
+
import { EditableBlockProps } from '../views/editable_block';
|
|
18
19
|
export declare const sectionLevel: (depth: number) => string;
|
|
19
20
|
interface Actions {
|
|
20
21
|
setComment?: (comment: CommentAnnotation) => void;
|
|
@@ -24,7 +25,8 @@ export declare class ContextMenu {
|
|
|
24
25
|
private readonly view;
|
|
25
26
|
private readonly getPos;
|
|
26
27
|
private readonly actions;
|
|
27
|
-
|
|
28
|
+
private readonly props?;
|
|
29
|
+
constructor(node: ManuscriptNode, view: ManuscriptEditorView, getPos: () => number, actions?: Actions, props?: EditableBlockProps);
|
|
28
30
|
showAddMenu: (target: Element, after: boolean) => void;
|
|
29
31
|
showEditMenu: (target: Element) => void;
|
|
30
32
|
private createMenuItem;
|
|
@@ -26,7 +26,7 @@ export interface EditableBlockProps extends BaseNodeProps {
|
|
|
26
26
|
retrySync: (componentIDs: string[]) => Promise<void>;
|
|
27
27
|
setComment: (comment: CommentAnnotation) => void;
|
|
28
28
|
dispatch?: Dispatch;
|
|
29
|
-
theme
|
|
29
|
+
theme: DefaultTheme;
|
|
30
30
|
}
|
|
31
31
|
export declare const EditableBlock: <T extends Constructor<BlockView<EditableBlockProps>>>(Base: T) => {
|
|
32
32
|
new (...args: any[]): {
|
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-3160-0",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@manuscripts/assets": "^0.6.4",
|
|
32
32
|
"@manuscripts/json-schema": "^2.2.4",
|
|
33
33
|
"@manuscripts/library": "^1.3.3",
|
|
34
|
-
"@manuscripts/style-guide": "
|
|
34
|
+
"@manuscripts/style-guide": "1.7.6-LEAN-3160-0",
|
|
35
35
|
"@manuscripts/track-changes-plugin": "^1.7.5",
|
|
36
36
|
"@manuscripts/transform": "^2.1.2",
|
|
37
37
|
"astrocite-eutils": "^0.16.4",
|
|
@@ -109,4 +109,4 @@
|
|
|
109
109
|
"resolutions": {
|
|
110
110
|
"@types/react": "^17.0.2"
|
|
111
111
|
}
|
|
112
|
-
}
|
|
112
|
+
}
|
package/styles/popper.css
CHANGED
|
@@ -135,7 +135,8 @@
|
|
|
135
135
|
.popper .citation-editor,
|
|
136
136
|
.popper .cross-reference-editor,
|
|
137
137
|
.popper .citation-references,
|
|
138
|
-
.popper .track-changes-review-panel
|
|
138
|
+
.popper .track-changes-review-panel,
|
|
139
|
+
.popper .table-footnote-editor {
|
|
139
140
|
background: #fff;
|
|
140
141
|
border: 1px solid #e2e2e2;
|
|
141
142
|
border-radius: 8px;
|
|
@@ -189,7 +190,8 @@
|
|
|
189
190
|
height: auto;
|
|
190
191
|
}
|
|
191
192
|
|
|
192
|
-
.popper .citation-editor
|
|
193
|
+
.popper .citation-editor,
|
|
194
|
+
.popper .table-footnote-editor {
|
|
193
195
|
width: 600px;
|
|
194
196
|
}
|
|
195
197
|
|
|
@@ -204,7 +206,8 @@
|
|
|
204
206
|
.popper .citation-editor,
|
|
205
207
|
.popper .cross-reference-editor,
|
|
206
208
|
.popper .equation-editor,
|
|
207
|
-
.popper .link-editor
|
|
209
|
+
.popper .link-editor,
|
|
210
|
+
.popper .table-footnote-editor {
|
|
208
211
|
min-width: 90%;
|
|
209
212
|
max-width: 90%;
|
|
210
213
|
}
|
|
@@ -219,6 +222,10 @@
|
|
|
219
222
|
width: 600px;
|
|
220
223
|
}
|
|
221
224
|
|
|
225
|
+
.popper .table-footnote-editor {
|
|
226
|
+
left: 50%;
|
|
227
|
+
transform: translate(-50%, -100%);
|
|
228
|
+
}
|
|
222
229
|
|
|
223
230
|
.popper .track-attrs-popper {
|
|
224
231
|
box-shadow: 0 4px 9px 0 rgba(0, 0, 0, 0.30);
|