@manuscripts/body-editor 1.7.21 → 1.7.22

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.
@@ -128,10 +128,14 @@ const insertGeneralFootnote = (tableNode, position, view, tableElementFooter) =>
128
128
  const generalNote = state.schema.nodes.paragraph.create({
129
129
  placeholder: 'Add general note here',
130
130
  });
131
+ const tableColGroup = (0, prosemirror_utils_1.findChildrenByType)(tableNode, transform_1.schema.nodes.table_colgroup)[0];
131
132
  const tr = state.tr;
132
133
  const pos = (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length)
133
134
  ? position + tableElementFooter[0].pos + 2
134
- : position + (((_a = tableNode.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize) || 0);
135
+ : position +
136
+ (!tableColGroup
137
+ ? ((_a = tableNode.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize) || 0
138
+ : tableColGroup.pos + tableColGroup.node.nodeSize);
135
139
  if (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length) {
136
140
  tr.insert(pos, generalNote);
137
141
  }
@@ -755,14 +759,22 @@ const insertTableFootnote = (node, position, state, dispatch) => {
755
759
  tr.insert(insertionPos, footnoteElement);
756
760
  }
757
761
  else {
758
- const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
759
- if (tableSize) {
760
- insertionPos = position + tableSize + 2;
761
- const tableElementFooter = transform_1.schema.nodes.table_element_footer.create({
762
- id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.TableElementFooter),
763
- }, [footnoteElement]);
762
+ const tableElementFooter = transform_1.schema.nodes.table_element_footer.create({
763
+ id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.TableElementFooter),
764
+ }, [footnoteElement]);
765
+ const tableColGroup = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.table_colgroup)[0];
766
+ if (tableColGroup) {
767
+ insertionPos =
768
+ position + tableColGroup.pos + tableColGroup.node.nodeSize + 2;
764
769
  tr.insert(insertionPos, tableElementFooter);
765
770
  }
771
+ else {
772
+ const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
773
+ if (tableSize) {
774
+ insertionPos = position + tableSize + 2;
775
+ tr.insert(insertionPos, tableElementFooter);
776
+ }
777
+ }
766
778
  }
767
779
  }
768
780
  if (dispatch && insertionPos) {
@@ -119,10 +119,14 @@ export const insertGeneralFootnote = (tableNode, position, view, tableElementFoo
119
119
  const generalNote = state.schema.nodes.paragraph.create({
120
120
  placeholder: 'Add general note here',
121
121
  });
122
+ const tableColGroup = findChildrenByType(tableNode, schema.nodes.table_colgroup)[0];
122
123
  const tr = state.tr;
123
124
  const pos = (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length)
124
125
  ? position + tableElementFooter[0].pos + 2
125
- : position + (((_a = tableNode.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize) || 0);
126
+ : position +
127
+ (!tableColGroup
128
+ ? ((_a = tableNode.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize) || 0
129
+ : tableColGroup.pos + tableColGroup.node.nodeSize);
126
130
  if (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length) {
127
131
  tr.insert(pos, generalNote);
128
132
  }
@@ -718,14 +722,22 @@ export const insertTableFootnote = (node, position, state, dispatch) => {
718
722
  tr.insert(insertionPos, footnoteElement);
719
723
  }
720
724
  else {
721
- const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
722
- if (tableSize) {
723
- insertionPos = position + tableSize + 2;
724
- const tableElementFooter = schema.nodes.table_element_footer.create({
725
- id: generateID(ObjectTypes.TableElementFooter),
726
- }, [footnoteElement]);
725
+ const tableElementFooter = schema.nodes.table_element_footer.create({
726
+ id: generateID(ObjectTypes.TableElementFooter),
727
+ }, [footnoteElement]);
728
+ const tableColGroup = findChildrenByType(node, schema.nodes.table_colgroup)[0];
729
+ if (tableColGroup) {
730
+ insertionPos =
731
+ position + tableColGroup.pos + tableColGroup.node.nodeSize + 2;
727
732
  tr.insert(insertionPos, tableElementFooter);
728
733
  }
734
+ else {
735
+ const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
736
+ if (tableSize) {
737
+ insertionPos = position + tableSize + 2;
738
+ tr.insert(insertionPos, tableElementFooter);
739
+ }
740
+ }
729
741
  }
730
742
  }
731
743
  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.21",
4
+ "version": "1.7.22",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",