studiokit-scaffolding-js 4.5.2 → 4.5.3

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.
Files changed (37) hide show
  1. package/lib/components/Quill/Formats/Image.d.ts +46 -0
  2. package/lib/components/Quill/Formats/Image.js +86 -0
  3. package/lib/components/Quill/Formats/List.d.ts +15 -0
  4. package/lib/components/Quill/Formats/List.js +79 -0
  5. package/lib/components/Quill/Formats/Video.d.ts +11 -0
  6. package/lib/components/Quill/Formats/Video.js +50 -0
  7. package/lib/components/{Blots → Quill/Specs}/CustomImageSpec.d.ts +2 -1
  8. package/lib/components/{Blots → Quill/Specs}/CustomImageSpec.js +10 -1
  9. package/lib/components/{Blots → Quill/Specs}/CustomVideoSpec.d.ts +0 -0
  10. package/lib/components/{Blots → Quill/Specs}/CustomVideoSpec.js +0 -0
  11. package/lib/components/Quill/TableModule/Blots/BaseTableBlot.d.ts +29 -0
  12. package/lib/components/Quill/TableModule/Blots/BaseTableBlot.js +126 -0
  13. package/lib/components/Quill/TableModule/Blots/TableBlot.d.ts +20 -0
  14. package/lib/components/Quill/TableModule/Blots/TableBlot.js +69 -0
  15. package/lib/components/Quill/TableModule/Blots/TableBodyBlot.d.ts +18 -0
  16. package/lib/components/Quill/TableModule/Blots/TableBodyBlot.js +71 -0
  17. package/lib/components/Quill/TableModule/Blots/TableCellBlot.d.ts +34 -0
  18. package/lib/components/Quill/TableModule/Blots/TableCellBlot.js +236 -0
  19. package/lib/components/Quill/TableModule/Blots/TableContainer.d.ts +16 -0
  20. package/lib/components/Quill/TableModule/Blots/TableContainer.js +103 -0
  21. package/lib/components/Quill/TableModule/Blots/TableRowBlot.d.ts +22 -0
  22. package/lib/components/Quill/TableModule/Blots/TableRowBlot.js +91 -0
  23. package/lib/components/Quill/TableModule/constants.d.ts +34 -0
  24. package/lib/components/Quill/TableModule/constants.js +42 -0
  25. package/lib/components/Quill/TableModule/index.css +171 -0
  26. package/lib/components/Quill/TableModule/index.d.ts +23 -0
  27. package/lib/components/Quill/TableModule/index.js +312 -0
  28. package/lib/components/Quill/TableModule/utils.d.ts +9 -0
  29. package/lib/components/Quill/TableModule/utils.js +54 -0
  30. package/lib/components/Quill/accessibilityFix.d.ts +19 -0
  31. package/lib/components/Quill/accessibilityFix.js +267 -0
  32. package/lib/components/Quill/index.d.ts +1 -0
  33. package/lib/components/Quill/index.js +27 -0
  34. package/lib/utils/dom.d.ts +25 -0
  35. package/lib/utils/dom.js +201 -0
  36. package/lib/utils/sort.js +1 -1
  37. package/package.json +4 -1
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.TableBodyBlot = void 0;
17
+ var react_quill_1 = require("react-quill");
18
+ var constants_1 = require("../constants");
19
+ var BaseTableBlot_1 = require("./BaseTableBlot");
20
+ var TableBlot_1 = require("./TableBlot");
21
+ var TableRowBlot_1 = require("./TableRowBlot");
22
+ var Parchment = react_quill_1.Quill.import('parchment');
23
+ var TableBodyBlot = /** @class */ (function (_super) {
24
+ __extends(TableBodyBlot, _super);
25
+ function TableBodyBlot() {
26
+ return _super !== null && _super.apply(this, arguments) || this;
27
+ }
28
+ TableBodyBlot.create = function (value) {
29
+ var node = _super.createWithValue.call(this, constants_1.TAG_NAME.TBODY, value);
30
+ return node;
31
+ };
32
+ TableBodyBlot.createWithChildren = function (id, rows, cols) {
33
+ var tableBody = Parchment.create(this.blotName, id);
34
+ for (var row = 0; row < rows; row++) {
35
+ var tableRow = TableRowBlot_1.TableRowBlot.createWithChildren(id, cols);
36
+ tableBody.appendChild(tableRow);
37
+ }
38
+ return tableBody;
39
+ };
40
+ TableBodyBlot.prototype.optimize = function (context) {
41
+ _super.prototype.optimize.call(this, context);
42
+ var didRemove = this.optimizeRemoveIfEmpty();
43
+ if (didRemove)
44
+ return;
45
+ this.optimizeMergeWithNext();
46
+ this.optimizeWrapInRequiredParent(this.tableId());
47
+ };
48
+ TableBodyBlot.prototype.unwrap = function () {
49
+ // keep a reference to the rows, since `super.unwrap()` will break the ref
50
+ var rows = this.children.map(function (r) { return r; });
51
+ _super.prototype.unwrap.call(this);
52
+ rows.forEach(function (c) {
53
+ var row = c;
54
+ row.unwrap();
55
+ });
56
+ };
57
+ TableBodyBlot.prototype.tableId = function () {
58
+ return this.domNode.getAttribute(constants_1.ATTRIBUTE.DATA_VALUE);
59
+ };
60
+ TableBodyBlot.prototype.table = function () {
61
+ // tbody -> table
62
+ return this.parent instanceof TableBlot_1.TableBlot ? this.parent : undefined;
63
+ };
64
+ TableBodyBlot.blotName = constants_1.TABLE_BLOT_NAME.TBODY;
65
+ TableBodyBlot.tagName = constants_1.TAG_NAME.TBODY;
66
+ TableBodyBlot.scope = Parchment.Scope.BLOCK_BLOT;
67
+ TableBodyBlot.requiredParentName = constants_1.TABLE_BLOT_NAME.TABLE;
68
+ TableBodyBlot.allowedChildrenNames = [constants_1.TABLE_BLOT_NAME.TR];
69
+ return TableBodyBlot;
70
+ }(BaseTableBlot_1.BaseTableBlot));
71
+ exports.TableBodyBlot = TableBodyBlot;
@@ -0,0 +1,34 @@
1
+ import { Blot } from 'parchment/dist/src/blot/abstract/blot';
2
+ import BlockBlot from 'parchment/dist/src/blot/block';
3
+ import { TABLE_BLOT_NAME, TAG_NAME } from '../constants';
4
+ import { BaseTableBlot } from './BaseTableBlot';
5
+ import { TableRowBlot } from './TableRowBlot';
6
+ export declare class TableCellBlot extends BaseTableBlot {
7
+ static blotName: TABLE_BLOT_NAME;
8
+ static tagName: TAG_NAME;
9
+ static scope: import("parchment/dist/src/registry").Scope;
10
+ static requiredParentName: string | null;
11
+ static defaultChildName: string;
12
+ /** use normal `allowedChildren` instead of `allowedChildrenNames` */
13
+ static allowedChildren: (typeof import("parchment/dist/src/blot/embed").default | typeof import("parchment/dist/src/blot/abstract/container").default)[];
14
+ static create(value: string): HTMLElement;
15
+ static createWithChildren(tableId: string, rowId: string): TableCellBlot;
16
+ formats(): {
17
+ [x: number]: string;
18
+ };
19
+ format(_name: string, _value: any): void;
20
+ optimize(context: {
21
+ [key: string]: any;
22
+ }): void;
23
+ insertBefore(child: Blot, refNode?: Blot): void;
24
+ createDefaultChild(): BlockBlot;
25
+ replace(target: Blot): void;
26
+ formatAt(index: number, length: number, name: string, value: any): void;
27
+ updateDataValue(): void;
28
+ id(): string;
29
+ tableId(): string;
30
+ rowId(): string;
31
+ row(): TableRowBlot | undefined;
32
+ table(): import("./TableBlot").TableBlot | undefined;
33
+ column(): number;
34
+ }
@@ -0,0 +1,236 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.TableCellBlot = void 0;
17
+ var react_quill_1 = require("react-quill");
18
+ var logger_1 = require("../../../../utils/logger");
19
+ var constants_1 = require("../constants");
20
+ var utils_1 = require("../utils");
21
+ var BaseTableBlot_1 = require("./BaseTableBlot");
22
+ var TableRowBlot_1 = require("./TableRowBlot");
23
+ var Parchment = react_quill_1.Quill.import('parchment');
24
+ var Container = react_quill_1.Quill.import('blots/container');
25
+ var Block = react_quill_1.Quill.import('blots/block');
26
+ var BlockEmbed = react_quill_1.Quill.import('blots/block/embed');
27
+ var Break = react_quill_1.Quill.import('blots/break');
28
+ var TableCellBlot = /** @class */ (function (_super) {
29
+ __extends(TableCellBlot, _super);
30
+ function TableCellBlot() {
31
+ return _super !== null && _super.apply(this, arguments) || this;
32
+ }
33
+ TableCellBlot.create = function (value) {
34
+ var node = _super.createWithValue.call(this, constants_1.TAG_NAME.TD, value);
35
+ // split data-value into separate attributes for easier access
36
+ var values = value.split('|');
37
+ node.setAttribute(constants_1.ATTRIBUTE.TABLE, values[0]);
38
+ node.setAttribute(constants_1.ATTRIBUTE.ROW, values[1]);
39
+ node.setAttribute(constants_1.ATTRIBUTE.CELL, values[2]);
40
+ node.setAttribute(constants_1.ATTRIBUTE.ID, values[2]);
41
+ return node;
42
+ };
43
+ TableCellBlot.createWithChildren = function (tableId, rowId) {
44
+ var id = utils_1.newId(this.blotName);
45
+ var tableCell = Parchment.create(this.blotName, tableId + "|" + rowId + "|" + id);
46
+ var p = Parchment.create(Block.blotName);
47
+ tableCell.appendChild(p);
48
+ var br = Parchment.create(Break.blotName);
49
+ p.appendChild(br);
50
+ return tableCell;
51
+ };
52
+ TableCellBlot.prototype.formats = function () {
53
+ var _a;
54
+ // We don't inherit from FormatBlot
55
+ return _a = {},
56
+ _a[this.statics.blotName] = this.tableId() + "|" + this.rowId() + "|" + this.id(),
57
+ _a;
58
+ };
59
+ TableCellBlot.prototype.format = function (_name, _value) {
60
+ // don't do anything
61
+ // our "td" value does not do anything beyond making the <td> tag
62
+ };
63
+ TableCellBlot.prototype.optimize = function (context) {
64
+ _super.prototype.optimize.call(this, context);
65
+ var didRemove = this.optimizeRemoveIfEmpty();
66
+ if (didRemove)
67
+ return;
68
+ this.optimizeMergeWithNext();
69
+ var firstChild = this.children.head;
70
+ while (firstChild instanceof TableCellBlot) {
71
+ logger_1.getLogger().debug(this.statics.tagName + " optimize: head child is TD. insert into parent before this, then optimize");
72
+ this.parent.insertBefore(firstChild, this);
73
+ firstChild.optimize({});
74
+ firstChild = this.children.head;
75
+ }
76
+ var lastChild = this.children.tail;
77
+ while (lastChild instanceof TableCellBlot) {
78
+ logger_1.getLogger().debug(this.statics.tagName + " optimize: tail child is TD. insert into parent after this, then optimize");
79
+ this.parent.insertBefore(lastChild, this.next);
80
+ lastChild.optimize({});
81
+ lastChild = this.children.tail;
82
+ }
83
+ if (this.parent && !utils_1.isInstanceOfBlot(this.parent, this.statics.requiredParentName)) {
84
+ logger_1.getLogger().debug(this.statics.tagName + " optimize: parent is not " + this.statics.requiredParentName, {
85
+ this: this,
86
+ context: context,
87
+ parent: this.parent,
88
+ prev: this.prev,
89
+ next: this.next
90
+ });
91
+ if (this.parent instanceof TableCellBlot && this.parent.dataValue() === this.dataValue()) {
92
+ logger_1.getLogger().debug(this.statics.tagName + " optimize: parent is matching TD. merge this into parent.");
93
+ this.moveChildren(this.parent, this.next);
94
+ this.remove();
95
+ }
96
+ else if (this.parent instanceof TableCellBlot) {
97
+ logger_1.getLogger().debug(this.statics.tagName + " optimize: parent is TD. optimize parent TD.");
98
+ this.parent.optimize(context);
99
+ }
100
+ else {
101
+ var newRow = Parchment.create(this.statics.requiredParentName, this.tableId() + "|" + this.rowId());
102
+ logger_1.getLogger().debug(this.statics.tagName + " optimize: wrap in new TR.", {
103
+ this: this,
104
+ newRow: newRow,
105
+ before: this.next
106
+ });
107
+ this.parent.insertBefore(newRow, this.next);
108
+ this.parent.removeChild(this);
109
+ newRow.appendChild(this);
110
+ }
111
+ }
112
+ };
113
+ TableCellBlot.prototype.insertBefore = function (child, refNode) {
114
+ // does not inherit from super, uses allowedChildren instead of allowedChildrenNames
115
+ logger_1.getLogger().debug(this.statics.tagName + " insertBefore: " + child.statics.tagName, {
116
+ this: this,
117
+ child: child,
118
+ ref: refNode
119
+ });
120
+ if (this.statics.allowedChildren != null &&
121
+ !this.statics.allowedChildren.some(function (allowedChild) {
122
+ return child instanceof allowedChild;
123
+ })) {
124
+ var newChild = this.createDefaultChild();
125
+ logger_1.getLogger().debug(this.statics.tagName + " insertBefore: createDefaultChild and append blot", {
126
+ this: this,
127
+ child: child,
128
+ newChild: newChild,
129
+ ref: refNode
130
+ });
131
+ newChild.appendChild(child);
132
+ newChild.insertInto(this, refNode);
133
+ }
134
+ else {
135
+ child.insertInto(this, refNode);
136
+ }
137
+ };
138
+ TableCellBlot.prototype.createDefaultChild = function () {
139
+ return Parchment.create(this.statics.defaultChildName);
140
+ };
141
+ TableCellBlot.prototype.replace = function (target) {
142
+ logger_1.getLogger().debug(this.statics.tagName + " replace: " + target.statics.tagName, {
143
+ this: this,
144
+ target: target
145
+ });
146
+ if (target instanceof Block) {
147
+ var newChild = target.clone();
148
+ target.moveChildren(newChild);
149
+ this.appendChild(newChild);
150
+ }
151
+ _super.prototype.replace.call(this, target);
152
+ };
153
+ TableCellBlot.prototype.formatAt = function (index, length, name, value) {
154
+ var _this = this;
155
+ var _a;
156
+ logger_1.getLogger().debug("TD formatAt", {
157
+ this: this,
158
+ childrenLength: this.children.length,
159
+ dataValue: this.dataValue(),
160
+ index: index,
161
+ length: length,
162
+ name: name,
163
+ value: value
164
+ });
165
+ // make a local copy of the "children.forEachAt" params, incase the cell is "unwrapped"
166
+ var childFormatAtParams = [];
167
+ this.children.forEachAt(index, length, function (child, offset, length) {
168
+ childFormatAtParams.push([child, offset, length]);
169
+ });
170
+ if (name === this.statics.blotName && (!value || value !== this.dataValue())) {
171
+ var tableContainer = (_a = this.table()) === null || _a === void 0 ? void 0 : _a.tableContainer();
172
+ if (tableContainer) {
173
+ logger_1.getLogger().debug("TD formatAt: cols or rows added were removed, deconstruct table to flatten cells");
174
+ tableContainer.unwrap();
175
+ }
176
+ if (value && index === 0 && length >= this.children.length) {
177
+ logger_1.getLogger().debug("TD formatAt: replace with new cell, do not format children");
178
+ this.replaceWith(name, value);
179
+ return;
180
+ }
181
+ if (!value && this.statics.containsOnlyEmptyBlock(this)) {
182
+ logger_1.getLogger().debug("TD formatAt: no value, unwrap, format children");
183
+ this.unwrap();
184
+ }
185
+ }
186
+ childFormatAtParams.forEach(function (params) {
187
+ var child = params[0], offset = params[1], length = params[2];
188
+ logger_1.getLogger().debug("TD formatAt child", {
189
+ this: _this,
190
+ child: child,
191
+ offset: offset,
192
+ length: length,
193
+ name: name,
194
+ value: value
195
+ });
196
+ child.formatAt(offset, length, name, value);
197
+ });
198
+ };
199
+ TableCellBlot.prototype.updateDataValue = function () {
200
+ this.domNode.setAttribute(constants_1.ATTRIBUTE.DATA_VALUE, this.formats()[this.statics.blotName]);
201
+ };
202
+ TableCellBlot.prototype.id = function () {
203
+ return this.domNode.getAttribute(constants_1.ATTRIBUTE.ID);
204
+ };
205
+ TableCellBlot.prototype.tableId = function () {
206
+ return this.domNode.getAttribute(constants_1.ATTRIBUTE.TABLE);
207
+ };
208
+ TableCellBlot.prototype.rowId = function () {
209
+ return this.domNode.getAttribute(constants_1.ATTRIBUTE.ROW);
210
+ };
211
+ TableCellBlot.prototype.row = function () {
212
+ // td -> tr
213
+ return this.parent instanceof TableRowBlot_1.TableRowBlot ? this.parent : undefined;
214
+ };
215
+ TableCellBlot.prototype.table = function () {
216
+ var _a;
217
+ return (_a = this.row()) === null || _a === void 0 ? void 0 : _a.table();
218
+ };
219
+ TableCellBlot.prototype.column = function () {
220
+ var row = this.row();
221
+ if (!row) {
222
+ throw new Error('row is required to know column');
223
+ }
224
+ var index = row.children.map(function (c) { return c; }).indexOf(this);
225
+ return index + 1;
226
+ };
227
+ TableCellBlot.blotName = constants_1.TABLE_BLOT_NAME.TD;
228
+ TableCellBlot.tagName = constants_1.TAG_NAME.TD;
229
+ TableCellBlot.scope = Parchment.Scope.BLOCK_BLOT;
230
+ TableCellBlot.requiredParentName = constants_1.TABLE_BLOT_NAME.TR;
231
+ TableCellBlot.defaultChildName = Block.blotName;
232
+ /** use normal `allowedChildren` instead of `allowedChildrenNames` */
233
+ TableCellBlot.allowedChildren = [Block, BlockEmbed, Container];
234
+ return TableCellBlot;
235
+ }(BaseTableBlot_1.BaseTableBlot));
236
+ exports.TableCellBlot = TableCellBlot;
@@ -0,0 +1,16 @@
1
+ import { TABLE_BLOT_NAME, TAG_NAME } from '../constants';
2
+ import { BaseTableBlot } from './BaseTableBlot';
3
+ import { TableBlot } from './TableBlot';
4
+ export declare class TableContainerBlot extends BaseTableBlot {
5
+ static blotName: TABLE_BLOT_NAME;
6
+ static tagName: TAG_NAME;
7
+ static scope: import("parchment/dist/src/registry").Scope;
8
+ static allowedChildrenNames: string[];
9
+ static create(value: string): HTMLDivElement;
10
+ static createWithChildren(rows: number, cols: number): TableContainerBlot;
11
+ optimize(context: {
12
+ [key: string]: any;
13
+ }): void;
14
+ unwrap(): void;
15
+ table(): TableBlot;
16
+ }
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.TableContainerBlot = void 0;
17
+ var react_quill_1 = require("react-quill");
18
+ var logger_1 = require("../../../../utils/logger");
19
+ var constants_1 = require("../constants");
20
+ var utils_1 = require("../utils");
21
+ var BaseTableBlot_1 = require("./BaseTableBlot");
22
+ var TableBlot_1 = require("./TableBlot");
23
+ var TableBodyBlot_1 = require("./TableBodyBlot");
24
+ var TableCellBlot_1 = require("./TableCellBlot");
25
+ var TableRowBlot_1 = require("./TableRowBlot");
26
+ var Parchment = react_quill_1.Quill.import('parchment');
27
+ var Block = react_quill_1.Quill.import('blots/block');
28
+ var TableContainerBlot = /** @class */ (function (_super) {
29
+ __extends(TableContainerBlot, _super);
30
+ function TableContainerBlot() {
31
+ return _super !== null && _super.apply(this, arguments) || this;
32
+ }
33
+ TableContainerBlot.create = function (value) {
34
+ var node = _super.createWithValue.call(this, constants_1.TAG_NAME.DIV, value);
35
+ node.classList.add('table-container');
36
+ return node;
37
+ };
38
+ TableContainerBlot.createWithChildren = function (rows, cols) {
39
+ var tableId = utils_1.newId(constants_1.TABLE_BLOT_NAME.TABLE);
40
+ var tableContainer = Parchment.create(this.blotName, tableId);
41
+ var table = TableBlot_1.TableBlot.createWithChildren(tableId, rows, cols);
42
+ tableContainer.appendChild(table);
43
+ return tableContainer;
44
+ };
45
+ TableContainerBlot.prototype.optimize = function (context) {
46
+ _super.prototype.optimize.call(this, context);
47
+ var didRemove = this.optimizeRemoveIfEmpty();
48
+ if (didRemove)
49
+ return;
50
+ this.optimizeMergeWithNext();
51
+ if (!this.prev ||
52
+ // check if prev is already a block
53
+ (!(this.prev instanceof Block) &&
54
+ // check if prev will be merged into the same table
55
+ !(this.prev instanceof TableContainerBlot && this.prev.dataValue() === this.dataValue()) &&
56
+ !(this.prev instanceof TableBlot_1.TableBlot && this.prev.id() === this.dataValue()) &&
57
+ !(this.prev instanceof TableBodyBlot_1.TableBodyBlot && this.prev.tableId() === this.dataValue()) &&
58
+ !(this.prev instanceof TableRowBlot_1.TableRowBlot && this.prev.tableId() === this.dataValue()) &&
59
+ !(this.prev instanceof TableCellBlot_1.TableCellBlot && this.prev.tableId() === this.dataValue()))) {
60
+ logger_1.getLogger().debug(this.statics.tagName + " optimize: no block before table container, inserting new block", {
61
+ this: this,
62
+ parent: this.parent,
63
+ prev: this.prev,
64
+ next: this.next
65
+ });
66
+ var block = Parchment.create(Block.blotName);
67
+ this.parent.insertBefore(block, this);
68
+ }
69
+ if (!this.next ||
70
+ // check if next is already a block
71
+ (!(this.next instanceof Block) &&
72
+ // check if next will be merged into the same table
73
+ !(this.next instanceof TableContainerBlot && this.next.dataValue() === this.dataValue()) &&
74
+ !(this.next instanceof TableBlot_1.TableBlot && this.next.id() === this.dataValue()) &&
75
+ !(this.next instanceof TableBodyBlot_1.TableBodyBlot && this.next.tableId() === this.dataValue()) &&
76
+ !(this.next instanceof TableRowBlot_1.TableRowBlot && this.next.tableId() === this.dataValue()) &&
77
+ !(this.next instanceof TableCellBlot_1.TableCellBlot && this.next.tableId() === this.dataValue()))) {
78
+ logger_1.getLogger().debug(this.statics.tagName + " optimize: no block after table container, inserting new block", {
79
+ this: this,
80
+ parent: this.parent,
81
+ prev: this.prev,
82
+ next: this.next
83
+ });
84
+ var block = Parchment.create(Block.blotName);
85
+ this.parent.insertBefore(block, this.next);
86
+ }
87
+ };
88
+ TableContainerBlot.prototype.unwrap = function () {
89
+ // keep a reference to the body, since `super.unwrap()` will break the ref
90
+ var table = this.table();
91
+ _super.prototype.unwrap.call(this);
92
+ table.unwrap();
93
+ };
94
+ TableContainerBlot.prototype.table = function () {
95
+ return this.children.head;
96
+ };
97
+ TableContainerBlot.blotName = constants_1.TABLE_BLOT_NAME.TABLE_CONTAINER;
98
+ TableContainerBlot.tagName = constants_1.TAG_NAME.DIV;
99
+ TableContainerBlot.scope = Parchment.Scope.BLOCK_BLOT;
100
+ TableContainerBlot.allowedChildrenNames = [constants_1.TABLE_BLOT_NAME.TABLE];
101
+ return TableContainerBlot;
102
+ }(BaseTableBlot_1.BaseTableBlot));
103
+ exports.TableContainerBlot = TableContainerBlot;
@@ -0,0 +1,22 @@
1
+ import { TABLE_BLOT_NAME, TAG_NAME } from '../constants';
2
+ import { BaseTableBlot } from './BaseTableBlot';
3
+ import { TableBodyBlot } from './TableBodyBlot';
4
+ export declare class TableRowBlot extends BaseTableBlot {
5
+ static blotName: TABLE_BLOT_NAME;
6
+ static tagName: TAG_NAME;
7
+ static scope: import("parchment/dist/src/registry").Scope;
8
+ static requiredParentName: string | null;
9
+ static allowedChildrenNames: string[];
10
+ static create(value: string): HTMLElement;
11
+ static createWithChildren(tableId: string, cols: number): TableRowBlot;
12
+ static createFromReference(reference: TableRowBlot): TableRowBlot;
13
+ optimize(context: {
14
+ [key: string]: any;
15
+ }): void;
16
+ id(): string;
17
+ tableId(): string;
18
+ tableBody(): TableBodyBlot | undefined;
19
+ prevRow(): TableRowBlot | null;
20
+ nextRow(): TableRowBlot | null;
21
+ table(): import("./TableBlot").TableBlot | undefined;
22
+ }
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.TableRowBlot = void 0;
17
+ var react_quill_1 = require("react-quill");
18
+ var constants_1 = require("../constants");
19
+ var utils_1 = require("../utils");
20
+ var BaseTableBlot_1 = require("./BaseTableBlot");
21
+ var TableBodyBlot_1 = require("./TableBodyBlot");
22
+ var TableCellBlot_1 = require("./TableCellBlot");
23
+ var Parchment = react_quill_1.Quill.import('parchment');
24
+ var TableRowBlot = /** @class */ (function (_super) {
25
+ __extends(TableRowBlot, _super);
26
+ function TableRowBlot() {
27
+ return _super !== null && _super.apply(this, arguments) || this;
28
+ }
29
+ TableRowBlot.create = function (value) {
30
+ var node = _super.createWithValue.call(this, constants_1.TAG_NAME.TR, value);
31
+ // split data-value into separate attributes for easier access
32
+ var values = value.split('|');
33
+ node.setAttribute(constants_1.ATTRIBUTE.TABLE, values[0]);
34
+ node.setAttribute(constants_1.ATTRIBUTE.ROW, values[1]);
35
+ node.setAttribute(constants_1.ATTRIBUTE.ID, values[1]);
36
+ return node;
37
+ };
38
+ TableRowBlot.createWithChildren = function (tableId, cols) {
39
+ var id = utils_1.newId(this.blotName);
40
+ var tableRow = Parchment.create(this.blotName, tableId + "|" + id);
41
+ for (var col = 0; col < cols; col++) {
42
+ var tableCell = TableCellBlot_1.TableCellBlot.createWithChildren(tableId, id);
43
+ tableRow.appendChild(tableCell);
44
+ }
45
+ return tableRow;
46
+ };
47
+ TableRowBlot.createFromReference = function (reference) {
48
+ var tableId = reference.tableId();
49
+ var tableRow = this.createWithChildren(tableId, 0);
50
+ reference.children.forEach(function (c) {
51
+ var newTableCell = TableCellBlot_1.TableCellBlot.createWithChildren(tableId, tableRow.id());
52
+ tableRow.appendChild(newTableCell);
53
+ });
54
+ return tableRow;
55
+ };
56
+ TableRowBlot.prototype.optimize = function (context) {
57
+ _super.prototype.optimize.call(this, context);
58
+ var didRemove = this.optimizeRemoveIfEmpty();
59
+ if (didRemove)
60
+ return;
61
+ this.optimizeMergeWithNext();
62
+ this.optimizeWrapInRequiredParent(this.tableId());
63
+ };
64
+ TableRowBlot.prototype.id = function () {
65
+ return this.domNode.getAttribute(constants_1.ATTRIBUTE.ID);
66
+ };
67
+ TableRowBlot.prototype.tableId = function () {
68
+ return this.domNode.getAttribute(constants_1.ATTRIBUTE.TABLE);
69
+ };
70
+ TableRowBlot.prototype.tableBody = function () {
71
+ // tr -> tbody
72
+ return this.parent instanceof TableBodyBlot_1.TableBodyBlot ? this.parent : undefined;
73
+ };
74
+ TableRowBlot.prototype.prevRow = function () {
75
+ return this.prev ? this.prev : null;
76
+ };
77
+ TableRowBlot.prototype.nextRow = function () {
78
+ return this.next ? this.next : null;
79
+ };
80
+ TableRowBlot.prototype.table = function () {
81
+ var _a;
82
+ return (_a = this.tableBody()) === null || _a === void 0 ? void 0 : _a.table();
83
+ };
84
+ TableRowBlot.blotName = constants_1.TABLE_BLOT_NAME.TR;
85
+ TableRowBlot.tagName = constants_1.TAG_NAME.TR;
86
+ TableRowBlot.scope = Parchment.Scope.BLOCK_BLOT;
87
+ TableRowBlot.requiredParentName = constants_1.TABLE_BLOT_NAME.TBODY;
88
+ TableRowBlot.allowedChildrenNames = [constants_1.TABLE_BLOT_NAME.TD];
89
+ return TableRowBlot;
90
+ }(BaseTableBlot_1.BaseTableBlot));
91
+ exports.TableRowBlot = TableRowBlot;
@@ -0,0 +1,34 @@
1
+ export declare enum TABLE_BLOT_NAME {
2
+ TABLE_CONTAINER = "table-container",
3
+ TABLE = "table",
4
+ TBODY = "tbody",
5
+ TR = "tr",
6
+ TD = "td"
7
+ }
8
+ export declare enum TAG_NAME {
9
+ DIV = "DIV",
10
+ TABLE = "TABLE",
11
+ TBODY = "TBODY",
12
+ TR = "TR",
13
+ TD = "TD",
14
+ P = "P",
15
+ BR = "BR"
16
+ }
17
+ export declare enum TABLE_ACTION {
18
+ NEW_TABLE = "newtable_",
19
+ INSERT_COL = "insert-col",
20
+ INSERT_ROW = "insert-row",
21
+ DELETE_COL = "delete-col",
22
+ DELETE_ROW = "delete-row"
23
+ }
24
+ export declare enum ATTRIBUTE {
25
+ ID = "id",
26
+ DATA_VALUE = "data-value",
27
+ TABLE = "data-table",
28
+ ROW = "data-row",
29
+ CELL = "data-cell"
30
+ }
31
+ export declare enum KEY {
32
+ BACKSPACE = 8,
33
+ DELETE = 46
34
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KEY = exports.ATTRIBUTE = exports.TABLE_ACTION = exports.TAG_NAME = exports.TABLE_BLOT_NAME = void 0;
4
+ var TABLE_BLOT_NAME;
5
+ (function (TABLE_BLOT_NAME) {
6
+ TABLE_BLOT_NAME["TABLE_CONTAINER"] = "table-container";
7
+ TABLE_BLOT_NAME["TABLE"] = "table";
8
+ TABLE_BLOT_NAME["TBODY"] = "tbody";
9
+ TABLE_BLOT_NAME["TR"] = "tr";
10
+ TABLE_BLOT_NAME["TD"] = "td";
11
+ })(TABLE_BLOT_NAME = exports.TABLE_BLOT_NAME || (exports.TABLE_BLOT_NAME = {}));
12
+ var TAG_NAME;
13
+ (function (TAG_NAME) {
14
+ TAG_NAME["DIV"] = "DIV";
15
+ TAG_NAME["TABLE"] = "TABLE";
16
+ TAG_NAME["TBODY"] = "TBODY";
17
+ TAG_NAME["TR"] = "TR";
18
+ TAG_NAME["TD"] = "TD";
19
+ TAG_NAME["P"] = "P";
20
+ TAG_NAME["BR"] = "BR";
21
+ })(TAG_NAME = exports.TAG_NAME || (exports.TAG_NAME = {}));
22
+ var TABLE_ACTION;
23
+ (function (TABLE_ACTION) {
24
+ TABLE_ACTION["NEW_TABLE"] = "newtable_";
25
+ TABLE_ACTION["INSERT_COL"] = "insert-col";
26
+ TABLE_ACTION["INSERT_ROW"] = "insert-row";
27
+ TABLE_ACTION["DELETE_COL"] = "delete-col";
28
+ TABLE_ACTION["DELETE_ROW"] = "delete-row";
29
+ })(TABLE_ACTION = exports.TABLE_ACTION || (exports.TABLE_ACTION = {}));
30
+ var ATTRIBUTE;
31
+ (function (ATTRIBUTE) {
32
+ ATTRIBUTE["ID"] = "id";
33
+ ATTRIBUTE["DATA_VALUE"] = "data-value";
34
+ ATTRIBUTE["TABLE"] = "data-table";
35
+ ATTRIBUTE["ROW"] = "data-row";
36
+ ATTRIBUTE["CELL"] = "data-cell";
37
+ })(ATTRIBUTE = exports.ATTRIBUTE || (exports.ATTRIBUTE = {}));
38
+ var KEY;
39
+ (function (KEY) {
40
+ KEY[KEY["BACKSPACE"] = 8] = "BACKSPACE";
41
+ KEY[KEY["DELETE"] = 46] = "DELETE";
42
+ })(KEY = exports.KEY || (exports.KEY = {}));