@kubohiroya/turbowarp-plus-editor-code-views 0.23.0 → 0.24.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/README.ja.md CHANGED
@@ -57,6 +57,8 @@ Matter.js 0.20.0(MIT)で、重力と回転を無効にしたコメント込
57
57
 
58
58
  ### ホストが渡すもの
59
59
 
60
+ `createHorizontalBlockPalette` の `showPaletteMenu` は既定で `true`。ホストが `false` を渡すと、パレット末尾の▼とそのメニューを作らない。カテゴリの選択・並べ替え・縦横配置の切り替えは引き続き使える。
61
+
60
62
  `attachCodeWorkspace` と `attachDockedScriptLayout` は `presentationElements(injection)` を受け取る。これはワークスペースのまわりのホストの要素(`wrapper`・`extensionButton`・`watermark`)を返す。ドックしたスクリプトの整列は、透かしに `data-code-watermark`、拡張ボタンに `data-code-extension-button` の印を付け、スタイルシートはこの印で、ホバーで出す面と非アクティブな分割表示の中でそれらを隠す。
61
63
 
62
64
  ### 保存するコードエリア
package/README.md CHANGED
@@ -57,6 +57,8 @@ The code pane adapter (`createCodePaneAdapter`) has `serialize(pane, presentatio
57
57
 
58
58
  React 16.14 or later is supported, because the Editor mounts these views in the GUI's React 16.
59
59
 
60
+ `createHorizontalBlockPalette` accepts `showPaletteMenu` (default `true`). Passing `false` omits the trailing ▼ button and its menu while keeping category selection, reordering, and horizontal/vertical layout switching available.
61
+
60
62
  ## Verification
61
63
 
62
64
  Run `npm test` to build the package, run the unit tests, and check that the sources use no React API newer than 16.14.
@@ -1,11 +1,13 @@
1
1
  import type { PaletteCategoryInfo } from './palette-category-visibility.js';
2
2
  /** Each editor host has its own palette state and lifecycle. */
3
- export declare function createHorizontalBlockPalette({ getScratchBlocks, openExtensionLibrary: openHostLibrary, styles }: {
3
+ export declare function createHorizontalBlockPalette({ getScratchBlocks, openExtensionLibrary: openHostLibrary, styles, showPaletteMenu }: {
4
4
  getScratchBlocks(): {
5
5
  getMainWorkspace?(): object;
6
6
  } | undefined;
7
7
  openExtensionLibrary(document: Document): void;
8
8
  styles: Record<string, string>;
9
+ /** Whether this host offers the palette settings and extension menu. */
10
+ showPaletteMenu?: boolean;
9
11
  }): {
10
12
  connectPaletteVisibility: (vm: {
11
13
  editingTarget?: any;
@@ -7,7 +7,7 @@ import { attachPaletteMenuButton, createPaletteOrder, createPaletteVisibilitySto
7
7
  import { openPaletteVisibilityDialog } from './palette-visibility-dialog.js';
8
8
  import { attachPaletteCategoryGroups, hasCategoryGroups } from './palette-category-groups.js';
9
9
  /** Each editor host has its own palette state and lifecycle. */
10
- export function createHorizontalBlockPalette({ getScratchBlocks, openExtensionLibrary: openHostLibrary, styles }) {
10
+ export function createHorizontalBlockPalette({ getScratchBlocks, openExtensionLibrary: openHostLibrary, styles, showPaletteMenu = true }) {
11
11
  const installed = new WeakSet();
12
12
  const closeOnDragExit = new WeakMap();
13
13
  const palettes = new Set();
@@ -470,10 +470,10 @@ export function createHorizontalBlockPalette({ getScratchBlocks, openExtensionLi
470
470
  const askNewSprite = (target) => openGroupSettings(target, true);
471
471
  newSpritePrompts.push(askNewSprite);
472
472
  const openExtensionLibrary = () => openHostLibrary(doc);
473
- const paletteMenu = attachPaletteMenuButton(menu, getLocale, locale => [
473
+ const paletteMenu = showPaletteMenu ? attachPaletteMenuButton(menu, getLocale, locale => [
474
474
  { label: paletteVisibilityMenuLabel(locale), onSelect: () => openGroupSettings() },
475
475
  { label: /^ja(?:-|$)/i.test(locale) ? '機能拡張を追加' : 'Add Extension', separated: true, onSelect: openExtensionLibrary }
476
- ]);
476
+ ]) : undefined;
477
477
  // The GUI selects an extension by its ID once it is added; one shown as a group selects its first shown group.
478
478
  const selectCategoryById = toolbox.setSelectedCategoryById;
479
479
  toolbox.setSelectedCategoryById = function (id) {
@@ -491,7 +491,7 @@ export function createHorizontalBlockPalette({ getScratchBlocks, openExtensionLi
491
491
  else {
492
492
  original.populate.call(toolbox, tree);
493
493
  }
494
- paletteMenu.update();
494
+ paletteMenu?.update();
495
495
  if (!horizontal)
496
496
  return;
497
497
  const category = categoryById(openId);
@@ -743,7 +743,7 @@ export function createHorizontalBlockPalette({ getScratchBlocks, openExtensionLi
743
743
  workspace.setVisible = original.setVisible;
744
744
  paletteRefreshers.delete(redraw);
745
745
  newSpritePrompts.splice(newSpritePrompts.indexOf(askNewSprite) >>> 0, 1);
746
- paletteMenu.dispose();
746
+ paletteMenu?.dispose();
747
747
  groups.dispose();
748
748
  disconnectPalette();
749
749
  if (inputDocument !== doc)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-plus-editor-code-views",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "Code views for TurboWarp Plus Editor: code in tabs and windows, the detached block palette, script layout and block field editing",
5
5
  "type": "module",
6
6
  "license": "MPL-2.0",
@@ -148,13 +148,13 @@
148
148
  "matter-js": "0.20.0"
149
149
  },
150
150
  "peerDependencies": {
151
- "@kubohiroya/turbowarp-extension-security-dialog": ">=0.9.0 <0.10.0 || 0.10.0",
151
+ "@kubohiroya/turbowarp-extension-security-dialog": ">=0.9.0 <0.10.0 || 0.10.0 || 0.13.0",
152
152
  "@kubohiroya/turbowarp-plus-editor-windows": ">=0.2.0 <0.3.0",
153
153
  "react": ">=16.14",
154
154
  "react-dom": ">=16.14"
155
155
  },
156
156
  "devDependencies": {
157
- "@kubohiroya/turbowarp-extension-security-dialog": "0.10.0",
157
+ "@kubohiroya/turbowarp-extension-security-dialog": "0.13.0",
158
158
  "@kubohiroya/turbowarp-plus-editor-test-runtime": "0.3.0",
159
159
  "@kubohiroya/turbowarp-plus-editor-windows": "0.2.1",
160
160
  "@playwright/test": "1.64.1",
@@ -13,10 +13,12 @@ import {attachPaletteCategoryGroups, hasCategoryGroups} from
13
13
  './palette-category-groups.js';
14
14
 
15
15
  /** Each editor host has its own palette state and lifecycle. */
16
- export function createHorizontalBlockPalette({getScratchBlocks, openExtensionLibrary: openHostLibrary, styles}: {
16
+ export function createHorizontalBlockPalette({getScratchBlocks, openExtensionLibrary: openHostLibrary, styles, showPaletteMenu = true}: {
17
17
  getScratchBlocks(): {getMainWorkspace?(): object} | undefined;
18
18
  openExtensionLibrary(document: Document): void;
19
19
  styles: Record<string, string>;
20
+ /** Whether this host offers the palette settings and extension menu. */
21
+ showPaletteMenu?: boolean;
20
22
  }) {
21
23
  const installed = new WeakSet();
22
24
  const closeOnDragExit = new WeakMap();
@@ -484,10 +486,10 @@ export function createHorizontalBlockPalette({getScratchBlocks, openExtensionLib
484
486
  const askNewSprite = (target: any) => openGroupSettings(target, true);
485
487
  newSpritePrompts.push(askNewSprite);
486
488
  const openExtensionLibrary = () => openHostLibrary(doc);
487
- const paletteMenu = attachPaletteMenuButton(menu, getLocale, locale => [
489
+ const paletteMenu = showPaletteMenu ? attachPaletteMenuButton(menu, getLocale, locale => [
488
490
  {label: paletteVisibilityMenuLabel(locale), onSelect: () => openGroupSettings()},
489
491
  {label: /^ja(?:-|$)/i.test(locale) ? '機能拡張を追加' : 'Add Extension', separated: true, onSelect: openExtensionLibrary}
490
- ]);
492
+ ]) : undefined;
491
493
 
492
494
  // The GUI selects an extension by its ID once it is added; one shown as a group selects its first shown group.
493
495
  const selectCategoryById = toolbox.setSelectedCategoryById;
@@ -506,7 +508,7 @@ export function createHorizontalBlockPalette({getScratchBlocks, openExtensionLib
506
508
  } else {
507
509
  original.populate.call(toolbox, tree);
508
510
  }
509
- paletteMenu.update();
511
+ paletteMenu?.update();
510
512
  if (!horizontal) return;
511
513
  const category = categoryById(openId);
512
514
  if (category) toolbox.setSelectedItem(category, false);
@@ -730,7 +732,7 @@ export function createHorizontalBlockPalette({getScratchBlocks, openExtensionLib
730
732
  if (workspace.setVisible === setVisible) workspace.setVisible = original.setVisible;
731
733
  paletteRefreshers.delete(redraw);
732
734
  newSpritePrompts.splice(newSpritePrompts.indexOf(askNewSprite) >>> 0, 1);
733
- paletteMenu.dispose();
735
+ paletteMenu?.dispose();
734
736
  groups.dispose();
735
737
  disconnectPalette();
736
738
  if (inputDocument !== doc) moveBlockWidgets(ScratchBlocks, doc);