@elliemae/ds-wysiwygeditor 2.2.0 → 2.3.0-alpha.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.
- package/cjs/DSWYSIWYGEditor.js +83 -72
- package/cjs/DSWYSIWYGEditor.js.map +7 -0
- package/cjs/components/CustomImageUploader.js +92 -94
- package/cjs/components/CustomImageUploader.js.map +7 -0
- package/cjs/components/CustomToolbar.js +172 -193
- package/cjs/components/CustomToolbar.js.map +7 -0
- package/cjs/components/DSWYSIWYGEditorImpl.js +147 -185
- package/cjs/components/DSWYSIWYGEditorImpl.js.map +7 -0
- package/cjs/components/ImageLibraryModal.js +75 -55
- package/cjs/components/ImageLibraryModal.js.map +7 -0
- package/cjs/components/InsertFieldModal.js +109 -142
- package/cjs/components/InsertFieldModal.js.map +7 -0
- package/cjs/components/TippedButton.js +56 -54
- package/cjs/components/TippedButton.js.map +7 -0
- package/cjs/components/TippedSelect.js +50 -39
- package/cjs/components/TippedSelect.js.map +7 -0
- package/cjs/components/colors.js +41 -21
- package/cjs/components/colors.js.map +7 -0
- package/cjs/components/customFields.js +66 -47
- package/cjs/components/customFields.js.map +7 -0
- package/cjs/constants.js +112 -38
- package/cjs/constants.js.map +7 -0
- package/cjs/index.js +39 -21
- package/cjs/index.js.map +7 -0
- package/cjs/quillMatchers/clipboardLinkWithTagMatcher.js +37 -22
- package/cjs/quillMatchers/clipboardLinkWithTagMatcher.js.map +7 -0
- package/cjs/quillOverrides/IndentStyle.js +41 -19
- package/cjs/quillOverrides/IndentStyle.js.map +7 -0
- package/cjs/quillOverrides/LinkFormat.js +57 -39
- package/cjs/quillOverrides/LinkFormat.js.map +7 -0
- package/cjs/quillOverrides/PlainClipboard.js +41 -21
- package/cjs/quillOverrides/PlainClipboard.js.map +7 -0
- package/cjs/utils.js +41 -18
- package/cjs/utils.js.map +7 -0
- package/esm/DSWYSIWYGEditor.js +50 -58
- package/esm/DSWYSIWYGEditor.js.map +7 -0
- package/esm/components/CustomImageUploader.js +60 -81
- package/esm/components/CustomImageUploader.js.map +7 -0
- package/esm/components/CustomToolbar.js +145 -184
- package/esm/components/CustomToolbar.js.map +7 -0
- package/esm/components/DSWYSIWYGEditorImpl.js +113 -169
- package/esm/components/DSWYSIWYGEditorImpl.js.map +7 -0
- package/esm/components/ImageLibraryModal.js +46 -47
- package/esm/components/ImageLibraryModal.js.map +7 -0
- package/esm/components/InsertFieldModal.js +72 -124
- package/esm/components/InsertFieldModal.js.map +7 -0
- package/esm/components/TippedButton.js +27 -44
- package/esm/components/TippedButton.js.map +7 -0
- package/esm/components/TippedSelect.js +21 -31
- package/esm/components/TippedSelect.js.map +7 -0
- package/esm/components/colors.js +12 -17
- package/esm/components/colors.js.map +7 -0
- package/esm/components/customFields.js +38 -40
- package/esm/components/customFields.js.map +7 -0
- package/esm/constants.js +83 -30
- package/esm/constants.js.map +7 -0
- package/esm/index.js +10 -4
- package/esm/index.js.map +7 -0
- package/esm/quillMatchers/clipboardLinkWithTagMatcher.js +8 -18
- package/esm/quillMatchers/clipboardLinkWithTagMatcher.js.map +7 -0
- package/esm/quillOverrides/IndentStyle.js +12 -17
- package/esm/quillOverrides/IndentStyle.js.map +7 -0
- package/esm/quillOverrides/LinkFormat.js +28 -37
- package/esm/quillOverrides/LinkFormat.js.map +7 -0
- package/esm/quillOverrides/PlainClipboard.js +12 -19
- package/esm/quillOverrides/PlainClipboard.js.map +7 -0
- package/esm/utils.js +12 -14
- package/esm/utils.js.map +7 -0
- package/package.json +9 -9
|
@@ -1,68 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var LinkFormat_exports = {};
|
|
29
|
+
__export(LinkFormat_exports, {
|
|
30
|
+
default: () => LinkFormat_default
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_react_quill = require("react-quill");
|
|
34
|
+
const sanitizeProtocol = (value) => {
|
|
35
|
+
if (typeof value === "boolean")
|
|
36
|
+
return value;
|
|
8
37
|
let newVal = value;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
38
|
+
if (!value.startsWith("http") && !value.startsWith("ftp") && !value.startsWith("mailto:") && !value.startsWith("{{")) {
|
|
39
|
+
if (!value.startsWith("www")) {
|
|
40
|
+
newVal = `https://www.${value}`;
|
|
41
|
+
} else
|
|
42
|
+
newVal = `https://${value}`;
|
|
14
43
|
}
|
|
15
|
-
|
|
16
44
|
return newVal;
|
|
17
45
|
};
|
|
18
|
-
|
|
19
46
|
function getIsValidProtocol(url, protocols) {
|
|
20
|
-
const anchor = document.createElement(
|
|
47
|
+
const anchor = document.createElement("a");
|
|
21
48
|
anchor.href = url;
|
|
22
|
-
const protocol = anchor.href.slice(0, anchor.href.indexOf(
|
|
49
|
+
const protocol = anchor.href.slice(0, anchor.href.indexOf(":"));
|
|
23
50
|
return protocols.indexOf(protocol) > -1;
|
|
24
51
|
}
|
|
25
|
-
|
|
26
|
-
const Link = ReactQuill.Quill.import('formats/link');
|
|
27
|
-
|
|
52
|
+
const Link = import_react_quill.Quill.import("formats/link");
|
|
28
53
|
class LinkFormat extends Link {
|
|
29
54
|
constructor() {
|
|
30
55
|
super(...arguments);
|
|
31
|
-
this.blotName =
|
|
32
|
-
this.tagName =
|
|
33
|
-
this.SANITIZED_URL =
|
|
34
|
-
this.PROTOCOL_WHITELIST = [
|
|
56
|
+
this.blotName = "link";
|
|
57
|
+
this.tagName = "A";
|
|
58
|
+
this.SANITIZED_URL = "about:blank";
|
|
59
|
+
this.PROTOCOL_WHITELIST = ["http", "ftp", "https", "mailto", "tel"];
|
|
35
60
|
}
|
|
36
|
-
|
|
37
61
|
static create(value) {
|
|
38
62
|
const newVal = sanitizeProtocol(value);
|
|
39
63
|
const node = super.create(newVal);
|
|
40
|
-
node.setAttribute(
|
|
64
|
+
node.setAttribute("href", newVal);
|
|
41
65
|
return node;
|
|
42
66
|
}
|
|
43
|
-
|
|
44
67
|
static formats(domNode) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return domNode === null || domNode === void 0 ? void 0 : (_domNode$getAttribute = domNode.getAttribute) === null || _domNode$getAttribute === void 0 ? void 0 : _domNode$getAttribute.call(domNode, 'href');
|
|
68
|
+
return domNode?.getAttribute?.("href");
|
|
48
69
|
}
|
|
49
|
-
|
|
50
70
|
static sanitize(url) {
|
|
51
71
|
return getIsValidProtocol(url, this.PROTOCOL_WHITELIST) ? url : this.SANITIZED_URL;
|
|
52
72
|
}
|
|
53
|
-
|
|
54
73
|
format(name, value) {
|
|
55
|
-
const newVal = sanitizeProtocol(value);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.domNode.removeAttribute('href');
|
|
74
|
+
const newVal = sanitizeProtocol(value);
|
|
75
|
+
if (name === "link" && value === false) {
|
|
76
|
+
this.domNode.removeAttribute("href");
|
|
59
77
|
} else if (name !== this.statics.blotName || !newVal) {
|
|
60
78
|
super.format(name, newVal);
|
|
61
79
|
} else {
|
|
62
|
-
this.domNode.setAttribute(
|
|
80
|
+
this.domNode.setAttribute("href", this.constructor.sanitize(newVal));
|
|
63
81
|
}
|
|
64
82
|
}
|
|
65
|
-
|
|
66
83
|
}
|
|
67
|
-
|
|
68
|
-
module.exports =
|
|
84
|
+
var LinkFormat_default = LinkFormat;
|
|
85
|
+
module.exports = __toCommonJS(LinkFormat_exports);
|
|
86
|
+
//# sourceMappingURL=LinkFormat.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/quillOverrides/LinkFormat.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\nimport { Quill } from 'react-quill';\n\nconst sanitizeProtocol = (value) => {\n if (typeof value === 'boolean') return value;\n let newVal = value;\n if (\n !value.startsWith('http') &&\n !value.startsWith('ftp') &&\n !value.startsWith('mailto:') &&\n !value.startsWith('{{')\n ) {\n if (!value.startsWith('www')) {\n newVal = `https://www.${value}`;\n } else newVal = `https://${value}`;\n }\n return newVal;\n};\n\nfunction getIsValidProtocol(url, protocols) {\n const anchor = document.createElement('a');\n anchor.href = url;\n const protocol = anchor.href.slice(0, anchor.href.indexOf(':'));\n return protocols.indexOf(protocol) > -1;\n}\n\nconst Link = Quill.import('formats/link');\n\nclass LinkFormat extends Link {\n blotName = 'link';\n\n tagName = 'A';\n\n SANITIZED_URL = 'about:blank';\n\n PROTOCOL_WHITELIST = ['http', 'ftp', 'https', 'mailto', 'tel'];\n\n static create(value) {\n const newVal = sanitizeProtocol(value);\n const node = super.create(newVal);\n node.setAttribute('href', newVal);\n return node;\n }\n\n static formats(domNode) {\n return domNode?.getAttribute?.('href');\n }\n\n static sanitize(url) {\n return getIsValidProtocol(url, this.PROTOCOL_WHITELIST) ? url : this.SANITIZED_URL;\n }\n\n format(name, value) {\n const newVal = sanitizeProtocol(value);\n // Remove link case\n if (name === 'link' && value === false) {\n this.domNode.removeAttribute('href');\n } else if (name !== this.statics.blotName || !newVal) {\n super.format(name, newVal);\n } else {\n this.domNode.setAttribute('href', this.constructor.sanitize(newVal));\n }\n }\n}\n\nexport default LinkFormat;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,yBAAsB;AAEtB,MAAM,mBAAmB,CAAC,UAAU;AAClC,MAAI,OAAO,UAAU;AAAW,WAAO;AACvC,MAAI,SAAS;AACb,MACE,CAAC,MAAM,WAAW,WAClB,CAAC,MAAM,WAAW,UAClB,CAAC,MAAM,WAAW,cAClB,CAAC,MAAM,WAAW,OAClB;AACA,QAAI,CAAC,MAAM,WAAW,QAAQ;AAC5B,eAAS,eAAe;AAAA;AACnB,eAAS,WAAW;AAAA;AAE7B,SAAO;AAAA;AAGT,4BAA4B,KAAK,WAAW;AAC1C,QAAM,SAAS,SAAS,cAAc;AACtC,SAAO,OAAO;AACd,QAAM,WAAW,OAAO,KAAK,MAAM,GAAG,OAAO,KAAK,QAAQ;AAC1D,SAAO,UAAU,QAAQ,YAAY;AAAA;AAGvC,MAAM,OAAO,yBAAM,OAAO;AAE1B,yBAAyB,KAAK;AAAA,EAA9B,cA5BA;AA4BA;AACE,oBAAW;AAEX,mBAAU;AAEV,yBAAgB;AAEhB,8BAAqB,CAAC,QAAQ,OAAO,SAAS,UAAU;AAAA;AAAA,SAEjD,OAAO,OAAO;AACnB,UAAM,SAAS,iBAAiB;AAChC,UAAM,OAAO,MAAM,OAAO;AAC1B,SAAK,aAAa,QAAQ;AAC1B,WAAO;AAAA;AAAA,SAGF,QAAQ,SAAS;AACtB,WAAO,SAAS,eAAe;AAAA;AAAA,SAG1B,SAAS,KAAK;AACnB,WAAO,mBAAmB,KAAK,KAAK,sBAAsB,MAAM,KAAK;AAAA;AAAA,EAGvE,OAAO,MAAM,OAAO;AAClB,UAAM,SAAS,iBAAiB;AAEhC,QAAI,SAAS,UAAU,UAAU,OAAO;AACtC,WAAK,QAAQ,gBAAgB;AAAA,eACpB,SAAS,KAAK,QAAQ,YAAY,CAAC,QAAQ;AACpD,YAAM,OAAO,MAAM;AAAA,WACd;AACL,WAAK,QAAQ,aAAa,QAAQ,KAAK,YAAY,SAAS;AAAA;AAAA;AAAA;AAKlE,IAAO,qBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,27 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var PlainClipboard_exports = {};
|
|
29
|
+
__export(PlainClipboard_exports, {
|
|
30
|
+
default: () => PlainClipboard
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_react_quill = require("react-quill");
|
|
34
|
+
const Clipboard = import_react_quill.Quill.import("modules/clipboard");
|
|
35
|
+
const Delta = import_react_quill.Quill.import("delta");
|
|
11
36
|
class PlainClipboard extends Clipboard {
|
|
12
|
-
convert() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (typeof html === 'string') {
|
|
37
|
+
convert(html = null) {
|
|
38
|
+
if (typeof html === "string") {
|
|
16
39
|
this.container.innerHTML = html;
|
|
17
40
|
}
|
|
18
|
-
|
|
19
41
|
const text = this.container.innerText;
|
|
20
|
-
this.container.innerHTML =
|
|
42
|
+
this.container.innerHTML = "";
|
|
21
43
|
return new Delta().insert(text);
|
|
22
44
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
module.exports = PlainClipboard;
|
|
45
|
+
}
|
|
46
|
+
module.exports = __toCommonJS(PlainClipboard_exports);
|
|
47
|
+
//# sourceMappingURL=PlainClipboard.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/quillOverrides/PlainClipboard.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { Quill } from 'react-quill';\n\nconst Clipboard = Quill.import('modules/clipboard');\nconst Delta = Quill.import('delta');\n\n/**\n * Just for the sake of an example. https://quilljs.com/docs/modules/\n */\nexport default class PlainClipboard extends Clipboard {\n convert(html = null) {\n if (typeof html === 'string') {\n this.container.innerHTML = html;\n }\n const text = this.container.innerText;\n this.container.innerHTML = '';\n return new Delta().insert(text);\n }\n}\n\n// Uncomment if adding custom clipboard, or add in the file you are importing this to\n// Quill.register('modules/clipboard', PlainClipboard)\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,yBAAsB;AAEtB,MAAM,YAAY,yBAAM,OAAO;AAC/B,MAAM,QAAQ,yBAAM,OAAO;AAK3B,6BAA4C,UAAU;AAAA,EACpD,QAAQ,OAAO,MAAM;AACnB,QAAI,OAAO,SAAS,UAAU;AAC5B,WAAK,UAAU,YAAY;AAAA;AAE7B,UAAM,OAAO,KAAK,UAAU;AAC5B,SAAK,UAAU,YAAY;AAC3B,WAAO,IAAI,QAAQ,OAAO;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/cjs/utils.js
CHANGED
|
@@ -1,27 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var utils_exports = {};
|
|
29
|
+
__export(utils_exports, {
|
|
30
|
+
formatHTML: () => formatHTML
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
const formatHTML = (html) => {
|
|
34
|
+
const tab = " ";
|
|
35
|
+
let result = "";
|
|
36
|
+
let indent = "";
|
|
37
|
+
html.split(/>\s*</).forEach((element) => {
|
|
14
38
|
if (element.match(/^\/\w/)) {
|
|
15
39
|
indent = indent.substring(tab.length);
|
|
16
40
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
41
|
+
result += `${indent}<${element}>\r
|
|
42
|
+
`;
|
|
20
43
|
if (element.match(/^<?\w[^>]*[^/]$/)) {
|
|
21
44
|
indent += tab;
|
|
22
45
|
}
|
|
23
46
|
});
|
|
24
47
|
return result.substring(1, result.length - 3);
|
|
25
48
|
};
|
|
26
|
-
|
|
27
|
-
|
|
49
|
+
module.exports = __toCommonJS(utils_exports);
|
|
50
|
+
//# sourceMappingURL=utils.js.map
|
package/cjs/utils.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export const formatHTML = (html) => {\n const tab = '\\t';\n let result = '';\n let indent = '';\n\n html.split(/>\\s*</).forEach((element) => {\n if (element.match(/^\\/\\w/)) {\n indent = indent.substring(tab.length);\n }\n\n result += `${indent}<${element}>\\r\\n`;\n\n if (element.match(/^<?\\w[^>]*[^/]$/)) {\n indent += tab;\n }\n });\n\n return result.substring(1, result.length - 3);\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,aAAa,CAAC,SAAS;AAClC,QAAM,MAAM;AACZ,MAAI,SAAS;AACb,MAAI,SAAS;AAEb,OAAK,MAAM,SAAS,QAAQ,CAAC,YAAY;AACvC,QAAI,QAAQ,MAAM,UAAU;AAC1B,eAAS,OAAO,UAAU,IAAI;AAAA;AAGhC,cAAU,GAAG,UAAU;AAAA;AAEvB,QAAI,QAAQ,MAAM,oBAAoB;AACpC,gBAAU;AAAA;AAAA;AAId,SAAO,OAAO,UAAU,GAAG,OAAO,SAAS;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/esm/DSWYSIWYGEditor.js
CHANGED
|
@@ -1,72 +1,64 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const DSWYSIWYGEditor = _ref => {
|
|
21
|
-
let {
|
|
22
|
-
value = '',
|
|
23
|
-
onChange = () => null,
|
|
24
|
-
getQuillRef = () => null,
|
|
25
|
-
quillModules = {},
|
|
26
|
-
customToolbar,
|
|
27
|
-
toolbarHandlers,
|
|
28
|
-
showRawHTML = false,
|
|
29
|
-
height,
|
|
30
|
-
hideItems
|
|
31
|
-
} = _ref,
|
|
32
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
33
|
-
|
|
34
|
-
const emptyAction = () => {};
|
|
35
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useState, useEffect } from "react";
|
|
3
|
+
import { describe, PropTypes } from "react-desc";
|
|
4
|
+
import DSWYSIWYGEditorImpl from "./components/DSWYSIWYGEditorImpl";
|
|
5
|
+
const DSWYSIWYGEditor = ({
|
|
6
|
+
value = "",
|
|
7
|
+
onChange = () => null,
|
|
8
|
+
getQuillRef = () => null,
|
|
9
|
+
quillModules = {},
|
|
10
|
+
customToolbar,
|
|
11
|
+
toolbarHandlers,
|
|
12
|
+
showRawHTML = false,
|
|
13
|
+
height,
|
|
14
|
+
hideItems,
|
|
15
|
+
...rest
|
|
16
|
+
}) => {
|
|
17
|
+
const emptyAction = () => {
|
|
18
|
+
};
|
|
36
19
|
const [showHTML, setShowHTML] = useState(showRawHTML);
|
|
37
20
|
useEffect(() => setShowHTML(showRawHTML), [showRawHTML]);
|
|
38
|
-
return
|
|
21
|
+
return /* @__PURE__ */ React2.createElement(DSWYSIWYGEditorImpl, {
|
|
39
22
|
forceHttpLink: true,
|
|
40
23
|
handleCustomFieldClick: emptyAction,
|
|
41
24
|
handleImageClick: emptyAction,
|
|
42
25
|
quillOverrides: [],
|
|
43
|
-
value
|
|
44
|
-
onChange
|
|
45
|
-
getQuillRef
|
|
46
|
-
quillModules
|
|
47
|
-
customToolbar
|
|
48
|
-
toolbarHandlers
|
|
26
|
+
value,
|
|
27
|
+
onChange,
|
|
28
|
+
getQuillRef,
|
|
29
|
+
quillModules,
|
|
30
|
+
customToolbar,
|
|
31
|
+
toolbarHandlers,
|
|
49
32
|
showRawHTML: showHTML,
|
|
50
33
|
onShowHTML: () => setShowHTML(!showHTML),
|
|
51
|
-
height
|
|
52
|
-
hideItems
|
|
53
|
-
|
|
34
|
+
height,
|
|
35
|
+
hideItems,
|
|
36
|
+
...rest
|
|
37
|
+
});
|
|
54
38
|
};
|
|
55
|
-
|
|
56
39
|
const wysiwygEditorProps = {
|
|
57
|
-
value: PropTypes.string.description(
|
|
58
|
-
onChange: PropTypes.func.description(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
40
|
+
value: PropTypes.string.description("editors value").isRequired,
|
|
41
|
+
onChange: PropTypes.func.description(`(content, delta, source, editor) : Called back with the new contents of the editor after change.
|
|
42
|
+
It will be passed the HTML contents of the editor, a delta object expressing the change, the source of the change, and finally a read-only proxy to editor accessors such as getHTML().
|
|
43
|
+
\u26A0\uFE0F Do not use this delta object as value, as it will cause a loop.
|
|
44
|
+
Use editor.getContents() instead. See Using Deltas for details.
|
|
45
|
+
Read more: https://github.com/zenoamaro/react-quill#props`).isRequired,
|
|
46
|
+
getQuillRef: PropTypes.func.description("function to use quill.js ref"),
|
|
47
|
+
quillModules: PropTypes.object.description("object to override quill modules"),
|
|
48
|
+
customToolbar: PropTypes.element.description("custom toolbar"),
|
|
49
|
+
toolbarHandlers: PropTypes.object.description("object with toolbar handlers"),
|
|
50
|
+
showRawHTML: PropTypes.bool.description("whether to display html view or not").defaultValue(false),
|
|
51
|
+
height: PropTypes.string.description("heigth of the editors text area"),
|
|
65
52
|
readOnly: PropTypes.string.description("If true, the editor won't allow changing its contents. Wraps the Quill disable API."),
|
|
66
|
-
hideItems: PropTypes.object.description(
|
|
67
|
-
zIndex: PropTypes.number.description(
|
|
53
|
+
hideItems: PropTypes.object.description("object of defaultItems to be removed from toolbar").defaultValue({}),
|
|
54
|
+
zIndex: PropTypes.number.description("zIndex to be used (required when used in a modal for correct tooltips displaying)")
|
|
68
55
|
};
|
|
56
|
+
DSWYSIWYGEditor.propTypes = wysiwygEditorProps;
|
|
69
57
|
const WYSIWYWithSchema = describe(DSWYSIWYGEditor);
|
|
70
58
|
WYSIWYWithSchema.propTypes = wysiwygEditorProps;
|
|
71
|
-
|
|
72
|
-
export {
|
|
59
|
+
var DSWYSIWYGEditor_default = DSWYSIWYGEditor;
|
|
60
|
+
export {
|
|
61
|
+
WYSIWYWithSchema,
|
|
62
|
+
DSWYSIWYGEditor_default as default
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=DSWYSIWYGEditor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSWYSIWYGEditor.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useState, useEffect } from 'react';\nimport { describe, PropTypes } from 'react-desc';\nimport DSWYSIWYGEditorImpl from './components/DSWYSIWYGEditorImpl';\n\nconst DSWYSIWYGEditor = ({\n value = '',\n onChange = () => null,\n getQuillRef = () => null,\n quillModules = {},\n customToolbar,\n toolbarHandlers,\n showRawHTML = false,\n height,\n hideItems,\n ...rest\n}) => {\n const emptyAction = () => {};\n const [showHTML, setShowHTML] = useState(showRawHTML);\n\n useEffect(() => setShowHTML(showRawHTML), [showRawHTML]);\n\n return (\n <DSWYSIWYGEditorImpl\n forceHttpLink\n handleCustomFieldClick={emptyAction}\n handleImageClick={emptyAction}\n quillOverrides={[]}\n value={value}\n onChange={onChange}\n getQuillRef={getQuillRef}\n quillModules={quillModules}\n customToolbar={customToolbar}\n toolbarHandlers={toolbarHandlers}\n showRawHTML={showHTML}\n onShowHTML={() => setShowHTML(!showHTML)}\n height={height}\n hideItems={hideItems}\n {...rest}\n />\n );\n};\n\nconst wysiwygEditorProps = {\n value: PropTypes.string.description('editors value').isRequired,\n onChange: PropTypes.func.description(\n `(content, delta, source, editor) : Called back with the new contents of the editor after change. \n It will be passed the HTML contents of the editor, a delta object expressing the change, the source of the change, and finally a read-only proxy to editor accessors such as getHTML(). \n \u26A0\uFE0F Do not use this delta object as value, as it will cause a loop. \n Use editor.getContents() instead. See Using Deltas for details. \n Read more: https://github.com/zenoamaro/react-quill#props`,\n ).isRequired,\n getQuillRef: PropTypes.func.description('function to use quill.js ref'),\n quillModules: PropTypes.object.description('object to override quill modules'),\n customToolbar: PropTypes.element.description('custom toolbar'),\n toolbarHandlers: PropTypes.object.description('object with toolbar handlers'),\n showRawHTML: PropTypes.bool.description('whether to display html view or not').defaultValue(false),\n height: PropTypes.string.description('heigth of the editors text area'),\n readOnly: PropTypes.string.description(\n \"If true, the editor won't allow changing its contents. Wraps the Quill disable API.\",\n ),\n hideItems: PropTypes.object.description('object of defaultItems to be removed from toolbar').defaultValue({}),\n zIndex: PropTypes.number.description(\n 'zIndex to be used (required when used in a modal for correct tooltips displaying)',\n ),\n};\n\nDSWYSIWYGEditor.propTypes = wysiwygEditorProps;\n\nconst WYSIWYWithSchema = describe(DSWYSIWYGEditor);\nWYSIWYWithSchema.propTypes = wysiwygEditorProps;\n\nexport { WYSIWYWithSchema };\nexport default DSWYSIWYGEditor;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AAEA,MAAM,kBAAkB,CAAC;AAAA,EACvB,QAAQ;AAAA,EACR,WAAW,MAAM;AAAA,EACjB,cAAc,MAAM;AAAA,EACpB,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA;AAAA,KACG;AAAA,MACC;AACJ,QAAM,cAAc,MAAM;AAAA;AAC1B,QAAM,CAAC,UAAU,eAAe,SAAS;AAEzC,YAAU,MAAM,YAAY,cAAc,CAAC;AAE3C,SACE,qCAAC,qBAAD;AAAA,IACE,eAAa;AAAA,IACb,wBAAwB;AAAA,IACxB,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,YAAY,MAAM,YAAY,CAAC;AAAA,IAC/B;AAAA,IACA;AAAA,OACI;AAAA;AAAA;AAKV,MAAM,qBAAqB;AAAA,EACzB,OAAO,UAAU,OAAO,YAAY,iBAAiB;AAAA,EACrD,UAAU,UAAU,KAAK,YACvB;AAAA;AAAA;AAAA;AAAA,gEAKA;AAAA,EACF,aAAa,UAAU,KAAK,YAAY;AAAA,EACxC,cAAc,UAAU,OAAO,YAAY;AAAA,EAC3C,eAAe,UAAU,QAAQ,YAAY;AAAA,EAC7C,iBAAiB,UAAU,OAAO,YAAY;AAAA,EAC9C,aAAa,UAAU,KAAK,YAAY,uCAAuC,aAAa;AAAA,EAC5F,QAAQ,UAAU,OAAO,YAAY;AAAA,EACrC,UAAU,UAAU,OAAO,YACzB;AAAA,EAEF,WAAW,UAAU,OAAO,YAAY,qDAAqD,aAAa;AAAA,EAC1G,QAAQ,UAAU,OAAO,YACvB;AAAA;AAIJ,gBAAgB,YAAY;AAE5B,MAAM,mBAAmB,SAAS;AAClC,iBAAiB,YAAY;AAG7B,IAAO,0BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,53 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import { jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
|
-
|
|
10
|
-
const ALLOWED_TYPES_TEXT = 'JPG, JPEG, PNG, GIF, BMP, TIFF';
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useState } from "react";
|
|
3
|
+
import { Image } from "@elliemae/ds-icons";
|
|
4
|
+
import DSUploader from "@elliemae/ds-uploader";
|
|
5
|
+
import DSModal, { MODAL_TYPE_V2 } from "@elliemae/ds-modal";
|
|
6
|
+
import { TippedButton } from "./TippedButton";
|
|
7
|
+
const ALLOWED_TYPES_TEXT = "JPG, JPEG, PNG, GIF, BMP, TIFF";
|
|
11
8
|
const ALLOWED_TYPES = /image\/(jpeg|jpg|png|gif|bmp|tiff)/;
|
|
12
|
-
const DEFAULT_MAX_SIZE = 1024 * 1024;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
zIndex = 1
|
|
21
|
-
} = _ref;
|
|
9
|
+
const DEFAULT_MAX_SIZE = 1024 * 1024;
|
|
10
|
+
const CustomImageUploader = ({
|
|
11
|
+
quillRef,
|
|
12
|
+
editorFieldName,
|
|
13
|
+
allowedImageTypes = ALLOWED_TYPES_TEXT,
|
|
14
|
+
uploadAsset = () => null,
|
|
15
|
+
zIndex = 1
|
|
16
|
+
}) => {
|
|
22
17
|
const [isOpen, setIsOpen] = useState(false);
|
|
23
18
|
const [error, setError] = useState(null);
|
|
24
19
|
const [inProgress, setInProgress] = useState(false);
|
|
25
|
-
const [lastSelection, setLastSelection] = useState({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
const elementId = "uploadImage".concat(editorFieldName); // eslint-disable-next-line consistent-return
|
|
30
|
-
|
|
31
|
-
const handleFileChange = async files => {
|
|
20
|
+
const [lastSelection, setLastSelection] = useState({ index: 0, length: 0 });
|
|
21
|
+
const elementId = `uploadImage${editorFieldName}`;
|
|
22
|
+
const handleFileChange = async (files) => {
|
|
32
23
|
if (!inProgress) {
|
|
33
24
|
setError(null);
|
|
34
25
|
const selectedFile = files[0];
|
|
35
|
-
|
|
36
26
|
if (!selectedFile) {
|
|
37
|
-
setError(
|
|
27
|
+
setError("Please select a file.");
|
|
38
28
|
return false;
|
|
39
29
|
}
|
|
40
|
-
|
|
41
30
|
if (!selectedFile.type.match(ALLOWED_TYPES)) {
|
|
42
|
-
setError(
|
|
31
|
+
setError("File must be an image.");
|
|
43
32
|
} else if (selectedFile.size > DEFAULT_MAX_SIZE) {
|
|
44
|
-
setError(
|
|
33
|
+
setError("File is too large.");
|
|
45
34
|
} else {
|
|
46
35
|
const fr = new FileReader();
|
|
47
|
-
|
|
48
36
|
fr.onload = async () => {
|
|
49
37
|
setInProgress(true);
|
|
50
|
-
|
|
51
38
|
try {
|
|
52
39
|
const url = await uploadAsset({
|
|
53
40
|
name: selectedFile.name,
|
|
@@ -57,59 +44,51 @@ const CustomImageUploader = _ref => {
|
|
|
57
44
|
file: fr.result
|
|
58
45
|
});
|
|
59
46
|
setIsOpen(false);
|
|
60
|
-
quillRef
|
|
47
|
+
quillRef?.getEditor().insertEmbed(lastSelection?.index || 0, "image", url);
|
|
61
48
|
} catch (e) {
|
|
62
|
-
setError(
|
|
49
|
+
setError("An error has occurred, try again");
|
|
63
50
|
}
|
|
64
|
-
|
|
65
51
|
setInProgress(false);
|
|
66
52
|
};
|
|
67
|
-
|
|
68
53
|
fr.readAsArrayBuffer(selectedFile);
|
|
69
54
|
}
|
|
70
55
|
}
|
|
71
56
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
color: 'red',
|
|
109
|
-
marginTop: '10px'
|
|
110
|
-
}
|
|
111
|
-
}, void 0, error))]
|
|
112
|
-
});
|
|
57
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(TippedButton, {
|
|
58
|
+
zIndex,
|
|
59
|
+
tip: "Insert Image",
|
|
60
|
+
onClick: () => {
|
|
61
|
+
setLastSelection(quillRef?.getEditor().getSelection());
|
|
62
|
+
setIsOpen(true);
|
|
63
|
+
}
|
|
64
|
+
}, /* @__PURE__ */ React2.createElement(Image, {
|
|
65
|
+
color: ["neutral", 500],
|
|
66
|
+
size: "s"
|
|
67
|
+
})), /* @__PURE__ */ React2.createElement(DSModal, {
|
|
68
|
+
isOpen,
|
|
69
|
+
title: "",
|
|
70
|
+
onConfirm: () => {
|
|
71
|
+
setIsOpen(false);
|
|
72
|
+
},
|
|
73
|
+
onClose: () => {
|
|
74
|
+
setIsOpen(false);
|
|
75
|
+
},
|
|
76
|
+
showClose: true,
|
|
77
|
+
version: 2,
|
|
78
|
+
size: "xsmall",
|
|
79
|
+
modalType: MODAL_TYPE_V2.DECISION,
|
|
80
|
+
confirmLabel: "Cancel",
|
|
81
|
+
message: ""
|
|
82
|
+
}, !inProgress && /* @__PURE__ */ React2.createElement(DSUploader, {
|
|
83
|
+
containerProps: { id: elementId },
|
|
84
|
+
showAltAction: false,
|
|
85
|
+
acceptedTypesText: allowedImageTypes,
|
|
86
|
+
onDrop: handleFileChange
|
|
87
|
+
}), inProgress && "Upload in progress...", error && /* @__PURE__ */ React2.createElement("div", {
|
|
88
|
+
style: { color: "red", marginTop: "10px" }
|
|
89
|
+
}, error)));
|
|
90
|
+
};
|
|
91
|
+
export {
|
|
92
|
+
CustomImageUploader
|
|
113
93
|
};
|
|
114
|
-
|
|
115
|
-
export { CustomImageUploader };
|
|
94
|
+
//# sourceMappingURL=CustomImageUploader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/components/CustomImageUploader.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n/* eslint-disable react/prop-types */\nimport React, { useState } from 'react';\nimport { Image } from '@elliemae/ds-icons';\nimport DSUploader from '@elliemae/ds-uploader';\nimport DSModal, { MODAL_TYPE_V2 } from '@elliemae/ds-modal';\nimport { TippedButton } from './TippedButton';\n\nconst ALLOWED_TYPES_TEXT = 'JPG, JPEG, PNG, GIF, BMP, TIFF';\nconst ALLOWED_TYPES = /image\\/(jpeg|jpg|png|gif|bmp|tiff)/;\nconst DEFAULT_MAX_SIZE = 1024 * 1024; // 1 MB\n\nexport const CustomImageUploader = ({\n quillRef,\n editorFieldName,\n allowedImageTypes = ALLOWED_TYPES_TEXT,\n uploadAsset = () => null,\n zIndex = 1,\n}) => {\n const [isOpen, setIsOpen] = useState(false);\n const [error, setError] = useState(null);\n const [inProgress, setInProgress] = useState(false);\n const [lastSelection, setLastSelection] = useState({ index: 0, length: 0 });\n\n const elementId = `uploadImage${editorFieldName}`;\n\n // eslint-disable-next-line consistent-return\n const handleFileChange = async (files) => {\n if (!inProgress) {\n setError(null);\n const selectedFile = files[0];\n if (!selectedFile) {\n setError('Please select a file.');\n return false;\n }\n if (!selectedFile.type.match(ALLOWED_TYPES)) {\n setError('File must be an image.');\n } else if (selectedFile.size > DEFAULT_MAX_SIZE) {\n setError('File is too large.');\n } else {\n const fr = new FileReader();\n fr.onload = async () => {\n setInProgress(true);\n try {\n const url = await uploadAsset({\n name: selectedFile.name,\n type: selectedFile.type,\n description: selectedFile.name,\n isSystemAsset: false,\n file: fr.result,\n });\n setIsOpen(false);\n quillRef?.getEditor().insertEmbed(lastSelection?.index || 0, 'image', url);\n } catch (e) {\n setError('An error has occurred, try again');\n }\n setInProgress(false);\n };\n fr.readAsArrayBuffer(selectedFile);\n }\n }\n };\n return (\n <>\n <TippedButton\n zIndex={zIndex}\n tip=\"Insert Image\"\n onClick={() => {\n setLastSelection(quillRef?.getEditor().getSelection());\n setIsOpen(true);\n }}\n >\n <Image color={['neutral', 500]} size=\"s\" />\n </TippedButton>\n <DSModal\n isOpen={isOpen}\n title=\"\"\n onConfirm={() => {\n setIsOpen(false);\n }}\n onClose={() => {\n setIsOpen(false);\n }}\n showClose\n version={2}\n size=\"xsmall\"\n modalType={MODAL_TYPE_V2.DECISION}\n confirmLabel=\"Cancel\"\n message=\"\"\n >\n {!inProgress && (\n <DSUploader\n containerProps={{ id: elementId }}\n showAltAction={false}\n acceptedTypesText={allowedImageTypes}\n onDrop={handleFileChange}\n />\n )}\n {inProgress && 'Upload in progress...'}\n {error && <div style={{ color: 'red', marginTop: '10px' }}>{error}</div>}\n </DSModal>\n </>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACIA;AACA;AACA;AACA;AACA;AAEA,MAAM,qBAAqB;AAC3B,MAAM,gBAAgB;AACtB,MAAM,mBAAmB,OAAO;AAEzB,MAAM,sBAAsB,CAAC;AAAA,EAClC;AAAA,EACA;AAAA,EACA,oBAAoB;AAAA,EACpB,cAAc,MAAM;AAAA,EACpB,SAAS;AAAA,MACL;AACJ,QAAM,CAAC,QAAQ,aAAa,SAAS;AACrC,QAAM,CAAC,OAAO,YAAY,SAAS;AACnC,QAAM,CAAC,YAAY,iBAAiB,SAAS;AAC7C,QAAM,CAAC,eAAe,oBAAoB,SAAS,EAAE,OAAO,GAAG,QAAQ;AAEvE,QAAM,YAAY,cAAc;AAGhC,QAAM,mBAAmB,OAAO,UAAU;AACxC,QAAI,CAAC,YAAY;AACf,eAAS;AACT,YAAM,eAAe,MAAM;AAC3B,UAAI,CAAC,cAAc;AACjB,iBAAS;AACT,eAAO;AAAA;AAET,UAAI,CAAC,aAAa,KAAK,MAAM,gBAAgB;AAC3C,iBAAS;AAAA,iBACA,aAAa,OAAO,kBAAkB;AAC/C,iBAAS;AAAA,aACJ;AACL,cAAM,KAAK,IAAI;AACf,WAAG,SAAS,YAAY;AACtB,wBAAc;AACd,cAAI;AACF,kBAAM,MAAM,MAAM,YAAY;AAAA,cAC5B,MAAM,aAAa;AAAA,cACnB,MAAM,aAAa;AAAA,cACnB,aAAa,aAAa;AAAA,cAC1B,eAAe;AAAA,cACf,MAAM,GAAG;AAAA;AAEX,sBAAU;AACV,sBAAU,YAAY,YAAY,eAAe,SAAS,GAAG,SAAS;AAAA,mBAC/D,GAAP;AACA,qBAAS;AAAA;AAEX,wBAAc;AAAA;AAEhB,WAAG,kBAAkB;AAAA;AAAA;AAAA;AAI3B,SACE,4DACE,qCAAC,cAAD;AAAA,IACE;AAAA,IACA,KAAI;AAAA,IACJ,SAAS,MAAM;AACb,uBAAiB,UAAU,YAAY;AACvC,gBAAU;AAAA;AAAA,KAGZ,qCAAC,OAAD;AAAA,IAAO,OAAO,CAAC,WAAW;AAAA,IAAM,MAAK;AAAA,OAEvC,qCAAC,SAAD;AAAA,IACE;AAAA,IACA,OAAM;AAAA,IACN,WAAW,MAAM;AACf,gBAAU;AAAA;AAAA,IAEZ,SAAS,MAAM;AACb,gBAAU;AAAA;AAAA,IAEZ,WAAS;AAAA,IACT,SAAS;AAAA,IACT,MAAK;AAAA,IACL,WAAW,cAAc;AAAA,IACzB,cAAa;AAAA,IACb,SAAQ;AAAA,KAEP,CAAC,cACA,qCAAC,YAAD;AAAA,IACE,gBAAgB,EAAE,IAAI;AAAA,IACtB,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,QAAQ;AAAA,MAGX,cAAc,yBACd,SAAS,qCAAC,OAAD;AAAA,IAAK,OAAO,EAAE,OAAO,OAAO,WAAW;AAAA,KAAW;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|