refactor: improve goView import and editor context menu parity

This commit is contained in:
clawdbot 2026-01-28 07:26:11 +08:00
parent 95f94e0733
commit e58b240778
4 changed files with 19 additions and 1 deletions

View File

@ -14,9 +14,11 @@ export function ContextMenu(props: {
selectionIds: string[]; selectionIds: string[];
selectionAllLocked: boolean; selectionAllLocked: boolean;
selectionAllHidden: boolean; selectionAllHidden: boolean;
hasAnyNodes?: boolean;
onClose: () => void; onClose: () => void;
onAddTextAt: (x: number, y: number) => void; onAddTextAt: (x: number, y: number) => void;
onSelectSingle?: (id?: string) => void; onSelectSingle?: (id?: string) => void;
onSelectAll?: () => void;
onDuplicateSelected?: () => void; onDuplicateSelected?: () => void;
onToggleLockSelected?: () => void; onToggleLockSelected?: () => void;
onToggleHideSelected?: () => void; onToggleHideSelected?: () => void;
@ -136,6 +138,16 @@ export function ContextMenu(props: {
/> />
) : null} ) : null}
{!hasTarget && props.hasAnyNodes && props.onSelectAll ? (
<MenuItem
label="Select All"
onClick={() => {
props.onSelectAll?.();
onClose();
}}
/>
) : null}
<div style={{ height: 1, margin: '6px 0', background: 'rgba(255,255,255,0.08)' }} /> <div style={{ height: 1, margin: '6px 0', background: 'rgba(255,255,255,0.08)' }} />
<MenuItem <MenuItem

View File

@ -509,9 +509,11 @@ export function EditorApp() {
selectionIds={state.selection.ids} selectionIds={state.selection.ids}
selectionAllLocked={selectionAllLocked} selectionAllLocked={selectionAllLocked}
selectionAllHidden={selectionAllHidden} selectionAllHidden={selectionAllHidden}
hasAnyNodes={state.doc.screen.nodes.length > 0}
onClose={closeContextMenu} onClose={closeContextMenu}
onAddTextAt={(x, y) => dispatch({ type: 'addTextAt', x, y })} onAddTextAt={(x, y) => dispatch({ type: 'addTextAt', x, y })}
onSelectSingle={(id) => dispatch({ type: 'selectSingle', id })} onSelectSingle={(id) => dispatch({ type: 'selectSingle', id })}
onSelectAll={() => dispatch({ type: 'selectAll' })}
onDuplicateSelected={() => dispatch({ type: 'duplicateSelected' })} onDuplicateSelected={() => dispatch({ type: 'duplicateSelected' })}
onToggleLockSelected={() => dispatch({ type: 'toggleLockSelected' })} onToggleLockSelected={() => dispatch({ type: 'toggleLockSelected' })}
onToggleHideSelected={() => dispatch({ type: 'toggleHideSelected' })} onToggleHideSelected={() => dispatch({ type: 'toggleHideSelected' })}

View File

@ -27,6 +27,7 @@ export type EditorAction =
| { type: 'updatePan'; current: { screenX: number; screenY: number } } | { type: 'updatePan'; current: { screenX: number; screenY: number } }
| { type: 'endPan' } | { type: 'endPan' }
| { type: 'selectSingle'; id?: string } | { type: 'selectSingle'; id?: string }
| { type: 'selectAll' }
| { type: 'toggleSelect'; id: string } | { type: 'toggleSelect'; id: string }
| { | {
type: 'beginBoxSelect'; type: 'beginBoxSelect';
@ -489,6 +490,9 @@ export function editorReducer(state: EditorState, action: EditorAction): EditorS
case 'selectSingle': case 'selectSingle':
return { ...state, selection: { ids: action.id ? [action.id] : [] } }; return { ...state, selection: { ids: action.id ? [action.id] : [] } };
case 'selectAll':
return { ...state, selection: { ids: state.doc.screen.nodes.map((n) => n.id) } };
case 'toggleSelect': { case 'toggleSelect': {
const ids = state.selection.ids; const ids = state.selection.ids;
if (ids.includes(action.id)) { if (ids.includes(action.id)) {

View File

@ -493,7 +493,7 @@ export function convertGoViewProjectToScreen(input: GoViewProjectLike | GoViewSt
const urlLike = pickUrlLike(option); const urlLike = pickUrlLike(option);
const urlLooksLikeEmbedPage = const urlLooksLikeEmbedPage =
!!urlLike && !!urlLike &&
/(youtube\.com|youtu\.be|vimeo\.com|bilibili\.com|youku\.com|iqiyi\.com|tencent|douyin\.com|kuaishou\.com)/i.test( /(youtube\.com|youtu\.be|vimeo\.com|bilibili\.com|youku\.com|iqiyi\.com|tencent|qq\.com|mgtv\.com|ixigua\.com|huya\.com|douyu\.com|twitch\.tv|douyin\.com|kuaishou\.com)/i.test(
urlLike, urlLike,
) && ) &&
// Keep actual media URLs as video. // Keep actual media URLs as video.