pmx-canvas 0.6.3 → 0.6.4

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.
@@ -34,6 +34,7 @@ import {
34
34
  import { saveCanvasTheme } from '../state/intent-bridge';
35
35
  import { createNodeInView } from './create-in-view';
36
36
  import { askText } from './TextPrompt';
37
+ import { FeedbackDialog } from './FeedbackDialog';
37
38
  import { clearThemeOverride } from '../state/theme-override';
38
39
  import { invalidateTokenCache } from '../theme/tokens';
39
40
  import type { AnnotationTool } from '../types';
@@ -170,6 +171,7 @@ export function ToolRail({
170
171
  const isTraceOn = traceEnabled.value;
171
172
  const traceNodeCount = Array.from(nodes.value.values()).filter((n) => n.type === 'trace').length;
172
173
  const edgeCount = edges.value.size;
174
+ const [feedbackOpen, setFeedbackOpen] = useState(false);
173
175
  const [openMenu, setOpenMenu] = useState<null | 'theme' | 'annotate'>(null);
174
176
  const [menuAnchor, setMenuAnchor] = useState<{ top: number; bottom: number; right: number } | null>(null);
175
177
  const railRef = useRef<HTMLDivElement>(null);
@@ -236,212 +238,246 @@ export function ToolRail({
236
238
  };
237
239
 
238
240
  return (
239
- <div class="tool-rail" ref={railRef} role="toolbar" aria-label="Canvas tools" aria-orientation="vertical">
240
- <span class="rail-brand" title="PMX Canvas" aria-label="PMX Canvas">
241
- <IconLogo size={22} />
242
- </span>
243
-
244
- <div class="rail-divider" />
241
+ <>
242
+ <div class="tool-rail" ref={railRef} role="toolbar" aria-label="Canvas tools" aria-orientation="vertical">
243
+ <span class="rail-brand" title="PMX Canvas" aria-label="PMX Canvas">
244
+ <IconLogo size={22} />
245
+ </span>
245
246
 
246
- <RailButton label="Select" shortcut="V" active={tool === 'select'} onClick={() => (canvasTool.value = 'select')}>
247
- <IconCursorTool />
248
- </RailButton>
249
- <RailButton label="Pan" shortcut="Space" active={tool === 'pan'} onClick={() => (canvasTool.value = 'pan')}>
250
- <IconHandTool />
251
- </RailButton>
252
- <RailButton
253
- label="Connect"
254
- shortcut="C"
255
- active={tool === 'connect'}
256
- onClick={() => (canvasTool.value = 'connect')}
257
- >
258
- <svg
259
- width="15"
260
- height="15"
261
- viewBox="0 0 16 16"
262
- fill="none"
263
- stroke="currentColor"
264
- stroke-width="1.5"
265
- stroke-linecap="round"
266
- aria-hidden="true"
247
+ <RailButton
248
+ label="Bug and feedback"
249
+ menuOpen={feedbackOpen}
250
+ onClick={() => {
251
+ setOpenMenu(null);
252
+ setFeedbackOpen(true);
253
+ }}
267
254
  >
268
- <circle cx="4" cy="4" r="2" />
269
- <circle cx="12" cy="12" r="2" />
270
- <path d="M5.5 5.5 C 8 8, 8 8, 10.5 10.5" />
271
- </svg>
272
- </RailButton>
255
+ <svg
256
+ width="16"
257
+ height="16"
258
+ viewBox="0 0 16 16"
259
+ fill="none"
260
+ stroke="currentColor"
261
+ stroke-width="1.5"
262
+ stroke-linecap="round"
263
+ stroke-linejoin="round"
264
+ aria-hidden="true"
265
+ >
266
+ <rect x="4.5" y="5" width="7" height="9" rx="3.5" />
267
+ <path d="M6 5V4a2 2 0 0 1 4 0v1M8 8v6M2 4l2.5 2M14 4l-2.5 2M1.5 9h3M11.5 9h3M2 14l2.5-2M14 14l-2.5-2" />
268
+ </svg>
269
+ </RailButton>
273
270
 
274
- <div class="rail-divider" />
271
+ <div class="rail-divider" />
275
272
 
276
- <RailButton
277
- label="Markdown note"
278
- shortcut="M"
279
- onClick={() =>
280
- void createNodeInView({ type: 'markdown', title: 'New note', width: 520, height: 360 }).catch((error) =>
281
- logRailError('create markdown', error),
282
- )
283
- }
284
- >
285
- <IconNodeMarkdown size={15} />
286
- </RailButton>
287
- <RailButton label="Image" shortcut="I" onClick={() => promptedCreate('image')}>
288
- <IconNodeImage size={15} />
289
- </RailButton>
290
- <RailButton label="File" shortcut="Shift+F" onClick={() => promptedCreate('file')}>
291
- <IconNodeFile size={15} />
292
- </RailButton>
293
- <RailButton label="Webpage" shortcut="W" onClick={() => promptedCreate('webpage')}>
294
- <IconNodeWebpage size={15} />
295
- </RailButton>
296
- <RailButton
297
- label="HTML surface"
298
- shortcut="H"
299
- onClick={() =>
300
- void createNodeInView({ type: 'html', title: 'HTML surface' }).catch((error) =>
301
- logRailError('create html', error),
302
- )
303
- }
304
- >
305
- <IconNodeHtml />
306
- </RailButton>
307
- <RailButton
308
- label="Group"
309
- shortcut="G"
310
- onClick={() =>
311
- void createNodeInView({ type: 'group', title: 'Group' }).catch((error) => logRailError('create group', error))
312
- }
313
- >
314
- <IconNodeGroup size={15} />
315
- </RailButton>
316
- <span class="toolbar-menu-anchor">
317
273
  <RailButton
318
- label="Annotate"
319
- shortcut="A"
320
- detail="Draw · Text note · Eraser"
321
- active={annotationTool !== null}
322
- menuOpen={openMenu === 'annotate'}
323
- onClick={toggleMenu('annotate')}
274
+ label="Select"
275
+ shortcut="V"
276
+ active={tool === 'select'}
277
+ onClick={() => (canvasTool.value = 'select')}
324
278
  >
325
- {annotationTool === 'eraser' ? (
326
- <IconEraser />
327
- ) : annotationTool === 'text' ? (
328
- <IconTextAnnotation />
329
- ) : (
330
- <IconPen />
331
- )}
279
+ <IconCursorTool />
280
+ </RailButton>
281
+ <RailButton label="Pan" shortcut="Space" active={tool === 'pan'} onClick={() => (canvasTool.value = 'pan')}>
282
+ <IconHandTool />
283
+ </RailButton>
284
+ <RailButton
285
+ label="Connect"
286
+ shortcut="C"
287
+ active={tool === 'connect'}
288
+ onClick={() => (canvasTool.value = 'connect')}
289
+ >
290
+ <svg
291
+ width="15"
292
+ height="15"
293
+ viewBox="0 0 16 16"
294
+ fill="none"
295
+ stroke="currentColor"
296
+ stroke-width="1.5"
297
+ stroke-linecap="round"
298
+ aria-hidden="true"
299
+ >
300
+ <circle cx="4" cy="4" r="2" />
301
+ <circle cx="12" cy="12" r="2" />
302
+ <path d="M5.5 5.5 C 8 8, 8 8, 10.5 10.5" />
303
+ </svg>
332
304
  </RailButton>
333
- {openMenu === 'annotate' && (
334
- <div class="toolbar-menu" style={sideMenuStyle(false)} role="menu" aria-label="Annotate">
335
- <button
336
- type="button"
337
- class={`toolbar-menu-item${annotationTool === 'pen' ? ' active' : ''}`}
338
- onClick={() => {
339
- onSetAnnotationTool(annotationTool === 'pen' ? null : 'pen');
340
- setOpenMenu(null);
341
- }}
342
- >
343
- <IconPen />
344
- <span>{annotationTool === 'pen' ? 'Stop annotating' : 'Draw (A)'}</span>
345
- </button>
346
- <button
347
- type="button"
348
- class={`toolbar-menu-item${annotationTool === 'text' ? ' active' : ''}`}
349
- onClick={() => {
350
- onSetAnnotationTool(annotationTool === 'text' ? null : 'text');
351
- setOpenMenu(null);
352
- }}
353
- >
354
- <IconTextAnnotation />
355
- <span>{annotationTool === 'text' ? 'Stop text notes' : 'Text note'}</span>
356
- </button>
357
- <button
358
- type="button"
359
- class={`toolbar-menu-item${annotationTool === 'eraser' ? ' active' : ''}`}
360
- onClick={() => {
361
- onSetAnnotationTool(annotationTool === 'eraser' ? null : 'eraser');
362
- setOpenMenu(null);
363
- }}
364
- >
365
- <IconEraser />
366
- <span>{annotationTool === 'eraser' ? 'Stop erasing' : 'Eraser'}</span>
367
- </button>
368
- </div>
369
- )}
370
- </span>
371
305
 
372
- <div class="rail-spacer" />
306
+ <div class="rail-divider" />
373
307
 
374
- <RailButton label="Search & commands" shortcut={modChord('K')} onClick={onOpenPalette}>
375
- <IconSearch />
376
- </RailButton>
377
- <RailButton
378
- label="Arrange"
379
- detail={edgeCount > 0 ? 'graph-aware' : 'grid'}
380
- onClick={() => (edgeCount > 0 ? forceDirectedArrange() : autoArrange())}
381
- >
382
- <IconArrange />
383
- </RailButton>
384
- <RailButton
385
- label={isTraceOn ? 'Disable trace' : 'Enable trace'}
386
- active={isTraceOn}
387
- onClick={() => sendIntent('trace-toggle', { enabled: !isTraceOn })}
388
- >
389
- <IconTrace />
390
- </RailButton>
391
- {(isTraceOn || traceNodeCount > 0) && (
392
- <RailButton label="Clear trace" onClick={() => sendIntent('trace-clear')}>
393
- <IconClearTrace />
308
+ <RailButton
309
+ label="Markdown note"
310
+ shortcut="M"
311
+ onClick={() =>
312
+ void createNodeInView({ type: 'markdown', title: 'New note', width: 520, height: 360 }).catch((error) =>
313
+ logRailError('create markdown', error),
314
+ )
315
+ }
316
+ >
317
+ <IconNodeMarkdown size={15} />
318
+ </RailButton>
319
+ <RailButton label="Image" shortcut="I" onClick={() => promptedCreate('image')}>
320
+ <IconNodeImage size={15} />
321
+ </RailButton>
322
+ <RailButton label="File" shortcut="Shift+F" onClick={() => promptedCreate('file')}>
323
+ <IconNodeFile size={15} />
324
+ </RailButton>
325
+ <RailButton label="Webpage" shortcut="W" onClick={() => promptedCreate('webpage')}>
326
+ <IconNodeWebpage size={15} />
327
+ </RailButton>
328
+ <RailButton
329
+ label="HTML surface"
330
+ shortcut="H"
331
+ onClick={() =>
332
+ void createNodeInView({ type: 'html', title: 'HTML surface' }).catch((error) =>
333
+ logRailError('create html', error),
334
+ )
335
+ }
336
+ >
337
+ <IconNodeHtml />
394
338
  </RailButton>
395
- )}
396
- <RailButton
397
- label={minimapVisible ? 'Hide minimap' : 'Show minimap'}
398
- active={minimapVisible}
399
- onClick={onToggleMinimap}
400
- >
401
- <IconMinimap />
402
- </RailButton>
403
- <RailButton label="Snapshots" active={snapshotOpen} onClick={onToggleSnapshot} btnRef={snapshotBtnRef}>
404
- <IconSnapshot />
405
- </RailButton>
406
- <span class="toolbar-menu-anchor">
407
339
  <RailButton
408
- label="Theme"
409
- detail={CANVAS_THEME_META[activeTheme].label}
410
- menuOpen={openMenu === 'theme'}
411
- ariaLabel="Choose theme"
412
- active={openMenu === 'theme'}
413
- onClick={toggleMenu('theme')}
340
+ label="Group"
341
+ shortcut="G"
342
+ onClick={() =>
343
+ void createNodeInView({ type: 'group', title: 'Group' }).catch((error) =>
344
+ logRailError('create group', error),
345
+ )
346
+ }
414
347
  >
415
- {canvasThemeScheme(activeTheme) === 'dark' ? <IconSun /> : <IconMoon />}
348
+ <IconNodeGroup size={15} />
416
349
  </RailButton>
417
- {openMenu === 'theme' && (
418
- <div class="toolbar-menu" style={sideMenuStyle(true)} role="menu" aria-label="Theme">
419
- {CANVAS_THEMES.map((name) => (
350
+ <span class="toolbar-menu-anchor">
351
+ <RailButton
352
+ label="Annotate"
353
+ shortcut="A"
354
+ detail="Draw · Text note · Eraser"
355
+ active={annotationTool !== null}
356
+ menuOpen={openMenu === 'annotate'}
357
+ onClick={toggleMenu('annotate')}
358
+ >
359
+ {annotationTool === 'eraser' ? (
360
+ <IconEraser />
361
+ ) : annotationTool === 'text' ? (
362
+ <IconTextAnnotation />
363
+ ) : (
364
+ <IconPen />
365
+ )}
366
+ </RailButton>
367
+ {openMenu === 'annotate' && (
368
+ <div class="toolbar-menu" style={sideMenuStyle(false)} role="menu" aria-label="Annotate">
420
369
  <button
421
- key={name}
422
370
  type="button"
423
- role="menuitemradio"
424
- aria-checked={activeTheme === name}
425
- class={`toolbar-menu-item${activeTheme === name ? ' active' : ''}`}
426
- onClick={() => applyTheme(name)}
371
+ class={`toolbar-menu-item${annotationTool === 'pen' ? ' active' : ''}`}
372
+ onClick={() => {
373
+ onSetAnnotationTool(annotationTool === 'pen' ? null : 'pen');
374
+ setOpenMenu(null);
375
+ }}
427
376
  >
428
- <span class="theme-swatch" style={{ background: CANVAS_THEME_META[name].swatchBg }}>
429
- <span class="theme-swatch-dot" style={{ background: CANVAS_THEME_META[name].swatchAccent }} />
430
- </span>
431
- <span>{CANVAS_THEME_META[name].label}</span>
432
- {activeTheme === name && (
433
- <span class="toolbar-menu-check" aria-hidden="true">
434
- ✓
435
- </span>
436
- )}
377
+ <IconPen />
378
+ <span>{annotationTool === 'pen' ? 'Stop annotating' : 'Draw (A)'}</span>
379
+ </button>
380
+ <button
381
+ type="button"
382
+ class={`toolbar-menu-item${annotationTool === 'text' ? ' active' : ''}`}
383
+ onClick={() => {
384
+ onSetAnnotationTool(annotationTool === 'text' ? null : 'text');
385
+ setOpenMenu(null);
386
+ }}
387
+ >
388
+ <IconTextAnnotation />
389
+ <span>{annotationTool === 'text' ? 'Stop text notes' : 'Text note'}</span>
437
390
  </button>
438
- ))}
439
- </div>
391
+ <button
392
+ type="button"
393
+ class={`toolbar-menu-item${annotationTool === 'eraser' ? ' active' : ''}`}
394
+ onClick={() => {
395
+ onSetAnnotationTool(annotationTool === 'eraser' ? null : 'eraser');
396
+ setOpenMenu(null);
397
+ }}
398
+ >
399
+ <IconEraser />
400
+ <span>{annotationTool === 'eraser' ? 'Stop erasing' : 'Eraser'}</span>
401
+ </button>
402
+ </div>
403
+ )}
404
+ </span>
405
+
406
+ <div class="rail-spacer" />
407
+
408
+ <RailButton label="Search & commands" shortcut={modChord('K')} onClick={onOpenPalette}>
409
+ <IconSearch />
410
+ </RailButton>
411
+ <RailButton
412
+ label="Arrange"
413
+ detail={edgeCount > 0 ? 'graph-aware' : 'grid'}
414
+ onClick={() => (edgeCount > 0 ? forceDirectedArrange() : autoArrange())}
415
+ >
416
+ <IconArrange />
417
+ </RailButton>
418
+ <RailButton
419
+ label={isTraceOn ? 'Disable trace' : 'Enable trace'}
420
+ active={isTraceOn}
421
+ onClick={() => sendIntent('trace-toggle', { enabled: !isTraceOn })}
422
+ >
423
+ <IconTrace />
424
+ </RailButton>
425
+ {(isTraceOn || traceNodeCount > 0) && (
426
+ <RailButton label="Clear trace" onClick={() => sendIntent('trace-clear')}>
427
+ <IconClearTrace />
428
+ </RailButton>
440
429
  )}
441
- </span>
442
- <RailButton label="Shortcuts" shortcut="?" onClick={onOpenShortcuts}>
443
- <IconShortcuts />
444
- </RailButton>
445
- </div>
430
+ <RailButton
431
+ label={minimapVisible ? 'Hide minimap' : 'Show minimap'}
432
+ active={minimapVisible}
433
+ onClick={onToggleMinimap}
434
+ >
435
+ <IconMinimap />
436
+ </RailButton>
437
+ <RailButton label="Snapshots" active={snapshotOpen} onClick={onToggleSnapshot} btnRef={snapshotBtnRef}>
438
+ <IconSnapshot />
439
+ </RailButton>
440
+ <span class="toolbar-menu-anchor">
441
+ <RailButton
442
+ label="Theme"
443
+ detail={CANVAS_THEME_META[activeTheme].label}
444
+ menuOpen={openMenu === 'theme'}
445
+ ariaLabel="Choose theme"
446
+ active={openMenu === 'theme'}
447
+ onClick={toggleMenu('theme')}
448
+ >
449
+ {canvasThemeScheme(activeTheme) === 'dark' ? <IconSun /> : <IconMoon />}
450
+ </RailButton>
451
+ {openMenu === 'theme' && (
452
+ <div class="toolbar-menu" style={sideMenuStyle(true)} role="menu" aria-label="Theme">
453
+ {CANVAS_THEMES.map((name) => (
454
+ <button
455
+ key={name}
456
+ type="button"
457
+ role="menuitemradio"
458
+ aria-checked={activeTheme === name}
459
+ class={`toolbar-menu-item${activeTheme === name ? ' active' : ''}`}
460
+ onClick={() => applyTheme(name)}
461
+ >
462
+ <span class="theme-swatch" style={{ background: CANVAS_THEME_META[name].swatchBg }}>
463
+ <span class="theme-swatch-dot" style={{ background: CANVAS_THEME_META[name].swatchAccent }} />
464
+ </span>
465
+ <span>{CANVAS_THEME_META[name].label}</span>
466
+ {activeTheme === name && (
467
+ <span class="toolbar-menu-check" aria-hidden="true">
468
+ ✓
469
+ </span>
470
+ )}
471
+ </button>
472
+ ))}
473
+ </div>
474
+ )}
475
+ </span>
476
+ <RailButton label="Shortcuts" shortcut="?" onClick={onOpenShortcuts}>
477
+ <IconShortcuts />
478
+ </RailButton>
479
+ </div>
480
+ {feedbackOpen && <FeedbackDialog onClose={() => setFeedbackOpen(false)} />}
481
+ </>
446
482
  );
447
483
  }
@@ -4474,6 +4474,38 @@ html.is-node-resizing .ext-app-preview-catcher {
4474
4474
  font-weight: 600;
4475
4475
  }
4476
4476
 
4477
+ .feedback-backdrop {
4478
+ position: fixed;
4479
+ padding: 24px 0;
4480
+ align-items: center;
4481
+ }
4482
+ .feedback-dialog {
4483
+ width: min(480px, calc(100% - 32px));
4484
+ max-height: calc(100dvh - 48px);
4485
+ overflow-y: auto;
4486
+ color: var(--c-text);
4487
+ }
4488
+ .feedback-dialog label {
4489
+ display: flex;
4490
+ flex-direction: column;
4491
+ gap: 6px;
4492
+ font-size: 12px;
4493
+ }
4494
+ .feedback-note {
4495
+ margin: 0;
4496
+ color: var(--c-muted);
4497
+ font-size: 12px;
4498
+ line-height: 1.5;
4499
+ }
4500
+ .feedback-dialog textarea {
4501
+ resize: vertical;
4502
+ min-height: 100px;
4503
+ }
4504
+ .feedback-dialog button:disabled {
4505
+ opacity: 0.5;
4506
+ cursor: not-allowed;
4507
+ }
4508
+
4477
4509
  /* Selection action bar — floating bottom-center of the canvas region
4478
4510
  (rail-chrome-v2 phase 7, item 13). */
4479
4511
  /* In a session the command bar owns the bottom-center slot — lift the