@sps-woodland/rich-text-editor 8.51.2 → 8.52.0
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/README.md +1 -15
- package/global.d.ts +4 -0
- package/lib/RTELinkModal.d.ts +12 -0
- package/lib/RichTextEditor.css.d.ts +14 -0
- package/lib/RichTextEditor.d.ts +7 -0
- package/lib/browser-ponyfill-D7tZnTg2-DLSaolgA.js +366 -0
- package/lib/hooks/useHtmlToMd.d.ts +1 -0
- package/lib/hooks/useMdToHtml.d.ts +1 -0
- package/lib/hooks/useRTEContent.d.ts +13 -0
- package/lib/hooks/useRTEObserver.d.ts +5 -0
- package/lib/hooks/useRTESelectionListener.d.ts +6 -0
- package/lib/hooks/useRTEToolbarButtons.d.ts +14 -0
- package/lib/icons/index.d.ts +11 -0
- package/lib/index-DUfGYdq1.js +20142 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +4 -146
- package/lib/index.umd.cjs +74 -5
- package/lib/style.css +1 -1
- package/lib/toolbar-button/RTEToolbarButton.css.d.ts +15 -0
- package/lib/toolbar-button/RTEToolbarButton.d.ts +10 -0
- package/lib/utils/utils.d.ts +2 -0
- package/package.json +24 -9
- package/vite.config.mjs +14 -5
package/README.md
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
1
|
## [@sps-woodland/rich-text-editor](https://github.com/SPSCommerce/woodland/tree/master/packages/@sps-woodland/rich-text-editor#readme)
|
|
2
2
|
|
|
3
|
-
SPS Woodland Design System rich text editor component
|
|
4
|
-
|
|
5
|
-
### Usage
|
|
6
|
-
|
|
7
|
-
```ts
|
|
8
|
-
// Preferred (mono-package, tree-shakes per component)
|
|
9
|
-
import { RichTextEditor } from "@sps-woodland/core/rich-text-editor";
|
|
10
|
-
import "@sps-woodland/core/rich-text-editor/style.css";
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
// Still supported, re-exports from @sps-woodland/core
|
|
15
|
-
import { RichTextEditor } from "@sps-woodland/rich-text-editor";
|
|
16
|
-
import "@sps-woodland/rich-text-editor/style.css";
|
|
17
|
-
```
|
|
3
|
+
SPS Woodland Design System rich text editor component
|
package/global.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ComponentProps } from "@sps-woodland/core";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import type { SelectionDOMContextFind } from "./hooks/useRTESelectionListener";
|
|
4
|
+
export interface LinkConfig {
|
|
5
|
+
text: string;
|
|
6
|
+
link: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function RTELinkModal({ onClose, selectionDOMContextFind, selectionRange, }: ComponentProps<{
|
|
9
|
+
onClose: (range?: Range, config?: LinkConfig) => void;
|
|
10
|
+
selectionDOMContextFind: SelectionDOMContextFind;
|
|
11
|
+
selectionRange?: Range;
|
|
12
|
+
}>): React.ReactElement;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const richTextEditor: import("@vanilla-extract/recipes/dist/declarations/src/types").RuntimeFn<{
|
|
2
|
+
disabled: {
|
|
3
|
+
true: {
|
|
4
|
+
borderColor: string;
|
|
5
|
+
};
|
|
6
|
+
false: {
|
|
7
|
+
borderColor: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}>;
|
|
11
|
+
export type RichTextEditorVariants = Required<Parameters<typeof richTextEditor>>[0];
|
|
12
|
+
export declare const rteEditableDiv: typeof richTextEditor;
|
|
13
|
+
export declare const rteToolbar: string;
|
|
14
|
+
export declare const vr: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ComponentProps } from "@sps-woodland/core";
|
|
3
|
+
import type { RichTextEditorAggregateValue } from "./hooks/useRTEContent";
|
|
4
|
+
import type { RichTextEditorVariants } from "./RichTextEditor.css";
|
|
5
|
+
export declare function RichTextEditor({ className, md: mdProp, html: htmlProp, disabled, onChange, ...rest }: ComponentProps<RichTextEditorVariants & Partial<RichTextEditorAggregateValue> & {
|
|
6
|
+
onChange?: (newValue: RichTextEditorAggregateValue) => void;
|
|
7
|
+
}, HTMLDivElement>): React.ReactElement;
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { y as A, G as X } from "./index-DUfGYdq1.js";
|
|
2
|
+
function J(E, y) {
|
|
3
|
+
for (var b = 0; b < y.length; b++) {
|
|
4
|
+
const d = y[b];
|
|
5
|
+
if (typeof d != "string" && !Array.isArray(d)) {
|
|
6
|
+
for (const c in d)
|
|
7
|
+
if (c !== "default" && !(c in E)) {
|
|
8
|
+
const p = Object.getOwnPropertyDescriptor(d, c);
|
|
9
|
+
p && Object.defineProperty(E, c, p.get ? p : {
|
|
10
|
+
enumerable: !0,
|
|
11
|
+
get: () => d[c]
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return Object.freeze(Object.defineProperty(E, Symbol.toStringTag, { value: "Module" }));
|
|
17
|
+
}
|
|
18
|
+
var P = { exports: {} }, S;
|
|
19
|
+
function Z() {
|
|
20
|
+
return S || (S = 1, (function(E, y) {
|
|
21
|
+
var b = typeof globalThis < "u" && globalThis || typeof self < "u" && self || typeof A < "u" && A, d = (function() {
|
|
22
|
+
function p() {
|
|
23
|
+
this.fetch = !1, this.DOMException = b.DOMException;
|
|
24
|
+
}
|
|
25
|
+
return p.prototype = b, new p();
|
|
26
|
+
})();
|
|
27
|
+
(function(p) {
|
|
28
|
+
(function(h) {
|
|
29
|
+
var a = typeof p < "u" && p || typeof self < "u" && self || // eslint-disable-next-line no-undef
|
|
30
|
+
typeof A < "u" && A || {}, f = {
|
|
31
|
+
searchParams: "URLSearchParams" in a,
|
|
32
|
+
iterable: "Symbol" in a && "iterator" in Symbol,
|
|
33
|
+
blob: "FileReader" in a && "Blob" in a && (function() {
|
|
34
|
+
try {
|
|
35
|
+
return new Blob(), !0;
|
|
36
|
+
} catch {
|
|
37
|
+
return !1;
|
|
38
|
+
}
|
|
39
|
+
})(),
|
|
40
|
+
formData: "FormData" in a,
|
|
41
|
+
arrayBuffer: "ArrayBuffer" in a
|
|
42
|
+
};
|
|
43
|
+
function F(t) {
|
|
44
|
+
return t && DataView.prototype.isPrototypeOf(t);
|
|
45
|
+
}
|
|
46
|
+
if (f.arrayBuffer)
|
|
47
|
+
var I = [
|
|
48
|
+
"[object Int8Array]",
|
|
49
|
+
"[object Uint8Array]",
|
|
50
|
+
"[object Uint8ClampedArray]",
|
|
51
|
+
"[object Int16Array]",
|
|
52
|
+
"[object Uint16Array]",
|
|
53
|
+
"[object Int32Array]",
|
|
54
|
+
"[object Uint32Array]",
|
|
55
|
+
"[object Float32Array]",
|
|
56
|
+
"[object Float64Array]"
|
|
57
|
+
], C = ArrayBuffer.isView || function(t) {
|
|
58
|
+
return t && I.indexOf(Object.prototype.toString.call(t)) > -1;
|
|
59
|
+
};
|
|
60
|
+
function w(t) {
|
|
61
|
+
if (typeof t != "string" && (t = String(t)), /[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t) || t === "")
|
|
62
|
+
throw new TypeError('Invalid character in header field name: "' + t + '"');
|
|
63
|
+
return t.toLowerCase();
|
|
64
|
+
}
|
|
65
|
+
function _(t) {
|
|
66
|
+
return typeof t != "string" && (t = String(t)), t;
|
|
67
|
+
}
|
|
68
|
+
function T(t) {
|
|
69
|
+
var e = {
|
|
70
|
+
next: function() {
|
|
71
|
+
var r = t.shift();
|
|
72
|
+
return { done: r === void 0, value: r };
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return f.iterable && (e[Symbol.iterator] = function() {
|
|
76
|
+
return e;
|
|
77
|
+
}), e;
|
|
78
|
+
}
|
|
79
|
+
function i(t) {
|
|
80
|
+
this.map = {}, t instanceof i ? t.forEach(function(e, r) {
|
|
81
|
+
this.append(r, e);
|
|
82
|
+
}, this) : Array.isArray(t) ? t.forEach(function(e) {
|
|
83
|
+
if (e.length != 2)
|
|
84
|
+
throw new TypeError("Headers constructor: expected name/value pair to be length 2, found" + e.length);
|
|
85
|
+
this.append(e[0], e[1]);
|
|
86
|
+
}, this) : t && Object.getOwnPropertyNames(t).forEach(function(e) {
|
|
87
|
+
this.append(e, t[e]);
|
|
88
|
+
}, this);
|
|
89
|
+
}
|
|
90
|
+
i.prototype.append = function(t, e) {
|
|
91
|
+
t = w(t), e = _(e);
|
|
92
|
+
var r = this.map[t];
|
|
93
|
+
this.map[t] = r ? r + ", " + e : e;
|
|
94
|
+
}, i.prototype.delete = function(t) {
|
|
95
|
+
delete this.map[w(t)];
|
|
96
|
+
}, i.prototype.get = function(t) {
|
|
97
|
+
return t = w(t), this.has(t) ? this.map[t] : null;
|
|
98
|
+
}, i.prototype.has = function(t) {
|
|
99
|
+
return this.map.hasOwnProperty(w(t));
|
|
100
|
+
}, i.prototype.set = function(t, e) {
|
|
101
|
+
this.map[w(t)] = _(e);
|
|
102
|
+
}, i.prototype.forEach = function(t, e) {
|
|
103
|
+
for (var r in this.map)
|
|
104
|
+
this.map.hasOwnProperty(r) && t.call(e, this.map[r], r, this);
|
|
105
|
+
}, i.prototype.keys = function() {
|
|
106
|
+
var t = [];
|
|
107
|
+
return this.forEach(function(e, r) {
|
|
108
|
+
t.push(r);
|
|
109
|
+
}), T(t);
|
|
110
|
+
}, i.prototype.values = function() {
|
|
111
|
+
var t = [];
|
|
112
|
+
return this.forEach(function(e) {
|
|
113
|
+
t.push(e);
|
|
114
|
+
}), T(t);
|
|
115
|
+
}, i.prototype.entries = function() {
|
|
116
|
+
var t = [];
|
|
117
|
+
return this.forEach(function(e, r) {
|
|
118
|
+
t.push([r, e]);
|
|
119
|
+
}), T(t);
|
|
120
|
+
}, f.iterable && (i.prototype[Symbol.iterator] = i.prototype.entries);
|
|
121
|
+
function x(t) {
|
|
122
|
+
if (!t._noBody) {
|
|
123
|
+
if (t.bodyUsed)
|
|
124
|
+
return Promise.reject(new TypeError("Already read"));
|
|
125
|
+
t.bodyUsed = !0;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function D(t) {
|
|
129
|
+
return new Promise(function(e, r) {
|
|
130
|
+
t.onload = function() {
|
|
131
|
+
e(t.result);
|
|
132
|
+
}, t.onerror = function() {
|
|
133
|
+
r(t.error);
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function M(t) {
|
|
138
|
+
var e = new FileReader(), r = D(e);
|
|
139
|
+
return e.readAsArrayBuffer(t), r;
|
|
140
|
+
}
|
|
141
|
+
function L(t) {
|
|
142
|
+
var e = new FileReader(), r = D(e), n = /charset=([A-Za-z0-9_-]+)/.exec(t.type), s = n ? n[1] : "utf-8";
|
|
143
|
+
return e.readAsText(t, s), r;
|
|
144
|
+
}
|
|
145
|
+
function q(t) {
|
|
146
|
+
for (var e = new Uint8Array(t), r = new Array(e.length), n = 0; n < e.length; n++)
|
|
147
|
+
r[n] = String.fromCharCode(e[n]);
|
|
148
|
+
return r.join("");
|
|
149
|
+
}
|
|
150
|
+
function R(t) {
|
|
151
|
+
if (t.slice)
|
|
152
|
+
return t.slice(0);
|
|
153
|
+
var e = new Uint8Array(t.byteLength);
|
|
154
|
+
return e.set(new Uint8Array(t)), e.buffer;
|
|
155
|
+
}
|
|
156
|
+
function U() {
|
|
157
|
+
return this.bodyUsed = !1, this._initBody = function(t) {
|
|
158
|
+
this.bodyUsed = this.bodyUsed, this._bodyInit = t, t ? typeof t == "string" ? this._bodyText = t : f.blob && Blob.prototype.isPrototypeOf(t) ? this._bodyBlob = t : f.formData && FormData.prototype.isPrototypeOf(t) ? this._bodyFormData = t : f.searchParams && URLSearchParams.prototype.isPrototypeOf(t) ? this._bodyText = t.toString() : f.arrayBuffer && f.blob && F(t) ? (this._bodyArrayBuffer = R(t.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : f.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(t) || C(t)) ? this._bodyArrayBuffer = R(t) : this._bodyText = t = Object.prototype.toString.call(t) : (this._noBody = !0, this._bodyText = ""), this.headers.get("content-type") || (typeof t == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : f.searchParams && URLSearchParams.prototype.isPrototypeOf(t) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
|
|
159
|
+
}, f.blob && (this.blob = function() {
|
|
160
|
+
var t = x(this);
|
|
161
|
+
if (t)
|
|
162
|
+
return t;
|
|
163
|
+
if (this._bodyBlob)
|
|
164
|
+
return Promise.resolve(this._bodyBlob);
|
|
165
|
+
if (this._bodyArrayBuffer)
|
|
166
|
+
return Promise.resolve(new Blob([this._bodyArrayBuffer]));
|
|
167
|
+
if (this._bodyFormData)
|
|
168
|
+
throw new Error("could not read FormData body as blob");
|
|
169
|
+
return Promise.resolve(new Blob([this._bodyText]));
|
|
170
|
+
}), this.arrayBuffer = function() {
|
|
171
|
+
if (this._bodyArrayBuffer) {
|
|
172
|
+
var t = x(this);
|
|
173
|
+
return t || (ArrayBuffer.isView(this._bodyArrayBuffer) ? Promise.resolve(
|
|
174
|
+
this._bodyArrayBuffer.buffer.slice(
|
|
175
|
+
this._bodyArrayBuffer.byteOffset,
|
|
176
|
+
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
|
|
177
|
+
)
|
|
178
|
+
) : Promise.resolve(this._bodyArrayBuffer));
|
|
179
|
+
} else {
|
|
180
|
+
if (f.blob)
|
|
181
|
+
return this.blob().then(M);
|
|
182
|
+
throw new Error("could not read as ArrayBuffer");
|
|
183
|
+
}
|
|
184
|
+
}, this.text = function() {
|
|
185
|
+
var t = x(this);
|
|
186
|
+
if (t)
|
|
187
|
+
return t;
|
|
188
|
+
if (this._bodyBlob)
|
|
189
|
+
return L(this._bodyBlob);
|
|
190
|
+
if (this._bodyArrayBuffer)
|
|
191
|
+
return Promise.resolve(q(this._bodyArrayBuffer));
|
|
192
|
+
if (this._bodyFormData)
|
|
193
|
+
throw new Error("could not read FormData body as text");
|
|
194
|
+
return Promise.resolve(this._bodyText);
|
|
195
|
+
}, f.formData && (this.formData = function() {
|
|
196
|
+
return this.text().then(G);
|
|
197
|
+
}), this.json = function() {
|
|
198
|
+
return this.text().then(JSON.parse);
|
|
199
|
+
}, this;
|
|
200
|
+
}
|
|
201
|
+
var N = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
|
|
202
|
+
function k(t) {
|
|
203
|
+
var e = t.toUpperCase();
|
|
204
|
+
return N.indexOf(e) > -1 ? e : t;
|
|
205
|
+
}
|
|
206
|
+
function m(t, e) {
|
|
207
|
+
if (!(this instanceof m))
|
|
208
|
+
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
|
|
209
|
+
e = e || {};
|
|
210
|
+
var r = e.body;
|
|
211
|
+
if (t instanceof m) {
|
|
212
|
+
if (t.bodyUsed)
|
|
213
|
+
throw new TypeError("Already read");
|
|
214
|
+
this.url = t.url, this.credentials = t.credentials, e.headers || (this.headers = new i(t.headers)), this.method = t.method, this.mode = t.mode, this.signal = t.signal, !r && t._bodyInit != null && (r = t._bodyInit, t.bodyUsed = !0);
|
|
215
|
+
} else
|
|
216
|
+
this.url = String(t);
|
|
217
|
+
if (this.credentials = e.credentials || this.credentials || "same-origin", (e.headers || !this.headers) && (this.headers = new i(e.headers)), this.method = k(e.method || this.method || "GET"), this.mode = e.mode || this.mode || null, this.signal = e.signal || this.signal || (function() {
|
|
218
|
+
if ("AbortController" in a) {
|
|
219
|
+
var o = new AbortController();
|
|
220
|
+
return o.signal;
|
|
221
|
+
}
|
|
222
|
+
})(), this.referrer = null, (this.method === "GET" || this.method === "HEAD") && r)
|
|
223
|
+
throw new TypeError("Body not allowed for GET or HEAD requests");
|
|
224
|
+
if (this._initBody(r), (this.method === "GET" || this.method === "HEAD") && (e.cache === "no-store" || e.cache === "no-cache")) {
|
|
225
|
+
var n = /([?&])_=[^&]*/;
|
|
226
|
+
if (n.test(this.url))
|
|
227
|
+
this.url = this.url.replace(n, "$1_=" + (/* @__PURE__ */ new Date()).getTime());
|
|
228
|
+
else {
|
|
229
|
+
var s = /\?/;
|
|
230
|
+
this.url += (s.test(this.url) ? "&" : "?") + "_=" + (/* @__PURE__ */ new Date()).getTime();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
m.prototype.clone = function() {
|
|
235
|
+
return new m(this, { body: this._bodyInit });
|
|
236
|
+
};
|
|
237
|
+
function G(t) {
|
|
238
|
+
var e = new FormData();
|
|
239
|
+
return t.trim().split("&").forEach(function(r) {
|
|
240
|
+
if (r) {
|
|
241
|
+
var n = r.split("="), s = n.shift().replace(/\+/g, " "), o = n.join("=").replace(/\+/g, " ");
|
|
242
|
+
e.append(decodeURIComponent(s), decodeURIComponent(o));
|
|
243
|
+
}
|
|
244
|
+
}), e;
|
|
245
|
+
}
|
|
246
|
+
function z(t) {
|
|
247
|
+
var e = new i(), r = t.replace(/\r?\n[\t ]+/g, " ");
|
|
248
|
+
return r.split("\r").map(function(n) {
|
|
249
|
+
return n.indexOf(`
|
|
250
|
+
`) === 0 ? n.substr(1, n.length) : n;
|
|
251
|
+
}).forEach(function(n) {
|
|
252
|
+
var s = n.split(":"), o = s.shift().trim();
|
|
253
|
+
if (o) {
|
|
254
|
+
var g = s.join(":").trim();
|
|
255
|
+
try {
|
|
256
|
+
e.append(o, g);
|
|
257
|
+
} catch (O) {
|
|
258
|
+
console.warn("Response " + O.message);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}), e;
|
|
262
|
+
}
|
|
263
|
+
U.call(m.prototype);
|
|
264
|
+
function l(t, e) {
|
|
265
|
+
if (!(this instanceof l))
|
|
266
|
+
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
|
|
267
|
+
if (e || (e = {}), this.type = "default", this.status = e.status === void 0 ? 200 : e.status, this.status < 200 || this.status > 599)
|
|
268
|
+
throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");
|
|
269
|
+
this.ok = this.status >= 200 && this.status < 300, this.statusText = e.statusText === void 0 ? "" : "" + e.statusText, this.headers = new i(e.headers), this.url = e.url || "", this._initBody(t);
|
|
270
|
+
}
|
|
271
|
+
U.call(l.prototype), l.prototype.clone = function() {
|
|
272
|
+
return new l(this._bodyInit, {
|
|
273
|
+
status: this.status,
|
|
274
|
+
statusText: this.statusText,
|
|
275
|
+
headers: new i(this.headers),
|
|
276
|
+
url: this.url
|
|
277
|
+
});
|
|
278
|
+
}, l.error = function() {
|
|
279
|
+
var t = new l(null, { status: 200, statusText: "" });
|
|
280
|
+
return t.ok = !1, t.status = 0, t.type = "error", t;
|
|
281
|
+
};
|
|
282
|
+
var V = [301, 302, 303, 307, 308];
|
|
283
|
+
l.redirect = function(t, e) {
|
|
284
|
+
if (V.indexOf(e) === -1)
|
|
285
|
+
throw new RangeError("Invalid status code");
|
|
286
|
+
return new l(null, { status: e, headers: { location: t } });
|
|
287
|
+
}, h.DOMException = a.DOMException;
|
|
288
|
+
try {
|
|
289
|
+
new h.DOMException();
|
|
290
|
+
} catch {
|
|
291
|
+
h.DOMException = function(t, e) {
|
|
292
|
+
this.message = t, this.name = e;
|
|
293
|
+
var r = Error(t);
|
|
294
|
+
this.stack = r.stack;
|
|
295
|
+
}, h.DOMException.prototype = Object.create(Error.prototype), h.DOMException.prototype.constructor = h.DOMException;
|
|
296
|
+
}
|
|
297
|
+
function B(t, e) {
|
|
298
|
+
return new Promise(function(r, n) {
|
|
299
|
+
var s = new m(t, e);
|
|
300
|
+
if (s.signal && s.signal.aborted)
|
|
301
|
+
return n(new h.DOMException("Aborted", "AbortError"));
|
|
302
|
+
var o = new XMLHttpRequest();
|
|
303
|
+
function g() {
|
|
304
|
+
o.abort();
|
|
305
|
+
}
|
|
306
|
+
o.onload = function() {
|
|
307
|
+
var u = {
|
|
308
|
+
statusText: o.statusText,
|
|
309
|
+
headers: z(o.getAllResponseHeaders() || "")
|
|
310
|
+
};
|
|
311
|
+
s.url.indexOf("file://") === 0 && (o.status < 200 || o.status > 599) ? u.status = 200 : u.status = o.status, u.url = "responseURL" in o ? o.responseURL : u.headers.get("X-Request-URL");
|
|
312
|
+
var v = "response" in o ? o.response : o.responseText;
|
|
313
|
+
setTimeout(function() {
|
|
314
|
+
r(new l(v, u));
|
|
315
|
+
}, 0);
|
|
316
|
+
}, o.onerror = function() {
|
|
317
|
+
setTimeout(function() {
|
|
318
|
+
n(new TypeError("Network request failed"));
|
|
319
|
+
}, 0);
|
|
320
|
+
}, o.ontimeout = function() {
|
|
321
|
+
setTimeout(function() {
|
|
322
|
+
n(new TypeError("Network request timed out"));
|
|
323
|
+
}, 0);
|
|
324
|
+
}, o.onabort = function() {
|
|
325
|
+
setTimeout(function() {
|
|
326
|
+
n(new h.DOMException("Aborted", "AbortError"));
|
|
327
|
+
}, 0);
|
|
328
|
+
};
|
|
329
|
+
function O(u) {
|
|
330
|
+
try {
|
|
331
|
+
return u === "" && a.location.href ? a.location.href : u;
|
|
332
|
+
} catch {
|
|
333
|
+
return u;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (o.open(s.method, O(s.url), !0), s.credentials === "include" ? o.withCredentials = !0 : s.credentials === "omit" && (o.withCredentials = !1), "responseType" in o && (f.blob ? o.responseType = "blob" : f.arrayBuffer && (o.responseType = "arraybuffer")), e && typeof e.headers == "object" && !(e.headers instanceof i || a.Headers && e.headers instanceof a.Headers)) {
|
|
337
|
+
var j = [];
|
|
338
|
+
Object.getOwnPropertyNames(e.headers).forEach(function(u) {
|
|
339
|
+
j.push(w(u)), o.setRequestHeader(u, _(e.headers[u]));
|
|
340
|
+
}), s.headers.forEach(function(u, v) {
|
|
341
|
+
j.indexOf(v) === -1 && o.setRequestHeader(v, u);
|
|
342
|
+
});
|
|
343
|
+
} else
|
|
344
|
+
s.headers.forEach(function(u, v) {
|
|
345
|
+
o.setRequestHeader(v, u);
|
|
346
|
+
});
|
|
347
|
+
s.signal && (s.signal.addEventListener("abort", g), o.onreadystatechange = function() {
|
|
348
|
+
o.readyState === 4 && s.signal.removeEventListener("abort", g);
|
|
349
|
+
}), o.send(typeof s._bodyInit > "u" ? null : s._bodyInit);
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
return B.polyfill = !0, a.fetch || (a.fetch = B, a.Headers = i, a.Request = m, a.Response = l), h.Headers = i, h.Request = m, h.Response = l, h.fetch = B, h;
|
|
353
|
+
})({});
|
|
354
|
+
})(d), d.fetch.ponyfill = !0, delete d.fetch.polyfill;
|
|
355
|
+
var c = b.fetch ? b : d;
|
|
356
|
+
y = c.fetch, y.default = c.fetch, y.fetch = c.fetch, y.Headers = c.Headers, y.Request = c.Request, y.Response = c.Response, E.exports = y;
|
|
357
|
+
})(P, P.exports)), P.exports;
|
|
358
|
+
}
|
|
359
|
+
var H = Z();
|
|
360
|
+
const $ = /* @__PURE__ */ X(H), K = /* @__PURE__ */ J({
|
|
361
|
+
__proto__: null,
|
|
362
|
+
default: $
|
|
363
|
+
}, [H]);
|
|
364
|
+
export {
|
|
365
|
+
K as b
|
|
366
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useHtmlToMd(): (html: string) => Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useMdToHtml(): (md: string) => Promise<string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
export interface RichTextEditorAggregateValue {
|
|
3
|
+
md: string;
|
|
4
|
+
html: string;
|
|
5
|
+
}
|
|
6
|
+
export type RTEStateUpdateFromDiv = <T extends HTMLElement>(ref: RefObject<T>) => void;
|
|
7
|
+
export declare function useRTEContent(initMd?: string, initHtml?: string): {
|
|
8
|
+
aggValue?: RichTextEditorAggregateValue;
|
|
9
|
+
editableDivInnerHtml: {
|
|
10
|
+
html: string;
|
|
11
|
+
};
|
|
12
|
+
updateStateFromDiv: RTEStateUpdateFromDiv;
|
|
13
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
import type { RTEStateUpdateFromDiv } from "./useRTEContent";
|
|
3
|
+
export declare function moveCaretAfter(node: Node): void;
|
|
4
|
+
export declare function moveCaretBefore(node: Node): void;
|
|
5
|
+
export declare function useRTEObserver(updateStateFromDiv: RTEStateUpdateFromDiv): RefObject<HTMLDivElement>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type ElementTest = (element: HTMLElement) => boolean;
|
|
2
|
+
export type SelectionDOMContextFind = (test?: ElementTest) => HTMLElement | null;
|
|
3
|
+
export declare function useRTESelectionListener(editableDivRef: any): {
|
|
4
|
+
selectionRange: Range | undefined;
|
|
5
|
+
selectionDOMContextFind: SelectionDOMContextFind;
|
|
6
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
import type { RTEToolbarButton } from "../toolbar-button/RTEToolbarButton";
|
|
3
|
+
import type { LinkConfig } from "../RTELinkModal";
|
|
4
|
+
import type { SelectionDOMContextFind } from "./useRTESelectionListener";
|
|
5
|
+
type ToolbarButtonProps = Parameters<typeof RTEToolbarButton>[0] & {
|
|
6
|
+
key: string;
|
|
7
|
+
};
|
|
8
|
+
type ToolbarButtonPartialProps = Omit<ToolbarButtonProps, "selectionDOMContextFind">;
|
|
9
|
+
export declare function useRTEToolbarButtons(selectionDOMContextFind: SelectionDOMContextFind, editableDivRef: RefObject<HTMLDivElement>): {
|
|
10
|
+
toolbarButtons: (ToolbarButtonPartialProps | "vr")[];
|
|
11
|
+
showLinkModal: boolean;
|
|
12
|
+
handleLinkModalClose: (range: Range, config?: LinkConfig) => void;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import bold from "./BOLD.svg";
|
|
2
|
+
import indent from "./INDENT.svg";
|
|
3
|
+
import italics from "./ITALICS.svg";
|
|
4
|
+
import link from "./LINK.svg";
|
|
5
|
+
import orderedList from "./ORDERED_LIST.svg";
|
|
6
|
+
import outdent from "./OUTDENT.svg";
|
|
7
|
+
import redo from "./REDO.svg";
|
|
8
|
+
import undo from "./UNDO.svg";
|
|
9
|
+
import unlink from "./UNLINK.svg";
|
|
10
|
+
import unorderedList from "./UNORDERED_LIST.svg";
|
|
11
|
+
export { bold, indent, italics, link, orderedList, outdent, redo, undo, unlink, unorderedList, };
|