kakidash 0.2.2 → 0.2.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/README.ja.md CHANGED
@@ -23,10 +23,13 @@ Kakidashのミッションは、**アウトプット速度の最大化**です
23
23
  - 太字 (Bold)、斜体 (Italic)
24
24
  - カラーパレットによる色変更 (Style Editor)
25
25
  - **テーマ**: 複数の組み込みテーマ (Default, Simple, Colorful, Dark) の切り替え
26
- - **アイコン設定**: コマンドパレットからのフラットアイコン追加・削除 (`m` key)
26
+ - **アイコン設定**: コマンドパレットからのフラットアイコンおよび数字アイコン (0-9) の追加・削除 (`m` key)
27
27
  - **インタラクション**:
28
28
  - ドラッグ&ドロップによるノード移動・並び替え
29
29
  - キーボードショートカットによる高速操作
30
+ - **ヘルプモーダル**: ツールバーの「?」アイコンからアイコンの意味とショートカットキーの確認が可能
31
+ - **複数選択**: Shift + Click または Shift + 矢印キーによる範囲選択
32
+ - **一括操作**: 削除、コピー、切り取り、貼り付け、スタイル変更は選択された全ノードに適用されます
30
33
  - ズーム、パン (画面移動)
31
34
  - **画像対応**: クリップボードからの画像貼り付け
32
35
  - **Auto Link**: ノード内のURLを自動検出し、クリック可能なリンクに変換
@@ -98,10 +101,12 @@ const container = document.getElementById('mindmap-container');
98
101
  // インスタンス化
99
102
  // インスタンス化 (オプション指定可能)
100
103
  const kakidash = new Kakidash(container, {
104
+ locale: 'ja', // オプション: 'en' | 'ja' (デフォルト: 'en')
101
105
  maxNodeWidth: 200, // オプション: ノードの最大幅
102
106
  customStyles: { // オプション: 初期のカスタムスタイル
103
107
  rootNode: { border: '2px solid red' }
104
- }
108
+ },
109
+ disabledCommandPaletteFeatures: ['import'] // オプション: 特定の機能を無効化
105
110
  });
106
111
 
107
112
  // 必要に応じて初期データをロードしたり、ノードを追加したりします
@@ -197,9 +202,11 @@ kakidash.setTheme('custom');
197
202
  ### Methods
198
203
 
199
204
  - **`new Kakidash(container: HTMLElement, options?: KakidashOptions)`**: インスタンスを生成します。
205
+ - `options.locale`: ヘルプモーダルなどの表示言語 ('en' | 'ja')。
200
206
  - `options.shortcuts`: キーボードショートカットのカスタマイズ。
201
207
  - `options.maxNodeWidth`: テキストノードの最大幅 (ピクセル)。
202
208
  - `options.customStyles`: 初期のカスタムスタイル。
209
+ - `options.disabledCommandPaletteFeatures`: コマンドパレットの特定の機能を無効化 ('search' | 'icon' | 'import' | 'export')。
203
210
  - **`kakidash.addNode(parentId, topic)`**: 指定した親ノードに新しい子ノードを追加します。
204
211
  - **`kakidash.getData()`**: 現在のマインドマップデータをJSONオブジェクトとして取得します。
205
212
  - **`kakidash.loadData(data)`**: JSONデータを読み込み、マインドマップを描画します。
@@ -212,6 +219,11 @@ kakidash.setTheme('custom');
212
219
  - **`kakidash.redo()`**: 元に戻した変更をやり直します。
213
220
  - **`kakidash.toggleFold(nodeId)`**: ノードの折り畳み/展開を切り替えます。
214
221
  - **`kakidash.getSelectedNodeId()`**: 現在選択されているノードのIDを取得します。
222
+ - **`kakidash.setSelectedNodeId(nodeId)`**: 指定したIDのノードを選択状態にします。
223
+ - **`kakidash.registerCommand(command)`**: コマンドパレットにカスタムコマンドを登録します。
224
+ - `command.id`: コマンドの一意なID。
225
+ - `command.topic`: パレットに表示される名前。
226
+ - `command.execute`: 実行時に呼ばれるコールバック `(selectedNodeId: string | null) => void`。
215
227
  - **`kakidash.updateNode(nodeId, { topic?, style?, icon? })`**: ノードを更新します。`icon` にはアイコンID ('check', 'star' など) を指定します。
216
228
  - **`kakidash.on(event, listener)`**: イベントリスナーを登録します。
217
229
  - **`kakidash.off(event, listener)`**: イベントリスナーを削除します。
@@ -317,6 +329,7 @@ const kakidash = new Kakidash(container, {
317
329
  | ----------------------------------- | --------------------------------------- |
318
330
  | `m` | コマンドパレット (検索 / アイコン) |
319
331
  | `Arrow Keys` | ノード間の移動 |
332
+ | `Shift + Arrow Keys` | ノードの範囲選択 |
320
333
  | `h` / `j` / `k` / `l` | ノード間の移動 (Vim風) |
321
334
  | `F2` / `DblClick` / `Space` / `i` | ノードの編集を開始 (画像の場合はズーム) |
322
335
  | `Enter` | 兄弟ノードを追加 (下) |
@@ -354,9 +367,29 @@ const kakidash = new Kakidash(container, {
354
367
  | `Shift + i` | 斜体 (Italic) 切り替え |
355
368
  | `Shift + . (>)` / `.` | フォントサイズ拡大 |
356
369
  | `Shift + , (<)` / `,` | フォントサイズ縮小 |
357
- | `Shift + ArrowLeft / Right` | ノード幅の変更 |
370
+ | `Shift + Alt + ArrowLeft / Right` | ノード幅の変更 |
358
371
  | `1` - `7` | ノードの色を変更 (パレット順) |
359
372
 
373
+ ## カスタムコマンドの登録
374
+
375
+ `registerCommand` を使用して、自身の関数をコマンドパレットに追加できます。
376
+
377
+ ```typescript
378
+ board.registerCommand({
379
+ id: 'rocket-launch',
380
+ topic: '🚀 Rocket Launch',
381
+ execute: (selectedNodeId) => {
382
+ console.log('選択中のノード:', selectedNodeId);
383
+ // ここに独自のロジックを記述します
384
+ if (selectedNodeId) {
385
+ board.updateNodeTopic(selectedNodeId, '🚀 LAUNCHED!');
386
+ }
387
+ }
388
+ });
389
+ ```
390
+
391
+ 登録されたコマンドはコマンドパレット(デフォルト:`m` キー)の一覧に表示されます。項目をクリックするか Enter キーを押すことで実行されます。
392
+
360
393
  ## アーキテクチャ
361
394
 
362
395
  ソフトウェアアーキテクチャの詳細や内部モジュールの依存関係については、以下を参照してください:
package/README.md CHANGED
@@ -21,10 +21,13 @@ Master the shortcuts and expand your mind map at the speed of thought.
21
21
  - Bold (`Bold`), Italic (`Italic`).
22
22
  - Color changes via palette (Style Editor).
23
23
  - **Themes**: Switch between multiple built-in themes (Default, Simple, Colorful, Dark).
24
- - **Icon Settings**: Add/Remove flat icons via Command Palette (`m` key).
24
+ - **Icon Settings**: Add/Remove flat icons and numeric icons (0-9) via Command Palette (`m` key).
25
25
  - **Interaction**:
26
26
  - Drag and drop for node movement and reordering.
27
27
  - Keyboard shortcuts for rapid operation.
28
+ - **Help Modal**: Accessible via the "?" icon in the toolbar, allowing you to check icon meanings and shortcuts.
29
+ - **Multi-selection**: Shift + Click or Shift + Arrow Keys to select multiple nodes.
30
+ - **Bulk Operations**: Delete, Copy, Cut, Paste, and Styling apply to all selected nodes.
28
31
  - Zoom, Pan (Screen navigation).
29
32
  - **Image Support**: Paste images from the clipboard.
30
33
  - **Auto Link**: Automatically detects URLs in node text and converts them to clickable links.
@@ -96,10 +99,12 @@ const container = document.getElementById('mindmap-container');
96
99
  // Instantiate
97
100
  // Instantiate with optional configuration
98
101
  const kakidash = new Kakidash(container, {
102
+ locale: 'en', // Optional: 'en' | 'ja' (Default: 'en')
99
103
  maxNodeWidth: 200, // Optional: Maximum width for nodes
100
104
  customStyles: { // Optional: Initial custom styles
101
105
  rootNode: { border: '2px solid red' }
102
- }
106
+ },
107
+ disabledCommandPaletteFeatures: ['import'] // Optional: Disable specific features
103
108
  });
104
109
 
105
110
  // Add initial data or nodes if needed
@@ -192,9 +197,11 @@ All values accept standard CSS strings.
192
197
  ### Methods
193
198
 
194
199
  - **`new Kakidash(container: HTMLElement, options?: KakidashOptions)`**: Creates a new instance.
200
+ - `options.locale`: Language for the help modal and other UI elements ('en' | 'ja').
195
201
  - `options.shortcuts`: Custom keyboard shortcuts.
196
202
  - `options.maxNodeWidth`: Maximum width for text nodes (pixels).
197
203
  - `options.customStyles`: Initial custom styles.
204
+ - `options.disabledCommandPaletteFeatures`: Features to disable in the command palette ('search' | 'icon' | 'import' | 'export').
198
205
  - **`kakidash.addNode(parentId, topic)`**: Adds a new child node to the specified parent node.
199
206
  - **`kakidash.getData()`**: Retrieves current mindmap data as a JSON object.
200
207
  - **`kakidash.loadData(data)`**: Loads JSON data and renders the mindmap.
@@ -207,6 +214,11 @@ All values accept standard CSS strings.
207
214
  - **`kakidash.redo()`**: Redo the last undone change.
208
215
  - **`kakidash.toggleFold(nodeId)`**: Toggle fold state of a node.
209
216
  - **`kakidash.getSelectedNodeId()`**: Get the ID of the currently selected node.
217
+ - **`kakidash.setSelectedNodeId(nodeId)`**: Selects a node by its ID.
218
+ - **`kakidash.registerCommand(command)`**: Registers a custom command to the command palette.
219
+ - `command.id`: Unique ID for the command.
220
+ - `command.topic`: Display name in the palette.
221
+ - `command.execute`: Callback function `(selectedNodeId: string | null) => void`.
210
222
  - **`kakidash.updateNode(nodeId, { topic?, style?, icon? })`**: Updates a node property. `icon` accepts an icon ID (e.g., 'check').
211
223
  - **`kakidash.on(event, listener)`**: Register an event listener.
212
224
  - **`kakidash.off(event, listener)`**: Remove an event listener.
@@ -312,6 +324,7 @@ Here is the complete default configuration. You can partially override these key
312
324
  | ----------------------------------- | ------------------------------------------------- |
313
325
  | `m` | Command Palette (Search / Icons) |
314
326
  | `Arrow Keys` | Navigate between nodes |
327
+ | `Shift + Arrow Keys` | Select range of nodes |
315
328
  | `h` / `j` / `k` / `l` | Navigate between nodes (Vim-style) |
316
329
  | `F2` / `DblClick` / `Space` / `i` | Start editing node (Space triggers zoom if image) |
317
330
  | `Enter` | Add sibling node (below) |
@@ -349,9 +362,29 @@ Here is the complete default configuration. You can partially override these key
349
362
  | `Shift + i` | Toggle Italic |
350
363
  | `Shift + . (>)` / `.` | Increase font size |
351
364
  | `Shift + , (<)` / `,` | Decrease font size |
352
- | `Shift + ArrowLeft / Right` | Adjust node width |
365
+ | `Shift + Alt + ArrowLeft / Right` | Adjust node width |
353
366
  | `1` - `7` | Change node color (Palette order) |
354
367
 
368
+ ## Custom Commands
369
+
370
+ You can extend the command palette with your own functions using `registerCommand`.
371
+
372
+ ```typescript
373
+ board.registerCommand({
374
+ id: 'rocket-launch',
375
+ topic: '🚀 Rocket Launch',
376
+ execute: (selectedNodeId) => {
377
+ console.log('Action on node:', selectedNodeId);
378
+ // Your logic here
379
+ if (selectedNodeId) {
380
+ board.updateNodeTopic(selectedNodeId, '🚀 LAUNCHED!');
381
+ }
382
+ }
383
+ });
384
+ ```
385
+
386
+ Registered commands will appear in the Command Palette (default key: `m`). Clicking or pressing Enter on the item will execute the handler.
387
+
355
388
  ## Architecture
356
389
 
357
390
  For details on the software architecture and internal module dependencies, please refer to:
package/dist/index.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ export declare interface CustomCommand {
2
+ id: string;
3
+ topic: string;
4
+ execute: (selectedNodeId: string | null) => void;
5
+ }
6
+
1
7
  export declare type Direction = 'Up' | 'Down' | 'Left' | 'Right';
2
8
 
3
9
  /**
@@ -50,6 +56,11 @@ export declare class Kakidash extends TypedEventEmitter<KakidashEventMap> {
50
56
  * Toggles the visibility of the command palette.
51
57
  */
52
58
  toggleCommandPalette(): void;
59
+ /**
60
+ * Registers a custom command to be displayed in the command palette.
61
+ * @param command The custom command definition.
62
+ */
63
+ registerCommand(command: CustomCommand): void;
53
64
  /**
54
65
  * Opens the command palette (alias for toggleCommandPalette).
55
66
  */
@@ -99,11 +110,12 @@ export declare class Kakidash extends TypedEventEmitter<KakidashEventMap> {
99
110
 
100
111
  declare type KakidashCommandArgs = {
101
112
  name: string;
102
- args?: any;
113
+ args?: unknown;
103
114
  };
104
115
 
105
116
  export declare type KakidashEventMap = {
106
117
  'node:select': string | null;
118
+ 'selection:change': string[];
107
119
  'node:add': {
108
120
  id: string;
109
121
  topic: string;
@@ -140,6 +152,14 @@ export declare interface KakidashOptions {
140
152
  * for importing and exporting files.
141
153
  */
142
154
  fileHandler?: FileHandler;
155
+ /**
156
+ * Locale for UI text (help modal, etc.). Defaults to 'en'.
157
+ */
158
+ locale?: 'en' | 'ja';
159
+ /**
160
+ * Features to disable in the command palette.
161
+ */
162
+ disabledCommandPaletteFeatures?: ('search' | 'icon' | 'import' | 'export')[];
143
163
  }
144
164
 
145
165
  export declare interface KeyBinding {
@@ -155,9 +175,26 @@ export declare type LayoutMode = 'Right' | 'Left' | 'Both';
155
175
  declare class MindMap {
156
176
  root: Node_2;
157
177
  theme: Theme;
178
+ private nodeIndex;
158
179
  constructor(rootNode: Node_2);
180
+ /**
181
+ * Rebuild the entire node index from the current root tree.
182
+ * Should be called after root replacement (e.g., importData).
183
+ */
184
+ rebuildIndex(): void;
185
+ private indexSubtree;
186
+ /**
187
+ * Register a node and its entire subtree into the index.
188
+ * Call after adding a node (or subtree) to the tree.
189
+ */
190
+ registerNode(node: Node_2): void;
191
+ /**
192
+ * Unregister a node and its entire subtree from the index.
193
+ * Call after removing a node (or subtree) from the tree.
194
+ */
195
+ unregisterNode(node: Node_2): void;
196
+ private removeFromIndex;
159
197
  findNode(id: string): Node_2 | null;
160
- private findNodeRecursive;
161
198
  moveNode(nodeId: string, newParentId: string): boolean;
162
199
  addSibling(referenceId: string, newNode: Node_2, position: 'before' | 'after'): boolean;
163
200
  insertParent(targetId: string, newParentNode: Node_2): boolean;
@@ -170,6 +207,7 @@ export declare interface MindMapData {
170
207
  theme?: Theme;
171
208
  direction?: number;
172
209
  selectedId?: string;
210
+ selectedIds?: string[];
173
211
  }
174
212
 
175
213
  export declare interface MindMapNodeData {
@@ -265,7 +303,7 @@ export declare class SvgGenerator {
265
303
 
266
304
  export declare type Theme = 'default' | 'simple' | 'colorful' | 'custom';
267
305
 
268
- declare class TypedEventEmitter<EventMap extends Record<string, any>> {
306
+ export declare class TypedEventEmitter<EventMap extends Record<string, any>> {
269
307
  private listeners;
270
308
  on<K extends keyof EventMap>(event: K, listener: (payload: EventMap[K]) => void): void;
271
309
  addListener<K extends keyof EventMap>(event: K, listener: (payload: EventMap[K]) => void): void;