@progress/kendo-editor-common 1.10.1-dev.202307201821 → 1.10.1-dev.202307241031

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.
@@ -183,10 +183,7 @@ var nodes = __assign({
183
183
  }, table_caption_external: {
184
184
  content: 'inline+',
185
185
  group: 'block',
186
- attrs: {
187
- caption: { default: null },
188
- style: { default: null }
189
- },
186
+ attrs: __assign({ caption: { default: null } }, commonAttributes()),
190
187
  parseDOM: [{
191
188
  tag: 'div[caption]',
192
189
  getAttrs: domAttributes
@@ -1,18 +1,16 @@
1
1
  import { __assign } from "tslib";
2
2
  import { Plugin } from 'prosemirror-state';
3
- import { tableNodeTypes, TableMap } from 'prosemirror-tables';
3
+ import { TableMap } from 'prosemirror-tables';
4
4
  import { Decoration, DecorationSet } from 'prosemirror-view';
5
5
  import { colgroupAttr } from '../../config/constants';
6
- import { TableView } from './table-view';
6
+ import { TableView, TableWrapperView } from './table-view';
7
7
  import { cellIndexes, domCellAround, otherResizeHandle, otherResizing, edgeCell, parseStyle, setNodeStyle, tableColumnResizeKey as key } from './utils';
8
8
  export function columnResizing() {
9
- // tslint:disable-next-line:variable-name
10
- var View = TableView, handleWidth = 5, cellMinWidth = 25;
9
+ var handleWidth = 5, cellMinWidth = 25;
11
10
  var plugin = new Plugin({
12
11
  key: key,
13
12
  state: {
14
- init: function (_, state) {
15
- this.spec.props.nodeViews[tableNodeTypes(state.schema).table.name] = function (node, view) { return new View(node, view); };
13
+ init: function (_, _state) {
16
14
  return new ResizeState(-1, null);
17
15
  },
18
16
  apply: function (tr, prev) {
@@ -51,7 +49,10 @@ export function columnResizing() {
51
49
  }
52
50
  return DecorationSet.empty;
53
51
  },
54
- nodeViews: {}
52
+ nodeViews: {
53
+ table_wrapper: function (node, view) { return new TableWrapperView(node, view); },
54
+ table: function (node, view) { return new TableView(node, view); }
55
+ }
55
56
  }
56
57
  });
57
58
  return plugin;
@@ -28,6 +28,7 @@ var ResizeState = /** @class */ (function () {
28
28
  return ResizeState;
29
29
  }());
30
30
  var handleMouseMove = function (view, event) {
31
+ var _a;
31
32
  var state = key.getState(view.state);
32
33
  var dragging = state.dragging, nodePosition = state.nodePosition, activeHandle = state.activeHandle;
33
34
  if (nodePosition < 0 || !dragging) {
@@ -52,6 +53,12 @@ var handleMouseMove = function (view, event) {
52
53
  if (verticalDir[activeHandle]) {
53
54
  tableDom.style.height = height + 'px';
54
55
  }
56
+ if (/px/.test(tableDom.style.width)) {
57
+ var wrapper = (_a = tableDom.parentNode) === null || _a === void 0 ? void 0 : _a.parentNode;
58
+ if (wrapper instanceof HTMLDivElement && wrapper.matches('div[table]') && /%/.test(wrapper.style.width)) {
59
+ wrapper.style.width = '';
60
+ }
61
+ }
55
62
  };
56
63
  var toPercents = function (view, tr, tablePos) {
57
64
  var tableNode = view.state.doc.nodeAt(tablePos);
@@ -152,6 +159,15 @@ var handleMouseUp = function (view) {
152
159
  activeHandle: null,
153
160
  nodePosition: nodePosition
154
161
  });
162
+ if (!/%/.test(parseStyle(attrs.style).width || '')) {
163
+ var $pos = tr.doc.resolve(nodePosition);
164
+ var wrapper = parentNode($pos, function (n) { return n.type.name === 'table_wrapper'; });
165
+ if (wrapper && /%/.test(parseStyle(wrapper.node.attrs.style).width || '')) {
166
+ var wrapperAttrs = setNodeStyle(wrapper.node.attrs, 'width', '');
167
+ var wrapperPos = $pos.start(wrapper.depth) - 1;
168
+ tr.setNodeMarkup(wrapperPos, null, wrapperAttrs);
169
+ }
170
+ }
155
171
  view.dispatch(tr);
156
172
  }
157
173
  }
@@ -81,7 +81,61 @@ var TableView = /** @class */ (function () {
81
81
  }
82
82
  }
83
83
  }
84
+ if (/%$/.test(table.style.width)) {
85
+ this.dom.style.width = table.style.width;
86
+ table.style.width = '';
87
+ }
88
+ else {
89
+ this.dom.style.width = '';
90
+ }
84
91
  };
85
92
  return TableView;
86
93
  }());
87
94
  export { TableView };
95
+ var TableWrapperView = /** @class */ (function () {
96
+ function TableWrapperView(node, view) {
97
+ this.node = node;
98
+ this.view = view;
99
+ this.dom = document.createElement('div');
100
+ this.setAttributes(this.dom, node.attrs);
101
+ this.contentDOM = this.dom;
102
+ }
103
+ TableWrapperView.prototype.update = function (node) {
104
+ if (node.type !== this.node.type) {
105
+ return false;
106
+ }
107
+ this.node = node;
108
+ this.setAttributes(this.dom, node.attrs);
109
+ return true;
110
+ };
111
+ TableWrapperView.prototype.ignoreMutation = function (record) {
112
+ return record.type === 'attributes' && record.attributeName === 'style';
113
+ };
114
+ TableWrapperView.prototype.destroy = function () {
115
+ this.node = undefined;
116
+ this.view = undefined;
117
+ };
118
+ TableWrapperView.prototype.setAttributes = function (dom, attrs) {
119
+ for (var attrName in attrs) {
120
+ if (attrName) {
121
+ var current = dom.getAttribute(attrName);
122
+ var next = attrs[attrName];
123
+ if (next && next !== current) {
124
+ dom.setAttribute(attrName, next);
125
+ }
126
+ else if (!next) {
127
+ dom.removeAttribute(attrName);
128
+ }
129
+ }
130
+ }
131
+ dom.setAttribute('table', '');
132
+ if (/%/.test(dom.style.width)) {
133
+ var table = dom.querySelector('table');
134
+ if (table && table.style.width && !/%/.test(table.style.width)) {
135
+ dom.style.width = '';
136
+ }
137
+ }
138
+ };
139
+ return TableWrapperView;
140
+ }());
141
+ export { TableWrapperView };
package/dist/es/source.js CHANGED
@@ -28,15 +28,24 @@ var restoreTables = function (fragment) {
28
28
  if (wrapper && wrapper.matches('div[table]')) {
29
29
  table.style.marginLeft = wrapper.style.marginLeft;
30
30
  table.style.marginRight = wrapper.style.marginRight;
31
- var captionDiv = Array.from(wrapper.children).find(function (el) { return el.matches('div[caption]'); });
32
- if (captionDiv) {
33
- var caption = table.createCaption();
34
- caption.style.textAlign = captionDiv.style.textAlign;
35
- caption.style.verticalAlign = captionDiv.style.verticalAlign;
36
- caption.style.captionSide = captionDiv.style.captionSide;
37
- while (captionDiv.firstChild) {
38
- caption.appendChild(captionDiv.firstChild);
31
+ var captionDiv_1 = Array.from(wrapper.children).find(function (el) { return el.matches('div[caption]'); });
32
+ if (captionDiv_1 && captionDiv_1.innerHTML !== '<img>') {
33
+ var caption_1 = table.createCaption();
34
+ if (captionDiv_1.id) {
35
+ caption_1.id = captionDiv_1.id;
39
36
  }
37
+ if (captionDiv_1.className) {
38
+ caption_1.className = captionDiv_1.className;
39
+ }
40
+ Array.from(captionDiv_1.style).forEach(function (styleName) {
41
+ caption_1.style[styleName] = captionDiv_1.style[styleName];
42
+ });
43
+ while (captionDiv_1.firstChild) {
44
+ caption_1.appendChild(captionDiv_1.firstChild);
45
+ }
46
+ }
47
+ if (wrapper.style.width && !table.style.width) {
48
+ table.style.width = wrapper.style.width;
40
49
  }
41
50
  wrapper.parentNode.insertBefore(table, wrapper);
42
51
  wrapper.parentNode.removeChild(wrapper);
@@ -75,20 +84,29 @@ var validateTablesToPmSchema = function (fragment) {
75
84
  wrapper.style.marginLeft = table.style.marginLeft;
76
85
  wrapper.style.marginRight = table.style.marginRight;
77
86
  if (table.caption) {
78
- var captionDiv = document.createElement('div');
79
- captionDiv.setAttribute('caption', '');
80
- captionDiv.style.display = 'table-caption';
81
- captionDiv.style.textAlign = table.caption.style.textAlign;
82
- captionDiv.style.verticalAlign = table.caption.style.verticalAlign;
83
- captionDiv.style.captionSide = table.caption.style.captionSide;
87
+ var captionDiv_2 = document.createElement('div');
88
+ captionDiv_2.setAttribute('caption', '');
89
+ if (table.caption.id) {
90
+ captionDiv_2.id = table.caption.id;
91
+ }
92
+ if (table.caption.className) {
93
+ captionDiv_2.className = table.caption.className;
94
+ }
95
+ Array.from(table.caption.style).forEach(function (styleName) {
96
+ captionDiv_2.style[styleName] = table.caption.style[styleName];
97
+ });
84
98
  while (table.caption.firstChild) {
85
- captionDiv.appendChild(table.caption.firstChild);
99
+ captionDiv_2.appendChild(table.caption.firstChild);
86
100
  }
87
101
  table.removeChild(table.caption);
88
- wrapper.appendChild(captionDiv);
102
+ wrapper.appendChild(captionDiv_2);
89
103
  }
90
104
  table.parentNode.insertBefore(wrapper, table);
91
105
  wrapper.appendChild(table);
106
+ if (/%/.test(table.style.width)) {
107
+ wrapper.style.width = table.style.width;
108
+ table.style.width = '';
109
+ }
92
110
  }
93
111
  });
94
112
  };
@@ -176,10 +176,7 @@ const nodes = Object.assign({
176
176
  }, table_caption_external: {
177
177
  content: 'inline+',
178
178
  group: 'block',
179
- attrs: {
180
- caption: { default: null },
181
- style: { default: null }
182
- },
179
+ attrs: Object.assign({ caption: { default: null } }, commonAttributes()),
183
180
  parseDOM: [{
184
181
  tag: 'div[caption]',
185
182
  getAttrs: domAttributes
@@ -1,17 +1,15 @@
1
1
  import { Plugin } from 'prosemirror-state';
2
- import { tableNodeTypes, TableMap } from 'prosemirror-tables';
2
+ import { TableMap } from 'prosemirror-tables';
3
3
  import { Decoration, DecorationSet } from 'prosemirror-view';
4
4
  import { colgroupAttr } from '../../config/constants';
5
- import { TableView } from './table-view';
5
+ import { TableView, TableWrapperView } from './table-view';
6
6
  import { cellIndexes, domCellAround, otherResizeHandle, otherResizing, edgeCell, parseStyle, setNodeStyle, tableColumnResizeKey as key } from './utils';
7
7
  export function columnResizing() {
8
- // tslint:disable-next-line:variable-name
9
- const View = TableView, handleWidth = 5, cellMinWidth = 25;
8
+ const handleWidth = 5, cellMinWidth = 25;
10
9
  let plugin = new Plugin({
11
10
  key,
12
11
  state: {
13
- init(_, state) {
14
- this.spec.props.nodeViews[tableNodeTypes(state.schema).table.name] = (node, view) => new View(node, view);
12
+ init(_, _state) {
15
13
  return new ResizeState(-1, null);
16
14
  },
17
15
  apply(tr, prev) {
@@ -50,7 +48,10 @@ export function columnResizing() {
50
48
  }
51
49
  return DecorationSet.empty;
52
50
  },
53
- nodeViews: {}
51
+ nodeViews: {
52
+ table_wrapper: (node, view) => new TableWrapperView(node, view),
53
+ table: (node, view) => new TableView(node, view)
54
+ }
54
55
  }
55
56
  });
56
57
  return plugin;
@@ -26,6 +26,7 @@ class ResizeState {
26
26
  }
27
27
  }
28
28
  const handleMouseMove = (view, event) => {
29
+ var _a;
29
30
  const state = key.getState(view.state);
30
31
  const { dragging, nodePosition, activeHandle } = state;
31
32
  if (nodePosition < 0 || !dragging) {
@@ -50,6 +51,12 @@ const handleMouseMove = (view, event) => {
50
51
  if (verticalDir[activeHandle]) {
51
52
  tableDom.style.height = height + 'px';
52
53
  }
54
+ if (/px/.test(tableDom.style.width)) {
55
+ const wrapper = (_a = tableDom.parentNode) === null || _a === void 0 ? void 0 : _a.parentNode;
56
+ if (wrapper instanceof HTMLDivElement && wrapper.matches('div[table]') && /%/.test(wrapper.style.width)) {
57
+ wrapper.style.width = '';
58
+ }
59
+ }
53
60
  };
54
61
  const toPercents = (view, tr, tablePos) => {
55
62
  const tableNode = view.state.doc.nodeAt(tablePos);
@@ -150,6 +157,15 @@ const handleMouseUp = (view) => {
150
157
  activeHandle: null,
151
158
  nodePosition
152
159
  });
160
+ if (!/%/.test(parseStyle(attrs.style).width || '')) {
161
+ const $pos = tr.doc.resolve(nodePosition);
162
+ const wrapper = parentNode($pos, n => n.type.name === 'table_wrapper');
163
+ if (wrapper && /%/.test(parseStyle(wrapper.node.attrs.style).width || '')) {
164
+ const wrapperAttrs = setNodeStyle(wrapper.node.attrs, 'width', '');
165
+ const wrapperPos = $pos.start(wrapper.depth) - 1;
166
+ tr.setNodeMarkup(wrapperPos, null, wrapperAttrs);
167
+ }
168
+ }
153
169
  view.dispatch(tr);
154
170
  }
155
171
  }
@@ -80,5 +80,57 @@ export class TableView {
80
80
  }
81
81
  }
82
82
  }
83
+ if (/%$/.test(table.style.width)) {
84
+ this.dom.style.width = table.style.width;
85
+ table.style.width = '';
86
+ }
87
+ else {
88
+ this.dom.style.width = '';
89
+ }
90
+ }
91
+ }
92
+ export class TableWrapperView {
93
+ constructor(node, view) {
94
+ this.node = node;
95
+ this.view = view;
96
+ this.dom = document.createElement('div');
97
+ this.setAttributes(this.dom, node.attrs);
98
+ this.contentDOM = this.dom;
99
+ }
100
+ update(node) {
101
+ if (node.type !== this.node.type) {
102
+ return false;
103
+ }
104
+ this.node = node;
105
+ this.setAttributes(this.dom, node.attrs);
106
+ return true;
107
+ }
108
+ ignoreMutation(record) {
109
+ return record.type === 'attributes' && record.attributeName === 'style';
110
+ }
111
+ destroy() {
112
+ this.node = undefined;
113
+ this.view = undefined;
114
+ }
115
+ setAttributes(dom, attrs) {
116
+ for (let attrName in attrs) {
117
+ if (attrName) {
118
+ const current = dom.getAttribute(attrName);
119
+ const next = attrs[attrName];
120
+ if (next && next !== current) {
121
+ dom.setAttribute(attrName, next);
122
+ }
123
+ else if (!next) {
124
+ dom.removeAttribute(attrName);
125
+ }
126
+ }
127
+ }
128
+ dom.setAttribute('table', '');
129
+ if (/%/.test(dom.style.width)) {
130
+ const table = dom.querySelector('table');
131
+ if (table && table.style.width && !/%/.test(table.style.width)) {
132
+ dom.style.width = '';
133
+ }
134
+ }
83
135
  }
84
136
  }
@@ -29,15 +29,24 @@ const restoreTables = (fragment) => {
29
29
  table.style.marginLeft = wrapper.style.marginLeft;
30
30
  table.style.marginRight = wrapper.style.marginRight;
31
31
  const captionDiv = Array.from(wrapper.children).find(el => el.matches('div[caption]'));
32
- if (captionDiv) {
32
+ if (captionDiv && captionDiv.innerHTML !== '<img>') {
33
33
  const caption = table.createCaption();
34
- caption.style.textAlign = captionDiv.style.textAlign;
35
- caption.style.verticalAlign = captionDiv.style.verticalAlign;
36
- caption.style.captionSide = captionDiv.style.captionSide;
34
+ if (captionDiv.id) {
35
+ caption.id = captionDiv.id;
36
+ }
37
+ if (captionDiv.className) {
38
+ caption.className = captionDiv.className;
39
+ }
40
+ Array.from(captionDiv.style).forEach((styleName) => {
41
+ caption.style[styleName] = captionDiv.style[styleName];
42
+ });
37
43
  while (captionDiv.firstChild) {
38
44
  caption.appendChild(captionDiv.firstChild);
39
45
  }
40
46
  }
47
+ if (wrapper.style.width && !table.style.width) {
48
+ table.style.width = wrapper.style.width;
49
+ }
41
50
  wrapper.parentNode.insertBefore(table, wrapper);
42
51
  wrapper.parentNode.removeChild(wrapper);
43
52
  }
@@ -77,10 +86,15 @@ const validateTablesToPmSchema = (fragment) => {
77
86
  if (table.caption) {
78
87
  const captionDiv = document.createElement('div');
79
88
  captionDiv.setAttribute('caption', '');
80
- captionDiv.style.display = 'table-caption';
81
- captionDiv.style.textAlign = table.caption.style.textAlign;
82
- captionDiv.style.verticalAlign = table.caption.style.verticalAlign;
83
- captionDiv.style.captionSide = table.caption.style.captionSide;
89
+ if (table.caption.id) {
90
+ captionDiv.id = table.caption.id;
91
+ }
92
+ if (table.caption.className) {
93
+ captionDiv.className = table.caption.className;
94
+ }
95
+ Array.from(table.caption.style).forEach((styleName) => {
96
+ captionDiv.style[styleName] = table.caption.style[styleName];
97
+ });
84
98
  while (table.caption.firstChild) {
85
99
  captionDiv.appendChild(table.caption.firstChild);
86
100
  }
@@ -89,6 +103,10 @@ const validateTablesToPmSchema = (fragment) => {
89
103
  }
90
104
  table.parentNode.insertBefore(wrapper, table);
91
105
  wrapper.appendChild(table);
106
+ if (/%/.test(table.style.width)) {
107
+ wrapper.style.width = table.style.width;
108
+ table.style.width = '';
109
+ }
92
110
  }
93
111
  });
94
112
  };
@@ -188,10 +188,7 @@ var nodes = tslib_1.__assign({
188
188
  }, table_caption_external: {
189
189
  content: 'inline+',
190
190
  group: 'block',
191
- attrs: {
192
- caption: { default: null },
193
- style: { default: null }
194
- },
191
+ attrs: tslib_1.__assign({ caption: { default: null } }, commonAttributes()),
195
192
  parseDOM: [{
196
193
  tag: 'div[caption]',
197
194
  getAttrs: domAttributes
@@ -9,13 +9,11 @@ var constants_1 = require("../../config/constants");
9
9
  var table_view_1 = require("./table-view");
10
10
  var utils_1 = require("./utils");
11
11
  function columnResizing() {
12
- // tslint:disable-next-line:variable-name
13
- var View = table_view_1.TableView, handleWidth = 5, cellMinWidth = 25;
12
+ var handleWidth = 5, cellMinWidth = 25;
14
13
  var plugin = new prosemirror_state_1.Plugin({
15
14
  key: utils_1.tableColumnResizeKey,
16
15
  state: {
17
- init: function (_, state) {
18
- this.spec.props.nodeViews[prosemirror_tables_1.tableNodeTypes(state.schema).table.name] = function (node, view) { return new View(node, view); };
16
+ init: function (_, _state) {
19
17
  return new ResizeState(-1, null);
20
18
  },
21
19
  apply: function (tr, prev) {
@@ -54,7 +52,10 @@ function columnResizing() {
54
52
  }
55
53
  return prosemirror_view_1.DecorationSet.empty;
56
54
  },
57
- nodeViews: {}
55
+ nodeViews: {
56
+ table_wrapper: function (node, view) { return new table_view_1.TableWrapperView(node, view); },
57
+ table: function (node, view) { return new table_view_1.TableView(node, view); }
58
+ }
58
59
  }
59
60
  });
60
61
  return plugin;
@@ -31,6 +31,7 @@ var ResizeState = /** @class */ (function () {
31
31
  return ResizeState;
32
32
  }());
33
33
  var handleMouseMove = function (view, event) {
34
+ var _a;
34
35
  var state = utils_1.tableResizeKey.getState(view.state);
35
36
  var dragging = state.dragging, nodePosition = state.nodePosition, activeHandle = state.activeHandle;
36
37
  if (nodePosition < 0 || !dragging) {
@@ -55,6 +56,12 @@ var handleMouseMove = function (view, event) {
55
56
  if (verticalDir[activeHandle]) {
56
57
  tableDom.style.height = height + 'px';
57
58
  }
59
+ if (/px/.test(tableDom.style.width)) {
60
+ var wrapper = (_a = tableDom.parentNode) === null || _a === void 0 ? void 0 : _a.parentNode;
61
+ if (wrapper instanceof HTMLDivElement && wrapper.matches('div[table]') && /%/.test(wrapper.style.width)) {
62
+ wrapper.style.width = '';
63
+ }
64
+ }
58
65
  };
59
66
  var toPercents = function (view, tr, tablePos) {
60
67
  var tableNode = view.state.doc.nodeAt(tablePos);
@@ -155,6 +162,15 @@ var handleMouseUp = function (view) {
155
162
  activeHandle: null,
156
163
  nodePosition: nodePosition
157
164
  });
165
+ if (!/%/.test(utils_1.parseStyle(attrs.style).width || '')) {
166
+ var $pos = tr.doc.resolve(nodePosition);
167
+ var wrapper = utils_1.parentNode($pos, function (n) { return n.type.name === 'table_wrapper'; });
168
+ if (wrapper && /%/.test(utils_1.parseStyle(wrapper.node.attrs.style).width || '')) {
169
+ var wrapperAttrs = utils_1.setNodeStyle(wrapper.node.attrs, 'width', '');
170
+ var wrapperPos = $pos.start(wrapper.depth) - 1;
171
+ tr.setNodeMarkup(wrapperPos, null, wrapperAttrs);
172
+ }
173
+ }
158
174
  view.dispatch(tr);
159
175
  }
160
176
  }
@@ -1,11 +1,11 @@
1
1
  import { Node } from 'prosemirror-model';
2
- import { EditorView } from 'prosemirror-view';
3
- export declare class TableView {
2
+ import { EditorView, NodeView } from 'prosemirror-view';
3
+ export declare class TableView implements NodeView {
4
4
  node?: Node;
5
5
  view?: EditorView;
6
6
  table?: HTMLTableElement;
7
7
  colgroup?: HTMLTableColElement;
8
- dom?: HTMLElement;
8
+ dom: HTMLElement;
9
9
  contentDOM?: HTMLElement;
10
10
  private resizeHandles?;
11
11
  constructor(node: Node, view: EditorView);
@@ -15,3 +15,14 @@ export declare class TableView {
15
15
  private renderColgroup;
16
16
  private setAttributes;
17
17
  }
18
+ export declare class TableWrapperView implements NodeView {
19
+ node?: Node;
20
+ view?: EditorView;
21
+ dom: HTMLElement;
22
+ contentDOM?: HTMLElement;
23
+ constructor(node: Node, view: EditorView);
24
+ update(node: Node): boolean;
25
+ ignoreMutation(record: MutationRecord): boolean;
26
+ destroy(): void;
27
+ private setAttributes;
28
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TableView = void 0;
3
+ exports.TableWrapperView = exports.TableView = void 0;
4
4
  var constants_1 = require("../../config/constants");
5
5
  var schema_1 = require("../../config/schema");
6
6
  var resize_utils_1 = require("./../resize-utils");
@@ -84,7 +84,61 @@ var TableView = /** @class */ (function () {
84
84
  }
85
85
  }
86
86
  }
87
+ if (/%$/.test(table.style.width)) {
88
+ this.dom.style.width = table.style.width;
89
+ table.style.width = '';
90
+ }
91
+ else {
92
+ this.dom.style.width = '';
93
+ }
87
94
  };
88
95
  return TableView;
89
96
  }());
90
97
  exports.TableView = TableView;
98
+ var TableWrapperView = /** @class */ (function () {
99
+ function TableWrapperView(node, view) {
100
+ this.node = node;
101
+ this.view = view;
102
+ this.dom = document.createElement('div');
103
+ this.setAttributes(this.dom, node.attrs);
104
+ this.contentDOM = this.dom;
105
+ }
106
+ TableWrapperView.prototype.update = function (node) {
107
+ if (node.type !== this.node.type) {
108
+ return false;
109
+ }
110
+ this.node = node;
111
+ this.setAttributes(this.dom, node.attrs);
112
+ return true;
113
+ };
114
+ TableWrapperView.prototype.ignoreMutation = function (record) {
115
+ return record.type === 'attributes' && record.attributeName === 'style';
116
+ };
117
+ TableWrapperView.prototype.destroy = function () {
118
+ this.node = undefined;
119
+ this.view = undefined;
120
+ };
121
+ TableWrapperView.prototype.setAttributes = function (dom, attrs) {
122
+ for (var attrName in attrs) {
123
+ if (attrName) {
124
+ var current = dom.getAttribute(attrName);
125
+ var next = attrs[attrName];
126
+ if (next && next !== current) {
127
+ dom.setAttribute(attrName, next);
128
+ }
129
+ else if (!next) {
130
+ dom.removeAttribute(attrName);
131
+ }
132
+ }
133
+ }
134
+ dom.setAttribute('table', '');
135
+ if (/%/.test(dom.style.width)) {
136
+ var table = dom.querySelector('table');
137
+ if (table && table.style.width && !/%/.test(table.style.width)) {
138
+ dom.style.width = '';
139
+ }
140
+ }
141
+ };
142
+ return TableWrapperView;
143
+ }());
144
+ exports.TableWrapperView = TableWrapperView;