@kubohiroya/turbowarp-plus-editor-workbench 0.8.0 → 0.9.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/dist/dockview-stage.js +3 -2
- package/dist/drawer-views.d.ts +1 -0
- package/dist/drawer-views.js +4 -0
- package/dist/stage-launcher.d.ts +6 -0
- package/dist/stage-launcher.js +16 -2
- package/dist/stage-surface.d.ts +2 -1
- package/dist/stage-surface.js +3 -2
- package/dist/standard-layout.d.ts +2 -1
- package/dist/standard-layout.js +32 -7
- package/dist/workspace-layout.d.ts +2 -0
- package/dist/workspace-layout.js +2 -1
- package/package.json +1 -1
- package/src/dockview-stage.ts +3 -2
- package/src/drawer-views.ts +7 -0
- package/src/stage-launcher.ts +17 -2
- package/src/stage-surface.ts +5 -2
- package/src/standard-layout.ts +29 -9
- package/src/workspace-layout.ts +4 -1
package/dist/dockview-stage.js
CHANGED
|
@@ -23,9 +23,10 @@ export function useDockviewStage(enabled, locale) {
|
|
|
23
23
|
const previous = savedDrawer.current;
|
|
24
24
|
const next = { open: false, selected: false, ...previous, ...patch };
|
|
25
25
|
if (next.open === Boolean(previous?.open) && next.selected === Boolean(previous?.selected) &&
|
|
26
|
-
next.position === previous?.position && next.width === previous?.width)
|
|
26
|
+
next.pinned === previous?.pinned && next.position === previous?.position && next.width === previous?.width)
|
|
27
27
|
return;
|
|
28
|
-
restoreDrawer(next.open || next.selected || next.position || next.width ?
|
|
28
|
+
restoreDrawer(next.open || next.selected || next.pinned !== undefined || next.position || next.width ?
|
|
29
|
+
next : undefined);
|
|
29
30
|
for (const listener of drawerListeners)
|
|
30
31
|
listener();
|
|
31
32
|
}, [drawerListeners, restoreDrawer]);
|
package/dist/drawer-views.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ declare const names: {
|
|
|
47
47
|
export declare const agentsIconPath = "M8 1.5 9.4 6.6 14.5 8 9.4 9.4 8 14.5 6.6 9.4 1.5 8 6.6 6.6Z";
|
|
48
48
|
export declare const isJapanese: (locale: string) => boolean;
|
|
49
49
|
export declare const drawerLabel: (id: keyof typeof names, locale: string) => "スプライト一覧" | "Sprites" | "プロジェクトフォルダ" | "Project folder" | "Git 履歴" | "Git history" | "AI エージェント" | "AI agents" | "ドロワーの表示" | "Drawer views";
|
|
50
|
+
export declare function drawerPinIcon(element: typeof import('react').createElement, pinned: boolean): import("react").ReactSVGElement;
|
|
50
51
|
/** The supported host views in button order, without unknown or repeated ids. */
|
|
51
52
|
export declare function availableDrawerViews(drawerViews: DrawerViews | undefined): DrawerView[];
|
|
52
53
|
/** The bar is shown only when the host supplies something besides the sprite list. */
|
package/dist/drawer-views.js
CHANGED
|
@@ -11,6 +11,10 @@ const names = {
|
|
|
11
11
|
export const agentsIconPath = 'M8 1.5 9.4 6.6 14.5 8 9.4 9.4 8 14.5 6.6 9.4 1.5 8 6.6 6.6Z';
|
|
12
12
|
export const isJapanese = (locale) => /^ja(?:-|$)/i.test(locale ?? '');
|
|
13
13
|
export const drawerLabel = (id, locale) => names[id][isJapanese(locale) ? 0 : 1];
|
|
14
|
+
export function drawerPinIcon(element, pinned) {
|
|
15
|
+
return element('svg', { 'aria-hidden': true, width: 14, height: 14, viewBox: '0 0 16 16',
|
|
16
|
+
fill: pinned ? 'currentColor' : 'none', stroke: 'currentColor', strokeWidth: 1.2, strokeLinejoin: 'round' }, element('path', { d: 'M9 2 14 7 12 8l-2 3-5-5 3-2 1-2Z' }), element('path', { d: 'm7.5 8.5-4 4' }), !pinned && element('path', { d: 'M2 2l12 12', strokeLinecap: 'round' }));
|
|
17
|
+
}
|
|
14
18
|
/** The supported host views in button order, without unknown or repeated ids. */
|
|
15
19
|
export function availableDrawerViews(drawerViews) {
|
|
16
20
|
const views = drawerViews?.views ?? [];
|
package/dist/stage-launcher.d.ts
CHANGED
|
@@ -2,6 +2,12 @@ import React, { type ComponentType } from 'react';
|
|
|
2
2
|
declare const modes: readonly ["window", "tab", "drawer"];
|
|
3
3
|
type StageMode = typeof modes[number];
|
|
4
4
|
export declare function stagePresentationItems(locale: string, current: StageMode | null, actions: Partial<Record<StageMode, () => void>>): MenuItem[];
|
|
5
|
+
export declare function stageDrawerPinItem(locale: string, pinned: boolean, setPinned: (pinned: boolean) => void): {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
icon: React.ReactSVGElement;
|
|
9
|
+
onSelect: () => void;
|
|
10
|
+
};
|
|
5
11
|
export declare function useStageDocumentFullscreen(doc?: Document): boolean;
|
|
6
12
|
export interface StageDockAction {
|
|
7
13
|
kind: 'docked' | 'opening' | 'external';
|
package/dist/stage-launcher.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import React, { createElement as element } from 'react';
|
|
2
|
+
import { drawerPinIcon } from "./drawer-views.js";
|
|
2
3
|
const labels = {
|
|
3
4
|
ja: {
|
|
4
5
|
open: 'ステージを開く',
|
|
5
6
|
menu: 'ステージの開き方',
|
|
6
7
|
window: '別ウィンドウで表示',
|
|
7
8
|
tab: 'タブで表示',
|
|
8
|
-
drawer: '引出しで表示'
|
|
9
|
+
drawer: '引出しで表示',
|
|
10
|
+
pinDrawer: '引出しを常時表示する',
|
|
11
|
+
autoHideDrawer: '引出しを自動的に隠す'
|
|
9
12
|
},
|
|
10
13
|
en: {
|
|
11
14
|
open: 'Open stage',
|
|
12
15
|
menu: 'Stage opening options',
|
|
13
16
|
window: 'Show in a separate window',
|
|
14
17
|
tab: 'Show in a tab',
|
|
15
|
-
drawer: 'Show in the drawer'
|
|
18
|
+
drawer: 'Show in the drawer',
|
|
19
|
+
pinDrawer: 'Keep the drawer open',
|
|
20
|
+
autoHideDrawer: 'Automatically hide the drawer'
|
|
16
21
|
}
|
|
17
22
|
};
|
|
18
23
|
const modes = ['window', 'tab', 'drawer'];
|
|
@@ -30,6 +35,15 @@ export function stagePresentationItems(locale, current, actions) {
|
|
|
30
35
|
strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true }, element('path', { d: icons[id] }))
|
|
31
36
|
}));
|
|
32
37
|
}
|
|
38
|
+
export function stageDrawerPinItem(locale, pinned, setPinned) {
|
|
39
|
+
const text = textFor(locale);
|
|
40
|
+
return {
|
|
41
|
+
id: 'drawer-pin',
|
|
42
|
+
label: pinned ? text.autoHideDrawer : text.pinDrawer,
|
|
43
|
+
icon: drawerPinIcon(element, !pinned),
|
|
44
|
+
onSelect: () => setPinned(!pinned)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
33
47
|
export function useStageDocumentFullscreen(doc) {
|
|
34
48
|
const [fullscreenDocument, setFullscreenDocument] = React.useState();
|
|
35
49
|
React.useLayoutEffect(() => {
|
package/dist/stage-surface.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Context, ElementType } from 'react';
|
|
|
2
2
|
import type { useDockviewStage } from './dockview-stage.ts';
|
|
3
3
|
import { type StageDockAction, type StageLauncherOptions } from './stage-launcher.ts';
|
|
4
4
|
export type { StageDockAction, StageLauncherOptions } from './stage-launcher.ts';
|
|
5
|
-
export { stagePresentationItems, useStageDocumentFullscreen } from './stage-launcher.ts';
|
|
5
|
+
export { stageDrawerPinItem, stagePresentationItems, useStageDocumentFullscreen } from './stage-launcher.ts';
|
|
6
6
|
export { StageResizeHandle } from './stage-resize-handle.ts';
|
|
7
7
|
interface StageWindowConnection<Target> {
|
|
8
8
|
ready: Promise<Target>;
|
|
@@ -26,6 +26,7 @@ export declare function createStageSurface(React: typeof import('react'), { cont
|
|
|
26
26
|
context: Context<{
|
|
27
27
|
locale: string;
|
|
28
28
|
stageDrawer?: boolean;
|
|
29
|
+
stageDrawerPinned?: boolean;
|
|
29
30
|
stageHidden?: boolean;
|
|
30
31
|
setStageDrawerOpen?(open: boolean): void;
|
|
31
32
|
setStageVisible?(visible: boolean): void;
|
package/dist/stage-surface.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createPortal } from 'react-dom';
|
|
2
2
|
import { createDockview, themeLight } from 'dockview';
|
|
3
3
|
import { StageLauncher } from "./stage-launcher.js";
|
|
4
|
-
export { stagePresentationItems, useStageDocumentFullscreen } from "./stage-launcher.js";
|
|
4
|
+
export { stageDrawerPinItem, stagePresentationItems, useStageDocumentFullscreen } from "./stage-launcher.js";
|
|
5
5
|
export { StageResizeHandle } from "./stage-resize-handle.js";
|
|
6
6
|
export function createStagePopoutHost(host, title) {
|
|
7
7
|
return {
|
|
@@ -84,7 +84,7 @@ export function stageDockActionLabel(locale, { drawer, detached, external }) {
|
|
|
84
84
|
}
|
|
85
85
|
export function createStageSurface(React, { context, EdgeDrawer, Panel }) {
|
|
86
86
|
return function StageSurface({ externalHost, onDockActionChange, placement, dockAction, launcher, openDrawerRef, closeDrawerRef, editorFullscreen, ...props }) {
|
|
87
|
-
const { locale, stageDrawer, stageHidden, setStageDrawerOpen, setStageVisible } = React.useContext(context);
|
|
87
|
+
const { locale, stageDrawer, stageDrawerPinned = true, stageHidden, setStageDrawerOpen, setStageVisible } = React.useContext(context);
|
|
88
88
|
const [drawerOpen, setDrawerOpen] = React.useState(false);
|
|
89
89
|
const localDrawerRef = React.useRef(null);
|
|
90
90
|
const focusDrawer = openDrawerRef ?? localDrawerRef;
|
|
@@ -119,6 +119,7 @@ export function createStageSurface(React, { context, EdgeDrawer, Panel }) {
|
|
|
119
119
|
const dock = stageDrawer ? React.createElement(EdgeDrawer, {
|
|
120
120
|
edge: 'right',
|
|
121
121
|
movableStage: true,
|
|
122
|
+
keepOpenOnBlur: stageDrawerPinned,
|
|
122
123
|
available: !placement?.docked && (!dockAction || dockAction.kind === 'docked'),
|
|
123
124
|
stageDrawerLayout: drawerLayout,
|
|
124
125
|
updateStageDrawer: updateDrawer,
|
|
@@ -22,7 +22,7 @@ export declare function createStandardLayout(React: any, { styles, targetStyles,
|
|
|
22
22
|
stageDrawerLayout?: StageDrawerLayout;
|
|
23
23
|
updateStageDrawer?: (patch: Partial<StageDrawerLayout>) => void;
|
|
24
24
|
}) => any;
|
|
25
|
-
EdgeDrawer: ({ edge, label, pinned, onOpenChange, portalContent, holdOpenSelector, focusPanelRef, closePanelRef, focusBoundary, showTrigger, movableStage, available, stageDrawerLayout, updateStageDrawer, children }: {
|
|
25
|
+
EdgeDrawer: ({ edge, label, pinned, onOpenChange, portalContent, holdOpenSelector, focusPanelRef, closePanelRef, focusBoundary, showTrigger, movableStage, available, keepOpenOnBlur, stageDrawerLayout, updateStageDrawer, children }: {
|
|
26
26
|
edge: any;
|
|
27
27
|
label: any;
|
|
28
28
|
pinned?: boolean;
|
|
@@ -35,6 +35,7 @@ export declare function createStandardLayout(React: any, { styles, targetStyles,
|
|
|
35
35
|
showTrigger?: boolean;
|
|
36
36
|
movableStage?: boolean;
|
|
37
37
|
available?: boolean;
|
|
38
|
+
keepOpenOnBlur?: boolean;
|
|
38
39
|
stageDrawerLayout?: StageDrawerLayout;
|
|
39
40
|
updateStageDrawer?: (patch: Partial<StageDrawerLayout>) => void;
|
|
40
41
|
children: any;
|
package/dist/standard-layout.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLayout, createSplitter, splitAxis } from "./index.js";
|
|
2
2
|
import { createTargetList } from "./targets.js";
|
|
3
|
-
import { availableDrawerViews, createDrawerViewBar, hasDrawerBar, readDrawerView, writeDrawerView } from "./drawer-views.js";
|
|
3
|
+
import { availableDrawerViews, createDrawerViewBar, drawerPinIcon, hasDrawerBar, readDrawerView, writeDrawerView } from "./drawer-views.js";
|
|
4
4
|
import { attachStageDrawerDrag } from "./stage-drawer-drag.js";
|
|
5
5
|
const isJapanese = locale => /^ja(?:-|$)/i.test(locale);
|
|
6
6
|
const singleColumnTargetWidth = 108;
|
|
@@ -21,6 +21,7 @@ export function createStandardLayout(React, { styles, targetStyles, context, Lay
|
|
|
21
21
|
const [targetsPinned, setTargetsPinned] = useState(true);
|
|
22
22
|
const [showStage, setShowStage] = useState(true);
|
|
23
23
|
const [stageDrawerOpen, setStageDrawerOpen] = useState(false);
|
|
24
|
+
const [localStageDrawerPinned, setLocalStageDrawerPinned] = useState(true);
|
|
24
25
|
const [size, setSize] = useState(null);
|
|
25
26
|
const [targetRatio, setTargetRatio] = useState(null);
|
|
26
27
|
const [viewRatio, setViewRatio] = useState(null);
|
|
@@ -37,6 +38,13 @@ export function createStandardLayout(React, { styles, targetStyles, context, Lay
|
|
|
37
38
|
const body = useRef(null);
|
|
38
39
|
const plusLayout = enabled && !props.fullscreen;
|
|
39
40
|
const stageHidden = plusLayout && !showStage;
|
|
41
|
+
const stageDrawerPinned = updateStageDrawer ? stageDrawerLayout?.pinned !== false : localStageDrawerPinned;
|
|
42
|
+
const setStageDrawerPinned = (pinned) => {
|
|
43
|
+
if (updateStageDrawer)
|
|
44
|
+
updateStageDrawer({ pinned });
|
|
45
|
+
else
|
|
46
|
+
setLocalStageDrawerPinned(pinned);
|
|
47
|
+
};
|
|
40
48
|
const japanese = isJapanese(props.locale);
|
|
41
49
|
const undockLabel = japanese ? 'アンドックボタンを表示' : 'Show undock buttons';
|
|
42
50
|
const layoutMenuLabel = japanese ? '配置メニュー' : 'Layout options';
|
|
@@ -171,11 +179,12 @@ export function createStandardLayout(React, { styles, targetStyles, context, Lay
|
|
|
171
179
|
});
|
|
172
180
|
return element(context.Provider, { value: {
|
|
173
181
|
showUndock, plusLayout, targetsPinned, setTargetsPinned, stageHidden, setStageVisible: setShowStage, stageResize, stageActionMount,
|
|
174
|
-
stageDrawer: plusLayout && stageDrawer,
|
|
182
|
+
stageDrawer: plusLayout && stageDrawer, stageDrawerPinned, setStageDrawerPinned, setStageDrawerOpen,
|
|
183
|
+
locale: props.locale,
|
|
175
184
|
drawerViews, drawerView, selectDrawerView
|
|
176
185
|
} }, Container ? element(Container, { locale: props.locale }, layout) : layout);
|
|
177
186
|
}
|
|
178
|
-
function EdgeDrawer({ edge, label, pinned = false, onOpenChange, portalContent = false, holdOpenSelector = '', focusPanelRef = undefined, closePanelRef = undefined, focusBoundary = undefined, showTrigger = true, movableStage = false, available = true, stageDrawerLayout = undefined, updateStageDrawer = undefined, children }) {
|
|
187
|
+
function EdgeDrawer({ edge, label, pinned = false, onOpenChange, portalContent = false, holdOpenSelector = '', focusPanelRef = undefined, closePanelRef = undefined, focusBoundary = undefined, showTrigger = true, movableStage = false, available = true, keepOpenOnBlur = false, stageDrawerLayout = undefined, updateStageDrawer = undefined, children }) {
|
|
179
188
|
const [hovered, setHovered] = useState(false);
|
|
180
189
|
const [localEngaged, setLocalEngaged] = useState(false);
|
|
181
190
|
const [heldOpen, setHeldOpen] = useState(false);
|
|
@@ -253,6 +262,8 @@ export function createStandardLayout(React, { styles, targetStyles, context, Lay
|
|
|
253
262
|
setEngaged(true);
|
|
254
263
|
};
|
|
255
264
|
const blur = (event) => {
|
|
265
|
+
if (keepOpenOnBlur)
|
|
266
|
+
return;
|
|
256
267
|
const target = event.relatedTarget;
|
|
257
268
|
const source = event.target;
|
|
258
269
|
// Opening the stage disables the launcher before focus moves into the drawer.
|
|
@@ -305,7 +316,7 @@ export function createStandardLayout(React, { styles, targetStyles, context, Lay
|
|
|
305
316
|
return;
|
|
306
317
|
focusBoundary.addEventListener('focusout', blur);
|
|
307
318
|
return () => focusBoundary.removeEventListener('focusout', blur);
|
|
308
|
-
}, [focusBoundary, setEngaged]);
|
|
319
|
+
}, [focusBoundary, keepOpenOnBlur, setEngaged]);
|
|
309
320
|
useLayoutEffect(() => {
|
|
310
321
|
if (!portalContent)
|
|
311
322
|
return;
|
|
@@ -321,7 +332,22 @@ export function createStandardLayout(React, { styles, targetStyles, context, Lay
|
|
|
321
332
|
node.removeEventListener('focusin', focus);
|
|
322
333
|
node.removeEventListener('focusout', blur);
|
|
323
334
|
};
|
|
324
|
-
}, [portalContent, focusBoundary, open, showTrigger, movableStage, setEngaged]);
|
|
335
|
+
}, [portalContent, focusBoundary, open, showTrigger, movableStage, keepOpenOnBlur, setEngaged]);
|
|
336
|
+
useLayoutEffect(() => {
|
|
337
|
+
if (!movableStage || keepOpenOnBlur || !open)
|
|
338
|
+
return;
|
|
339
|
+
const node = drawer.current;
|
|
340
|
+
const dismiss = (event) => {
|
|
341
|
+
const target = event.target;
|
|
342
|
+
if (node.contains(target) || focusBoundary?.contains(target))
|
|
343
|
+
return;
|
|
344
|
+
setHovered(false);
|
|
345
|
+
setEngaged(false);
|
|
346
|
+
};
|
|
347
|
+
// The restored drawer may be open without having received focus.
|
|
348
|
+
node.ownerDocument.addEventListener('pointerdown', dismiss, true);
|
|
349
|
+
return () => node.ownerDocument.removeEventListener('pointerdown', dismiss, true);
|
|
350
|
+
}, [movableStage, keepOpenOnBlur, open, focusBoundary, setEngaged]);
|
|
325
351
|
useLayoutEffect(() => {
|
|
326
352
|
if (!portalContent || !movableStage || !open)
|
|
327
353
|
return;
|
|
@@ -415,8 +441,7 @@ export function createStandardLayout(React, { styles, targetStyles, context, Lay
|
|
|
415
441
|
function DrawerPinButton({ label }) {
|
|
416
442
|
const { targetsPinned, setTargetsPinned } = useContext(context);
|
|
417
443
|
return element('button', { type: 'button', className: styles.drawerPin, 'aria-label': label, 'aria-pressed': targetsPinned,
|
|
418
|
-
title: label, onClick: () => setTargetsPinned(value => !value) }, element
|
|
419
|
-
fill: targetsPinned ? 'currentColor' : 'none', stroke: 'currentColor', strokeWidth: 1.2, strokeLinejoin: 'round' }, element('path', { d: 'M9 2 14 7 12 8l-2 3-5-5 3-2 1-2Z' }), element('path', { d: 'm7.5 8.5-4 4' }), !targetsPinned && element('path', { d: 'M2 2l12 12', strokeLinecap: 'round' })));
|
|
444
|
+
title: label, onClick: () => setTargetsPinned(value => !value) }, drawerPinIcon(element, targetsPinned));
|
|
420
445
|
}
|
|
421
446
|
function useSpriteListTools() {
|
|
422
447
|
const { locale } = useContext(context);
|
|
@@ -32,6 +32,8 @@ export interface StageDrawerLayout {
|
|
|
32
32
|
open: boolean;
|
|
33
33
|
/** Keep the drawer selected after it folds into the edge. */
|
|
34
34
|
selected: boolean;
|
|
35
|
+
/** Missing in older records, which use the default pinned behavior. */
|
|
36
|
+
pinned?: boolean;
|
|
35
37
|
position?: StageDrawerPosition;
|
|
36
38
|
width?: number;
|
|
37
39
|
}
|
package/dist/workspace-layout.js
CHANGED
|
@@ -198,12 +198,13 @@ export function readWorkspaceLayout(raw, project) {
|
|
|
198
198
|
function readStageDrawer(input) {
|
|
199
199
|
if (!record(input) || typeof input.open !== 'boolean' || typeof input.selected !== 'boolean')
|
|
200
200
|
return;
|
|
201
|
-
const { position, width } = input;
|
|
201
|
+
const { position, width, pinned } = input;
|
|
202
202
|
const fraction = (value) => size(value) && value <= 1;
|
|
203
203
|
const edge = (value) => value === 0 || value === 1;
|
|
204
204
|
return {
|
|
205
205
|
open: input.open,
|
|
206
206
|
selected: input.open || input.selected,
|
|
207
|
+
...(typeof pinned === 'boolean' && { pinned }),
|
|
207
208
|
...(size(width) && width > 0 && { width }),
|
|
208
209
|
...(record(position) && fraction(position.x) && fraction(position.y) &&
|
|
209
210
|
(edge(position.x) || edge(position.y)) && { position: { x: position.x, y: position.y } })
|
package/package.json
CHANGED
package/src/dockview-stage.ts
CHANGED
|
@@ -37,8 +37,9 @@ export function useDockviewStage(enabled: boolean, locale: string) {
|
|
|
37
37
|
const previous = savedDrawer.current;
|
|
38
38
|
const next = {open: false, selected: false, ...previous, ...patch};
|
|
39
39
|
if (next.open === Boolean(previous?.open) && next.selected === Boolean(previous?.selected) &&
|
|
40
|
-
next.position === previous?.position && next.width === previous?.width) return;
|
|
41
|
-
restoreDrawer(next.open || next.selected || next.position || next.width ?
|
|
40
|
+
next.pinned === previous?.pinned && next.position === previous?.position && next.width === previous?.width) return;
|
|
41
|
+
restoreDrawer(next.open || next.selected || next.pinned !== undefined || next.position || next.width ?
|
|
42
|
+
next : undefined);
|
|
42
43
|
for (const listener of drawerListeners) listener();
|
|
43
44
|
}, [drawerListeners, restoreDrawer]);
|
|
44
45
|
const resetDrawerPresentation = React.useCallback(() => updateDrawer({open: false, selected: false}),
|
package/src/drawer-views.ts
CHANGED
|
@@ -59,6 +59,13 @@ export const agentsIconPath = 'M8 1.5 9.4 6.6 14.5 8 9.4 9.4 8 14.5 6.6 9.4 1.5
|
|
|
59
59
|
export const isJapanese =(locale: string) => /^ja(?:-|$)/i.test(locale ?? '');
|
|
60
60
|
export const drawerLabel = (id: keyof typeof names, locale: string) => names[id][isJapanese(locale) ? 0 : 1];
|
|
61
61
|
|
|
62
|
+
export function drawerPinIcon(element: typeof import('react').createElement, pinned: boolean) {
|
|
63
|
+
return element('svg', {'aria-hidden': true, width: 14, height: 14, viewBox: '0 0 16 16',
|
|
64
|
+
fill: pinned ? 'currentColor' : 'none', stroke: 'currentColor', strokeWidth: 1.2, strokeLinejoin: 'round'},
|
|
65
|
+
element('path', {d: 'M9 2 14 7 12 8l-2 3-5-5 3-2 1-2Z'}), element('path', {d: 'm7.5 8.5-4 4'}),
|
|
66
|
+
!pinned && element('path', {d: 'M2 2l12 12', strokeLinecap: 'round'}));
|
|
67
|
+
}
|
|
68
|
+
|
|
62
69
|
/** The supported host views in button order, without unknown or repeated ids. */
|
|
63
70
|
export function availableDrawerViews(drawerViews: DrawerViews | undefined): DrawerView[] {
|
|
64
71
|
const views = drawerViews?.views ?? [];
|
package/src/stage-launcher.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, {createElement as element, type ComponentType} from 'react';
|
|
2
|
+
import {drawerPinIcon} from './drawer-views.ts';
|
|
2
3
|
|
|
3
4
|
const labels = {
|
|
4
5
|
ja: {
|
|
@@ -6,14 +7,18 @@ const labels = {
|
|
|
6
7
|
menu: 'ステージの開き方',
|
|
7
8
|
window: '別ウィンドウで表示',
|
|
8
9
|
tab: 'タブで表示',
|
|
9
|
-
drawer: '引出しで表示'
|
|
10
|
+
drawer: '引出しで表示',
|
|
11
|
+
pinDrawer: '引出しを常時表示する',
|
|
12
|
+
autoHideDrawer: '引出しを自動的に隠す'
|
|
10
13
|
},
|
|
11
14
|
en: {
|
|
12
15
|
open: 'Open stage',
|
|
13
16
|
menu: 'Stage opening options',
|
|
14
17
|
window: 'Show in a separate window',
|
|
15
18
|
tab: 'Show in a tab',
|
|
16
|
-
drawer: 'Show in the drawer'
|
|
19
|
+
drawer: 'Show in the drawer',
|
|
20
|
+
pinDrawer: 'Keep the drawer open',
|
|
21
|
+
autoHideDrawer: 'Automatically hide the drawer'
|
|
17
22
|
}
|
|
18
23
|
};
|
|
19
24
|
|
|
@@ -36,6 +41,16 @@ export function stagePresentationItems(locale: string, current: StageMode | null
|
|
|
36
41
|
}));
|
|
37
42
|
}
|
|
38
43
|
|
|
44
|
+
export function stageDrawerPinItem(locale: string, pinned: boolean, setPinned: (pinned: boolean) => void) {
|
|
45
|
+
const text = textFor(locale);
|
|
46
|
+
return {
|
|
47
|
+
id: 'drawer-pin',
|
|
48
|
+
label: pinned ? text.autoHideDrawer : text.pinDrawer,
|
|
49
|
+
icon: drawerPinIcon(element, !pinned),
|
|
50
|
+
onSelect: () => setPinned(!pinned)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
39
54
|
export function useStageDocumentFullscreen(doc?: Document) {
|
|
40
55
|
const [fullscreenDocument, setFullscreenDocument] = React.useState<Document>();
|
|
41
56
|
React.useLayoutEffect(() => {
|
package/src/stage-surface.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {createDockview, themeLight} from 'dockview';
|
|
|
5
5
|
import {StageLauncher, type StageDockAction, type StageLauncherOptions} from './stage-launcher.ts';
|
|
6
6
|
|
|
7
7
|
export type {StageDockAction, StageLauncherOptions} from './stage-launcher.ts';
|
|
8
|
-
export {stagePresentationItems, useStageDocumentFullscreen} from './stage-launcher.ts';
|
|
8
|
+
export {stageDrawerPinItem, stagePresentationItems, useStageDocumentFullscreen} from './stage-launcher.ts';
|
|
9
9
|
export {StageResizeHandle} from './stage-resize-handle.ts';
|
|
10
10
|
|
|
11
11
|
interface StageWindowConnection<Target> {
|
|
@@ -112,6 +112,7 @@ export function createStageSurface(React: typeof import('react'), {
|
|
|
112
112
|
context: Context<{
|
|
113
113
|
locale: string;
|
|
114
114
|
stageDrawer?: boolean;
|
|
115
|
+
stageDrawerPinned?: boolean;
|
|
115
116
|
stageHidden?: boolean;
|
|
116
117
|
setStageDrawerOpen?(open: boolean): void;
|
|
117
118
|
setStageVisible?(visible: boolean): void;
|
|
@@ -129,7 +130,8 @@ export function createStageSurface(React: typeof import('react'), {
|
|
|
129
130
|
editorFullscreen?: boolean;
|
|
130
131
|
[key: string]: any;
|
|
131
132
|
}) {
|
|
132
|
-
const {locale, stageDrawer, stageHidden, setStageDrawerOpen, setStageVisible} =
|
|
133
|
+
const {locale, stageDrawer, stageDrawerPinned = true, stageHidden, setStageDrawerOpen, setStageVisible} =
|
|
134
|
+
React.useContext(context);
|
|
133
135
|
const [drawerOpen, setDrawerOpen] = React.useState(false);
|
|
134
136
|
const localDrawerRef = React.useRef<() => void>(null);
|
|
135
137
|
const focusDrawer = openDrawerRef ?? localDrawerRef;
|
|
@@ -163,6 +165,7 @@ export function createStageSurface(React: typeof import('react'), {
|
|
|
163
165
|
const dock = stageDrawer ? React.createElement(EdgeDrawer, {
|
|
164
166
|
edge: 'right',
|
|
165
167
|
movableStage: true,
|
|
168
|
+
keepOpenOnBlur: stageDrawerPinned,
|
|
166
169
|
available: !placement?.docked && (!dockAction || dockAction.kind === 'docked'),
|
|
167
170
|
stageDrawerLayout: drawerLayout,
|
|
168
171
|
updateStageDrawer: updateDrawer,
|
package/src/standard-layout.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {createLayout, createSplitter, splitAxis} from './index.ts';
|
|
2
2
|
import {createTargetList} from './targets.ts';
|
|
3
3
|
import type {DrawerViews} from './drawer-views.ts';
|
|
4
|
-
import {availableDrawerViews, createDrawerViewBar, hasDrawerBar, readDrawerView, writeDrawerView} from './drawer-views.ts';
|
|
4
|
+
import {availableDrawerViews, createDrawerViewBar, drawerPinIcon, hasDrawerBar, readDrawerView, writeDrawerView} from './drawer-views.ts';
|
|
5
5
|
import {attachStageDrawerDrag} from './stage-drawer-drag.ts';
|
|
6
6
|
import type {StageDrawerLayout, StageDrawerPosition} from './workspace-layout.ts';
|
|
7
7
|
|
|
@@ -34,6 +34,7 @@ export function createStandardLayout(React, {styles, targetStyles, context, Layo
|
|
|
34
34
|
const [targetsPinned, setTargetsPinned] = useState(true);
|
|
35
35
|
const [showStage, setShowStage] = useState(true);
|
|
36
36
|
const [stageDrawerOpen, setStageDrawerOpen] = useState(false);
|
|
37
|
+
const [localStageDrawerPinned, setLocalStageDrawerPinned] = useState(true);
|
|
37
38
|
const [size, setSize] = useState(null);
|
|
38
39
|
const [targetRatio, setTargetRatio] = useState(null);
|
|
39
40
|
const [viewRatio, setViewRatio] = useState(null);
|
|
@@ -50,6 +51,11 @@ export function createStandardLayout(React, {styles, targetStyles, context, Layo
|
|
|
50
51
|
const body = useRef(null);
|
|
51
52
|
const plusLayout = enabled && !props.fullscreen;
|
|
52
53
|
const stageHidden = plusLayout && !showStage;
|
|
54
|
+
const stageDrawerPinned = updateStageDrawer ? stageDrawerLayout?.pinned !== false : localStageDrawerPinned;
|
|
55
|
+
const setStageDrawerPinned = (pinned: boolean) => {
|
|
56
|
+
if (updateStageDrawer) updateStageDrawer({pinned});
|
|
57
|
+
else setLocalStageDrawerPinned(pinned);
|
|
58
|
+
};
|
|
53
59
|
const japanese = isJapanese(props.locale);
|
|
54
60
|
const undockLabel = japanese ? 'アンドックボタンを表示' : 'Show undock buttons';
|
|
55
61
|
const layoutMenuLabel = japanese ? '配置メニュー' : 'Layout options';
|
|
@@ -188,7 +194,8 @@ export function createStandardLayout(React, {styles, targetStyles, context, Layo
|
|
|
188
194
|
});
|
|
189
195
|
return element(context.Provider, {value: {
|
|
190
196
|
showUndock, plusLayout, targetsPinned, setTargetsPinned, stageHidden, setStageVisible: setShowStage, stageResize, stageActionMount,
|
|
191
|
-
stageDrawer: plusLayout && stageDrawer,
|
|
197
|
+
stageDrawer: plusLayout && stageDrawer, stageDrawerPinned, setStageDrawerPinned, setStageDrawerOpen,
|
|
198
|
+
locale: props.locale,
|
|
192
199
|
drawerViews, drawerView, selectDrawerView
|
|
193
200
|
}},
|
|
194
201
|
Container ? element(Container, {locale: props.locale}, layout) : layout);
|
|
@@ -196,7 +203,8 @@ export function createStandardLayout(React, {styles, targetStyles, context, Layo
|
|
|
196
203
|
|
|
197
204
|
function EdgeDrawer({edge, label, pinned = false, onOpenChange, portalContent = false, holdOpenSelector = '',
|
|
198
205
|
focusPanelRef = undefined, closePanelRef = undefined, focusBoundary = undefined, showTrigger = true,
|
|
199
|
-
movableStage = false, available = true,
|
|
206
|
+
movableStage = false, available = true, keepOpenOnBlur = false,
|
|
207
|
+
stageDrawerLayout = undefined as StageDrawerLayout | undefined,
|
|
200
208
|
updateStageDrawer = undefined as ((patch: Partial<StageDrawerLayout>) => void) | undefined, children}) {
|
|
201
209
|
const [hovered, setHovered] = useState(false);
|
|
202
210
|
const [localEngaged, setLocalEngaged] = useState(false);
|
|
@@ -272,6 +280,7 @@ export function createStandardLayout(React, {styles, targetStyles, context, Layo
|
|
|
272
280
|
if (panel.current.contains(event.target as Node)) setEngaged(true);
|
|
273
281
|
};
|
|
274
282
|
const blur = (event: FocusEvent) => {
|
|
283
|
+
if (keepOpenOnBlur) return;
|
|
275
284
|
const target = event.relatedTarget as Node;
|
|
276
285
|
const source = event.target as HTMLButtonElement;
|
|
277
286
|
// Opening the stage disables the launcher before focus moves into the drawer.
|
|
@@ -317,7 +326,7 @@ export function createStandardLayout(React, {styles, targetStyles, context, Layo
|
|
|
317
326
|
if (!focusBoundary) return;
|
|
318
327
|
focusBoundary.addEventListener('focusout', blur);
|
|
319
328
|
return () => focusBoundary.removeEventListener('focusout', blur);
|
|
320
|
-
}, [focusBoundary, setEngaged]);
|
|
329
|
+
}, [focusBoundary, keepOpenOnBlur, setEngaged]);
|
|
321
330
|
|
|
322
331
|
useLayoutEffect(() => {
|
|
323
332
|
if (!portalContent) return;
|
|
@@ -333,7 +342,21 @@ export function createStandardLayout(React, {styles, targetStyles, context, Layo
|
|
|
333
342
|
node.removeEventListener('focusin', focus);
|
|
334
343
|
node.removeEventListener('focusout', blur);
|
|
335
344
|
};
|
|
336
|
-
}, [portalContent, focusBoundary, open, showTrigger, movableStage, setEngaged]);
|
|
345
|
+
}, [portalContent, focusBoundary, open, showTrigger, movableStage, keepOpenOnBlur, setEngaged]);
|
|
346
|
+
|
|
347
|
+
useLayoutEffect(() => {
|
|
348
|
+
if (!movableStage || keepOpenOnBlur || !open) return;
|
|
349
|
+
const node = drawer.current as HTMLElement;
|
|
350
|
+
const dismiss = (event: PointerEvent) => {
|
|
351
|
+
const target = event.target as Node;
|
|
352
|
+
if (node.contains(target) || focusBoundary?.contains(target)) return;
|
|
353
|
+
setHovered(false);
|
|
354
|
+
setEngaged(false);
|
|
355
|
+
};
|
|
356
|
+
// The restored drawer may be open without having received focus.
|
|
357
|
+
node.ownerDocument.addEventListener('pointerdown', dismiss, true);
|
|
358
|
+
return () => node.ownerDocument.removeEventListener('pointerdown', dismiss, true);
|
|
359
|
+
}, [movableStage, keepOpenOnBlur, open, focusBoundary, setEngaged]);
|
|
337
360
|
|
|
338
361
|
useLayoutEffect(() => {
|
|
339
362
|
if (!portalContent || !movableStage || !open) return;
|
|
@@ -443,10 +466,7 @@ export function createStandardLayout(React, {styles, targetStyles, context, Layo
|
|
|
443
466
|
const {targetsPinned, setTargetsPinned} = useContext(context);
|
|
444
467
|
return element('button', {type: 'button', className: styles.drawerPin, 'aria-label': label, 'aria-pressed': targetsPinned,
|
|
445
468
|
title: label, onClick: () => setTargetsPinned(value => !value)},
|
|
446
|
-
element
|
|
447
|
-
fill: targetsPinned ? 'currentColor' : 'none', stroke: 'currentColor', strokeWidth: 1.2, strokeLinejoin: 'round'},
|
|
448
|
-
element('path', {d: 'M9 2 14 7 12 8l-2 3-5-5 3-2 1-2Z'}), element('path', {d: 'm7.5 8.5-4 4'}),
|
|
449
|
-
!targetsPinned && element('path', {d: 'M2 2l12 12', strokeLinecap: 'round'})));
|
|
469
|
+
drawerPinIcon(element, targetsPinned));
|
|
450
470
|
}
|
|
451
471
|
|
|
452
472
|
function useSpriteListTools() {
|
package/src/workspace-layout.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface StageDrawerLayout {
|
|
|
21
21
|
open: boolean;
|
|
22
22
|
/** Keep the drawer selected after it folds into the edge. */
|
|
23
23
|
selected: boolean;
|
|
24
|
+
/** Missing in older records, which use the default pinned behavior. */
|
|
25
|
+
pinned?: boolean;
|
|
24
26
|
position?: StageDrawerPosition;
|
|
25
27
|
width?: number;
|
|
26
28
|
}
|
|
@@ -212,12 +214,13 @@ export function readWorkspaceLayout(raw: string, project?: string): WorkspaceLay
|
|
|
212
214
|
|
|
213
215
|
function readStageDrawer(input: unknown): StageDrawerLayout | undefined {
|
|
214
216
|
if (!record(input) || typeof input.open !== 'boolean' || typeof input.selected !== 'boolean') return;
|
|
215
|
-
const {position, width} = input;
|
|
217
|
+
const {position, width, pinned} = input;
|
|
216
218
|
const fraction = (value: unknown): value is number => size(value) && value <= 1;
|
|
217
219
|
const edge = (value: number) => value === 0 || value === 1;
|
|
218
220
|
return {
|
|
219
221
|
open: input.open,
|
|
220
222
|
selected: input.open || input.selected,
|
|
223
|
+
...(typeof pinned === 'boolean' && {pinned}),
|
|
221
224
|
...(size(width) && width > 0 && {width}),
|
|
222
225
|
...(record(position) && fraction(position.x) && fraction(position.y) &&
|
|
223
226
|
(edge(position.x) || edge(position.y)) && {position: {x: position.x, y: position.y}})
|