@blockrun/franklin 3.25.0 → 3.25.1
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/ui/app.js +45 -28
- package/package.json +1 -1
package/dist/ui/app.js
CHANGED
|
@@ -445,37 +445,54 @@ function PromptTextInput({ value, onChange, onSubmit, placeholder = '', focus =
|
|
|
445
445
|
const buffered = pasteBufferRef.current;
|
|
446
446
|
pasteBufferRef.current = '';
|
|
447
447
|
pasteActiveRef.current = false;
|
|
448
|
-
// Image-paste detection
|
|
449
|
-
//
|
|
450
|
-
//
|
|
451
|
-
//
|
|
452
|
-
//
|
|
453
|
-
//
|
|
454
|
-
//
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
448
|
+
// Image-paste detection. Original heuristic (3.25.0) only probed the
|
|
449
|
+
// clipboard when the bracketed-paste buffer was empty, assuming Cmd+V
|
|
450
|
+
// on an image-only clipboard always arrived as an empty paste. That
|
|
451
|
+
// assumption holds for macOS Terminal/iTerm2 but NOT for several Linux
|
|
452
|
+
// terminals — some send a filename, a `file://` URI, or a short binary
|
|
453
|
+
// header alongside the image, which made the gate skip the probe and
|
|
454
|
+
// the image silently dropped (user-reported on Kali: the clipboard
|
|
455
|
+
// image was readable by other tools but Franklin couldn't paste it).
|
|
456
|
+
// Verified in a Lima Ubuntu VM with xclip — non-empty buffer triggered
|
|
457
|
+
// the skip.
|
|
458
|
+
//
|
|
459
|
+
// Fix: ALWAYS probe the clipboard on a paste-end. If an image is there,
|
|
460
|
+
// it wins; the bracketed-paste buffer text is treated as terminal noise
|
|
461
|
+
// and dropped. If no image, fall through to the normal text-paste path
|
|
462
|
+
// (collapse-to-block or inline) so text pastes are unaffected. The
|
|
463
|
+
// probe is async (osascript / xclip / wl-paste shell-out, 30-100 ms),
|
|
464
|
+
// so the handler returns immediately and updateValue happens when the
|
|
465
|
+
// Promise resolves.
|
|
466
|
+
const insertAt = currentCursorOffset;
|
|
467
|
+
tryReadClipboardImage().then((img) => {
|
|
468
|
+
if (img && 'path' in img) {
|
|
469
|
+
// Image wins — drop the bracketed-paste buffer (likely a stub the
|
|
470
|
+
// terminal sent for the image).
|
|
471
|
+
const injected = encodeImageBlock(img.path);
|
|
469
472
|
const cur = valueRef.current;
|
|
470
473
|
const at = Math.min(insertAt, cur.length);
|
|
471
474
|
updateValue(cur.slice(0, at) + injected + cur.slice(at), at + injected.length);
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
if (img && 'error' in img) {
|
|
478
|
+
const injected = `[Image rejected: ${img.error}] `;
|
|
479
|
+
const cur = valueRef.current;
|
|
480
|
+
const at = Math.min(insertAt, cur.length);
|
|
481
|
+
updateValue(cur.slice(0, at) + injected + cur.slice(at), at + injected.length);
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
// No image on the clipboard — treat as a normal text paste.
|
|
485
|
+
if (buffered.length === 0)
|
|
486
|
+
return;
|
|
487
|
+
const lineCount = buffered.split('\n').length;
|
|
488
|
+
const textToInsert = lineCount >= PASTE_COLLAPSE_LINE_THRESHOLD
|
|
489
|
+
? encodePasteBlock(buffered)
|
|
490
|
+
: buffered;
|
|
491
|
+
const cur = valueRef.current;
|
|
492
|
+
const at = Math.min(insertAt, cur.length);
|
|
493
|
+
updateValue(cur.slice(0, at) + textToInsert + cur.slice(at), at + textToInsert.length);
|
|
494
|
+
}).catch(() => { });
|
|
495
|
+
return;
|
|
479
496
|
}
|
|
480
497
|
if (!text) {
|
|
481
498
|
if (hasPasteEnd)
|
package/package.json
CHANGED