@manuscripts/body-editor 1.7.17 → 1.7.18-LEAN-3458-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.
@@ -127,10 +127,14 @@ const insertGeneralFootnote = (tableNode, position, view, tableElementFooter) =>
127
127
  const generalNote = state.schema.nodes.paragraph.create({
128
128
  placeholder: 'Add general note here',
129
129
  });
130
+ const tableColGroup = (0, prosemirror_utils_1.findChildrenByType)(tableNode, transform_1.schema.nodes.table_colgroup)[0];
130
131
  const tr = state.tr;
131
132
  const pos = (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length)
132
133
  ? position + tableElementFooter[0].pos + 2
133
- : position + (((_a = tableNode.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize) || 0);
134
+ : position +
135
+ (!tableColGroup
136
+ ? ((_a = tableNode.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize) || 0
137
+ : tableColGroup.pos + tableColGroup.node.nodeSize);
134
138
  if (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length) {
135
139
  tr.insert(pos, generalNote);
136
140
  }
@@ -752,14 +756,22 @@ const insertTableFootnote = (node, position, state, dispatch) => {
752
756
  tr.insert(insertionPos, footnoteElement);
753
757
  }
754
758
  else {
755
- const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
756
- if (tableSize) {
757
- insertionPos = position + tableSize + 2;
758
- const tableElementFooter = transform_1.schema.nodes.table_element_footer.create({
759
- id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.TableElementFooter),
760
- }, [footnoteElement]);
759
+ const tableElementFooter = transform_1.schema.nodes.table_element_footer.create({
760
+ id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.TableElementFooter),
761
+ }, [footnoteElement]);
762
+ const tableColGroup = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.table_colgroup)[0];
763
+ if (tableColGroup) {
764
+ insertionPos =
765
+ position + tableColGroup.pos + tableColGroup.node.nodeSize + 2;
761
766
  tr.insert(insertionPos, tableElementFooter);
762
767
  }
768
+ else {
769
+ const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
770
+ if (tableSize) {
771
+ insertionPos = position + tableSize + 2;
772
+ tr.insert(insertionPos, tableElementFooter);
773
+ }
774
+ }
763
775
  }
764
776
  }
765
777
  if (dispatch && insertionPos) {
@@ -118,10 +118,14 @@ export const insertGeneralFootnote = (tableNode, position, view, tableElementFoo
118
118
  const generalNote = state.schema.nodes.paragraph.create({
119
119
  placeholder: 'Add general note here',
120
120
  });
121
+ const tableColGroup = findChildrenByType(tableNode, schema.nodes.table_colgroup)[0];
121
122
  const tr = state.tr;
122
123
  const pos = (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length)
123
124
  ? position + tableElementFooter[0].pos + 2
124
- : position + (((_a = tableNode.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize) || 0);
125
+ : position +
126
+ (!tableColGroup
127
+ ? ((_a = tableNode.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize) || 0
128
+ : tableColGroup.pos + tableColGroup.node.nodeSize);
125
129
  if (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length) {
126
130
  tr.insert(pos, generalNote);
127
131
  }
@@ -715,14 +719,22 @@ export const insertTableFootnote = (node, position, state, dispatch) => {
715
719
  tr.insert(insertionPos, footnoteElement);
716
720
  }
717
721
  else {
718
- const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
719
- if (tableSize) {
720
- insertionPos = position + tableSize + 2;
721
- const tableElementFooter = schema.nodes.table_element_footer.create({
722
- id: generateID(ObjectTypes.TableElementFooter),
723
- }, [footnoteElement]);
722
+ const tableElementFooter = schema.nodes.table_element_footer.create({
723
+ id: generateID(ObjectTypes.TableElementFooter),
724
+ }, [footnoteElement]);
725
+ const tableColGroup = findChildrenByType(node, schema.nodes.table_colgroup)[0];
726
+ if (tableColGroup) {
727
+ insertionPos =
728
+ position + tableColGroup.pos + tableColGroup.node.nodeSize + 2;
724
729
  tr.insert(insertionPos, tableElementFooter);
725
730
  }
731
+ else {
732
+ const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
733
+ if (tableSize) {
734
+ insertionPos = position + tableSize + 2;
735
+ tr.insert(insertionPos, tableElementFooter);
736
+ }
737
+ }
726
738
  }
727
739
  }
728
740
  if (dispatch && insertionPos) {
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.17",
4
+ "version": "1.7.18-LEAN-3458-0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -29,11 +29,11 @@
29
29
  "dependencies": {
30
30
  "@iarna/word-count": "^1.1.2",
31
31
  "@manuscripts/assets": "^0.6.4",
32
- "@manuscripts/json-schema": "^2.2.5",
33
- "@manuscripts/library": "^1.3.4",
34
- "@manuscripts/style-guide": "^1.7.10",
32
+ "@manuscripts/json-schema": "^2.2.6",
33
+ "@manuscripts/library": "^1.3.5",
34
+ "@manuscripts/style-guide": "^1.7.11",
35
35
  "@manuscripts/track-changes-plugin": "^1.7.6",
36
- "@manuscripts/transform": "^2.1.5",
36
+ "@manuscripts/transform": "^2.1.6",
37
37
  "astrocite-eutils": "^0.16.4",
38
38
  "axios": "^1.6.7",
39
39
  "mathjax-full": "^3.2.2",
@@ -110,4 +110,4 @@
110
110
  "resolutions": {
111
111
  "@types/react": "^17.0.2"
112
112
  }
113
- }
113
+ }