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,46 @@
1
+ declare const Parchment: {
2
+ Scope: typeof import("parchment/dist/src/registry").Scope;
3
+ create: typeof import("parchment/dist/src/registry").create;
4
+ find: typeof import("parchment/dist/src/registry").find;
5
+ query: typeof import("parchment/dist/src/registry").query;
6
+ register: typeof import("parchment/dist/src/registry").register;
7
+ Container: typeof import("parchment/dist/src/blot/abstract/container").default;
8
+ Format: typeof import("parchment/dist/src/blot/abstract/format").default;
9
+ Leaf: typeof import("parchment/dist/src/blot/abstract/leaf").default;
10
+ Embed: typeof import("parchment/dist/src/blot/embed").default;
11
+ Scroll: typeof import("parchment/dist/src/blot/scroll").default;
12
+ Block: typeof import("parchment/dist/src/blot/block").default;
13
+ Inline: typeof import("parchment/dist/src/blot/inline").default;
14
+ Text: typeof import("parchment/dist/src/blot/text").default;
15
+ Attributor: {
16
+ Attribute: typeof import("parchment/dist/src/attributor/attributor").default;
17
+ Class: typeof import("parchment/dist/src/attributor/class").default;
18
+ Style: typeof import("parchment/dist/src/attributor/style").default;
19
+ Store: typeof import("parchment/dist/src/attributor/store").default;
20
+ };
21
+ };
22
+ export interface ImageValue {
23
+ src: string;
24
+ alt: string;
25
+ width: string;
26
+ height: string;
27
+ }
28
+ declare type ImageBlotOnClick = (img: ImageValue, blot: Image) => void;
29
+ export declare function setImageClickHandlersEnabled(value: boolean): void;
30
+ export declare function setOnImageBlotClick(guid: string, value: ImageBlotOnClick | undefined): void;
31
+ /**
32
+ * Defines a new implementation of `Image`, to allow setting alt text, width, and height.
33
+ *
34
+ * https://github.com/zenoamaro/react-quill/issues/169
35
+ */
36
+ export declare class Image extends Parchment.Embed {
37
+ static blotName: string;
38
+ static tagName: string;
39
+ /** Creates the DOM Node from a value */
40
+ static create(value: ImageValue): HTMLImageElement;
41
+ /** Returns the value for a DOM Node */
42
+ static value(node: HTMLImageElement): ImageValue;
43
+ /** Create the Blot using the DOM Node from static `create` */
44
+ constructor(domNode: HTMLImageElement);
45
+ }
46
+ export {};
@@ -0,0 +1,86 @@
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.Image = exports.setOnImageBlotClick = exports.setImageClickHandlersEnabled = void 0;
17
+ var react_quill_1 = require("react-quill");
18
+ var dom_1 = require("../../../utils/dom");
19
+ var logger_1 = require("../../../utils/logger");
20
+ var Parchment = react_quill_1.Quill.import('parchment');
21
+ var clickHandlersEnabled = true;
22
+ var onClickHandlers = {};
23
+ function setImageClickHandlersEnabled(value) {
24
+ clickHandlersEnabled = value;
25
+ }
26
+ exports.setImageClickHandlersEnabled = setImageClickHandlersEnabled;
27
+ function setOnImageBlotClick(guid, value) {
28
+ if (value) {
29
+ onClickHandlers[guid] = value;
30
+ }
31
+ else {
32
+ delete onClickHandlers[guid];
33
+ }
34
+ }
35
+ exports.setOnImageBlotClick = setOnImageBlotClick;
36
+ /**
37
+ * Defines a new implementation of `Image`, to allow setting alt text, width, and height.
38
+ *
39
+ * https://github.com/zenoamaro/react-quill/issues/169
40
+ */
41
+ var Image = /** @class */ (function (_super) {
42
+ __extends(Image, _super);
43
+ /** Create the Blot using the DOM Node from static `create` */
44
+ function Image(domNode) {
45
+ var _this = _super.call(this, domNode) || this;
46
+ // right click listener to open modal to edit alt text
47
+ domNode.addEventListener('contextmenu', function (ev) {
48
+ logger_1.getLogger().debug('image right clicked', { this: _this, ev: ev });
49
+ var quillEdit = dom_1.getFirstParentElementWithClassName(domNode, 'QuillEdit');
50
+ if (!quillEdit) {
51
+ return;
52
+ }
53
+ var onClick = onClickHandlers[quillEdit.id];
54
+ if (onClick && clickHandlersEnabled) {
55
+ ev.preventDefault();
56
+ onClick(Image.value(domNode), _this);
57
+ }
58
+ });
59
+ return _this;
60
+ }
61
+ /** Creates the DOM Node from a value */
62
+ Image.create = function (value) {
63
+ var _a, _b, _c;
64
+ var node = _super.create.call(this, this.tagName);
65
+ // Adding a default value for images already saved in the db
66
+ node.setAttribute('alt', (_a = value.alt) !== null && _a !== void 0 ? _a : 'Statement Image');
67
+ node.setAttribute('src', value.src);
68
+ // Setting up the height and width to be reactive when an image is getting resize
69
+ node.setAttribute('height', (_b = value.height) !== null && _b !== void 0 ? _b : 'auto');
70
+ node.setAttribute('width', (_c = value.width) !== null && _c !== void 0 ? _c : 'auto');
71
+ return node;
72
+ };
73
+ /** Returns the value for a DOM Node */
74
+ Image.value = function (node) {
75
+ return {
76
+ width: node.getAttribute('width'),
77
+ height: node.getAttribute('height'),
78
+ alt: node.getAttribute('alt'),
79
+ src: node.getAttribute('src')
80
+ };
81
+ };
82
+ Image.blotName = 'image';
83
+ Image.tagName = 'IMG';
84
+ return Image;
85
+ }(Parchment.Embed));
86
+ exports.Image = Image;
@@ -0,0 +1,15 @@
1
+ declare const QuillList: typeof import("parchment/dist/src/blot/abstract/container").default;
2
+ declare const QuillListItem: typeof import("parchment/dist/src/blot/block").default;
3
+ export declare class ListItem extends QuillListItem {
4
+ format(name: string, value: any): void;
5
+ }
6
+ /**
7
+ * Extend `List` to add new `alpha` type.
8
+ */
9
+ export declare class List extends QuillList {
10
+ static allowedChildren: (typeof ListItem)[];
11
+ static create(value: string): HTMLElement;
12
+ static formats(domNode: HTMLElement): any;
13
+ optimize(context: any): void;
14
+ }
15
+ export {};
@@ -0,0 +1,79 @@
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.List = exports.ListItem = void 0;
17
+ var react_quill_1 = require("react-quill");
18
+ var logger_1 = require("../../../utils/logger");
19
+ var constants_1 = require("../TableModule/constants");
20
+ var QuillList = react_quill_1.Quill.import('formats/list');
21
+ var QuillListItem = react_quill_1.Quill.import('formats/list/item');
22
+ var ALPHA = 'alpha';
23
+ var ListItem = /** @class */ (function (_super) {
24
+ __extends(ListItem, _super);
25
+ function ListItem() {
26
+ return _super !== null && _super.apply(this, arguments) || this;
27
+ }
28
+ ListItem.prototype.format = function (name, value) {
29
+ if (name === constants_1.TABLE_BLOT_NAME.TD && this.parent) {
30
+ logger_1.getLogger().debug('ListItem format: wrap parent in TD');
31
+ this.parent.wrap(name, value);
32
+ }
33
+ else {
34
+ _super.prototype.format.call(this, name, value);
35
+ }
36
+ };
37
+ return ListItem;
38
+ }(QuillListItem));
39
+ exports.ListItem = ListItem;
40
+ /**
41
+ * Extend `List` to add new `alpha` type.
42
+ */
43
+ var List = /** @class */ (function (_super) {
44
+ __extends(List, _super);
45
+ function List() {
46
+ return _super !== null && _super.apply(this, arguments) || this;
47
+ }
48
+ List.create = function (value) {
49
+ var node = _super.create.call(this, value === ALPHA ? 'ordered' : value);
50
+ if (value === ALPHA) {
51
+ node.setAttribute('data-value', ALPHA);
52
+ }
53
+ return node;
54
+ };
55
+ List.formats = function (domNode) {
56
+ if (domNode.tagName === 'OL' &&
57
+ domNode.hasAttribute('data-value') &&
58
+ domNode.getAttribute('data-value') === ALPHA) {
59
+ return ALPHA;
60
+ }
61
+ // @ts-ignore: parent List class _does_ implement `formats`
62
+ return _super.formats.call(this, domNode);
63
+ };
64
+ List.prototype.optimize = function (context) {
65
+ var next = this.next;
66
+ if (next != null &&
67
+ next.prev === this &&
68
+ next instanceof QuillList &&
69
+ next.domNode.tagName === this.domNode.tagName &&
70
+ next.domNode.getAttribute('data-checked') === this.domNode.getAttribute('data-checked') &&
71
+ // add data-value comparison, avoid combining "ordered" and "alpha" lists
72
+ next.domNode.getAttribute('data-value') === this.domNode.getAttribute('data-value')) {
73
+ _super.prototype.optimize.call(this, context);
74
+ }
75
+ };
76
+ List.allowedChildren = [ListItem];
77
+ return List;
78
+ }(QuillList));
79
+ exports.List = List;
@@ -0,0 +1,11 @@
1
+ declare const QuillVideo: typeof import("parchment/dist/src/blot/embed").default;
2
+ /**
3
+ * Extend `Video` to allow use inside of a `TableCellBlot`
4
+ */
5
+ export declare class Video extends QuillVideo {
6
+ formats(): {
7
+ [index: string]: any;
8
+ };
9
+ formatAt(index: number, length: number, name: string, value: any): void;
10
+ }
11
+ export {};
@@ -0,0 +1,50 @@
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.Video = void 0;
17
+ var react_quill_1 = require("react-quill");
18
+ var TableCellBlot_1 = require("../TableModule/Blots/TableCellBlot");
19
+ var constants_1 = require("../TableModule/constants");
20
+ var QuillVideo = react_quill_1.Quill.import('formats/video');
21
+ /**
22
+ * Extend `Video` to allow use inside of a `TableCellBlot`
23
+ */
24
+ var Video = /** @class */ (function (_super) {
25
+ __extends(Video, _super);
26
+ function Video() {
27
+ return _super !== null && _super.apply(this, arguments) || this;
28
+ }
29
+ Video.prototype.formats = function () {
30
+ var formats = _super.prototype.formats.call(this);
31
+ // allow video that is wrapped in a table cell to return this "format"
32
+ // when the delta op for this blot is created
33
+ if (this.parent instanceof TableCellBlot_1.TableCellBlot) {
34
+ formats[constants_1.TABLE_BLOT_NAME.TD] = this.parent.dataValue();
35
+ }
36
+ return formats;
37
+ };
38
+ Video.prototype.formatAt = function (index, length, name, value) {
39
+ // `BlockEmbed` ignores all formatting sent to `formatAt`
40
+ // allow the video iframe to be wrapped in a table cell, e.g. "formatted as a table cell"
41
+ if (name === constants_1.TABLE_BLOT_NAME.TD) {
42
+ this.wrap(name, value);
43
+ }
44
+ else {
45
+ _super.prototype.formatAt.call(this, index, length, name, value);
46
+ }
47
+ };
48
+ return Video;
49
+ }(QuillVideo));
50
+ exports.Video = Video;
@@ -9,6 +9,7 @@ import { DeleteAction, ImageSpec, ResizeAction } from 'quill-blot-formatter';
9
9
  declare class CustomImageSpec extends ImageSpec {
10
10
  init(): void;
11
11
  getActions(): (typeof ResizeAction | typeof DeleteAction)[];
12
- reposition: (e: any) => void;
12
+ onRightClick: (e: Event) => void;
13
+ reposition: (_e: Event) => void;
13
14
  }
14
15
  export default CustomImageSpec;
@@ -25,7 +25,13 @@ var CustomImageSpec = /** @class */ (function (_super) {
25
25
  __extends(CustomImageSpec, _super);
26
26
  function CustomImageSpec() {
27
27
  var _this = _super !== null && _super.apply(this, arguments) || this;
28
- _this.reposition = function (e) {
28
+ _this.onRightClick = function (e) {
29
+ e.preventDefault();
30
+ if (_this.img) {
31
+ _this.img.dispatchEvent(new CustomEvent('contextmenu'));
32
+ }
33
+ };
34
+ _this.reposition = function (_e) {
29
35
  if (_this.img) {
30
36
  _this.formatter.repositionOverlay();
31
37
  }
@@ -34,8 +40,11 @@ var CustomImageSpec = /** @class */ (function (_super) {
34
40
  }
35
41
  CustomImageSpec.prototype.init = function () {
36
42
  _super.prototype.init.call(this);
43
+ // listen for scroll and resize, to reposition the overlay
37
44
  this.formatter.quill.root.addEventListener('scroll', this.reposition);
38
45
  window.addEventListener('resize', this.reposition);
46
+ // listen for right-click of the overlay, to pass through to the img
47
+ this.formatter.overlay.addEventListener('contextmenu', this.onRightClick);
39
48
  };
40
49
  CustomImageSpec.prototype.getActions = function () {
41
50
  return [quill_blot_formatter_1.ResizeAction, quill_blot_formatter_1.DeleteAction];
@@ -0,0 +1,29 @@
1
+ import { Blot } from 'parchment/dist/src/blot/abstract/blot';
2
+ declare const Container: typeof import("parchment/dist/src/blot/abstract/container").default;
3
+ /**
4
+ * A base class for all Table module blots to inherit.
5
+ *
6
+ * Created with a `value` that is stored on the DOM Node as the `data-value` attribute.
7
+ * This is used for optimization (merging related blots).
8
+ */
9
+ export declare class BaseTableBlot extends Container {
10
+ static scope: import("parchment/dist/src/registry").Scope;
11
+ static requiredParentName: string | null;
12
+ /** alternate to `allowedChildren`, to avoid circular class refs */
13
+ static allowedChildrenNames: string[];
14
+ static createWithValue(tagName: string, value: string): HTMLElement;
15
+ /**
16
+ * Check if the blot only contains `<p><br></p>`
17
+ */
18
+ static containsOnlyEmptyBlock(blot: BaseTableBlot): boolean | null;
19
+ insertBefore(childBlot: Blot, refBlot?: Blot): void;
20
+ optimize(_context: {
21
+ [key: string]: any;
22
+ }): void;
23
+ unwrap(): void;
24
+ optimizeRemoveIfEmpty(): boolean;
25
+ optimizeMergeWithNext(): boolean;
26
+ optimizeWrapInRequiredParent(value: string): boolean;
27
+ dataValue(): string;
28
+ }
29
+ export {};
@@ -0,0 +1,126 @@
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.BaseTableBlot = 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 Parchment = react_quill_1.Quill.import('parchment');
22
+ var Container = react_quill_1.Quill.import('blots/container');
23
+ /**
24
+ * A base class for all Table module blots to inherit.
25
+ *
26
+ * Created with a `value` that is stored on the DOM Node as the `data-value` attribute.
27
+ * This is used for optimization (merging related blots).
28
+ */
29
+ var BaseTableBlot = /** @class */ (function (_super) {
30
+ __extends(BaseTableBlot, _super);
31
+ function BaseTableBlot() {
32
+ return _super !== null && _super.apply(this, arguments) || this;
33
+ }
34
+ BaseTableBlot.createWithValue = function (tagName, value) {
35
+ var node = _super.create.call(this, tagName);
36
+ node.setAttribute(constants_1.ATTRIBUTE.DATA_VALUE, value);
37
+ logger_1.getLogger().debug(tagName + " created", { value: value, node: node });
38
+ return node;
39
+ };
40
+ /**
41
+ * Check if the blot only contains `<p><br></p>`
42
+ */
43
+ BaseTableBlot.containsOnlyEmptyBlock = function (blot) {
44
+ var _a;
45
+ return (blot.length() === 1 &&
46
+ blot.children.head &&
47
+ blot.children.head.domNode.tagName === constants_1.TAG_NAME.P &&
48
+ blot.children.head.length() === 1 &&
49
+ ((_a = blot.children.head.children.head) === null || _a === void 0 ? void 0 : _a.domNode).tagName === constants_1.TAG_NAME.BR);
50
+ };
51
+ BaseTableBlot.prototype.insertBefore = function (childBlot, refBlot) {
52
+ // override super.insertBefore to change `allowedChildren` to use blotName strings, instead of class constructors
53
+ if (this.statics.allowedChildrenNames != null &&
54
+ !this.statics.allowedChildrenNames.some(function (allowedBlotName) {
55
+ return childBlot.statics.blotName === allowedBlotName;
56
+ })) {
57
+ throw new Error("Cannot insert " + childBlot.statics.blotName + " into " + this.statics.blotName);
58
+ }
59
+ childBlot.insertInto(this, refBlot);
60
+ };
61
+ BaseTableBlot.prototype.optimize = function (_context) {
62
+ // @ts-ignore: copied from Parchment.ShadowBlot
63
+ if (this.domNode['__blot'] != null) {
64
+ // @ts-ignore: copied from Parchment.ShadowBlot
65
+ delete this.domNode['__blot'].mutations;
66
+ }
67
+ // do not inherit from Container, allow each child to determine optimization
68
+ };
69
+ BaseTableBlot.prototype.unwrap = function () {
70
+ _super.prototype.unwrap.call(this);
71
+ logger_1.getLogger().debug(this.statics.tagName + " unwrap");
72
+ };
73
+ BaseTableBlot.prototype.optimizeRemoveIfEmpty = function () {
74
+ if (this.children.length === 0) {
75
+ this.remove();
76
+ return true;
77
+ }
78
+ return false;
79
+ };
80
+ BaseTableBlot.prototype.optimizeMergeWithNext = function () {
81
+ var next = this.next;
82
+ if (next != null &&
83
+ next.prev === this &&
84
+ utils_1.isInstanceOfBlot(next, this.statics.blotName) &&
85
+ next.domNode.tagName === this.domNode.tagName &&
86
+ next.domNode.getAttribute(constants_1.ATTRIBUTE.DATA_VALUE) === this.dataValue()) {
87
+ logger_1.getLogger().debug(this.statics.tagName + " optimize: next is matching blot. merge next into this.", {
88
+ this: this,
89
+ parent: this.parent,
90
+ prev: this.prev,
91
+ next: this.next
92
+ });
93
+ next.moveChildren(this);
94
+ next.remove();
95
+ return true;
96
+ }
97
+ return false;
98
+ };
99
+ BaseTableBlot.prototype.optimizeWrapInRequiredParent = function (value) {
100
+ if (this.parent &&
101
+ this.statics.requiredParentName !== null &&
102
+ !utils_1.isInstanceOfBlot(this.parent, this.statics.requiredParentName)) {
103
+ logger_1.getLogger().debug(this.statics.tagName + " optimize: parent not " + this.statics.requiredParentName + ". wrap in new " + this.statics.requiredParentName + ".", {
104
+ this: this,
105
+ parent: this.parent,
106
+ prev: this.prev,
107
+ next: this.next
108
+ });
109
+ var newParent = Parchment.create(this.statics.requiredParentName, value);
110
+ this.parent.removeChild(this);
111
+ this.parent.insertBefore(newParent, this.next);
112
+ newParent.appendChild(this);
113
+ return true;
114
+ }
115
+ return false;
116
+ };
117
+ BaseTableBlot.prototype.dataValue = function () {
118
+ return this.domNode.getAttribute(constants_1.ATTRIBUTE.DATA_VALUE);
119
+ };
120
+ BaseTableBlot.scope = Parchment.Scope.BLOCK_BLOT;
121
+ BaseTableBlot.requiredParentName = null;
122
+ /** alternate to `allowedChildren`, to avoid circular class refs */
123
+ BaseTableBlot.allowedChildrenNames = [];
124
+ return BaseTableBlot;
125
+ }(Container));
126
+ exports.BaseTableBlot = BaseTableBlot;
@@ -0,0 +1,20 @@
1
+ import { TABLE_BLOT_NAME, TAG_NAME } from '../constants';
2
+ import { BaseTableBlot } from './BaseTableBlot';
3
+ import { TableBodyBlot } from './TableBodyBlot';
4
+ import { TableContainerBlot } from './TableContainer';
5
+ export declare class TableBlot extends BaseTableBlot {
6
+ static blotName: TABLE_BLOT_NAME;
7
+ static tagName: TAG_NAME;
8
+ static scope: import("parchment/dist/src/registry").Scope;
9
+ static requiredParentName: string | null;
10
+ static allowedChildrenNames: string[];
11
+ static create(value: string): HTMLTableElement;
12
+ static createWithChildren(id: string, rows: number, cols: number): TableBlot;
13
+ optimize(context: {
14
+ [key: string]: any;
15
+ }): void;
16
+ unwrap(): void;
17
+ id(): string;
18
+ tableContainer(): TableContainerBlot | undefined;
19
+ tableBody(): TableBodyBlot;
20
+ }
@@ -0,0 +1,69 @@
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.TableBlot = void 0;
17
+ var react_quill_1 = require("react-quill");
18
+ var constants_1 = require("../constants");
19
+ var BaseTableBlot_1 = require("./BaseTableBlot");
20
+ var TableBodyBlot_1 = require("./TableBodyBlot");
21
+ var TableContainer_1 = require("./TableContainer");
22
+ var Parchment = react_quill_1.Quill.import('parchment');
23
+ var TableBlot = /** @class */ (function (_super) {
24
+ __extends(TableBlot, _super);
25
+ function TableBlot() {
26
+ return _super !== null && _super.apply(this, arguments) || this;
27
+ }
28
+ TableBlot.create = function (value) {
29
+ var node = _super.createWithValue.call(this, constants_1.TAG_NAME.TABLE, value);
30
+ node.setAttribute(constants_1.ATTRIBUTE.ID, value);
31
+ return node;
32
+ };
33
+ TableBlot.createWithChildren = function (id, rows, cols) {
34
+ var table = Parchment.create(this.blotName, id);
35
+ var tableBody = TableBodyBlot_1.TableBodyBlot.createWithChildren(id, rows, cols);
36
+ table.appendChild(tableBody);
37
+ return table;
38
+ };
39
+ TableBlot.prototype.optimize = function (context) {
40
+ _super.prototype.optimize.call(this, context);
41
+ var didRemove = this.optimizeRemoveIfEmpty();
42
+ if (didRemove)
43
+ return;
44
+ this.optimizeMergeWithNext();
45
+ this.optimizeWrapInRequiredParent(this.id());
46
+ };
47
+ TableBlot.prototype.unwrap = function () {
48
+ // keep a reference to the body, since `super.unwrap()` will break the ref
49
+ var tbody = this.tableBody();
50
+ _super.prototype.unwrap.call(this);
51
+ tbody.unwrap();
52
+ };
53
+ TableBlot.prototype.id = function () {
54
+ return this.domNode.getAttribute(constants_1.ATTRIBUTE.ID);
55
+ };
56
+ TableBlot.prototype.tableContainer = function () {
57
+ return this.parent instanceof TableContainer_1.TableContainerBlot ? this.parent : undefined;
58
+ };
59
+ TableBlot.prototype.tableBody = function () {
60
+ return this.children.head;
61
+ };
62
+ TableBlot.blotName = constants_1.TABLE_BLOT_NAME.TABLE;
63
+ TableBlot.tagName = constants_1.TAG_NAME.TABLE;
64
+ TableBlot.scope = Parchment.Scope.BLOCK_BLOT;
65
+ TableBlot.requiredParentName = constants_1.TABLE_BLOT_NAME.TABLE_CONTAINER;
66
+ TableBlot.allowedChildrenNames = [constants_1.TABLE_BLOT_NAME.TBODY];
67
+ return TableBlot;
68
+ }(BaseTableBlot_1.BaseTableBlot));
69
+ exports.TableBlot = TableBlot;
@@ -0,0 +1,18 @@
1
+ import { TABLE_BLOT_NAME, TAG_NAME } from '../constants';
2
+ import { BaseTableBlot } from './BaseTableBlot';
3
+ import { TableBlot } from './TableBlot';
4
+ export declare class TableBodyBlot 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(id: string, rows: number, cols: number): TableBodyBlot;
12
+ optimize(context: {
13
+ [key: string]: any;
14
+ }): void;
15
+ unwrap(): void;
16
+ tableId(): string;
17
+ table(): TableBlot | undefined;
18
+ }