@kubohiroya/turbowarp-plus-editor-code-views 0.21.1 → 0.21.3
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 +5 -0
- package/dist/code-popout.d.ts +10 -0
- package/dist/code-popout.js +402 -0
- package/dist/context-menu-icons.d.ts +13 -0
- package/dist/context-menu-icons.js +200 -0
- package/dist/desktop-code.d.ts +11 -0
- package/dist/desktop-code.js +47 -0
- package/dist/horizontal-block-palette.d.ts +39 -0
- package/dist/horizontal-block-palette.js +774 -0
- package/dist/palette-delete-preview.d.ts +3 -0
- package/dist/palette-delete-preview.js +73 -0
- package/dist/script-arrows.js +3 -4
- package/package.json +27 -3
- package/src/code-popout.tsx +399 -0
- package/src/context-menu-icons.css +14 -0
- package/src/context-menu-icons.ts +209 -0
- package/src/desktop-code.ts +45 -0
- package/src/horizontal-block-palette.css +111 -0
- package/src/horizontal-block-palette.ts +765 -0
- package/src/palette-delete-preview.css +21 -0
- package/src/palette-delete-preview.ts +79 -0
- package/src/pin-off.svg +6 -0
- package/src/pin.svg +5 -0
- package/src/script-arrows.ts +3 -4
- package/src/styles.css +3 -1
- package/src/trash.svg +3 -0
- package/tsconfig.json +87 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
import { createCodeSession } from '@kubohiroya/turbowarp-plus-editor-code-views';
|
|
3
|
+
import { createSurface, pendingSurfaceEdits } from '@kubohiroya/turbowarp-plus-editor-windows/surfaces';
|
|
4
|
+
export function createDesktopCode({ host, layoutMenu }) {
|
|
5
|
+
const desktopCodeEnabled = Boolean(host);
|
|
6
|
+
let openCode = null;
|
|
7
|
+
const openDesktopCode = () => openCode?.();
|
|
8
|
+
function attachDesktopCode(context) {
|
|
9
|
+
if (!host)
|
|
10
|
+
return null;
|
|
11
|
+
const session = createCodeSession(context);
|
|
12
|
+
const unregister = pendingSurfaceEdits.register(() => session.flush());
|
|
13
|
+
const surfaces = new Set();
|
|
14
|
+
const menu = layoutMenu;
|
|
15
|
+
const open = (target = context.vm.editingTarget) => {
|
|
16
|
+
if (!target?.isOriginal || !context.canUse() || surfaces.size >= 2)
|
|
17
|
+
return;
|
|
18
|
+
let detach;
|
|
19
|
+
const surface = createSurface(host, state => {
|
|
20
|
+
if (state.kind === 'external') {
|
|
21
|
+
detach = session.attach({ ...state.target, target, close: () => surface.dock(),
|
|
22
|
+
duplicate: menu ? next => open(next) : undefined, layoutMenu: menu });
|
|
23
|
+
}
|
|
24
|
+
else if (state.kind === 'docked') {
|
|
25
|
+
surfaces.delete(surface);
|
|
26
|
+
detach?.();
|
|
27
|
+
if (menu)
|
|
28
|
+
session.setCanDuplicate(surfaces.size < 2);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
surfaces.add(surface);
|
|
32
|
+
if (menu)
|
|
33
|
+
session.setCanDuplicate(surfaces.size < 2);
|
|
34
|
+
surface.undock({ timeoutMs: 15000 });
|
|
35
|
+
};
|
|
36
|
+
openCode = open;
|
|
37
|
+
return { dispose() {
|
|
38
|
+
if (openCode === open)
|
|
39
|
+
openCode = null;
|
|
40
|
+
unregister();
|
|
41
|
+
session.dispose();
|
|
42
|
+
for (const surface of surfaces)
|
|
43
|
+
surface.dock();
|
|
44
|
+
} };
|
|
45
|
+
}
|
|
46
|
+
return { desktopCodeEnabled, openDesktopCode, attachDesktopCode };
|
|
47
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { PaletteCategoryInfo } from './palette-category-visibility.js';
|
|
2
|
+
/** Each editor host has its own palette state and lifecycle. */
|
|
3
|
+
export declare function createHorizontalBlockPalette({ getScratchBlocks, openExtensionLibrary: openHostLibrary, styles }: {
|
|
4
|
+
getScratchBlocks(): {
|
|
5
|
+
getMainWorkspace?(): object;
|
|
6
|
+
} | undefined;
|
|
7
|
+
openExtensionLibrary(document: Document): void;
|
|
8
|
+
styles: Record<string, string>;
|
|
9
|
+
}): {
|
|
10
|
+
connectPaletteVisibility: (vm: {
|
|
11
|
+
editingTarget?: any;
|
|
12
|
+
runtime: {
|
|
13
|
+
targets?: any[];
|
|
14
|
+
_blockInfo?: PaletteCategoryInfo[];
|
|
15
|
+
_fillExtensionCategory?(...args: any[]): unknown;
|
|
16
|
+
getTargetForStage(): any;
|
|
17
|
+
emitProjectChanged(): void;
|
|
18
|
+
on(event: string, listener: (...args: any[]) => void): void;
|
|
19
|
+
off(event: string, listener: (...args: any[]) => void): void;
|
|
20
|
+
};
|
|
21
|
+
on(event: string, listener: (...args: any[]) => void): void;
|
|
22
|
+
off(event: string, listener: (...args: any[]) => void): void;
|
|
23
|
+
addSprite?(...args: any[]): Promise<unknown>;
|
|
24
|
+
duplicateSprite?(targetId: string): Promise<unknown>;
|
|
25
|
+
}, getScreenState?: () => {
|
|
26
|
+
register(key: string, slice: {
|
|
27
|
+
capture(): unknown;
|
|
28
|
+
}): () => void;
|
|
29
|
+
whenLoaded(): Promise<{
|
|
30
|
+
slices: Record<string, unknown>;
|
|
31
|
+
} | undefined>;
|
|
32
|
+
} | undefined) => () => void;
|
|
33
|
+
setHorizontalBlockPalette: (horizontal: boolean) => void;
|
|
34
|
+
openDetachedBlockPalette: (options: any) => void;
|
|
35
|
+
installHorizontalBlockPalette: (ScratchBlocks: any, { allowManualToggle, allowCategoryReorder }?: {
|
|
36
|
+
allowManualToggle?: boolean;
|
|
37
|
+
allowCategoryReorder?: boolean;
|
|
38
|
+
}) => void;
|
|
39
|
+
};
|