refactor: improve goView import and editor context menu parity
This commit is contained in:
parent
95f94e0733
commit
e58b240778
@ -14,9 +14,11 @@ export function ContextMenu(props: {
|
||||
selectionIds: string[];
|
||||
selectionAllLocked: boolean;
|
||||
selectionAllHidden: boolean;
|
||||
hasAnyNodes?: boolean;
|
||||
onClose: () => void;
|
||||
onAddTextAt: (x: number, y: number) => void;
|
||||
onSelectSingle?: (id?: string) => void;
|
||||
onSelectAll?: () => void;
|
||||
onDuplicateSelected?: () => void;
|
||||
onToggleLockSelected?: () => void;
|
||||
onToggleHideSelected?: () => void;
|
||||
@ -136,6 +138,16 @@ export function ContextMenu(props: {
|
||||
/>
|
||||
) : 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)' }} />
|
||||
|
||||
<MenuItem
|
||||
|
||||
@ -509,9 +509,11 @@ export function EditorApp() {
|
||||
selectionIds={state.selection.ids}
|
||||
selectionAllLocked={selectionAllLocked}
|
||||
selectionAllHidden={selectionAllHidden}
|
||||
hasAnyNodes={state.doc.screen.nodes.length > 0}
|
||||
onClose={closeContextMenu}
|
||||
onAddTextAt={(x, y) => dispatch({ type: 'addTextAt', x, y })}
|
||||
onSelectSingle={(id) => dispatch({ type: 'selectSingle', id })}
|
||||
onSelectAll={() => dispatch({ type: 'selectAll' })}
|
||||
onDuplicateSelected={() => dispatch({ type: 'duplicateSelected' })}
|
||||
onToggleLockSelected={() => dispatch({ type: 'toggleLockSelected' })}
|
||||
onToggleHideSelected={() => dispatch({ type: 'toggleHideSelected' })}
|
||||
|
||||
@ -27,6 +27,7 @@ export type EditorAction =
|
||||
| { type: 'updatePan'; current: { screenX: number; screenY: number } }
|
||||
| { type: 'endPan' }
|
||||
| { type: 'selectSingle'; id?: string }
|
||||
| { type: 'selectAll' }
|
||||
| { type: 'toggleSelect'; id: string }
|
||||
| {
|
||||
type: 'beginBoxSelect';
|
||||
@ -489,6 +490,9 @@ export function editorReducer(state: EditorState, action: EditorAction): EditorS
|
||||
case 'selectSingle':
|
||||
return { ...state, selection: { ids: action.id ? [action.id] : [] } };
|
||||
|
||||
case 'selectAll':
|
||||
return { ...state, selection: { ids: state.doc.screen.nodes.map((n) => n.id) } };
|
||||
|
||||
case 'toggleSelect': {
|
||||
const ids = state.selection.ids;
|
||||
if (ids.includes(action.id)) {
|
||||
|
||||
@ -493,7 +493,7 @@ export function convertGoViewProjectToScreen(input: GoViewProjectLike | GoViewSt
|
||||
const urlLike = pickUrlLike(option);
|
||||
const urlLooksLikeEmbedPage =
|
||||
!!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,
|
||||
) &&
|
||||
// Keep actual media URLs as video.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user