@hlang-org/editor-ui 0.1.0 → 0.2.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/lib/index.mjs CHANGED
@@ -553,9 +553,8 @@ function PillNodeChrome({ node, selected }) {
553
553
  ) : /* @__PURE__ */ jsx10(
554
554
  "span",
555
555
  {
556
- className: "hl-pill-name nodrag",
557
- onClick: (e) => {
558
- e.stopPropagation();
556
+ className: "hl-pill-name",
557
+ onClick: () => {
559
558
  onNameClick();
560
559
  },
561
560
  title: "Double-click to rename",
@@ -879,7 +878,7 @@ function CanvasDock({
879
878
  /* @__PURE__ */ jsx17("button", { className: "hl-dock-btn", onClick: onZoomOut, title: "Zoom out", "aria-label": "Zoom out", children: /* @__PURE__ */ jsx17("span", { className: "hl-dock-glyph", children: "\u2212" }) }),
880
879
  /* @__PURE__ */ jsx17("button", { className: "hl-dock-zoom hl-mono", onClick: onFitView, title: "Fit view", children: pct }),
881
880
  /* @__PURE__ */ jsx17("button", { className: "hl-dock-btn", onClick: onZoomIn, title: "Zoom in", "aria-label": "Zoom in", children: /* @__PURE__ */ jsx17("span", { className: "hl-dock-glyph", children: "+" }) }),
882
- /* @__PURE__ */ jsx17("button", { className: "hl-dock-btn", onClick: onFitView, title: "Fit view", "aria-label": "Fit view", children: /* @__PURE__ */ jsx17(FitIcon, {}) })
881
+ /* @__PURE__ */ jsx17("button", { className: "hl-dock-btn hl-dock-fit", onClick: onFitView, title: "Fit view", "aria-label": "Fit view", children: /* @__PURE__ */ jsx17(FitIcon, {}) })
883
882
  ] });
884
883
  }
885
884
 
@@ -1884,11 +1883,19 @@ function isEditableTarget(target) {
1884
1883
  const tag = target.tagName;
1885
1884
  return tag === "INPUT" || tag === "TEXTAREA" || target.isContentEditable;
1886
1885
  }
1887
- function useEditorHotkeys(core) {
1886
+ function withinScope(target, scope) {
1887
+ if (scope === void 0) {
1888
+ return true;
1889
+ }
1890
+ const root = scope.current;
1891
+ return root !== null && target instanceof Node && root.contains(target);
1892
+ }
1893
+ function useEditorHotkeys(core, options = {}) {
1888
1894
  const clipboard = useClipboard(core);
1895
+ const { scope } = options;
1889
1896
  useEffect5(() => {
1890
1897
  const onKeyDown = (event) => {
1891
- if (isEditableTarget(event.target)) {
1898
+ if (!withinScope(event.target, scope) || isEditableTarget(event.target)) {
1892
1899
  return;
1893
1900
  }
1894
1901
  const mod = event.metaKey || event.ctrlKey;
@@ -1945,7 +1952,7 @@ function useEditorHotkeys(core) {
1945
1952
  return () => {
1946
1953
  window.removeEventListener("keydown", onKeyDown);
1947
1954
  };
1948
- }, [core, clipboard]);
1955
+ }, [core, clipboard, scope]);
1949
1956
  }
1950
1957
 
1951
1958
  // src/context-menu/NodeContextMenu.tsx