feat: improve goView import and context menu selection

This commit is contained in:
clawdbot 2026-01-28 05:15:37 +08:00
parent 3dfb548c11
commit b667b02b79
3 changed files with 36 additions and 0 deletions

View File

@ -16,6 +16,7 @@ export function ContextMenu(props: {
selectionAllHidden: boolean;
onClose: () => void;
onAddTextAt: (x: number, y: number) => void;
onSelectSingle?: (id?: string) => void;
onDuplicateSelected?: () => void;
onToggleLockSelected?: () => void;
onToggleHideSelected?: () => void;
@ -83,6 +84,9 @@ export function ContextMenu(props: {
if (!ctx || !position) return null;
const hasSelection = props.selectionIds.length > 0;
const hasTarget = !!ctx.targetId;
const targetInSelection = !!ctx.targetId && props.selectionIds.includes(ctx.targetId);
const canSelectSingle = !!props.onSelectSingle;
return (
<div
@ -112,6 +116,26 @@ export function ContextMenu(props: {
}}
/>
{canSelectSingle && hasTarget && targetInSelection && props.selectionIds.length > 1 ? (
<MenuItem
label="Select Only"
onClick={() => {
props.onSelectSingle?.(ctx.targetId);
onClose();
}}
/>
) : null}
{canSelectSingle && !hasTarget && hasSelection ? (
<MenuItem
label="Clear Selection"
onClick={() => {
props.onSelectSingle?.(undefined);
onClose();
}}
/>
) : null}
<div style={{ height: 1, margin: '6px 0', background: 'rgba(255,255,255,0.08)' }} />
<MenuItem

View File

@ -504,6 +504,7 @@ export function EditorApp() {
selectionAllHidden={selectionAllHidden}
onClose={closeContextMenu}
onAddTextAt={(x, y) => dispatch({ type: 'addTextAt', x, y })}
onSelectSingle={(id) => dispatch({ type: 'selectSingle', id })}
onDuplicateSelected={() => dispatch({ type: 'duplicateSelected' })}
onToggleLockSelected={() => dispatch({ type: 'toggleLockSelected' })}
onToggleHideSelected={() => dispatch({ type: 'toggleHideSelected' })}

View File

@ -115,12 +115,18 @@ function isIframe(c: GoViewComponentLike): boolean {
if (k === 'iframe' || k.includes('iframe')) return true;
// Other names seen in low-code editors for embedded web content.
// Keep this fairly conservative; video/image are handled separately.
return (
k.includes('embed') ||
k.includes('webview') ||
k.includes('html') ||
k.includes('browser') ||
k.includes('webpage') ||
k.includes('website') ||
// Chinese low-code widgets sometimes call this H5.
k === 'h5' ||
k.includes('h5_') ||
k.includes('_h5') ||
// keep the plain 'web' check last; it's broad and may overlap other widgets.
k === 'web' ||
k.endsWith('_web') ||
@ -149,6 +155,11 @@ function isVideo(c: GoViewComponentLike): boolean {
k.includes('mp4') ||
k.includes('media') ||
k.includes('player') ||
// player implementation names frequently used in low-code widgets
k.includes('flvjs') ||
k.includes('hlsjs') ||
k.includes('dplayer') ||
k.includes('vlc') ||
k.includes('stream') ||
k.includes('rtsp') ||
k.includes('rtmp') ||