@posiwise/utils 0.0.150 → 0.0.152
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.
|
@@ -1,5 +1,400 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, Directive, inject } from "@angular/core";
|
|
3
|
+
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
4
|
+
import { QuillEditorComponent } from "ngx-quill";
|
|
5
|
+
import { ActivatedRoute } from "@angular/router";
|
|
6
|
+
import { EditorImageUploadService, PermissionService } from "@posiwise/common-services";
|
|
7
|
+
import { TranslocoPipe, translate } from "@jsverse/transloco";
|
|
8
|
+
import { NgbActiveModal, NgbModal } from "@ng-bootstrap/ng-bootstrap";
|
|
9
|
+
import * as i1 from "@angular/forms";
|
|
10
|
+
import { FormsModule } from "@angular/forms";
|
|
11
|
+
import { ButtonBusyDirective } from "@posiwise/directives";
|
|
1
12
|
import Quill from "quill";
|
|
2
13
|
import * as ImageResize from "quill-resize-image";
|
|
14
|
+
const EMBED = "no-drag-image";
|
|
15
|
+
const PREVIEW_RELEASE_MS = 1e4;
|
|
16
|
+
function outsideHistory(quill, change) {
|
|
17
|
+
const history = quill.getModule?.("history");
|
|
18
|
+
if (!history) {
|
|
19
|
+
change();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
history.ignoreChange = true;
|
|
23
|
+
let delta;
|
|
24
|
+
try {
|
|
25
|
+
delta = change();
|
|
26
|
+
} finally {
|
|
27
|
+
history.ignoreChange = false;
|
|
28
|
+
}
|
|
29
|
+
if (delta) history.transform(delta);
|
|
30
|
+
}
|
|
31
|
+
function indexOfImage(quill, url) {
|
|
32
|
+
let index = 0;
|
|
33
|
+
for (const op of quill.getContents().ops) {
|
|
34
|
+
const insert = op.insert;
|
|
35
|
+
if (typeof insert === "object" && insert?.[EMBED]?.url === url) return index;
|
|
36
|
+
index += typeof insert === "string" ? insert.length : 1;
|
|
37
|
+
}
|
|
38
|
+
return -1;
|
|
39
|
+
}
|
|
40
|
+
function showImagePreview(quill, index, file) {
|
|
41
|
+
if (typeof URL.createObjectURL !== "function") return null;
|
|
42
|
+
const local = URL.createObjectURL(file);
|
|
43
|
+
outsideHistory(quill, () => quill.insertEmbed(index, EMBED, { url: local }, Quill.sources.API));
|
|
44
|
+
outsideHistory(quill, () => quill.insertText(index + 1, "\n", Quill.sources.API));
|
|
45
|
+
return (url) => {
|
|
46
|
+
const at = indexOfImage(quill, local);
|
|
47
|
+
if (at >= 0) outsideHistory(quill, () => quill.deleteText(at, 1, Quill.sources.API));
|
|
48
|
+
setTimeout(() => URL.revokeObjectURL(local), PREVIEW_RELEASE_MS);
|
|
49
|
+
if (at < 0 || !url) return null;
|
|
50
|
+
quill.insertEmbed(at, EMBED, { url }, Quill.sources.USER);
|
|
51
|
+
return at + 2;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const HOST_CLASS = "ql-upload-host";
|
|
55
|
+
const CHIP_CLASS = "ql-upload-indicator";
|
|
56
|
+
const PERCENT_CLASS = "ql-upload-percent";
|
|
57
|
+
function showUploadIndicator(quill, label = "") {
|
|
58
|
+
const container = quill.container ?? quill.root.parentElement;
|
|
59
|
+
const host = container?.parentElement;
|
|
60
|
+
if (!container || !host) return Object.assign(() => void 0, { progress: () => void 0 });
|
|
61
|
+
host.classList.add(HOST_CLASS);
|
|
62
|
+
const doc = host.ownerDocument;
|
|
63
|
+
const chip = doc.createElement("div");
|
|
64
|
+
chip.className = CHIP_CLASS;
|
|
65
|
+
chip.setAttribute("role", "status");
|
|
66
|
+
const spinner = doc.createElement("i");
|
|
67
|
+
spinner.className = "fa fa-spinner fa-spin";
|
|
68
|
+
spinner.setAttribute("aria-hidden", "true");
|
|
69
|
+
const percent = doc.createElement("span");
|
|
70
|
+
percent.className = PERCENT_CLASS;
|
|
71
|
+
percent.setAttribute("aria-hidden", "true");
|
|
72
|
+
chip.append(spinner, ` ${label}`, percent);
|
|
73
|
+
chip.style.setProperty("--upload-top", `${container.offsetTop}px`);
|
|
74
|
+
host.append(chip);
|
|
75
|
+
const hide = () => {
|
|
76
|
+
chip.remove();
|
|
77
|
+
if (!host.querySelector(`.${CHIP_CLASS}`)) host.classList.remove(HOST_CLASS);
|
|
78
|
+
};
|
|
79
|
+
const progress = (sent) => {
|
|
80
|
+
percent.textContent = `${Math.min(Math.max(Math.round(sent), 0), 99)}%`;
|
|
81
|
+
};
|
|
82
|
+
return Object.assign(hide, { progress });
|
|
83
|
+
}
|
|
84
|
+
const EDITOR_IMAGE_TYPES = [
|
|
85
|
+
"image/png",
|
|
86
|
+
"image/jpeg",
|
|
87
|
+
"image/webp"
|
|
88
|
+
];
|
|
89
|
+
function insertImageUrl(quill, index, url) {
|
|
90
|
+
quill.insertEmbed(index, "no-drag-image", { url }, Quill.sources.USER);
|
|
91
|
+
quill.insertText(index + 1, "\n", Quill.sources.USER);
|
|
92
|
+
}
|
|
93
|
+
async function uploadOne(quill, at, item, toUrl, busyLabel) {
|
|
94
|
+
const indicator = showUploadIndicator(quill, busyLabel);
|
|
95
|
+
const settlePreview = item instanceof File ? showImagePreview(quill, at, item) : null;
|
|
96
|
+
let url;
|
|
97
|
+
try {
|
|
98
|
+
url = await (item instanceof File ? toUrl(item, indicator.progress) : toUrl(item)).catch(() => null);
|
|
99
|
+
} finally {
|
|
100
|
+
indicator();
|
|
101
|
+
}
|
|
102
|
+
if (settlePreview) return settlePreview(url) ?? at;
|
|
103
|
+
if (!url) return at;
|
|
104
|
+
insertImageUrl(quill, at, url);
|
|
105
|
+
return at + 2;
|
|
106
|
+
}
|
|
107
|
+
async function insertUploadedImages(quill, index, items, toUrl, busyLabel) {
|
|
108
|
+
let at = index;
|
|
109
|
+
quill.root.setAttribute("aria-busy", "true");
|
|
110
|
+
try {
|
|
111
|
+
for (const item of items) {
|
|
112
|
+
const next = await uploadOne(quill, at, item, toUrl, busyLabel);
|
|
113
|
+
if (next !== at) {
|
|
114
|
+
at = next;
|
|
115
|
+
quill.setSelection(at, Quill.sources.SILENT);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
} finally {
|
|
119
|
+
quill.root.removeAttribute("aria-busy");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function pickImageFiles(onPicked, doc = document) {
|
|
123
|
+
const input = doc.createElement("input");
|
|
124
|
+
input.type = "file";
|
|
125
|
+
input.accept = EDITOR_IMAGE_TYPES.join(",");
|
|
126
|
+
input.multiple = true;
|
|
127
|
+
input.addEventListener("change", () => {
|
|
128
|
+
const files = Array.from(input.files ?? []);
|
|
129
|
+
if (files.length) onPicked(files);
|
|
130
|
+
});
|
|
131
|
+
input.click();
|
|
132
|
+
}
|
|
133
|
+
async function chooseImage(quill, options) {
|
|
134
|
+
const index = quill.getSelection(true)?.index ?? 0;
|
|
135
|
+
if (!options.choose) {
|
|
136
|
+
pickImageFiles((files) => insertUploadedImages(quill, index, files, options.upload, options.busyLabel?.()));
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const choice = await options.choose();
|
|
140
|
+
if (!choice) return;
|
|
141
|
+
if ("url" in choice) insertImageUrl(quill, index, choice.url);
|
|
142
|
+
else await insertUploadedImages(quill, index, choice.files, options.upload, options.busyLabel?.());
|
|
143
|
+
}
|
|
144
|
+
function imageUploaderModule(options) {
|
|
145
|
+
return {
|
|
146
|
+
mimetypes: EDITOR_IMAGE_TYPES,
|
|
147
|
+
handler(range, files) {
|
|
148
|
+
insertUploadedImages(this.quill, range.index, files, options.upload, options.busyLabel?.());
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const DROP_CLASS = "ql-image-drop";
|
|
153
|
+
var ImageDropHint = class {
|
|
154
|
+
constructor(quill, options) {
|
|
155
|
+
const container = quill.container;
|
|
156
|
+
const show = (event) => {
|
|
157
|
+
if (Array.from(event.dataTransfer?.types ?? []).includes("Files")) {
|
|
158
|
+
container.setAttribute("data-drop-label", options?.label?.() ?? "");
|
|
159
|
+
container.classList.add(DROP_CLASS);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const hide = (event) => {
|
|
163
|
+
if (event.type === "drop" || !container.contains(event.relatedTarget)) container.classList.remove(DROP_CLASS);
|
|
164
|
+
};
|
|
165
|
+
container.addEventListener("dragenter", show);
|
|
166
|
+
container.addEventListener("dragover", show);
|
|
167
|
+
container.addEventListener("dragleave", hide);
|
|
168
|
+
container.addEventListener("drop", hide);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
const LINK = /^https?:\/\/\S+$/i;
|
|
172
|
+
var EditorImageDialogComponent = class EditorImageDialogComponent {
|
|
173
|
+
constructor() {
|
|
174
|
+
this.modal = inject(NgbActiveModal);
|
|
175
|
+
this.cdr = inject(ChangeDetectorRef);
|
|
176
|
+
this.accept = EDITOR_IMAGE_TYPES.join(",");
|
|
177
|
+
this.link = "";
|
|
178
|
+
this.triedLink = false;
|
|
179
|
+
this.importing = false;
|
|
180
|
+
}
|
|
181
|
+
get linkValid() {
|
|
182
|
+
return LINK.test(this.link.trim());
|
|
183
|
+
}
|
|
184
|
+
async addLink() {
|
|
185
|
+
this.triedLink = true;
|
|
186
|
+
if (!this.linkValid || this.importing) return;
|
|
187
|
+
this.importing = true;
|
|
188
|
+
try {
|
|
189
|
+
const url = await this.importUrl(this.link.trim());
|
|
190
|
+
this.modal.close({ url });
|
|
191
|
+
} catch {} finally {
|
|
192
|
+
this.importing = false;
|
|
193
|
+
this.cdr.markForCheck();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
filesPicked(input) {
|
|
197
|
+
const files = Array.from(input.files ?? []);
|
|
198
|
+
if (files.length) this.modal.close({ files });
|
|
199
|
+
}
|
|
200
|
+
static {
|
|
201
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
202
|
+
minVersion: "12.0.0",
|
|
203
|
+
version: "22.2.3",
|
|
204
|
+
ngImport: i0,
|
|
205
|
+
type: EditorImageDialogComponent,
|
|
206
|
+
deps: [],
|
|
207
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
static {
|
|
211
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
212
|
+
minVersion: "17.0.0",
|
|
213
|
+
version: "22.2.3",
|
|
214
|
+
type: EditorImageDialogComponent,
|
|
215
|
+
isStandalone: true,
|
|
216
|
+
selector: "pw-editor-image-dialog",
|
|
217
|
+
ngImport: i0,
|
|
218
|
+
template: "<div class=\"pw-editor-image\">\n <div class=\"pw-editor-image__header\">\n <h5 class=\"pw-editor-image__title\" id=\"pw-editor-image-title\">{{ 'Common.Upload.Image.Title' | transloco }}</h5>\n <button type=\"button\"\n class=\"btn-close\"\n [disabled]=\"importing\"\n [attr.aria-label]=\"'Button.Cancel' | transloco\"\n (click)=\"modal.dismiss()\">\n </button>\n </div>\n\n <form class=\"pw-editor-image__link\" (ngSubmit)=\"addLink()\">\n <label class=\"form-label\" for=\"pw-editor-image-link\">{{ 'Common.Upload.Image.LinkLabel' | transloco }}</label>\n <div class=\"input-group\">\n <input id=\"pw-editor-image-link\"\n name=\"link\"\n type=\"url\"\n class=\"form-control\"\n autocomplete=\"off\"\n [readonly]=\"importing\"\n [class.is-invalid]=\"triedLink && !linkValid\"\n [placeholder]=\"'Common.Upload.Image.LinkPlaceholder' | transloco\"\n [(ngModel)]=\"link\">\n <button type=\"submit\" class=\"btn btn-primary\" [buttonBusy]=\"importing\">{{ 'Common.Upload.Image.Add' | transloco }}</button>\n </div>\n @if (triedLink && !linkValid) {\n <div class=\"invalid-feedback d-block\" role=\"alert\">{{ 'Common.Upload.Image.LinkInvalid' | transloco }}</div>\n }\n </form>\n\n <div class=\"pw-editor-image__or\">{{ 'Common.Upload.Image.Or' | transloco }}</div>\n\n <input #fileInput\n type=\"file\"\n class=\"d-none\"\n tabindex=\"-1\"\n [attr.aria-label]=\"'Common.Upload.Image.Upload' | transloco\"\n multiple\n [accept]=\"accept\"\n (change)=\"filesPicked(fileInput)\">\n <button type=\"button\" class=\"btn btn-outline-primary w-100\" [disabled]=\"importing\" (click)=\"fileInput.click()\">\n <i class=\"fa fa-upload\" aria-hidden=\"true\"></i>\n {{ 'Common.Upload.Image.Upload' | transloco }}\n </button>\n <p class=\"pw-editor-image__hint\">{{ 'Common.Upload.Image.Hint' | transloco }}</p>\n</div>\n",
|
|
219
|
+
styles: [".pw-editor-image{padding:24px}.pw-editor-image__header{display:flex;align-items:center;gap:12px;margin-bottom:20px}.pw-editor-image__title{flex:1;margin:0;font-size:16px;font-weight:600;color:var(--titles)}.pw-editor-image__or{display:flex;align-items:center;gap:12px;margin:20px 0;font-size:13px;color:var(--text)}.pw-editor-image__or:before,.pw-editor-image__or:after{content:\"\";flex:1;border-top:1px solid var(--bs-border-color)}.pw-editor-image__hint{margin:12px 0 0;font-size:13px;color:var(--text)}\n"],
|
|
220
|
+
dependencies: [
|
|
221
|
+
{
|
|
222
|
+
kind: "directive",
|
|
223
|
+
type: ButtonBusyDirective,
|
|
224
|
+
selector: "[buttonBusy]",
|
|
225
|
+
inputs: ["buttonBusy", "busyText"]
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
kind: "ngmodule",
|
|
229
|
+
type: FormsModule
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
kind: "directive",
|
|
233
|
+
type: i1.ɵNgNoValidate,
|
|
234
|
+
selector: "form:not([ngNoForm]):not([ngNativeValidate])"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
kind: "directive",
|
|
238
|
+
type: i1.DefaultValueAccessor,
|
|
239
|
+
selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]"
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
kind: "directive",
|
|
243
|
+
type: i1.NgControlStatus,
|
|
244
|
+
selector: "[formControlName],[ngModel],[formControl]"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
kind: "directive",
|
|
248
|
+
type: i1.NgControlStatusGroup,
|
|
249
|
+
selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
kind: "directive",
|
|
253
|
+
type: i1.NgModel,
|
|
254
|
+
selector: "[ngModel]:not([formControlName]):not([formControl])",
|
|
255
|
+
inputs: [
|
|
256
|
+
"name",
|
|
257
|
+
"disabled",
|
|
258
|
+
"ngModel",
|
|
259
|
+
"ngModelOptions"
|
|
260
|
+
],
|
|
261
|
+
outputs: ["ngModelChange"],
|
|
262
|
+
exportAs: ["ngModel"]
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
kind: "directive",
|
|
266
|
+
type: i1.NgForm,
|
|
267
|
+
selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]",
|
|
268
|
+
inputs: ["ngFormOptions"],
|
|
269
|
+
outputs: ["ngSubmit"],
|
|
270
|
+
exportAs: ["ngForm"]
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
kind: "pipe",
|
|
274
|
+
type: TranslocoPipe,
|
|
275
|
+
name: "transloco"
|
|
276
|
+
}
|
|
277
|
+
],
|
|
278
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
283
|
+
minVersion: "12.0.0",
|
|
284
|
+
version: "22.2.3",
|
|
285
|
+
ngImport: i0,
|
|
286
|
+
type: EditorImageDialogComponent,
|
|
287
|
+
decorators: [{
|
|
288
|
+
type: Component,
|
|
289
|
+
args: [{
|
|
290
|
+
selector: "pw-editor-image-dialog",
|
|
291
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
292
|
+
imports: [
|
|
293
|
+
ButtonBusyDirective,
|
|
294
|
+
FormsModule,
|
|
295
|
+
TranslocoPipe
|
|
296
|
+
],
|
|
297
|
+
template: "<div class=\"pw-editor-image\">\n <div class=\"pw-editor-image__header\">\n <h5 class=\"pw-editor-image__title\" id=\"pw-editor-image-title\">{{ 'Common.Upload.Image.Title' | transloco }}</h5>\n <button type=\"button\"\n class=\"btn-close\"\n [disabled]=\"importing\"\n [attr.aria-label]=\"'Button.Cancel' | transloco\"\n (click)=\"modal.dismiss()\">\n </button>\n </div>\n\n <form class=\"pw-editor-image__link\" (ngSubmit)=\"addLink()\">\n <label class=\"form-label\" for=\"pw-editor-image-link\">{{ 'Common.Upload.Image.LinkLabel' | transloco }}</label>\n <div class=\"input-group\">\n <input id=\"pw-editor-image-link\"\n name=\"link\"\n type=\"url\"\n class=\"form-control\"\n autocomplete=\"off\"\n [readonly]=\"importing\"\n [class.is-invalid]=\"triedLink && !linkValid\"\n [placeholder]=\"'Common.Upload.Image.LinkPlaceholder' | transloco\"\n [(ngModel)]=\"link\">\n <button type=\"submit\" class=\"btn btn-primary\" [buttonBusy]=\"importing\">{{ 'Common.Upload.Image.Add' | transloco }}</button>\n </div>\n @if (triedLink && !linkValid) {\n <div class=\"invalid-feedback d-block\" role=\"alert\">{{ 'Common.Upload.Image.LinkInvalid' | transloco }}</div>\n }\n </form>\n\n <div class=\"pw-editor-image__or\">{{ 'Common.Upload.Image.Or' | transloco }}</div>\n\n <input #fileInput\n type=\"file\"\n class=\"d-none\"\n tabindex=\"-1\"\n [attr.aria-label]=\"'Common.Upload.Image.Upload' | transloco\"\n multiple\n [accept]=\"accept\"\n (change)=\"filesPicked(fileInput)\">\n <button type=\"button\" class=\"btn btn-outline-primary w-100\" [disabled]=\"importing\" (click)=\"fileInput.click()\">\n <i class=\"fa fa-upload\" aria-hidden=\"true\"></i>\n {{ 'Common.Upload.Image.Upload' | transloco }}\n </button>\n <p class=\"pw-editor-image__hint\">{{ 'Common.Upload.Image.Hint' | transloco }}</p>\n</div>\n",
|
|
298
|
+
styles: [".pw-editor-image{padding:24px}.pw-editor-image__header{display:flex;align-items:center;gap:12px;margin-bottom:20px}.pw-editor-image__title{flex:1;margin:0;font-size:16px;font-weight:600;color:var(--titles)}.pw-editor-image__or{display:flex;align-items:center;gap:12px;margin:20px 0;font-size:13px;color:var(--text)}.pw-editor-image__or:before,.pw-editor-image__or:after{content:\"\";flex:1;border-top:1px solid var(--bs-border-color)}.pw-editor-image__hint{margin:12px 0 0;font-size:13px;color:var(--text)}\n"]
|
|
299
|
+
}]
|
|
300
|
+
}]
|
|
301
|
+
});
|
|
302
|
+
function openEditorImageDialog(modal, importUrl) {
|
|
303
|
+
const ref = modal.open(EditorImageDialogComponent, {
|
|
304
|
+
centered: true,
|
|
305
|
+
size: "md",
|
|
306
|
+
beforeDismiss: () => !dialog?.importing
|
|
307
|
+
});
|
|
308
|
+
const dialog = ref.componentInstance;
|
|
309
|
+
dialog.importUrl = importUrl;
|
|
310
|
+
return ref.result.then((choice) => choice ?? null, () => null);
|
|
311
|
+
}
|
|
312
|
+
function defaultImageUpload() {
|
|
313
|
+
let route;
|
|
314
|
+
try {
|
|
315
|
+
route = inject(ActivatedRoute, { optional: true });
|
|
316
|
+
} catch {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
return editorImageUpload(() => uploadSubscriptionId(route));
|
|
320
|
+
}
|
|
321
|
+
function editorImageUpload(subscriptionId) {
|
|
322
|
+
let service;
|
|
323
|
+
let modal;
|
|
324
|
+
try {
|
|
325
|
+
service = inject(EditorImageUploadService, { optional: true });
|
|
326
|
+
modal = inject(NgbModal, { optional: true });
|
|
327
|
+
} catch {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
if (!service) return;
|
|
331
|
+
const { upload, importUrl } = service.forSubscription(subscriptionId);
|
|
332
|
+
return {
|
|
333
|
+
upload,
|
|
334
|
+
importUrl,
|
|
335
|
+
choose: modal ? () => openEditorImageDialog(modal, importUrl) : void 0,
|
|
336
|
+
dropLabel: () => translate("Common.Upload.Image.Drop"),
|
|
337
|
+
busyLabel: () => translate("Common.Upload.Image.Uploading")
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
function uploadSubscriptionId(route) {
|
|
341
|
+
const selected = PermissionService.selectedSubscription;
|
|
342
|
+
const path = route?.snapshot?.pathFromRoot ?? [];
|
|
343
|
+
const firstSegment = path.flatMap((r) => r.url ?? []).map((segment) => segment.path)[0];
|
|
344
|
+
const slug = path.map((r) => r.params?.["slug"]).find((value) => value && value === firstSegment);
|
|
345
|
+
if (slug && selected?.slug !== slug) return;
|
|
346
|
+
return selected?.id;
|
|
347
|
+
}
|
|
348
|
+
const EXTERNAL = /^https?:\/\//i;
|
|
349
|
+
function isOwnImage(src) {
|
|
350
|
+
return src.startsWith("/") || /\/editor_images\/\d+\//.test(src);
|
|
351
|
+
}
|
|
352
|
+
function needsImport(src) {
|
|
353
|
+
return !!src && EXTERNAL.test(src) && !isOwnImage(src);
|
|
354
|
+
}
|
|
355
|
+
function droppedImageLinks(data) {
|
|
356
|
+
const html = data?.getData("text/html");
|
|
357
|
+
if (html) {
|
|
358
|
+
const doc = new DOMParser().parseFromString(html, "text/html");
|
|
359
|
+
const srcs = Array.from(doc.images, (img) => img.getAttribute("src")).filter(needsImport);
|
|
360
|
+
if (srcs.length) return srcs;
|
|
361
|
+
}
|
|
362
|
+
const link = data?.getData("text/uri-list")?.split("\n")[0]?.trim();
|
|
363
|
+
return needsImport(link) ? [link] : [];
|
|
364
|
+
}
|
|
365
|
+
var ImageLinkImport = class {
|
|
366
|
+
constructor(quill, options) {
|
|
367
|
+
this.quill = quill;
|
|
368
|
+
this.options = options;
|
|
369
|
+
this.pending = [];
|
|
370
|
+
if (!options?.importUrl) return;
|
|
371
|
+
const Delta = Quill.import("delta");
|
|
372
|
+
quill.clipboard.addMatcher("IMG", (node, delta) => {
|
|
373
|
+
const src = node instanceof Element ? node.getAttribute("src") : null;
|
|
374
|
+
if (!needsImport(src)) return delta;
|
|
375
|
+
this.pending.push(src);
|
|
376
|
+
return new Delta();
|
|
377
|
+
});
|
|
378
|
+
quill.root.addEventListener("paste", () => setTimeout(() => this.importPending(), 0));
|
|
379
|
+
quill.root.addEventListener("drop", (event) => this.onDrop(event));
|
|
380
|
+
}
|
|
381
|
+
importPending() {
|
|
382
|
+
const links = this.pending.splice(0);
|
|
383
|
+
if (links.length) this.insert(links);
|
|
384
|
+
}
|
|
385
|
+
onDrop(event) {
|
|
386
|
+
if (event.dataTransfer?.files?.length) return;
|
|
387
|
+
const links = droppedImageLinks(event.dataTransfer);
|
|
388
|
+
if (links.length) {
|
|
389
|
+
event.preventDefault();
|
|
390
|
+
this.insert(links);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
insert(links) {
|
|
394
|
+
const index = this.quill.getSelection(true)?.index ?? this.quill.getLength();
|
|
395
|
+
insertUploadedImages(this.quill, index, links, this.options.importUrl, this.options.busyLabel?.());
|
|
396
|
+
}
|
|
397
|
+
};
|
|
3
398
|
const DATA_URI_IMAGE = /^data:image\//i;
|
|
4
399
|
const PASTED_IMAGE_MESSAGE = "That image was pasted, so it would be stored inside the article itself rather than on the image host — which makes the page much heavier for every reader. Upload the image somewhere first, then use the image button in the toolbar to add it by URL.";
|
|
5
400
|
function clipboardHasImageFile(clipboardData) {
|
|
@@ -13,6 +408,7 @@ function isEmbeddedImageSrc(src) {
|
|
|
13
408
|
var PasteGuard = class {
|
|
14
409
|
constructor(quill, options) {
|
|
15
410
|
this.notify = options?.onBlocked ?? ((message) => globalThis.alert?.(message));
|
|
411
|
+
this.allowImageFiles = options?.allowImageFiles ?? false;
|
|
16
412
|
quill.root.addEventListener("paste", (event) => this.handlePaste(event), true);
|
|
17
413
|
const Delta = Quill.import("delta");
|
|
18
414
|
quill.clipboard.addMatcher("IMG", (node, delta) => {
|
|
@@ -22,12 +418,71 @@ var PasteGuard = class {
|
|
|
22
418
|
});
|
|
23
419
|
}
|
|
24
420
|
handlePaste(event) {
|
|
25
|
-
if (!clipboardHasImageFile(event.clipboardData)) return;
|
|
421
|
+
if (this.allowImageFiles || !clipboardHasImageFile(event.clipboardData)) return;
|
|
26
422
|
event.preventDefault();
|
|
27
423
|
event.stopPropagation();
|
|
28
424
|
this.notify(PASTED_IMAGE_MESSAGE);
|
|
29
425
|
}
|
|
30
426
|
};
|
|
427
|
+
var EditorImageUploadDirective = class EditorImageUploadDirective {
|
|
428
|
+
constructor() {
|
|
429
|
+
this.editor = inject(QuillEditorComponent, { self: true });
|
|
430
|
+
this.destroyRef = inject(DestroyRef);
|
|
431
|
+
this.options = defaultImageUpload();
|
|
432
|
+
}
|
|
433
|
+
ngOnInit() {
|
|
434
|
+
if (!this.options) return;
|
|
435
|
+
this.editor.onEditorCreated.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((quill) => wireImageUpload(quill, this.options));
|
|
436
|
+
}
|
|
437
|
+
static {
|
|
438
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
439
|
+
minVersion: "12.0.0",
|
|
440
|
+
version: "22.2.3",
|
|
441
|
+
ngImport: i0,
|
|
442
|
+
type: EditorImageUploadDirective,
|
|
443
|
+
deps: [],
|
|
444
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
static {
|
|
448
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
449
|
+
minVersion: "14.0.0",
|
|
450
|
+
version: "22.2.3",
|
|
451
|
+
type: EditorImageUploadDirective,
|
|
452
|
+
isStandalone: true,
|
|
453
|
+
selector: "[pwEditorImages]",
|
|
454
|
+
ngImport: i0
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
459
|
+
minVersion: "12.0.0",
|
|
460
|
+
version: "22.2.3",
|
|
461
|
+
ngImport: i0,
|
|
462
|
+
type: EditorImageUploadDirective,
|
|
463
|
+
decorators: [{
|
|
464
|
+
type: Directive,
|
|
465
|
+
args: [{
|
|
466
|
+
selector: "[pwEditorImages]",
|
|
467
|
+
standalone: true
|
|
468
|
+
}]
|
|
469
|
+
}]
|
|
470
|
+
});
|
|
471
|
+
function wireImageUpload(quill, options) {
|
|
472
|
+
const editor = quill;
|
|
473
|
+
quill.getModule("toolbar")?.addHandler("image", () => chooseImage(editor, options));
|
|
474
|
+
const uploader = quill.getModule("uploader");
|
|
475
|
+
if (uploader) {
|
|
476
|
+
uploader.options.mimetypes = EDITOR_IMAGE_TYPES;
|
|
477
|
+
uploader.options.handler = imageUploaderModule(options).handler;
|
|
478
|
+
}
|
|
479
|
+
new PasteGuard(quill, { allowImageFiles: true });
|
|
480
|
+
new ImageDropHint(quill, { label: options.dropLabel });
|
|
481
|
+
new ImageLinkImport(quill, {
|
|
482
|
+
importUrl: options.importUrl,
|
|
483
|
+
busyLabel: options.busyLabel
|
|
484
|
+
});
|
|
485
|
+
}
|
|
31
486
|
const BlockEmbed = Quill.import("formats/image");
|
|
32
487
|
var NoDragImage = class extends BlockEmbed {
|
|
33
488
|
static create(value) {
|
|
@@ -102,6 +557,111 @@ NoDragImage["tagName"] = "img";
|
|
|
102
557
|
Quill.register(NoDragImage);
|
|
103
558
|
Quill.register("modules/noDragDrop", NoDragDrop);
|
|
104
559
|
Quill.register("modules/imageResize", ImageResize.default || ImageResize);
|
|
560
|
+
function createAlignButtons(container) {
|
|
561
|
+
const buttonContainer = document.createElement("div");
|
|
562
|
+
buttonContainer.setAttribute("class", "media-align-buttons");
|
|
563
|
+
buttonContainer.style.position = "absolute";
|
|
564
|
+
buttonContainer.style.top = "0";
|
|
565
|
+
buttonContainer.style.right = "0";
|
|
566
|
+
buttonContainer.style.display = "flex";
|
|
567
|
+
buttonContainer.setAttribute("contenteditable", "false");
|
|
568
|
+
const leftButton = createButton("Left", () => {
|
|
569
|
+
container.style.textAlign = "left";
|
|
570
|
+
container.setAttribute("data-align", "left");
|
|
571
|
+
});
|
|
572
|
+
const centerButton = createButton("Center", () => {
|
|
573
|
+
container.style.textAlign = "center";
|
|
574
|
+
container.setAttribute("data-align", "center");
|
|
575
|
+
});
|
|
576
|
+
const rightButton = createButton("Right", () => {
|
|
577
|
+
container.style.textAlign = "right";
|
|
578
|
+
container.setAttribute("data-align", "right");
|
|
579
|
+
});
|
|
580
|
+
buttonContainer.appendChild(leftButton);
|
|
581
|
+
buttonContainer.appendChild(centerButton);
|
|
582
|
+
buttonContainer.appendChild(rightButton);
|
|
583
|
+
return buttonContainer;
|
|
584
|
+
}
|
|
585
|
+
function createRemoveButton(container) {
|
|
586
|
+
const wrapper = document.createElement("div");
|
|
587
|
+
wrapper.setAttribute("class", "media-remove-button");
|
|
588
|
+
wrapper.style.position = "absolute";
|
|
589
|
+
wrapper.style.top = "0";
|
|
590
|
+
wrapper.style.left = "0";
|
|
591
|
+
wrapper.style.display = "flex";
|
|
592
|
+
wrapper.setAttribute("contenteditable", "false");
|
|
593
|
+
const removeButton = createButton("Remove", () => {
|
|
594
|
+
const mediaContainer = container.classList.contains("media-container") ? container : container.closest(".media-container");
|
|
595
|
+
if (mediaContainer) {
|
|
596
|
+
const blot = Quill.find(mediaContainer);
|
|
597
|
+
if (blot && "remove" in blot && typeof blot.remove === "function") blot.remove();
|
|
598
|
+
else mediaContainer.remove();
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
removeButton.style.background = "rgb(243, 67, 67)";
|
|
602
|
+
removeButton.style.color = "white";
|
|
603
|
+
removeButton.style.border = "none";
|
|
604
|
+
removeButton.style.padding = "2px 8px";
|
|
605
|
+
removeButton.style.marginTop = "2px";
|
|
606
|
+
removeButton.style.borderRadius = "4px";
|
|
607
|
+
removeButton.title = "Remove video";
|
|
608
|
+
wrapper.appendChild(removeButton);
|
|
609
|
+
return wrapper;
|
|
610
|
+
}
|
|
611
|
+
function createResizeButtons(container) {
|
|
612
|
+
const buttonContainer = document.createElement("div");
|
|
613
|
+
buttonContainer.setAttribute("class", "media-resize-buttons");
|
|
614
|
+
buttonContainer.style.position = "absolute";
|
|
615
|
+
buttonContainer.style.bottom = "5px";
|
|
616
|
+
buttonContainer.style.right = "5px";
|
|
617
|
+
buttonContainer.style.display = "flex";
|
|
618
|
+
buttonContainer.setAttribute("contenteditable", "false");
|
|
619
|
+
const updateWidthAndHeight = (mediaElement, width, height) => {
|
|
620
|
+
mediaElement.style.width = width;
|
|
621
|
+
mediaElement.style.height = height;
|
|
622
|
+
container.setAttribute("data-width", width);
|
|
623
|
+
container.setAttribute("data-height", height);
|
|
624
|
+
};
|
|
625
|
+
const increaseWidthButton = createButton("Increase Width", () => {
|
|
626
|
+
const mediaElement = container.querySelector(".no-drag-media");
|
|
627
|
+
const currentWidth = parseInt(mediaElement.style.width || "100%");
|
|
628
|
+
updateWidthAndHeight(mediaElement, `${currentWidth + 20}px`, mediaElement.style.height);
|
|
629
|
+
});
|
|
630
|
+
const decreaseWidthButton = createButton("Decrease Width", () => {
|
|
631
|
+
const mediaElement = container.querySelector(".no-drag-media");
|
|
632
|
+
const currentWidth = parseInt(mediaElement.style.width || "100%");
|
|
633
|
+
updateWidthAndHeight(mediaElement, `${Math.max(100, currentWidth - 20)}px`, mediaElement.style.height);
|
|
634
|
+
});
|
|
635
|
+
const increaseHeightButton = createButton("Increase Height", () => {
|
|
636
|
+
const mediaElement = container.querySelector(".no-drag-media");
|
|
637
|
+
const currentHeight = parseInt(mediaElement.style.height || "200px");
|
|
638
|
+
updateWidthAndHeight(mediaElement, mediaElement.style.width, `${currentHeight + 20}px`);
|
|
639
|
+
});
|
|
640
|
+
const decreaseHeightButton = createButton("Decrease Height", () => {
|
|
641
|
+
const mediaElement = container.querySelector(".no-drag-media");
|
|
642
|
+
const currentHeight = parseInt(mediaElement.style.height || "200px");
|
|
643
|
+
updateWidthAndHeight(mediaElement, mediaElement.style.width, `${Math.max(100, currentHeight - 20)}px`);
|
|
644
|
+
});
|
|
645
|
+
buttonContainer.appendChild(increaseWidthButton);
|
|
646
|
+
buttonContainer.appendChild(decreaseWidthButton);
|
|
647
|
+
buttonContainer.appendChild(increaseHeightButton);
|
|
648
|
+
buttonContainer.appendChild(decreaseHeightButton);
|
|
649
|
+
return buttonContainer;
|
|
650
|
+
}
|
|
651
|
+
function createButton(label, onClick) {
|
|
652
|
+
const button = document.createElement("button");
|
|
653
|
+
button.innerHTML = label;
|
|
654
|
+
button.style.margin = "0 5px";
|
|
655
|
+
button.style.cursor = "pointer";
|
|
656
|
+
button.setAttribute("contenteditable", "false");
|
|
657
|
+
button.style.pointerEvents = "auto";
|
|
658
|
+
button.onclick = (event) => {
|
|
659
|
+
event.preventDefault();
|
|
660
|
+
event.stopPropagation();
|
|
661
|
+
onClick();
|
|
662
|
+
};
|
|
663
|
+
return button;
|
|
664
|
+
}
|
|
105
665
|
const BlockEmbedVideo = Quill.import("blots/block/embed");
|
|
106
666
|
var NoDragVideo = class extends BlockEmbedVideo {
|
|
107
667
|
static create(value) {
|
|
@@ -133,128 +693,23 @@ var NoDragVideo = class extends BlockEmbedVideo {
|
|
|
133
693
|
container.style.height = "auto";
|
|
134
694
|
container.appendChild(node);
|
|
135
695
|
if (!container.querySelector(".media-remove-button")) {
|
|
136
|
-
const removeButton =
|
|
696
|
+
const removeButton = createRemoveButton(container);
|
|
137
697
|
removeButton.setAttribute("contenteditable", "false");
|
|
138
698
|
container.appendChild(removeButton);
|
|
139
699
|
}
|
|
140
700
|
if (!container.querySelector(".media-align-buttons")) {
|
|
141
|
-
const alignButtons =
|
|
701
|
+
const alignButtons = createAlignButtons(container);
|
|
142
702
|
alignButtons.setAttribute("contenteditable", "false");
|
|
143
703
|
container.appendChild(alignButtons);
|
|
144
704
|
}
|
|
145
705
|
if (!container.querySelector(".media-resize-buttons")) {
|
|
146
|
-
const resizeButtons =
|
|
706
|
+
const resizeButtons = createResizeButtons(container);
|
|
147
707
|
resizeButtons.setAttribute("contenteditable", "false");
|
|
148
708
|
container.appendChild(resizeButtons);
|
|
149
709
|
}
|
|
150
710
|
container.setAttribute("contenteditable", "false");
|
|
151
711
|
return container;
|
|
152
712
|
}
|
|
153
|
-
static createAlignButtons(container) {
|
|
154
|
-
const buttonContainer = document.createElement("div");
|
|
155
|
-
buttonContainer.setAttribute("class", "media-align-buttons");
|
|
156
|
-
buttonContainer.style.position = "absolute";
|
|
157
|
-
buttonContainer.style.top = "0";
|
|
158
|
-
buttonContainer.style.right = "0";
|
|
159
|
-
buttonContainer.style.display = "flex";
|
|
160
|
-
buttonContainer.setAttribute("contenteditable", "false");
|
|
161
|
-
const leftButton = this.createButton("Left", () => {
|
|
162
|
-
container.style.textAlign = "left";
|
|
163
|
-
container.setAttribute("data-align", "left");
|
|
164
|
-
});
|
|
165
|
-
const centerButton = this.createButton("Center", () => {
|
|
166
|
-
container.style.textAlign = "center";
|
|
167
|
-
container.setAttribute("data-align", "center");
|
|
168
|
-
});
|
|
169
|
-
const rightButton = this.createButton("Right", () => {
|
|
170
|
-
container.style.textAlign = "right";
|
|
171
|
-
container.setAttribute("data-align", "right");
|
|
172
|
-
});
|
|
173
|
-
buttonContainer.appendChild(leftButton);
|
|
174
|
-
buttonContainer.appendChild(centerButton);
|
|
175
|
-
buttonContainer.appendChild(rightButton);
|
|
176
|
-
return buttonContainer;
|
|
177
|
-
}
|
|
178
|
-
static createRemoveButton(container) {
|
|
179
|
-
const wrapper = document.createElement("div");
|
|
180
|
-
wrapper.setAttribute("class", "media-remove-button");
|
|
181
|
-
wrapper.style.position = "absolute";
|
|
182
|
-
wrapper.style.top = "0";
|
|
183
|
-
wrapper.style.left = "0";
|
|
184
|
-
wrapper.style.display = "flex";
|
|
185
|
-
wrapper.setAttribute("contenteditable", "false");
|
|
186
|
-
const removeButton = this.createButton("Remove", () => {
|
|
187
|
-
const mediaContainer = container.classList.contains("media-container") ? container : container.closest(".media-container");
|
|
188
|
-
if (mediaContainer) {
|
|
189
|
-
const blot = Quill.find(mediaContainer);
|
|
190
|
-
if (blot && "remove" in blot && typeof blot.remove === "function") blot.remove();
|
|
191
|
-
else mediaContainer.remove();
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
removeButton.style.background = "rgb(243, 67, 67)";
|
|
195
|
-
removeButton.style.color = "white";
|
|
196
|
-
removeButton.style.border = "none";
|
|
197
|
-
removeButton.style.padding = "2px 8px";
|
|
198
|
-
removeButton.style.marginTop = "2px";
|
|
199
|
-
removeButton.style.borderRadius = "4px";
|
|
200
|
-
removeButton.title = "Remove video";
|
|
201
|
-
wrapper.appendChild(removeButton);
|
|
202
|
-
return wrapper;
|
|
203
|
-
}
|
|
204
|
-
static createResizeButtons(container) {
|
|
205
|
-
const buttonContainer = document.createElement("div");
|
|
206
|
-
buttonContainer.setAttribute("class", "media-resize-buttons");
|
|
207
|
-
buttonContainer.style.position = "absolute";
|
|
208
|
-
buttonContainer.style.bottom = "5px";
|
|
209
|
-
buttonContainer.style.right = "5px";
|
|
210
|
-
buttonContainer.style.display = "flex";
|
|
211
|
-
buttonContainer.setAttribute("contenteditable", "false");
|
|
212
|
-
const updateWidthAndHeight = (mediaElement, width, height) => {
|
|
213
|
-
mediaElement.style.width = width;
|
|
214
|
-
mediaElement.style.height = height;
|
|
215
|
-
container.setAttribute("data-width", width);
|
|
216
|
-
container.setAttribute("data-height", height);
|
|
217
|
-
};
|
|
218
|
-
const increaseWidthButton = this.createButton("Increase Width", () => {
|
|
219
|
-
const mediaElement = container.querySelector(".no-drag-media");
|
|
220
|
-
const currentWidth = parseInt(mediaElement.style.width || "100%");
|
|
221
|
-
updateWidthAndHeight(mediaElement, `${currentWidth + 20}px`, mediaElement.style.height);
|
|
222
|
-
});
|
|
223
|
-
const decreaseWidthButton = this.createButton("Decrease Width", () => {
|
|
224
|
-
const mediaElement = container.querySelector(".no-drag-media");
|
|
225
|
-
const currentWidth = parseInt(mediaElement.style.width || "100%");
|
|
226
|
-
updateWidthAndHeight(mediaElement, `${Math.max(100, currentWidth - 20)}px`, mediaElement.style.height);
|
|
227
|
-
});
|
|
228
|
-
const increaseHeightButton = this.createButton("Increase Height", () => {
|
|
229
|
-
const mediaElement = container.querySelector(".no-drag-media");
|
|
230
|
-
const currentHeight = parseInt(mediaElement.style.height || "200px");
|
|
231
|
-
updateWidthAndHeight(mediaElement, mediaElement.style.width, `${currentHeight + 20}px`);
|
|
232
|
-
});
|
|
233
|
-
const decreaseHeightButton = this.createButton("Decrease Height", () => {
|
|
234
|
-
const mediaElement = container.querySelector(".no-drag-media");
|
|
235
|
-
const currentHeight = parseInt(mediaElement.style.height || "200px");
|
|
236
|
-
updateWidthAndHeight(mediaElement, mediaElement.style.width, `${Math.max(100, currentHeight - 20)}px`);
|
|
237
|
-
});
|
|
238
|
-
buttonContainer.appendChild(increaseWidthButton);
|
|
239
|
-
buttonContainer.appendChild(decreaseWidthButton);
|
|
240
|
-
buttonContainer.appendChild(increaseHeightButton);
|
|
241
|
-
buttonContainer.appendChild(decreaseHeightButton);
|
|
242
|
-
return buttonContainer;
|
|
243
|
-
}
|
|
244
|
-
static createButton(label, onClick) {
|
|
245
|
-
const button = document.createElement("button");
|
|
246
|
-
button.innerHTML = label;
|
|
247
|
-
button.style.margin = "0 5px";
|
|
248
|
-
button.style.cursor = "pointer";
|
|
249
|
-
button.setAttribute("contenteditable", "false");
|
|
250
|
-
button.style.pointerEvents = "auto";
|
|
251
|
-
button.onclick = (event) => {
|
|
252
|
-
event.preventDefault();
|
|
253
|
-
event.stopPropagation();
|
|
254
|
-
onClick();
|
|
255
|
-
};
|
|
256
|
-
return button;
|
|
257
|
-
}
|
|
258
713
|
static value(container) {
|
|
259
714
|
const iframe = container.querySelector("iframe");
|
|
260
715
|
return {
|
|
@@ -275,8 +730,10 @@ var QuillHelper = class {
|
|
|
275
730
|
if (!Quill.imports["modules/imageResize"]) Quill.register("modules/imageResize", ImageResize.default || ImageResize);
|
|
276
731
|
if (!Quill.imports["modules/noDragDrop"]) Quill.register("modules/noDragDrop", NoDragDrop);
|
|
277
732
|
if (!Quill.imports["modules/pasteGuard"]) Quill.register("modules/pasteGuard", PasteGuard);
|
|
733
|
+
if (!Quill.imports["modules/imageDropHint"]) Quill.register("modules/imageDropHint", ImageDropHint);
|
|
734
|
+
if (!Quill.imports["modules/imageLinkImport"]) Quill.register("modules/imageLinkImport", ImageLinkImport);
|
|
278
735
|
}
|
|
279
|
-
static getEditorConfig(additionalToolbarConfig = []) {
|
|
736
|
+
static getEditorConfig(additionalToolbarConfig = [], imageUpload = defaultImageUpload()) {
|
|
280
737
|
return {
|
|
281
738
|
toolbar: {
|
|
282
739
|
container: [...[
|
|
@@ -313,6 +770,10 @@ var QuillHelper = class {
|
|
|
313
770
|
], ...additionalToolbarConfig],
|
|
314
771
|
handlers: {
|
|
315
772
|
image: function() {
|
|
773
|
+
if (imageUpload) {
|
|
774
|
+
chooseImage(this.quill, imageUpload);
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
316
777
|
const range = this.quill.getSelection();
|
|
317
778
|
const value = prompt("Enter image URL:");
|
|
318
779
|
if (value) {
|
|
@@ -345,11 +806,21 @@ var QuillHelper = class {
|
|
|
345
806
|
}
|
|
346
807
|
},
|
|
347
808
|
imageResize: { displaySize: true },
|
|
348
|
-
|
|
349
|
-
|
|
809
|
+
...imageUpload ? {
|
|
810
|
+
uploader: imageUploaderModule(imageUpload),
|
|
811
|
+
imageDropHint: { label: imageUpload.dropLabel },
|
|
812
|
+
imageLinkImport: {
|
|
813
|
+
importUrl: imageUpload.importUrl,
|
|
814
|
+
busyLabel: imageUpload.busyLabel
|
|
815
|
+
},
|
|
816
|
+
pasteGuard: { allowImageFiles: true }
|
|
817
|
+
} : {
|
|
818
|
+
noDragDrop: true,
|
|
819
|
+
pasteGuard: true
|
|
820
|
+
}
|
|
350
821
|
};
|
|
351
822
|
}
|
|
352
823
|
};
|
|
353
|
-
export { PASTED_IMAGE_MESSAGE, PasteGuard, QuillHelper, clipboardHasImageFile, isEmbeddedImageSrc };
|
|
824
|
+
export { EDITOR_IMAGE_TYPES, EditorImageUploadDirective, ImageDropHint, PASTED_IMAGE_MESSAGE, PasteGuard, QuillHelper, chooseImage, clipboardHasImageFile, editorImageUpload, imageUploaderModule, insertUploadedImages, isEmbeddedImageSrc, pickImageFiles, wireImageUpload };
|
|
354
825
|
|
|
355
826
|
//# sourceMappingURL=posiwise-utils-quill.mjs.map
|