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

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.
@@ -51,8 +51,8 @@ function setCellAttrs(node, extraAttrs) {
51
51
  if (node.attrs.colwidth) {
52
52
  attrs['data-colwidth'] = node.attrs.colwidth.join(',');
53
53
  }
54
- if (node.textContent) {
55
- attrs.class = 'palceholder';
54
+ if (!node.textContent) {
55
+ attrs.class = 'placeholder';
56
56
  }
57
57
  for (const prop in extraAttrs) {
58
58
  const setter = extraAttrs[prop].setDOMAttr;
@@ -78,9 +78,29 @@ function createTableNodes(options) {
78
78
  tableRole: 'table',
79
79
  isolating: true,
80
80
  group: options.tableGroup,
81
- parseDOM: [{ tag: 'table' }],
82
- toDOM() {
83
- return ['table', ['tbody', 0]];
81
+ parseDOM: [
82
+ {
83
+ tag: 'table',
84
+ getAttrs: (p) => {
85
+ const dom = p;
86
+ return {
87
+ id: dom.getAttribute('id'),
88
+ headerRows: dom.dataset && dom.dataset['header-rows'],
89
+ footerRows: dom.dataset && dom.dataset['footer-rows'],
90
+ };
91
+ },
92
+ },
93
+ ],
94
+ toDOM(node) {
95
+ return [
96
+ 'table',
97
+ {
98
+ id: node.attrs.id,
99
+ 'data-header-rows': String(node.attrs.headerRows),
100
+ 'data-footer-rows': String(node.attrs.footerRows),
101
+ },
102
+ ['tbody', 0],
103
+ ];
84
104
  },
85
105
  },
86
106
  table_row: {
@@ -200,7 +220,7 @@ const tableOptions = {
200
220
  },
201
221
  };
202
222
  exports.tableNodes = createTableNodes(tableOptions);
203
- 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 } }) });
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 } }) });
204
224
  exports.tableRow = exports.tableNodes.table_row;
205
225
  exports.tableCell = exports.tableNodes.table_cell;
206
226
  exports.tableHeader = exports.tableNodes.table_header;
@@ -48,8 +48,8 @@ function setCellAttrs(node, extraAttrs) {
48
48
  if (node.attrs.colwidth) {
49
49
  attrs['data-colwidth'] = node.attrs.colwidth.join(',');
50
50
  }
51
- if (node.textContent) {
52
- attrs.class = 'palceholder';
51
+ if (!node.textContent) {
52
+ attrs.class = 'placeholder';
53
53
  }
54
54
  for (const prop in extraAttrs) {
55
55
  const setter = extraAttrs[prop].setDOMAttr;
@@ -75,9 +75,29 @@ export function createTableNodes(options) {
75
75
  tableRole: 'table',
76
76
  isolating: true,
77
77
  group: options.tableGroup,
78
- parseDOM: [{ tag: 'table' }],
79
- toDOM() {
80
- return ['table', ['tbody', 0]];
78
+ parseDOM: [
79
+ {
80
+ tag: 'table',
81
+ getAttrs: (p) => {
82
+ const dom = p;
83
+ return {
84
+ id: dom.getAttribute('id'),
85
+ headerRows: dom.dataset && dom.dataset['header-rows'],
86
+ footerRows: dom.dataset && dom.dataset['footer-rows'],
87
+ };
88
+ },
89
+ },
90
+ ],
91
+ toDOM(node) {
92
+ return [
93
+ 'table',
94
+ {
95
+ id: node.attrs.id,
96
+ 'data-header-rows': String(node.attrs.headerRows),
97
+ 'data-footer-rows': String(node.attrs.footerRows),
98
+ },
99
+ ['tbody', 0],
100
+ ];
81
101
  },
82
102
  },
83
103
  table_row: {
@@ -196,7 +216,7 @@ const tableOptions = {
196
216
  },
197
217
  };
198
218
  export const tableNodes = createTableNodes(tableOptions);
199
- 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 } }) });
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 } }) });
200
220
  export const tableRow = tableNodes.table_row;
201
221
  export const tableCell = tableNodes.table_cell;
202
222
  export const tableHeader = tableNodes.table_header;
@@ -28,6 +28,12 @@ export declare const table: {
28
28
  comments: {
29
29
  default: null;
30
30
  };
31
+ headerRows: {
32
+ default: number;
33
+ };
34
+ footerRows: {
35
+ default: number;
36
+ };
31
37
  };
32
38
  content?: string | undefined;
33
39
  marks?: string | undefined;
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-10",
4
+ "version": "2.1.1-LEAN-3336-12",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",