fix: broaden legacy import + context-menu selection

This commit is contained in:
clawdbot 2026-01-27 22:47:10 +08:00
parent 485af01c17
commit 38119cbe55
3 changed files with 39 additions and 10 deletions

View File

@ -192,7 +192,8 @@ export function Canvas(props: CanvasProps) {
const p = clientToWorld(e.clientX, e.clientY);
if (!p) return;
const additive = (e as React.MouseEvent).ctrlKey || (e as React.MouseEvent).metaKey;
const additive =
(e as React.MouseEvent).ctrlKey || (e as React.MouseEvent).metaKey || (e as React.MouseEvent).shiftKey;
if (targetId) {
if (!props.selectionIds.includes(targetId)) {

View File

@ -124,8 +124,18 @@ function isVideo(c: GoViewComponentLike): boolean {
// goView variants: "Video", "VideoCommon", etc.
if (k === 'video' || k.includes('video')) return true;
// Misspellings / aliases seen in forks.
if (k.includes('vedio')) return true;
// Other names seen in the wild.
return k.includes('mp4') || k.includes('media') || k.includes('player') || k.includes('stream');
return (
k.includes('mp4') ||
k.includes('media') ||
k.includes('player') ||
k.includes('stream') ||
k.includes('rtsp') ||
k.includes('hls')
);
}
function looksLikeImageOption(option: unknown): boolean {
@ -142,11 +152,13 @@ function looksLikeImageOption(option: unknown): boolean {
}
function looksLikeIframeOption(option: unknown): boolean {
if (!option || typeof option !== 'object') return false;
const o = option as Record<string, unknown>;
if (!option) return false;
// Prefer explicit iframe-ish keys.
if ('iframeUrl' in o || 'iframeSrc' in o || 'embedUrl' in o) return true;
// Prefer explicit iframe-ish keys when option is an object.
if (typeof option === 'object') {
const o = option as Record<string, unknown>;
if ('iframeUrl' in o || 'iframeSrc' in o || 'embedUrl' in o) return true;
}
const url = pickUrlLike(option);
if (!url) return false;
@ -161,11 +173,15 @@ function looksLikeIframeOption(option: unknown): boolean {
}
function looksLikeVideoOption(option: unknown): boolean {
if (!option || typeof option !== 'object') return false;
const o = option as Record<string, unknown>;
if (!option) return false;
// Prefer explicit video-ish keys.
if ('videoUrl' in o || 'videoSrc' in o || 'mp4' in o || 'm3u8' in o || 'flv' in o || 'hls' in o || 'rtsp' in o) return true;
// Prefer explicit video-ish keys when option is an object.
if (typeof option === 'object') {
const o = option as Record<string, unknown>;
if ('videoUrl' in o || 'videoSrc' in o || 'mp4' in o || 'm3u8' in o || 'flv' in o || 'hls' in o || 'rtsp' in o) {
return true;
}
}
const url = pickUrlLike(option);
if (!url) return false;

View File

@ -40,13 +40,23 @@ function pickUrlLikeInner(input: unknown, depth: number): string {
'path',
'source',
'address',
// common aliases
'srcUrl',
'sourceUrl',
'playUrl',
// iframe-ish
'iframeUrl',
'iframeSrc',
'embedUrl',
'frameUrl',
'frameSrc',
'htmlUrl',
'htmlSrc',
// video-ish
'videoUrl',
'videoSrc',
'vedioUrl',
'vedioSrc',
'mp4',
'm3u8',
'flv',
@ -57,6 +67,8 @@ function pickUrlLikeInner(input: unknown, depth: number): string {
'streamUrl',
'rtsp',
'rtspUrl',
'rtmp',
'rtmpUrl',
]) {
const v = obj[key];
if (typeof v === 'string' && v) return v;