@makeswift/runtime 0.0.9 → 0.0.10

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.es.js CHANGED
@@ -62,6 +62,7 @@ import { normalize } from "polished";
62
62
  import ReactPlayer from "react-player";
63
63
  import Hotkeys from "slate-hotkeys";
64
64
  import ipsum from "corporate-ipsum";
65
+ import { isHotkey } from "is-hotkey";
65
66
  import { Editor } from "slate-react";
66
67
  import Lists from "@convertkit/slate-lists";
67
68
  import { S as ShapeControlType, I as ImageControlType, C as ColorControlType, a as SelectControlType, T as TextAreaControlType, b as TextInputControlType, N as NumberControlType, c as CheckboxControlType } from "./text-input.es.js";
@@ -7578,7 +7579,7 @@ const Text = forwardRef(function Text2({
7578
7579
  (_a = lastController.current) == null ? void 0 : _a.focus();
7579
7580
  }, []);
7580
7581
  const handleKeyDown = useCallback((event, _editor, next) => {
7581
- var _a, _b;
7582
+ var _a, _b, _c;
7582
7583
  if (Hotkeys.isUndo(event)) {
7583
7584
  (_a = lastController.current) == null ? void 0 : _a.undo();
7584
7585
  return true;
@@ -7587,6 +7588,10 @@ const Text = forwardRef(function Text2({
7587
7588
  (_b = lastController.current) == null ? void 0 : _b.redo();
7588
7589
  return true;
7589
7590
  }
7591
+ if (isHotkey("escape")(event)) {
7592
+ (_c = lastController.current) == null ? void 0 : _c.blur();
7593
+ return true;
7594
+ }
7590
7595
  return next();
7591
7596
  }, []);
7592
7597
  const isInBuilder = useIsInBuilder();
@@ -7599,7 +7604,8 @@ const Text = forwardRef(function Text2({
7599
7604
  value,
7600
7605
  onChange: handleChange,
7601
7606
  onFocus: handleFocus,
7602
- onKeyDown: handleKeyDown
7607
+ onKeyDown: handleKeyDown,
7608
+ onBlur: (e) => e.preventDefault()
7603
7609
  });
7604
7610
  });
7605
7611
  function registerComponent$1(runtime) {
@@ -8578,6 +8584,7 @@ const ElementData = memo(forwardRef(function ElementData2({
8578
8584
  })
8579
8585
  });
8580
8586
  }));
8587
+ const DisableRegisterElement = createContext(false);
8581
8588
  const ElementReference = memo(forwardRef(function ElementReference2({
8582
8589
  elementReference
8583
8590
  }, ref) {
@@ -8614,9 +8621,12 @@ const ElementReference = memo(forwardRef(function ElementReference2({
8614
8621
  return elementReferenceDocument != null ? /* @__PURE__ */ jsx(Document, {
8615
8622
  document: elementReferenceDocument,
8616
8623
  ref
8617
- }) : /* @__PURE__ */ jsx(ElementData, {
8618
- elementData: globalElementData,
8619
- ref
8624
+ }) : /* @__PURE__ */ jsx(DisableRegisterElement.Provider, {
8625
+ value: true,
8626
+ children: /* @__PURE__ */ jsx(ElementData, {
8627
+ elementData: globalElementData,
8628
+ ref
8629
+ })
8620
8630
  });
8621
8631
  }));
8622
8632
  const Element$1 = memo(forwardRef(function Element2({
@@ -8626,17 +8636,18 @@ const Element$1 = memo(forwardRef(function Element2({
8626
8636
  const dispatch = useDispatch();
8627
8637
  const documentKey = useDocumentKey();
8628
8638
  const [handle, setHandle] = useState(null);
8639
+ const isRegisterElementDisabled = useContext(DisableRegisterElement);
8629
8640
  useImperativeHandle(ref, () => handle, [handle]);
8630
8641
  useEffect(() => {
8631
- if (documentKey == null)
8642
+ if (documentKey == null || isRegisterElementDisabled)
8632
8643
  return;
8633
8644
  return dispatch(registerComponentHandleEffect(documentKey, elementKey, handle));
8634
- }, [dispatch, documentKey, elementKey, handle]);
8645
+ }, [dispatch, documentKey, elementKey, handle, isRegisterElementDisabled]);
8635
8646
  useEffect(() => {
8636
- if (documentKey == null)
8647
+ if (documentKey == null || isRegisterElementDisabled)
8637
8648
  return;
8638
8649
  return dispatch(mountComponentEffect(documentKey, elementKey));
8639
- }, [dispatch, documentKey, elementKey]);
8650
+ }, [dispatch, documentKey, elementKey, isRegisterElementDisabled]);
8640
8651
  return isElementReference(element) ? /* @__PURE__ */ jsx(ElementReference, {
8641
8652
  ref: setHandle,
8642
8653
  elementReference: element