@makeswift/runtime 0.8.9 → 0.8.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/Box.cjs.js +2 -4
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +2 -4
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +1 -4
- package/dist/Button.cjs.js.map +1 -1
- package/dist/Button.es.js +1 -4
- package/dist/Button.es.js.map +1 -1
- package/dist/Carousel.cjs.js +1 -4
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Carousel.es.js +1 -4
- package/dist/Carousel.es.js.map +1 -1
- package/dist/Countdown.cjs.js +1 -4
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +1 -4
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +1 -4
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +1 -4
- package/dist/Divider.es.js.map +1 -1
- package/dist/Embed.cjs.js +3 -5
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +3 -5
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +1 -4
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +2 -5
- package/dist/Form.es.js.map +1 -1
- package/dist/Image.cjs.js +1 -4
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +2 -5
- package/dist/Image.es.js.map +1 -1
- package/dist/LiveProvider.cjs.js +1 -4
- package/dist/LiveProvider.cjs.js.map +1 -1
- package/dist/LiveProvider.es.js +2 -5
- package/dist/LiveProvider.es.js.map +1 -1
- package/dist/Navigation.cjs.js +3 -5
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +3 -5
- package/dist/Navigation.es.js.map +1 -1
- package/dist/PreviewProvider.cjs.js +1 -4
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +3 -6
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +62 -60
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +9 -7
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +318 -0
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -0
- package/dist/ReadOnlyTextV2.es.js +314 -0
- package/dist/ReadOnlyTextV2.es.js.map +1 -0
- package/dist/Root.cjs.js +2 -4
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +2 -4
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.cjs.js +1 -4
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +1 -4
- package/dist/SocialLinks.es.js.map +1 -1
- package/dist/Text.cjs.js +2 -5
- package/dist/Text.cjs.js.map +1 -1
- package/dist/Text.es.js +3 -6
- package/dist/Text.es.js.map +1 -1
- package/dist/Video.cjs.js +1 -4
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +1 -4
- package/dist/Video.es.js.map +1 -1
- package/dist/actions.cjs.js.map +1 -1
- package/dist/actions.es.js.map +1 -1
- package/dist/builder.cjs.js +1 -2
- package/dist/builder.cjs.js.map +1 -1
- package/dist/builder.es.js +1 -2
- package/dist/builder.es.js.map +1 -1
- package/dist/components.cjs.js +2 -4
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +2 -4
- package/dist/components.es.js.map +1 -1
- package/dist/constants.cjs.js.map +1 -1
- package/dist/constants.es.js.map +1 -1
- package/dist/control-serialization.cjs.js +0 -2
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +0 -2
- package/dist/control-serialization.es.js.map +1 -1
- package/dist/controls.cjs.js +2 -6
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +2 -3
- package/dist/controls.es.js.map +1 -1
- package/dist/descriptors.cjs.js +53 -88
- package/dist/descriptors.cjs.js.map +1 -1
- package/dist/descriptors.es.js +32 -64
- package/dist/descriptors.es.js.map +1 -1
- package/dist/element.cjs.js +55 -0
- package/dist/element.cjs.js.map +1 -0
- package/dist/element.es.js +54 -0
- package/dist/element.es.js.map +1 -0
- package/dist/index.cjs.js +33 -116
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs2.js +3 -4
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs5.js +48 -82
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +41 -42
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.cjs7.js +14 -341
- package/dist/index.cjs7.js.map +1 -1
- package/dist/index.cjs8.js +209 -0
- package/dist/index.cjs8.js.map +1 -0
- package/dist/index.cjs9.js +370 -0
- package/dist/index.cjs9.js.map +1 -0
- package/dist/index.es.js +32 -117
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +2 -3
- package/dist/index.es2.js.map +1 -1
- package/dist/index.es3.js +1 -1
- package/dist/index.es5.js +19 -54
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +36 -40
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es7.js +13 -336
- package/dist/index.es7.js.map +1 -1
- package/dist/index.es8.js +202 -0
- package/dist/index.es8.js.map +1 -0
- package/dist/index.es9.js +363 -0
- package/dist/index.es9.js.map +1 -0
- package/dist/introspection.cjs.js +0 -2
- package/dist/introspection.cjs.js.map +1 -1
- package/dist/introspection.es.js +0 -2
- package/dist/introspection.es.js.map +1 -1
- package/dist/leaf.cjs.js.map +1 -1
- package/dist/leaf.es.js +1 -1
- package/dist/leaf.es.js.map +1 -1
- package/dist/main.cjs.js +1 -2
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +1 -2
- package/dist/main.es.js.map +1 -1
- package/dist/next.cjs.js +1 -4
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +2 -5
- package/dist/next.es.js.map +1 -1
- package/dist/prop-controllers.cjs.js +1 -2
- package/dist/prop-controllers.cjs.js.map +1 -1
- package/dist/prop-controllers.es.js +1 -2
- package/dist/prop-controllers.es.js.map +1 -1
- package/dist/react.cjs.js +1 -4
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +1 -4
- package/dist/react.es.js.map +1 -1
- package/dist/slate.cjs.js +8 -3
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.cjs2.js +46 -0
- package/dist/slate.cjs2.js.map +1 -0
- package/dist/slate.es.js +6 -4
- package/dist/slate.es.js.map +1 -1
- package/dist/slate.es2.js +44 -0
- package/dist/slate.es2.js.map +1 -0
- package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
- package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
- package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts +2 -1
- package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/components/Element/block.d.ts +1 -1
- package/dist/types/src/components/builtin/Text/components/Element/block.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts +1 -1
- package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts +1 -1
- package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +1 -1
- package/dist/types/src/controls/list.d.ts +2 -1
- package/dist/types/src/controls/list.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/dto-types.d.ts +1 -1
- package/dist/types/src/controls/rich-text/dto-types.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/index.d.ts +0 -1
- package/dist/types/src/controls/rich-text/index.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/rich-text.d.ts +1 -1
- package/dist/types/src/controls/rich-text/rich-text.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/translation.d.ts +1 -1
- package/dist/types/src/controls/rich-text/translation.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +25 -4
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/controls/shape.d.ts +2 -1
- package/dist/types/src/controls/shape.d.ts.map +1 -1
- package/dist/types/src/controls/slot.d.ts +1 -1
- package/dist/types/src/controls/slot.d.ts.map +1 -1
- package/dist/types/src/controls/style.d.ts +2 -1
- package/dist/types/src/controls/style.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/base.d.ts +7 -0
- package/dist/types/src/prop-controllers/base.d.ts.map +1 -0
- package/dist/types/src/prop-controllers/instances.d.ts +1 -5
- package/dist/types/src/prop-controllers/instances.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts +13 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/index.d.ts +4 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/index.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.d.ts +9 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts +21 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/index.d.ts +2 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/index.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts +8 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/index.d.ts +1 -1
- package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/types.d.ts +1 -1
- package/dist/types/src/slate/BlockPlugin/types.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/unwrapInline.d.ts +1 -1
- package/dist/types/src/slate/BlockPlugin/unwrapInline.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/wrapInline.d.ts +1 -1
- package/dist/types/src/slate/BlockPlugin/wrapInline.d.ts.map +1 -1
- package/dist/types/src/slate/BuilderPlugin/index.d.ts +7 -0
- package/dist/types/src/slate/BuilderPlugin/index.d.ts.map +1 -0
- package/dist/types/src/slate/InlineModePlugin/index.d.ts +5 -0
- package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -0
- package/dist/types/src/slate/ListPlugin/index.d.ts +1 -1
- package/dist/types/src/slate/ListPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/ListPlugin/toggleList.d.ts +1 -1
- package/dist/types/src/slate/ListPlugin/toggleList.d.ts.map +1 -1
- package/dist/types/src/slate/ListPlugin/wrapList.d.ts +1 -1
- package/dist/types/src/slate/ListPlugin/wrapList.d.ts.map +1 -1
- package/dist/types/src/slate/TypographyPlugin/detachActiveTypography.d.ts +1 -1
- package/dist/types/src/slate/TypographyPlugin/detachActiveTypography.d.ts.map +1 -1
- package/dist/types/src/slate/TypographyPlugin/index.d.ts +1 -1
- package/dist/types/src/slate/TypographyPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/TypographyPlugin/setActiveTypographyStyle.d.ts.map +1 -1
- package/dist/types/src/slate/index.d.ts +2 -0
- package/dist/types/src/slate/index.d.ts.map +1 -1
- package/dist/types/src/slate/selectors.d.ts +1 -1
- package/dist/types/src/slate/selectors.d.ts.map +1 -1
- package/dist/types/src/slate/utils/editor.d.ts +1 -1
- package/dist/types/src/slate/utils/editor.d.ts.map +1 -1
- package/dist/types/src/slate/utils/element.d.ts +1 -1
- package/dist/types/src/slate/utils/element.d.ts.map +1 -1
- package/dist/types/src/state/actions.d.ts +2 -1
- package/dist/types/src/state/actions.d.ts.map +1 -1
- package/dist/types/src/state/modules/prop-controller-handles.d.ts +2 -1
- package/dist/types/src/state/modules/prop-controller-handles.d.ts.map +1 -1
- package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
- package/dist/types/src/state/react-page.d.ts +1 -1
- package/dist/types/src/state/react-page.d.ts.map +1 -1
- package/dist/types/{src/controls/rich-text/types.d.ts → types/slate.d.ts} +20 -17
- package/dist/types/types/slate.d.ts.map +1 -0
- package/dist/useIsomorphicLayoutEffect.cjs.js +6 -0
- package/dist/useIsomorphicLayoutEffect.cjs.js.map +1 -0
- package/dist/useIsomorphicLayoutEffect.es.js +5 -0
- package/dist/useIsomorphicLayoutEffect.es.js.map +1 -0
- package/package.json +1 -1
- package/dist/types/src/controls/rich-text/types.d.ts.map +0 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2.d.ts +0 -15
- package/dist/types/src/runtimes/react/controls/rich-text-v2.d.ts.map +0 -1
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
34
|
+
var React = require("react");
|
|
35
|
+
var slate$1 = require("slate");
|
|
36
|
+
var slateReact = require("slate-react");
|
|
37
|
+
var css = require("@emotion/css");
|
|
38
|
+
var boxModels = require("./box-models.cjs.js");
|
|
39
|
+
var descriptors = require("./descriptors.cjs.js");
|
|
40
|
+
var leaf = require("./leaf.cjs.js");
|
|
41
|
+
var next = require("./index.cjs.js");
|
|
42
|
+
var slate = require("./slate.cjs2.js");
|
|
43
|
+
var jsxRuntime = require("react/jsx-runtime");
|
|
44
|
+
var index = require("./index.cjs3.js");
|
|
45
|
+
var isHotkey = require("is-hotkey");
|
|
46
|
+
var index$1 = require("./index.cjs5.js");
|
|
47
|
+
var useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect.cjs.js");
|
|
48
|
+
require("css-box-model");
|
|
49
|
+
require("./actions.cjs.js");
|
|
50
|
+
require("./introspection.cjs.js");
|
|
51
|
+
require("./state/breakpoints.cjs.js");
|
|
52
|
+
require("use-sync-external-store/shim/with-selector");
|
|
53
|
+
require("next/dynamic");
|
|
54
|
+
require("./constants.cjs.js");
|
|
55
|
+
require("redux");
|
|
56
|
+
require("redux-thunk");
|
|
57
|
+
require("@emotion/serialize");
|
|
58
|
+
require("@emotion/utils");
|
|
59
|
+
require("./text-input.cjs.js");
|
|
60
|
+
require("./combobox.cjs.js");
|
|
61
|
+
require("use-sync-external-store/shim");
|
|
62
|
+
require("./types.cjs.js");
|
|
63
|
+
require("color");
|
|
64
|
+
require("scroll-into-view-if-needed");
|
|
65
|
+
require("react-dom");
|
|
66
|
+
require("html-react-parser");
|
|
67
|
+
require("next/head");
|
|
68
|
+
require("@emotion/server/create-instance");
|
|
69
|
+
require("next/document");
|
|
70
|
+
require("cors");
|
|
71
|
+
require("path-to-regexp");
|
|
72
|
+
require("cookie");
|
|
73
|
+
require("http-proxy");
|
|
74
|
+
require("set-cookie-parser");
|
|
75
|
+
require("uuid");
|
|
76
|
+
require("corporate-ipsum");
|
|
77
|
+
require("next/link");
|
|
78
|
+
require("./element.cjs.js");
|
|
79
|
+
function _interopDefaultLegacy(e) {
|
|
80
|
+
return e && typeof e === "object" && "default" in e ? e : { "default": e };
|
|
81
|
+
}
|
|
82
|
+
var isHotkey__default = /* @__PURE__ */ _interopDefaultLegacy(isHotkey);
|
|
83
|
+
function BlockElement({
|
|
84
|
+
element,
|
|
85
|
+
attributes,
|
|
86
|
+
children
|
|
87
|
+
}) {
|
|
88
|
+
const blockStyles = [next.useStyle({
|
|
89
|
+
margin: 0
|
|
90
|
+
}), next.useStyle(next.useResponsiveStyle([element.textAlign], ([textAlign = "left"]) => ({
|
|
91
|
+
textAlign
|
|
92
|
+
})))];
|
|
93
|
+
switch (element.type) {
|
|
94
|
+
case slate.BlockType.Text:
|
|
95
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps(__spreadValues({}, attributes), {
|
|
96
|
+
className: css.cx(...blockStyles),
|
|
97
|
+
children
|
|
98
|
+
}));
|
|
99
|
+
case slate.BlockType.Paragraph:
|
|
100
|
+
return /* @__PURE__ */ jsxRuntime.jsx("p", __spreadProps(__spreadValues({}, attributes), {
|
|
101
|
+
className: css.cx(...blockStyles),
|
|
102
|
+
children
|
|
103
|
+
}));
|
|
104
|
+
case slate.BlockType.Heading1:
|
|
105
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h1", __spreadProps(__spreadValues({}, attributes), {
|
|
106
|
+
className: css.cx(...blockStyles),
|
|
107
|
+
children
|
|
108
|
+
}));
|
|
109
|
+
case slate.BlockType.Heading2:
|
|
110
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h2", __spreadProps(__spreadValues({}, attributes), {
|
|
111
|
+
className: css.cx(...blockStyles),
|
|
112
|
+
children
|
|
113
|
+
}));
|
|
114
|
+
case slate.BlockType.Heading3:
|
|
115
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h3", __spreadProps(__spreadValues({}, attributes), {
|
|
116
|
+
className: css.cx(...blockStyles),
|
|
117
|
+
children
|
|
118
|
+
}));
|
|
119
|
+
case slate.BlockType.Heading4:
|
|
120
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h4", __spreadProps(__spreadValues({}, attributes), {
|
|
121
|
+
className: css.cx(...blockStyles),
|
|
122
|
+
children
|
|
123
|
+
}));
|
|
124
|
+
case slate.BlockType.Heading5:
|
|
125
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h5", __spreadProps(__spreadValues({}, attributes), {
|
|
126
|
+
className: css.cx(...blockStyles),
|
|
127
|
+
children
|
|
128
|
+
}));
|
|
129
|
+
case slate.BlockType.Heading6:
|
|
130
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h6", __spreadProps(__spreadValues({}, attributes), {
|
|
131
|
+
className: css.cx(...blockStyles),
|
|
132
|
+
children
|
|
133
|
+
}));
|
|
134
|
+
case slate.BlockType.BlockQuote:
|
|
135
|
+
return /* @__PURE__ */ jsxRuntime.jsx("blockquote", __spreadProps(__spreadValues({}, attributes), {
|
|
136
|
+
className: css.cx(...blockStyles, next.useStyle({
|
|
137
|
+
padding: "0.5em 10px",
|
|
138
|
+
fontSize: "1.25em",
|
|
139
|
+
fontWeight: "300",
|
|
140
|
+
borderLeft: "5px solid rgba(0, 0, 0, 0.1)"
|
|
141
|
+
})),
|
|
142
|
+
children
|
|
143
|
+
}));
|
|
144
|
+
case slate.BlockType.OrderedList:
|
|
145
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ol", __spreadProps(__spreadValues({}, attributes), {
|
|
146
|
+
className: css.cx(...blockStyles),
|
|
147
|
+
style: {
|
|
148
|
+
listStylePosition: "inside"
|
|
149
|
+
},
|
|
150
|
+
children
|
|
151
|
+
}));
|
|
152
|
+
case slate.BlockType.UnorderedList:
|
|
153
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", __spreadProps(__spreadValues({}, attributes), {
|
|
154
|
+
className: css.cx(...blockStyles),
|
|
155
|
+
style: {
|
|
156
|
+
listStylePosition: "inside"
|
|
157
|
+
},
|
|
158
|
+
children
|
|
159
|
+
}));
|
|
160
|
+
case slate.BlockType.ListItem:
|
|
161
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", __spreadProps(__spreadValues({}, attributes), {
|
|
162
|
+
className: css.cx(...blockStyles),
|
|
163
|
+
children
|
|
164
|
+
}));
|
|
165
|
+
case slate.BlockType.ListItemChild:
|
|
166
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps(__spreadValues({}, attributes), {
|
|
167
|
+
className: css.cx(...blockStyles),
|
|
168
|
+
children
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function StyledLink(_a) {
|
|
173
|
+
var _b = _a, {
|
|
174
|
+
className
|
|
175
|
+
} = _b, restOfProps = __objRest(_b, [
|
|
176
|
+
"className"
|
|
177
|
+
]);
|
|
178
|
+
return /* @__PURE__ */ jsxRuntime.jsx(index.Link, __spreadProps(__spreadValues({}, restOfProps), {
|
|
179
|
+
className: css.cx(next.useStyle({
|
|
180
|
+
textDecoration: "none"
|
|
181
|
+
}), className)
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
function InlineElement({
|
|
185
|
+
element,
|
|
186
|
+
attributes,
|
|
187
|
+
children
|
|
188
|
+
}) {
|
|
189
|
+
switch (element.type) {
|
|
190
|
+
case slate.InlineType.Code:
|
|
191
|
+
return /* @__PURE__ */ jsxRuntime.jsx("code", __spreadProps(__spreadValues({}, attributes), {
|
|
192
|
+
children
|
|
193
|
+
}));
|
|
194
|
+
case slate.InlineType.SuperScript:
|
|
195
|
+
return /* @__PURE__ */ jsxRuntime.jsx("sup", __spreadProps(__spreadValues({}, attributes), {
|
|
196
|
+
children
|
|
197
|
+
}));
|
|
198
|
+
case slate.InlineType.SubScript:
|
|
199
|
+
return /* @__PURE__ */ jsxRuntime.jsx("sub", __spreadProps(__spreadValues({}, attributes), {
|
|
200
|
+
children
|
|
201
|
+
}));
|
|
202
|
+
case slate.InlineType.Link:
|
|
203
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StyledLink, __spreadProps(__spreadValues({}, attributes), {
|
|
204
|
+
link: element.link,
|
|
205
|
+
children
|
|
206
|
+
}));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function Element(_c) {
|
|
210
|
+
var _d = _c, {
|
|
211
|
+
element
|
|
212
|
+
} = _d, props = __objRest(_d, [
|
|
213
|
+
"element"
|
|
214
|
+
]);
|
|
215
|
+
switch (element.type) {
|
|
216
|
+
case slate.InlineType.Code:
|
|
217
|
+
case slate.InlineType.SuperScript:
|
|
218
|
+
case slate.InlineType.SubScript:
|
|
219
|
+
case slate.InlineType.Link:
|
|
220
|
+
return /* @__PURE__ */ jsxRuntime.jsx(InlineElement, __spreadValues({
|
|
221
|
+
element
|
|
222
|
+
}, props));
|
|
223
|
+
case slate.BlockType.Paragraph:
|
|
224
|
+
case slate.BlockType.Heading1:
|
|
225
|
+
case slate.BlockType.Heading2:
|
|
226
|
+
case slate.BlockType.Heading3:
|
|
227
|
+
case slate.BlockType.BlockQuote:
|
|
228
|
+
case slate.BlockType.OrderedList:
|
|
229
|
+
case slate.BlockType.UnorderedList:
|
|
230
|
+
case slate.BlockType.ListItem:
|
|
231
|
+
case slate.BlockType.ListItemChild:
|
|
232
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BlockElement, __spreadValues({
|
|
233
|
+
element
|
|
234
|
+
}, props));
|
|
235
|
+
default:
|
|
236
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps(__spreadValues({}, props.attributes), {
|
|
237
|
+
children: props.children
|
|
238
|
+
}));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const COMMIT_DEBOUNCE_DELAY = 500;
|
|
242
|
+
function useSyncWithBuilder(editor, text) {
|
|
243
|
+
const [shouldCommit, setShouldCommit] = React.useState(true);
|
|
244
|
+
const isInBuilder = next.useIsInBuilder();
|
|
245
|
+
React.useEffect(() => {
|
|
246
|
+
if (shouldCommit && text && isInBuilder) {
|
|
247
|
+
const nextValue = descriptors.richTextDTOtoDAO(text);
|
|
248
|
+
const nextSelection = descriptors.richTextDTOtoSelection(text);
|
|
249
|
+
if (!next.deepEqual(editor.children, nextValue) || !next.deepEqual(editor.selection, nextSelection)) {
|
|
250
|
+
editor.children = nextValue;
|
|
251
|
+
editor.selection = nextSelection;
|
|
252
|
+
editor.onChange();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}, [editor, shouldCommit, text]);
|
|
256
|
+
React.useEffect(() => {
|
|
257
|
+
if (shouldCommit)
|
|
258
|
+
return;
|
|
259
|
+
const timeoutId = window.setTimeout(() => {
|
|
260
|
+
setShouldCommit(true);
|
|
261
|
+
}, COMMIT_DEBOUNCE_DELAY);
|
|
262
|
+
return () => {
|
|
263
|
+
window.clearTimeout(timeoutId);
|
|
264
|
+
};
|
|
265
|
+
}, [shouldCommit]);
|
|
266
|
+
return React.useCallback(() => setShouldCommit(false), []);
|
|
267
|
+
}
|
|
268
|
+
function useSyncDOMSelection(editor, isEnabled) {
|
|
269
|
+
useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
270
|
+
if (!isEnabled || editor.selection == null || slateReact.ReactEditor.isFocused(editor))
|
|
271
|
+
return;
|
|
272
|
+
try {
|
|
273
|
+
const root = slateReact.ReactEditor.findDocumentOrShadowRoot(editor);
|
|
274
|
+
const domSelection = root.getSelection();
|
|
275
|
+
const newDomRange = slateReact.ReactEditor.toDOMRange(editor, editor.selection);
|
|
276
|
+
if (newDomRange) {
|
|
277
|
+
if (slate$1.Range.isBackward(editor.selection)) {
|
|
278
|
+
domSelection == null ? void 0 : domSelection.setBaseAndExtent(newDomRange.endContainer, newDomRange.endOffset, newDomRange.startContainer, newDomRange.startOffset);
|
|
279
|
+
} else {
|
|
280
|
+
domSelection == null ? void 0 : domSelection.setBaseAndExtent(newDomRange.startContainer, newDomRange.startOffset, newDomRange.endContainer, newDomRange.endOffset);
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
domSelection == null ? void 0 : domSelection.removeAllRanges();
|
|
284
|
+
}
|
|
285
|
+
} catch (e) {
|
|
286
|
+
console.error(e);
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
const defaultText = [{
|
|
291
|
+
type: slate.BlockType.Paragraph,
|
|
292
|
+
children: [{
|
|
293
|
+
text: ""
|
|
294
|
+
}]
|
|
295
|
+
}];
|
|
296
|
+
const EditableText = React.forwardRef(function EditableText2({
|
|
297
|
+
id,
|
|
298
|
+
text,
|
|
299
|
+
width,
|
|
300
|
+
margin
|
|
301
|
+
}, ref) {
|
|
302
|
+
const [editor] = React.useState(() => index$1.withBlock(index$1.withTypography(index$1.withList(index$1.withBuilder(slateReact.withReact(slate$1.createEditor()))))));
|
|
303
|
+
const [isPreservingDOMSElection, setIsPreservingDOMSelection] = React.useState(false);
|
|
304
|
+
useSyncDOMSelection(editor, isPreservingDOMSElection);
|
|
305
|
+
const delaySync = useSyncWithBuilder(editor, text);
|
|
306
|
+
const editMode = next.useBuilderEditMode();
|
|
307
|
+
const [propControllers, setPropControllers] = React.useState(null);
|
|
308
|
+
const controller = propControllers == null ? void 0 : propControllers.text;
|
|
309
|
+
React.useEffect(() => {
|
|
310
|
+
if (controller == null)
|
|
311
|
+
return;
|
|
312
|
+
const element = slateReact.ReactEditor.toDOMNode(editor, editor);
|
|
313
|
+
return next.pollBoxModel({
|
|
314
|
+
element,
|
|
315
|
+
onBoxModelChange: (boxModel) => controller.changeBoxModel(boxModel)
|
|
316
|
+
});
|
|
317
|
+
}, [editor, controller]);
|
|
318
|
+
React.useImperativeHandle(ref, () => ({
|
|
319
|
+
getDomNode() {
|
|
320
|
+
return slateReact.ReactEditor.toDOMNode(editor, editor);
|
|
321
|
+
},
|
|
322
|
+
getBoxModel() {
|
|
323
|
+
return boxModels.getBox(slateReact.ReactEditor.toDOMNode(editor, editor));
|
|
324
|
+
},
|
|
325
|
+
setPropControllers
|
|
326
|
+
}), [editor, setPropControllers]);
|
|
327
|
+
const initialValue = React.useMemo(() => text ? descriptors.richTextDTOtoDAO(text) : defaultText, [text]);
|
|
328
|
+
React.useEffect(() => {
|
|
329
|
+
controller == null ? void 0 : controller.setSlateEditor(editor);
|
|
330
|
+
}, [controller, editor]);
|
|
331
|
+
const handleFocus = React.useCallback(() => {
|
|
332
|
+
controller == null ? void 0 : controller.focus();
|
|
333
|
+
setIsPreservingDOMSelection(true);
|
|
334
|
+
}, [controller]);
|
|
335
|
+
const handleKeyDown = React.useCallback((e) => {
|
|
336
|
+
if (isHotkey__default["default"]("mod+shift+z", e))
|
|
337
|
+
return controller == null ? void 0 : controller.redo();
|
|
338
|
+
if (isHotkey__default["default"]("mod+z", e))
|
|
339
|
+
return controller == null ? void 0 : controller.undo();
|
|
340
|
+
if (isHotkey__default["default"]("escape")(e))
|
|
341
|
+
return controller == null ? void 0 : controller.blur();
|
|
342
|
+
index$1.onKeyDown(e, editor);
|
|
343
|
+
}, [controller, editor]);
|
|
344
|
+
const handleBlur = React.useCallback((e) => {
|
|
345
|
+
if (e.relatedTarget == null)
|
|
346
|
+
return;
|
|
347
|
+
setIsPreservingDOMSelection(false);
|
|
348
|
+
slateReact.ReactEditor.deselect(editor);
|
|
349
|
+
}, []);
|
|
350
|
+
return /* @__PURE__ */ jsxRuntime.jsx(slateReact.Slate, {
|
|
351
|
+
editor,
|
|
352
|
+
value: initialValue,
|
|
353
|
+
onChange: delaySync,
|
|
354
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(slateReact.Editable, {
|
|
355
|
+
id,
|
|
356
|
+
renderLeaf: leaf.Leaf,
|
|
357
|
+
renderElement: Element,
|
|
358
|
+
onFocus: handleFocus,
|
|
359
|
+
onKeyDown: handleKeyDown,
|
|
360
|
+
onBlur: handleBlur,
|
|
361
|
+
className: css.cx(width, margin),
|
|
362
|
+
readOnly: editMode !== descriptors.BuilderEditMode.CONTENT,
|
|
363
|
+
placeholder: "Write some text..."
|
|
364
|
+
})
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
var EditableText$1 = EditableText;
|
|
368
|
+
exports.EditableText = EditableText;
|
|
369
|
+
exports["default"] = EditableText$1;
|
|
370
|
+
//# sourceMappingURL=index.cjs9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs9.js","sources":["../src/components/builtin/Text/components/Element/block.tsx","../src/components/builtin/Text/components/Element/inline.tsx","../src/components/builtin/Text/components/Element/element.tsx","../src/components/builtin/Text/EditableText/useSyncWithBuilder.tsx","../src/components/builtin/Text/EditableText/useSyncDOMSelection.tsx","../src/components/builtin/Text/EditableText/editable-text.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { RenderElementProps } from 'slate-react'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { useResponsiveStyle } from '../../../../utils/responsive-style'\nimport { Block, BlockType } from '../../../../../../types/slate'\n\nexport interface InlineRenderElementProps extends RenderElementProps {\n element: Block\n}\n\nexport function BlockElement({ element, attributes, children }: InlineRenderElementProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([element.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n\n switch (element.type) {\n case BlockType.Text:\n return (\n <span {...attributes} className={cx(...blockStyles)}>\n {children}\n </span>\n )\n case BlockType.Paragraph:\n return (\n <p {...attributes} className={cx(...blockStyles)}>\n {children}\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote\n {...attributes}\n className={cx(\n ...blockStyles,\n useStyle({\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n }),\n )}\n >\n {children}\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol {...attributes} className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n {children}\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul {...attributes} className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n {children}\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li {...attributes} className={cx(...blockStyles)}>\n {children}\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span {...attributes} className={cx(...blockStyles)}>\n {children}\n </span>\n )\n }\n}\n","import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef } from 'react'\nimport { RenderElementProps } from 'slate-react'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { Link } from '../../../../shared/Link'\nimport { Inline, InlineType } from '../../../../../../types/slate'\n\nfunction StyledLink({ className, ...restOfProps }: ComponentPropsWithoutRef<typeof Link>) {\n return <Link {...restOfProps} className={cx(useStyle({ textDecoration: 'none' }), className)} />\n}\n\nexport interface InlineRenderElementProps extends RenderElementProps {\n element: Inline\n}\n\nexport function InlineElement({ element, attributes, children }: InlineRenderElementProps) {\n switch (element.type) {\n case InlineType.Code:\n return <code {...attributes}>{children}</code>\n case InlineType.SuperScript:\n return <sup {...attributes}>{children}</sup>\n case InlineType.SubScript:\n return <sub {...attributes}>{children}</sub>\n case InlineType.Link:\n return (\n <StyledLink {...attributes} link={element.link}>\n {children}\n </StyledLink>\n )\n }\n}\n","import { RenderElementProps } from 'slate-react'\nimport { BlockElement } from './block'\nimport { InlineElement } from './inline'\nimport { InlineType, BlockType } from '../../../../../../types/slate'\n\nexport function Element({ element, ...props }: RenderElementProps) {\n switch (element.type) {\n case InlineType.Code:\n case InlineType.SuperScript:\n case InlineType.SubScript:\n case InlineType.Link:\n return <InlineElement element={element} {...props} />\n case BlockType.Paragraph:\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement element={element} {...props} />\n default:\n return <span {...props.attributes}>{props.children}</span>\n }\n}\n","import { useState, useEffect, useCallback } from 'react'\nimport { Editor } from 'slate'\nimport { richTextDTOtoDAO, richTextDTOtoSelection } from '../../../../controls'\nimport { RichTextValue } from '../../../../prop-controllers'\nimport deepEqual from '../../../../utils/deepEqual'\nimport { useIsInBuilder } from '../../../../runtimes/react'\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\n/**\n * Compare new prop value with current editor and update editor\n * if the values are not equal.\n */\nexport function useSyncWithBuilder(editor: Editor, text?: RichTextValue) {\n const [shouldCommit, setShouldCommit] = useState(true)\n const isInBuilder = useIsInBuilder()\n\n useEffect(() => {\n if (shouldCommit && text && isInBuilder) {\n const nextValue = richTextDTOtoDAO(text)\n const nextSelection = richTextDTOtoSelection(text)\n if (!deepEqual(editor.children, nextValue) || !deepEqual(editor.selection, nextSelection)) {\n editor.children = nextValue\n editor.selection = nextSelection\n editor.onChange()\n }\n }\n }, [editor, shouldCommit, text])\n\n useEffect(() => {\n if (shouldCommit) return\n\n const timeoutId = window.setTimeout(() => {\n setShouldCommit(true)\n }, COMMIT_DEBOUNCE_DELAY)\n\n return () => {\n window.clearTimeout(timeoutId)\n }\n }, [shouldCommit])\n\n return useCallback(() => setShouldCommit(false), [])\n}\n","import { ReactEditor } from 'slate-react'\nimport { useIsomorphicLayoutEffect } from '../../../hooks/useIsomorphicLayoutEffect'\nimport { Editor, Range as SlateRange } from 'slate'\n\n/**\n * Clicking outside of the host blurs our `<Editable />`.\n * `<Editable />` only updates the DOM's selection to match slate when it is focused.\n * In the case of a panel being clicked this hook updates the DOM selection to match slate.\n */\nexport function useSyncDOMSelection(editor: Editor, isEnabled: boolean) {\n useIsomorphicLayoutEffect(() => {\n if (!isEnabled || editor.selection == null || ReactEditor.isFocused(editor)) return\n try {\n const root = ReactEditor.findDocumentOrShadowRoot(editor) as Document\n const domSelection = root.getSelection()\n const newDomRange: Range | null = ReactEditor.toDOMRange(editor, editor.selection)\n\n if (newDomRange) {\n if (SlateRange.isBackward(editor.selection!)) {\n domSelection?.setBaseAndExtent(\n newDomRange.endContainer,\n newDomRange.endOffset,\n newDomRange.startContainer,\n newDomRange.startOffset,\n )\n } else {\n domSelection?.setBaseAndExtent(\n newDomRange.startContainer,\n newDomRange.startOffset,\n newDomRange.endContainer,\n newDomRange.endOffset,\n )\n }\n } else {\n domSelection?.removeAllRanges()\n }\n } catch (e) {\n console.error(e)\n }\n })\n}\n","import {\n FocusEvent,\n forwardRef,\n KeyboardEvent,\n Ref,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react'\n\nimport { createEditor } from 'slate'\nimport { Slate, Editable, withReact, ReactEditor } from 'slate-react'\n\nimport { ElementIDValue, RichTextValue } from '../../../../prop-controllers/descriptors'\nimport { cx } from '@emotion/css'\nimport { DescriptorsPropControllers } from '../../../../prop-controllers/instances'\nimport { Descriptors } from '../../../../runtimes/react/controls/rich-text'\nimport { getBox } from '../../../../box-model'\nimport { PropControllersHandle } from '../../../../state/modules/prop-controller-handles'\nimport { richTextDTOtoDAO } from '../../../../controls'\nimport { Leaf } from '../components/Leaf'\nimport { Element } from '../components/Element'\nimport { useSyncWithBuilder } from './useSyncWithBuilder'\nimport isHotkey from 'is-hotkey'\nimport { useBuilderEditMode } from '../../../../runtimes/react'\nimport { BuilderEditMode } from '../../../../state/modules/builder-edit-mode'\nimport { onKeyDown, withBlock, withList, withTypography, withBuilder } from '../../../../slate'\nimport { pollBoxModel } from '../../../../runtimes/react/poll-box-model'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { RichTextDAO, BlockType } from '../../../../../types/slate'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst defaultText: RichTextDAO = [{ type: BlockType.Paragraph, children: [{ text: '' }] }]\n\nexport const EditableText = forwardRef(function EditableText(\n { id, text, width, margin }: Props,\n ref: Ref<PropControllersHandle<Descriptors>>,\n) {\n const [editor] = useState(() =>\n withBlock(withTypography(withList(withBuilder(withReact(createEditor()))))),\n )\n const [isPreservingDOMSElection, setIsPreservingDOMSelection] = useState(false)\n useSyncDOMSelection(editor, isPreservingDOMSElection)\n const delaySync = useSyncWithBuilder(editor, text)\n const editMode = useBuilderEditMode()\n\n const [propControllers, setPropControllers] =\n useState<DescriptorsPropControllers<Descriptors> | null>(null)\n const controller = propControllers?.text\n\n useEffect(() => {\n if (controller == null) return\n\n const element = ReactEditor.toDOMNode(editor, editor)\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => controller.changeBoxModel(boxModel),\n })\n }, [editor, controller])\n\n useImperativeHandle(\n ref,\n () => ({\n getDomNode() {\n return ReactEditor.toDOMNode(editor, editor)\n },\n getBoxModel() {\n return getBox(ReactEditor.toDOMNode(editor, editor))\n },\n setPropControllers,\n }),\n [editor, setPropControllers],\n )\n\n const initialValue = useMemo(() => (text ? richTextDTOtoDAO(text) : defaultText), [text])\n\n useEffect(() => {\n controller?.setSlateEditor(editor)\n }, [controller, editor])\n\n const handleFocus = useCallback(() => {\n controller?.focus()\n setIsPreservingDOMSelection(true)\n }, [controller])\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (isHotkey('mod+shift+z', e)) return controller?.redo()\n if (isHotkey('mod+z', e)) return controller?.undo()\n if (isHotkey('escape')(e)) return controller?.blur()\n onKeyDown(e, editor)\n },\n [controller, editor],\n )\n\n const handleBlur = useCallback((e: FocusEvent) => {\n // When clicking outside of the iframe (`relatedTarget` is null) we want to preserve the DOM selection.\n if (e.relatedTarget == null) return\n // Otherwise we want to deselect on blur and stop preserving selection.\n setIsPreservingDOMSelection(false)\n ReactEditor.deselect(editor)\n }, [])\n\n return (\n <Slate editor={editor} value={initialValue} onChange={delaySync}>\n <Editable\n id={id}\n renderLeaf={Leaf}\n renderElement={Element}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n className={cx(width, margin)}\n readOnly={editMode !== BuilderEditMode.CONTENT}\n placeholder=\"Write some text...\"\n />\n </Slate>\n )\n})\n\nexport default EditableText\n"],"names":["element","attributes","children","blockStyles","useStyle","margin","useResponsiveStyle","textAlign","type","BlockType","Text","cx","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","padding","fontSize","fontWeight","borderLeft","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","className","restOfProps","Link","textDecoration","InlineType","Code","SuperScript","SubScript","link","props","COMMIT_DEBOUNCE_DELAY","editor","text","shouldCommit","setShouldCommit","useState","isInBuilder","useIsInBuilder","useEffect","nextValue","richTextDTOtoDAO","nextSelection","richTextDTOtoSelection","deepEqual","selection","onChange","timeoutId","window","setTimeout","clearTimeout","useCallback","isEnabled","useIsomorphicLayoutEffect","ReactEditor","isFocused","root","findDocumentOrShadowRoot","domSelection","getSelection","newDomRange","toDOMRange","SlateRange","isBackward","setBaseAndExtent","endContainer","endOffset","startContainer","startOffset","removeAllRanges","e","console","error","defaultText","EditableText","forwardRef","id","width","ref","withBlock","withTypography","withList","withBuilder","withReact","createEditor","isPreservingDOMSElection","setIsPreservingDOMSelection","useSyncDOMSelection","delaySync","useSyncWithBuilder","editMode","useBuilderEditMode","propControllers","setPropControllers","controller","toDOMNode","pollBoxModel","onBoxModelChange","boxModel","changeBoxModel","useImperativeHandle","getDomNode","getBoxModel","getBox","initialValue","useMemo","setSlateEditor","handleFocus","focus","handleKeyDown","isHotkey","redo","undo","blur","onKeyDown","handleBlur","relatedTarget","deselect","Slate","Editable","Leaf","Element","BuilderEditMode","CONTENT"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAU6B,sBAAA;AAAA,EAAEA;AAAAA,EAASC;AAAAA,EAAYC;AAAAA,GAAsC;AAClFC,QAAAA,cAAc,CAClBC,cAAS;AAAA,IAAEC,QAAQ;AAAA,EAAA,CAAX,GACRD,KAAAA,SAASE,KAAmB,mBAAA,CAACN,QAAQO,SAAT,GAAqB,CAAC,CAACA,YAAY,YAAa;AAAA,IAAEA;AAAAA,EAAAA,EAAnD,CAAnB,CAFU;AAKZP,UAAAA,QAAQQ;AAAAA,SACTC,MAAUC,UAAAA;AACb,qFACYT;QAAY,WAAWU,IAAAA,GAAG,GAAGR,WAAJ;AAAA,QAChCD;AAAAA,MAAAA,EAFL;AAAA,SAKGO,MAAUG,UAAAA;AACb,kFACSX;QAAY,WAAWU,IAAAA,GAAG,GAAGR,WAAJ;AAAA,QAC7BD;AAAAA,MAAAA,EAFL;AAAA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ASxC,CAAV;AAAc,aAAOwB,yCAAYkB;AACzCF,QAAAA,kBAAAA,WAAS,QAAD,EAAWxC,CAAnB;AAAuB,aAAOwB,yCAAYmB;AAC9CC,sBAAU5C,GAAGtC,MAAJ;AAAA,EAAA,GAEX,CAAC8D,YAAY9D,MAAb,CAP+B;AAU3BmF,QAAAA,aAAahE,kBAAY,CAACmB,MAAkB;AAEhD,QAAIA,EAAE8C,iBAAiB;AAAM;AAE7B9B,gCAA4B,KAAD;AAC3BhC,2BAAY+D,SAASrF,MAArB;AAAA,EAL4B,GAM3B,CAN2B,CAAA;AAQ9B,wCACGsF,WAAAA,OAAD;AAAA,IAAO;AAAA,IAAgB,OAAOd;AAAAA,IAAc,UAAUhB;AAAAA,IAAtD,yCACG+B,qBAAD;AAAA,MACE;AAAA,MACA,YAAYC,KAAAA;AAAAA,MACZ,eAAeC;AAAAA,MACf,SAASd;AAAAA,MACT,WAAWE;AAAAA,MACX,QAAQM;AAAAA,MACR,WAAWhH,IAAAA,GAAG0E,OAAOhF,MAAR;AAAA,MACb,UAAU6F,aAAagC,YAAAA,gBAAgBC;AAAAA,MACvC,aAAY;AAAA,IAAA,CATd;AAAA,EAAA,CAFJ;AAeD,CArFqC;AAuFtC,IAAA,iBAAejD;;;"}
|
package/dist/index.es.js
CHANGED
|
@@ -36,7 +36,7 @@ var __publicField = (obj, key, value) => {
|
|
|
36
36
|
};
|
|
37
37
|
var _c;
|
|
38
38
|
import * as React from "react";
|
|
39
|
-
import { useEffect, createContext, useContext, useState, useMemo, useRef, Children, createElement, forwardRef, memo, useId, useCallback,
|
|
39
|
+
import { useEffect, createContext, useContext, useState, useMemo, useRef, Children, createElement, forwardRef, memo, useId, useCallback, useImperativeHandle, Component, Suspense } from "react";
|
|
40
40
|
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
|
|
41
41
|
import dynamic from "next/dynamic";
|
|
42
42
|
import { a as createDocumentReference, g as getPropControllerDescriptors, i as isElementReference, M as MakeswiftComponentType, b as isPropControllersHandle, d as getComponentPropControllerDescriptors, e as getPropControllers, f as configureStore$1, h as copyElementTree, j as getBreakpoints, k as getDocument, l as getElementId, m as getIsPreview, n as getIsInBuilder, o as getReactComponent, p as getBuilderEditMode } from "./constants.es.js";
|
|
@@ -45,11 +45,9 @@ import { cache, cx } from "@emotion/css";
|
|
|
45
45
|
import { serializeStyles } from "@emotion/serialize";
|
|
46
46
|
import { registerStyles, insertStyles } from "@emotion/utils";
|
|
47
47
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
48
|
-
import { S as ShapeControlType, L as ListControlType, T as Types, E as ElementID, B as Backgrounds, W as Width, f as ResponsiveIconRadioGroup, M as Margin, P as Padding, g as Border, h as BorderRadius, i as Shadows, G as GapY, j as GapX, k as ResponsiveSelect, l as ResponsiveNumber, m as Checkbox, n as Grid, o as TextInput, p as Link, q as ResponsiveColor, s as TextStyle, t as Images, N as Number$1, D as Date$1, F as Font, u as ResponsiveLength, v as TextArea, w as Table, x as TableFormFields, y as Image, z as ResponsiveOpacity, A as NavigationLinks, H as SocialLinks, J as RichText, V as Video, K as StyleControlProperty, O as ImageControlValueFormat, Q as
|
|
49
|
-
import { createEditor } from "slate";
|
|
48
|
+
import { S as ShapeControlType, L as ListControlType, T as Types, E as ElementID, B as Backgrounds, W as Width, f as ResponsiveIconRadioGroup, M as Margin, P as Padding, g as Border, h as BorderRadius, i as Shadows, G as GapY, j as GapX, k as ResponsiveSelect, l as ResponsiveNumber, m as Checkbox, n as Grid, o as TextInput, p as Link, q as ResponsiveColor, s as TextStyle, t as Images, N as Number$1, D as Date$1, F as Font, u as ResponsiveLength, v as TextArea, w as Table, x as TableFormFields, y as Image, z as ResponsiveOpacity, A as NavigationLinks, H as SocialLinks, J as RichText, V as Video, K as StyleControlProperty, O as ImageControlValueFormat, Q as StyleControlType, U as RichTextV2ControlType, X as RichTextControlType, b as SlotControlType, Y as LinkControlType, I as ImageControlType, C as ColorControlType, Z as BorderPropControllerFormat, _ as ShadowsPropControllerFormat, $ as BorderRadiusPropControllerFormat, a0 as MarginPropControllerFormat, a1 as PaddingPropControllerFormat, a2 as WidthPropControllerFormat } from "./descriptors.es.js";
|
|
50
49
|
import { S as SelectControlType, T as TextAreaControlType, a as TextInputControlType, N as NumberControlType, C as CheckboxControlType } from "./text-input.es.js";
|
|
51
50
|
import { C as ComboboxControlType } from "./combobox.es.js";
|
|
52
|
-
import { withReact, ReactEditor, Slate, Editable } from "slate-react";
|
|
53
51
|
import { useSyncExternalStore } from "use-sync-external-store/shim";
|
|
54
52
|
import { createStore, applyMiddleware } from "redux";
|
|
55
53
|
import thunk from "redux-thunk";
|
|
@@ -59,8 +57,6 @@ import { getBaseBreakpoint, findBreakpointOverride, DefaultBreakpointID, join, g
|
|
|
59
57
|
import { g as getBox, i as isMeasurable, m as measure } from "./box-models.es.js";
|
|
60
58
|
import ColorHelper from "color";
|
|
61
59
|
import scrollIntoView from "scroll-into-view-if-needed";
|
|
62
|
-
import isHotkey from "is-hotkey";
|
|
63
|
-
import { withHistory, HistoryEditor } from "slate-history";
|
|
64
60
|
import { findDOMNode } from "react-dom";
|
|
65
61
|
import parse from "html-react-parser";
|
|
66
62
|
import Head from "next/head";
|
|
@@ -1129,7 +1125,7 @@ async function fonts(_req, res, { getFonts } = {}) {
|
|
|
1129
1125
|
const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
|
|
1130
1126
|
return res.json(fonts2);
|
|
1131
1127
|
}
|
|
1132
|
-
const version = "0.8.
|
|
1128
|
+
const version = "0.8.10";
|
|
1133
1129
|
async function handler(req, res, { apiKey }) {
|
|
1134
1130
|
if (req.query.secret !== apiKey) {
|
|
1135
1131
|
return res.status(401).json({ message: "Unauthorized" });
|
|
@@ -3079,7 +3075,7 @@ function ListControlValue({
|
|
|
3079
3075
|
function useNumber(numberControlData, controlDefinition) {
|
|
3080
3076
|
return numberControlData != null ? numberControlData : controlDefinition.config.defaultValue;
|
|
3081
3077
|
}
|
|
3082
|
-
const Text = forwardNextDynamicRef((patch) => dynamic(() => patch(import("./index.
|
|
3078
|
+
const Text = forwardNextDynamicRef((patch) => dynamic(() => patch(import("./index.es7.js"))));
|
|
3083
3079
|
function useRichText(data, control) {
|
|
3084
3080
|
const textCallbackRef = useCallback((handle) => {
|
|
3085
3081
|
var _a;
|
|
@@ -3093,115 +3089,15 @@ function useRichText(data, control) {
|
|
|
3093
3089
|
ref: textCallbackRef
|
|
3094
3090
|
});
|
|
3095
3091
|
}
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
onBoxModelChange
|
|
3099
|
-
}) {
|
|
3100
|
-
let currentBoxModel = null;
|
|
3101
|
-
const handleAnimationFrameRequest = () => {
|
|
3102
|
-
const measuredBoxModel = getBox(element);
|
|
3103
|
-
if (!deepEqual(currentBoxModel, measuredBoxModel)) {
|
|
3104
|
-
currentBoxModel = measuredBoxModel;
|
|
3105
|
-
onBoxModelChange(currentBoxModel);
|
|
3106
|
-
}
|
|
3107
|
-
animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest);
|
|
3108
|
-
};
|
|
3109
|
-
let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest);
|
|
3110
|
-
return () => {
|
|
3111
|
-
cancelAnimationFrame(animationFrameHandle);
|
|
3112
|
-
onBoxModelChange(null);
|
|
3113
|
-
};
|
|
3114
|
-
}
|
|
3115
|
-
const isSSR = typeof window === "undefined" || /ServerSideRendering/.test(window.navigator && window.navigator.userAgent);
|
|
3116
|
-
const useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect;
|
|
3117
|
-
const defaultText = [{
|
|
3118
|
-
type: BlockType.Text,
|
|
3119
|
-
children: [{
|
|
3120
|
-
text: ""
|
|
3121
|
-
}]
|
|
3122
|
-
}];
|
|
3092
|
+
const EditableText = forwardNextDynamicRef((patch) => dynamic(() => patch(import("./index.es8.js"))));
|
|
3093
|
+
const ReadOnlyText = forwardNextDynamicRef((patch) => dynamic(() => patch(import("./ReadOnlyTextV2.es.js"))));
|
|
3123
3094
|
function useRichTextV2(data, control) {
|
|
3124
|
-
const
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
const element = ReactEditor.toDOMNode(editor, editor);
|
|
3131
|
-
return pollBoxModel({
|
|
3132
|
-
element,
|
|
3133
|
-
onBoxModelChange: (boxModel) => control.changeBoxModel(boxModel)
|
|
3134
|
-
});
|
|
3135
|
-
}, [editor, control]);
|
|
3136
|
-
const renderElement = useCallback(({
|
|
3137
|
-
attributes,
|
|
3138
|
-
children,
|
|
3139
|
-
element
|
|
3140
|
-
}) => {
|
|
3141
|
-
switch (element.type) {
|
|
3142
|
-
default:
|
|
3143
|
-
return /* @__PURE__ */ jsx("p", __spreadProps(__spreadValues({}, attributes), {
|
|
3144
|
-
children
|
|
3145
|
-
}));
|
|
3146
|
-
}
|
|
3147
|
-
}, []);
|
|
3148
|
-
const renderLeaf = useCallback(({
|
|
3149
|
-
attributes,
|
|
3150
|
-
children
|
|
3151
|
-
}) => {
|
|
3152
|
-
return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, attributes), {
|
|
3153
|
-
children
|
|
3154
|
-
}));
|
|
3155
|
-
}, []);
|
|
3156
|
-
const initialValue = useMemo(() => data != null ? data : defaultText, [data]);
|
|
3157
|
-
useEffect(() => {
|
|
3158
|
-
if (editMode !== BuilderEditMode.CONTENT) {
|
|
3159
|
-
isPreservingFocus.current = false;
|
|
3160
|
-
ReactEditor.deselect(editor);
|
|
3161
|
-
}
|
|
3162
|
-
}, [editMode]);
|
|
3163
|
-
useEffect(() => {
|
|
3164
|
-
control == null ? void 0 : control.setEditor(editor);
|
|
3165
|
-
control == null ? void 0 : control.setDefaultValue(defaultText);
|
|
3166
|
-
}, [control, editor, defaultText]);
|
|
3167
|
-
const handleFocus = useCallback(() => {
|
|
3168
|
-
isPreservingFocus.current = true;
|
|
3169
|
-
control == null ? void 0 : control.select();
|
|
3170
|
-
}, [control]);
|
|
3171
|
-
const handleKeyDown = useCallback((e) => {
|
|
3172
|
-
if (isHotkey("mod+shift+z", e))
|
|
3173
|
-
return HistoryEditor.redo(editor);
|
|
3174
|
-
if (isHotkey("mod+z", e))
|
|
3175
|
-
return HistoryEditor.undo(editor);
|
|
3176
|
-
if (isHotkey("escape")(e)) {
|
|
3177
|
-
isPreservingFocus.current = false;
|
|
3178
|
-
ReactEditor.blur(editor);
|
|
3179
|
-
control == null ? void 0 : control.switchToBuildMode();
|
|
3180
|
-
}
|
|
3181
|
-
}, [control, editor]);
|
|
3182
|
-
const handleBlur = useCallback((e) => {
|
|
3183
|
-
var _a;
|
|
3184
|
-
if (e.relatedTarget == null)
|
|
3185
|
-
return;
|
|
3186
|
-
if (((_a = e.relatedTarget) == null ? void 0 : _a.getAttribute("contenteditable")) === "true")
|
|
3187
|
-
isPreservingFocus.current = false;
|
|
3188
|
-
}, []);
|
|
3189
|
-
const handleOnChange = useCallback((value) => {
|
|
3190
|
-
control == null ? void 0 : control.onChange(value);
|
|
3191
|
-
}, [control]);
|
|
3192
|
-
return /* @__PURE__ */ jsx(Slate, {
|
|
3193
|
-
editor,
|
|
3194
|
-
onChange: handleOnChange,
|
|
3195
|
-
value: initialValue,
|
|
3196
|
-
children: /* @__PURE__ */ jsx(Editable, {
|
|
3197
|
-
renderLeaf,
|
|
3198
|
-
renderElement,
|
|
3199
|
-
onFocus: handleFocus,
|
|
3200
|
-
onKeyDown: handleKeyDown,
|
|
3201
|
-
onBlur: handleBlur,
|
|
3202
|
-
readOnly: editMode !== BuilderEditMode.CONTENT,
|
|
3203
|
-
placeholder: "Write some text..."
|
|
3204
|
-
})
|
|
3095
|
+
const isPreview = useIsPreview();
|
|
3096
|
+
return isPreview ? /* @__PURE__ */ jsx(EditableText, {
|
|
3097
|
+
text: data,
|
|
3098
|
+
control
|
|
3099
|
+
}) : /* @__PURE__ */ jsx(ReadOnlyText, {
|
|
3100
|
+
text: data
|
|
3205
3101
|
});
|
|
3206
3102
|
}
|
|
3207
3103
|
function useSelectControlValue(data, definition) {
|
|
@@ -3222,6 +3118,25 @@ function ShapeControlValue({
|
|
|
3222
3118
|
}))
|
|
3223
3119
|
}), children)({});
|
|
3224
3120
|
}
|
|
3121
|
+
function pollBoxModel({
|
|
3122
|
+
element,
|
|
3123
|
+
onBoxModelChange
|
|
3124
|
+
}) {
|
|
3125
|
+
let currentBoxModel = null;
|
|
3126
|
+
const handleAnimationFrameRequest = () => {
|
|
3127
|
+
const measuredBoxModel = getBox(element);
|
|
3128
|
+
if (!deepEqual(currentBoxModel, measuredBoxModel)) {
|
|
3129
|
+
currentBoxModel = measuredBoxModel;
|
|
3130
|
+
onBoxModelChange(currentBoxModel);
|
|
3131
|
+
}
|
|
3132
|
+
animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest);
|
|
3133
|
+
};
|
|
3134
|
+
let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest);
|
|
3135
|
+
return () => {
|
|
3136
|
+
cancelAnimationFrame(animationFrameHandle);
|
|
3137
|
+
onBoxModelChange(null);
|
|
3138
|
+
};
|
|
3139
|
+
}
|
|
3225
3140
|
function useSlot(data, control) {
|
|
3226
3141
|
if (data == null || data.elements.length === 0) {
|
|
3227
3142
|
return /* @__PURE__ */ jsx(Slot.Placeholder, {
|
|
@@ -4011,5 +3926,5 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
|
|
|
4011
3926
|
document: document2
|
|
4012
3927
|
});
|
|
4013
3928
|
}));
|
|
4014
|
-
export {
|
|
3929
|
+
export { Document$1 as $, Alignments as A, useFile as B, Contrasts as C, DocumentReference as D, Element$1 as E, forwardNextDynamicRef as F, useIsPreview as G, useFiles as H, useSwatches as I, usePagePathnameSlice as J, useElementId as K, deepEqual as L, ElementImperativeHandle as M, StoreContext as N, MakeswiftProvider as O, PageProvider as P, useBuilderEditMode as Q, RuntimeProvider as R, Shapes as S, pollBoxModel as T, useTypography as U, getStaticPaths as V, getStaticProps as W, getServerSideProps as X, Page as Y, Makeswift as Z, PreviewModeScript as _, ReactRuntime as a, MakeswiftApiHandler as a0, usePageId as b, DEFAULT_BOX_ANIMATE_TYPE as c, DEFAULT_BOX_ANIMATE_DELAY as d, DEFAULT_BOX_ANIMATE_DURATION as e, DEFAULT_ITEM_ANIMATE_TYPE as f, DEFAULT_ITEM_ANIMATE_DELAY as g, DEFAULT_ITEM_ANIMATE_DURATION as h, DEFAULT_ITEM_STAGGER_DURATION as i, useBorder as j, useBoxShadow as k, useResponsiveColor as l, Page$1 as m, useStyle as n, useResponsiveStyle as o, useResponsiveWidth as p, useResponsiveTextStyle as q, colorToString as r, useBreakpoints as s, Sizes as t, useIsInBuilder as u, useFormContext as v, useResponsiveGridItem as w, useTable as x, useMakeswiftClient as y, Provider as z };
|
|
4015
3930
|
//# sourceMappingURL=index.es.js.map
|