@wildwinter/expr-editor 0.8.0 → 0.9.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.md CHANGED
@@ -63,6 +63,11 @@ Notable options beyond the basics:
63
63
  Pills carry `aria-haspopup`/labels and the tree controls carry aria-labels for
64
64
  assistive tech. A comparison of a numeric dialect function against a number
65
65
  (e.g. `turns_since_tag("x") > 3`) deletes as a unit.
66
+
67
+ `renderConditionPreview(src, opts)` / `renderEffectsPreview(effects, opts)`
68
+ return read-only pill strips (same pills as the editor, non-interactive). Pass
69
+ `propertyActions` to make property pills right-click interactive (e.g. "Go to
70
+ definition") while left-click still falls through to the host.
66
71
  - `setText(on)` — the host's raw-text toggle (`</>`); unparseable input falls
67
72
  back to raw text automatically.
68
73
 
package/dist/index.cjs CHANGED
@@ -492,9 +492,10 @@ function attachPropertyMenu(ctx, node, pillEl) {
492
492
  if (!ctx.propertyActions) return;
493
493
  const actions = ctx.propertyActions({ scope: node.scope, name: node.name });
494
494
  if (!actions.length) return;
495
+ const open = ctx.openMenu ?? ctx.openPopover;
495
496
  pillEl.addEventListener("contextmenu", (e) => {
496
497
  e.preventDefault();
497
- ctx.openPopover(pillEl, (close) => {
498
+ open(pillEl, (close) => {
498
499
  const wrap = el("div", "exed-menu");
499
500
  for (const a of actions) wrap.append(button("exed-opt", a.label, () => {
500
501
  a.run();
@@ -1664,7 +1665,13 @@ function frozenCtx(src, o) {
1664
1665
  pickNode: () => {
1665
1666
  },
1666
1667
  // enables labelled node pills; never fires (preview is read-only)
1667
- ...o.nodeLabel ? { nodeLabel: o.nodeLabel } : {}
1668
+ ...o.nodeLabel ? { nodeLabel: o.nodeLabel } : {},
1669
+ ...o.propertyActions ? {
1670
+ propertyActions: o.propertyActions,
1671
+ openMenu: (anchor, render) => {
1672
+ openPopover(anchor, render, { container: o.popoverContainer });
1673
+ }
1674
+ } : {}
1668
1675
  };
1669
1676
  return { ctx, ast: v.ast };
1670
1677
  }
@@ -1673,7 +1680,8 @@ function exprPills(src, o) {
1673
1680
  return ast ? renderNode(ast, [], ctx) : el("span", "exed-preview-raw", [src]);
1674
1681
  }
1675
1682
  function renderConditionPreview(src, o) {
1676
- return el("div", "exed-preview", [exprPills(src, o)]);
1683
+ const cls = o.propertyActions ? "exed-preview exed-preview-interactive" : "exed-preview";
1684
+ return el("div", cls, [exprPills(src, o)]);
1677
1685
  }
1678
1686
  function renderEffectsPreview(effects, o) {
1679
1687
  const wrap = el("div", "exed-preview exed-preview-effects");