@kubohiroya/turbowarp-plus-editor-workbench 0.27.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EDITOR-MIGRATION.md +5 -0
- package/README.ja.md +9 -0
- package/dist/basic-panel.d.ts +52 -0
- package/dist/basic-panel.js +153 -0
- package/dist/editor-tabs.d.ts +37 -0
- package/dist/editor-tabs.js +550 -0
- package/dist/popup-layout.d.ts +20 -0
- package/dist/popup-layout.js +59 -0
- package/dist/project-folder-workflows.d.ts +31 -0
- package/dist/project-folder-workflows.js +1 -0
- package/dist/project-payload-forms.d.ts +8 -0
- package/dist/project-payload-forms.js +184 -0
- package/dist/project-tools/diagnostics.d.ts +13 -0
- package/dist/project-tools/diagnostics.js +65 -0
- package/dist/project-tools/dialog.d.ts +21 -0
- package/dist/project-tools/dialog.js +363 -0
- package/dist/project-tools/history.d.ts +8 -0
- package/dist/project-tools/history.js +22 -0
- package/dist/project-tools/integration.d.ts +65 -0
- package/dist/project-tools/integration.js +356 -0
- package/dist/project-tools/links.d.ts +3 -0
- package/dist/project-tools/links.js +36 -0
- package/dist/project-tools/properties.d.ts +51 -0
- package/dist/project-tools/properties.js +268 -0
- package/dist/sprite-tabs.d.ts +1 -0
- package/dist/sprite-tabs.js +1 -0
- package/dist/stage-display-menu.d.ts +21 -0
- package/dist/stage-display-menu.js +156 -0
- package/dist/stage-panel.d.ts +29 -0
- package/dist/stage-panel.js +105 -0
- package/package.json +78 -9
- package/src/basic-panel.tsx +207 -0
- package/src/editor-tabs.tsx +591 -0
- package/src/popup-layout.css +4 -0
- package/src/popup-layout.tsx +81 -0
- package/src/project-dialog.css +39 -0
- package/src/project-folder-workflows.ts +32 -0
- package/src/project-payload-forms.ts +179 -0
- package/src/project-snackbar.css +85 -0
- package/src/project-tools/diagnostics.ts +51 -0
- package/src/project-tools/dialog.ts +341 -0
- package/src/project-tools/history.ts +20 -0
- package/src/project-tools/integration.ts +366 -0
- package/src/project-tools/links.ts +31 -0
- package/src/project-tools/properties.ts +251 -0
- package/src/sprite-tabs.ts +2 -1
- package/src/stage-display-menu.css +28 -0
- package/src/stage-display-menu.tsx +177 -0
- package/src/stage-panel.tsx +127 -0
package/src/sprite-tabs.ts
CHANGED
|
@@ -1578,7 +1578,7 @@ type SpriteTabsProps<Snapshot> = Omit<TabOptions<Snapshot>, 'activateSection' |
|
|
|
1578
1578
|
/** Open a script chosen in the relationship graph, including one on another target. */
|
|
1579
1579
|
openRelationScript?(endpoint: ScriptEndpoint): void;
|
|
1580
1580
|
/** The function or hat script shown beside the sprite, which the list of hats and functions highlights. */
|
|
1581
|
-
selectedScript?: {targetId: string; id: string};
|
|
1581
|
+
selectedScript?: {targetId: string; id: string; focusRequest?: number};
|
|
1582
1582
|
/**
|
|
1583
1583
|
* Make a new function of this name in the target: a standard custom block, whose block text is the name,
|
|
1584
1584
|
* or a TurboWarp-Plus named function. Resolves with the id of the new hat, or with nothing when nothing
|
|
@@ -1849,6 +1849,7 @@ function SpriteTabs<Snapshot>(props: SpriteTabsProps<Snapshot>) {
|
|
|
1849
1849
|
((hat: SpriteHatScript, options?: OpenScriptOptions) => props.openScript!(targetId, hat, options)),
|
|
1850
1850
|
onOpenRelationScript: props.openRelationScript,
|
|
1851
1851
|
selectedId: props.selectedScript?.targetId === targetId ? props.selectedScript.id : undefined,
|
|
1852
|
+
focusRequest: props.selectedScript?.targetId === targetId ? props.selectedScript.focusRequest : undefined,
|
|
1852
1853
|
onCreate: props.createFunction && (async (functionKind: FunctionKind, name: string) => {
|
|
1853
1854
|
const created = await props.createFunction!(targetId, functionKind, name);
|
|
1854
1855
|
// Show the new function now rather than at the next project change.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MPL-2.0 */
|
|
2
|
+
:global([data-movable-stage]) .stage-display-menu {
|
|
3
|
+
background: transparent;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
:global([data-movable-stage]) .stage-display-menu > button {
|
|
7
|
+
border: 0;
|
|
8
|
+
padding: calc(0.25rem + 1px);
|
|
9
|
+
background: transparent;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.visible-when-stage-hidden {
|
|
13
|
+
visibility: visible;
|
|
14
|
+
pointer-events: auto;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:global([class*="stage-header_fullscreen-buttons-row_"]):has(> .fullscreen-layout-menu)
|
|
18
|
+
> :global([class*="stage-header_unselect-wrapper_"]:not([class*="stage-header_settings-button_"])) {
|
|
19
|
+
display: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
img.directional {
|
|
23
|
+
filter: var(--filter-icon-gray);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
[dir="rtl"] .directional {
|
|
27
|
+
transform: scaleX(-1);
|
|
28
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {createPortal} from 'react-dom';
|
|
4
|
+
import {IconMenuButton, type IconMenuItem} from '@kubohiroya/turbowarp-plus-editor-windows';
|
|
5
|
+
import {panelLayoutIconPath} from './index.ts';
|
|
6
|
+
import {stageDockActionLabel, stageDrawerPinItem, stagePresentationItems,
|
|
7
|
+
useStageDocumentFullscreen} from './stage-surface.ts';
|
|
8
|
+
|
|
9
|
+
export function createStageDisplayMenu({WindowLayoutContext, StageDisplayMenuContext, layoutFlags, styles,
|
|
10
|
+
workbenchStyles, fullscreenIcon, exitFullscreenIcon, connectFullscreen, fullscreenMount}: {
|
|
11
|
+
WindowLayoutContext: React.Context<any>; StageDisplayMenuContext: React.Context<any>;
|
|
12
|
+
layoutFlags: {stageDisplayMenu: boolean}; styles: Record<string, string>; workbenchStyles: Record<string, string>;
|
|
13
|
+
fullscreenIcon: string; exitFullscreenIcon: string;
|
|
14
|
+
connectFullscreen(component: React.ComponentType<any>): React.ComponentType<any>;
|
|
15
|
+
fullscreenMount(header: HTMLElement): HTMLElement | null;
|
|
16
|
+
}) {
|
|
17
|
+
const stageLayoutIcon = (
|
|
18
|
+
<svg viewBox="-4 -4 24 24" fill="none" stroke="currentColor" strokeWidth="1.4"
|
|
19
|
+
strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
20
|
+
<path d={panelLayoutIconPath} />
|
|
21
|
+
</svg>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
function PresetIcon({icon}) {
|
|
25
|
+
return <img className={styles.directional} src={typeof icon === 'function' ? icon() : icon} alt="" draggable={false} />;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const isJapanese = locale => /^ja(?:-|$)/i.test(locale);
|
|
29
|
+
const menuLabel = locale => isJapanese(locale) ? 'ステージの表示' : 'Stage display';
|
|
30
|
+
|
|
31
|
+
function fullscreenItem(locale: string, active: boolean, onSelect: () => void, disabled = false): IconMenuItem {
|
|
32
|
+
const label = active ? (isJapanese(locale) ? '全画面表示を終了' : 'Exit full screen mode') :
|
|
33
|
+
(isJapanese(locale) ? '全画面表示にする' : 'Enter full screen mode');
|
|
34
|
+
return {id: 'fullscreen', label, icon: <PresetIcon icon={active ? exitFullscreenIcon : fullscreenIcon} />,
|
|
35
|
+
onSelect, disabled};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function dockIcon(returning: boolean) {
|
|
39
|
+
return <svg className={styles.directional} viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5"
|
|
40
|
+
strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
41
|
+
<path d="M6 4H3v9h9v-3" />
|
|
42
|
+
<path d={returning ? 'M12.5 3.5 7 9m0-4v4h4' : 'M8 3h5v5m0-5L7 9'} />
|
|
43
|
+
</svg>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function StageLayoutMenu({locale, items, className = ''}: {locale: string; items: IconMenuItem[]; className?: string}) {
|
|
47
|
+
return <IconMenuButton label={menuLabel(locale)} icon={stageLayoutIcon} items={items}
|
|
48
|
+
className={`${styles.stageDisplayMenu} ${workbenchStyles.stagePresentationMenu} ${className}`} />;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const EditorStageFullscreenMenu = connectFullscreen(function EditorStageFullscreenMenu({header, locale, onExit}: {
|
|
52
|
+
header: HTMLElement; locale: string; onExit(): void;
|
|
53
|
+
}) {
|
|
54
|
+
// Use the GUI's existing fullscreen controls row, including its alignment and stacking.
|
|
55
|
+
const mount = fullscreenMount(header);
|
|
56
|
+
return mount ? createPortal(
|
|
57
|
+
<StageLayoutMenu locale={locale} className={styles.fullscreenLayoutMenu}
|
|
58
|
+
items={[fullscreenItem(locale, true, onExit)]} />, mount
|
|
59
|
+
) : null;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
function DisplayMenu({locale, presets, fullscreen}) {
|
|
63
|
+
const {dockAction, stage, launcher, openDrawer, closeDrawer} = React.useContext(StageDisplayMenuContext) ?? {};
|
|
64
|
+
const {plusLayout, stageDrawer, stageDrawerPinned, setStageDrawerPinned, stageHidden, setStageVisible} =
|
|
65
|
+
React.useContext(WindowLayoutContext);
|
|
66
|
+
const japanese = isJapanese(locale);
|
|
67
|
+
const canToggleVisibility = plusLayout && (!dockAction || dockAction.kind === 'docked');
|
|
68
|
+
const visibilityLabel = stageHidden ? (japanese ? 'ステージを表示' : 'Show stage') :
|
|
69
|
+
(japanese ? 'ステージを隠す' : 'Hide stage');
|
|
70
|
+
const detached = dockAction?.kind === 'external';
|
|
71
|
+
const popupDocument = detached ? dockAction.mount?.ownerDocument : undefined;
|
|
72
|
+
const popupFullscreen = useStageDocumentFullscreen(popupDocument);
|
|
73
|
+
if (popupDocument) {
|
|
74
|
+
const toggleFullscreen = () => {
|
|
75
|
+
const operation = popupFullscreen ? popupDocument.exitFullscreen() :
|
|
76
|
+
popupDocument.documentElement.requestFullscreen();
|
|
77
|
+
void operation.catch(() => {});
|
|
78
|
+
};
|
|
79
|
+
return <StageLayoutMenu locale={locale} items={[
|
|
80
|
+
fullscreenItem(locale, popupFullscreen, toggleFullscreen, !popupFullscreen && !popupDocument.fullscreenEnabled),
|
|
81
|
+
{id: 'dock', label: japanese ? 'エディターに戻る' : 'Return to the editor',
|
|
82
|
+
icon: dockIcon(true), separatorBefore: true, onSelect: dockAction.dock}
|
|
83
|
+
]} />;
|
|
84
|
+
}
|
|
85
|
+
const dockLabel = stageDockActionLabel(locale, {drawer: stageDrawer, detached, external: dockAction?.external});
|
|
86
|
+
|
|
87
|
+
const selectDisplay = action => {
|
|
88
|
+
if (stageHidden) setStageVisible(true);
|
|
89
|
+
if (detached) dockAction.dock();
|
|
90
|
+
action();
|
|
91
|
+
};
|
|
92
|
+
// Scratch GUI passes small first and full last, with an optional fixed-width preset between them.
|
|
93
|
+
const items: IconMenuItem[] = presets.slice(1, -1).map(({title, isSelected, handleClick, icon}) => ({
|
|
94
|
+
id: title,
|
|
95
|
+
label: title,
|
|
96
|
+
checked: isSelected,
|
|
97
|
+
icon: <PresetIcon icon={icon} />,
|
|
98
|
+
onSelect: () => selectDisplay(handleClick)
|
|
99
|
+
}));
|
|
100
|
+
const enterFullscreen = fullscreenItem(locale, false, () => {
|
|
101
|
+
// Dockview flushes the drawer state when the fullscreen view unmounts it.
|
|
102
|
+
stage?.resetDrawerPresentation();
|
|
103
|
+
selectDisplay(fullscreen.handleClick);
|
|
104
|
+
});
|
|
105
|
+
const openWindow = () => {
|
|
106
|
+
if (stageHidden) setStageVisible(true);
|
|
107
|
+
if (stage?.docked) stage.commands.close();
|
|
108
|
+
dockAction.undock();
|
|
109
|
+
};
|
|
110
|
+
const drawerPin = stageDrawer && !detached && !stage?.docked ?
|
|
111
|
+
stageDrawerPinItem(locale, stageDrawerPinned, setStageDrawerPinned) : undefined;
|
|
112
|
+
if (launcher && stageDrawer && !detached) {
|
|
113
|
+
const inTab = Boolean(stage?.docked);
|
|
114
|
+
const placement = stagePresentationItems(locale, inTab ? 'tab' : null, {
|
|
115
|
+
window: dockAction?.external && dockAction.kind === 'docked' ? openWindow : undefined,
|
|
116
|
+
tab: !inTab && stage?.commands ? stage.commands.open : undefined,
|
|
117
|
+
drawer: inTab ? () => {
|
|
118
|
+
stage.commands.close();
|
|
119
|
+
// The drawer becomes available after the stage tab has been removed.
|
|
120
|
+
requestAnimationFrame(() => openDrawer?.current?.());
|
|
121
|
+
} : undefined
|
|
122
|
+
}).map(item => drawerPin && item.id === 'drawer' ? drawerPin : item);
|
|
123
|
+
const close: IconMenuItem = {
|
|
124
|
+
id: 'close-placement',
|
|
125
|
+
label: inTab ? (japanese ? 'タブを閉じる' : 'Close the tab') :
|
|
126
|
+
(japanese ? '引出しを閉じる' : 'Close the drawer'),
|
|
127
|
+
icon: <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.4"
|
|
128
|
+
strokeLinecap="round" aria-hidden="true"><path d="m4.5 4.5 7 7m0-7-7 7" /></svg>,
|
|
129
|
+
onSelect: inTab ? stage.commands.close : () => closeDrawer?.current?.()
|
|
130
|
+
};
|
|
131
|
+
return <StageLayoutMenu locale={locale} items={[
|
|
132
|
+
...placement, {...enterFullscreen, separatorBefore: true}, ...items, close
|
|
133
|
+
]} />;
|
|
134
|
+
}
|
|
135
|
+
if (drawerPin) items.push(drawerPin);
|
|
136
|
+
items.push(japanese ? enterFullscreen : {...enterFullscreen, label: fullscreen.title});
|
|
137
|
+
if (canToggleVisibility) items.push({
|
|
138
|
+
id: 'visibility',
|
|
139
|
+
label: visibilityLabel,
|
|
140
|
+
onSelect: () => {
|
|
141
|
+
if (!stageHidden && !stage?.docked && closeDrawer?.current) {
|
|
142
|
+
closeDrawer.current();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (stage?.docked) stage.commands.close();
|
|
146
|
+
setStageVisible(stageHidden);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
if (stage?.commands && dockAction?.kind === 'docked') items.push({
|
|
150
|
+
id: 'workspace',
|
|
151
|
+
label: stage.docked ? stage.closeLabel : stage.openLabel,
|
|
152
|
+
onSelect: () => {
|
|
153
|
+
if (stage.docked) stage.commands.close();
|
|
154
|
+
else {
|
|
155
|
+
if (stageHidden) setStageVisible(true);
|
|
156
|
+
stage.commands.open();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
items.push({
|
|
161
|
+
id: 'dock',
|
|
162
|
+
label: dockLabel,
|
|
163
|
+
disabled: !dockAction || dockAction.kind === 'opening',
|
|
164
|
+
separatorBefore: true,
|
|
165
|
+
icon: dockIcon(detached),
|
|
166
|
+
onSelect: detached ? () => {
|
|
167
|
+
if (stageHidden) setStageVisible(true);
|
|
168
|
+
dockAction.dock();
|
|
169
|
+
} : openWindow
|
|
170
|
+
});
|
|
171
|
+
return <StageLayoutMenu locale={locale} items={items} className={stageHidden ? styles.visibleWhenStageHidden : undefined} />;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const StageDisplayMenu = layoutFlags.stageDisplayMenu ? DisplayMenu : undefined;
|
|
175
|
+
|
|
176
|
+
return {EditorStageFullscreenMenu, StageDisplayMenu};
|
|
177
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {createStageSurface, StageResizeHandle} from './stage-surface.ts';
|
|
4
|
+
|
|
5
|
+
export function createStagePanel({WindowLayoutContext, StageDisplayMenuContext, BasicPanel, EdgeDrawer,
|
|
6
|
+
EditorStageFullscreenMenu, externalHost, decorateSurface, layoutFlags, stageCanUndock, styles}: {
|
|
7
|
+
WindowLayoutContext: React.Context<any>; StageDisplayMenuContext: React.Context<any>;
|
|
8
|
+
BasicPanel: Parameters<typeof createStageSurface>[1]['Panel'];
|
|
9
|
+
EdgeDrawer: Parameters<typeof createStageSurface>[1]['EdgeDrawer'];
|
|
10
|
+
EditorStageFullscreenMenu: React.ComponentType<{header: HTMLElement; locale: string}>;
|
|
11
|
+
externalHost: Parameters<ReturnType<typeof createStageSurface>>[0]['externalHost'];
|
|
12
|
+
decorateSurface(document: Document): () => void;
|
|
13
|
+
layoutFlags: {standardLayout: boolean; stageDisplayMenu: boolean}; stageCanUndock: boolean;
|
|
14
|
+
styles: Record<string, string>;
|
|
15
|
+
}) {
|
|
16
|
+
const StageSurface = createStageSurface(React, {
|
|
17
|
+
context: WindowLayoutContext, EdgeDrawer: EdgeDrawer, Panel: BasicPanel
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
function StageViewport({aspect, width, defaultWidth, floating, workspace, useNativeKeyboard, render, renderHeader,
|
|
21
|
+
isFullScreen, inputDocument}) {
|
|
22
|
+
const {stageDrawer, stageHidden, stageResize, locale} = React.useContext(WindowLayoutContext);
|
|
23
|
+
const fit = floating || workspace;
|
|
24
|
+
const resizable = !fit && !isFullScreen && stageResize;
|
|
25
|
+
const resizeLabel = /^ja(?:-|$)/i.test(locale) ? 'ステージのサイズを変更' : 'Resize stage';
|
|
26
|
+
const viewport = React.useRef(null);
|
|
27
|
+
const header = React.useRef(null);
|
|
28
|
+
const [fullscreenHeader, setFullscreenHeader] = React.useState<HTMLElement>();
|
|
29
|
+
const [floatingWidth, setFloatingWidth] = React.useState(null);
|
|
30
|
+
const [externalBounds, setExternalBounds] = React.useState(Boolean(inputDocument));
|
|
31
|
+
React.useLayoutEffect(() => {
|
|
32
|
+
setFullscreenHeader(isFullScreen && layoutFlags.stageDisplayMenu ? header.current ?? undefined : undefined);
|
|
33
|
+
}, [isFullScreen]);
|
|
34
|
+
React.useLayoutEffect(() => {
|
|
35
|
+
if (inputDocument) {
|
|
36
|
+
setExternalBounds(true);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (!externalBounds) return;
|
|
40
|
+
// Recalculate Stage bounds after the docking portal has moved back into the editor.
|
|
41
|
+
const frame = requestAnimationFrame(() => setExternalBounds(false));
|
|
42
|
+
return () => cancelAnimationFrame(frame);
|
|
43
|
+
}, [inputDocument, externalBounds]);
|
|
44
|
+
React.useLayoutEffect(() => {
|
|
45
|
+
if (!fit) return;
|
|
46
|
+
const node = viewport.current;
|
|
47
|
+
const measure = () => {
|
|
48
|
+
const height = node.clientHeight - (header.current?.offsetHeight ?? 0) - 8;
|
|
49
|
+
if (node.clientWidth < 12 || height < 1) return;
|
|
50
|
+
// A tab or separate window is the stage's own space, so the stage grows and shrinks with it.
|
|
51
|
+
setFloatingWidth(Math.max(1, Math.floor(Math.min(node.clientWidth - 12, height * aspect))));
|
|
52
|
+
};
|
|
53
|
+
const observer = new (inputDocument?.defaultView.ResizeObserver ?? ResizeObserver)(measure);
|
|
54
|
+
measure();
|
|
55
|
+
observer.observe(node);
|
|
56
|
+
if (header.current) observer.observe(header.current);
|
|
57
|
+
return () => observer.disconnect();
|
|
58
|
+
}, [aspect, fit, inputDocument]);
|
|
59
|
+
|
|
60
|
+
const displayWidth = fit ? floatingWidth ?? Math.min(240, width ?? defaultWidth) : width;
|
|
61
|
+
const canvas = render(displayWidth, Boolean(stageDrawer || fit || externalBounds || resizable), inputDocument);
|
|
62
|
+
const resizeHandles = resizable && (stageDrawer ? ['left', 'right', 'top', 'bottom'] : ['left', 'bottom', 'corner'])
|
|
63
|
+
.map(edge => <StageResizeHandle key={edge} {...{edge, aspect, width}} limits={stageResize} label={resizeLabel}
|
|
64
|
+
className={styles.stageResizeHandle} drawer={Boolean(stageDrawer)} />);
|
|
65
|
+
return <div className={styles.stageViewport} data-floating={fit} data-stage-hidden={stageHidden || undefined}
|
|
66
|
+
data-resizable={resizable ? true : undefined} data-focusable={stageCanUndock || undefined} ref={viewport}
|
|
67
|
+
tabIndex={stageCanUndock ? -1 : undefined}
|
|
68
|
+
onClick={event => {
|
|
69
|
+
const node = event.currentTarget;
|
|
70
|
+
const target = event.target as HTMLElement;
|
|
71
|
+
if (target.closest('[role="menu"]')) return;
|
|
72
|
+
if (useNativeKeyboard && !inputDocument && target.matches('canvas')) {
|
|
73
|
+
// The GUI routes project key presses from the document body.
|
|
74
|
+
(node.ownerDocument.activeElement as HTMLElement)?.blur();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (stageCanUndock && !node.contains(node.ownerDocument.activeElement)) node.focus({preventScroll: true});
|
|
78
|
+
}}>
|
|
79
|
+
{renderHeader ? <div className={styles.stageFrame} data-fullscreen={isFullScreen || undefined} data-plus-stage-frame="">
|
|
80
|
+
<div className={styles.stageHeader} data-stage-drawer-handle="" ref={header}>
|
|
81
|
+
{renderHeader(displayWidth)}
|
|
82
|
+
{isFullScreen && fullscreenHeader && <EditorStageFullscreenMenu header={fullscreenHeader} locale={locale} />}
|
|
83
|
+
</div>
|
|
84
|
+
<div className={styles.stageCanvas}>{canvas}{!stageDrawer && resizeHandles}</div>
|
|
85
|
+
{stageDrawer && resizeHandles}
|
|
86
|
+
</div> : <div className={styles.stageCanvas}>{canvas}{resizeHandles}</div>}
|
|
87
|
+
</div>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function AppStagePanel({aspect, width, defaultWidth, render, renderHeader, isFullScreen}) {
|
|
91
|
+
const {stageActionMount} = React.useContext(WindowLayoutContext);
|
|
92
|
+
const menu = React.useContext(StageDisplayMenuContext);
|
|
93
|
+
const stage = menu?.stage;
|
|
94
|
+
const suspend = stage?.suspend;
|
|
95
|
+
const surface = stage?.surface;
|
|
96
|
+
const resizeStage = menu?.resizeStage;
|
|
97
|
+
React.useLayoutEffect(() => {
|
|
98
|
+
suspend?.(Boolean(isFullScreen));
|
|
99
|
+
}, [suspend, isFullScreen]);
|
|
100
|
+
React.useLayoutEffect(() => {
|
|
101
|
+
if (!surface) return;
|
|
102
|
+
// The native update can run while the drawer anchor is still hidden.
|
|
103
|
+
const resize = () => resizeStage(surface);
|
|
104
|
+
const observer = new ResizeObserver(resize);
|
|
105
|
+
observer.observe(surface);
|
|
106
|
+
const frame = requestAnimationFrame(resize);
|
|
107
|
+
return () => {
|
|
108
|
+
observer.disconnect();
|
|
109
|
+
cancelAnimationFrame(frame);
|
|
110
|
+
};
|
|
111
|
+
}, [surface, resizeStage, stage?.docked, isFullScreen]);
|
|
112
|
+
return <StageSurface placement={stage} externalHost={externalHost} decorate={decorateSurface}
|
|
113
|
+
launcher={menu?.launcher} dockAction={menu?.dockAction} editorFullscreen={isFullScreen}
|
|
114
|
+
openDrawerRef={menu?.openDrawer} closeDrawerRef={menu?.closeDrawer}
|
|
115
|
+
actionMount={stageActionMount ?? null} onDockActionChange={layoutFlags.stageDisplayMenu ? menu?.setDockAction : undefined}
|
|
116
|
+
dockHeight={Math.round((width ?? defaultWidth) / aspect) + (renderHeader ? 44 : 0)}
|
|
117
|
+
render={(floating, mount) => <StageViewport {...{aspect, width, defaultWidth, floating, render, renderHeader, isFullScreen}}
|
|
118
|
+
workspace={Boolean(stage?.docked && !isFullScreen)} useNativeKeyboard={Boolean(stage)}
|
|
119
|
+
inputDocument={mount?.ownerDocument} />}
|
|
120
|
+
/>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const StagePanel = stageCanUndock ? AppStagePanel :
|
|
124
|
+
(layoutFlags.standardLayout ? StageViewport : undefined);
|
|
125
|
+
|
|
126
|
+
return {StagePanel};
|
|
127
|
+
}
|