@manuscripts/body-editor 1.7.10-LEAN-3160-0 → 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 +14 -23
- package/dist/cjs/lib/context-menu.js +1 -44
- package/dist/cjs/views/editable_block.js +1 -1
- package/dist/es/commands.js +14 -23
- package/dist/es/lib/context-menu.js +1 -41
- package/dist/es/views/editable_block.js +1 -1
- package/dist/types/lib/context-menu.d.ts +1 -3
- package/dist/types/views/editable_block.d.ts +1 -1
- package/package.json +3 -3
- package/styles/popper.css +3 -10
package/dist/cjs/commands.js
CHANGED
|
@@ -722,37 +722,28 @@ const insertTableFootnote = (node, position, state, dispatch) => {
|
|
|
722
722
|
});
|
|
723
723
|
const insertedAt = state.selection.to;
|
|
724
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);
|
|
726
725
|
const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
|
|
727
726
|
rids: [footnote.attrs.id],
|
|
728
|
-
contents:
|
|
727
|
+
contents: inlineFootnotes.length + 1,
|
|
729
728
|
});
|
|
730
729
|
const tr = state.tr;
|
|
731
730
|
tr.insert(insertedAt, inlineFootnoteNode);
|
|
731
|
+
const footnoteElement = state.schema.nodes.footnotes_element.create({}, footnote);
|
|
732
|
+
const tableElementFooter = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.table_element_footer);
|
|
732
733
|
let insertionPos;
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
insertionPos
|
|
737
|
-
tr.insert(insertionPos, footnote);
|
|
734
|
+
if (tableElementFooter.length) {
|
|
735
|
+
const pos = tableElementFooter[0].pos;
|
|
736
|
+
insertionPos = position + pos + tableElementFooter[0].node.nodeSize + 1;
|
|
737
|
+
tr.insert(insertionPos, footnoteElement);
|
|
738
738
|
}
|
|
739
739
|
else {
|
|
740
|
-
const
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
const
|
|
744
|
-
|
|
745
|
-
|
|
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
|
-
}
|
|
740
|
+
const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
|
|
741
|
+
if (tableSize) {
|
|
742
|
+
insertionPos = position + tableSize + 2;
|
|
743
|
+
const tableElementFooter = transform_1.schema.nodes.table_element_footer.create({
|
|
744
|
+
id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.TableElementFooter),
|
|
745
|
+
}, [footnoteElement]);
|
|
746
|
+
tr.insert(insertionPos, tableElementFooter);
|
|
756
747
|
}
|
|
757
748
|
}
|
|
758
749
|
if (dispatch && insertionPos) {
|
|
@@ -14,16 +14,11 @@
|
|
|
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
|
-
};
|
|
20
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
18
|
exports.ContextMenu = exports.sectionLevel = void 0;
|
|
22
|
-
const style_guide_1 = require("@manuscripts/style-guide");
|
|
23
19
|
const transform_1 = require("@manuscripts/transform");
|
|
24
20
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
25
21
|
const commands_1 = require("../commands");
|
|
26
|
-
const ReactSubView_1 = __importDefault(require("../views/ReactSubView"));
|
|
27
22
|
const popper_1 = require("./popper");
|
|
28
23
|
const popper = new popper_1.PopperManager();
|
|
29
24
|
const listTypes = [transform_1.schema.nodes.ordered_list, transform_1.schema.nodes.bullet_list];
|
|
@@ -41,7 +36,7 @@ const hasAny = (set, ...items) => {
|
|
|
41
36
|
return items.some((i) => set.has(i));
|
|
42
37
|
};
|
|
43
38
|
class ContextMenu {
|
|
44
|
-
constructor(node, view, getPos, actions = {}
|
|
39
|
+
constructor(node, view, getPos, actions = {}) {
|
|
45
40
|
this.showAddMenu = (target, after) => {
|
|
46
41
|
const menu = document.createElement('div');
|
|
47
42
|
menu.className = 'menu';
|
|
@@ -186,48 +181,11 @@ class ContextMenu {
|
|
|
186
181
|
if (isInTable) {
|
|
187
182
|
menu.appendChild(this.createMenuSection((section) => {
|
|
188
183
|
section.appendChild(this.createMenuItem('Add Reference Note', () => {
|
|
189
|
-
var _a;
|
|
190
184
|
const footnotesElement = (0, prosemirror_utils_1.findChildrenByType)(this.node, transform_1.schema.nodes.footnotes_element);
|
|
191
185
|
if (!footnotesElement.length) {
|
|
192
186
|
const { state, dispatch } = this.view;
|
|
193
187
|
(0, commands_1.insertTableFootnote)(this.node, this.getPos(), state, dispatch);
|
|
194
188
|
}
|
|
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
|
-
}
|
|
231
189
|
}));
|
|
232
190
|
}));
|
|
233
191
|
}
|
|
@@ -348,7 +306,6 @@ class ContextMenu {
|
|
|
348
306
|
this.view = view;
|
|
349
307
|
this.getPos = getPos;
|
|
350
308
|
this.actions = actions;
|
|
351
|
-
this.props = props;
|
|
352
309
|
}
|
|
353
310
|
}
|
|
354
311
|
exports.ContextMenu = ContextMenu;
|
package/dist/es/commands.js
CHANGED
|
@@ -685,37 +685,28 @@ export const insertTableFootnote = (node, position, state, dispatch) => {
|
|
|
685
685
|
});
|
|
686
686
|
const insertedAt = state.selection.to;
|
|
687
687
|
const inlineFootnotes = findChildrenByType(node, schema.nodes.inline_footnote);
|
|
688
|
-
const labels = inlineFootnotes.map((nodeWithPos) => nodeWithPos.node.attrs.contents);
|
|
689
688
|
const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
|
|
690
689
|
rids: [footnote.attrs.id],
|
|
691
|
-
contents:
|
|
690
|
+
contents: inlineFootnotes.length + 1,
|
|
692
691
|
});
|
|
693
692
|
const tr = state.tr;
|
|
694
693
|
tr.insert(insertedAt, inlineFootnoteNode);
|
|
694
|
+
const footnoteElement = state.schema.nodes.footnotes_element.create({}, footnote);
|
|
695
|
+
const tableElementFooter = findChildrenByType(node, schema.nodes.table_element_footer);
|
|
695
696
|
let insertionPos;
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
insertionPos
|
|
700
|
-
tr.insert(insertionPos, footnote);
|
|
697
|
+
if (tableElementFooter.length) {
|
|
698
|
+
const pos = tableElementFooter[0].pos;
|
|
699
|
+
insertionPos = position + pos + tableElementFooter[0].node.nodeSize + 1;
|
|
700
|
+
tr.insert(insertionPos, footnoteElement);
|
|
701
701
|
}
|
|
702
702
|
else {
|
|
703
|
-
const
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
const
|
|
707
|
-
|
|
708
|
-
|
|
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
|
-
}
|
|
703
|
+
const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
|
|
704
|
+
if (tableSize) {
|
|
705
|
+
insertionPos = position + tableSize + 2;
|
|
706
|
+
const tableElementFooter = schema.nodes.table_element_footer.create({
|
|
707
|
+
id: generateID(ObjectTypes.TableElementFooter),
|
|
708
|
+
}, [footnoteElement]);
|
|
709
|
+
tr.insert(insertionPos, tableElementFooter);
|
|
719
710
|
}
|
|
720
711
|
}
|
|
721
712
|
if (dispatch && insertionPos) {
|
|
@@ -13,11 +13,9 @@
|
|
|
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';
|
|
17
16
|
import { isInBibliographySection, nodeNames, schema, } from '@manuscripts/transform';
|
|
18
17
|
import { findChildrenByType, hasParentNodeOfType } from 'prosemirror-utils';
|
|
19
18
|
import { addComment, createBlock, insertGeneralFootnote, insertTableFootnote, } from '../commands';
|
|
20
|
-
import ReactSubView from '../views/ReactSubView';
|
|
21
19
|
import { PopperManager } from './popper';
|
|
22
20
|
const popper = new PopperManager();
|
|
23
21
|
const listTypes = [schema.nodes.ordered_list, schema.nodes.bullet_list];
|
|
@@ -34,7 +32,7 @@ const hasAny = (set, ...items) => {
|
|
|
34
32
|
return items.some((i) => set.has(i));
|
|
35
33
|
};
|
|
36
34
|
export class ContextMenu {
|
|
37
|
-
constructor(node, view, getPos, actions = {}
|
|
35
|
+
constructor(node, view, getPos, actions = {}) {
|
|
38
36
|
this.showAddMenu = (target, after) => {
|
|
39
37
|
const menu = document.createElement('div');
|
|
40
38
|
menu.className = 'menu';
|
|
@@ -179,48 +177,11 @@ export class ContextMenu {
|
|
|
179
177
|
if (isInTable) {
|
|
180
178
|
menu.appendChild(this.createMenuSection((section) => {
|
|
181
179
|
section.appendChild(this.createMenuItem('Add Reference Note', () => {
|
|
182
|
-
var _a;
|
|
183
180
|
const footnotesElement = findChildrenByType(this.node, schema.nodes.footnotes_element);
|
|
184
181
|
if (!footnotesElement.length) {
|
|
185
182
|
const { state, dispatch } = this.view;
|
|
186
183
|
insertTableFootnote(this.node, this.getPos(), state, dispatch);
|
|
187
184
|
}
|
|
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
|
-
}
|
|
224
185
|
}));
|
|
225
186
|
}));
|
|
226
187
|
}
|
|
@@ -341,6 +302,5 @@ export class ContextMenu {
|
|
|
341
302
|
this.view = view;
|
|
342
303
|
this.getPos = getPos;
|
|
343
304
|
this.actions = actions;
|
|
344
|
-
this.props = props;
|
|
345
305
|
}
|
|
346
306
|
}
|
|
@@ -15,7 +15,6 @@
|
|
|
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';
|
|
19
18
|
export declare const sectionLevel: (depth: number) => string;
|
|
20
19
|
interface Actions {
|
|
21
20
|
setComment?: (comment: CommentAnnotation) => void;
|
|
@@ -25,8 +24,7 @@ export declare class ContextMenu {
|
|
|
25
24
|
private readonly view;
|
|
26
25
|
private readonly getPos;
|
|
27
26
|
private readonly actions;
|
|
28
|
-
|
|
29
|
-
constructor(node: ManuscriptNode, view: ManuscriptEditorView, getPos: () => number, actions?: Actions, props?: EditableBlockProps);
|
|
27
|
+
constructor(node: ManuscriptNode, view: ManuscriptEditorView, getPos: () => number, actions?: Actions);
|
|
30
28
|
showAddMenu: (target: Element, after: boolean) => void;
|
|
31
29
|
showEditMenu: (target: Element) => void;
|
|
32
30
|
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.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",
|
|
@@ -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": "1.7.6
|
|
34
|
+
"@manuscripts/style-guide": "^1.7.6",
|
|
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,8 +135,7 @@
|
|
|
135
135
|
.popper .citation-editor,
|
|
136
136
|
.popper .cross-reference-editor,
|
|
137
137
|
.popper .citation-references,
|
|
138
|
-
.popper .track-changes-review-panel
|
|
139
|
-
.popper .table-footnote-editor {
|
|
138
|
+
.popper .track-changes-review-panel {
|
|
140
139
|
background: #fff;
|
|
141
140
|
border: 1px solid #e2e2e2;
|
|
142
141
|
border-radius: 8px;
|
|
@@ -190,8 +189,7 @@
|
|
|
190
189
|
height: auto;
|
|
191
190
|
}
|
|
192
191
|
|
|
193
|
-
.popper .citation-editor
|
|
194
|
-
.popper .table-footnote-editor {
|
|
192
|
+
.popper .citation-editor {
|
|
195
193
|
width: 600px;
|
|
196
194
|
}
|
|
197
195
|
|
|
@@ -206,8 +204,7 @@
|
|
|
206
204
|
.popper .citation-editor,
|
|
207
205
|
.popper .cross-reference-editor,
|
|
208
206
|
.popper .equation-editor,
|
|
209
|
-
.popper .link-editor
|
|
210
|
-
.popper .table-footnote-editor {
|
|
207
|
+
.popper .link-editor {
|
|
211
208
|
min-width: 90%;
|
|
212
209
|
max-width: 90%;
|
|
213
210
|
}
|
|
@@ -222,10 +219,6 @@
|
|
|
222
219
|
width: 600px;
|
|
223
220
|
}
|
|
224
221
|
|
|
225
|
-
.popper .table-footnote-editor {
|
|
226
|
-
left: 50%;
|
|
227
|
-
transform: translate(-50%, -100%);
|
|
228
|
-
}
|
|
229
222
|
|
|
230
223
|
.popper .track-attrs-popper {
|
|
231
224
|
box-shadow: 0 4px 9px 0 rgba(0, 0, 0, 0.30);
|