studiokit-scaffolding-js 4.5.1 → 4.5.2-next.3.1

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 (50) hide show
  1. package/lib/components/HOC/ActivityRequiredComponent.d.ts +19 -22
  2. package/lib/components/HOC/ActivityRequiredComponent.js +29 -13
  3. package/lib/components/HOC/CollectionComponent.js +3 -3
  4. package/lib/components/HOC/CollectionItemComponent.js +2 -2
  5. package/lib/components/HOC/GroupActivityRequiredComponent.d.ts +9 -6
  6. package/lib/components/HOC/GroupActivityRequiredComponent.js +12 -8
  7. package/lib/components/Quill/Formats/Image.d.ts +46 -0
  8. package/lib/components/Quill/Formats/Image.js +86 -0
  9. package/lib/components/Quill/Formats/List.d.ts +15 -0
  10. package/lib/components/Quill/Formats/List.js +79 -0
  11. package/lib/components/Quill/Formats/Video.d.ts +11 -0
  12. package/lib/components/Quill/Formats/Video.js +50 -0
  13. package/lib/components/{Blots → Quill/Specs}/CustomImageSpec.d.ts +2 -1
  14. package/lib/components/{Blots → Quill/Specs}/CustomImageSpec.js +10 -1
  15. package/lib/components/{Blots → Quill/Specs}/CustomVideoSpec.d.ts +0 -0
  16. package/lib/components/{Blots → Quill/Specs}/CustomVideoSpec.js +0 -0
  17. package/lib/components/Quill/TableModule/Blots/BaseTableBlot.d.ts +29 -0
  18. package/lib/components/Quill/TableModule/Blots/BaseTableBlot.js +117 -0
  19. package/lib/components/Quill/TableModule/Blots/TableBlot.d.ts +19 -0
  20. package/lib/components/Quill/TableModule/Blots/TableBlot.js +70 -0
  21. package/lib/components/Quill/TableModule/Blots/TableBodyBlot.d.ts +19 -0
  22. package/lib/components/Quill/TableModule/Blots/TableBodyBlot.js +71 -0
  23. package/lib/components/Quill/TableModule/Blots/TableCellBlot.d.ts +33 -0
  24. package/lib/components/Quill/TableModule/Blots/TableCellBlot.js +234 -0
  25. package/lib/components/Quill/TableModule/Blots/TableContainer.d.ts +18 -0
  26. package/lib/components/Quill/TableModule/Blots/TableContainer.js +107 -0
  27. package/lib/components/Quill/TableModule/Blots/TableRowBlot.d.ts +23 -0
  28. package/lib/components/Quill/TableModule/Blots/TableRowBlot.js +91 -0
  29. package/lib/components/Quill/TableModule/constants.d.ts +34 -0
  30. package/lib/components/Quill/TableModule/constants.js +42 -0
  31. package/lib/components/Quill/TableModule/index.css +171 -0
  32. package/lib/components/Quill/TableModule/index.d.ts +23 -0
  33. package/lib/components/Quill/TableModule/index.js +312 -0
  34. package/lib/components/Quill/TableModule/utils.d.ts +9 -0
  35. package/lib/components/Quill/TableModule/utils.js +54 -0
  36. package/lib/components/Quill/accessibilityFix.d.ts +19 -0
  37. package/lib/components/Quill/accessibilityFix.js +267 -0
  38. package/lib/components/Quill/index.d.ts +1 -0
  39. package/lib/components/Quill/index.js +26 -0
  40. package/lib/components/UserRoles/index.d.ts +7 -3
  41. package/lib/components/UserRoles/index.js +11 -11
  42. package/lib/hooks/useCollection.js +3 -3
  43. package/lib/hooks/useCollectionConfiguration.d.ts +1 -0
  44. package/lib/hooks/useCollectionConfiguration.js +2 -0
  45. package/lib/hooks/useCollectionItem.js +3 -3
  46. package/lib/utils/collection.d.ts +2 -2
  47. package/lib/utils/collection.js +7 -4
  48. package/lib/utils/dom.d.ts +25 -0
  49. package/lib/utils/dom.js +201 -0
  50. package/package.json +4 -1
@@ -4,6 +4,7 @@ import { BaseReduxState, OptionalRecord } from '../../types';
4
4
  import { ActivityOptions } from '../../utils/baseActivity';
5
5
  export interface ActivityRequiredStateProps {
6
6
  hasAccess: boolean;
7
+ redirectPath: string;
7
8
  }
8
9
  export declare const configureActivityRequiredComponent: <TOwnProps extends {}>(WrappedComponent: React.ComponentType<TOwnProps>) => {
9
10
  new (props: (TOwnProps & ActivityRequiredStateProps) | Readonly<TOwnProps & ActivityRequiredStateProps>): {
@@ -60,15 +61,14 @@ export declare const configureActivityRequiredComponent: <TOwnProps extends {}>(
60
61
  };
61
62
  /**
62
63
  * Return `mapStateToProps` function. Add a `hasAccess` boolean property to the component's props
63
- * checking whether the user has the passed `requiredActivity`
64
+ * checking whether the user has the passed `requiredActivity`.
64
65
  *
65
- * @param {function} accessPredicate A predicate accepting a required activity and an optional entity and/or
66
- * userInfo object
67
- * @param {string} requiredActivity The required activity which is passed to the predicate for evaluation
68
- * @param {string} modelsProperty The property used to locate the entity or entities needed for entity-level
69
- * activity grants
66
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
67
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
68
+ * @param modelsProperty (Optional) The property used to locate the entity or entities needed for entity-level activity grants
69
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
70
70
  */
71
- export declare const configureMapStateToProps: <TOwnProps extends {}>(accessPredicate: (requiredActivity: string, options: ActivityOptions) => boolean, requiredActivity: string, modelsProperty?: string | undefined) => (state: BaseReduxState, ownProps?: TOwnProps | undefined) => ActivityRequiredStateProps;
71
+ export declare const configureMapStateToProps: <TOwnProps extends {}>(accessPredicate: (requiredActivity: string, options: ActivityOptions) => boolean, requiredActivity: string, modelsProperty?: string | undefined, redirectPath?: string | ((options: ActivityOptions) => string | undefined) | undefined) => (state: BaseReduxState, ownProps?: TOwnProps | undefined) => ActivityRequiredStateProps;
72
72
  /**
73
73
  * This HOC ensures that the wrapped component is only rendered if the predicate provided is satisfied.
74
74
  *
@@ -78,15 +78,14 @@ export declare const configureMapStateToProps: <TOwnProps extends {}>(accessPred
78
78
  * If a lambda is passed as the predicate, it is passed (but may or may not opt to utilize) the `requiredActivity`
79
79
  * parameter. It can be ignored if not needed by the lambda.
80
80
  *
81
- * @param {Component} WrappedComponent The component which requires activity/activities in order to render
82
- * @param {function} accessPredicate A predicate accepting a required activity and an optional entity and/or
83
- * userInfo object
84
- * @param {string} requiredActivity The required activity which is passed to the predicate for evaluation
85
- *
81
+ * @param WrappedComponent The component which requires activity/activities in order to render
82
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
83
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
84
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
86
85
  */
87
- export default function activityRequiredComponent<TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps>, accessPredicate: (requiredActivity: string, options: any) => boolean, requiredActivity: string): ComponentClass<TOwnProps>;
86
+ export default function activityRequiredComponent<TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps>, accessPredicate: (requiredActivity: string, options: ActivityOptions) => boolean, requiredActivity: string, redirectPath?: string | ((options: ActivityOptions) => string | undefined) | undefined): ComponentClass<TOwnProps>;
88
87
  /**
89
- * This HOC ensures that the wrapped component is rendered iff the predicate provided is satisfied.
88
+ * This HOC ensures that the wrapped component is rendered if the predicate provided is satisfied.
90
89
  *
91
90
  * Typically this component is used by passing one of the functions in utils/activities as the
92
91
  * `accessPredicate` and a constant from "constants/activities" as the `requiredActivity`.
@@ -94,12 +93,10 @@ export default function activityRequiredComponent<TOwnProps extends {}>(WrappedC
94
93
  * If a lambda is passed as the predicate, it is passed (but may or may not opt to utilize) the `requiredActivity`
95
94
  * and `modelsProperty` parameters. They can be ignored if not needed by the lambda.
96
95
  *
97
- * @param {Component} WrappedComponent The component which requires activity/activities in order to render
98
- * @param {function} accessPredicate A predicate accepting a required activity and an optional entity and/or
99
- * userInfo object
100
- * @param {string} requiredActivity The required activity which is passed to the predicate for evaluation
101
- * @param {string} modelsProperty The property used to locate the entity or entities needed for entity-level
102
- * activity grants
103
- *
96
+ * @param WrappedComponent The component which requires activity/activities in order to render
97
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
98
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
99
+ * @param modelsProperty The property used to locate the entity or entities needed for entity-level activity grants
100
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
104
101
  */
105
- export default function activityRequiredComponent<TOwnProps extends {}, TPropName extends string>(WrappedComponent: ComponentType<TOwnProps>, accessPredicate: (requiredActivity: string, options: any) => boolean, requiredActivity: string, modelsProperty: TPropName): ComponentClass<TOwnProps & OptionalRecord<TPropName, Model>>;
102
+ export default function activityRequiredComponent<TOwnProps extends {}, TPropName extends string>(WrappedComponent: ComponentType<TOwnProps>, accessPredicate: (requiredActivity: string, options: ActivityOptions) => boolean, requiredActivity: string, modelsProperty: TPropName, redirectPath?: string | ((options: ActivityOptions) => string | undefined) | undefined): ComponentClass<TOwnProps & OptionalRecord<TPropName, Model>>;
@@ -66,9 +66,9 @@ var configureActivityRequiredComponent = function (WrappedComponent) {
66
66
  return _super !== null && _super.apply(this, arguments) || this;
67
67
  }
68
68
  ActivityRequiredComponent.prototype.render = function () {
69
- var _a = this.props, hasAccess = _a.hasAccess, rest = __rest(_a, ["hasAccess"]);
70
- if (!this.props.hasAccess) {
71
- return react_1.default.createElement(react_router_dom_1.Redirect, { to: '/' });
69
+ var _a = this.props, hasAccess = _a.hasAccess, redirectPath = _a.redirectPath, rest = __rest(_a, ["hasAccess", "redirectPath"]);
70
+ if (!hasAccess) {
71
+ return react_1.default.createElement(react_router_dom_1.Redirect, { to: redirectPath });
72
72
  }
73
73
  return react_1.default.createElement(WrappedComponent, __assign({}, rest));
74
74
  };
@@ -78,23 +78,39 @@ var configureActivityRequiredComponent = function (WrappedComponent) {
78
78
  exports.configureActivityRequiredComponent = configureActivityRequiredComponent;
79
79
  /**
80
80
  * Return `mapStateToProps` function. Add a `hasAccess` boolean property to the component's props
81
- * checking whether the user has the passed `requiredActivity`
81
+ * checking whether the user has the passed `requiredActivity`.
82
82
  *
83
- * @param {function} accessPredicate A predicate accepting a required activity and an optional entity and/or
84
- * userInfo object
85
- * @param {string} requiredActivity The required activity which is passed to the predicate for evaluation
86
- * @param {string} modelsProperty The property used to locate the entity or entities needed for entity-level
87
- * activity grants
83
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
84
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
85
+ * @param modelsProperty (Optional) The property used to locate the entity or entities needed for entity-level activity grants
86
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
88
87
  */
89
- var configureMapStateToProps = function (accessPredicate, requiredActivity, modelsProperty) { return function (state, ownProps) {
88
+ var configureMapStateToProps = function (accessPredicate, requiredActivity, modelsProperty, redirectPath) { return function (state, ownProps) {
89
+ var options = baseActivity_1.defaultOptions(state, ownProps, modelsProperty);
90
90
  return {
91
- hasAccess: accessPredicate(requiredActivity, baseActivity_1.defaultOptions(state, ownProps, modelsProperty))
91
+ hasAccess: accessPredicate(requiredActivity, options),
92
+ redirectPath: (typeof redirectPath === 'function' ? redirectPath(options) : redirectPath) || '/'
92
93
  };
93
94
  }; };
94
95
  exports.configureMapStateToProps = configureMapStateToProps;
95
- function activityRequiredComponent(WrappedComponent, accessPredicate, requiredActivity, modelsProperty) {
96
+ /**
97
+ * This HOC ensures that the wrapped component is rendered if the predicate provided is satisfied.
98
+ *
99
+ * Typically this component is used by passing one of the functions in utils/activities as the
100
+ * `accessPredicate` and a constant from "constants/activities" as the `requiredActivity`.
101
+ *
102
+ * If a lambda is passed as the predicate, it is passed (but may or may not opt to utilize) the `requiredActivity`
103
+ * and `modelsProperty` parameters. They can be ignored if not needed by the lambda.
104
+ *
105
+ * @param WrappedComponent The component which requires activity/activities in order to render
106
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
107
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
108
+ * @param modelsProperty The property used to locate the entity or entities needed for entity-level activity grants
109
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
110
+ */
111
+ function activityRequiredComponent(WrappedComponent, accessPredicate, requiredActivity, modelsProperty, redirectPath) {
96
112
  var ActivityRequiredComponent = exports.configureActivityRequiredComponent(WrappedComponent);
97
- var mapStateToProps = exports.configureMapStateToProps(accessPredicate, requiredActivity, modelsProperty);
113
+ var mapStateToProps = exports.configureMapStateToProps(accessPredicate, requiredActivity, modelsProperty, redirectPath);
98
114
  // @ts-ignore: could not match inferred type from the `connect` HOC
99
115
  return react_redux_1.connect(mapStateToProps)(ActivityRequiredComponent);
100
116
  }
@@ -123,11 +123,11 @@ function configureCollectionComponent(WrappedComponent, LoaderComponent) {
123
123
  collection_1.initializeCollection(model, this.load, this.getCollectionMethodConfig());
124
124
  };
125
125
  CollectionComponent.prototype.componentDidUpdate = function (prevProps) {
126
- var prevModel = prevProps.model, prevPathParams = prevProps.pathParams, prevQueryParams = prevProps.queryParams;
127
- var _a = this.props, model = _a.model, pathParams = _a.pathParams, queryParams = _a.queryParams;
126
+ var prevModel = prevProps.model, prevModelName = prevProps.modelName, prevPathParams = prevProps.pathParams, prevQueryParams = prevProps.queryParams;
127
+ var _a = this.props, model = _a.model, modelName = _a.modelName, pathParams = _a.pathParams, queryParams = _a.queryParams;
128
128
  var fetchingId = this.state.fetchingId;
129
129
  model_1.handleModelFetchFinish(model, prevModel, fetchingId, this.changeModelStatus);
130
- collection_1.handleCollectionParamsChange(pathParams, prevPathParams, queryParams, prevQueryParams, this.load);
130
+ collection_1.handleCollectionParamsChange(modelName, prevModelName, pathParams, prevPathParams, queryParams, prevQueryParams, this.load);
131
131
  };
132
132
  CollectionComponent.prototype.componentWillUnmount = function () {
133
133
  var model = this.props.model;
@@ -125,10 +125,10 @@ function configureCollectionItemComponent(WrappedComponent, LoaderComponent) {
125
125
  collection_1.initializeCollectionItem(model, this.load, this.getCollectionMethodConfig());
126
126
  };
127
127
  CollectionItemComponent.prototype.componentDidUpdate = function (prevProps) {
128
- var prevModel = prevProps.model, prevPathParams = prevProps.pathParams, prevQueryParams = prevProps.queryParams;
128
+ var prevModel = prevProps.model, prevModelName = prevProps.modelName, prevPathParams = prevProps.pathParams, prevQueryParams = prevProps.queryParams;
129
129
  var _a = this.props, modelName = _a.modelName, model = _a.model, pathParams = _a.pathParams, queryParams = _a.queryParams;
130
130
  model_1.handleModelFetchFinish(model, prevModel, undefined, this.setModelStatus);
131
- collection_1.handleCollectionItemParamsChange(modelName, pathParams, prevPathParams, queryParams, prevQueryParams, this.load);
131
+ collection_1.handleCollectionItemParamsChange(modelName, prevModelName, pathParams, prevPathParams, queryParams, prevQueryParams, this.load);
132
132
  };
133
133
  CollectionItemComponent.prototype.render = function () {
134
134
  var _a = this.props, history = _a.history, match = _a.match, location = _a.location, staticContext = _a.staticContext, otherProps = __rest(_a, ["history", "match", "location", "staticContext"]);
@@ -15,15 +15,18 @@ export interface GroupRelatedEntity extends Model {
15
15
  * checking whether the user has the passed `requiredActivity` for the group referenced by
16
16
  * `ownProps.model.groupId`, if any.
17
17
  *
18
- * @param {function} accessPredicate A predicate accepting a required activity and an optional entity and/or
19
- * userInfo object
20
- * @param {string} requiredActivity The required activity which is passed to the predicate for evaluation
18
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
19
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
20
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
21
21
  */
22
- export declare const configureMapStateToProps: <TOwnProps extends CollectionItemComponentWrappedProps<GroupRelatedEntity>>(accessPredicate: (requiredActivity: string, options: ActivityOptions) => boolean, requiredActivity: string) => (state: BaseReduxState, ownProps?: TOwnProps | undefined) => ActivityRequiredStateProps;
22
+ export declare const configureMapStateToProps: <TOwnProps extends CollectionItemComponentWrappedProps<GroupRelatedEntity>>(accessPredicate: (requiredActivity: string, options: ActivityOptions) => boolean, requiredActivity: string, redirectPath?: string | ((options: ActivityOptions) => string | undefined) | undefined) => (state: BaseReduxState, ownProps?: TOwnProps | undefined) => ActivityRequiredStateProps;
23
23
  /**
24
24
  * This HOC ensures that the wrapped component is only rendered if the group referenced by
25
25
  * `props.model.groupId`, if any, satisfies the `accessPredicate` for the `requiredActivity`.
26
26
  *
27
- * @see ActivityRequiredComponent
27
+ * @param WrappedComponent The component which requires activity/activities in order to render
28
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
29
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
30
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
28
31
  */
29
- export default function groupActivityRequiredComponent<TOwnProps extends CollectionItemComponentWrappedProps<GroupRelatedEntity>>(WrappedComponent: ComponentType<TOwnProps>, accessPredicate: (requiredActivity: string, options: any) => boolean, requiredActivity: string): ComponentClass<TOwnProps>;
32
+ export default function groupActivityRequiredComponent<TOwnProps extends CollectionItemComponentWrappedProps<GroupRelatedEntity>>(WrappedComponent: ComponentType<TOwnProps>, accessPredicate: (requiredActivity: string, options: any) => boolean, requiredActivity: string, redirectPath?: string | undefined | ((options: ActivityOptions) => string | undefined)): ComponentClass<TOwnProps>;
@@ -20,17 +20,18 @@ var ActivityRequiredComponent_1 = require("./ActivityRequiredComponent");
20
20
  * checking whether the user has the passed `requiredActivity` for the group referenced by
21
21
  * `ownProps.model.groupId`, if any.
22
22
  *
23
- * @param {function} accessPredicate A predicate accepting a required activity and an optional entity and/or
24
- * userInfo object
25
- * @param {string} requiredActivity The required activity which is passed to the predicate for evaluation
23
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
24
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
25
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
26
26
  */
27
- var configureMapStateToProps = function (accessPredicate, requiredActivity) { return function (state, ownProps) {
27
+ var configureMapStateToProps = function (accessPredicate, requiredActivity, redirectPath) { return function (state, ownProps) {
28
28
  var entity = ownProps && ownProps.model && state.models && state.models.groups
29
29
  ? state.models.groups[ownProps.model.groupId]
30
30
  : undefined;
31
31
  var options = __assign(__assign({}, baseActivity_1.defaultOptions(state, ownProps)), { entity: entity });
32
32
  return {
33
- hasAccess: accessPredicate(requiredActivity, options)
33
+ hasAccess: accessPredicate(requiredActivity, options),
34
+ redirectPath: (typeof redirectPath === 'function' ? redirectPath(options) : redirectPath) || '/'
34
35
  };
35
36
  }; };
36
37
  exports.configureMapStateToProps = configureMapStateToProps;
@@ -38,11 +39,14 @@ exports.configureMapStateToProps = configureMapStateToProps;
38
39
  * This HOC ensures that the wrapped component is only rendered if the group referenced by
39
40
  * `props.model.groupId`, if any, satisfies the `accessPredicate` for the `requiredActivity`.
40
41
  *
41
- * @see ActivityRequiredComponent
42
+ * @param WrappedComponent The component which requires activity/activities in order to render
43
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
44
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
45
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
42
46
  */
43
- function groupActivityRequiredComponent(WrappedComponent, accessPredicate, requiredActivity) {
47
+ function groupActivityRequiredComponent(WrappedComponent, accessPredicate, requiredActivity, redirectPath) {
44
48
  var ActivityRequiredComponent = ActivityRequiredComponent_1.configureActivityRequiredComponent(WrappedComponent);
45
- var mapStateToProps = exports.configureMapStateToProps(accessPredicate, requiredActivity);
49
+ var mapStateToProps = exports.configureMapStateToProps(accessPredicate, requiredActivity, redirectPath);
46
50
  // @ts-ignore: could not match inferred type from the `connect` HOC
47
51
  return react_redux_1.connect(mapStateToProps)(ActivityRequiredComponent);
48
52
  }
@@ -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
+ declare const Container: typeof import("parchment/dist/src/blot/abstract/container").default;
2
+ /**
3
+ * A base class for all Table module blots to inherit.
4
+ *
5
+ * Created with a `value` that is stored on the DOM Node as the `data-value` attribute.
6
+ * This is used for optimization (merging related blots).
7
+ */
8
+ export declare class BaseTableBlot extends Container {
9
+ static scope: import("parchment/dist/src/registry").Scope;
10
+ static requiredParent: string | null;
11
+ static allowedChildren: (typeof import("parchment/dist/src/blot/abstract/container").default | typeof import("parchment/dist/src/blot/embed").default | {
12
+ new (data?: string | undefined): Text;
13
+ prototype: Text;
14
+ })[];
15
+ static createWithValue(tagName: string, value: string): HTMLElement;
16
+ /**
17
+ * Check if the blot only contains `<p><br></p>`
18
+ */
19
+ static containsOnlyEmptyBlock(blot: BaseTableBlot): boolean | null;
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 {};