unsys-canvas 0.1.1 → 0.1.2

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/index.d.ts CHANGED
@@ -252,11 +252,11 @@ declare function unsysCanvasHasLiveElements(scene: UnsysCanvasScene | null | und
252
252
  declare const UNSYS_CANVAS_COMMANDS: readonly [{
253
253
  readonly id: "simplify";
254
254
  readonly label: "Simplify";
255
- readonly tooltip: "Replace the selected marks with a shorter, plainer rewrite. If the selection is a term, make the meaning plain.";
255
+ readonly tooltip: "Keep the original marks and place a shorter, plainer rewrite next to them. If the selection is a term, make the meaning plain.";
256
256
  readonly shortcut: "s";
257
257
  readonly needsSelection: true;
258
258
  readonly boardOnly: false;
259
- readonly replacesSelection: true;
259
+ readonly replacesSelection: false;
260
260
  }, {
261
261
  readonly id: "breakdown";
262
262
  readonly label: "Subdivide";
@@ -299,6 +299,7 @@ type UnsysCanvasHostCommand = {
299
299
  shortcut?: string;
300
300
  slash?: string;
301
301
  needsSelection?: boolean;
302
+ /** Ignored. Only Refactor may replace the selection. */
302
303
  replacesSelection?: boolean;
303
304
  run?: (ctx: {
304
305
  selectedElements: UnsysCanvasElement[];
@@ -334,9 +335,9 @@ type UnsysCanvasCommandRun = {
334
335
  };
335
336
  /**
336
337
  * Local result of a sidebar/dock command click.
337
- * Subdivide, Focus, and Next mutate now. Simplify and Refactor drop the
338
- * original marks immediately, then ask XAI. Do/run and Concepts keep the
339
- * original and ask. A click that cannot run returns a short board notice instead of going silent.
338
+ * Subdivide, Focus, and Next mutate now. Refactor drops the original marks
339
+ * immediately, then asks XAI. Simplify, Do/run, and Concepts keep the original
340
+ * and ask. A click that cannot run returns a short board notice instead of going silent.
340
341
  */
341
342
  declare function runUnsysCanvasCommand(input: {
342
343
  action: UnsysCanvasCommandId;
package/dist/index.js CHANGED
@@ -2881,11 +2881,11 @@ var UNSYS_CANVAS_COMMANDS = [
2881
2881
  {
2882
2882
  id: "simplify",
2883
2883
  label: "Simplify",
2884
- tooltip: "Replace the selected marks with a shorter, plainer rewrite. If the selection is a term, make the meaning plain.",
2884
+ tooltip: "Keep the original marks and place a shorter, plainer rewrite next to them. If the selection is a term, make the meaning plain.",
2885
2885
  shortcut: "s",
2886
2886
  needsSelection: true,
2887
2887
  boardOnly: false,
2888
- replacesSelection: true
2888
+ replacesSelection: false
2889
2889
  },
2890
2890
  {
2891
2891
  id: "breakdown",
@@ -2940,7 +2940,7 @@ function unsysCanvasCommandsFor(_guide, extras = []) {
2940
2940
  shortcut: extra.shortcut ?? "",
2941
2941
  needsSelection: extra.needsSelection ?? false,
2942
2942
  boardOnly: false,
2943
- replacesSelection: extra.replacesSelection ?? false,
2943
+ replacesSelection: false,
2944
2944
  slash: extra.slash,
2945
2945
  run: extra.run
2946
2946
  });
@@ -3112,6 +3112,11 @@ function unsysCanvasBindFanArrow(arrow, start, end, hostBounds) {
3112
3112
  { id: arrow.id, type: "arrow" }
3113
3113
  ];
3114
3114
  }
3115
+ function unsysCanvasFanNoteKind(mark) {
3116
+ if (mark === "ileConcepts") return "concepts";
3117
+ if (mark === "ileSimplify") return "simplify";
3118
+ return "breakdown";
3119
+ }
3115
3120
  function unsysCanvasFanStem(host, hostRect, end, toX, toY, mark, hostBounds) {
3116
3121
  const startX = hostRect.maxX;
3117
3122
  const startY = (hostRect.minY + hostRect.maxY) / 2;
@@ -3216,7 +3221,7 @@ function fanUnsysCanvasLabeledNodes(scene, selectedElements, chunks, mark) {
3216
3221
  x: hostRect.maxX + gapX,
3217
3222
  y: cursorY,
3218
3223
  width: innerWidth,
3219
- label: unsysCanvasNoteLabel(mark === "ileConcepts" ? "concepts" : "breakdown"),
3224
+ label: unsysCanvasNoteLabel(unsysCanvasFanNoteKind(mark)),
3220
3225
  customData: { [mark]: true }
3221
3226
  });
3222
3227
  created.push(...note.elements);
@@ -3385,7 +3390,7 @@ function runUnsysCanvasCommand(input) {
3385
3390
  target ? "Need at least two words to subdivide." : "Select text, or a labeled shape, to subdivide."
3386
3391
  );
3387
3392
  }
3388
- if (input.action === "simplify" || input.action === "refactor") {
3393
+ if (input.action === "refactor") {
3389
3394
  const stripped = removeUnsysCanvasSelection(current, selected);
3390
3395
  return {
3391
3396
  scene: withUnsysCanvasAutoLayout(stripped.scene),
@@ -3393,10 +3398,13 @@ function runUnsysCanvasCommand(input) {
3393
3398
  parts: [],
3394
3399
  selected,
3395
3400
  prompt,
3396
- ask: { kind: input.action, prompt },
3401
+ ask: { kind: "refactor", prompt },
3397
3402
  notice: null
3398
3403
  };
3399
3404
  }
3405
+ if (input.action === "simplify") {
3406
+ return idle(null, { kind: "simplify", prompt });
3407
+ }
3400
3408
  if (input.action === "concepts") {
3401
3409
  return idle(null, { kind: "concepts", prompt });
3402
3410
  }
@@ -4542,13 +4550,18 @@ function applyUnsysCanvasAskReply(input) {
4542
4550
  let next = live;
4543
4551
  if (kind === "selective-compress") {
4544
4552
  next = compressUnsysCanvasSelection(live, selected, source);
4545
- } else if (kind === "simplify" || kind === "refactor") {
4553
+ } else if (kind === "refactor") {
4546
4554
  next = replaceUnsysCanvasSelection(live, selected, {
4547
4555
  text: input.payload.text,
4548
4556
  elements: input.payload.elements,
4549
4557
  turnId: input.payload.turnId,
4550
4558
  label: noteLabel
4551
4559
  });
4560
+ } else if (kind === "simplify") {
4561
+ const text = stripLearnerFacingWrappers(String(input.payload.text || "").trim());
4562
+ if (text) {
4563
+ next = fanUnsysCanvasLabeledNodes(live, selected, [text], "ileSimplify").scene;
4564
+ }
4552
4565
  } else if (kind === "concepts") {
4553
4566
  const labels = unsysCanvasConceptLabels(source, {
4554
4567
  text: input.payload.text,