diff --git a/apps/catalog/src/EditorDockExample.tsx b/apps/catalog/src/EditorDockExample.tsx index e65dc80..a2274ed 100644 --- a/apps/catalog/src/EditorDockExample.tsx +++ b/apps/catalog/src/EditorDockExample.tsx @@ -1,11 +1,11 @@ import {useState} from 'react'; import {Button,Window,Description,EditorDockLayout,EditorWorkspace,type EditorDockState} from '@nodedc/ui-react'; export function EditorDockExample({inWindow=false}:{inWindow?:boolean}){ - const [modal,setModal]=useState(false); + const [modal,setModal]=useState(false),[purpose,setPurpose]=useState<'edit'|'view'>('edit'); const [editing,setEditing]=useState(false),[open,setOpen]=useState({objects:true,materials:true}); const [layout,setLayout]=useState({tree:{axis:'y',ratio:70,first:{axis:'x',ratio:25,first:{id:'objects'},second:{id:'viewport'}},second:{id:'materials'}},floating:{}}); - return <>{!inWindow&&<>setModal(false)}>}
- setEditing(false)}> + return <>{!inWindow&&<>setModal(false)}>}
+ setEditing(false)} headerActions={purpose==='view'?:undefined}> Закреплённая сцена
} tools={[{id:'objects',title:'Объекты',label:'Объекты',open:open.objects,onClose:()=>setOpen(v=>({...v,objects:false})),content:Сцена → Модель → Детали}, {id:'materials',title:'Материалы',label:'Материалы',open:open.materials,onClose:()=>setOpen(v=>({...v,materials:false})),content:Перетащите шапку к краю, рядом с другим инструментом или в центр сцены.}]}/> diff --git a/docs/WINDOWS_AND_LAYERS.md b/docs/WINDOWS_AND_LAYERS.md index 5ad991c..66ed9ce 100644 --- a/docs/WINDOWS_AND_LAYERS.md +++ b/docs/WINDOWS_AND_LAYERS.md @@ -159,3 +159,5 @@ close without also closing the battery/detail window. Portal typography is self-contained: Window text base is md/13 px, its title is title/18 px, and explanatory/status paragraphs use Description/sm/12 px. This stays identical in centered and floating modes and is independent of the host body size. + +`EditorWorkspace purpose="view"` reuses the same stable host and docking grammar for viewers. Back/close return the mounted view to its inline slot; no edit-completion action is shown. Optional `headerActions` keeps application actions in the fixed window header. The default `purpose="edit"` preserves existing editors. The living docking example demonstrates both purposes. diff --git a/packages/ui-react/src/EditorWorkspace.tsx b/packages/ui-react/src/EditorWorkspace.tsx index 621b2a6..d86f880 100644 --- a/packages/ui-react/src/EditorWorkspace.tsx +++ b/packages/ui-react/src/EditorWorkspace.tsx @@ -5,9 +5,9 @@ import {Icon} from './Icon.js'; import {WindowSuspensionContext} from './WindowSuspensionContext.js'; import {cn} from './cn.js'; -export interface EditorWorkspaceProps {editing:boolean;title:ReactNode;subtitle?:ReactNode;onBack:()=>void;children:ReactNode;className?:string} +export interface EditorWorkspaceProps {editing:boolean;title:ReactNode;subtitle?:ReactNode;onBack:()=>void;children:ReactNode;className?:string;purpose?:'edit'|'view';headerActions?:ReactNode} /** One mounted renderer moves between its original slot and a modeless editor window. */ -export function EditorWorkspace({editing,title,subtitle,onBack,children,className}:EditorWorkspaceProps){ +export function EditorWorkspace({editing,title,subtitle,onBack,children,className,purpose='edit',headerActions}:EditorWorkspaceProps){ const suspend=useContext(WindowSuspensionContext); useLayoutEffect(()=>{if(editing)return suspend?.();},[editing,suspend]); const inline=useRef(null),[host]=useState(()=>document.createElement('div')); @@ -28,10 +28,11 @@ export function EditorWorkspace({editing,title,subtitle,onBack,children,classNam {editing&&

{title}

{subtitle&&

{subtitle}

}
- - setExpanded(v=>!v)}> - - + {headerActions} + + setExpanded(v=>!v)}> + {purpose==='edit'&&} +
}
{children}
diff --git a/registry/components.json b/registry/components.json index 5e9ab70..a48f3bc 100644 --- a/registry/components.json +++ b/registry/components.json @@ -1400,7 +1400,8 @@ "Hidden tools retain their docking placement and remembered floating rectangle. Viewport clamps never overwrite preferred geometry.", "EditorWorkspace keeps one mounted portal host, moves it atomically when supported, and restores its original slot on return. It never changes the source-view layout.", "The fixed editor header is outside docking bounds. Back, edit completion and close return to the original view.", - "When opened inside Window, the editor suspends that overlay, backdrop and focus trap without unmounting; returning restores the same window." + "When opened inside Window, the editor suspends that overlay, backdrop and focus trap without unmounting; returning restores the same window.", + "EditorWorkspace purpose=view uses the same mounted host, return/fullscreen behavior and optional fixed headerActions; purpose=edit remains the compatible default." ] }, {