loopengine 0.1.50 → 0.1.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/playground.js +21 -5
- package/package.json +1 -1
package/dist/web/playground.js
CHANGED
|
@@ -200,7 +200,14 @@ export const playgroundHtml = `<!doctype html>
|
|
|
200
200
|
image's real visible edge instead of floating in empty space beside
|
|
201
201
|
a narrower image inside a full-width box. */
|
|
202
202
|
.msg-preview-wrap { position: relative; display: inline-block; max-width: 100%; margin: 6px 0; }
|
|
203
|
-
.msg-
|
|
203
|
+
/* .msg-plain-img (no download link — see renderMessageMarkdown's own
|
|
204
|
+
doc comment) gets the same capped size and click-to-zoom as the
|
|
205
|
+
merged .msg-preview-img, just without the corner download icon and
|
|
206
|
+
without a wrap element of its own (nothing needs to be positioned
|
|
207
|
+
relative to it) — see the chatPane click handler below and
|
|
208
|
+
openImageLightbox's own handling of a missing downloadHref. */
|
|
209
|
+
.msg-preview-img, .msg-plain-img { display: block; max-width: 100%; max-height: 260px; width: auto; height: auto; border-radius: 8px; cursor: zoom-in; }
|
|
210
|
+
.msg-plain-img { margin: 6px 0; }
|
|
204
211
|
.msg-download-icon {
|
|
205
212
|
position: absolute;
|
|
206
213
|
top: 8px;
|
|
@@ -488,7 +495,7 @@ export const playgroundHtml = `<!doctype html>
|
|
|
488
495
|
.replace(inlineCodePattern, '<code>$1</code>')
|
|
489
496
|
.replace(boldPattern, '<strong>$1</strong>')
|
|
490
497
|
.replace(italicPattern, '<em>$1</em>')
|
|
491
|
-
.replace(imagePattern, '<img src="$2" alt="$1" class="msg-plain-img">')
|
|
498
|
+
.replace(imagePattern, '<img src="$2" alt="$1" class="msg-plain-img" data-full-src="$2">')
|
|
492
499
|
.replace(linkPattern, '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>');
|
|
493
500
|
}
|
|
494
501
|
function flushParagraph() {
|
|
@@ -571,7 +578,7 @@ export const playgroundHtml = `<!doctype html>
|
|
|
571
578
|
// isn't a recognized string escape character either. A plain string
|
|
572
579
|
// needs no such escaping for "/" at all.
|
|
573
580
|
var previewMergePattern = new RegExp(
|
|
574
|
-
'<img src="([^"]*)" alt="([^"]*)" class="msg-plain-img">' + bs + 's*<a href="([^"]*)"[^>]*>[^<]*</a>',
|
|
581
|
+
'<img src="([^"]*)" alt="([^"]*)" class="msg-plain-img" data-full-src="[^"]*">' + bs + 's*<a href="([^"]*)"[^>]*>[^<]*</a>',
|
|
575
582
|
'g',
|
|
576
583
|
);
|
|
577
584
|
html = html.replace(previewMergePattern, function (match, src, alt, href) {
|
|
@@ -591,7 +598,16 @@ export const playgroundHtml = `<!doctype html>
|
|
|
591
598
|
|
|
592
599
|
function openImageLightbox(src, downloadHref) {
|
|
593
600
|
lightboxImage.src = src;
|
|
594
|
-
|
|
601
|
+
// A plain image (no download link — see renderMessageMarkdown's own
|
|
602
|
+
// doc comment on .msg-plain-img) has no downloadHref at all; hiding
|
|
603
|
+
// the button beats pointing it at '' (a dead link that would just
|
|
604
|
+
// reload the page) or at src (opens inline, not an actual download).
|
|
605
|
+
if (downloadHref) {
|
|
606
|
+
lightboxDownload.href = downloadHref;
|
|
607
|
+
lightboxDownload.style.display = '';
|
|
608
|
+
} else {
|
|
609
|
+
lightboxDownload.style.display = 'none';
|
|
610
|
+
}
|
|
595
611
|
lightboxOverlay.classList.add('open');
|
|
596
612
|
}
|
|
597
613
|
function closeImageLightbox() {
|
|
@@ -616,7 +632,7 @@ export const playgroundHtml = `<!doctype html>
|
|
|
616
632
|
// rewired after each new message.
|
|
617
633
|
chatPane.addEventListener('click', function (ev) {
|
|
618
634
|
var target = ev.target;
|
|
619
|
-
if (target && target.classList && target.classList.contains('msg-preview-img')) {
|
|
635
|
+
if (target && target.classList && (target.classList.contains('msg-preview-img') || target.classList.contains('msg-plain-img'))) {
|
|
620
636
|
openImageLightbox(target.getAttribute('data-full-src'), target.getAttribute('data-download-href'));
|
|
621
637
|
}
|
|
622
638
|
});
|