@manuscripts/body-editor 2.0.22-LEAN-3901.0 → 2.0.23
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 +16 -13
- package/dist/cjs/versions.js +1 -1
- package/dist/es/commands.js +16 -13
- package/dist/es/versions.js +1 -1
- package/dist/types/commands.d.ts +2 -2
- package/dist/types/versions.d.ts +1 -1
- package/package.json +2 -2
package/dist/cjs/commands.js
CHANGED
|
@@ -132,7 +132,8 @@ const createBlock = (nodeType, position, state, dispatch, attrs, tableConfig) =>
|
|
|
132
132
|
}
|
|
133
133
|
};
|
|
134
134
|
exports.createBlock = createBlock;
|
|
135
|
-
const insertGeneralFootnote = (
|
|
135
|
+
const insertGeneralFootnote = (tableNode, position, view, tableElementFooter) => {
|
|
136
|
+
var _a;
|
|
136
137
|
const { state, dispatch } = view;
|
|
137
138
|
const paragraph = state.schema.nodes.paragraph.create({
|
|
138
139
|
placeholder: 'Add general note here',
|
|
@@ -140,14 +141,13 @@ const insertGeneralFootnote = (tableElementNode, position, view, tableElementFoo
|
|
|
140
141
|
const generalNote = state.schema.nodes.general_table_footnote.create({}, [
|
|
141
142
|
paragraph,
|
|
142
143
|
]);
|
|
143
|
-
const tableColGroup = (0, prosemirror_utils_1.findChildrenByType)(
|
|
144
|
-
const table = (0, prosemirror_utils_1.findChildrenByType)(tableElementNode, transform_1.schema.nodes.table)[0];
|
|
144
|
+
const tableColGroup = (0, prosemirror_utils_1.findChildrenByType)(tableNode, transform_1.schema.nodes.table_colgroup)[0];
|
|
145
145
|
const tr = state.tr;
|
|
146
146
|
const pos = (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length)
|
|
147
147
|
? position + tableElementFooter[0].pos + 2
|
|
148
148
|
: position +
|
|
149
149
|
(!tableColGroup
|
|
150
|
-
?
|
|
150
|
+
? ((_a = tableNode.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize) || 0
|
|
151
151
|
: tableColGroup.pos + tableColGroup.node.nodeSize);
|
|
152
152
|
if (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length) {
|
|
153
153
|
tr.insert(pos, generalNote);
|
|
@@ -921,7 +921,8 @@ const addInlineComment = (state, dispatch) => {
|
|
|
921
921
|
return false;
|
|
922
922
|
};
|
|
923
923
|
exports.addInlineComment = addInlineComment;
|
|
924
|
-
const insertTableFootnote = (
|
|
924
|
+
const insertTableFootnote = (node, position, view, inlineFootnote) => {
|
|
925
|
+
var _a;
|
|
925
926
|
const { state, dispatch } = view;
|
|
926
927
|
const tr = state.tr;
|
|
927
928
|
const footnote = state.schema.nodes.footnote.createAndFill({
|
|
@@ -939,9 +940,9 @@ const insertTableFootnote = (tableElementNode, position, view, inlineFootnote) =
|
|
|
939
940
|
});
|
|
940
941
|
}
|
|
941
942
|
else {
|
|
942
|
-
const inlineFootnotes = (0, prosemirror_utils_1.findChildrenByType)(
|
|
943
|
+
const inlineFootnotes = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.inline_footnote);
|
|
943
944
|
footnoteIndex =
|
|
944
|
-
inlineFootnotes.filter(({ pos }) => !(0, track_changes_utils_1.isRejectedInsert)(
|
|
945
|
+
inlineFootnotes.filter(({ pos }) => !(0, track_changes_utils_1.isRejectedInsert)(node) && position + pos <= insertedAt).length + 1;
|
|
945
946
|
const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
|
|
946
947
|
rids: [footnote.attrs.id],
|
|
947
948
|
contents: footnoteIndex === -1 ? inlineFootnotes.length : footnoteIndex,
|
|
@@ -949,7 +950,7 @@ const insertTableFootnote = (tableElementNode, position, view, inlineFootnote) =
|
|
|
949
950
|
tr.insert(insertedAt, inlineFootnoteNode);
|
|
950
951
|
}
|
|
951
952
|
let insertionPos = position;
|
|
952
|
-
const footnotesElement = (0, prosemirror_utils_1.findChildrenByType)(
|
|
953
|
+
const footnotesElement = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.footnotes_element).pop();
|
|
953
954
|
if (footnotesElement &&
|
|
954
955
|
!(0, track_changes_utils_1.isDeleted)(footnotesElement.node) &&
|
|
955
956
|
!(0, track_changes_utils_1.isRejectedInsert)(footnotesElement.node)) {
|
|
@@ -959,7 +960,7 @@ const insertTableFootnote = (tableElementNode, position, view, inlineFootnote) =
|
|
|
959
960
|
}
|
|
960
961
|
else {
|
|
961
962
|
const footnoteElement = state.schema.nodes.footnotes_element.create({}, footnote);
|
|
962
|
-
const tableElementFooter = (0, prosemirror_utils_1.findChildrenByType)(
|
|
963
|
+
const tableElementFooter = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.table_element_footer)[0];
|
|
963
964
|
if (tableElementFooter) {
|
|
964
965
|
const pos = tableElementFooter.pos;
|
|
965
966
|
insertionPos = position + pos + tableElementFooter.node.nodeSize;
|
|
@@ -969,16 +970,18 @@ const insertTableFootnote = (tableElementNode, position, view, inlineFootnote) =
|
|
|
969
970
|
const tableElementFooter = transform_1.schema.nodes.table_element_footer.create({
|
|
970
971
|
id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.TableElementFooter),
|
|
971
972
|
}, [footnoteElement]);
|
|
972
|
-
const tableColGroup = (0, prosemirror_utils_1.findChildrenByType)(
|
|
973
|
-
const table = (0, prosemirror_utils_1.findChildrenByType)(tableElementNode, transform_1.schema.nodes.table)[0];
|
|
973
|
+
const tableColGroup = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.table_colgroup)[0];
|
|
974
974
|
if (tableColGroup) {
|
|
975
975
|
insertionPos =
|
|
976
976
|
position + tableColGroup.pos + tableColGroup.node.nodeSize;
|
|
977
977
|
tr.insert(tr.mapping.map(insertionPos), tableElementFooter);
|
|
978
978
|
}
|
|
979
979
|
else {
|
|
980
|
-
|
|
981
|
-
|
|
980
|
+
const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
|
|
981
|
+
if (tableSize) {
|
|
982
|
+
insertionPos = position + tableSize;
|
|
983
|
+
tr.insert(tr.mapping.map(insertionPos), tableElementFooter);
|
|
984
|
+
}
|
|
982
985
|
}
|
|
983
986
|
}
|
|
984
987
|
}
|
package/dist/cjs/versions.js
CHANGED
package/dist/es/commands.js
CHANGED
|
@@ -123,7 +123,8 @@ export const createBlock = (nodeType, position, state, dispatch, attrs, tableCon
|
|
|
123
123
|
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
|
-
export const insertGeneralFootnote = (
|
|
126
|
+
export const insertGeneralFootnote = (tableNode, position, view, tableElementFooter) => {
|
|
127
|
+
var _a;
|
|
127
128
|
const { state, dispatch } = view;
|
|
128
129
|
const paragraph = state.schema.nodes.paragraph.create({
|
|
129
130
|
placeholder: 'Add general note here',
|
|
@@ -131,14 +132,13 @@ export const insertGeneralFootnote = (tableElementNode, position, view, tableEle
|
|
|
131
132
|
const generalNote = state.schema.nodes.general_table_footnote.create({}, [
|
|
132
133
|
paragraph,
|
|
133
134
|
]);
|
|
134
|
-
const tableColGroup = findChildrenByType(
|
|
135
|
-
const table = findChildrenByType(tableElementNode, schema.nodes.table)[0];
|
|
135
|
+
const tableColGroup = findChildrenByType(tableNode, schema.nodes.table_colgroup)[0];
|
|
136
136
|
const tr = state.tr;
|
|
137
137
|
const pos = (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length)
|
|
138
138
|
? position + tableElementFooter[0].pos + 2
|
|
139
139
|
: position +
|
|
140
140
|
(!tableColGroup
|
|
141
|
-
?
|
|
141
|
+
? ((_a = tableNode.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize) || 0
|
|
142
142
|
: tableColGroup.pos + tableColGroup.node.nodeSize);
|
|
143
143
|
if (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length) {
|
|
144
144
|
tr.insert(pos, generalNote);
|
|
@@ -879,7 +879,8 @@ export const addInlineComment = (state, dispatch) => {
|
|
|
879
879
|
}
|
|
880
880
|
return false;
|
|
881
881
|
};
|
|
882
|
-
export const insertTableFootnote = (
|
|
882
|
+
export const insertTableFootnote = (node, position, view, inlineFootnote) => {
|
|
883
|
+
var _a;
|
|
883
884
|
const { state, dispatch } = view;
|
|
884
885
|
const tr = state.tr;
|
|
885
886
|
const footnote = state.schema.nodes.footnote.createAndFill({
|
|
@@ -897,9 +898,9 @@ export const insertTableFootnote = (tableElementNode, position, view, inlineFoot
|
|
|
897
898
|
});
|
|
898
899
|
}
|
|
899
900
|
else {
|
|
900
|
-
const inlineFootnotes = findChildrenByType(
|
|
901
|
+
const inlineFootnotes = findChildrenByType(node, schema.nodes.inline_footnote);
|
|
901
902
|
footnoteIndex =
|
|
902
|
-
inlineFootnotes.filter(({ pos }) => !isRejectedInsert(
|
|
903
|
+
inlineFootnotes.filter(({ pos }) => !isRejectedInsert(node) && position + pos <= insertedAt).length + 1;
|
|
903
904
|
const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
|
|
904
905
|
rids: [footnote.attrs.id],
|
|
905
906
|
contents: footnoteIndex === -1 ? inlineFootnotes.length : footnoteIndex,
|
|
@@ -907,7 +908,7 @@ export const insertTableFootnote = (tableElementNode, position, view, inlineFoot
|
|
|
907
908
|
tr.insert(insertedAt, inlineFootnoteNode);
|
|
908
909
|
}
|
|
909
910
|
let insertionPos = position;
|
|
910
|
-
const footnotesElement = findChildrenByType(
|
|
911
|
+
const footnotesElement = findChildrenByType(node, schema.nodes.footnotes_element).pop();
|
|
911
912
|
if (footnotesElement &&
|
|
912
913
|
!isDeleted(footnotesElement.node) &&
|
|
913
914
|
!isRejectedInsert(footnotesElement.node)) {
|
|
@@ -917,7 +918,7 @@ export const insertTableFootnote = (tableElementNode, position, view, inlineFoot
|
|
|
917
918
|
}
|
|
918
919
|
else {
|
|
919
920
|
const footnoteElement = state.schema.nodes.footnotes_element.create({}, footnote);
|
|
920
|
-
const tableElementFooter = findChildrenByType(
|
|
921
|
+
const tableElementFooter = findChildrenByType(node, schema.nodes.table_element_footer)[0];
|
|
921
922
|
if (tableElementFooter) {
|
|
922
923
|
const pos = tableElementFooter.pos;
|
|
923
924
|
insertionPos = position + pos + tableElementFooter.node.nodeSize;
|
|
@@ -927,16 +928,18 @@ export const insertTableFootnote = (tableElementNode, position, view, inlineFoot
|
|
|
927
928
|
const tableElementFooter = schema.nodes.table_element_footer.create({
|
|
928
929
|
id: generateID(ObjectTypes.TableElementFooter),
|
|
929
930
|
}, [footnoteElement]);
|
|
930
|
-
const tableColGroup = findChildrenByType(
|
|
931
|
-
const table = findChildrenByType(tableElementNode, schema.nodes.table)[0];
|
|
931
|
+
const tableColGroup = findChildrenByType(node, schema.nodes.table_colgroup)[0];
|
|
932
932
|
if (tableColGroup) {
|
|
933
933
|
insertionPos =
|
|
934
934
|
position + tableColGroup.pos + tableColGroup.node.nodeSize;
|
|
935
935
|
tr.insert(tr.mapping.map(insertionPos), tableElementFooter);
|
|
936
936
|
}
|
|
937
937
|
else {
|
|
938
|
-
|
|
939
|
-
|
|
938
|
+
const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
|
|
939
|
+
if (tableSize) {
|
|
940
|
+
insertionPos = position + tableSize;
|
|
941
|
+
tr.insert(tr.mapping.map(insertionPos), tableElementFooter);
|
|
942
|
+
}
|
|
940
943
|
}
|
|
941
944
|
}
|
|
942
945
|
}
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '2.0.
|
|
1
|
+
export const VERSION = '2.0.23';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare const blockActive: (type: ManuscriptNodeType) => (state: Manuscri
|
|
|
28
28
|
export declare const canInsert: (type: ManuscriptNodeType) => (state: ManuscriptEditorState) => boolean;
|
|
29
29
|
export declare const createSelection: (nodeType: ManuscriptNodeType, position: number, doc: ManuscriptNode) => Selection;
|
|
30
30
|
export declare const createBlock: (nodeType: ManuscriptNodeType, position: number, state: ManuscriptEditorState, dispatch?: Dispatch, attrs?: Attrs, tableConfig?: TableConfig) => void;
|
|
31
|
-
export declare const insertGeneralFootnote: (
|
|
31
|
+
export declare const insertGeneralFootnote: (tableNode: ManuscriptNode, position: number, view: ManuscriptEditorView, tableElementFooter?: NodeWithPos[]) => void;
|
|
32
32
|
export declare const insertFigure: (file: FileAttachment, state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
33
33
|
export declare const insertSupplement: (file: FileAttachment, state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
34
34
|
export declare const insertBlock: (nodeType: ManuscriptNodeType) => (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView, tableConfig?: TableConfig) => boolean;
|
|
@@ -65,7 +65,7 @@ interface NodeWithPosition {
|
|
|
65
65
|
node: InlineFootnoteNode;
|
|
66
66
|
pos: number;
|
|
67
67
|
}
|
|
68
|
-
export declare const insertTableFootnote: (
|
|
68
|
+
export declare const insertTableFootnote: (node: ManuscriptNode, position: number, view: EditorView, inlineFootnote?: NodeWithPosition) => void;
|
|
69
69
|
export declare const addRows: (direction: 'top' | 'bottom') => (state: EditorState, dispatch?: ((tr: Transaction) => void) | undefined) => boolean;
|
|
70
70
|
export declare const addColumns: (direction: 'right' | 'left') => (state: EditorState, dispatch?: ((tr: Transaction) => void) | undefined) => boolean;
|
|
71
71
|
export declare function mergeCellsWithSpace(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
package/dist/types/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "2.0.
|
|
1
|
+
export declare const VERSION = "2.0.23";
|
|
2
2
|
export declare const MATHJAX_VERSION = "3.2.2";
|
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": "2.0.
|
|
4
|
+
"version": "2.0.23",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@iarna/word-count": "^1.1.2",
|
|
33
33
|
"@manuscripts/json-schema": "2.2.10",
|
|
34
34
|
"@manuscripts/library": "1.3.11",
|
|
35
|
-
"@manuscripts/style-guide": "2.0.
|
|
35
|
+
"@manuscripts/style-guide": "2.0.6",
|
|
36
36
|
"@manuscripts/track-changes-plugin": "1.7.17",
|
|
37
37
|
"@manuscripts/transform": "2.3.24",
|
|
38
38
|
"@popperjs/core": "^2.11.8",
|