artifactuse 0.1.28 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -3
- package/dist/{index-D56xsAnF.js → index-BH35XKmt.js} +387 -375
- package/dist/index.js +1 -1
- package/dist/react/index.js +44 -43
- package/dist/styles/components/inline-preview.css +9 -0
- package/dist/svelte/index.js +72 -71
- package/dist/vue/index.js +84 -83
- package/dist/vue2/index.js +46 -6
- package/package.json +1 -1
package/dist/vue2/index.js
CHANGED
|
@@ -423,6 +423,33 @@ function computeSimpleDiff(oldCode, newCode) {
|
|
|
423
423
|
function createInlinePreview(artifact, code, langLower, inlinePreview) {
|
|
424
424
|
const maxLines = inlinePreview.maxLines || 15;
|
|
425
425
|
|
|
426
|
+
// Resolve whether preview should be non-clickable (short code, no panel value)
|
|
427
|
+
function isNonClickable(lineCount, isTruncated) {
|
|
428
|
+
if (isTruncated) return false;
|
|
429
|
+
const minClick = inlinePreview.minClickableLines;
|
|
430
|
+
if (minClick == null) return false;
|
|
431
|
+
const minLines = typeof minClick === 'number' ? minClick : (minClick.lines || 0);
|
|
432
|
+
const ignoreLanguages = (typeof minClick === 'object' && Array.isArray(minClick.ignoreLanguages))
|
|
433
|
+
? minClick.ignoreLanguages : [];
|
|
434
|
+
return lineCount < minLines && !ignoreLanguages.includes(langLower);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// Resolve action label for the fade overlay
|
|
438
|
+
function getActionLabel(lang, lineCount) {
|
|
439
|
+
const al = inlinePreview.actionLabel;
|
|
440
|
+
let labelText;
|
|
441
|
+
if (typeof al === 'string') {
|
|
442
|
+
labelText = al;
|
|
443
|
+
} else if (al && typeof al === 'object') {
|
|
444
|
+
labelText = al[lang] || al.default || null;
|
|
445
|
+
}
|
|
446
|
+
if (!labelText) {
|
|
447
|
+
labelText = (lang === 'diff' || lang === 'patch' || lang === 'smartdiff')
|
|
448
|
+
? 'View full diff' : 'View full code';
|
|
449
|
+
}
|
|
450
|
+
return `${labelText} (${lineCount} lines)`;
|
|
451
|
+
}
|
|
452
|
+
|
|
426
453
|
// Smartdiff: parse JSON, compute diff, use actual language for highlighting
|
|
427
454
|
if (langLower === 'smartdiff') {
|
|
428
455
|
try {
|
|
@@ -437,10 +464,14 @@ function createInlinePreview(artifact, code, langLower, inlinePreview) {
|
|
|
437
464
|
const encoded = encodeHtml(codeLines.join('\n'));
|
|
438
465
|
const isTruncated = allDiffLines.length > maxLines;
|
|
439
466
|
const actualLang = diffData.language || 'plaintext';
|
|
467
|
+
const nonClickable = isNonClickable(allDiffLines.length, isTruncated);
|
|
468
|
+
const staticClass = nonClickable ? ' artifactuse-inline-preview--static' : '';
|
|
469
|
+
const staticAttr = nonClickable ? ' data-non-clickable="true"' : '';
|
|
470
|
+
const actionText = getActionLabel('smartdiff', allDiffLines.length);
|
|
440
471
|
|
|
441
|
-
return `<div class="artifactuse-inline-preview${isTruncated ? ' artifactuse-inline-preview--truncated' : ''}" data-artifact-id="${artifact.id}" data-smartdiff="true" data-smartdiff-markers="${markers.join(',')}">`
|
|
472
|
+
return `<div class="artifactuse-inline-preview${isTruncated ? ' artifactuse-inline-preview--truncated' : ''}${staticClass}" data-artifact-id="${artifact.id}" data-smartdiff="true" data-smartdiff-markers="${markers.join(',')}"${staticAttr}>`
|
|
442
473
|
+ `<pre class="artifactuse-inline-preview__pre"><code class="language-${actualLang}">${encoded}</code></pre>`
|
|
443
|
-
+ (isTruncated ? `<div class="artifactuse-inline-preview__fade"><span class="artifactuse-inline-preview__action"
|
|
474
|
+
+ (isTruncated ? `<div class="artifactuse-inline-preview__fade"><span class="artifactuse-inline-preview__action">${actionText}</span></div>` : '')
|
|
444
475
|
+ `</div>`;
|
|
445
476
|
} catch {
|
|
446
477
|
// Fallback: show raw content as JSON
|
|
@@ -455,11 +486,14 @@ function createInlinePreview(artifact, code, langLower, inlinePreview) {
|
|
|
455
486
|
const truncated = lines.slice(0, maxLines).join('\n');
|
|
456
487
|
const encoded = encodeHtml(truncated);
|
|
457
488
|
const isTruncated = lines.length > maxLines;
|
|
458
|
-
const
|
|
489
|
+
const nonClickable = isNonClickable(lines.length, isTruncated);
|
|
490
|
+
const staticClass = nonClickable ? ' artifactuse-inline-preview--static' : '';
|
|
491
|
+
const staticAttr = nonClickable ? ' data-non-clickable="true"' : '';
|
|
492
|
+
const actionText = getActionLabel(langLower, lines.length);
|
|
459
493
|
|
|
460
|
-
return `<div class="artifactuse-inline-preview${isTruncated ? ' artifactuse-inline-preview--truncated' : ''}" data-artifact-id="${artifact.id}">`
|
|
494
|
+
return `<div class="artifactuse-inline-preview${isTruncated ? ' artifactuse-inline-preview--truncated' : ''}${staticClass}" data-artifact-id="${artifact.id}"${staticAttr}>`
|
|
461
495
|
+ `<pre class="artifactuse-inline-preview__pre"><code class="language-${previewLang}">${encoded}</code></pre>`
|
|
462
|
-
+ (isTruncated ? `<div class="artifactuse-inline-preview__fade"><span class="artifactuse-inline-preview__action"
|
|
496
|
+
+ (isTruncated ? `<div class="artifactuse-inline-preview__fade"><span class="artifactuse-inline-preview__action">${actionText}</span></div>` : '')
|
|
463
497
|
+ `</div>`;
|
|
464
498
|
}
|
|
465
499
|
|
|
@@ -592,7 +626,12 @@ function extractCodeBlockArtifacts(html, messageId, options = {}) {
|
|
|
592
626
|
|
|
593
627
|
function shouldShowPreview(lang) {
|
|
594
628
|
if (!inlinePreview) return false;
|
|
595
|
-
if (inlinePreview.languages === true)
|
|
629
|
+
if (inlinePreview.languages === true) {
|
|
630
|
+
if (Array.isArray(inlinePreview.excludeLanguages) && inlinePreview.excludeLanguages.includes(lang)) {
|
|
631
|
+
return false;
|
|
632
|
+
}
|
|
633
|
+
return true;
|
|
634
|
+
}
|
|
596
635
|
if (Array.isArray(inlinePreview.languages)) return inlinePreview.languages.includes(lang);
|
|
597
636
|
return false;
|
|
598
637
|
}
|
|
@@ -11577,6 +11616,7 @@ var script$2 = {
|
|
|
11577
11616
|
function handleContentClick(e) {
|
|
11578
11617
|
const preview = e.target.closest('.artifactuse-inline-preview');
|
|
11579
11618
|
if (preview) {
|
|
11619
|
+
if (preview.dataset.nonClickable) return;
|
|
11580
11620
|
const artifactId = preview.dataset.artifactId;
|
|
11581
11621
|
if (artifactId) {
|
|
11582
11622
|
const artifact = state.artifacts.find(a => a.id === artifactId);
|