@makeswift/runtime 0.9.11 → 0.9.12
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 +1 -1
- package/dist/Box.es.js +1 -1
- package/dist/Button.cjs.js +1 -1
- package/dist/Button.es.js +1 -1
- package/dist/Carousel.cjs.js +1 -1
- package/dist/Carousel.es.js +1 -1
- package/dist/Countdown.cjs.js +1 -1
- package/dist/Countdown.es.js +1 -1
- package/dist/Divider.cjs.js +1 -1
- package/dist/Divider.es.js +1 -1
- package/dist/Form.cjs.js +1 -1
- package/dist/Form.es.js +1 -1
- package/dist/Image.cjs.js +1 -1
- package/dist/Image.es.js +1 -1
- package/dist/LiveProvider.cjs.js +1 -1
- package/dist/LiveProvider.es.js +3 -3
- package/dist/Navigation.cjs.js +1 -1
- package/dist/Navigation.es.js +1 -1
- package/dist/PreviewProvider.cjs.js +1 -1
- package/dist/PreviewProvider.es.js +3 -3
- package/dist/ReadOnlyText.cjs.js +18 -3
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +20 -5
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +116 -240
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +115 -238
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/Root.cjs.js +1 -1
- package/dist/Root.es.js +1 -1
- package/dist/SocialLinks.cjs.js +1 -1
- package/dist/SocialLinks.es.js +1 -1
- package/dist/Text.cjs.js +1 -1
- package/dist/Text.es.js +1 -1
- package/dist/components.cjs.js +1 -1
- package/dist/components.es.js +1 -1
- package/dist/control-serialization.es.js +1 -1
- package/dist/controls.cjs.js +28 -18
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +2 -2
- package/dist/index.cjs.js +39 -38
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs10.js +2 -2
- package/dist/index.cjs2.js +3 -3
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs5.js +5 -6
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +20 -0
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.cjs8.js +1 -1
- package/dist/index.cjs9.js +27 -31
- package/dist/index.cjs9.js.map +1 -1
- package/dist/index.es.js +14 -14
- package/dist/index.es.js.map +1 -1
- package/dist/index.es10.js +4 -4
- package/dist/index.es2.js +2 -2
- package/dist/index.es3.js +1 -1
- package/dist/index.es5.js +1 -2
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +21 -2
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es8.js +1 -1
- package/dist/index.es9.js +31 -35
- package/dist/index.es9.js.map +1 -1
- package/dist/next.cjs.js +1 -1
- package/dist/next.es.js +2 -2
- package/dist/react-page.cjs.js +310 -147
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +297 -146
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs.js +1 -1
- package/dist/react.es.js +1 -1
- package/dist/slate.cjs.js +40 -27
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +49 -37
- package/dist/slate.es.js.map +1 -1
- package/dist/{typography.cjs.js → text-input.cjs.js} +1 -9
- package/dist/text-input.cjs.js.map +1 -0
- package/dist/{typography.es.js → text-input.es.js} +2 -8
- package/dist/text-input.es.js.map +1 -0
- package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
- package/dist/types/src/controls/list.d.ts +5 -2
- package/dist/types/src/controls/list.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/introspection.d.ts +5 -0
- package/dist/types/src/controls/rich-text/introspection.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text/introspection.test.d.ts +2 -0
- package/dist/types/src/controls/rich-text/introspection.test.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text-v2/introspection.d.ts +5 -0
- package/dist/types/src/controls/rich-text-v2/introspection.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text-v2/introspection.test.d.ts +2 -0
- package/dist/types/src/controls/rich-text-v2/introspection.test.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +15 -3
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/translation.d.ts +1 -1
- package/dist/types/src/controls/rich-text-v2/translation.d.ts.map +1 -1
- package/dist/types/src/controls/shape.d.ts +5 -2
- package/dist/types/src/controls/shape.d.ts.map +1 -1
- package/dist/types/src/controls/typography.d.ts +2 -0
- package/dist/types/src/controls/typography.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/descriptors.d.ts +10 -0
- package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/introspection.d.ts +0 -2
- package/dist/types/src/prop-controllers/introspection.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.d.ts +4 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts +7 -16
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
- package/dist/types/src/slate/LinkPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/LocalChangesPlugin/index.d.ts +16 -0
- package/dist/types/src/slate/LocalChangesPlugin/index.d.ts.map +1 -0
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/index.d.ts +1 -0
- package/dist/types/src/slate/index.d.ts.map +1 -1
- package/dist/types/src/slate/types.d.ts +2 -2
- package/dist/types/src/slate/types.d.ts.map +1 -1
- package/dist/types.cjs2.js +67 -48
- package/dist/types.cjs2.js.map +1 -1
- package/dist/types.es2.js +64 -45
- package/dist/types.es2.js.map +1 -1
- package/package.json +1 -2
- package/dist/typography.cjs.js.map +0 -1
- package/dist/typography.es.js.map +0 -1
package/dist/index.cjs9.js
CHANGED
|
@@ -34,7 +34,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
34
34
|
var React = require("react");
|
|
35
35
|
var slate = require("slate");
|
|
36
36
|
var isHotkey = require("is-hotkey");
|
|
37
|
-
var slateHistory = require("slate-history");
|
|
38
37
|
var slateReact = require("slate-react");
|
|
39
38
|
var reactPage = require("./react-page.cjs.js");
|
|
40
39
|
var next = require("./index.cjs.js");
|
|
@@ -44,7 +43,7 @@ var index = require("./index.cjs6.js");
|
|
|
44
43
|
var index$1 = require("./index.cjs7.js");
|
|
45
44
|
var jsxRuntime = require("react/jsx-runtime");
|
|
46
45
|
require("./index.cjs3.js");
|
|
47
|
-
|
|
46
|
+
require("@emotion/css");
|
|
48
47
|
var useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect.cjs.js");
|
|
49
48
|
require("./actions.cjs.js");
|
|
50
49
|
require("redux");
|
|
@@ -53,7 +52,7 @@ require("@emotion/serialize");
|
|
|
53
52
|
require("@emotion/utils");
|
|
54
53
|
require("use-sync-external-store/shim/with-selector");
|
|
55
54
|
require("next/dynamic");
|
|
56
|
-
require("./
|
|
55
|
+
require("./text-input.cjs.js");
|
|
57
56
|
require("./combobox.cjs.js");
|
|
58
57
|
require("use-sync-external-store/shim");
|
|
59
58
|
require("./types.cjs.js");
|
|
@@ -110,24 +109,8 @@ function RichTextV2Element(_a) {
|
|
|
110
109
|
"definition",
|
|
111
110
|
"plugins"
|
|
112
111
|
]);
|
|
113
|
-
const blockStyles = [reactPage.useStyle({
|
|
114
|
-
margin: 0
|
|
115
|
-
})];
|
|
116
112
|
function initialRenderElement(props2) {
|
|
117
|
-
|
|
118
|
-
case reactPage.BlockType.Default:
|
|
119
|
-
default:
|
|
120
|
-
if (definition.config.mode === reactPage.RichTextV2Mode.Inline) {
|
|
121
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps(__spreadValues({}, props2.attributes), {
|
|
122
|
-
className: css.cx(...blockStyles),
|
|
123
|
-
children: props2.children
|
|
124
|
-
}));
|
|
125
|
-
}
|
|
126
|
-
return /* @__PURE__ */ jsxRuntime.jsx("p", __spreadProps(__spreadValues({}, props2.attributes), {
|
|
127
|
-
className: css.cx(...blockStyles),
|
|
128
|
-
children: props2.children
|
|
129
|
-
}));
|
|
130
|
-
}
|
|
113
|
+
return props2.children;
|
|
131
114
|
}
|
|
132
115
|
const renderElement = plugins.reduce((renderFn, plugin) => (props2) => {
|
|
133
116
|
const {
|
|
@@ -182,6 +165,21 @@ function RichTextV2Leaf(_c) {
|
|
|
182
165
|
}, initialRenderLeaf);
|
|
183
166
|
return renderLeaf(props);
|
|
184
167
|
}
|
|
168
|
+
function isChangeWithinPreviousSec(change) {
|
|
169
|
+
var _a;
|
|
170
|
+
return performance.now() - ((_a = change == null ? void 0 : change.time) != null ? _a : 0) < 1e3;
|
|
171
|
+
}
|
|
172
|
+
function useSyncRemoteChanges(editor, data) {
|
|
173
|
+
const isInBuilder = next.useIsInBuilder();
|
|
174
|
+
React.useEffect(() => {
|
|
175
|
+
var _a, _b, _c;
|
|
176
|
+
if (!isChangeWithinPreviousSec(editor.localChanges.get((_a = data == null ? void 0 : data.key) != null ? _a : "")) && data && isInBuilder) {
|
|
177
|
+
editor.children = reactPage.richTextV2DataToDescendents(data);
|
|
178
|
+
editor.selection = (_c = (_b = editor == null ? void 0 : editor.localChanges.get(data.key)) == null ? void 0 : _b.selection) != null ? _c : null;
|
|
179
|
+
editor.onChange();
|
|
180
|
+
}
|
|
181
|
+
}, [editor, data]);
|
|
182
|
+
}
|
|
185
183
|
const defaultText = [{
|
|
186
184
|
type: reactPage.BlockType.Default,
|
|
187
185
|
children: [{
|
|
@@ -201,10 +199,11 @@ function EditableTextV2({
|
|
|
201
199
|
const [editor] = React.useState(() => plugins.reduceRight((editor2, plugin) => {
|
|
202
200
|
var _a, _b;
|
|
203
201
|
return (_b = (_a = plugin == null ? void 0 : plugin.withPlugin) == null ? void 0 : _a.call(plugin, editor2)) != null ? _b : editor2;
|
|
204
|
-
}, index$1.withBuilder(
|
|
202
|
+
}, index.withLocalChanges(index$1.withBuilder(slateReact.withReact(slate.createEditor())))));
|
|
205
203
|
const isPreservingFocus = React.useRef(false);
|
|
206
204
|
useSyncDOMSelection(editor, isPreservingFocus);
|
|
207
205
|
const editMode = next.useBuilderEditMode();
|
|
206
|
+
useSyncRemoteChanges(editor, text);
|
|
208
207
|
React.useEffect(() => {
|
|
209
208
|
if (control == null)
|
|
210
209
|
return;
|
|
@@ -245,23 +244,24 @@ function EditableTextV2({
|
|
|
245
244
|
control == null ? void 0 : control.select();
|
|
246
245
|
}, [control]);
|
|
247
246
|
const handleKeyDown = React.useCallback((e) => {
|
|
248
|
-
if (isHotkey__default["default"]("mod+shift+z", e))
|
|
249
|
-
return slateHistory.HistoryEditor.redo(editor);
|
|
250
|
-
if (isHotkey__default["default"]("mod+z", e))
|
|
251
|
-
return slateHistory.HistoryEditor.undo(editor);
|
|
252
247
|
if (isHotkey__default["default"]("escape")(e)) {
|
|
253
248
|
isPreservingFocus.current = false;
|
|
254
249
|
slateReact.ReactEditor.blur(editor);
|
|
255
250
|
control == null ? void 0 : control.switchToBuildMode();
|
|
256
251
|
}
|
|
252
|
+
if (editMode === reactPage.BuilderEditMode.CONTENT) {
|
|
253
|
+
e.stopPropagation();
|
|
254
|
+
}
|
|
257
255
|
plugins.forEach((plugin) => {
|
|
258
256
|
var _a;
|
|
259
257
|
return (_a = plugin == null ? void 0 : plugin.onKeyDown) == null ? void 0 : _a.call(plugin, e, editor);
|
|
260
258
|
});
|
|
261
|
-
}, [control, plugins, editor]);
|
|
259
|
+
}, [control, plugins, editor, editMode]);
|
|
262
260
|
const handleKeyUp = React.useCallback((e) => {
|
|
263
|
-
if (editMode === reactPage.BuilderEditMode.CONTENT)
|
|
261
|
+
if (editMode === reactPage.BuilderEditMode.CONTENT) {
|
|
262
|
+
e.stopPropagation();
|
|
264
263
|
e.preventDefault();
|
|
264
|
+
}
|
|
265
265
|
}, [control, editor, editMode]);
|
|
266
266
|
const handleClick = React.useCallback((e) => {
|
|
267
267
|
if (editMode === reactPage.BuilderEditMode.CONTENT)
|
|
@@ -274,12 +274,8 @@ function EditableTextV2({
|
|
|
274
274
|
if (((_a = e.relatedTarget) == null ? void 0 : _a.getAttribute("contenteditable")) === "true")
|
|
275
275
|
isPreservingFocus.current = false;
|
|
276
276
|
}, []);
|
|
277
|
-
const handleOnChange = React.useCallback((value) => {
|
|
278
|
-
control == null ? void 0 : control.onChange(value);
|
|
279
|
-
}, [control]);
|
|
280
277
|
return /* @__PURE__ */ jsxRuntime.jsx(slateReact.Slate, {
|
|
281
278
|
editor,
|
|
282
|
-
onChange: handleOnChange,
|
|
283
279
|
value: initialValue,
|
|
284
280
|
children: /* @__PURE__ */ jsxRuntime.jsx(slateReact.Editable, {
|
|
285
281
|
renderLeaf,
|
package/dist/index.cjs9.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs9.js","sources":["../src/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.tsx"],"sourcesContent":["import { Editor, Range as SlateRange } from 'slate'\nimport { useIsomorphicLayoutEffect } from '../../../../../components/hooks/useIsomorphicLayoutEffect'\nimport { MutableRefObject } from 'react'\nimport { ReactEditor } from 'slate-react'\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: MutableRefObject<boolean>) {\n useIsomorphicLayoutEffect(() => {\n if (!isEnabled.current || 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 { cx } from '@emotion/css'\nimport { RenderElementProps } from 'slate-react'\nimport {\n RichTextV2ControlDefinition,\n RichTextV2Plugin,\n RichTextV2Mode,\n} from '../../../../../controls'\nimport { BlockType } from '../../../../../slate'\nimport { useStyle } from '../../../use-style'\nimport { ControlValue } from '../../control'\n\ntype RichTextV2ElementProps = RenderElementProps & {\n definition: RichTextV2ControlDefinition\n plugins: RichTextV2Plugin[]\n}\n\nexport function RichTextV2Element({ definition, plugins, ...props }: RichTextV2ElementProps) {\n const blockStyles = [useStyle({ margin: 0 })]\n\n function initialRenderElement(props: RenderElementProps) {\n switch (props.element.type) {\n case BlockType.Default:\n default:\n if (definition.config.mode === RichTextV2Mode.Inline) {\n return (\n <span {...props.attributes} className={cx(...blockStyles)}>\n {props.children}\n </span>\n )\n }\n\n return (\n <p {...props.attributes} className={cx(...blockStyles)}>\n {props.children}\n </p>\n )\n }\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement(props)\n}\n","import { RenderLeafProps } from 'slate-react'\nimport { RichTextV2ControlDefinition, RichTextV2Plugin } from '../../../../../controls'\nimport { ControlValue } from '../../control'\n\ntype RichTextV2LeafProps = RenderLeafProps & {\n definition: RichTextV2ControlDefinition\n plugins: RichTextV2Plugin[]\n}\n\nexport function RichTextV2Leaf({ definition, plugins, ...props }: RichTextV2LeafProps) {\n function initialRenderLeaf({ attributes, children, leaf }: RenderLeafProps) {\n return (\n <span className={leaf.className} {...attributes}>\n {children}\n </span>\n )\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf(props)\n}\n","import {\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport { Descendant, createEditor } from 'slate'\nimport isHotkey from 'is-hotkey'\nimport { withHistory, HistoryEditor } from 'slate-history'\nimport {\n withReact,\n ReactEditor,\n RenderElementProps,\n RenderLeafProps,\n Slate,\n Editable,\n} from 'slate-react'\n\nimport {\n RichTextV2Control,\n RichTextV2ControlData,\n RichTextV2ControlDefinition,\n RichTextV2Mode,\n} from '../../../../../controls'\nimport { useBuilderEditMode } from '../../..'\nimport { BuilderEditMode } from '../../../../../state/modules/builder-edit-mode'\nimport { pollBoxModel } from '../../../poll-box-model'\nimport { InlineModePlugin, withBuilder } from '../../../../../slate'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { BlockType } from '../../../../../slate'\nimport { RichTextV2Element } from './render-element'\nimport { RichTextV2Leaf } from './render-leaf'\nimport { richTextV2DataToDescendents } from '../../../../../controls/rich-text-v2/translation'\n\nexport type RichTextV2ControlValue = ReactNode\n\nexport type Descriptors = { text?: RichTextV2ControlDefinition }\n\nconst defaultText: Descendant[] = [{ type: BlockType.Default, children: [{ text: '' }] }]\n\ntype Props = {\n text?: RichTextV2ControlData\n definition: RichTextV2ControlDefinition\n control: RichTextV2Control | null\n}\n\nexport function EditableTextV2({ text, definition, control }: Props) {\n const plugins = useMemo(() => {\n const plugins = [\n ...(definition?.config?.plugins ?? []),\n ...(definition?.config?.mode === RichTextV2Mode.Inline ? [InlineModePlugin] : []),\n ]\n return plugins\n }, [definition])\n\n const [editor] = useState(() =>\n plugins.reduceRight(\n (editor, plugin) => plugin?.withPlugin?.(editor) ?? editor,\n withBuilder(withHistory(withReact(createEditor()))),\n ),\n )\n\n const isPreservingFocus = useRef(false)\n useSyncDOMSelection(editor, isPreservingFocus)\n\n const editMode = useBuilderEditMode()\n\n useEffect(() => {\n if (control == null) return\n\n const element = ReactEditor.toDOMNode(editor, editor)\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeBoxModel(boxModel),\n })\n }, [editor, control])\n\n const renderElement = useCallback(\n (props: RenderElementProps) => {\n return <RichTextV2Element {...props} definition={definition} plugins={plugins} />\n },\n [plugins, definition],\n )\n\n const renderLeaf = useCallback(\n (props: RenderLeafProps) => {\n return <RichTextV2Leaf {...props} definition={definition} plugins={plugins} />\n },\n [plugins, definition],\n )\n\n const initialValue = useMemo(\n () => (text && richTextV2DataToDescendents(text)) ?? defaultText,\n [text],\n )\n\n useEffect(() => {\n /**\n * This is required because clicking on the overlay has `relatedTarget` null just like the sidebar, but\n * - in the case of the overlay we switch to BUILD mode\n * - in the case of the sidebar we preserve the selection\n */\n if (editMode !== BuilderEditMode.CONTENT) {\n isPreservingFocus.current = false\n ReactEditor.deselect(editor)\n }\n }, [editMode])\n\n useEffect(() => {\n control?.setEditor(editor)\n control?.setDefaultValue(defaultText)\n }, [control, editor, defaultText])\n\n const handleFocus = useCallback(() => {\n isPreservingFocus.current = true\n control?.select()\n }, [control])\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (isHotkey('mod+shift+z', e)) return HistoryEditor.redo(editor)\n if (isHotkey('mod+z', e)) return HistoryEditor.undo(editor)\n if (isHotkey('escape')(e)) {\n isPreservingFocus.current = false\n ReactEditor.blur(editor)\n control?.switchToBuildMode()\n }\n\n plugins.forEach(plugin => plugin?.onKeyDown?.(e, editor))\n },\n [control, plugins, editor],\n )\n\n const handleKeyUp = useCallback(\n (e: KeyboardEvent) => {\n if (editMode === BuilderEditMode.CONTENT) e.preventDefault()\n },\n [control, editor, editMode],\n )\n\n const handleClick = useCallback(\n (e: MouseEvent) => {\n if (editMode === BuilderEditMode.CONTENT) e.stopPropagation()\n },\n [editMode],\n )\n\n const handleBlur = useCallback((e: FocusEvent) => {\n // outside of iframe (overlay, sidebar, etc)\n if (e.relatedTarget == null) return\n // another text\n if (e.relatedTarget?.getAttribute('contenteditable') === 'true')\n isPreservingFocus.current = false\n }, [])\n\n const handleOnChange = useCallback(\n (value: Descendant[]) => {\n control?.onChange(value)\n },\n [control],\n )\n\n return (\n <Slate editor={editor} onChange={handleOnChange} value={initialValue}>\n <Editable\n renderLeaf={renderLeaf}\n renderElement={renderElement}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n onClick={handleClick}\n onBlur={handleBlur}\n readOnly={editMode !== BuilderEditMode.CONTENT}\n placeholder=\"Write some text...\"\n />\n </Slate>\n )\n}\n\nexport default EditableTextV2\n"],"names":["editor","isEnabled","useIsomorphicLayoutEffect","current","selection","ReactEditor","isFocused","root","findDocumentOrShadowRoot","domSelection","getSelection","newDomRange","toDOMRange","SlateRange","isBackward","setBaseAndExtent","endContainer","endOffset","startContainer","startOffset","removeAllRanges","e","console","error","definition","plugins","props","blockStyles","useStyle","margin","element","type","BlockType","Default","config","mode","RichTextV2Mode","Inline","attributes","cx","children","renderElement","reduce","renderFn","plugin","control","getElementValue","undefined","ControlValue","value","initialRenderElement","leaf","className","renderLeaf","getLeafValue","initialRenderLeaf","defaultText","text","useMemo","InlineModePlugin","useState","reduceRight","withPlugin","withBuilder","withHistory","withReact","createEditor","isPreservingFocus","useRef","useSyncDOMSelection","editMode","useBuilderEditMode","useEffect","toDOMNode","pollBoxModel","onBoxModelChange","boxModel","changeBoxModel","useCallback","initialValue","richTextV2DataToDescendents","BuilderEditMode","CONTENT","deselect","setEditor","setDefaultValue","handleFocus","select","handleKeyDown","isHotkey","HistoryEditor","redo","undo","blur","switchToBuildMode","forEach","onKeyDown","handleKeyUp","preventDefault","handleClick","stopPropagation","handleBlur","relatedTarget","getAttribute","handleOnChange","onChange","Slate","Editable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,6BAA6BA,QAAgBC,WAAsC;AACxFC,4BAAAA,0BAA0B,MAAM;AAC1B,QAAA,CAACD,UAAUE,WAAWH,OAAOI,aAAa,QAAQC,WAAAA,YAAYC,UAAUN,MAAtB;AAA+B;AACjF,QAAA;AACIO,YAAAA,OAAOF,WAAAA,YAAYG,yBAAyBR,MAArC;AACPS,YAAAA,eAAeF,KAAKG;AAC1B,YAAMC,cAA4BN,WAAAA,YAAYO,WAAWZ,QAAQA,OAAOI,SAAtC;AAElC,UAAIO,aAAa;AACXE,YAAAA,YAAWC,WAAWd,OAAOI,SAA7B,GAA0C;AAC9BW,uDAAAA,iBACZJ,YAAYK,cACZL,YAAYM,WACZN,YAAYO,gBACZP,YAAYQ;AAAAA,Q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AAA,EAE5C,GAAA,CAACrD,SAAS7C,QAAQsE,QAAlB,CAJ6B;AAOzB6B,QAAAA,cAAcrB,kBAClB,CAACzD,MAAkB;AACbiD,QAAAA,aAAaW,UAAAA,gBAAgBC;AAAS7D,QAAE+E,gBAAF;AAAA,EAAA,GAE5C,CAAC9B,QAAD,CAJ6B;AAOzB+B,QAAAA,aAAavB,kBAAY,CAACzD,MAAkB;;AAEhD,QAAIA,EAAEiF,iBAAiB;AAAM;AAE7B,QAAIjF,SAAEiF,kBAAFjF,mBAAiBkF,aAAa,wBAAuB;AACvDpC,wBAAkBhE,UAAU;AAAA,EALF,GAM3B,CAN2B,CAAA;AAQxBqG,QAAAA,iBAAiB1B,kBACrB,CAAC7B,UAAwB;AACvBJ,uCAAS4D,SAASxD;AAAAA,EAAlB,GAEF,CAACJ,OAAD,CAJgC;AAOlC,wCACG6D,WAAAA,OAAD;AAAA,IAAO;AAAA,IAAgB,UAAUF;AAAAA,IAAgB,OAAOzB;AAAAA,IAAxD,yCACG4B,qBAAD;AAAA,MACE;AAAA,MACA;AAAA,MACA,SAASrB;AAAAA,MACT,WAAWE;AAAAA,MACX,SAASS;AAAAA,MACT,SAASE;AAAAA,MACT,QAAQE;AAAAA,MACR,UAAU/B,aAAaW,UAAAA,gBAAgBC;AAAAA,MACvC,aAAY;AAAA,IAAA,CATd;AAAA,EAAA,CAFJ;AAeD;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs9.js","sources":["../src/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.tsx"],"sourcesContent":["import { Editor, Range as SlateRange } from 'slate'\nimport { useIsomorphicLayoutEffect } from '../../../../../components/hooks/useIsomorphicLayoutEffect'\nimport { MutableRefObject } from 'react'\nimport { ReactEditor } from 'slate-react'\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: MutableRefObject<boolean>) {\n useIsomorphicLayoutEffect(() => {\n if (!isEnabled.current || 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 { RenderElementProps } from 'slate-react'\nimport { RichTextV2ControlDefinition, RichTextV2Plugin } from '../../../../../controls'\nimport { ControlValue } from '../../control'\n\ntype RichTextV2ElementProps = RenderElementProps & {\n definition: RichTextV2ControlDefinition\n plugins: RichTextV2Plugin[]\n}\n\nexport function RichTextV2Element({ definition, plugins, ...props }: RichTextV2ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return props.children\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement(props)\n}\n","import { RenderLeafProps } from 'slate-react'\nimport { RichTextV2ControlDefinition, RichTextV2Plugin } from '../../../../../controls'\nimport { ControlValue } from '../../control'\n\ntype RichTextV2LeafProps = RenderLeafProps & {\n definition: RichTextV2ControlDefinition\n plugins: RichTextV2Plugin[]\n}\n\nexport function RichTextV2Leaf({ definition, plugins, ...props }: RichTextV2LeafProps) {\n function initialRenderLeaf({ attributes, children, leaf }: RenderLeafProps) {\n return (\n <span className={leaf.className} {...attributes}>\n {children}\n </span>\n )\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf(props)\n}\n","import { useEffect } from 'react'\nimport { Editor } from 'slate'\nimport { useIsInBuilder } from '../../../../../react'\nimport { RichTextV2ControlData, richTextV2DataToDescendents } from '../../../../../controls'\nimport { LocalChange } from '../../../../../slate'\n\n// From the component point of view we can't know if the change came from an action or a undo/redo\n// So we diff the time and force updates on actions that occured over a second ago.\nfunction isChangeWithinPreviousSec(change?: LocalChange) {\n return performance.now() - (change?.time ?? 0) < 1000\n}\n\nexport function useSyncRemoteChanges(editor: Editor, data?: RichTextV2ControlData) {\n const isInBuilder = useIsInBuilder()\n\n useEffect(() => {\n if (\n !isChangeWithinPreviousSec(editor.localChanges.get(data?.key ?? '')) &&\n data &&\n isInBuilder\n ) {\n editor.children = richTextV2DataToDescendents(data)\n editor.selection = editor?.localChanges.get(data.key)?.selection ?? null\n editor.onChange()\n }\n }, [editor, data])\n}\n","import {\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport { Descendant, createEditor } from 'slate'\nimport isHotkey from 'is-hotkey'\nimport {\n withReact,\n ReactEditor,\n RenderElementProps,\n RenderLeafProps,\n Slate,\n Editable,\n} from 'slate-react'\n\nimport {\n RichTextV2Control,\n RichTextV2ControlData,\n RichTextV2ControlDefinition,\n RichTextV2Mode,\n} from '../../../../../controls'\nimport { useBuilderEditMode } from '../../..'\nimport { BuilderEditMode } from '../../../../../state/modules/builder-edit-mode'\nimport { pollBoxModel } from '../../../poll-box-model'\nimport { InlineModePlugin, withBuilder, withLocalChanges } from '../../../../../slate'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { BlockType } from '../../../../../slate'\nimport { RichTextV2Element } from './render-element'\nimport { RichTextV2Leaf } from './render-leaf'\nimport { richTextV2DataToDescendents } from '../../../../../controls/rich-text-v2/translation'\nimport { useSyncRemoteChanges } from './useRemoteChanges'\n\nexport type RichTextV2ControlValue = ReactNode\n\nexport type Descriptors = { text?: RichTextV2ControlDefinition }\n\nconst defaultText: Descendant[] = [{ type: BlockType.Default, children: [{ text: '' }] }]\n\ntype Props = {\n text?: RichTextV2ControlData\n definition: RichTextV2ControlDefinition\n control: RichTextV2Control | null\n}\n\nexport function EditableTextV2({ text, definition, control }: Props) {\n const plugins = useMemo(() => {\n const plugins = [\n ...(definition?.config?.plugins ?? []),\n ...(definition?.config?.mode === RichTextV2Mode.Inline ? [InlineModePlugin] : []),\n ]\n return plugins\n }, [definition])\n\n const [editor] = useState(() =>\n plugins.reduceRight(\n (editor, plugin) => plugin?.withPlugin?.(editor) ?? editor,\n withLocalChanges(withBuilder(withReact(createEditor()))),\n ),\n )\n\n const isPreservingFocus = useRef(false)\n useSyncDOMSelection(editor, isPreservingFocus)\n\n const editMode = useBuilderEditMode()\n\n useSyncRemoteChanges(editor, text)\n\n useEffect(() => {\n if (control == null) return\n\n const element = ReactEditor.toDOMNode(editor, editor)\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeBoxModel(boxModel),\n })\n }, [editor, control])\n\n const renderElement = useCallback(\n (props: RenderElementProps) => {\n return <RichTextV2Element {...props} definition={definition} plugins={plugins} />\n },\n [plugins, definition],\n )\n\n const renderLeaf = useCallback(\n (props: RenderLeafProps) => {\n return <RichTextV2Leaf {...props} definition={definition} plugins={plugins} />\n },\n [plugins, definition],\n )\n\n const initialValue = useMemo(\n () => (text && richTextV2DataToDescendents(text)) ?? defaultText,\n [text],\n )\n\n useEffect(() => {\n /**\n * This is required because clicking on the overlay has `relatedTarget` null just like the sidebar, but\n * - in the case of the overlay we switch to BUILD mode\n * - in the case of the sidebar we preserve the selection\n */\n if (editMode !== BuilderEditMode.CONTENT) {\n isPreservingFocus.current = false\n ReactEditor.deselect(editor)\n }\n }, [editMode])\n\n useEffect(() => {\n control?.setEditor(editor)\n control?.setDefaultValue(defaultText)\n }, [control, editor, defaultText])\n\n const handleFocus = useCallback(() => {\n isPreservingFocus.current = true\n control?.select()\n }, [control])\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (isHotkey('escape')(e)) {\n isPreservingFocus.current = false\n ReactEditor.blur(editor)\n control?.switchToBuildMode()\n }\n\n if (editMode === BuilderEditMode.CONTENT) {\n e.stopPropagation()\n }\n\n plugins.forEach(plugin => plugin?.onKeyDown?.(e, editor))\n },\n [control, plugins, editor, editMode],\n )\n\n const handleKeyUp = useCallback(\n (e: KeyboardEvent) => {\n if (editMode === BuilderEditMode.CONTENT) {\n e.stopPropagation()\n e.preventDefault()\n }\n },\n [control, editor, editMode],\n )\n\n const handleClick = useCallback(\n (e: MouseEvent) => {\n if (editMode === BuilderEditMode.CONTENT) e.stopPropagation()\n },\n [editMode],\n )\n\n const handleBlur = useCallback((e: FocusEvent) => {\n // outside of iframe (overlay, sidebar, etc)\n if (e.relatedTarget == null) return\n // another text\n if (e.relatedTarget?.getAttribute('contenteditable') === 'true')\n isPreservingFocus.current = false\n }, [])\n\n return (\n <Slate editor={editor} value={initialValue}>\n <Editable\n renderLeaf={renderLeaf}\n renderElement={renderElement}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n onClick={handleClick}\n onBlur={handleBlur}\n readOnly={editMode !== BuilderEditMode.CONTENT}\n placeholder=\"Write some text...\"\n />\n </Slate>\n )\n}\n\nexport default EditableTextV2\n"],"names":["editor","isEnabled","useIsomorphicLayoutEffect","current","selection","ReactEditor","isFocused","root","findDocumentOrShadowRoot","domSelection","getSelection","newDomRange","toDOMRange","SlateRange","isBackward","setBaseAndExtent","endContainer","endOffset","startContainer","startOffset","removeAllRanges","e","console","error","definition","plugins","props","children","renderElement","reduce","renderFn","plugin","control","getElementValue","undefined","ControlValue","element","value","initialRenderElement","attributes","leaf","className","renderLeaf","getLeafValue","initialRenderLeaf","change","performance","now","time","data","isInBuilder","useIsInBuilder","useEffect","isChangeWithinPreviousSec","localChanges","get","key","richTextV2DataToDescendents","onChange","defaultText","type","BlockType","Default","text","useMemo","config","mode","RichTextV2Mode","Inline","InlineModePlugin","useState","reduceRight","withPlugin","withLocalChanges","withBuilder","withReact","createEditor","isPreservingFocus","useRef","useSyncDOMSelection","editMode","useBuilderEditMode","useSyncRemoteChanges","toDOMNode","pollBoxModel","onBoxModelChange","boxModel","changeBoxModel","useCallback","initialValue","BuilderEditMode","CONTENT","deselect","setEditor","setDefaultValue","handleFocus","select","handleKeyDown","isHotkey","blur","switchToBuildMode","stopPropagation","forEach","onKeyDown","handleKeyUp","preventDefault","handleClick","handleBlur","relatedTarget","getAttribute","Slate","Editable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,6BAA6BA,QAAgBC,WAAsC;AACxFC,4BAAAA,0BAA0B,MAAM;AAC1B,QAAA,CAACD,UAAUE,WAAWH,OAAOI,aAAa,QAAQC,WAAAA,YAAYC,UAAUN,MAAtB;AAA+B;AACjF,QAAA;AACIO,YAAAA,OAAOF,WAAAA,YAAYG,yB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cAARxE,gCAAoBV,GAAGrB;AAAAA,KAAjD;AAAA,KAEF,CAACgC,SAASP,SAASzB,QAAQgF,QAA3B,CAd+B;AAiB3BwB,QAAAA,cAAchB,kBAClB,CAACnE,MAAqB;AAChB2D,QAAAA,aAAaU,0BAAgBC,SAAS;AACxCtE,QAAEgF,gBAAF;AACAhF,QAAEoF,eAAF;AAAA,IACD;AAAA,EAEH,GAAA,CAACzE,SAAShC,QAAQgF,QAAlB,CAP6B;AAUzB0B,QAAAA,cAAclB,kBAClB,CAACnE,MAAkB;AACb2D,QAAAA,aAAaU,UAAAA,gBAAgBC;AAAStE,QAAEgF,gBAAF;AAAA,EAAA,GAE5C,CAACrB,QAAD,CAJ6B;AAOzB2B,QAAAA,aAAanB,kBAAY,CAACnE,MAAkB;;AAEhD,QAAIA,EAAEuF,iBAAiB;AAAM;AAE7B,QAAIvF,SAAEuF,kBAAFvF,mBAAiBwF,aAAa,wBAAuB;AACvDhC,wBAAkB1E,UAAU;AAAA,EALF,GAM3B,CAN2B,CAAA;AAQ9B,wCACG2G,WAAAA,OAAD;AAAA,IAAO;AAAA,IAAgB,OAAOrB;AAAAA,IAA9B,yCACGsB,qBAAD;AAAA,MACE;AAAA,MACA;AAAA,MACA,SAAShB;AAAAA,MACT,WAAWE;AAAAA,MACX,SAASO;AAAAA,MACT,SAASE;AAAAA,MACT,QAAQC;AAAAA,MACR,UAAU3B,aAAaU,UAAAA,gBAAgBC;AAAAA,MACvC,aAAY;AAAA,IAAA,CATd;AAAA,EAAA,CAFJ;AAeD;;;"}
|
package/dist/index.es.js
CHANGED
|
@@ -38,10 +38,10 @@ import * as React from "react";
|
|
|
38
38
|
import { useEffect, createContext, useContext, useState, useMemo, useRef, Children, createElement, forwardRef, memo, useId, useCallback, useImperativeHandle, Component, Suspense } from "react";
|
|
39
39
|
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
|
|
40
40
|
import dynamic from "next/dynamic";
|
|
41
|
-
import { a as createDocumentReference, g as getPropControllerDescriptors, b as isElementReference, e as getSwatchIds, f as getFileIds, h as getTypographyIds, j as getTableIds, k as getPageIds, l as getElementChildren, E as ElementID, B as Backgrounds, W as Width, m as ResponsiveIconRadioGroup, M as Margin, P as Padding, n as Border, o as BorderRadius, S as Shadows, G as GapY, p as GapX, q as ResponsiveSelect, r as ResponsiveNumber, s as Checkbox, t as Grid, u as TextInput, L as Link, v as ResponsiveColor, w as TextStyle, C as ComponentIcon, I as Images, N as Number$1, D as Date$1, F as Font, x as ResponsiveLength, y as TextArea, z as Table, A as TableFormFields, H as Image, J as ResponsiveOpacity, K as NavigationLinks, O as SocialLinks, Q as RichText, V as Video, U as useStyle, X as getBorderSwatchIds, Y as
|
|
41
|
+
import { a as createDocumentReference, g as getPropControllerDescriptors, b as isElementReference, e as getSwatchIds, f as getFileIds, h as getTypographyIds, j as getTableIds, k as getPageIds, l as getElementChildren, E as ElementID, B as Backgrounds, W as Width, m as ResponsiveIconRadioGroup, M as Margin, P as Padding, n as Border, o as BorderRadius, S as Shadows, G as GapY, p as GapX, q as ResponsiveSelect, r as ResponsiveNumber, s as Checkbox, t as Grid, u as TextInput, L as Link, v as ResponsiveColor, w as TextStyle, C as ComponentIcon, I as Images, N as Number$1, D as Date$1, F as Font, x as ResponsiveLength, y as TextArea, z as Table, A as TableFormFields, H as Image, J as ResponsiveOpacity, K as NavigationLinks, O as SocialLinks, Q as RichText, V as Video, U as useStyle, X as getBorderSwatchIds, Y as getBoxShadowsSwatchIds, Z as getResponsiveColorSwatchIds, _ as StyleControlProperty, $ as ImageControlValueFormat, a0 as isPropControllersHandle, a1 as isRichTextV1Data, a2 as isNonNullable$1, a3 as TypographyControlType, a4 as StyleControlType, a5 as RichTextV2ControlType, a6 as RichTextControlType, a7 as SlotControlType, a8 as StyleV2ControlType, a9 as ListControlType, aa as ShapeControlType, ab as LinkControlType, ac as ImageControlType, ad as ColorControlType, ae as getComponentPropControllerDescriptors, af as getPropControllers, ag as Types, ah as BorderPropControllerFormat, ai as ShadowsPropControllerFormat, aj as BorderRadiusPropControllerFormat, ak as MarginPropControllerFormat, al as PaddingPropControllerFormat, am as WidthPropControllerFormat, an as configureStore$1, ao as copyElementTree, ap as getBreakpoints, aq as parseLocalesInput, ar as getDocument, as as getElementId, at as getIsPreview, au as getIsInBuilder, av as getReactComponent, aw as getBuilderEditMode } from "./react-page.es.js";
|
|
42
42
|
import { A as ActionTypes, o as apiResourceFulfilled, p as registerComponentEffect, q as registerReactComponentEffect, t as registerComponentHandleEffect, v as mountComponentEffect } from "./actions.es.js";
|
|
43
43
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
44
|
-
import {
|
|
44
|
+
import { I as IconRadioGroupControlType, S as SelectControlType, T as TextAreaControlType, a as TextInputControlType, N as NumberControlType, C as CheckboxControlType } from "./text-input.es.js";
|
|
45
45
|
import { C as ComboboxControlType } from "./combobox.es.js";
|
|
46
46
|
import "slate";
|
|
47
47
|
import { useSyncExternalStore } from "use-sync-external-store/shim";
|
|
@@ -1206,7 +1206,7 @@ async function fonts(_req, res, { getFonts } = {}) {
|
|
|
1206
1206
|
const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
|
|
1207
1207
|
return res.json(fonts2);
|
|
1208
1208
|
}
|
|
1209
|
-
const version = "0.9.
|
|
1209
|
+
const version = "0.9.12";
|
|
1210
1210
|
async function handler(req, res, { apiKey, unstable_siteVersions }) {
|
|
1211
1211
|
if (req.query.secret !== apiKey) {
|
|
1212
1212
|
return res.status(401).json({ message: "Unauthorized" });
|
|
@@ -2537,6 +2537,9 @@ const FallbackComponent = forwardRef(function FallbackComponent2({
|
|
|
2537
2537
|
})]
|
|
2538
2538
|
});
|
|
2539
2539
|
});
|
|
2540
|
+
function isNonNullable(value) {
|
|
2541
|
+
return value != null;
|
|
2542
|
+
}
|
|
2540
2543
|
function useSwatch(swatchId) {
|
|
2541
2544
|
const client = useMakeswiftClient();
|
|
2542
2545
|
const readSwatch = () => swatchId == null ? null : client.readSwatch(swatchId);
|
|
@@ -2645,7 +2648,7 @@ function mapSideColor(swatches, _e) {
|
|
|
2645
2648
|
return __spreadProps(__spreadValues({}, restOfSide), {
|
|
2646
2649
|
color: color && {
|
|
2647
2650
|
alpha: color.alpha,
|
|
2648
|
-
swatch: swatches.filter(isNonNullable
|
|
2651
|
+
swatch: swatches.filter(isNonNullable).find((s) => s && s.id === color.swatchId)
|
|
2649
2652
|
}
|
|
2650
2653
|
});
|
|
2651
2654
|
}
|
|
@@ -2691,7 +2694,7 @@ function useBoxShadow(value) {
|
|
|
2691
2694
|
return __spreadProps(__spreadValues({}, restOfShadow), {
|
|
2692
2695
|
payload: {
|
|
2693
2696
|
color: color != null ? {
|
|
2694
|
-
swatch: swatches.filter(isNonNullable
|
|
2697
|
+
swatch: swatches.filter(isNonNullable).find((s) => s && s.id === color.swatchId),
|
|
2695
2698
|
alpha: color.alpha
|
|
2696
2699
|
} : null,
|
|
2697
2700
|
inset: inset != null ? inset : ShadowDefaultValue.inset,
|
|
@@ -2715,7 +2718,7 @@ function useResponsiveColor(color) {
|
|
|
2715
2718
|
const { swatchId, alpha } = v;
|
|
2716
2719
|
const swatch = swatches.find((s) => s && s.id === swatchId);
|
|
2717
2720
|
return swatch == null ? null : __spreadProps(__spreadValues({}, rest), { value: { swatch, alpha } });
|
|
2718
|
-
}).filter(isNonNullable
|
|
2721
|
+
}).filter(isNonNullable);
|
|
2719
2722
|
}
|
|
2720
2723
|
const getIndexes = (spans, index) => {
|
|
2721
2724
|
const flattened = spans.reduce((a, s) => a.concat(s), []);
|
|
@@ -3203,7 +3206,7 @@ function useRichTextV2(data, definition, control) {
|
|
|
3203
3206
|
control
|
|
3204
3207
|
}) : /* @__PURE__ */ jsx(ReadOnlyText, {
|
|
3205
3208
|
text: data,
|
|
3206
|
-
|
|
3209
|
+
definition
|
|
3207
3210
|
});
|
|
3208
3211
|
}
|
|
3209
3212
|
function useSelectControlValue(data, definition) {
|
|
@@ -3429,9 +3432,6 @@ function useTextAreaValue(data, definition) {
|
|
|
3429
3432
|
function useTextInputValue(data, definition) {
|
|
3430
3433
|
return data != null ? data : definition.config.defaultValue;
|
|
3431
3434
|
}
|
|
3432
|
-
function isNonNullable(value) {
|
|
3433
|
-
return value != null;
|
|
3434
|
-
}
|
|
3435
3435
|
function typographyFragementToTypographyControlData(typography) {
|
|
3436
3436
|
if (typography == null)
|
|
3437
3437
|
return void 0;
|
|
@@ -3463,7 +3463,7 @@ function getTypographyStyleSwatchIds(style) {
|
|
|
3463
3463
|
return (_a = style == null ? void 0 : style.map((override) => override.value).flatMap((typographyStyle) => {
|
|
3464
3464
|
var _a2;
|
|
3465
3465
|
return (_a2 = typographyStyle.color) == null ? void 0 : _a2.swatchId;
|
|
3466
|
-
}).filter(isNonNullable)) != null ? _a : [];
|
|
3466
|
+
}).filter(isNonNullable$1)) != null ? _a : [];
|
|
3467
3467
|
}
|
|
3468
3468
|
const withColor = (swatches) => (deviceRawTypographyValue) => {
|
|
3469
3469
|
var _b, _c;
|
|
@@ -3499,7 +3499,7 @@ function useEnhancedTypography(value) {
|
|
|
3499
3499
|
...getTypographyStyleSwatchIds(value == null ? void 0 : value.style),
|
|
3500
3500
|
...getTypographyStyleSwatchIds(typography == null ? void 0 : typography.style)
|
|
3501
3501
|
];
|
|
3502
|
-
const swatches = useSwatches(swatchIds).filter(isNonNullable);
|
|
3502
|
+
const swatches = useSwatches(swatchIds).filter(isNonNullable$1);
|
|
3503
3503
|
const enhancedSource = source.map(withColor(swatches));
|
|
3504
3504
|
const enhancedOverride = override.map(withColor(swatches));
|
|
3505
3505
|
const devices = [
|
|
@@ -3526,7 +3526,7 @@ function useEnhancedTypography(value) {
|
|
|
3526
3526
|
};
|
|
3527
3527
|
}
|
|
3528
3528
|
return null;
|
|
3529
|
-
}).filter(isNonNullable);
|
|
3529
|
+
}).filter(isNonNullable$1);
|
|
3530
3530
|
}
|
|
3531
3531
|
function useTypographyClassName(value) {
|
|
3532
3532
|
return useStyle(useResponsiveStyle([value], ([value2]) => {
|
|
@@ -4227,5 +4227,5 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
|
|
|
4227
4227
|
document: document2
|
|
4228
4228
|
});
|
|
4229
4229
|
}));
|
|
4230
|
-
export {
|
|
4230
|
+
export { Page as $, Alignments as A, forwardNextDynamicRef as B, Contrasts as C, DocumentReference as D, Element$1 as E, useIsPreview as F, isNonNullable as G, useFiles as H, useSwatches as I, usePagePathnameSlice as J, useElementId as K, shallowEqual as L, deepEqual as M, ElementImperativeHandle as N, StoreContext as O, PageProvider as P, MakeswiftProvider as Q, RuntimeProvider as R, Shapes as S, ControlValue as T, useBuilderEditMode as U, pollBoxModel as V, useEnhancedTypography as W, useTypographyClassName as X, getStaticPaths as Y, getStaticProps as Z, getServerSideProps as _, ReactRuntime as a, Makeswift as a0, PreviewModeScript as a1, Document$1 as a2, MakeswiftApiHandler as a3, 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, useResponsiveStyle as n, useResponsiveWidth as o, useResponsiveTextStyle as p, colorToString as q, useBreakpoints as r, Sizes as s, useFormContext as t, useIsInBuilder as u, useResponsiveGridItem as v, useTable as w, useMakeswiftClient as x, Provider as y, useFile as z };
|
|
4231
4231
|
//# sourceMappingURL=index.es.js.map
|