lexxy 0.9.15.alpha.1 → 0.9.15.alpha.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d9a254f888998ed62a3d7af0cbf6644a0b82fde3ca02d0eefc604c512e12ba9
4
- data.tar.gz: b0d14ac32727c31eaf0709f16f178ad1056d38e30959141ef3e8b2cbb3f170fe
3
+ metadata.gz: 86b63d9156e8846e2eaab83979bf9fc696eb37743e560cbe590f8d91f7448bd7
4
+ data.tar.gz: 375a9d775564689646650622857495a59239d65c2e1b6fd48e861f74abddcd84
5
5
  SHA512:
6
- metadata.gz: 3964a7317fdaf7ac44d2c31f546e073a13942bd3a3839be20f9a32a6159e4bc0daf7db35579a21fba551caaa4f136435be392ef70e99c3461eb40ccf3dfdb6c2
7
- data.tar.gz: f3ea71f58d2a94b6226f9c0e4ace4b08f3ab0fb3d08eaff38159c38f736667661db6e60b0918d3e69a9563c89b244c1d8d3d5b052f8e7f0ea2da298d6011dc1d
6
+ metadata.gz: fff91b9c87fcabab97ae5375233a3819f5aa7097c913df32dea9dd914952451f889cb29c98888c1d6173c67ba3ae67732422952afc13812af25c81bec66e1afe
7
+ data.tar.gz: bbde40f03c4a7e950e99d0ac2e018b7e1c8251e0a53246bcffdde5a7141117ed860f9b22f2b75fb242a58ed8dbafe0992e24badb07d167028ac6925f1e03896a
@@ -8244,6 +8244,11 @@ function safeCloneEditorState(editorState) {
8244
8244
  return clone
8245
8245
  }
8246
8246
 
8247
+ const INITIAL_PREVIEW_POLL_DELAY_MS = 3000;
8248
+ const MAX_PREVIEW_POLL_DELAY_MS = 120000;
8249
+ const MAX_PREVIEW_POLL_ATTEMPTS = 20;
8250
+
8251
+
8247
8252
  class ActionTextAttachmentNode extends Ji {
8248
8253
  static getType() {
8249
8254
  return "action_text_attachment"
@@ -8318,7 +8323,7 @@ class ActionTextAttachmentNode extends Ji {
8318
8323
  return Lexxy.global.get("attachmentTagName")
8319
8324
  }
8320
8325
 
8321
- constructor({ tagName, sgid, src, previewSrc, previewable, pendingPreview, altText, caption, contentType, fileName, fileSize, width, height, uploadError }, key) {
8326
+ constructor({ tagName, sgid, src, previewSrc, previewable, previewStatusUrl, pendingPreview, altText, caption, contentType, fileName, fileSize, width, height, uploadError }, key) {
8322
8327
  super(key);
8323
8328
 
8324
8329
  this.tagName = tagName || ActionTextAttachmentNode.TAG_NAME;
@@ -8326,6 +8331,7 @@ class ActionTextAttachmentNode extends Ji {
8326
8331
  this.src = src;
8327
8332
  this.previewSrc = previewSrc;
8328
8333
  this.previewable = parseBoolean(previewable);
8334
+ this.previewStatusUrl = previewStatusUrl;
8329
8335
  this.pendingPreview = pendingPreview;
8330
8336
  this.altText = altText || "";
8331
8337
  this.caption = caption || "";
@@ -8404,6 +8410,8 @@ class ActionTextAttachmentNode extends Ji {
8404
8410
  sgid: this.sgid,
8405
8411
  src: this.src,
8406
8412
  previewable: this.previewable,
8413
+ previewStatusUrl: this.previewStatusUrl,
8414
+ pendingPreview: this.pendingPreview,
8407
8415
  altText: this.altText,
8408
8416
  caption: this.caption,
8409
8417
  contentType: this.contentType,
@@ -8522,41 +8530,61 @@ class ActionTextAttachmentNode extends Ji {
8522
8530
  });
8523
8531
  }
8524
8532
 
8533
+ // While the file-icon is shown, watch for the preview to become ready.
8534
+ // With a status URL, poll it (2xx = processing, anything else = ready).
8535
+ // Without one, preload the preview URL once and swap on load.
8525
8536
  #pollForPreview(figure) {
8537
+ if (this.previewStatusUrl) {
8538
+ this.#waitForPreviewByPollingStatus(figure);
8539
+ } else {
8540
+ this.#waitForPreviewByPreloadingImage(figure);
8541
+ }
8542
+ }
8543
+
8544
+ #waitForPreviewByPollingStatus(figure) {
8526
8545
  let attempt = 0;
8527
- const maxAttempts = 10;
8528
8546
 
8529
- const tryLoad = () => {
8547
+ const tryStatus = async () => {
8530
8548
  if (!this.editor.read(() => this.isAttached())) return
8531
8549
 
8532
- const img = new Image();
8533
- const cacheBustedSrc = `${this.src}${this.src.includes("?") ? "&" : "?"}_=${Date.now()}`;
8550
+ try {
8551
+ // redirect: "manual" prevents fetch from transparently following a
8552
+ // 3xx response — without it, a status endpoint that redirected to,
8553
+ // say, the preview URL would resolve to a 200 and look like
8554
+ // "still processing." The contract is "any non-2xx means done."
8555
+ const response = await fetch(this.previewStatusUrl, { credentials: "include", redirect: "manual" });
8534
8556
 
8535
- img.onload = () => {
8536
8557
  if (!this.editor.read(() => this.isAttached())) return
8537
8558
 
8538
- // The placeholder is a file-type icon SVG (86×100). A real thumbnail
8539
- // generated from PDF/video content is significantly larger.
8540
- if (img.naturalWidth > 150 && img.naturalHeight > 150) {
8541
- this.#swapToPreviewDOM(figure, cacheBustedSrc);
8542
- } else {
8559
+ if (response.ok) {
8543
8560
  retry();
8561
+ } else {
8562
+ this.#swapToPreviewDOM(figure, this.src);
8544
8563
  }
8545
- };
8546
- img.onerror = () => retry();
8547
- img.src = cacheBustedSrc;
8564
+ } catch {
8565
+ retry();
8566
+ }
8548
8567
  };
8549
8568
 
8550
8569
  const retry = () => {
8551
8570
  attempt++;
8552
- if (attempt < maxAttempts && this.editor.read(() => this.isAttached())) {
8553
- const delay = Math.min(2000 * Math.pow(1.5, attempt), 15000);
8554
- setTimeout(tryLoad, delay);
8571
+ if (attempt < MAX_PREVIEW_POLL_ATTEMPTS && this.editor.read(() => this.isAttached())) {
8572
+ const delay = Math.min(2000 * Math.pow(1.5, attempt), MAX_PREVIEW_POLL_DELAY_MS);
8573
+ setTimeout(tryStatus, delay);
8555
8574
  }
8556
8575
  };
8557
8576
 
8558
8577
  // Give the server time to start processing before the first attempt
8559
- setTimeout(tryLoad, 3000);
8578
+ setTimeout(tryStatus, INITIAL_PREVIEW_POLL_DELAY_MS);
8579
+ }
8580
+
8581
+ #waitForPreviewByPreloadingImage(figure) {
8582
+ const img = new Image();
8583
+ img.onload = () => {
8584
+ if (!this.editor.read(() => this.isAttached())) return
8585
+ this.#swapToPreviewDOM(figure, this.src);
8586
+ };
8587
+ img.src = this.src;
8560
8588
  }
8561
8589
 
8562
8590
  #swapToPreviewDOM(figure, previewSrc) {
@@ -11185,7 +11213,7 @@ class ImageGalleryNode extends Bi {
11185
11213
  replaceWithSingularChild() {
11186
11214
  if (this.#hasSingularChild) {
11187
11215
  const child = this.getFirstChild();
11188
- return this.replace(child)
11216
+ return this.replace($makeSafeForRoot(child))
11189
11217
  }
11190
11218
  }
11191
11219
 
@@ -11613,6 +11641,7 @@ class AttachmentNodeConversion {
11613
11641
  fileName: blob.filename,
11614
11642
  fileSize: blob.byte_size,
11615
11643
  previewable: blob.previewable,
11644
+ previewStatusUrl: blob.preview_status_url
11616
11645
  }
11617
11646
  }
11618
11647
 
@@ -15264,7 +15293,7 @@ class LexicalPromptElement extends HTMLElement {
15264
15293
 
15265
15294
  const popoverRect = this.popoverElement.getBoundingClientRect();
15266
15295
 
15267
- if (popoverRect.right > window.innerWidth) {
15296
+ if (popoverRect.right > editorRect.right) {
15268
15297
  this.popoverElement.toggleAttribute("data-clipped-at-right", true);
15269
15298
  }
15270
15299
 
Binary file
Binary file