@makeswift/runtime 0.0.7 → 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) {
@@ -8169,7 +8175,8 @@ function useStyleControlCssObject(style, controlDefinition) {
8169
8175
  return `${borderRadius.value}${borderRadius.unit}`;
8170
8176
  }
8171
8177
  }
8172
- const useInsertionEffect = (_ea = React.useInsertionEffect) != null ? _ea : React.useLayoutEffect;
8178
+ const useInsertionEffectSpecifier = "useInsertionEffect";
8179
+ const useInsertionEffect = (_ea = React[useInsertionEffectSpecifier]) != null ? _ea : React.useLayoutEffect;
8173
8180
  function useFormattedStyle(styleControlData, controlDefinition) {
8174
8181
  const style = useStyleControlCssObject(styleControlData, controlDefinition);
8175
8182
  const serialized = serializeStyles([style], cache.registered);
@@ -8577,6 +8584,7 @@ const ElementData = memo(forwardRef(function ElementData2({
8577
8584
  })
8578
8585
  });
8579
8586
  }));
8587
+ const DisableRegisterElement = createContext(false);
8580
8588
  const ElementReference = memo(forwardRef(function ElementReference2({
8581
8589
  elementReference
8582
8590
  }, ref) {
@@ -8613,9 +8621,12 @@ const ElementReference = memo(forwardRef(function ElementReference2({
8613
8621
  return elementReferenceDocument != null ? /* @__PURE__ */ jsx(Document, {
8614
8622
  document: elementReferenceDocument,
8615
8623
  ref
8616
- }) : /* @__PURE__ */ jsx(ElementData, {
8617
- elementData: globalElementData,
8618
- ref
8624
+ }) : /* @__PURE__ */ jsx(DisableRegisterElement.Provider, {
8625
+ value: true,
8626
+ children: /* @__PURE__ */ jsx(ElementData, {
8627
+ elementData: globalElementData,
8628
+ ref
8629
+ })
8619
8630
  });
8620
8631
  }));
8621
8632
  const Element$1 = memo(forwardRef(function Element2({
@@ -8625,17 +8636,18 @@ const Element$1 = memo(forwardRef(function Element2({
8625
8636
  const dispatch = useDispatch();
8626
8637
  const documentKey = useDocumentKey();
8627
8638
  const [handle, setHandle] = useState(null);
8639
+ const isRegisterElementDisabled = useContext(DisableRegisterElement);
8628
8640
  useImperativeHandle(ref, () => handle, [handle]);
8629
8641
  useEffect(() => {
8630
- if (documentKey == null)
8642
+ if (documentKey == null || isRegisterElementDisabled)
8631
8643
  return;
8632
8644
  return dispatch(registerComponentHandleEffect(documentKey, elementKey, handle));
8633
- }, [dispatch, documentKey, elementKey, handle]);
8645
+ }, [dispatch, documentKey, elementKey, handle, isRegisterElementDisabled]);
8634
8646
  useEffect(() => {
8635
- if (documentKey == null)
8647
+ if (documentKey == null || isRegisterElementDisabled)
8636
8648
  return;
8637
8649
  return dispatch(mountComponentEffect(documentKey, elementKey));
8638
- }, [dispatch, documentKey, elementKey]);
8650
+ }, [dispatch, documentKey, elementKey, isRegisterElementDisabled]);
8639
8651
  return isElementReference(element) ? /* @__PURE__ */ jsx(ElementReference, {
8640
8652
  ref: setHandle,
8641
8653
  elementReference: element