@manuscripts/transform 2.1.1-LEAN-3336-12 → 2.1.1-LEAN-3336-14

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.
@@ -241,7 +241,6 @@ exports.jatsBodyTransformations = {
241
241
  fixTables(body, createElement) {
242
242
  const tables = body.querySelectorAll('table-wrap > table');
243
243
  tables.forEach((table) => {
244
- var _a;
245
244
  const colgroup = table.querySelector('colgroup');
246
245
  const cols = table.querySelectorAll('col');
247
246
  if (!colgroup && table.firstChild && cols.length > 0) {
@@ -249,19 +248,20 @@ exports.jatsBodyTransformations = {
249
248
  for (const col of cols) {
250
249
  colgroup.appendChild(col);
251
250
  }
252
- (_a = table.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(colgroup, table);
253
- }
254
- const rows = table.querySelectorAll('tr');
255
- for (const row of rows) {
256
- table.appendChild(row);
257
- }
258
- const thead = table.querySelector('thead');
259
- if (thead) {
260
- table.removeChild(thead);
251
+ table.insertBefore(colgroup, table.firstChild);
261
252
  }
262
253
  const tbody = table.querySelector('tbody');
263
254
  if (tbody) {
264
- table.removeChild(tbody);
255
+ const headerRow = table.querySelector('thead > tr');
256
+ if (!headerRow) {
257
+ const tr = createElement('tr');
258
+ tbody.insertBefore(tr, tbody.firstElementChild);
259
+ }
260
+ const footerRow = table.querySelector('tfoot > tr');
261
+ if (!footerRow) {
262
+ const tr = createElement('tr');
263
+ tbody.appendChild(tr);
264
+ }
265
265
  }
266
266
  });
267
267
  },
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.tableHeader = exports.tableCell = exports.tableRow = exports.table = exports.tableNodes = exports.createTableNodes = void 0;
18
+ exports.tableHeader = exports.tableCell = exports.tableRow = exports.table = exports.tableNodes = void 0;
19
19
  const table_cell_styles_1 = require("../../lib/table-cell-styles");
20
20
  function getCellAttrs(dom, extraAttrs) {
21
21
  if (typeof dom === 'string') {
@@ -77,6 +77,13 @@ function createTableNodes(options) {
77
77
  content: 'table_row+',
78
78
  tableRole: 'table',
79
79
  isolating: true,
80
+ attrs: {
81
+ id: { default: '' },
82
+ dataTracked: { default: null },
83
+ comments: { default: null },
84
+ headerRows: { default: 1 },
85
+ footerRows: { default: 1 },
86
+ },
80
87
  group: options.tableGroup,
81
88
  parseDOM: [
82
89
  {
@@ -137,7 +144,6 @@ function createTableNodes(options) {
137
144
  },
138
145
  };
139
146
  }
140
- exports.createTableNodes = createTableNodes;
141
147
  const tableOptions = {
142
148
  tableGroup: 'block',
143
149
  cellContent: 'inline*',
@@ -165,14 +171,6 @@ const tableOptions = {
165
171
  }
166
172
  },
167
173
  },
168
- class: {
169
- default: null,
170
- setDOMAttr(value, attrs) {
171
- if (value) {
172
- attrs['class'] = value;
173
- }
174
- },
175
- },
176
174
  valign: {
177
175
  default: null,
178
176
  getFromDOM(dom) {
@@ -220,7 +218,7 @@ const tableOptions = {
220
218
  },
221
219
  };
222
220
  exports.tableNodes = createTableNodes(tableOptions);
223
- exports.table = Object.assign(Object.assign({}, exports.tableNodes.table), { attrs: Object.assign(Object.assign({}, exports.tableNodes.table.attrs), { id: { default: '' }, dataTracked: { default: null }, comments: { default: null }, headerRows: { default: 1 }, footerRows: { default: 1 } }) });
221
+ exports.table = exports.tableNodes.table;
224
222
  exports.tableRow = exports.tableNodes.table_row;
225
223
  exports.tableCell = exports.tableNodes.table_cell;
226
224
  exports.tableHeader = exports.tableNodes.table_header;
@@ -574,12 +574,14 @@ class Decoder {
574
574
  const figcaption = this.getFigcaption(model);
575
575
  const comments = this.createCommentNodes(model);
576
576
  comments.forEach((c) => this.comments.set(c.attrs.id, c));
577
- const content = tableElementFooter
578
- ? [table, tableElementFooter, figcaption]
579
- : [table, figcaption];
577
+ const content = [table];
580
578
  if (tableColGroup) {
581
579
  content.unshift(tableColGroup);
582
580
  }
581
+ if (tableElementFooter) {
582
+ content.push(tableElementFooter);
583
+ }
584
+ content.push(figcaption);
583
585
  if (model.listingID) {
584
586
  const listing = this.createListing(model.listingID);
585
587
  content.push(listing);
@@ -238,7 +238,6 @@ export const jatsBodyTransformations = {
238
238
  fixTables(body, createElement) {
239
239
  const tables = body.querySelectorAll('table-wrap > table');
240
240
  tables.forEach((table) => {
241
- var _a;
242
241
  const colgroup = table.querySelector('colgroup');
243
242
  const cols = table.querySelectorAll('col');
244
243
  if (!colgroup && table.firstChild && cols.length > 0) {
@@ -246,19 +245,20 @@ export const jatsBodyTransformations = {
246
245
  for (const col of cols) {
247
246
  colgroup.appendChild(col);
248
247
  }
249
- (_a = table.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(colgroup, table);
250
- }
251
- const rows = table.querySelectorAll('tr');
252
- for (const row of rows) {
253
- table.appendChild(row);
254
- }
255
- const thead = table.querySelector('thead');
256
- if (thead) {
257
- table.removeChild(thead);
248
+ table.insertBefore(colgroup, table.firstChild);
258
249
  }
259
250
  const tbody = table.querySelector('tbody');
260
251
  if (tbody) {
261
- table.removeChild(tbody);
252
+ const headerRow = table.querySelector('thead > tr');
253
+ if (!headerRow) {
254
+ const tr = createElement('tr');
255
+ tbody.insertBefore(tr, tbody.firstElementChild);
256
+ }
257
+ const footerRow = table.querySelector('tfoot > tr');
258
+ if (!footerRow) {
259
+ const tr = createElement('tr');
260
+ tbody.appendChild(tr);
261
+ }
262
262
  }
263
263
  });
264
264
  },
@@ -59,7 +59,7 @@ function setCellAttrs(node, extraAttrs) {
59
59
  }
60
60
  return attrs;
61
61
  }
62
- export function createTableNodes(options) {
62
+ function createTableNodes(options) {
63
63
  const extraAttrs = options.cellAttributes || {};
64
64
  const cellAttrs = {
65
65
  colspan: { default: 1 },
@@ -74,6 +74,13 @@ export function createTableNodes(options) {
74
74
  content: 'table_row+',
75
75
  tableRole: 'table',
76
76
  isolating: true,
77
+ attrs: {
78
+ id: { default: '' },
79
+ dataTracked: { default: null },
80
+ comments: { default: null },
81
+ headerRows: { default: 1 },
82
+ footerRows: { default: 1 },
83
+ },
77
84
  group: options.tableGroup,
78
85
  parseDOM: [
79
86
  {
@@ -161,14 +168,6 @@ const tableOptions = {
161
168
  }
162
169
  },
163
170
  },
164
- class: {
165
- default: null,
166
- setDOMAttr(value, attrs) {
167
- if (value) {
168
- attrs['class'] = value;
169
- }
170
- },
171
- },
172
171
  valign: {
173
172
  default: null,
174
173
  getFromDOM(dom) {
@@ -216,7 +215,7 @@ const tableOptions = {
216
215
  },
217
216
  };
218
217
  export const tableNodes = createTableNodes(tableOptions);
219
- export const table = Object.assign(Object.assign({}, tableNodes.table), { attrs: Object.assign(Object.assign({}, tableNodes.table.attrs), { id: { default: '' }, dataTracked: { default: null }, comments: { default: null }, headerRows: { default: 1 }, footerRows: { default: 1 } }) });
218
+ export const table = tableNodes.table;
220
219
  export const tableRow = tableNodes.table_row;
221
220
  export const tableCell = tableNodes.table_cell;
222
221
  export const tableHeader = tableNodes.table_header;
@@ -565,12 +565,14 @@ export class Decoder {
565
565
  const figcaption = this.getFigcaption(model);
566
566
  const comments = this.createCommentNodes(model);
567
567
  comments.forEach((c) => this.comments.set(c.attrs.id, c));
568
- const content = tableElementFooter
569
- ? [table, tableElementFooter, figcaption]
570
- : [table, figcaption];
568
+ const content = [table];
571
569
  if (tableColGroup) {
572
570
  content.unshift(tableColGroup);
573
571
  }
572
+ if (tableElementFooter) {
573
+ content.push(tableElementFooter);
574
+ }
575
+ content.push(figcaption);
574
576
  if (model.listingID) {
575
577
  const listing = this.createListing(model.listingID);
576
578
  content.push(listing);
@@ -13,46 +13,9 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Node } from 'prosemirror-model';
17
- import { TableNodes, TableNodesOptions } from 'prosemirror-tables';
18
- export declare function createTableNodes(options: TableNodesOptions): TableNodes;
16
+ import { TableNodes } from 'prosemirror-tables';
19
17
  export declare const tableNodes: TableNodes;
20
- export declare const table: {
21
- attrs: {
22
- id: {
23
- default: string;
24
- };
25
- dataTracked: {
26
- default: null;
27
- };
28
- comments: {
29
- default: null;
30
- };
31
- headerRows: {
32
- default: number;
33
- };
34
- footerRows: {
35
- default: number;
36
- };
37
- };
38
- content?: string | undefined;
39
- marks?: string | undefined;
40
- group?: string | undefined;
41
- inline?: boolean | undefined;
42
- atom?: boolean | undefined;
43
- selectable?: boolean | undefined;
44
- draggable?: boolean | undefined;
45
- code?: boolean | undefined;
46
- whitespace?: "pre" | "normal" | undefined;
47
- definingAsContext?: boolean | undefined;
48
- definingForContent?: boolean | undefined;
49
- defining?: boolean | undefined;
50
- isolating?: boolean | undefined;
51
- toDOM?: ((node: Node) => import("prosemirror-model").DOMOutputSpec) | undefined;
52
- parseDOM?: readonly import("prosemirror-model").ParseRule[] | undefined;
53
- toDebugString?: ((node: Node) => string) | undefined;
54
- leafText?: ((node: Node) => string) | undefined;
55
- };
18
+ export declare const table: import("prosemirror-model").NodeSpec;
56
19
  export declare const tableRow: import("prosemirror-model").NodeSpec;
57
20
  export declare const tableCell: import("prosemirror-model").NodeSpec;
58
21
  export declare const tableHeader: import("prosemirror-model").NodeSpec;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/transform",
3
3
  "description": "ProseMirror transformer for Manuscripts applications",
4
- "version": "2.1.1-LEAN-3336-12",
4
+ "version": "2.1.1-LEAN-3336-14",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",