@posiwise/utils 0.0.150 → 0.0.151

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,392 @@
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
+ function outsideHistory(quill, change) {
16
+ const history = quill.getModule?.("history");
17
+ if (!history) {
18
+ change();
19
+ return;
20
+ }
21
+ history.ignoreChange = true;
22
+ let delta;
23
+ try {
24
+ delta = change();
25
+ } finally {
26
+ history.ignoreChange = false;
27
+ }
28
+ if (delta) history.transform(delta);
29
+ }
30
+ function indexOfImage(quill, url) {
31
+ let index = 0;
32
+ for (const op of quill.getContents().ops) {
33
+ const insert = op.insert;
34
+ if (typeof insert === "object" && insert?.[EMBED]?.url === url) return index;
35
+ index += typeof insert === "string" ? insert.length : 1;
36
+ }
37
+ return -1;
38
+ }
39
+ function showImagePreview(quill, index, file) {
40
+ if (typeof URL.createObjectURL !== "function") return null;
41
+ const local = URL.createObjectURL(file);
42
+ outsideHistory(quill, () => quill.insertEmbed(index, EMBED, { url: local }, Quill.sources.API));
43
+ outsideHistory(quill, () => quill.insertText(index + 1, "\n", Quill.sources.API));
44
+ return (url) => {
45
+ const at = indexOfImage(quill, local);
46
+ if (at >= 0) outsideHistory(quill, () => quill.deleteText(at, 1, Quill.sources.API));
47
+ URL.revokeObjectURL(local);
48
+ if (at < 0 || !url) return null;
49
+ quill.insertEmbed(at, EMBED, { url }, Quill.sources.USER);
50
+ return at + 2;
51
+ };
52
+ }
53
+ const HOST_CLASS = "ql-upload-host";
54
+ const CHIP_CLASS = "ql-upload-indicator";
55
+ function showUploadIndicator(quill, label = "") {
56
+ const container = quill.container ?? quill.root.parentElement;
57
+ const host = container?.parentElement;
58
+ if (!container || !host) return () => void 0;
59
+ host.classList.add(HOST_CLASS);
60
+ const doc = host.ownerDocument;
61
+ const chip = doc.createElement("div");
62
+ chip.className = CHIP_CLASS;
63
+ chip.setAttribute("role", "status");
64
+ const spinner = doc.createElement("i");
65
+ spinner.className = "fa fa-spinner fa-spin";
66
+ spinner.setAttribute("aria-hidden", "true");
67
+ chip.append(spinner, ` ${label}`);
68
+ chip.style.setProperty("--upload-top", `${container.offsetTop}px`);
69
+ host.append(chip);
70
+ return () => {
71
+ chip.remove();
72
+ if (!host.querySelector(`.${CHIP_CLASS}`)) host.classList.remove(HOST_CLASS);
73
+ };
74
+ }
75
+ const EDITOR_IMAGE_TYPES = [
76
+ "image/png",
77
+ "image/jpeg",
78
+ "image/gif",
79
+ "image/webp"
80
+ ];
81
+ function insertImageUrl(quill, index, url) {
82
+ quill.insertEmbed(index, "no-drag-image", { url }, Quill.sources.USER);
83
+ quill.insertText(index + 1, "\n", Quill.sources.USER);
84
+ }
85
+ async function uploadOne(quill, at, item, toUrl, busyLabel) {
86
+ const hide = showUploadIndicator(quill, busyLabel);
87
+ const settlePreview = item instanceof File ? showImagePreview(quill, at, item) : null;
88
+ let url;
89
+ try {
90
+ url = await toUrl(item).catch(() => null);
91
+ } finally {
92
+ hide();
93
+ }
94
+ if (settlePreview) return settlePreview(url) ?? at;
95
+ if (!url) return at;
96
+ insertImageUrl(quill, at, url);
97
+ return at + 2;
98
+ }
99
+ async function insertUploadedImages(quill, index, items, toUrl, busyLabel) {
100
+ let at = index;
101
+ quill.root.setAttribute("aria-busy", "true");
102
+ try {
103
+ for (const item of items) {
104
+ const next = await uploadOne(quill, at, item, toUrl, busyLabel);
105
+ if (next !== at) {
106
+ at = next;
107
+ quill.setSelection(at, Quill.sources.SILENT);
108
+ }
109
+ }
110
+ } finally {
111
+ quill.root.removeAttribute("aria-busy");
112
+ }
113
+ }
114
+ function pickImageFiles(onPicked, doc = document) {
115
+ const input = doc.createElement("input");
116
+ input.type = "file";
117
+ input.accept = EDITOR_IMAGE_TYPES.join(",");
118
+ input.multiple = true;
119
+ input.addEventListener("change", () => {
120
+ const files = Array.from(input.files ?? []);
121
+ if (files.length) onPicked(files);
122
+ });
123
+ input.click();
124
+ }
125
+ async function chooseImage(quill, options) {
126
+ const index = quill.getSelection(true)?.index ?? 0;
127
+ if (!options.choose) {
128
+ pickImageFiles((files) => insertUploadedImages(quill, index, files, options.upload, options.busyLabel?.()));
129
+ return;
130
+ }
131
+ const choice = await options.choose();
132
+ if (!choice) return;
133
+ if ("url" in choice) insertImageUrl(quill, index, choice.url);
134
+ else await insertUploadedImages(quill, index, choice.files, options.upload, options.busyLabel?.());
135
+ }
136
+ function imageUploaderModule(options) {
137
+ return {
138
+ mimetypes: EDITOR_IMAGE_TYPES,
139
+ handler(range, files) {
140
+ insertUploadedImages(this.quill, range.index, files, options.upload, options.busyLabel?.());
141
+ }
142
+ };
143
+ }
144
+ const DROP_CLASS = "ql-image-drop";
145
+ var ImageDropHint = class {
146
+ constructor(quill, options) {
147
+ const container = quill.container;
148
+ const show = (event) => {
149
+ if (Array.from(event.dataTransfer?.types ?? []).includes("Files")) {
150
+ container.setAttribute("data-drop-label", options?.label?.() ?? "");
151
+ container.classList.add(DROP_CLASS);
152
+ }
153
+ };
154
+ const hide = (event) => {
155
+ if (event.type === "drop" || !container.contains(event.relatedTarget)) container.classList.remove(DROP_CLASS);
156
+ };
157
+ container.addEventListener("dragenter", show);
158
+ container.addEventListener("dragover", show);
159
+ container.addEventListener("dragleave", hide);
160
+ container.addEventListener("drop", hide);
161
+ }
162
+ };
163
+ const LINK = /^https?:\/\/\S+$/i;
164
+ var EditorImageDialogComponent = class EditorImageDialogComponent {
165
+ constructor() {
166
+ this.modal = inject(NgbActiveModal);
167
+ this.cdr = inject(ChangeDetectorRef);
168
+ this.accept = EDITOR_IMAGE_TYPES.join(",");
169
+ this.link = "";
170
+ this.triedLink = false;
171
+ this.importing = false;
172
+ }
173
+ get linkValid() {
174
+ return LINK.test(this.link.trim());
175
+ }
176
+ async addLink() {
177
+ this.triedLink = true;
178
+ if (!this.linkValid || this.importing) return;
179
+ this.importing = true;
180
+ try {
181
+ const url = await this.importUrl(this.link.trim());
182
+ this.modal.close({ url });
183
+ } catch {} finally {
184
+ this.importing = false;
185
+ this.cdr.markForCheck();
186
+ }
187
+ }
188
+ filesPicked(input) {
189
+ const files = Array.from(input.files ?? []);
190
+ if (files.length) this.modal.close({ files });
191
+ }
192
+ static {
193
+ this.ɵfac = i0.ɵɵngDeclareFactory({
194
+ minVersion: "12.0.0",
195
+ version: "22.2.3",
196
+ ngImport: i0,
197
+ type: EditorImageDialogComponent,
198
+ deps: [],
199
+ target: i0.ɵɵFactoryTarget.Component
200
+ });
201
+ }
202
+ static {
203
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
204
+ minVersion: "17.0.0",
205
+ version: "22.2.3",
206
+ type: EditorImageDialogComponent,
207
+ isStandalone: true,
208
+ selector: "pw-editor-image-dialog",
209
+ ngImport: i0,
210
+ 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",
211
+ 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"],
212
+ dependencies: [
213
+ {
214
+ kind: "directive",
215
+ type: ButtonBusyDirective,
216
+ selector: "[buttonBusy]",
217
+ inputs: ["buttonBusy", "busyText"]
218
+ },
219
+ {
220
+ kind: "ngmodule",
221
+ type: FormsModule
222
+ },
223
+ {
224
+ kind: "directive",
225
+ type: i1.ɵNgNoValidate,
226
+ selector: "form:not([ngNoForm]):not([ngNativeValidate])"
227
+ },
228
+ {
229
+ kind: "directive",
230
+ type: i1.DefaultValueAccessor,
231
+ 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]"
232
+ },
233
+ {
234
+ kind: "directive",
235
+ type: i1.NgControlStatus,
236
+ selector: "[formControlName],[ngModel],[formControl]"
237
+ },
238
+ {
239
+ kind: "directive",
240
+ type: i1.NgControlStatusGroup,
241
+ selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
242
+ },
243
+ {
244
+ kind: "directive",
245
+ type: i1.NgModel,
246
+ selector: "[ngModel]:not([formControlName]):not([formControl])",
247
+ inputs: [
248
+ "name",
249
+ "disabled",
250
+ "ngModel",
251
+ "ngModelOptions"
252
+ ],
253
+ outputs: ["ngModelChange"],
254
+ exportAs: ["ngModel"]
255
+ },
256
+ {
257
+ kind: "directive",
258
+ type: i1.NgForm,
259
+ selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]",
260
+ inputs: ["ngFormOptions"],
261
+ outputs: ["ngSubmit"],
262
+ exportAs: ["ngForm"]
263
+ },
264
+ {
265
+ kind: "pipe",
266
+ type: TranslocoPipe,
267
+ name: "transloco"
268
+ }
269
+ ],
270
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
271
+ });
272
+ }
273
+ };
274
+ i0.ɵɵngDeclareClassMetadata({
275
+ minVersion: "12.0.0",
276
+ version: "22.2.3",
277
+ ngImport: i0,
278
+ type: EditorImageDialogComponent,
279
+ decorators: [{
280
+ type: Component,
281
+ args: [{
282
+ selector: "pw-editor-image-dialog",
283
+ changeDetection: ChangeDetectionStrategy.OnPush,
284
+ imports: [
285
+ ButtonBusyDirective,
286
+ FormsModule,
287
+ TranslocoPipe
288
+ ],
289
+ 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",
290
+ 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"]
291
+ }]
292
+ }]
293
+ });
294
+ function openEditorImageDialog(modal, importUrl) {
295
+ const ref = modal.open(EditorImageDialogComponent, {
296
+ centered: true,
297
+ size: "md",
298
+ beforeDismiss: () => !dialog?.importing
299
+ });
300
+ const dialog = ref.componentInstance;
301
+ dialog.importUrl = importUrl;
302
+ return ref.result.then((choice) => choice ?? null, () => null);
303
+ }
304
+ function defaultImageUpload() {
305
+ let route;
306
+ try {
307
+ route = inject(ActivatedRoute, { optional: true });
308
+ } catch {
309
+ return;
310
+ }
311
+ return editorImageUpload(() => uploadSubscriptionId(route));
312
+ }
313
+ function editorImageUpload(subscriptionId) {
314
+ let service;
315
+ let modal;
316
+ try {
317
+ service = inject(EditorImageUploadService, { optional: true });
318
+ modal = inject(NgbModal, { optional: true });
319
+ } catch {
320
+ return;
321
+ }
322
+ if (!service) return;
323
+ const { upload, importUrl } = service.forSubscription(subscriptionId);
324
+ return {
325
+ upload,
326
+ importUrl,
327
+ choose: modal ? () => openEditorImageDialog(modal, importUrl) : void 0,
328
+ dropLabel: () => translate("Common.Upload.Image.Drop"),
329
+ busyLabel: () => translate("Common.Upload.Image.Uploading")
330
+ };
331
+ }
332
+ function uploadSubscriptionId(route) {
333
+ const selected = PermissionService.selectedSubscription;
334
+ const path = route?.snapshot?.pathFromRoot ?? [];
335
+ const firstSegment = path.flatMap((r) => r.url ?? []).map((segment) => segment.path)[0];
336
+ const slug = path.map((r) => r.params?.["slug"]).find((value) => value && value === firstSegment);
337
+ if (slug && selected?.slug !== slug) return;
338
+ return selected?.id;
339
+ }
340
+ const EXTERNAL = /^https?:\/\//i;
341
+ function isOwnImage(src) {
342
+ return src.startsWith("/") || /\/editor_images\/\d+\//.test(src);
343
+ }
344
+ function needsImport(src) {
345
+ return !!src && EXTERNAL.test(src) && !isOwnImage(src);
346
+ }
347
+ function droppedImageLinks(data) {
348
+ const html = data?.getData("text/html");
349
+ if (html) {
350
+ const doc = new DOMParser().parseFromString(html, "text/html");
351
+ const srcs = Array.from(doc.images, (img) => img.getAttribute("src")).filter(needsImport);
352
+ if (srcs.length) return srcs;
353
+ }
354
+ const link = data?.getData("text/uri-list")?.split("\n")[0]?.trim();
355
+ return needsImport(link) ? [link] : [];
356
+ }
357
+ var ImageLinkImport = class {
358
+ constructor(quill, options) {
359
+ this.quill = quill;
360
+ this.options = options;
361
+ this.pending = [];
362
+ if (!options?.importUrl) return;
363
+ const Delta = Quill.import("delta");
364
+ quill.clipboard.addMatcher("IMG", (node, delta) => {
365
+ const src = node instanceof Element ? node.getAttribute("src") : null;
366
+ if (!needsImport(src)) return delta;
367
+ this.pending.push(src);
368
+ return new Delta();
369
+ });
370
+ quill.root.addEventListener("paste", () => setTimeout(() => this.importPending(), 0));
371
+ quill.root.addEventListener("drop", (event) => this.onDrop(event));
372
+ }
373
+ importPending() {
374
+ const links = this.pending.splice(0);
375
+ if (links.length) this.insert(links);
376
+ }
377
+ onDrop(event) {
378
+ if (event.dataTransfer?.files?.length) return;
379
+ const links = droppedImageLinks(event.dataTransfer);
380
+ if (links.length) {
381
+ event.preventDefault();
382
+ this.insert(links);
383
+ }
384
+ }
385
+ insert(links) {
386
+ const index = this.quill.getSelection(true)?.index ?? this.quill.getLength();
387
+ insertUploadedImages(this.quill, index, links, this.options.importUrl, this.options.busyLabel?.());
388
+ }
389
+ };
3
390
  const DATA_URI_IMAGE = /^data:image\//i;
4
391
  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
392
  function clipboardHasImageFile(clipboardData) {
@@ -13,6 +400,7 @@ function isEmbeddedImageSrc(src) {
13
400
  var PasteGuard = class {
14
401
  constructor(quill, options) {
15
402
  this.notify = options?.onBlocked ?? ((message) => globalThis.alert?.(message));
403
+ this.allowImageFiles = options?.allowImageFiles ?? false;
16
404
  quill.root.addEventListener("paste", (event) => this.handlePaste(event), true);
17
405
  const Delta = Quill.import("delta");
18
406
  quill.clipboard.addMatcher("IMG", (node, delta) => {
@@ -22,12 +410,71 @@ var PasteGuard = class {
22
410
  });
23
411
  }
24
412
  handlePaste(event) {
25
- if (!clipboardHasImageFile(event.clipboardData)) return;
413
+ if (this.allowImageFiles || !clipboardHasImageFile(event.clipboardData)) return;
26
414
  event.preventDefault();
27
415
  event.stopPropagation();
28
416
  this.notify(PASTED_IMAGE_MESSAGE);
29
417
  }
30
418
  };
419
+ var EditorImageUploadDirective = class EditorImageUploadDirective {
420
+ constructor() {
421
+ this.editor = inject(QuillEditorComponent, { self: true });
422
+ this.destroyRef = inject(DestroyRef);
423
+ this.options = defaultImageUpload();
424
+ }
425
+ ngOnInit() {
426
+ if (!this.options) return;
427
+ this.editor.onEditorCreated.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((quill) => wireImageUpload(quill, this.options));
428
+ }
429
+ static {
430
+ this.ɵfac = i0.ɵɵngDeclareFactory({
431
+ minVersion: "12.0.0",
432
+ version: "22.2.3",
433
+ ngImport: i0,
434
+ type: EditorImageUploadDirective,
435
+ deps: [],
436
+ target: i0.ɵɵFactoryTarget.Directive
437
+ });
438
+ }
439
+ static {
440
+ this.ɵdir = i0.ɵɵngDeclareDirective({
441
+ minVersion: "14.0.0",
442
+ version: "22.2.3",
443
+ type: EditorImageUploadDirective,
444
+ isStandalone: true,
445
+ selector: "[pwEditorImages]",
446
+ ngImport: i0
447
+ });
448
+ }
449
+ };
450
+ i0.ɵɵngDeclareClassMetadata({
451
+ minVersion: "12.0.0",
452
+ version: "22.2.3",
453
+ ngImport: i0,
454
+ type: EditorImageUploadDirective,
455
+ decorators: [{
456
+ type: Directive,
457
+ args: [{
458
+ selector: "[pwEditorImages]",
459
+ standalone: true
460
+ }]
461
+ }]
462
+ });
463
+ function wireImageUpload(quill, options) {
464
+ const editor = quill;
465
+ quill.getModule("toolbar")?.addHandler("image", () => chooseImage(editor, options));
466
+ const uploader = quill.getModule("uploader");
467
+ if (uploader) {
468
+ uploader.options.mimetypes = EDITOR_IMAGE_TYPES;
469
+ uploader.options.handler = imageUploaderModule(options).handler;
470
+ }
471
+ new PasteGuard(quill, { allowImageFiles: true });
472
+ new ImageDropHint(quill, { label: options.dropLabel });
473
+ new ImageLinkImport(quill, {
474
+ importUrl: options.importUrl,
475
+ busyLabel: options.busyLabel
476
+ });
477
+ }
31
478
  const BlockEmbed = Quill.import("formats/image");
32
479
  var NoDragImage = class extends BlockEmbed {
33
480
  static create(value) {
@@ -102,6 +549,111 @@ NoDragImage["tagName"] = "img";
102
549
  Quill.register(NoDragImage);
103
550
  Quill.register("modules/noDragDrop", NoDragDrop);
104
551
  Quill.register("modules/imageResize", ImageResize.default || ImageResize);
552
+ function createAlignButtons(container) {
553
+ const buttonContainer = document.createElement("div");
554
+ buttonContainer.setAttribute("class", "media-align-buttons");
555
+ buttonContainer.style.position = "absolute";
556
+ buttonContainer.style.top = "0";
557
+ buttonContainer.style.right = "0";
558
+ buttonContainer.style.display = "flex";
559
+ buttonContainer.setAttribute("contenteditable", "false");
560
+ const leftButton = createButton("Left", () => {
561
+ container.style.textAlign = "left";
562
+ container.setAttribute("data-align", "left");
563
+ });
564
+ const centerButton = createButton("Center", () => {
565
+ container.style.textAlign = "center";
566
+ container.setAttribute("data-align", "center");
567
+ });
568
+ const rightButton = createButton("Right", () => {
569
+ container.style.textAlign = "right";
570
+ container.setAttribute("data-align", "right");
571
+ });
572
+ buttonContainer.appendChild(leftButton);
573
+ buttonContainer.appendChild(centerButton);
574
+ buttonContainer.appendChild(rightButton);
575
+ return buttonContainer;
576
+ }
577
+ function createRemoveButton(container) {
578
+ const wrapper = document.createElement("div");
579
+ wrapper.setAttribute("class", "media-remove-button");
580
+ wrapper.style.position = "absolute";
581
+ wrapper.style.top = "0";
582
+ wrapper.style.left = "0";
583
+ wrapper.style.display = "flex";
584
+ wrapper.setAttribute("contenteditable", "false");
585
+ const removeButton = createButton("Remove", () => {
586
+ const mediaContainer = container.classList.contains("media-container") ? container : container.closest(".media-container");
587
+ if (mediaContainer) {
588
+ const blot = Quill.find(mediaContainer);
589
+ if (blot && "remove" in blot && typeof blot.remove === "function") blot.remove();
590
+ else mediaContainer.remove();
591
+ }
592
+ });
593
+ removeButton.style.background = "rgb(243, 67, 67)";
594
+ removeButton.style.color = "white";
595
+ removeButton.style.border = "none";
596
+ removeButton.style.padding = "2px 8px";
597
+ removeButton.style.marginTop = "2px";
598
+ removeButton.style.borderRadius = "4px";
599
+ removeButton.title = "Remove video";
600
+ wrapper.appendChild(removeButton);
601
+ return wrapper;
602
+ }
603
+ function createResizeButtons(container) {
604
+ const buttonContainer = document.createElement("div");
605
+ buttonContainer.setAttribute("class", "media-resize-buttons");
606
+ buttonContainer.style.position = "absolute";
607
+ buttonContainer.style.bottom = "5px";
608
+ buttonContainer.style.right = "5px";
609
+ buttonContainer.style.display = "flex";
610
+ buttonContainer.setAttribute("contenteditable", "false");
611
+ const updateWidthAndHeight = (mediaElement, width, height) => {
612
+ mediaElement.style.width = width;
613
+ mediaElement.style.height = height;
614
+ container.setAttribute("data-width", width);
615
+ container.setAttribute("data-height", height);
616
+ };
617
+ const increaseWidthButton = createButton("Increase Width", () => {
618
+ const mediaElement = container.querySelector(".no-drag-media");
619
+ const currentWidth = parseInt(mediaElement.style.width || "100%");
620
+ updateWidthAndHeight(mediaElement, `${currentWidth + 20}px`, mediaElement.style.height);
621
+ });
622
+ const decreaseWidthButton = createButton("Decrease Width", () => {
623
+ const mediaElement = container.querySelector(".no-drag-media");
624
+ const currentWidth = parseInt(mediaElement.style.width || "100%");
625
+ updateWidthAndHeight(mediaElement, `${Math.max(100, currentWidth - 20)}px`, mediaElement.style.height);
626
+ });
627
+ const increaseHeightButton = createButton("Increase Height", () => {
628
+ const mediaElement = container.querySelector(".no-drag-media");
629
+ const currentHeight = parseInt(mediaElement.style.height || "200px");
630
+ updateWidthAndHeight(mediaElement, mediaElement.style.width, `${currentHeight + 20}px`);
631
+ });
632
+ const decreaseHeightButton = createButton("Decrease Height", () => {
633
+ const mediaElement = container.querySelector(".no-drag-media");
634
+ const currentHeight = parseInt(mediaElement.style.height || "200px");
635
+ updateWidthAndHeight(mediaElement, mediaElement.style.width, `${Math.max(100, currentHeight - 20)}px`);
636
+ });
637
+ buttonContainer.appendChild(increaseWidthButton);
638
+ buttonContainer.appendChild(decreaseWidthButton);
639
+ buttonContainer.appendChild(increaseHeightButton);
640
+ buttonContainer.appendChild(decreaseHeightButton);
641
+ return buttonContainer;
642
+ }
643
+ function createButton(label, onClick) {
644
+ const button = document.createElement("button");
645
+ button.innerHTML = label;
646
+ button.style.margin = "0 5px";
647
+ button.style.cursor = "pointer";
648
+ button.setAttribute("contenteditable", "false");
649
+ button.style.pointerEvents = "auto";
650
+ button.onclick = (event) => {
651
+ event.preventDefault();
652
+ event.stopPropagation();
653
+ onClick();
654
+ };
655
+ return button;
656
+ }
105
657
  const BlockEmbedVideo = Quill.import("blots/block/embed");
106
658
  var NoDragVideo = class extends BlockEmbedVideo {
107
659
  static create(value) {
@@ -133,128 +685,23 @@ var NoDragVideo = class extends BlockEmbedVideo {
133
685
  container.style.height = "auto";
134
686
  container.appendChild(node);
135
687
  if (!container.querySelector(".media-remove-button")) {
136
- const removeButton = this.createRemoveButton(container);
688
+ const removeButton = createRemoveButton(container);
137
689
  removeButton.setAttribute("contenteditable", "false");
138
690
  container.appendChild(removeButton);
139
691
  }
140
692
  if (!container.querySelector(".media-align-buttons")) {
141
- const alignButtons = this.createAlignButtons(container);
693
+ const alignButtons = createAlignButtons(container);
142
694
  alignButtons.setAttribute("contenteditable", "false");
143
695
  container.appendChild(alignButtons);
144
696
  }
145
697
  if (!container.querySelector(".media-resize-buttons")) {
146
- const resizeButtons = this.createResizeButtons(container);
698
+ const resizeButtons = createResizeButtons(container);
147
699
  resizeButtons.setAttribute("contenteditable", "false");
148
700
  container.appendChild(resizeButtons);
149
701
  }
150
702
  container.setAttribute("contenteditable", "false");
151
703
  return container;
152
704
  }
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
705
  static value(container) {
259
706
  const iframe = container.querySelector("iframe");
260
707
  return {
@@ -275,8 +722,10 @@ var QuillHelper = class {
275
722
  if (!Quill.imports["modules/imageResize"]) Quill.register("modules/imageResize", ImageResize.default || ImageResize);
276
723
  if (!Quill.imports["modules/noDragDrop"]) Quill.register("modules/noDragDrop", NoDragDrop);
277
724
  if (!Quill.imports["modules/pasteGuard"]) Quill.register("modules/pasteGuard", PasteGuard);
725
+ if (!Quill.imports["modules/imageDropHint"]) Quill.register("modules/imageDropHint", ImageDropHint);
726
+ if (!Quill.imports["modules/imageLinkImport"]) Quill.register("modules/imageLinkImport", ImageLinkImport);
278
727
  }
279
- static getEditorConfig(additionalToolbarConfig = []) {
728
+ static getEditorConfig(additionalToolbarConfig = [], imageUpload = defaultImageUpload()) {
280
729
  return {
281
730
  toolbar: {
282
731
  container: [...[
@@ -313,6 +762,10 @@ var QuillHelper = class {
313
762
  ], ...additionalToolbarConfig],
314
763
  handlers: {
315
764
  image: function() {
765
+ if (imageUpload) {
766
+ chooseImage(this.quill, imageUpload);
767
+ return;
768
+ }
316
769
  const range = this.quill.getSelection();
317
770
  const value = prompt("Enter image URL:");
318
771
  if (value) {
@@ -345,11 +798,21 @@ var QuillHelper = class {
345
798
  }
346
799
  },
347
800
  imageResize: { displaySize: true },
348
- noDragDrop: true,
349
- pasteGuard: true
801
+ ...imageUpload ? {
802
+ uploader: imageUploaderModule(imageUpload),
803
+ imageDropHint: { label: imageUpload.dropLabel },
804
+ imageLinkImport: {
805
+ importUrl: imageUpload.importUrl,
806
+ busyLabel: imageUpload.busyLabel
807
+ },
808
+ pasteGuard: { allowImageFiles: true }
809
+ } : {
810
+ noDragDrop: true,
811
+ pasteGuard: true
812
+ }
350
813
  };
351
814
  }
352
815
  };
353
- export { PASTED_IMAGE_MESSAGE, PasteGuard, QuillHelper, clipboardHasImageFile, isEmbeddedImageSrc };
816
+ export { EDITOR_IMAGE_TYPES, EditorImageUploadDirective, ImageDropHint, PASTED_IMAGE_MESSAGE, PasteGuard, QuillHelper, chooseImage, clipboardHasImageFile, editorImageUpload, imageUploaderModule, insertUploadedImages, isEmbeddedImageSrc, pickImageFiles, wireImageUpload };
354
817
 
355
818
  //# sourceMappingURL=posiwise-utils-quill.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"posiwise-utils-quill.mjs","names":[],"sources":["../../../../libs/utils/quill/src/lib/quill-paste-guard.ts","../../../../libs/utils/quill/src/lib/quill-helper.ts"],"sourcesContent":["import Quill from 'quill';\n\n/**\n * Stops an image being PASTED into a Quill editor as an inline `data:` URI.\n *\n * Quill's default clipboard module turns a pasted screenshot into\n * `<img src=\"data:image/png;base64,…\">`, which stores the entire file inside the document. The\n * toolbar's image button cannot do this (it prompts for a URL) and dropped images are stripped by\n * NoDragDrop, so paste was the one remaining way in — and it was unhandled in this shared config,\n * which eleven editors across the app rely on.\n *\n * It is not merely a size problem. Embedded bytes bypass the image host and its CDN, cannot be\n * cached, resized or replaced, and are re-sent from the database on every page view. One live\n * CloudOlive post reached 1.4 MB from nine pasted PNGs, against 19 KB of actual prose.\n *\n * main-api rejects these on save as the backstop; this is the prevention, and the reason an author\n * finds out while they are still writing rather than when they press save.\n */\n\nconst DATA_URI_IMAGE = /^data:image\\//i;\n\nexport const PASTED_IMAGE_MESSAGE =\n 'That image was pasted, so it would be stored inside the article itself rather than on the ' +\n 'image host — which makes the page much heavier for every reader. Upload the image somewhere ' +\n 'first, then use the image button in the toolbar to add it by URL.';\n\n/** True when the clipboard carries an image FILE — a screenshot, or an image copied from disk. */\nexport function clipboardHasImageFile(clipboardData: DataTransfer | null | undefined): boolean {\n if (!clipboardData) {\n return false;\n }\n const items = Array.from(clipboardData.items ?? []);\n if (items.some(item => item.kind === 'file' && item.type?.startsWith('image/'))) {\n return true;\n }\n // Safari populates `files` without always setting `items[].kind`, so check both.\n return Array.from(clipboardData.files ?? []).some(file => file.type?.startsWith('image/'));\n}\n\n/** True when this src embeds the file in the document instead of referencing it. */\nexport function isEmbeddedImageSrc(src: string | null | undefined): boolean {\n return DATA_URI_IMAGE.test((src ?? '').trim());\n}\n\n/**\n * Quill module. Register once, then enable with `pasteGuard: true` (or\n * `pasteGuard: { onBlocked: fn }` to replace the default alert with a toast).\n */\nexport class PasteGuard {\n private readonly notify: (message: string) => void;\n\n constructor(quill: Quill, options?: { onBlocked?: (message: string) => void }) {\n this.notify = options?.onBlocked ?? (message => globalThis.alert?.(message));\n\n // Capture phase: run before Quill's own clipboard handler turns the file into a delta.\n quill.root.addEventListener(\n 'paste',\n event => this.handlePaste(event as ClipboardEvent),\n true\n );\n\n // A separate vector: pasting HTML copied from another page, which can carry a `data:` <img>\n // with no file on the clipboard at all. Quill matches on the parsed DOM, so drop those\n // there — and leave https images alone, since pasting a real image URL is fine.\n // Quill types the matcher's first argument as Node, so narrow before reading the attribute.\n const Delta = Quill.import('delta');\n quill.clipboard.addMatcher('IMG', (node: Node, delta) => {\n const src = node instanceof Element ? node.getAttribute('src') : null;\n if (!isEmbeddedImageSrc(src)) {\n return delta;\n }\n this.notify(PASTED_IMAGE_MESSAGE);\n return new Delta();\n });\n }\n\n private handlePaste(event: ClipboardEvent): void {\n if (!clipboardHasImageFile(event.clipboardData)) {\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n this.notify(PASTED_IMAGE_MESSAGE);\n }\n}\n","import Quill from 'quill';\nimport * as ImageResize from 'quill-resize-image';\n\nimport { PasteGuard } from './quill-paste-guard';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst BlockEmbed = Quill.import('formats/image') as any;\n\nclass NoDragImage extends BlockEmbed {\n static create(value) {\n const node = super.create();\n node.setAttribute('src', value.url);\n node.setAttribute('alt', value.alt || '');\n node.setAttribute('class', 'no-drag-image');\n node.setAttribute('draggable', 'false');\n\n node.style.width = value.width || '300px'; // Default width\n node.style.height = value.height || 'auto';\n\n if (value.align) {\n switch (value.align) {\n case 'left':\n node.style.float = 'left';\n node.style.marginRight = '1em';\n break;\n case 'right':\n node.style.float = 'right';\n node.style.marginLeft = '1em';\n break;\n case 'center':\n node.style.display = 'block';\n node.style.marginLeft = 'auto';\n node.style.marginRight = 'auto';\n break;\n default:\n node.style.float = 'none';\n }\n }\n\n return node;\n }\n\n static value(node) {\n return {\n url: node.getAttribute('src'),\n alt: node.getAttribute('alt'),\n width: node.getAttribute('data-width') || node.style.width,\n height: node.getAttribute('data-height') || node.style.height,\n align: node.style.float || 'center'\n };\n }\n}\n\nclass NoDragDrop {\n constructor(quill, _options) {\n quill.root.addEventListener('drop', this.handleDrop.bind(this, quill));\n quill.root.addEventListener('dragover', this.preventDefault);\n }\n\n preventDefault(e) {\n e.preventDefault();\n e.stopPropagation();\n }\n\n handleDrop(quill, e) {\n this.preventDefault(e);\n\n // Create a MutationObserver to detect inserted images\n const observer = new MutationObserver(mutations => {\n this.removeInsertedImages(quill, mutations);\n });\n\n // Start observing for added nodes\n observer.observe(quill.root, { childList: true, subtree: true });\n\n // Stop observing after a short delay\n setTimeout(() => {\n observer.disconnect();\n }, 1000); // Adjust the timeout as needed\n }\n\n removeInsertedImages(quill, mutations) {\n mutations.forEach(mutation => {\n mutation.addedNodes.forEach(node => {\n if (node instanceof HTMLImageElement) {\n node.remove();\n } else if (node.nodeType === Node.ELEMENT_NODE) {\n node.querySelectorAll('img').forEach(img => img.remove());\n }\n });\n });\n }\n}\n\nNoDragImage['blotName'] = 'no-drag-image';\nNoDragImage['tagName'] = 'img';\nQuill.register(NoDragImage);\nQuill.register('modules/noDragDrop', NoDragDrop);\nQuill.register('modules/imageResize', ImageResize.default || ImageResize);\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst BlockEmbedVideo = Quill.import('blots/block/embed') as any;\nclass NoDragVideo extends BlockEmbedVideo {\n static create(value) {\n const node = document.createElement('iframe');\n node.setAttribute('src', value.url);\n node.setAttribute('frameborder', '0');\n node.setAttribute('allowfullscreen', 'true');\n node.setAttribute('width', value.width || '100%'); // Default width\n node.setAttribute('height', value.height || '200px'); // Default height\n node.setAttribute('class', 'no-drag-media');\n node.setAttribute('contenteditable', 'false'); // Prevent content from being editable\n\n // Add proper allow attribute for YouTube and other video embeds\n if (value.url && (value.url.includes('youtube.com') || value.url.includes('youtu.be'))) {\n node.setAttribute(\n 'allow',\n 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share'\n );\n // Ensure YouTube embed URL format is correct\n if (\n value.url &&\n !value.url.includes('youtube-nocookie.com') &&\n !value.url.includes('enablejsapi=1')\n ) {\n try {\n const url = new URL(value.url);\n url.searchParams.set('enablejsapi', '1');\n if (typeof window !== 'undefined' && window.location) {\n url.searchParams.set('origin', window.location.origin);\n }\n node.setAttribute('src', url.toString());\n } catch {\n // If URL parsing fails, keep original src and just add query params manually\n const separator = value.url.includes('?') ? '&' : '?';\n node.setAttribute('src', `${value.url}${separator}enablejsapi=1`);\n }\n }\n } else if (value.url && value.url.includes('loom.com')) {\n node.setAttribute(\n 'allow',\n 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture'\n );\n } else {\n // Default allow for other iframes\n node.setAttribute('allow', 'fullscreen');\n }\n\n // Create a container for both video/iframe and buttons\n const container = document.createElement('div');\n container.setAttribute('class', 'media-container');\n container.style.position = 'relative';\n container.style.width = '100%';\n container.style.height = 'auto';\n container.appendChild(node); // Append video/iframe to the container\n\n // Append remove button so video can be deleted after save/update (backspace often doesn't work on reloaded content)\n if (!container.querySelector('.media-remove-button')) {\n const removeButton = this.createRemoveButton(container);\n removeButton.setAttribute('contenteditable', 'false');\n container.appendChild(removeButton);\n }\n\n // Append align buttons if not already present\n if (!container.querySelector('.media-align-buttons')) {\n const alignButtons = this.createAlignButtons(container);\n alignButtons.setAttribute('contenteditable', 'false'); // Prevent buttons from being editable\n container.appendChild(alignButtons);\n }\n\n // Append resize buttons if not already present\n if (!container.querySelector('.media-resize-buttons')) {\n const resizeButtons = this.createResizeButtons(container);\n resizeButtons.setAttribute('contenteditable', 'false'); // Prevent buttons from being editable\n container.appendChild(resizeButtons);\n }\n\n container.setAttribute('contenteditable', 'false'); // Prevent the entire container from being editable\n\n return container;\n }\n\n static createAlignButtons(container) {\n const buttonContainer = document.createElement('div');\n buttonContainer.setAttribute('class', 'media-align-buttons');\n buttonContainer.style.position = 'absolute';\n buttonContainer.style.top = '0';\n buttonContainer.style.right = '0';\n buttonContainer.style.display = 'flex';\n buttonContainer.setAttribute('contenteditable', 'false'); // Prevent buttons from being editable\n\n const leftButton = this.createButton('Left', () => {\n container.style.textAlign = 'left';\n container.setAttribute('data-align', 'left'); // Save alignment\n });\n\n const centerButton = this.createButton('Center', () => {\n container.style.textAlign = 'center';\n container.setAttribute('data-align', 'center'); // Save alignment\n });\n\n const rightButton = this.createButton('Right', () => {\n container.style.textAlign = 'right';\n container.setAttribute('data-align', 'right'); // Save alignment\n });\n\n buttonContainer.appendChild(leftButton);\n buttonContainer.appendChild(centerButton);\n buttonContainer.appendChild(rightButton);\n\n return buttonContainer;\n }\n\n static createRemoveButton(container) {\n const wrapper = document.createElement('div');\n wrapper.setAttribute('class', 'media-remove-button');\n wrapper.style.position = 'absolute';\n wrapper.style.top = '0';\n wrapper.style.left = '0';\n wrapper.style.display = 'flex';\n wrapper.setAttribute('contenteditable', 'false');\n\n const removeButton = this.createButton('Remove', () => {\n const mediaContainer = container.classList.contains('media-container')\n ? container\n : container.closest('.media-container');\n if (mediaContainer) {\n const blot = Quill.find(mediaContainer);\n if (blot && 'remove' in blot && typeof blot.remove === 'function') {\n (blot as { remove: () => void }).remove();\n } else {\n // Content loaded from saved HTML may not be a Quill blot; remove from DOM so save persists the change\n mediaContainer.remove();\n }\n }\n });\n removeButton.style.background = 'rgb(243, 67, 67)';\n removeButton.style.color = 'white';\n removeButton.style.border = 'none';\n removeButton.style.padding = '2px 8px';\n removeButton.style.marginTop = '2px';\n removeButton.style.borderRadius = '4px';\n removeButton.title = 'Remove video';\n wrapper.appendChild(removeButton);\n\n return wrapper;\n }\n\n static createResizeButtons(container) {\n const buttonContainer = document.createElement('div');\n buttonContainer.setAttribute('class', 'media-resize-buttons');\n buttonContainer.style.position = 'absolute';\n buttonContainer.style.bottom = '5px'; // Adjust position above the bottom edge\n buttonContainer.style.right = '5px';\n buttonContainer.style.display = 'flex';\n buttonContainer.setAttribute('contenteditable', 'false'); // Prevent buttons from being editable\n\n const updateWidthAndHeight = (mediaElement, width, height) => {\n mediaElement.style.width = width;\n mediaElement.style.height = height;\n container.setAttribute('data-width', width); // Save width\n container.setAttribute('data-height', height); // Save height\n };\n\n const increaseWidthButton = this.createButton('Increase Width', () => {\n const mediaElement = container.querySelector('.no-drag-media');\n const currentWidth = parseInt(mediaElement.style.width || '100%');\n updateWidthAndHeight(mediaElement, `${currentWidth + 20}px`, mediaElement.style.height);\n });\n\n const decreaseWidthButton = this.createButton('Decrease Width', () => {\n const mediaElement = container.querySelector('.no-drag-media');\n const currentWidth = parseInt(mediaElement.style.width || '100%');\n updateWidthAndHeight(\n mediaElement,\n `${Math.max(100, currentWidth - 20)}px`,\n mediaElement.style.height\n );\n });\n\n const increaseHeightButton = this.createButton('Increase Height', () => {\n const mediaElement = container.querySelector('.no-drag-media');\n const currentHeight = parseInt(mediaElement.style.height || '200px'); // Default height\n updateWidthAndHeight(mediaElement, mediaElement.style.width, `${currentHeight + 20}px`);\n });\n\n const decreaseHeightButton = this.createButton('Decrease Height', () => {\n const mediaElement = container.querySelector('.no-drag-media');\n const currentHeight = parseInt(mediaElement.style.height || '200px'); // Default height\n updateWidthAndHeight(\n mediaElement,\n mediaElement.style.width,\n `${Math.max(100, currentHeight - 20)}px`\n );\n });\n\n buttonContainer.appendChild(increaseWidthButton);\n buttonContainer.appendChild(decreaseWidthButton);\n buttonContainer.appendChild(increaseHeightButton);\n buttonContainer.appendChild(decreaseHeightButton);\n\n return buttonContainer;\n }\n\n static createButton(label, onClick) {\n const button = document.createElement('button');\n button.innerHTML = label;\n button.style.margin = '0 5px';\n button.style.cursor = 'pointer';\n\n // Prevent Quill from treating this as part of the content\n button.setAttribute('contenteditable', 'false');\n button.style.pointerEvents = 'auto'; // Allow button clicks but don't let Quill interact with them\n\n button.onclick = event => {\n event.preventDefault(); // Prevent default action\n event.stopPropagation(); // Prevent the event from bubbling up and being interpreted by Quill\n onClick(); // Execute the button's action\n };\n\n return button;\n }\n\n static value(container) {\n const iframe = container.querySelector('iframe');\n return {\n url: iframe?.getAttribute('src'),\n width: container.getAttribute('data-width') || iframe?.getAttribute('width'),\n height: container.getAttribute('data-height') || iframe?.getAttribute('height'),\n align: container.getAttribute('data-align') || 'center' // Default to center if no alignment\n };\n }\n}\n\nNoDragVideo['blotName'] = 'no-drag-video';\nNoDragVideo['tagName'] = 'div'; // TagName is set to div to hold buttons\nQuill.register(NoDragVideo);\n\nexport class QuillHelper {\n static init() {\n if (!Quill.imports['formats/no-drag-image']) {\n Quill.register(NoDragImage);\n }\n if (!Quill.imports['formats/no-drag-video']) {\n Quill.register(NoDragVideo);\n }\n if (!Quill.imports['modules/imageResize']) {\n Quill.register('modules/imageResize', ImageResize.default || ImageResize);\n }\n if (!Quill.imports['modules/noDragDrop']) {\n Quill.register('modules/noDragDrop', NoDragDrop);\n }\n if (!Quill.imports['modules/pasteGuard']) {\n Quill.register('modules/pasteGuard', PasteGuard);\n }\n }\n\n static getEditorConfig(additionalToolbarConfig = []) {\n const defaultToolbarConfig = [\n ['bold', 'italic', 'underline', 'strike'], // toggled buttons\n ['blockquote', 'code-block'],\n [{ header: 1 }, { header: 2 }], // custom button values\n [{ list: 'ordered' }, { list: 'bullet' }],\n [{ script: 'sub' }, { script: 'super' }], // superscript/subscript\n [{ indent: '-1' }, { indent: '+1' }], // outdent/indent\n [{ direction: 'rtl' }], // text direction\n [{ header: [1, 2, 3, 4, 5, 6, false] }],\n [{ color: [] }, { background: [] }], // dropdown with defaults from theme\n [{ align: [] }],\n ['link', 'image', 'video'],\n ['clean'], // remove formatting button\n ['table'] // table button\n ];\n\n const mergedToolbarConfig = [...defaultToolbarConfig, ...additionalToolbarConfig];\n\n return {\n toolbar: {\n container: mergedToolbarConfig,\n handlers: {\n image: function () {\n const range = this.quill.getSelection();\n const value = prompt('Enter image URL:');\n if (value) {\n this.quill.insertEmbed(range.index, 'no-drag-image', { url: value });\n this.quill.insertText(range.index + 1, '\\n', Quill.sources.USER);\n }\n },\n video: function () {\n const range = this.quill.getSelection();\n let value = prompt('Enter video URL:');\n if (value?.includes('youtube.com/watch?v=')) {\n const videoId = value.split('v=')[1];\n value = `https://www.youtube.com/embed/${videoId}`;\n } else if (value?.includes('youtu.be/')) {\n const videoId = value.split('.be/')[1];\n value = `https://www.youtube.com/embed/${videoId}`;\n } else if (value?.includes('loom.com/share/')) {\n const videoId = value.split('share/')[1];\n value = `https://www.loom.com/embed/${videoId}`;\n } else if (value?.includes('capture.dropbox.com/')) {\n const videoId = value.split('capture.dropbox.com/')[1];\n if (videoId.includes('embed')) {\n value = `https://capture.dropbox.com/${videoId}`;\n } else {\n value = `https://capture.dropbox.com/embed/${videoId}`;\n }\n }\n if (value) {\n const useIframe =\n value.includes('youtube.com') ||\n value.includes('youtu.be') ||\n value.includes('loom.com') ||\n value.includes('drop');\n this.quill.insertEmbed(range.index, 'no-drag-video', {\n url: value,\n isEdit: true,\n width: useIframe ? '560px' : '640px', // Different width for iframe vs video\n height: useIframe ? '315px' : '360px' // Different height for iframe vs video\n });\n this.quill.insertText(range.index + 1, '\\n', Quill.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Q,qCAAqC;MAErD;MACA,IAAI,OAAO;OACP,MAAM,YACF,MAAM,SAAS,aAAa,KAC5B,MAAM,SAAS,UAAU,KACzB,MAAM,SAAS,UAAU,KACzB,MAAM,SAAS,MAAM;OACzB,KAAK,MAAM,YAAY,MAAM,OAAO,iBAAiB;QACjD,KAAK;QACL,QAAQ;QACR,OAAO,YAAY,UAAU;QAC7B,QAAQ,YAAY,UAAU;OACjC,CAAA;OACD,KAAK,MAAM,WAAW,MAAM,QAAQ,GAAG,MAAM,MAAM,QAAQ,IAAI;MACnE;KACJ;IACH;GACJ;GACD,aAAa,EACT,aAAa,KAChB;GACD,YAAY;GACZ,YAAY;EACf;CACL;AACH"}
1
+ {"version":3,"file":"posiwise-utils-quill.mjs","names":[],"sources":["../../../../libs/utils/quill/src/lib/quill-image-preview.ts","../../../../libs/utils/quill/src/lib/quill-upload-indicator.ts","../../../../libs/utils/quill/src/lib/quill-image-upload.ts","../../../../libs/utils/quill/src/lib/editor-image-dialog/editor-image-dialog.component.ts","../../../../libs/utils/quill/src/lib/editor-image-dialog/editor-image-dialog.component.html","../../../../libs/utils/quill/src/lib/quill-default-image-upload.ts","../../../../libs/utils/quill/src/lib/quill-image-link-import.ts","../../../../libs/utils/quill/src/lib/quill-paste-guard.ts","../../../../libs/utils/quill/src/lib/editor-image-upload.directive.ts","../../../../libs/utils/quill/src/lib/quill-no-drag-image.ts","../../../../libs/utils/quill/src/lib/quill-video-controls.ts","../../../../libs/utils/quill/src/lib/quill-no-drag-video.ts","../../../../libs/utils/quill/src/lib/quill-helper.ts"],"sourcesContent":["import Quill from 'quill';\n\ntype PreviewQuill = Pick<Quill, 'insertEmbed' | 'insertText' | 'deleteText' | 'getContents'> & {\n getModule?: (name: string) => unknown;\n};\n\ntype HistoryModule = { ignoreChange: boolean; transform: (delta: unknown) => void };\n\nconst EMBED = 'no-drag-image';\n\n/**\n * Applies a change that undo must not record (the temporary preview), while still moving undo's\n * stored positions past it. Without this, Undo could bring back a preview whose local file is gone.\n */\nfunction outsideHistory(quill: PreviewQuill, change: () => unknown): void {\n const history = quill.getModule?.('history') as HistoryModule | null | undefined;\n if (!history) {\n change();\n return;\n }\n history.ignoreChange = true;\n let delta: unknown;\n try {\n delta = change();\n } finally {\n history.ignoreChange = false;\n }\n if (delta) {\n history.transform(delta);\n }\n}\n\n/** Where the image with `url` is now; the user may have typed or deleted around it. */\nfunction indexOfImage(quill: PreviewQuill, url: string): number {\n let index = 0;\n for (const op of quill.getContents().ops) {\n const insert = op.insert as string | Record<string, { url?: string }> | undefined;\n if (typeof insert === 'object' && insert?.[EMBED]?.url === url) {\n return index;\n }\n index += typeof insert === 'string' ? insert.length : 1;\n }\n return -1;\n}\n\n/**\n * Shows a picked or pasted image file in the text straight away, dimmed, while it uploads\n * (posiwise-frontend#4272), like GitLab. The preview points at a local copy of the file, so it is\n * only ever temporary: the returned function swaps it for the uploaded image's URL (resolving with\n * the index after it), or removes it when the upload failed or the user deleted it meanwhile\n * (resolving with null). Without browser support for local copies it returns null and the caller\n * inserts the image when the upload finishes, as before.\n */\nexport function showImagePreview(\n quill: PreviewQuill,\n index: number,\n file: File\n): ((url: string | null) => number | null) | null {\n if (typeof URL.createObjectURL !== 'function') {\n return null;\n }\n const local = URL.createObjectURL(file);\n outsideHistory(quill, () => quill.insertEmbed(index, EMBED, { url: local }, Quill.sources.API));\n outsideHistory(quill, () => quill.insertText(index + 1, '\\n', Quill.sources.API));\n\n return url => {\n const at = indexOfImage(quill, local);\n if (at >= 0) {\n outsideHistory(quill, () => quill.deleteText(at, 1, Quill.sources.API));\n }\n URL.revokeObjectURL(local);\n if (at < 0 || !url) {\n return null;\n }\n quill.insertEmbed(at, EMBED, { url }, Quill.sources.USER);\n return at + 2;\n };\n}\n","/** What the indicator needs from an editor; a real Quill has both. */\nexport type IndicatorQuill = { root: HTMLElement; container?: HTMLElement };\n\nconst HOST_CLASS = 'ql-upload-host';\nconst CHIP_CLASS = 'ql-upload-indicator';\n\n/**\n * Shows the app's spinner with `label` in a chip centred on the line between the toolbar and the\n * text while an image uploads (posiwise-frontend#4272), like GitLab's, and returns a function that\n * removes it. The chip sits on the editor's wrapper, outside the content, so it never covers the\n * text and is never saved; not in `.ql-container`, whose scrolling would clip it. Styled by\n * `.ql-upload-indicator` (core-styles); only its height comes from here, because the toolbar's\n * height varies by editor and screen width.\n */\nexport function showUploadIndicator(quill: IndicatorQuill, label = ''): () => void {\n const container = quill.container ?? quill.root.parentElement;\n const host = container?.parentElement;\n if (!container || !host) {\n return () => undefined;\n }\n host.classList.add(HOST_CLASS);\n const doc = host.ownerDocument;\n const chip = doc.createElement('div');\n chip.className = CHIP_CLASS;\n chip.setAttribute('role', 'status');\n const spinner = doc.createElement('i');\n spinner.className = 'fa fa-spinner fa-spin';\n spinner.setAttribute('aria-hidden', 'true');\n chip.append(spinner, ` ${label}`);\n chip.style.setProperty('--upload-top', `${container.offsetTop}px`);\n host.append(chip);\n return () => {\n chip.remove();\n if (!host.querySelector(`.${CHIP_CLASS}`)) {\n host.classList.remove(HOST_CLASS);\n }\n };\n}\n","import Quill from 'quill';\n\nimport { showImagePreview } from './quill-image-preview';\nimport { IndicatorQuill, showUploadIndicator } from './quill-upload-indicator';\n\n/**\n * Uploading images from a Quill editor (posiwise-frontend#4272).\n *\n * The file goes to S3 through main-api and the editor inserts only its URL, so no image bytes are\n * ever stored in the document. The image button, paste and drop all end in `insertUploadedImages`.\n */\n\n/** Uploads one file and resolves with its public URL. Rejects after telling the user why. */\nexport type QuillImageUploader = (file: File) => Promise<string>;\n\n/** What the user picked in the \"Add image\" box. */\nexport type EditorImageChoice = { url: string } | { files: File[] };\n\nexport interface QuillImageUploadOptions {\n upload: QuillImageUploader;\n /** Copies an image from a link into our storage and resolves with OUR URL. */\n importUrl?: (url: string) => Promise<string>;\n /** Asks the user for a link or files. Without it the image button opens the file picker. */\n choose?: () => Promise<EditorImageChoice | null>;\n /** Text shown over the editor while an image is dragged onto it. */\n dropLabel?: () => string;\n /** Text next to the spinner shown in the body while an image uploads. */\n busyLabel?: () => string;\n}\n\n/** Mirrors main-api's `main_api_editor_image` purpose. No SVG: it can carry script. */\nexport const EDITOR_IMAGE_TYPES = ['image/png', 'image/jpeg', 'image/gif', 'image/webp'];\n\ntype EditorQuill = Pick<\n Quill,\n 'insertEmbed' | 'insertText' | 'deleteText' | 'getContents' | 'setSelection' | 'getSelection'\n> &\n IndicatorQuill & { getModule?: (name: string) => unknown };\n\nfunction insertImageUrl(quill: EditorQuill, index: number, url: string): void {\n quill.insertEmbed(index, 'no-drag-image', { url }, Quill.sources.USER);\n quill.insertText(index + 1, '\\n', Quill.sources.USER);\n}\n\n/**\n * Uploads one file (or link) and puts the image at `at`. A file shows a dimmed preview there\n * meanwhile; a link has no local copy to preview. Resolves with where the next image goes.\n */\nasync function uploadOne<T>(\n quill: EditorQuill,\n at: number,\n item: T,\n toUrl: (item: T) => Promise<string>,\n busyLabel?: string\n): Promise<number> {\n const hide = showUploadIndicator(quill, busyLabel);\n const settlePreview = item instanceof File ? showImagePreview(quill, at, item) : null;\n let url: string | null;\n try {\n url = await toUrl(item).catch(() => null);\n } finally {\n hide();\n }\n if (settlePreview) {\n return settlePreview(url) ?? at;\n }\n if (!url) {\n return at;\n }\n insertImageUrl(quill, at, url);\n return at + 2;\n}\n\n/**\n * Turns each file (or link) into our URL one after another and inserts the images at `index`, in\n * order. A spinner chip shows on the editor's top edge, and the editor is `aria-busy` meanwhile,\n * which also holds its form's save button (buttonBusy).\n */\nexport async function insertUploadedImages<T>(\n quill: EditorQuill,\n index: number,\n items: T[],\n toUrl: (item: T) => Promise<string>,\n busyLabel?: string\n): Promise<void> {\n let at = index;\n quill.root.setAttribute('aria-busy', 'true');\n try {\n for (const item of items) {\n const next = await uploadOne(quill, at, item, toUrl, busyLabel);\n if (next !== at) {\n at = next;\n quill.setSelection(at, Quill.sources.SILENT);\n }\n }\n } finally {\n quill.root.removeAttribute('aria-busy');\n }\n}\n\n/** Opens the browser's file picker for images. Must run inside a click handler. */\nexport function pickImageFiles(onPicked: (files: File[]) => void, doc: Document = document): void {\n const input = doc.createElement('input');\n input.type = 'file';\n input.accept = EDITOR_IMAGE_TYPES.join(',');\n input.multiple = true;\n input.addEventListener('change', () => {\n const files = Array.from(input.files ?? []);\n if (files.length) {\n onPicked(files);\n }\n });\n input.click();\n}\n\n/** Image button: a link is inserted as it is, chosen files are uploaded. */\nexport async function chooseImage(\n quill: EditorQuill,\n options: QuillImageUploadOptions\n): Promise<void> {\n const index = quill.getSelection(true)?.index ?? 0;\n if (!options.choose) {\n pickImageFiles(files =>\n insertUploadedImages(quill, index, files, options.upload, options.busyLabel?.())\n );\n return;\n }\n const choice = await options.choose();\n if (!choice) {\n return;\n }\n if ('url' in choice) {\n insertImageUrl(quill, index, choice.url);\n } else {\n await insertUploadedImages(\n quill,\n index,\n choice.files,\n options.upload,\n options.busyLabel?.()\n );\n }\n}\n\n/** Quill `uploader` module config: Quill hands it every pasted or dropped file. */\nexport function imageUploaderModule(options: QuillImageUploadOptions) {\n return {\n mimetypes: EDITOR_IMAGE_TYPES,\n handler(this: { quill: EditorQuill }, range: { index: number }, files: File[]) {\n insertUploadedImages(\n this.quill,\n range.index,\n files,\n options.upload,\n options.busyLabel?.()\n );\n }\n };\n}\n\nconst DROP_CLASS = 'ql-image-drop';\n\n/**\n * Quill module: highlights the editor only while a file is dragged over it, so the drop target is\n * clear without a permanent hint in the text. Styled by `.ql-container.ql-image-drop` (core-styles).\n */\nexport class ImageDropHint {\n constructor(quill: { container: HTMLElement }, options?: { label?: () => string }) {\n const container = quill.container;\n const show = (event: DragEvent) => {\n if (Array.from(event.dataTransfer?.types ?? []).includes('Files')) {\n container.setAttribute('data-drop-label', options?.label?.() ?? '');\n container.classList.add(DROP_CLASS);\n }\n };\n const hide = (event: DragEvent) => {\n if (event.type === 'drop' || !container.contains(event.relatedTarget as Node | null)) {\n container.classList.remove(DROP_CLASS);\n }\n };\n container.addEventListener('dragenter', show);\n container.addEventListener('dragover', show);\n container.addEventListener('dragleave', hide);\n container.addEventListener('drop', hide);\n }\n}\n","import { ChangeDetectionStrategy, ChangeDetectorRef, Component, inject } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\n\nimport { ButtonBusyDirective } from '@posiwise/directives';\n\nimport { TranslocoPipe } from '@jsverse/transloco';\nimport { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';\n\nimport { EDITOR_IMAGE_TYPES, EditorImageChoice } from '../quill-image-upload';\n\nconst LINK = /^https?:\\/\\/\\S+$/i;\n\n/**\n * \"Add image\" box opened by the editor's image button (posiwise-frontend#4272): add by link, or\n * upload from the computer. A link is copied into our storage first (`importUrl`) and the box\n * returns OUR URL, so the body never points at another site. The upload button is its own click, so\n * the browser always lets it open the file picker.\n */\n@Component({\n selector: 'pw-editor-image-dialog',\n templateUrl: './editor-image-dialog.component.html',\n styleUrl: './editor-image-dialog.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [ButtonBusyDirective, FormsModule, TranslocoPipe]\n})\nexport class EditorImageDialogComponent {\n readonly modal = inject(NgbActiveModal);\n private readonly cdr = inject(ChangeDetectorRef);\n readonly accept = EDITOR_IMAGE_TYPES.join(',');\n\n /** Copies the linked image into our storage; set by `openEditorImageDialog`. */\n importUrl: (url: string) => Promise<string>;\n link = '';\n triedLink = false;\n importing = false;\n\n get linkValid(): boolean {\n return LINK.test(this.link.trim());\n }\n\n async addLink(): Promise<void> {\n this.triedLink = true;\n if (!this.linkValid || this.importing) {\n return;\n }\n this.importing = true;\n try {\n const url = await this.importUrl(this.link.trim());\n this.modal.close({ url } satisfies EditorImageChoice);\n } catch {\n // main-api's error toast says why; the box stays open to try another link.\n } finally {\n this.importing = false;\n this.cdr.markForCheck();\n }\n }\n\n filesPicked(input: HTMLInputElement): void {\n const files = Array.from(input.files ?? []);\n if (files.length) {\n this.modal.close({ files } satisfies EditorImageChoice);\n }\n }\n}\n\n/** Resolves with what the user chose (a link already copied to our URL), or null when closed. */\nexport function openEditorImageDialog(\n modal: NgbModal,\n importUrl: (url: string) => Promise<string>\n): Promise<EditorImageChoice | null> {\n // Not closable mid-copy: closing would drop an image that is already being stored.\n const ref = modal.open(EditorImageDialogComponent, {\n centered: true,\n size: 'md',\n beforeDismiss: () => !dialog?.importing\n });\n // Read lazily by beforeDismiss, i.e. only after this line has run.\n const dialog = ref.componentInstance as EditorImageDialogComponent;\n dialog.importUrl = importUrl;\n return ref.result.then(\n (choice: EditorImageChoice) => choice ?? null,\n () => null\n );\n}\n","<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","import { inject } from '@angular/core';\nimport { ActivatedRoute } from '@angular/router';\n\nimport { EditorImageUploadService, PermissionService } from '@posiwise/common-services';\n\nimport { translate } from '@jsverse/transloco';\nimport { NgbModal } from '@ng-bootstrap/ng-bootstrap';\n\nimport { openEditorImageDialog } from './editor-image-dialog/editor-image-dialog.component';\nimport { QuillImageUploadOptions } from './quill-image-upload';\n\n/**\n * Image upload for every editor built with `QuillHelper.getEditorConfig()` (posiwise-frontend#4272),\n * without each component wiring it: the editors build their config in their constructor, where\n * `inject` works. Images go to the subscription the user has selected, which is the one these\n * editors save their content to.\n *\n * Outside an injection context (plain code, unit tests) it returns undefined and the editor keeps\n * the URL-only image button.\n */\nexport function defaultImageUpload(): QuillImageUploadOptions | undefined {\n let route: ActivatedRoute | null;\n try {\n route = inject(ActivatedRoute, { optional: true });\n } catch {\n return undefined;\n }\n return editorImageUpload(() => uploadSubscriptionId(route));\n}\n\n/**\n * Same as `defaultImageUpload`, for an editor that saves its content to a subscription it resolves\n * itself (e.g. from the route or local storage). Call it from a constructor or field initialiser:\n * `QuillHelper.getEditorConfig([], editorImageUpload(() => this.subscriptionId))`.\n */\nexport function editorImageUpload(\n subscriptionId: () => number | null | undefined\n): QuillImageUploadOptions | undefined {\n let service: EditorImageUploadService | null;\n let modal: NgbModal | null;\n try {\n service = inject(EditorImageUploadService, { optional: true });\n modal = inject(NgbModal, { optional: true });\n } catch {\n return undefined;\n }\n if (!service) {\n return undefined;\n }\n const { upload, importUrl } = service.forSubscription(subscriptionId);\n return {\n upload,\n importUrl,\n choose: modal ? () => openEditorImageDialog(modal, importUrl) : undefined,\n dropLabel: () => translate('Common.Upload.Image.Drop'),\n busyLabel: () => translate('Common.Upload.Image.Uploading')\n };\n}\n\n/**\n * The selected subscription, read at upload time. On a subscription page (`/:slug/...`) it must be\n * that slug's subscription; if the two ever differ, no subscription is returned and the upload is\n * refused rather than stored under another subscription. A `slug` deeper in the URL names a record\n * (e.g. `/admin/resources/:slug`), not a subscription, and is ignored.\n */\nexport function uploadSubscriptionId(route: ActivatedRoute | null): number | undefined {\n const selected = PermissionService.selectedSubscription;\n const path = route?.snapshot?.pathFromRoot ?? [];\n const firstSegment = path.flatMap(r => r.url ?? []).map(segment => segment.path)[0];\n const slug = path.map(r => r.params?.['slug']).find(value => value && value === firstSegment);\n if (slug && selected?.slug !== slug) {\n return undefined;\n }\n return selected?.id;\n}\n","import Quill from 'quill';\n\nimport { insertUploadedImages } from './quill-image-upload';\n\n/**\n * Keeps editor bodies on our own storage (posiwise-frontend#4272): an image pasted from a web page,\n * or dragged in from another site, arrives as a link to that site. This module takes those links\n * out of the paste/drop, copies each image into our storage (`importUrl`) and inserts OUR URL.\n * Image FILES are handled by Quill's uploader; `data:` images are refused by PasteGuard.\n */\n\nconst EXTERNAL = /^https?:\\/\\//i;\n\n/** Already ours: same-origin (`/downloads`, `/s3-local`) or an uploaded editor image. */\nexport function isOwnImage(src: string): boolean {\n return src.startsWith('/') || /\\/editor_images\\/\\d+\\//.test(src);\n}\n\nfunction needsImport(src: string | null | undefined): src is string {\n return !!src && EXTERNAL.test(src) && !isOwnImage(src);\n}\n\n/** External image links in dropped data: `<img src>` from HTML, else the dragged URL itself. */\nexport function droppedImageLinks(data: DataTransfer | null | undefined): string[] {\n const html = data?.getData('text/html');\n if (html) {\n const doc = new DOMParser().parseFromString(html, 'text/html');\n const srcs = Array.from(doc.images, img => img.getAttribute('src')).filter(needsImport);\n if (srcs.length) {\n return srcs;\n }\n }\n const link = data?.getData('text/uri-list')?.split('\\n')[0]?.trim();\n return needsImport(link) ? [link] : [];\n}\n\ntype ImportOptions = {\n importUrl?: (url: string) => Promise<string>;\n busyLabel?: () => string;\n};\n\n/** Quill module: `imageLinkImport: { importUrl, busyLabel }`. Does nothing without an importer. */\nexport class ImageLinkImport {\n private pending: string[] = [];\n\n constructor(\n private readonly quill: Quill,\n private readonly options?: ImportOptions\n ) {\n if (!options?.importUrl) {\n return;\n }\n const Delta = Quill.import('delta');\n quill.clipboard.addMatcher('IMG', (node: Node, delta) => {\n const src = node instanceof Element ? node.getAttribute('src') : null;\n if (!needsImport(src)) {\n return delta;\n }\n this.pending.push(src);\n return new Delta();\n });\n // Quill converts the paste synchronously; the links it set aside are copied right after.\n quill.root.addEventListener('paste', () => setTimeout(() => this.importPending(), 0));\n quill.root.addEventListener('drop', event => this.onDrop(event as DragEvent));\n }\n\n private importPending(): void {\n const links = this.pending.splice(0);\n if (links.length) {\n this.insert(links);\n }\n }\n\n private onDrop(event: DragEvent): void {\n if (event.dataTransfer?.files?.length) {\n return; // a file: Quill's uploader stores it\n }\n const links = droppedImageLinks(event.dataTransfer);\n if (links.length) {\n event.preventDefault();\n this.insert(links);\n }\n }\n\n private insert(links: string[]): void {\n const index = this.quill.getSelection(true)?.index ?? this.quill.getLength();\n insertUploadedImages(\n this.quill as never,\n index,\n links,\n this.options.importUrl,\n this.options.busyLabel?.()\n );\n }\n}\n","import Quill from 'quill';\n\n/**\n * Stops an image being PASTED into a Quill editor as an inline `data:` URI.\n *\n * Quill's default clipboard module turns a pasted screenshot into\n * `<img src=\"data:image/png;base64,…\">`, which stores the entire file inside the document. The\n * toolbar's image button cannot do this (it prompts for a URL) and dropped images are stripped by\n * NoDragDrop, so paste was the one remaining way in — and it was unhandled in this shared config,\n * which eleven editors across the app rely on.\n *\n * It is not merely a size problem. Embedded bytes bypass the image host and its CDN, cannot be\n * cached, resized or replaced, and are re-sent from the database on every page view. One live\n * CloudOlive post reached 1.4 MB from nine pasted PNGs, against 19 KB of actual prose.\n *\n * main-api rejects these on save as the backstop; this is the prevention, and the reason an author\n * finds out while they are still writing rather than when they press save.\n */\n\nconst DATA_URI_IMAGE = /^data:image\\//i;\n\nexport const PASTED_IMAGE_MESSAGE =\n 'That image was pasted, so it would be stored inside the article itself rather than on the ' +\n 'image host — which makes the page much heavier for every reader. Upload the image somewhere ' +\n 'first, then use the image button in the toolbar to add it by URL.';\n\n/** True when the clipboard carries an image FILE — a screenshot, or an image copied from disk. */\nexport function clipboardHasImageFile(clipboardData: DataTransfer | null | undefined): boolean {\n if (!clipboardData) {\n return false;\n }\n const items = Array.from(clipboardData.items ?? []);\n if (items.some(item => item.kind === 'file' && item.type?.startsWith('image/'))) {\n return true;\n }\n // Safari populates `files` without always setting `items[].kind`, so check both.\n return Array.from(clipboardData.files ?? []).some(file => file.type?.startsWith('image/'));\n}\n\n/** True when this src embeds the file in the document instead of referencing it. */\nexport function isEmbeddedImageSrc(src: string | null | undefined): boolean {\n return DATA_URI_IMAGE.test((src ?? '').trim());\n}\n\n/**\n * Quill module. Register once, then enable with `pasteGuard: true` (or\n * `pasteGuard: { onBlocked: fn }` to replace the default alert with a toast).\n */\nexport class PasteGuard {\n private readonly notify: (message: string) => void;\n private readonly allowImageFiles: boolean;\n\n /**\n * `allowImageFiles`: the editor uploads pasted image files (Quill's `uploader` module), so let\n * them through. Pasted HTML carrying a `data:` image is still dropped.\n */\n constructor(\n quill: Quill,\n options?: { onBlocked?: (message: string) => void; allowImageFiles?: boolean }\n ) {\n this.notify = options?.onBlocked ?? (message => globalThis.alert?.(message));\n this.allowImageFiles = options?.allowImageFiles ?? false;\n\n // Capture phase: run before Quill's own clipboard handler turns the file into a delta.\n quill.root.addEventListener(\n 'paste',\n event => this.handlePaste(event as ClipboardEvent),\n true\n );\n\n // A separate vector: pasting HTML copied from another page, which can carry a `data:` <img>\n // with no file on the clipboard at all. Quill matches on the parsed DOM, so drop those\n // there — and leave https images alone, since pasting a real image URL is fine.\n // Quill types the matcher's first argument as Node, so narrow before reading the attribute.\n const Delta = Quill.import('delta');\n quill.clipboard.addMatcher('IMG', (node: Node, delta) => {\n const src = node instanceof Element ? node.getAttribute('src') : null;\n if (!isEmbeddedImageSrc(src)) {\n return delta;\n }\n this.notify(PASTED_IMAGE_MESSAGE);\n return new Delta();\n });\n }\n\n private handlePaste(event: ClipboardEvent): void {\n if (this.allowImageFiles || !clipboardHasImageFile(event.clipboardData)) {\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n this.notify(PASTED_IMAGE_MESSAGE);\n }\n}\n","import { DestroyRef, Directive, inject, OnInit } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\n\nimport { QuillEditorComponent } from 'ngx-quill';\nimport type Quill from 'quill';\n\nimport { defaultImageUpload } from './quill-default-image-upload';\nimport { ImageLinkImport } from './quill-image-link-import';\nimport {\n chooseImage,\n EDITOR_IMAGE_TYPES,\n ImageDropHint,\n imageUploaderModule,\n QuillImageUploadOptions\n} from './quill-image-upload';\nimport { PasteGuard } from './quill-paste-guard';\n\n/**\n * Image upload for a `<quill-editor>` that has no `[modules]` of its own (posiwise-frontend#4272):\n * `<quill-editor pwEditorImages …>` gets the same \"Add image\" box, paste/drop upload and drop\n * highlight as editors built with `QuillHelper.getEditorConfig()`. It wires the created editor,\n * because a component's ngx-quill config can't be changed from outside.\n */\n@Directive({\n selector: '[pwEditorImages]',\n standalone: true\n})\nexport class EditorImageUploadDirective implements OnInit {\n private readonly editor = inject(QuillEditorComponent, { self: true });\n private readonly destroyRef = inject(DestroyRef);\n private readonly options = defaultImageUpload();\n\n ngOnInit(): void {\n if (!this.options) {\n return;\n }\n this.editor.onEditorCreated\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe((quill: Quill) => wireImageUpload(quill, this.options));\n }\n}\n\n/** Gives an already-created editor the image button, paste/drop upload and drop highlight. */\nexport function wireImageUpload(quill: Quill, options: QuillImageUploadOptions): void {\n const editor = quill as unknown as Parameters<typeof chooseImage>[0];\n const toolbar = quill.getModule('toolbar') as {\n addHandler(name: string, handler: () => void): void;\n } | null;\n toolbar?.addHandler('image', () => chooseImage(editor, options));\n\n const uploader = quill.getModule('uploader') as {\n options: { mimetypes?: string[]; handler?: unknown };\n } | null;\n if (uploader) {\n uploader.options.mimetypes = EDITOR_IMAGE_TYPES;\n uploader.options.handler = imageUploaderModule(options).handler;\n }\n new PasteGuard(quill, { allowImageFiles: true });\n new ImageDropHint(quill, { label: options.dropLabel });\n new ImageLinkImport(quill, { importUrl: options.importUrl, busyLabel: options.busyLabel });\n}\n","import Quill from 'quill';\nimport * as ImageResize from 'quill-resize-image';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst BlockEmbed = Quill.import('formats/image') as any;\n\nexport class NoDragImage extends BlockEmbed {\n static create(value) {\n const node = super.create();\n node.setAttribute('src', value.url);\n node.setAttribute('alt', value.alt || '');\n node.setAttribute('class', 'no-drag-image');\n node.setAttribute('draggable', 'false');\n\n node.style.width = value.width || '300px'; // Default width\n node.style.height = value.height || 'auto';\n\n if (value.align) {\n switch (value.align) {\n case 'left':\n node.style.float = 'left';\n node.style.marginRight = '1em';\n break;\n case 'right':\n node.style.float = 'right';\n node.style.marginLeft = '1em';\n break;\n case 'center':\n node.style.display = 'block';\n node.style.marginLeft = 'auto';\n node.style.marginRight = 'auto';\n break;\n default:\n node.style.float = 'none';\n }\n }\n\n return node;\n }\n\n static value(node) {\n return {\n url: node.getAttribute('src'),\n alt: node.getAttribute('alt'),\n width: node.getAttribute('data-width') || node.style.width,\n height: node.getAttribute('data-height') || node.style.height,\n align: node.style.float || 'center'\n };\n }\n}\n\nexport class NoDragDrop {\n constructor(quill, _options) {\n quill.root.addEventListener('drop', this.handleDrop.bind(this, quill));\n quill.root.addEventListener('dragover', this.preventDefault);\n }\n\n preventDefault(e) {\n e.preventDefault();\n e.stopPropagation();\n }\n\n handleDrop(quill, e) {\n this.preventDefault(e);\n\n // Create a MutationObserver to detect inserted images\n const observer = new MutationObserver(mutations => {\n this.removeInsertedImages(quill, mutations);\n });\n\n // Start observing for added nodes\n observer.observe(quill.root, { childList: true, subtree: true });\n\n // Stop observing after a short delay\n setTimeout(() => {\n observer.disconnect();\n }, 1000); // Adjust the timeout as needed\n }\n\n removeInsertedImages(quill, mutations) {\n mutations.forEach(mutation => {\n mutation.addedNodes.forEach(node => {\n if (node instanceof HTMLImageElement) {\n node.remove();\n } else if (node.nodeType === Node.ELEMENT_NODE) {\n node.querySelectorAll('img').forEach(img => img.remove());\n }\n });\n });\n }\n}\n\nNoDragImage['blotName'] = 'no-drag-image';\nNoDragImage['tagName'] = 'img';\nQuill.register(NoDragImage);\nQuill.register('modules/noDragDrop', NoDragDrop);\nQuill.register('modules/imageResize', ImageResize.default || ImageResize);\n","import Quill from 'quill';\n\n/** Buttons drawn over an embedded video in the editor. */\n\nexport function createAlignButtons(container) {\n const buttonContainer = document.createElement('div');\n buttonContainer.setAttribute('class', 'media-align-buttons');\n buttonContainer.style.position = 'absolute';\n buttonContainer.style.top = '0';\n buttonContainer.style.right = '0';\n buttonContainer.style.display = 'flex';\n buttonContainer.setAttribute('contenteditable', 'false'); // Prevent buttons from being editable\n\n const leftButton = createButton('Left', () => {\n container.style.textAlign = 'left';\n container.setAttribute('data-align', 'left'); // Save alignment\n });\n\n const centerButton = createButton('Center', () => {\n container.style.textAlign = 'center';\n container.setAttribute('data-align', 'center'); // Save alignment\n });\n\n const rightButton = createButton('Right', () => {\n container.style.textAlign = 'right';\n container.setAttribute('data-align', 'right'); // Save alignment\n });\n\n buttonContainer.appendChild(leftButton);\n buttonContainer.appendChild(centerButton);\n buttonContainer.appendChild(rightButton);\n\n return buttonContainer;\n}\n\nexport function createRemoveButton(container) {\n const wrapper = document.createElement('div');\n wrapper.setAttribute('class', 'media-remove-button');\n wrapper.style.position = 'absolute';\n wrapper.style.top = '0';\n wrapper.style.left = '0';\n wrapper.style.display = 'flex';\n wrapper.setAttribute('contenteditable', 'false');\n\n const removeButton = createButton('Remove', () => {\n const mediaContainer = container.classList.contains('media-container')\n ? container\n : container.closest('.media-container');\n if (mediaContainer) {\n const blot = Quill.find(mediaContainer);\n if (blot && 'remove' in blot && typeof blot.remove === 'function') {\n (blot as { remove: () => void }).remove();\n } else {\n // Content loaded from saved HTML may not be a Quill blot; remove from DOM so save persists the change\n mediaContainer.remove();\n }\n }\n });\n removeButton.style.background = 'rgb(243, 67, 67)';\n removeButton.style.color = 'white';\n removeButton.style.border = 'none';\n removeButton.style.padding = '2px 8px';\n removeButton.style.marginTop = '2px';\n removeButton.style.borderRadius = '4px';\n removeButton.title = 'Remove video';\n wrapper.appendChild(removeButton);\n\n return wrapper;\n}\n\nexport function createResizeButtons(container) {\n const buttonContainer = document.createElement('div');\n buttonContainer.setAttribute('class', 'media-resize-buttons');\n buttonContainer.style.position = 'absolute';\n buttonContainer.style.bottom = '5px'; // Adjust position above the bottom edge\n buttonContainer.style.right = '5px';\n buttonContainer.style.display = 'flex';\n buttonContainer.setAttribute('contenteditable', 'false'); // Prevent buttons from being editable\n\n const updateWidthAndHeight = (mediaElement, width, height) => {\n mediaElement.style.width = width;\n mediaElement.style.height = height;\n container.setAttribute('data-width', width); // Save width\n container.setAttribute('data-height', height); // Save height\n };\n\n const increaseWidthButton = createButton('Increase Width', () => {\n const mediaElement = container.querySelector('.no-drag-media');\n const currentWidth = parseInt(mediaElement.style.width || '100%');\n updateWidthAndHeight(mediaElement, `${currentWidth + 20}px`, mediaElement.style.height);\n });\n\n const decreaseWidthButton = createButton('Decrease Width', () => {\n const mediaElement = container.querySelector('.no-drag-media');\n const currentWidth = parseInt(mediaElement.style.width || '100%');\n updateWidthAndHeight(\n mediaElement,\n `${Math.max(100, currentWidth - 20)}px`,\n mediaElement.style.height\n );\n });\n\n const increaseHeightButton = createButton('Increase Height', () => {\n const mediaElement = container.querySelector('.no-drag-media');\n const currentHeight = parseInt(mediaElement.style.height || '200px'); // Default height\n updateWidthAndHeight(mediaElement, mediaElement.style.width, `${currentHeight + 20}px`);\n });\n\n const decreaseHeightButton = createButton('Decrease Height', () => {\n const mediaElement = container.querySelector('.no-drag-media');\n const currentHeight = parseInt(mediaElement.style.height || '200px'); // Default height\n updateWidthAndHeight(\n mediaElement,\n mediaElement.style.width,\n `${Math.max(100, currentHeight - 20)}px`\n );\n });\n\n buttonContainer.appendChild(increaseWidthButton);\n buttonContainer.appendChild(decreaseWidthButton);\n buttonContainer.appendChild(increaseHeightButton);\n buttonContainer.appendChild(decreaseHeightButton);\n\n return buttonContainer;\n}\n\nexport function createButton(label, onClick) {\n const button = document.createElement('button');\n button.innerHTML = label;\n button.style.margin = '0 5px';\n button.style.cursor = 'pointer';\n\n // Prevent Quill from treating this as part of the content\n button.setAttribute('contenteditable', 'false');\n button.style.pointerEvents = 'auto'; // Allow button clicks but don't let Quill interact with them\n\n button.onclick = event => {\n event.preventDefault(); // Prevent default action\n event.stopPropagation(); // Prevent the event from bubbling up and being interpreted by Quill\n onClick(); // Execute the button's action\n };\n\n return button;\n}\n","import Quill from 'quill';\n\nimport {\n createAlignButtons,\n createRemoveButton,\n createResizeButtons\n} from './quill-video-controls';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst BlockEmbedVideo = Quill.import('blots/block/embed') as any;\nexport class NoDragVideo extends BlockEmbedVideo {\n static create(value) {\n const node = document.createElement('iframe');\n node.setAttribute('src', value.url);\n node.setAttribute('frameborder', '0');\n node.setAttribute('allowfullscreen', 'true');\n node.setAttribute('width', value.width || '100%'); // Default width\n node.setAttribute('height', value.height || '200px'); // Default height\n node.setAttribute('class', 'no-drag-media');\n node.setAttribute('contenteditable', 'false'); // Prevent content from being editable\n\n // Add proper allow attribute for YouTube and other video embeds\n if (value.url && (value.url.includes('youtube.com') || value.url.includes('youtu.be'))) {\n node.setAttribute(\n 'allow',\n 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share'\n );\n // Ensure YouTube embed URL format is correct\n if (\n value.url &&\n !value.url.includes('youtube-nocookie.com') &&\n !value.url.includes('enablejsapi=1')\n ) {\n try {\n const url = new URL(value.url);\n url.searchParams.set('enablejsapi', '1');\n if (typeof window !== 'undefined' && window.location) {\n url.searchParams.set('origin', window.location.origin);\n }\n node.setAttribute('src', url.toString());\n } catch {\n // If URL parsing fails, keep original src and just add query params manually\n const separator = value.url.includes('?') ? '&' : '?';\n node.setAttribute('src', `${value.url}${separator}enablejsapi=1`);\n }\n }\n } else if (value.url && value.url.includes('loom.com')) {\n node.setAttribute(\n 'allow',\n 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture'\n );\n } else {\n // Default allow for other iframes\n node.setAttribute('allow', 'fullscreen');\n }\n\n // Create a container for both video/iframe and buttons\n const container = document.createElement('div');\n container.setAttribute('class', 'media-container');\n container.style.position = 'relative';\n container.style.width = '100%';\n container.style.height = 'auto';\n container.appendChild(node); // Append video/iframe to the container\n\n // Append remove button so video can be deleted after save/update (backspace often doesn't work on reloaded content)\n if (!container.querySelector('.media-remove-button')) {\n const removeButton = createRemoveButton(container);\n removeButton.setAttribute('contenteditable', 'false');\n container.appendChild(removeButton);\n }\n\n // Append align buttons if not already present\n if (!container.querySelector('.media-align-buttons')) {\n const alignButtons = createAlignButtons(container);\n alignButtons.setAttribute('contenteditable', 'false'); // Prevent buttons from being editable\n container.appendChild(alignButtons);\n }\n\n // Append resize buttons if not already present\n if (!container.querySelector('.media-resize-buttons')) {\n const resizeButtons = createResizeButtons(container);\n resizeButtons.setAttribute('contenteditable', 'false'); // Prevent buttons from being editable\n container.appendChild(resizeButtons);\n }\n\n container.setAttribute('contenteditable', 'false'); // Prevent the entire container from being editable\n\n return container;\n }\n\n static value(container) {\n const iframe = container.querySelector('iframe');\n return {\n url: iframe?.getAttribute('src'),\n width: container.getAttribute('data-width') || iframe?.getAttribute('width'),\n height: container.getAttribute('data-height') || iframe?.getAttribute('height'),\n align: container.getAttribute('data-align') || 'center' // Default to center if no alignment\n };\n }\n}\n\nNoDragVideo['blotName'] = 'no-drag-video';\nNoDragVideo['tagName'] = 'div'; // TagName is set to div to hold buttons\nQuill.register(NoDragVideo);\n","import Quill from 'quill';\nimport * as ImageResize from 'quill-resize-image';\n\nimport { defaultImageUpload } from './quill-default-image-upload';\nimport { ImageLinkImport } from './quill-image-link-import';\nimport {\n chooseImage,\n ImageDropHint,\n imageUploaderModule,\n QuillImageUploadOptions\n} from './quill-image-upload';\nimport { NoDragDrop, NoDragImage } from './quill-no-drag-image';\nimport { NoDragVideo } from './quill-no-drag-video';\nimport { PasteGuard } from './quill-paste-guard';\n\nexport class QuillHelper {\n static init() {\n if (!Quill.imports['formats/no-drag-image']) {\n Quill.register(NoDragImage);\n }\n if (!Quill.imports['formats/no-drag-video']) {\n Quill.register(NoDragVideo);\n }\n if (!Quill.imports['modules/imageResize']) {\n Quill.register('modules/imageResize', ImageResize.default || ImageResize);\n }\n if (!Quill.imports['modules/noDragDrop']) {\n Quill.register('modules/noDragDrop', NoDragDrop);\n }\n if (!Quill.imports['modules/pasteGuard']) {\n Quill.register('modules/pasteGuard', PasteGuard);\n }\n if (!Quill.imports['modules/imageDropHint']) {\n Quill.register('modules/imageDropHint', ImageDropHint);\n }\n if (!Quill.imports['modules/imageLinkImport']) {\n Quill.register('modules/imageLinkImport', ImageLinkImport);\n }\n }\n\n /**\n * `imageUpload` uploads images to S3 instead of only accepting a URL (#4272). Called from a\n * constructor it defaults to the selected subscription; see `defaultImageUpload`.\n */\n static getEditorConfig(\n additionalToolbarConfig = [],\n imageUpload: QuillImageUploadOptions | undefined = defaultImageUpload()\n ) {\n const defaultToolbarConfig = [\n ['bold', 'italic', 'underline', 'strike'], // toggled buttons\n ['blockquote', 'code-block'],\n [{ header: 1 }, { header: 2 }], // custom button values\n [{ list: 'ordered' }, { list: 'bullet' }],\n [{ script: 'sub' }, { script: 'super' }], // superscript/subscript\n [{ indent: '-1' }, { indent: '+1' }], // outdent/indent\n [{ direction: 'rtl' }], // text direction\n [{ header: [1, 2, 3, 4, 5, 6, false] }],\n [{ color: [] }, { background: [] }], // dropdown with defaults from theme\n [{ align: [] }],\n ['link', 'image', 'video'],\n ['clean'], // remove formatting button\n ['table'] // table button\n ];\n\n const mergedToolbarConfig = [...defaultToolbarConfig, ...additionalToolbarConfig];\n\n return {\n toolbar: {\n container: mergedToolbarConfig,\n handlers: {\n image: function () {\n if (imageUpload) {\n chooseImage(this.quill, imageUpload);\n return;\n }\n const range = this.quill.getSelection();\n const value = prompt('Enter image URL:');\n if (value) {\n this.quill.insertEmbed(range.index, 'no-drag-image', { url: value });\n this.quill.insertText(range.index + 1, '\\n', Quill.sources.USER);\n }\n },\n video: function () {\n const range = this.quill.getSelection();\n let value = prompt('Enter video URL:');\n if (value?.includes('youtube.com/watch?v=')) {\n const videoId = value.split('v=')[1];\n value = `https://www.youtube.com/embed/${videoId}`;\n } else if (value?.includes('youtu.be/')) {\n const videoId = value.split('.be/')[1];\n value = `https://www.youtube.com/embed/${videoId}`;\n } else if (value?.includes('loom.com/share/')) {\n const videoId = value.split('share/')[1];\n value = `https://www.loom.com/embed/${videoId}`;\n } else if (value?.includes('capture.dropbox.com/')) {\n const videoId = value.split('capture.dropbox.com/')[1];\n if (videoId.includes('embed')) {\n value = `https://capture.dropbox.com/${videoId}`;\n } else {\n value = `https://capture.dropbox.com/embed/${videoId}`;\n }\n }\n if (value) {\n const useIframe =\n value.includes('youtube.com') ||\n value.includes('youtu.be') ||\n value.includes('loom.com') ||\n value.includes('drop');\n this.quill.insertEmbed(range.index, 'no-drag-video', {\n url: value,\n isEdit: true,\n width: useIframe ? '560px' : '640px', // Different width for iframe vs video\n height: useIframe ? '315px' : '360px' // Different height for iframe vs video\n });\n this.quill.insertText(range.index + 1, '\\n', Quill.sources.USER);\n }\n }\n }\n },\n imageResize: {\n displaySize: true\n },\n // With uploads, Quill's uploader takes dropped files; NoDragDrop would delete the result.\n ...(imageUpload\n ? {\n uploader: imageUploaderModule(imageUpload),\n imageDropHint: { label: imageUpload.dropLabel },\n imageLinkImport: {\n importUrl: imageUpload.importUrl,\n busyLabel: imageUpload.busyLabel\n },\n pasteGuard: { all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
2
2
  "name": "@posiwise/utils",
3
- "version": "0.0.150",
3
+ "version": "0.0.151",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^22.2.0",
6
6
  "@angular/core": "^22.2.0",
7
7
  "@angular/forms": "^22.2.0",
8
+ "ngx-quill": "^28.0.2",
8
9
  "quill": "^2.0.0",
9
10
  "quill-resize-image": "^1.0.5"
10
11
  },
@@ -1,7 +1,147 @@
1
+ import * as i0 from "@angular/core";
2
+ import { OnInit } from "@angular/core";
1
3
  import Quill from "quill";
4
+ import { ActivatedRoute } from "@angular/router";
5
+ /** What the indicator needs from an editor; a real Quill has both. */
6
+ type IndicatorQuill = {
7
+ root: HTMLElement;
8
+ container?: HTMLElement;
9
+ };
10
+ /**
11
+ * Shows the app's spinner with `label` in a chip centred on the line between the toolbar and the
12
+ * text while an image uploads (posiwise-frontend#4272), like GitLab's, and returns a function that
13
+ * removes it. The chip sits on the editor's wrapper, outside the content, so it never covers the
14
+ * text and is never saved; not in `.ql-container`, whose scrolling would clip it. Styled by
15
+ * `.ql-upload-indicator` (core-styles); only its height comes from here, because the toolbar's
16
+ * height varies by editor and screen width.
17
+ */
18
+ declare function showUploadIndicator(quill: IndicatorQuill, label?: string): () => void;
19
+ /**
20
+ * Uploading images from a Quill editor (posiwise-frontend#4272).
21
+ *
22
+ * The file goes to S3 through main-api and the editor inserts only its URL, so no image bytes are
23
+ * ever stored in the document. The image button, paste and drop all end in `insertUploadedImages`.
24
+ */
25
+ /** Uploads one file and resolves with its public URL. Rejects after telling the user why. */
26
+ export type QuillImageUploader = (file: File) => Promise<string>;
27
+ /** What the user picked in the "Add image" box. */
28
+ export type EditorImageChoice = {
29
+ url: string;
30
+ } | {
31
+ files: File[];
32
+ };
33
+ export interface QuillImageUploadOptions {
34
+ upload: QuillImageUploader;
35
+ /** Copies an image from a link into our storage and resolves with OUR URL. */
36
+ importUrl?: (url: string) => Promise<string>;
37
+ /** Asks the user for a link or files. Without it the image button opens the file picker. */
38
+ choose?: () => Promise<EditorImageChoice | null>;
39
+ /** Text shown over the editor while an image is dragged onto it. */
40
+ dropLabel?: () => string;
41
+ /** Text next to the spinner shown in the body while an image uploads. */
42
+ busyLabel?: () => string;
43
+ }
44
+ /** Mirrors main-api's `main_api_editor_image` purpose. No SVG: it can carry script. */
45
+ export declare const EDITOR_IMAGE_TYPES: string[];
46
+ type EditorQuill = Pick<Quill, 'insertEmbed' | 'insertText' | 'deleteText' | 'getContents' | 'setSelection' | 'getSelection'> & IndicatorQuill & {
47
+ getModule?: (name: string) => unknown;
48
+ };
49
+ /**
50
+ * Turns each file (or link) into our URL one after another and inserts the images at `index`, in
51
+ * order. A spinner chip shows on the editor's top edge, and the editor is `aria-busy` meanwhile,
52
+ * which also holds its form's save button (buttonBusy).
53
+ */
54
+ export declare function insertUploadedImages<T>(quill: EditorQuill, index: number, items: T[], toUrl: (item: T) => Promise<string>, busyLabel?: string): Promise<void>;
55
+ /** Opens the browser's file picker for images. Must run inside a click handler. */
56
+ export declare function pickImageFiles(onPicked: (files: File[]) => void, doc?: Document): void;
57
+ /** Image button: a link is inserted as it is, chosen files are uploaded. */
58
+ export declare function chooseImage(quill: EditorQuill, options: QuillImageUploadOptions): Promise<void>;
59
+ /** Quill `uploader` module config: Quill hands it every pasted or dropped file. */
60
+ export declare function imageUploaderModule(options: QuillImageUploadOptions): {
61
+ mimetypes: string[];
62
+ handler(this: {
63
+ quill: EditorQuill;
64
+ }, range: {
65
+ index: number;
66
+ }, files: File[]): void;
67
+ };
68
+ /**
69
+ * Quill module: highlights the editor only while a file is dragged over it, so the drop target is
70
+ * clear without a permanent hint in the text. Styled by `.ql-container.ql-image-drop` (core-styles).
71
+ */
72
+ export declare class ImageDropHint {
73
+ constructor(quill: {
74
+ container: HTMLElement;
75
+ }, options?: {
76
+ label?: () => string;
77
+ });
78
+ }
79
+ /**
80
+ * Image upload for a `<quill-editor>` that has no `[modules]` of its own (posiwise-frontend#4272):
81
+ * `<quill-editor pwEditorImages …>` gets the same "Add image" box, paste/drop upload and drop
82
+ * highlight as editors built with `QuillHelper.getEditorConfig()`. It wires the created editor,
83
+ * because a component's ngx-quill config can't be changed from outside.
84
+ */
85
+ export declare class EditorImageUploadDirective implements OnInit {
86
+ private readonly editor;
87
+ private readonly destroyRef;
88
+ private readonly options;
89
+ ngOnInit(): void;
90
+ static ɵfac: i0.ɵɵFactoryDeclaration<EditorImageUploadDirective, never>;
91
+ static ɵdir: i0.ɵɵDirectiveDeclaration<EditorImageUploadDirective, "[pwEditorImages]", never, {}, {}, never, never, true, never>;
92
+ }
93
+ /** Gives an already-created editor the image button, paste/drop upload and drop highlight. */
94
+ export declare function wireImageUpload(quill: Quill, options: QuillImageUploadOptions): void;
95
+ /**
96
+ * Image upload for every editor built with `QuillHelper.getEditorConfig()` (posiwise-frontend#4272),
97
+ * without each component wiring it: the editors build their config in their constructor, where
98
+ * `inject` works. Images go to the subscription the user has selected, which is the one these
99
+ * editors save their content to.
100
+ *
101
+ * Outside an injection context (plain code, unit tests) it returns undefined and the editor keeps
102
+ * the URL-only image button.
103
+ */
104
+ declare function defaultImageUpload(): QuillImageUploadOptions | undefined;
105
+ /**
106
+ * Same as `defaultImageUpload`, for an editor that saves its content to a subscription it resolves
107
+ * itself (e.g. from the route or local storage). Call it from a constructor or field initialiser:
108
+ * `QuillHelper.getEditorConfig([], editorImageUpload(() => this.subscriptionId))`.
109
+ */
110
+ export declare function editorImageUpload(subscriptionId: () => number | null | undefined): QuillImageUploadOptions | undefined;
111
+ /**
112
+ * The selected subscription, read at upload time. On a subscription page (`/:slug/...`) it must be
113
+ * that slug's subscription; if the two ever differ, no subscription is returned and the upload is
114
+ * refused rather than stored under another subscription. A `slug` deeper in the URL names a record
115
+ * (e.g. `/admin/resources/:slug`), not a subscription, and is ignored.
116
+ */
117
+ declare function uploadSubscriptionId(route: ActivatedRoute | null): number | undefined;
2
118
  export declare class QuillHelper {
3
119
  static init(): void;
4
- static getEditorConfig(additionalToolbarConfig?: any[]): {
120
+ /**
121
+ * `imageUpload` uploads images to S3 instead of only accepting a URL (#4272). Called from a
122
+ * constructor it defaults to the selected subscription; see `defaultImageUpload`.
123
+ */
124
+ static getEditorConfig(additionalToolbarConfig?: any[], imageUpload?: QuillImageUploadOptions | undefined): {
125
+ uploader: {
126
+ mimetypes: string[];
127
+ handler(this: {
128
+ quill: Pick<Quill, "insertEmbed" | "insertText" | "deleteText" | "getContents" | "setSelection" | "getSelection"> & IndicatorQuill & {
129
+ getModule?: (name: string) => unknown;
130
+ };
131
+ }, range: {
132
+ index: number;
133
+ }, files: File[]): void;
134
+ };
135
+ imageDropHint: {
136
+ label: () => string;
137
+ };
138
+ imageLinkImport: {
139
+ importUrl: (url: string) => Promise<string>;
140
+ busyLabel: () => string;
141
+ };
142
+ pasteGuard: {
143
+ allowImageFiles: boolean;
144
+ };
5
145
  toolbar: {
6
146
  container: any[];
7
147
  handlers: {
@@ -12,8 +152,19 @@ export declare class QuillHelper {
12
152
  imageResize: {
13
153
  displaySize: boolean;
14
154
  };
155
+ } | {
15
156
  noDragDrop: boolean;
16
157
  pasteGuard: boolean;
158
+ toolbar: {
159
+ container: any[];
160
+ handlers: {
161
+ image: () => void;
162
+ video: () => void;
163
+ };
164
+ };
165
+ imageResize: {
166
+ displaySize: boolean;
167
+ };
17
168
  };
18
169
  }
19
170
  export declare const PASTED_IMAGE_MESSAGE: string;
@@ -27,8 +178,14 @@ export declare function isEmbeddedImageSrc(src: string | null | undefined): bool
27
178
  */
28
179
  export declare class PasteGuard {
29
180
  private readonly notify;
181
+ private readonly allowImageFiles;
182
+ /**
183
+ * `allowImageFiles`: the editor uploads pasted image files (Quill's `uploader` module), so let
184
+ * them through. Pasted HTML carrying a `data:` image is still dropped.
185
+ */
30
186
  constructor(quill: Quill, options?: {
31
187
  onBlocked?: (message: string) => void;
188
+ allowImageFiles?: boolean;
32
189
  });
33
190
  private handlePaste;
34
191
  }