@makeswift/runtime 0.6.1 → 0.6.3

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.
Files changed (105) hide show
  1. package/dist/Box.cjs.js +1 -1
  2. package/dist/Box.es.js +1 -1
  3. package/dist/Button.cjs.js +1 -1
  4. package/dist/Button.es.js +1 -1
  5. package/dist/Carousel.cjs.js +1 -1
  6. package/dist/Carousel.es.js +1 -1
  7. package/dist/Countdown.cjs.js +1 -1
  8. package/dist/Countdown.es.js +1 -1
  9. package/dist/Divider.cjs.js +1 -1
  10. package/dist/Divider.es.js +1 -1
  11. package/dist/EditableText.cjs.js +11 -2
  12. package/dist/EditableText.cjs.js.map +1 -1
  13. package/dist/EditableText.es.js +13 -4
  14. package/dist/EditableText.es.js.map +1 -1
  15. package/dist/Embed.cjs.js +1 -1
  16. package/dist/Embed.es.js +1 -1
  17. package/dist/Form.cjs.js +1 -1
  18. package/dist/Form.es.js +1 -1
  19. package/dist/Image.cjs.js +3 -6
  20. package/dist/Image.cjs.js.map +1 -1
  21. package/dist/Image.es.js +4 -7
  22. package/dist/Image.es.js.map +1 -1
  23. package/dist/LiveProvider.cjs.js +1 -1
  24. package/dist/LiveProvider.es.js +1 -1
  25. package/dist/Navigation.cjs.js +1 -1
  26. package/dist/Navigation.es.js +1 -1
  27. package/dist/PreviewProvider.cjs.js +2 -2
  28. package/dist/PreviewProvider.cjs.js.map +1 -1
  29. package/dist/PreviewProvider.es.js +2 -2
  30. package/dist/ReadOnlyText.cjs.js +6 -3
  31. package/dist/ReadOnlyText.cjs.js.map +1 -1
  32. package/dist/ReadOnlyText.es.js +6 -3
  33. package/dist/ReadOnlyText.es.js.map +1 -1
  34. package/dist/Root.cjs.js +1 -1
  35. package/dist/Root.es.js +1 -1
  36. package/dist/SocialLinks.cjs.js +1 -1
  37. package/dist/SocialLinks.es.js +1 -1
  38. package/dist/Text.cjs.js +1 -1
  39. package/dist/Text.es.js +1 -1
  40. package/dist/Video.cjs.js +1 -1
  41. package/dist/Video.es.js +1 -1
  42. package/dist/builder.cjs.js +1 -1
  43. package/dist/builder.es.js +1 -1
  44. package/dist/components.cjs.js +1 -1
  45. package/dist/components.es.js +1 -1
  46. package/dist/constants.cjs.js +20 -20
  47. package/dist/constants.cjs.js.map +1 -1
  48. package/dist/constants.es.js +2 -2
  49. package/dist/control-serialization.cjs.js +37 -37
  50. package/dist/control-serialization.cjs.js.map +1 -1
  51. package/dist/control-serialization.es.js +1 -1
  52. package/dist/control.cjs.js +22 -22
  53. package/dist/control.cjs.js.map +1 -1
  54. package/dist/control.es.js +1 -1
  55. package/dist/controls.cjs.js +21 -17
  56. package/dist/controls.cjs.js.map +1 -1
  57. package/dist/controls.es.js +1 -1
  58. package/dist/index.cjs.js +237 -208
  59. package/dist/index.cjs.js.map +1 -1
  60. package/dist/index.cjs2.js +1 -1
  61. package/dist/index.cjs5.js +36 -139
  62. package/dist/index.cjs5.js.map +1 -1
  63. package/dist/index.cjs6.js +141 -0
  64. package/dist/index.cjs6.js.map +1 -0
  65. package/dist/index.es.js +52 -26
  66. package/dist/index.es.js.map +1 -1
  67. package/dist/index.es2.js +1 -1
  68. package/dist/index.es5.js +34 -138
  69. package/dist/index.es5.js.map +1 -1
  70. package/dist/index.es6.js +139 -0
  71. package/dist/index.es6.js.map +1 -0
  72. package/dist/main.cjs.js +1 -1
  73. package/dist/main.es.js +1 -1
  74. package/dist/next.cjs.js +1 -1
  75. package/dist/next.es.js +2 -2
  76. package/dist/prop-controllers.cjs.js +4 -4
  77. package/dist/prop-controllers.es.js +1 -1
  78. package/dist/react.cjs.js +1 -1
  79. package/dist/react.es.js +1 -1
  80. package/dist/{slot.cjs.js → rich-text.cjs.js} +84 -8
  81. package/dist/rich-text.cjs.js.map +1 -0
  82. package/dist/{slot.es.js → rich-text.es.js} +80 -8
  83. package/dist/rich-text.es.js.map +1 -0
  84. package/dist/types/src/components/builtin/Box/register.d.ts.map +1 -1
  85. package/dist/types/src/components/builtin/Image/Image.d.ts.map +1 -1
  86. package/dist/types/src/components/builtin/Text/EditableText.d.ts.map +1 -1
  87. package/dist/types/src/controls/index.d.ts +1 -0
  88. package/dist/types/src/controls/index.d.ts.map +1 -1
  89. package/dist/types/src/controls/rich-text.d.ts +66 -0
  90. package/dist/types/src/controls/rich-text.d.ts.map +1 -0
  91. package/dist/types/src/controls/style.d.ts +16 -4
  92. package/dist/types/src/controls/style.d.ts.map +1 -1
  93. package/dist/types/src/prop-controllers/descriptors.d.ts +4 -2
  94. package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
  95. package/dist/types/src/prop-controllers/instances.d.ts +13 -3
  96. package/dist/types/src/prop-controllers/instances.d.ts.map +1 -1
  97. package/dist/types/src/runtimes/react/controls/rich-text.d.ts +8 -0
  98. package/dist/types/src/runtimes/react/controls/rich-text.d.ts.map +1 -0
  99. package/dist/types/src/runtimes/react/controls/slot.d.ts.map +1 -1
  100. package/dist/types/src/runtimes/react/controls.d.ts.map +1 -1
  101. package/dist/types/src/runtimes/react/poll-box-model.d.ts +6 -0
  102. package/dist/types/src/runtimes/react/poll-box-model.d.ts.map +1 -0
  103. package/package.json +1 -1
  104. package/dist/slot.cjs.js.map +0 -1
  105. package/dist/slot.es.js.map +0 -1
@@ -8,7 +8,7 @@ import "./actions.es.js";
8
8
  import "@emotion/css";
9
9
  import "@emotion/serialize";
10
10
  import "@emotion/utils";
11
- import "./slot.es.js";
11
+ import "./rich-text.es.js";
12
12
  import "./text-input.es.js";
13
13
  import "./combobox.es.js";
14
14
  import "./control.es.js";
@@ -38,7 +38,7 @@ var Button = require("./Button.cjs.js");
38
38
  var next = require("./index.cjs.js");
39
39
  var jsxRuntime = require("react/jsx-runtime");
40
40
  require("use-sync-external-store/shim");
41
- require("./slot.cjs.js");
41
+ require("./rich-text.cjs.js");
42
42
  var index$1 = require("./index.cjs3.js");
43
43
  var useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect.cjs.js");
44
44
  var css = require("@emotion/css");
@@ -37,7 +37,7 @@ import Button from "./Button.es.js";
37
37
  import { o as useStyle, l as useResponsiveColor, q as responsiveTextStyle, r as responsiveStyle, s as colorToString } from "./index.es.js";
38
38
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
39
39
  import "use-sync-external-store/shim";
40
- import "./slot.es.js";
40
+ import "./rich-text.es.js";
41
41
  import { L as Link } from "./index.es3.js";
42
42
  import { u as useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.es.js";
43
43
  import { keyframes, cx } from "@emotion/css";
@@ -27,7 +27,7 @@ var immutable = require("immutable");
27
27
  var constants = require("./constants.cjs.js");
28
28
  var actions = require("./actions.cjs.js");
29
29
  var boxModels = require("./box-models.cjs.js");
30
- var slot = require("./slot.cjs.js");
30
+ var richText = require("./rich-text.cjs.js");
31
31
  var controlSerialization = require("./control-serialization.cjs.js");
32
32
  var jsxRuntime = require("react/jsx-runtime");
33
33
  require("use-sync-external-store/shim/with-selector");
@@ -361,7 +361,7 @@ function createAndRegisterPropControllers(documentKey, elementKey) {
361
361
  if (descriptors == null)
362
362
  return null;
363
363
  const propControllers = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {
364
- const propController = slot.createPropController(descriptor, (message) => dispatch(actions.messageBuilderPropController(documentKey, elementKey, propName, message)));
364
+ const propController = richText.createPropController(descriptor, (message) => dispatch(actions.messageBuilderPropController(documentKey, elementKey, propName, message)));
365
365
  return __spreadProps(__spreadValues({}, acc), { [propName]: propController });
366
366
  }, {});
367
367
  dispatch(actions.registerPropControllers(documentKey, elementKey, propControllers));
@@ -1 +1 @@
1
- {"version":3,"file":"PreviewProvider.cjs.js","sources":["../src/state/modules/read-write-documents.ts","../src/state/react-builder-preview.ts","../src/runtimes/react/components/PreviewProvider.tsx"],"sourcesContent":["import { Operation } from 'ot-json0'\nimport { removeIn, setIn } from 'immutable'\n\nimport * as ReadOnlyDocuments from './read-only-documents'\nimport { Action, ActionTypes } from '../actions'\n\nexport type { Document, Element, ElementData, ElementReference } from './read-only-documents'\nexport { isElementReference } from './read-only-documents'\nexport type { Operation }\n\nfunction apply(data: ReadOnlyDocuments.Element, operation: Operation): ReadOnlyDocuments.Element {\n let applied = data\n\n operation.forEach(component => {\n // @ts-expect-error: `ld` isn't in all possible values of `component`\n if (component.ld != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `od` isn't in all possible values of `component`\n if (component.od != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `li` isn't in all possible values of `component`\n if (component.li != null) applied = setIn(applied, component.p, component.li)\n\n // @ts-expect-error: `oi` isn't in all possible values of `component`\n if (component.oi != null) applied = setIn(applied, component.p, component.oi)\n })\n\n return applied\n}\n\nexport type State = ReadOnlyDocuments.State\n\nexport function getInitialState({\n rootElements,\n}: {\n rootElements?: Map<string, ReadOnlyDocuments.Element>\n} = {}): State {\n return ReadOnlyDocuments.getInitialState({ rootElements })\n}\n\nfunction getReadOnlyDocumentsStateSlice(state: State): ReadOnlyDocuments.State {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): ReadOnlyDocuments.Document | null {\n return ReadOnlyDocuments.getDocument(getReadOnlyDocumentsStateSlice(state), documentKey)\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n const nextState = ReadOnlyDocuments.reducer(state, action)\n\n switch (action.type) {\n case ActionTypes.CHANGE_DOCUMENT: {\n const currentRootElement = getDocument(nextState, action.payload.documentKey)?.rootElement\n\n if (currentRootElement == null) return nextState\n\n const nextRootElement = apply(currentRootElement, action.payload.operation)\n\n return currentRootElement === nextRootElement\n ? nextState\n : new Map(nextState).set(\n action.payload.documentKey,\n ReadOnlyDocuments.createDocument(action.payload.documentKey, nextRootElement),\n )\n }\n\n default:\n return nextState\n }\n}\n","import {\n applyMiddleware,\n combineReducers,\n createStore,\n Dispatch as ReduxDispatch,\n Middleware,\n MiddlewareAPI,\n PreloadedState,\n Store as ReduxStore,\n} from 'redux'\nimport thunk, { ThunkAction, ThunkDispatch } from 'redux-thunk'\nimport deepEqual from '../utils/deepEqual'\n\nimport * as Documents from './modules/read-write-documents'\nimport * as ReactComponents from './modules/react-components'\nimport * as BoxModels from './modules/box-models'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as PropControllerHandles from './modules/prop-controller-handles'\nimport * as IsInBuilder from './modules/is-in-builder'\nimport * as IsPreview from './modules/is-preview'\nimport * as ReactPage from './react-page'\nimport {\n Action,\n changeDocumentElementSize,\n changeElementBoxModels,\n messageBuilderPropController,\n registerBuilderComponent,\n registerMeasurable,\n registerPropControllers,\n registerPropControllersHandle,\n registerDocument,\n registerComponentHandle,\n unregisterBuilderComponent,\n unregisterMeasurable,\n unregisterPropControllers,\n setIsInBuilder,\n handleWheel,\n handlePointerMove,\n} from './actions'\nimport { ActionTypes } from './actions'\nimport { createPropController, PropController } from '../prop-controllers/instances'\nimport { serializeControls } from '../builder'\nimport { MakeswiftClient } from '../api/react'\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\n\nexport type { Operation } from './modules/read-write-documents'\nexport type { BoxModelHandle } from './modules/box-models'\nexport { createBox, getBox, parse } from './modules/box-models'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n reactComponents: ReactComponents.reducer,\n boxModels: BoxModels.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n propControllerHandles: PropControllerHandles.reducer,\n isInBuilder: IsInBuilder.reducer,\n isPreview: IsPreview.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\n\nfunction getBoxModelsStateSlice(state: State): BoxModels.State {\n return state.boxModels\n}\n\nfunction getMeasurables(state: State): Map<string, Map<string, BoxModels.Measurable>> {\n return BoxModels.getMeasurables(getBoxModelsStateSlice(state))\n}\n\nfunction getBoxModels(state: State): Map<string, Map<string, BoxModels.BoxModel>> {\n return BoxModels.getBoxModels(getBoxModelsStateSlice(state))\n}\n\nfunction getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModels.BoxModel | null {\n return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey)\n}\n\nfunction getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nfunction getComponentsMeta(state: State): Map<string, ComponentsMeta.ComponentMeta> {\n return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state))\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nfunction getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction getPropControllerHandlesStateSlice(state: State): PropControllerHandles.State {\n return state.propControllerHandles\n}\n\nfunction measureElements(): ThunkAction<void, State, unknown, Action> {\n return (dispatch, getState) => {\n const measurables = getMeasurables(getState())\n const currentBoxModels = getBoxModels(getState())\n const measuredBoxModels = new Map<string, Map<string, BoxModels.BoxModel>>()\n\n measurables.forEach((documentMeasurables, documentKey) => {\n const measuredDocumentBoxModels = new Map<string, BoxModels.BoxModel>()\n\n documentMeasurables.forEach((measurable, elementKey) => {\n const boxModel = BoxModels.measure(measurable)\n\n if (boxModel != null) measuredDocumentBoxModels.set(elementKey, boxModel)\n })\n\n if (measuredDocumentBoxModels.size > 0) {\n measuredBoxModels.set(documentKey, measuredDocumentBoxModels)\n }\n })\n\n const changedBoxModels = new Map<string, Map<string, BoxModels.BoxModel | null>>()\n\n currentBoxModels.forEach((currentDocumentBoxModels, documentKey) => {\n const changedDocumentBoxModels = new Map<string, BoxModels.BoxModel | null>()\n\n currentDocumentBoxModels.forEach((_boxModel, elementKey) => {\n if (!measuredBoxModels.get(documentKey)?.has(elementKey)) {\n changedDocumentBoxModels.set(elementKey, null)\n }\n\n if (changedDocumentBoxModels.size > 0) {\n changedBoxModels.set(documentKey, changedDocumentBoxModels)\n }\n })\n })\n\n measuredBoxModels.forEach((measuredDocumentBoxModels, documentKey) => {\n const changedDocumentBoxModels = new Map<string, BoxModels.BoxModel | null>()\n\n measuredDocumentBoxModels.forEach((measuredBoxModel, elementKey) => {\n const currentBoxModel = getBoxModel(getState(), documentKey, elementKey)\n\n if (currentBoxModel == null || !deepEqual(currentBoxModel, measuredBoxModel)) {\n changedDocumentBoxModels.set(elementKey, measuredBoxModel)\n }\n })\n\n if (changedDocumentBoxModels.size > 0) {\n changedBoxModels.set(documentKey, changedDocumentBoxModels)\n }\n })\n\n if (changedBoxModels.size > 0) dispatch(changeElementBoxModels(changedBoxModels))\n }\n}\n\nexport function startMeasuringElements(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n\n return () => {\n cancelAnimationFrame(animationFrameHandle)\n }\n\n function handleAnimationFrameRequest() {\n dispatch(measureElements())\n\n animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nexport type Size = {\n offsetWidth: number\n offsetHeight: number\n clientWidth: number\n clientHeight: number\n scrollWidth: number\n scrollHeight: number\n scrollTop: number\n scrollLeft: number\n}\n\nfunction getElementSize(element: HTMLElement): Size {\n return {\n offsetWidth: element.offsetWidth,\n offsetHeight: element.offsetHeight,\n clientWidth: element.clientWidth,\n clientHeight: element.clientHeight,\n scrollWidth: element.scrollWidth,\n scrollHeight: element.scrollHeight,\n scrollTop: element.scrollTop,\n scrollLeft: element.scrollLeft,\n }\n}\n\nfunction lockDocumentScroll(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n const lastDocumentOverflow = window.document.documentElement.style.overflow\n window.document.documentElement.style.overflow = 'hidden'\n\n window.document.documentElement.addEventListener('wheel', handleWheelEvent)\n\n return () => {\n window.document.documentElement.style.overflow = lastDocumentOverflow\n window.document.documentElement.removeEventListener('wheel', handleWheelEvent)\n }\n\n function handleWheelEvent({ deltaX, deltaY }: WheelEvent) {\n dispatch(handleWheel({ deltaX, deltaY }))\n }\n }\n}\n\nfunction startHandlingPointerMoveEvent(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n window.document.documentElement.addEventListener('pointermove', handlePointerMoveEvent)\n\n return () => {\n window.document.documentElement.removeEventListener('pointermove', handlePointerMoveEvent)\n }\n\n function handlePointerMoveEvent({ clientX, clientY }: PointerEvent) {\n dispatch(handlePointerMove({ clientX, clientY }))\n }\n }\n}\n\nfunction startHandlingFocusEvents(): () => void {\n window.addEventListener('focusin', handleFocusIn)\n window.addEventListener('focusout', handleFocusOut)\n\n return () => {\n window.removeEventListener('focusin', handleFocusIn)\n window.removeEventListener('focusout', handleFocusOut)\n }\n\n function handleFocusIn(event: FocusEvent) {\n if (!(event.target instanceof window.HTMLElement) || !event.target.isContentEditable) {\n window.parent.focus()\n }\n }\n\n function handleFocusOut(event: FocusEvent) {\n if (\n !(event.relatedTarget instanceof window.HTMLElement) ||\n !event.relatedTarget.isContentEditable\n ) {\n window.parent.focus()\n }\n }\n}\n\nfunction startMeasuringDocumentElement(): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n let lastSize: Size\n\n return () => {\n cancelAnimationFrame(animationFrameHandle)\n }\n\n function handleAnimationFrameRequest() {\n const nextSize = getElementSize(window.document.documentElement)\n\n if (!deepEqual(lastSize, nextSize)) {\n lastSize = nextSize\n\n dispatch(changeDocumentElementSize(nextSize))\n }\n\n animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nexport function initialize(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n const stopMeasuringElements = dispatch(startMeasuringElements())\n const stopMeasuringDocumentElement = dispatch(startMeasuringDocumentElement())\n const stopHandlingFocusEvent = startHandlingFocusEvents()\n const unlockDocumentScroll = dispatch(lockDocumentScroll())\n const stopHandlingPointerMoveEvent = dispatch(startHandlingPointerMoveEvent())\n dispatch(setIsInBuilder(true))\n\n return () => {\n stopMeasuringElements()\n stopMeasuringDocumentElement()\n stopHandlingFocusEvent()\n unlockDocumentScroll()\n stopHandlingPointerMoveEvent()\n dispatch(setIsInBuilder(false))\n }\n }\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction measureBoxModelsMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch }: MiddlewareAPI<Dispatch>) =>\n (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE: {\n if (BoxModels.isMeasurable(action.payload.componentHandle)) {\n dispatch(\n registerMeasurable(\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n }\n\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE:\n dispatch(unregisterMeasurable(action.payload.documentKey, action.payload.elementKey))\n break\n }\n\n return next(action)\n }\n }\n}\n\nexport function messageChannelMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch, getState }: MiddlewareAPI<Dispatch, State>) =>\n (next: ReduxDispatch<Action>) => {\n let cleanUp = () => {}\n\n if (typeof window === 'undefined') return cleanUp\n\n const messageChannel = new window.MessageChannel()\n\n window.parent.postMessage(messageChannel.port2, '*', [messageChannel.port2])\n\n messageChannel.port1.onmessage = (event: MessageEvent<Action>) => dispatch(event.data)\n\n const state = getState()\n const registeredComponentsMeta = getComponentsMeta(state)\n\n registeredComponentsMeta.forEach((componentMeta, componentType) => {\n const propControllerDescriptors = getComponentPropControllerDescriptors(\n state,\n componentType,\n )\n\n if (propControllerDescriptors != null) {\n const [serializedControls, transferables] = serializeControls(propControllerDescriptors)\n\n messageChannel.port1.postMessage(\n registerBuilderComponent(componentType, componentMeta, serializedControls),\n transferables,\n )\n }\n })\n\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.CHANGE_ELEMENT_BOX_MODELS:\n case ActionTypes.MOUNT_COMPONENT:\n case ActionTypes.UNMOUNT_COMPONENT:\n case ActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:\n case ActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:\n case ActionTypes.HANDLE_WHEEL:\n case ActionTypes.HANDLE_POINTER_MOVE:\n messageChannel.port1.postMessage(action)\n break\n\n case ActionTypes.REGISTER_COMPONENT: {\n const { type, meta, propControllerDescriptors } = action.payload\n const [serializedControls, transferables] = serializeControls(propControllerDescriptors)\n\n messageChannel.port1.postMessage(\n registerBuilderComponent(type, meta, serializedControls),\n transferables,\n )\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT:\n messageChannel.port1.postMessage(unregisterBuilderComponent(action.payload.type))\n break\n\n case ActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:\n window.document.documentElement.scrollTop = action.payload.scrollTop\n break\n\n case ActionTypes.SCROLL_DOCUMENT_ELEMENT:\n window.document.documentElement.scrollTop += action.payload.scrollTopDelta\n break\n\n case ActionTypes.INIT:\n cleanUp = dispatch(initialize())\n break\n\n case ActionTypes.CLEAN_UP:\n cleanUp()\n break\n }\n\n return next(action)\n }\n }\n}\n\nfunction createAndRegisterPropControllers(\n documentKey: string,\n elementKey: string,\n): ThunkAction<Record<string, PropController> | null, State, unknown, Action> {\n return (dispatch, getState) => {\n const descriptors = ReactPage.getElementPropControllerDescriptors(\n getState(),\n documentKey,\n elementKey,\n )\n\n if (descriptors == null) return null\n\n const propControllers = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {\n const propController = createPropController(descriptor, message =>\n dispatch(messageBuilderPropController(documentKey, elementKey, propName, message)),\n ) as PropController\n\n return { ...acc, [propName]: propController }\n }, {} as Record<string, PropController>)\n\n dispatch(registerPropControllers(documentKey, elementKey, propControllers))\n\n return propControllers\n }\n}\n\nfunction propControllerHandlesMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch, getState }: MiddlewareAPI<Dispatch, State>) =>\n (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey, componentHandle } = action.payload\n const element = ReactPage.getElement(getState(), documentKey, elementKey)\n const propControllers = dispatch(\n createAndRegisterPropControllers(documentKey, elementKey),\n )\n\n if (\n element != null &&\n !ReactPage.isElementReference(element) &&\n PropControllerHandles.isPropControllersHandle(componentHandle)\n ) {\n dispatch(registerPropControllersHandle(documentKey, elementKey, componentHandle))\n componentHandle.setPropControllers(propControllers)\n }\n\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const handle = PropControllerHandles.getPropControllersHandle(\n getPropControllerHandlesStateSlice(getState()),\n documentKey,\n elementKey,\n )\n\n handle?.setPropControllers(null)\n\n dispatch(unregisterPropControllers(documentKey, elementKey))\n\n break\n }\n\n case ActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {\n const propController = PropControllerHandles.getPropController(\n getPropControllerHandlesStateSlice(getState()),\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.propName,\n )\n\n if (propController) propController.recv(action.payload.message)\n }\n }\n\n return next(action)\n }\n }\n}\n\nif (import.meta.vitest) {\n const { describe, it, fn, expect } = import.meta.vitest\n\n describe('propControllerHandlesMiddleware', () => {\n it('registers prop controllers for element data', () => {\n // Arrange\n const documentKey = 'documentKey'\n const element: ReactPage.Element = { key: 'elementKey', type: 'type', props: {} }\n const store = createStore(reducer, applyMiddleware(thunk, propControllerHandlesMiddleware()))\n const setPropControllers = fn()\n const handle = new ElementImperativeHandle()\n\n handle.callback(() => ({ setPropControllers }))\n\n store.dispatch(registerDocument(ReactPage.createDocument(documentKey, element)))\n\n // Act\n store.dispatch(registerComponentHandle(documentKey, element.key, handle))\n\n // Assert\n expect(setPropControllers).toHaveBeenCalled()\n })\n\n it(\"doesn't register prop controllers for element references\", () => {\n // Arrange\n const documentKey = 'documentKey'\n const element: ReactPage.Element = { type: 'reference', key: 'elementKey', value: 'value' }\n const store = createStore(reducer, applyMiddleware(thunk, propControllerHandlesMiddleware()))\n const setPropControllers = fn()\n const handle = new ElementImperativeHandle()\n\n handle.callback(() => ({ setPropControllers }))\n\n store.dispatch(registerDocument(ReactPage.createDocument(documentKey, element)))\n\n // Act\n store.dispatch(registerComponentHandle(documentKey, element.key, handle))\n\n // Assert\n expect(setPropControllers).not.toHaveBeenCalled()\n })\n })\n}\n\nfunction makeswiftApiClientSyncMiddleware(\n client: MakeswiftClient,\n): Middleware<Dispatch, State, Dispatch> {\n return () => (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n client.makeswiftApiClient.dispatch(action)\n\n return next(action)\n }\n }\n}\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n rootElements,\n preloadedState,\n client,\n}: {\n rootElements?: Map<string, Documents.Element>\n preloadedState?: PreloadedState<State>\n client: MakeswiftClient\n}): Store {\n const initialState: PreloadedState<State> = {\n ...preloadedState,\n documents: Documents.getInitialState({ rootElements }),\n isPreview: IsPreview.getInitialState(true),\n }\n\n return createStore(\n reducer,\n initialState,\n applyMiddleware(\n thunk,\n measureBoxModelsMiddleware(),\n messageChannelMiddleware(),\n propControllerHandlesMiddleware(),\n makeswiftApiClientSyncMiddleware(client),\n ),\n )\n}\n","import { ReactNode, useEffect, useMemo } from 'react'\n\nimport { StoreContext, storeContextDefaultValue } from '..'\nimport * as ReactBuilderPreview from '../../../state/react-builder-preview'\nimport * as ReactPage from '../../../state/react-page'\nimport { MakeswiftProvider, MakeswiftClient } from '../../../api/react'\nimport { registerDocumentEffect } from '../../../state/actions'\n\ntype Props = {\n client: MakeswiftClient\n rootElements?: Map<string, ReactPage.Element>\n children?: ReactNode\n}\n\nexport default function PreviewProvider({ client, children, rootElements }: Props): JSX.Element {\n const store = useMemo(\n () =>\n ReactBuilderPreview.configureStore({\n preloadedState: storeContextDefaultValue.getState(),\n rootElements,\n client,\n }),\n [client, rootElements],\n )\n\n useEffect(() => {\n const unregisterDocuments = Array.from(rootElements?.entries() ?? []).map(\n ([documentKey, rootElement]) =>\n store.dispatch(registerDocumentEffect(ReactPage.createDocument(documentKey, rootElement))),\n )\n\n return () => {\n unregisterDocuments.forEach(unregisterDocument => {\n unregisterDocument()\n })\n }\n }, [store, rootElements])\n\n return (\n <StoreContext.Provider value={store}>\n <MakeswiftProvider client={client}>{children}</MakeswiftProvider>\n </StoreContext.Provider>\n )\n}\n"],"names":["removeIn","setIn","ReadOnlyDocuments.getInitialState","ReadOnlyDocuments.getDocument","ReadOnlyDocuments.reducer","ActionTypes","ReadOnlyDocuments.createDocument","combineReducers","Documents.reducer","ReactComponents.reducer","BoxModels.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","IsInBuilder.reducer","IsPreview.reducer","BoxModels.getMeasurables","BoxModels.getBoxModels","BoxModels.getBoxModel","ComponentsMeta.getComponentsMeta","PropControllers.getComponentPropControllerDescriptors","BoxModels.measure","deepEqual","changeElementBoxModels","handleWheel","handlePointerMove","changeDocumentElementSize","setIsInBuilder","BoxModels.isMeasurable","registerMeasurable","unregisterMeasurable","serializeControls","registerBuilderComponent","unregisterBuilderComponent","ReactPage.getElementPropControllerDescriptors","createPropController","messageBuilderPropController","registerPropControllers","ReactPage.getElement","ReactPage.isElementReference","PropControllerHandles.isPropControllersHandle","registerPropControllersHandle","PropControllerHandles.getPropControllersHandle","unregisterPropControllers","PropControllerHandles.getPropController","Documents.getInitialState","IsPreview.getInitialState","createStore","applyMiddleware","thunk","client","children","rootElements","store","useMemo","ReactBuilderPreview","preloadedState","storeContextDefaultValue","getState","useEffect","unregisterDocuments","Array","from","entries","map","documentKey","rootElement","dispatch","registerDocumentEffect","ReactPage","forEach","unregisterDocument","_jsx","StoreContext","MakeswiftProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,eAAe,MAAiC,WAAiD;AAC/F,MAAI,UAAU;AAEd,YAAU,QAAQ,CAAa,cAAA;AAE7B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AAaC,iBACbb,MAAMc,SAASC,QAAuBC,uBAAAA,yBAAyBJ,aAAaC,WAAtC,CAAD,CAArC,CAFwB;AAK5B,WAAO,MAAM;AACXN,0BAAoBU,QAAQC,CAAsB,uBAAA;AAC9B;MAAA,CADpB;AAAA,IAAA;AAAA,EADF,GAKC,CAAClB,OAAOD,YAAR,CAXM;AAcP,SAAAoB,2BAAA,IAACC,kBAAa,UAAd;AAAA,IAAuB,OAAOpB;AAAAA,IAA9B,yCACGqB,wBAAD;AAAA,MAAmB;AAAA,MAAiBvB;AAAAA,IAAAA,CAApC;AAAA,EAAA,CAFJ;AAKD;;"}
1
+ {"version":3,"file":"PreviewProvider.cjs.js","sources":["../src/state/modules/read-write-documents.ts","../src/state/react-builder-preview.ts","../src/runtimes/react/components/PreviewProvider.tsx"],"sourcesContent":["import { Operation } from 'ot-json0'\nimport { removeIn, setIn } from 'immutable'\n\nimport * as ReadOnlyDocuments from './read-only-documents'\nimport { Action, ActionTypes } from '../actions'\n\nexport type { Document, Element, ElementData, ElementReference } from './read-only-documents'\nexport { isElementReference } from './read-only-documents'\nexport type { Operation }\n\nfunction apply(data: ReadOnlyDocuments.Element, operation: Operation): ReadOnlyDocuments.Element {\n let applied = data\n\n operation.forEach(component => {\n // @ts-expect-error: `ld` isn't in all possible values of `component`\n if (component.ld != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `od` isn't in all possible values of `component`\n if (component.od != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `li` isn't in all possible values of `component`\n if (component.li != null) applied = setIn(applied, component.p, component.li)\n\n // @ts-expect-error: `oi` isn't in all possible values of `component`\n if (component.oi != null) applied = setIn(applied, component.p, component.oi)\n })\n\n return applied\n}\n\nexport type State = ReadOnlyDocuments.State\n\nexport function getInitialState({\n rootElements,\n}: {\n rootElements?: Map<string, ReadOnlyDocuments.Element>\n} = {}): State {\n return ReadOnlyDocuments.getInitialState({ rootElements })\n}\n\nfunction getReadOnlyDocumentsStateSlice(state: State): ReadOnlyDocuments.State {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): ReadOnlyDocuments.Document | null {\n return ReadOnlyDocuments.getDocument(getReadOnlyDocumentsStateSlice(state), documentKey)\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n const nextState = ReadOnlyDocuments.reducer(state, action)\n\n switch (action.type) {\n case ActionTypes.CHANGE_DOCUMENT: {\n const currentRootElement = getDocument(nextState, action.payload.documentKey)?.rootElement\n\n if (currentRootElement == null) return nextState\n\n const nextRootElement = apply(currentRootElement, action.payload.operation)\n\n return currentRootElement === nextRootElement\n ? nextState\n : new Map(nextState).set(\n action.payload.documentKey,\n ReadOnlyDocuments.createDocument(action.payload.documentKey, nextRootElement),\n )\n }\n\n default:\n return nextState\n }\n}\n","import {\n applyMiddleware,\n combineReducers,\n createStore,\n Dispatch as ReduxDispatch,\n Middleware,\n MiddlewareAPI,\n PreloadedState,\n Store as ReduxStore,\n} from 'redux'\nimport thunk, { ThunkAction, ThunkDispatch } from 'redux-thunk'\nimport deepEqual from '../utils/deepEqual'\n\nimport * as Documents from './modules/read-write-documents'\nimport * as ReactComponents from './modules/react-components'\nimport * as BoxModels from './modules/box-models'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as PropControllerHandles from './modules/prop-controller-handles'\nimport * as IsInBuilder from './modules/is-in-builder'\nimport * as IsPreview from './modules/is-preview'\nimport * as ReactPage from './react-page'\nimport {\n Action,\n changeDocumentElementSize,\n changeElementBoxModels,\n messageBuilderPropController,\n registerBuilderComponent,\n registerMeasurable,\n registerPropControllers,\n registerPropControllersHandle,\n registerDocument,\n registerComponentHandle,\n unregisterBuilderComponent,\n unregisterMeasurable,\n unregisterPropControllers,\n setIsInBuilder,\n handleWheel,\n handlePointerMove,\n} from './actions'\nimport { ActionTypes } from './actions'\nimport { createPropController, PropController } from '../prop-controllers/instances'\nimport { serializeControls } from '../builder'\nimport { MakeswiftClient } from '../api/react'\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\n\nexport type { Operation } from './modules/read-write-documents'\nexport type { BoxModelHandle } from './modules/box-models'\nexport { createBox, getBox, parse } from './modules/box-models'\n\nconst reducer = combineReducers({\n documents: Documents.reducer,\n reactComponents: ReactComponents.reducer,\n boxModels: BoxModels.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n propControllerHandles: PropControllerHandles.reducer,\n isInBuilder: IsInBuilder.reducer,\n isPreview: IsPreview.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\n\nfunction getBoxModelsStateSlice(state: State): BoxModels.State {\n return state.boxModels\n}\n\nfunction getMeasurables(state: State): Map<string, Map<string, BoxModels.Measurable>> {\n return BoxModels.getMeasurables(getBoxModelsStateSlice(state))\n}\n\nfunction getBoxModels(state: State): Map<string, Map<string, BoxModels.BoxModel>> {\n return BoxModels.getBoxModels(getBoxModelsStateSlice(state))\n}\n\nfunction getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModels.BoxModel | null {\n return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey)\n}\n\nfunction getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nfunction getComponentsMeta(state: State): Map<string, ComponentsMeta.ComponentMeta> {\n return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state))\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nfunction getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction getPropControllerHandlesStateSlice(state: State): PropControllerHandles.State {\n return state.propControllerHandles\n}\n\nfunction measureElements(): ThunkAction<void, State, unknown, Action> {\n return (dispatch, getState) => {\n const measurables = getMeasurables(getState())\n const currentBoxModels = getBoxModels(getState())\n const measuredBoxModels = new Map<string, Map<string, BoxModels.BoxModel>>()\n\n measurables.forEach((documentMeasurables, documentKey) => {\n const measuredDocumentBoxModels = new Map<string, BoxModels.BoxModel>()\n\n documentMeasurables.forEach((measurable, elementKey) => {\n const boxModel = BoxModels.measure(measurable)\n\n if (boxModel != null) measuredDocumentBoxModels.set(elementKey, boxModel)\n })\n\n if (measuredDocumentBoxModels.size > 0) {\n measuredBoxModels.set(documentKey, measuredDocumentBoxModels)\n }\n })\n\n const changedBoxModels = new Map<string, Map<string, BoxModels.BoxModel | null>>()\n\n currentBoxModels.forEach((currentDocumentBoxModels, documentKey) => {\n const changedDocumentBoxModels = new Map<string, BoxModels.BoxModel | null>()\n\n currentDocumentBoxModels.forEach((_boxModel, elementKey) => {\n if (!measuredBoxModels.get(documentKey)?.has(elementKey)) {\n changedDocumentBoxModels.set(elementKey, null)\n }\n\n if (changedDocumentBoxModels.size > 0) {\n changedBoxModels.set(documentKey, changedDocumentBoxModels)\n }\n })\n })\n\n measuredBoxModels.forEach((measuredDocumentBoxModels, documentKey) => {\n const changedDocumentBoxModels = new Map<string, BoxModels.BoxModel | null>()\n\n measuredDocumentBoxModels.forEach((measuredBoxModel, elementKey) => {\n const currentBoxModel = getBoxModel(getState(), documentKey, elementKey)\n\n if (currentBoxModel == null || !deepEqual(currentBoxModel, measuredBoxModel)) {\n changedDocumentBoxModels.set(elementKey, measuredBoxModel)\n }\n })\n\n if (changedDocumentBoxModels.size > 0) {\n changedBoxModels.set(documentKey, changedDocumentBoxModels)\n }\n })\n\n if (changedBoxModels.size > 0) dispatch(changeElementBoxModels(changedBoxModels))\n }\n}\n\nexport function startMeasuringElements(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n\n return () => {\n cancelAnimationFrame(animationFrameHandle)\n }\n\n function handleAnimationFrameRequest() {\n dispatch(measureElements())\n\n animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nexport type Size = {\n offsetWidth: number\n offsetHeight: number\n clientWidth: number\n clientHeight: number\n scrollWidth: number\n scrollHeight: number\n scrollTop: number\n scrollLeft: number\n}\n\nfunction getElementSize(element: HTMLElement): Size {\n return {\n offsetWidth: element.offsetWidth,\n offsetHeight: element.offsetHeight,\n clientWidth: element.clientWidth,\n clientHeight: element.clientHeight,\n scrollWidth: element.scrollWidth,\n scrollHeight: element.scrollHeight,\n scrollTop: element.scrollTop,\n scrollLeft: element.scrollLeft,\n }\n}\n\nfunction lockDocumentScroll(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n const lastDocumentOverflow = window.document.documentElement.style.overflow\n window.document.documentElement.style.overflow = 'hidden'\n\n window.document.documentElement.addEventListener('wheel', handleWheelEvent)\n\n return () => {\n window.document.documentElement.style.overflow = lastDocumentOverflow\n window.document.documentElement.removeEventListener('wheel', handleWheelEvent)\n }\n\n function handleWheelEvent({ deltaX, deltaY }: WheelEvent) {\n dispatch(handleWheel({ deltaX, deltaY }))\n }\n }\n}\n\nfunction startHandlingPointerMoveEvent(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n window.document.documentElement.addEventListener('pointermove', handlePointerMoveEvent)\n\n return () => {\n window.document.documentElement.removeEventListener('pointermove', handlePointerMoveEvent)\n }\n\n function handlePointerMoveEvent({ clientX, clientY }: PointerEvent) {\n dispatch(handlePointerMove({ clientX, clientY }))\n }\n }\n}\n\nfunction startHandlingFocusEvents(): () => void {\n window.addEventListener('focusin', handleFocusIn)\n window.addEventListener('focusout', handleFocusOut)\n\n return () => {\n window.removeEventListener('focusin', handleFocusIn)\n window.removeEventListener('focusout', handleFocusOut)\n }\n\n function handleFocusIn(event: FocusEvent) {\n if (!(event.target instanceof window.HTMLElement) || !event.target.isContentEditable) {\n window.parent.focus()\n }\n }\n\n function handleFocusOut(event: FocusEvent) {\n if (\n !(event.relatedTarget instanceof window.HTMLElement) ||\n !event.relatedTarget.isContentEditable\n ) {\n window.parent.focus()\n }\n }\n}\n\nfunction startMeasuringDocumentElement(): ThunkAction<() => void, unknown, unknown, Action> {\n return dispatch => {\n let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n let lastSize: Size\n\n return () => {\n cancelAnimationFrame(animationFrameHandle)\n }\n\n function handleAnimationFrameRequest() {\n const nextSize = getElementSize(window.document.documentElement)\n\n if (!deepEqual(lastSize, nextSize)) {\n lastSize = nextSize\n\n dispatch(changeDocumentElementSize(nextSize))\n }\n\n animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest)\n }\n }\n}\n\nexport function initialize(): ThunkAction<() => void, State, unknown, Action> {\n return dispatch => {\n const stopMeasuringElements = dispatch(startMeasuringElements())\n const stopMeasuringDocumentElement = dispatch(startMeasuringDocumentElement())\n const stopHandlingFocusEvent = startHandlingFocusEvents()\n const unlockDocumentScroll = dispatch(lockDocumentScroll())\n const stopHandlingPointerMoveEvent = dispatch(startHandlingPointerMoveEvent())\n dispatch(setIsInBuilder(true))\n\n return () => {\n stopMeasuringElements()\n stopMeasuringDocumentElement()\n stopHandlingFocusEvent()\n unlockDocumentScroll()\n stopHandlingPointerMoveEvent()\n dispatch(setIsInBuilder(false))\n }\n }\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction measureBoxModelsMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch }: MiddlewareAPI<Dispatch>) =>\n (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE: {\n if (BoxModels.isMeasurable(action.payload.componentHandle)) {\n dispatch(\n registerMeasurable(\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.componentHandle,\n ),\n )\n }\n\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE:\n dispatch(unregisterMeasurable(action.payload.documentKey, action.payload.elementKey))\n break\n }\n\n return next(action)\n }\n }\n}\n\nexport function messageChannelMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch, getState }: MiddlewareAPI<Dispatch, State>) =>\n (next: ReduxDispatch<Action>) => {\n let cleanUp = () => {}\n\n if (typeof window === 'undefined') return cleanUp\n\n const messageChannel = new window.MessageChannel()\n\n window.parent.postMessage(messageChannel.port2, '*', [messageChannel.port2])\n\n messageChannel.port1.onmessage = (event: MessageEvent<Action>) => dispatch(event.data)\n\n const state = getState()\n const registeredComponentsMeta = getComponentsMeta(state)\n\n registeredComponentsMeta.forEach((componentMeta, componentType) => {\n const propControllerDescriptors = getComponentPropControllerDescriptors(\n state,\n componentType,\n )\n\n if (propControllerDescriptors != null) {\n const [serializedControls, transferables] = serializeControls(propControllerDescriptors)\n\n messageChannel.port1.postMessage(\n registerBuilderComponent(componentType, componentMeta, serializedControls),\n transferables,\n )\n }\n })\n\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.CHANGE_ELEMENT_BOX_MODELS:\n case ActionTypes.MOUNT_COMPONENT:\n case ActionTypes.UNMOUNT_COMPONENT:\n case ActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:\n case ActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:\n case ActionTypes.HANDLE_WHEEL:\n case ActionTypes.HANDLE_POINTER_MOVE:\n messageChannel.port1.postMessage(action)\n break\n\n case ActionTypes.REGISTER_COMPONENT: {\n const { type, meta, propControllerDescriptors } = action.payload\n const [serializedControls, transferables] = serializeControls(propControllerDescriptors)\n\n messageChannel.port1.postMessage(\n registerBuilderComponent(type, meta, serializedControls),\n transferables,\n )\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT:\n messageChannel.port1.postMessage(unregisterBuilderComponent(action.payload.type))\n break\n\n case ActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:\n window.document.documentElement.scrollTop = action.payload.scrollTop\n break\n\n case ActionTypes.SCROLL_DOCUMENT_ELEMENT:\n window.document.documentElement.scrollTop += action.payload.scrollTopDelta\n break\n\n case ActionTypes.INIT:\n cleanUp = dispatch(initialize())\n break\n\n case ActionTypes.CLEAN_UP:\n cleanUp()\n break\n }\n\n return next(action)\n }\n }\n}\n\nfunction createAndRegisterPropControllers(\n documentKey: string,\n elementKey: string,\n): ThunkAction<Record<string, PropController> | null, State, unknown, Action> {\n return (dispatch, getState) => {\n const descriptors = ReactPage.getElementPropControllerDescriptors(\n getState(),\n documentKey,\n elementKey,\n )\n\n if (descriptors == null) return null\n\n const propControllers = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {\n const propController = createPropController(descriptor, message =>\n dispatch(messageBuilderPropController(documentKey, elementKey, propName, message)),\n ) as PropController\n\n return { ...acc, [propName]: propController }\n }, {} as Record<string, PropController>)\n\n dispatch(registerPropControllers(documentKey, elementKey, propControllers))\n\n return propControllers\n }\n}\n\nfunction propControllerHandlesMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return ({ dispatch, getState }: MiddlewareAPI<Dispatch, State>) =>\n (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n switch (action.type) {\n case ActionTypes.REGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey, componentHandle } = action.payload\n const element = ReactPage.getElement(getState(), documentKey, elementKey)\n const propControllers = dispatch(\n createAndRegisterPropControllers(documentKey, elementKey),\n )\n\n if (\n element != null &&\n !ReactPage.isElementReference(element) &&\n PropControllerHandles.isPropControllersHandle(componentHandle)\n ) {\n dispatch(registerPropControllersHandle(documentKey, elementKey, componentHandle))\n componentHandle.setPropControllers(propControllers)\n }\n\n break\n }\n\n case ActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const handle = PropControllerHandles.getPropControllersHandle(\n getPropControllerHandlesStateSlice(getState()),\n documentKey,\n elementKey,\n )\n\n handle?.setPropControllers(null)\n\n dispatch(unregisterPropControllers(documentKey, elementKey))\n\n break\n }\n\n case ActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {\n const propController = PropControllerHandles.getPropController(\n getPropControllerHandlesStateSlice(getState()),\n action.payload.documentKey,\n action.payload.elementKey,\n action.payload.propName,\n )\n\n if (propController) propController.recv(action.payload.message)\n }\n }\n\n return next(action)\n }\n }\n}\n\nif (import.meta.vitest) {\n const { describe, it, fn, expect } = import.meta.vitest\n\n describe('propControllerHandlesMiddleware', () => {\n it('registers prop controllers for element data', () => {\n // Arrange\n const documentKey = 'documentKey'\n const element: ReactPage.Element = { key: 'elementKey', type: 'type', props: {} }\n const store = createStore(reducer, applyMiddleware(thunk, propControllerHandlesMiddleware()))\n const setPropControllers = fn()\n const handle = new ElementImperativeHandle()\n\n handle.callback(() => ({ setPropControllers }))\n\n store.dispatch(registerDocument(ReactPage.createDocument(documentKey, element)))\n\n // Act\n store.dispatch(registerComponentHandle(documentKey, element.key, handle))\n\n // Assert\n expect(setPropControllers).toHaveBeenCalled()\n })\n\n it(\"doesn't register prop controllers for element references\", () => {\n // Arrange\n const documentKey = 'documentKey'\n const element: ReactPage.Element = { type: 'reference', key: 'elementKey', value: 'value' }\n const store = createStore(reducer, applyMiddleware(thunk, propControllerHandlesMiddleware()))\n const setPropControllers = fn()\n const handle = new ElementImperativeHandle()\n\n handle.callback(() => ({ setPropControllers }))\n\n store.dispatch(registerDocument(ReactPage.createDocument(documentKey, element)))\n\n // Act\n store.dispatch(registerComponentHandle(documentKey, element.key, handle))\n\n // Assert\n expect(setPropControllers).not.toHaveBeenCalled()\n })\n })\n}\n\nfunction makeswiftApiClientSyncMiddleware(\n client: MakeswiftClient,\n): Middleware<Dispatch, State, Dispatch> {\n return () => (next: ReduxDispatch<Action>) => {\n return (action: Action): Action => {\n client.makeswiftApiClient.dispatch(action)\n\n return next(action)\n }\n }\n}\n\nexport type Store = ReduxStore<State, Action> & { dispatch: Dispatch }\n\nexport function configureStore({\n rootElements,\n preloadedState,\n client,\n}: {\n rootElements?: Map<string, Documents.Element>\n preloadedState?: PreloadedState<State>\n client: MakeswiftClient\n}): Store {\n const initialState: PreloadedState<State> = {\n ...preloadedState,\n documents: Documents.getInitialState({ rootElements }),\n isPreview: IsPreview.getInitialState(true),\n }\n\n return createStore(\n reducer,\n initialState,\n applyMiddleware(\n thunk,\n measureBoxModelsMiddleware(),\n messageChannelMiddleware(),\n propControllerHandlesMiddleware(),\n makeswiftApiClientSyncMiddleware(client),\n ),\n )\n}\n","import { ReactNode, useEffect, useMemo } from 'react'\n\nimport { StoreContext, storeContextDefaultValue } from '..'\nimport * as ReactBuilderPreview from '../../../state/react-builder-preview'\nimport * as ReactPage from '../../../state/react-page'\nimport { MakeswiftProvider, MakeswiftClient } from '../../../api/react'\nimport { registerDocumentEffect } from '../../../state/actions'\n\ntype Props = {\n client: MakeswiftClient\n rootElements?: Map<string, ReactPage.Element>\n children?: ReactNode\n}\n\nexport default function PreviewProvider({ client, children, rootElements }: Props): JSX.Element {\n const store = useMemo(\n () =>\n ReactBuilderPreview.configureStore({\n preloadedState: storeContextDefaultValue.getState(),\n rootElements,\n client,\n }),\n [client, rootElements],\n )\n\n useEffect(() => {\n const unregisterDocuments = Array.from(rootElements?.entries() ?? []).map(\n ([documentKey, rootElement]) =>\n store.dispatch(registerDocumentEffect(ReactPage.createDocument(documentKey, rootElement))),\n )\n\n return () => {\n unregisterDocuments.forEach(unregisterDocument => {\n unregisterDocument()\n })\n }\n }, [store, rootElements])\n\n return (\n <StoreContext.Provider value={store}>\n <MakeswiftProvider client={client}>{children}</MakeswiftProvider>\n </StoreContext.Provider>\n )\n}\n"],"names":["removeIn","setIn","ReadOnlyDocuments.getInitialState","ReadOnlyDocuments.getDocument","ReadOnlyDocuments.reducer","ActionTypes","ReadOnlyDocuments.createDocument","combineReducers","Documents.reducer","ReactComponents.reducer","BoxModels.reducer","ComponentsMeta.reducer","PropControllers.reducer","PropControllerHandles.reducer","IsInBuilder.reducer","IsPreview.reducer","BoxModels.getMeasurables","BoxModels.getBoxModels","BoxModels.getBoxModel","ComponentsMeta.getComponentsMeta","PropControllers.getComponentPropControllerDescriptors","BoxModels.measure","deepEqual","changeElementBoxModels","handleWheel","handlePointerMove","changeDocumentElementSize","setIsInBuilder","BoxModels.isMeasurable","registerMeasurable","unregisterMeasurable","serializeControls","registerBuilderComponent","unregisterBuilderComponent","ReactPage.getElementPropControllerDescriptors","createPropController","messageBuilderPropController","registerPropControllers","ReactPage.getElement","ReactPage.isElementReference","PropControllerHandles.isPropControllersHandle","registerPropControllersHandle","PropControllerHandles.getPropControllersHandle","unregisterPropControllers","PropControllerHandles.getPropController","Documents.getInitialState","IsPreview.getInitialState","createStore","applyMiddleware","thunk","client","children","rootElements","store","useMemo","ReactBuilderPreview","preloadedState","storeContextDefaultValue","getState","useEffect","unregisterDocuments","Array","from","entries","map","documentKey","rootElement","dispatch","registerDocumentEffect","ReactPage","forEach","unregisterDocument","_jsx","StoreContext","MakeswiftProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,eAAe,MAAiC,WAAiD;AAC/F,MAAI,UAAU;AAEd,YAAU,QAAQ,CAAa,cAAA;AAE7B,QAAI,UAAU,MAAM;AAAgB,gBAAAA,UAAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAgB,gBAAAA,UAAAA,SAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAM,gBAAUC,UAAM,MAAA,SAAS,UAAU,GAAG,UAAU,EAAE;AAG5E,QAAI,UAAU,MAAM;AAAM,gBAAUA,UAAM,MAAA,SAAS,UAAU,GAAG,UAAU,EAAE;AAAA,EAAA,CAC7E;AAEM,SAAA;AACT;AAIgC,yBAAA;AAAA,EAC9B;AAAA,IAGE,IAAW;AACb,SAAOC,UAAkB,gBAAgB,EAAE,aAAA,CAAc;AAC3D;AAEA,wCAAwC,OAAuC;AACtE,SAAA;AACT;AAEO,qBAAqB,OAAc,aAAwD;AAChG,SAAOC,UAAkB,cAAY,+BAA+B,KAAK,GAAG,WAAW;AACzF;AAEwB,mBAAA,QAAe,gBAAgB,GAAG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A,EACA;AAAA,GAKQ;AACR,QAAM,eAAsC,iCACvC,iBADuC;AAAA,IAE1C,WAAWC,gBAA0B,EAAE,cAAc;AAAA,IACrD,WAAWC,UAAU,kBAAgB,IAAI;AAAA,EAAA;AAG3C,SAAOC,MACL,YAAA,SACA,cACAC,MAAA,gBACEC,2BACA,2BAA2B,GAC3B,yBAAyB,GACzB,gCAAgC,GAChC,iCAAiC,MAAM,CACzC,CACF;AACF;AC1jBwC,yBAAA;AAAA,EAAEC;AAAAA,EAAQC;AAAAA,EAAUC;AAAAA,GAAoC;AACxFC,QAAAA,QAAQC,cACZ,MACEC,eAAmC;AAAA,IACjCC,gBAAgBC,8BAAyBC,SADR;AAAA,IAEjCN;AAAAA,IACAF;AAAAA,EAHF,CAAA,GAKF,CAACA,QAAQE,YAAT,CAPmB;AAUrBO,QAAAA,UAAU,MAAM;;AACRC,UAAAA,sBAAsBC,MAAMC,KAAKV,mDAAcW,cAAdX,YAA2B,CAAA,CAAtC,EAA0CY,IACpE,CAAC,CAACC,aAAaC,iBACbb,MAAMc,SAASC,QAAuBC,uBAAAA,yBAAyBJ,aAAaC,WAAtC,CAAD,CAArC,CAFwB;AAK5B,WAAO,MAAM;AACXN,0BAAoBU,QAAQC,CAAsB,uBAAA;AAC9B;MAAA,CADpB;AAAA,IAAA;AAAA,EADF,GAKC,CAAClB,OAAOD,YAAR,CAXM;AAcP,SAAAoB,2BAAA,IAACC,kBAAa,UAAd;AAAA,IAAuB,OAAOpB;AAAAA,IAA9B,yCACGqB,wBAAD;AAAA,MAAmB;AAAA,MAAiBvB;AAAAA,IAAAA,CAApC;AAAA,EAAA,CAFJ;AAKD;;"}
@@ -22,10 +22,10 @@ import { N as deepEqual, O as storeContextDefaultValue, Q as StoreContext, T as
22
22
  import { createStore, applyMiddleware, combineReducers } from "redux";
23
23
  import thunk from "redux-thunk";
24
24
  import { removeIn, setIn } from "immutable";
25
- import { A as getInitialState$1, B as reducer$2, C as getDocument$1, c as createDocument, D as getComponentsMeta$1, E as getComponentPropControllerDescriptors$1, F as getPropController, G as getPropControllersHandle, H as getElement, I as getElementPropControllerDescriptors, i as isElementReference, q as isPropControllersHandle, J as reducer$3, K as reducer$5, L as reducer$6, N as reducer$7, O as reducer$8, P as reducer$9, Q as getInitialState$2 } from "./constants.es.js";
25
+ import { A as getInitialState$1, B as reducer$2, C as getDocument$1, c as createDocument, D as getComponentsMeta$1, E as getComponentPropControllerDescriptors$1, F as getPropController, G as getPropControllersHandle, H as getElement, I as getElementPropControllerDescriptors, i as isElementReference, o as isPropControllersHandle, J as reducer$3, K as reducer$5, L as reducer$6, N as reducer$7, O as reducer$8, P as reducer$9, Q as getInitialState$2 } from "./constants.es.js";
26
26
  import { A as ActionTypes, n as unregisterMeasurable, o as registerMeasurable, p as registerBuilderComponent, q as changeElementBoxModels, v as changeDocumentElementSize, w as handleWheel, x as handlePointerMove, y as setIsInBuilder, z as unregisterBuilderComponent, B as unregisterPropControllers, C as registerPropControllers, D as registerPropControllersHandle, E as messageBuilderPropController, F as registerDocumentEffect } from "./actions.es.js";
27
27
  import { i as isMeasurable, a as getMeasurables$1, b as getBoxModels$1, m as measure, d as getBoxModel$1, r as reducer$4 } from "./box-models.es.js";
28
- import { a5 as createPropController } from "./slot.es.js";
28
+ import { a9 as createPropController } from "./rich-text.es.js";
29
29
  import { a as serializeControls } from "./control-serialization.es.js";
30
30
  import { jsx } from "react/jsx-runtime";
31
31
  import "use-sync-external-store/shim/with-selector";
@@ -23,7 +23,7 @@ var css = require("@emotion/css");
23
23
  var React = require("react");
24
24
  var next = require("./index.cjs.js");
25
25
  var index$1 = require("./index.cjs3.js");
26
- var index = require("./index.cjs5.js");
26
+ var index = require("./index.cjs6.js");
27
27
  var jsxRuntime = require("react/jsx-runtime");
28
28
  require("use-sync-external-store/shim/with-selector");
29
29
  require("next/dynamic");
@@ -31,7 +31,7 @@ require("./constants.cjs.js");
31
31
  require("redux");
32
32
  require("redux-thunk");
33
33
  require("./actions.cjs.js");
34
- require("./slot.cjs.js");
34
+ require("./rich-text.cjs.js");
35
35
  require("./control.cjs.js");
36
36
  require("@emotion/serialize");
37
37
  require("@emotion/utils");
@@ -118,7 +118,10 @@ function Block({
118
118
  "heading-four": "h4",
119
119
  "heading-five": "h5",
120
120
  "heading-six": "h6",
121
- blockquote: "blockquote"
121
+ blockquote: "blockquote",
122
+ "ordered-list": "ol",
123
+ "unordered-list": "ul",
124
+ "list-item": "li"
122
125
  }[type];
123
126
  return /* @__PURE__ */ jsxRuntime.jsx(index.DeviceOverrideBlock, {
124
127
  as: component,
@@ -1 +1 @@
1
- {"version":3,"file":"ReadOnlyText.cjs.js","sources":["../src/components/builtin/Text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef, ReactNode } from 'react'\nimport type { BlockJSON, DocumentJSON, InlineJSON, MarkJSON, NodeJSON, TextJSON } from 'slate'\nimport type {\n ElementIDValue,\n LinkValue,\n RichTextValue,\n} from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport DeviceOverrideBlock from './components/RichTextEditor/components/Block'\nimport DeviceOverrideMark from './components/RichTextEditor/components/Mark'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const plaintext = text?.document == null ? '' : getNodeText(text.document)\n\n return (\n <div ref={ref} id={id} className={cx(width, margin)}>\n {plaintext === '' ? <Placeholder /> : <Node {...text?.document} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nfunction Node(props: NodeJSON) {\n switch (props.object) {\n case 'document':\n return <Document {...props} />\n\n case 'block':\n return <Block {...props} />\n\n case 'inline':\n return <Inline {...props} />\n\n case 'text':\n return <Text {...props} />\n\n default:\n return null\n }\n}\n\nfunction Document({ nodes }: DocumentJSON) {\n return (\n <>\n {nodes?.map((node, idx) => (\n <Node key={idx.toString()} {...node} />\n ))}\n </>\n )\n}\n\nfunction Block({ type, data, nodes }: BlockJSON) {\n const component = {\n paragraph: 'p',\n 'heading-one': 'h1',\n 'heading-two': 'h2',\n 'heading-three': 'h3',\n 'heading-four': 'h4',\n 'heading-five': 'h5',\n 'heading-six': 'h6',\n blockquote: 'blockquote',\n }[type]\n\n return (\n <DeviceOverrideBlock as={component} textAlign={data?.textAlign}>\n {nodes?.map((node, idx) => (\n <Node key={idx.toString()} {...node} />\n ))}\n </DeviceOverrideBlock>\n )\n}\n\nfunction Inline({ type, nodes, data }: InlineJSON) {\n const children = nodes?.map((node, idx) => <Node key={idx.toString()} {...node} />)\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (type) {\n case 'code':\n return <code>{children}</code>\n\n case 'superscript':\n return <sup>{children}</sup>\n\n case 'subscript':\n return <sub>{children}</sub>\n\n case 'link':\n return (\n <Link className={linkClassName} link={data as LinkValue | undefined}>\n {children}\n </Link>\n )\n\n default:\n return <>{children}</>\n }\n}\n\nfunction Text({ marks, text = '' }: TextJSON) {\n return (\n <>\n {(marks ?? []).reduce(\n (element, mark) => (\n <Mark {...mark}>{element}</Mark>\n ),\n <>{text === '' ? '\\uFEFF' : text}</>,\n )}\n </>\n )\n}\n\nconst TYPOGRAPHY_MARK_TYPE = 'typography'\n\nfunction Mark({ type, children, data }: MarkJSON & { children: ReactNode }) {\n if (type !== TYPOGRAPHY_MARK_TYPE) return <>{children}</>\n\n return <DeviceOverrideMark value={data?.value}>{children}</DeviceOverrideMark>\n}\n\nfunction getNodeText(node: NodeJSON): string {\n switch (node.object) {\n case 'document':\n return node?.nodes?.map(node => getNodeText(node)).join('\\n') ?? ''\n\n case 'block':\n return (\n node?.nodes\n ?.map(node => getNodeText(node))\n .join(node.nodes.every(node => node.object === 'block') ? '\\n' : '') ?? ''\n )\n\n case 'inline':\n return node?.nodes?.map(node => getNodeText(node)).join('') ?? ''\n\n case 'text':\n return node.text ?? ''\n\n default:\n return ''\n }\n}\n"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","plaintext","document","getNodeText","cx","_jsx","useStyle","display","maxWidth","whiteSpace","opacity","verticalAlign","props","object","nodes","_Fragment","map","node","idx","toString","type","data","component","paragraph","blockquote","DeviceOverrideBlock","textAlign","children","linkClassName","textDecoration","Link","marks","reduce","element","mark","TYPOGRAPHY_MARK_TYPE","DeviceOverrideMark","value","join","every"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBMA,MAAAA,eAAeC,MAAAA,WAAW,uBAC9B;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAMC;AAAAA,EAAOC;AAAAA,GACnBC,KACA;AACA,QAAMC,YAAYJ,8BAAMK,aAAY,OAAO,KAAKC,YAAYN,KAAKK,QAAN;AAGzD,wCAAA,OAAA;AAAA,IAAK;AAAA,IAAU;AAAA,IAAQ,WAAWE,IAAAA,GAAGN,OAAOC,MAAR;AAAA,IAApC,UACGE,cAAc,KAAKI,2BAAA,IAAC,aAApB,EAAA,IAAqCA,2BAAA,IAAC,MAASR,mBAAAA,6BAAMK,SAAhB;AAAA,EAAA,CAF1C;AAKD,CAX8B;AAe/B,qBAAqB;AAAA,EAAEL,OAAO;AAAA,GAA2C;AAErE,wCAAA,QAAA;AAAA,IACE,WAAWS,KAAAA,SAAS;AAAA,MAClBC,SAAS;AAAA,MACTT,OAAO;AAAA,MACPU,UAAU;AAAA,MACVC,YAAY;AAAA,MACZC,SAAS;AAAA,MACTC,eAAe;AAAA,IAAA,CANE;AAAA,IASlBd,UAAAA;AAAAA,EAAAA,CAXL;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D,OAAO,QAFnEI,YAE0E;AAAA,SAGzE;AACIA,aAAAA,yCAAMH,UAANG,mBAAaD,IAAIC,CAAQd,UAAAA,YAAYc,KAAD,GAAQqB,KAAK,QAAjDrB,YAAwD;AAAA,SAE5D;AACH,aAAOA,WAAKpB,SAALoB,YAAa;AAAA;AAGb,aAAA;AAAA;AAEZ;;"}
1
+ {"version":3,"file":"ReadOnlyText.cjs.js","sources":["../src/components/builtin/Text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef, ReactNode } from 'react'\nimport type { BlockJSON, DocumentJSON, InlineJSON, MarkJSON, NodeJSON, TextJSON } from 'slate'\nimport type {\n ElementIDValue,\n LinkValue,\n RichTextValue,\n} from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport DeviceOverrideBlock from './components/RichTextEditor/components/Block'\nimport DeviceOverrideMark from './components/RichTextEditor/components/Mark'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const plaintext = text?.document == null ? '' : getNodeText(text.document)\n\n return (\n <div ref={ref} id={id} className={cx(width, margin)}>\n {plaintext === '' ? <Placeholder /> : <Node {...text?.document} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nfunction Node(props: NodeJSON) {\n switch (props.object) {\n case 'document':\n return <Document {...props} />\n\n case 'block':\n return <Block {...props} />\n\n case 'inline':\n return <Inline {...props} />\n\n case 'text':\n return <Text {...props} />\n\n default:\n return null\n }\n}\n\nfunction Document({ nodes }: DocumentJSON) {\n return (\n <>\n {nodes?.map((node, idx) => (\n <Node key={idx.toString()} {...node} />\n ))}\n </>\n )\n}\n\nfunction Block({ type, data, nodes }: BlockJSON) {\n const component = {\n paragraph: 'p',\n 'heading-one': 'h1',\n 'heading-two': 'h2',\n 'heading-three': 'h3',\n 'heading-four': 'h4',\n 'heading-five': 'h5',\n 'heading-six': 'h6',\n blockquote: 'blockquote',\n 'ordered-list': 'ol',\n 'unordered-list': 'ul',\n 'list-item': 'li',\n }[type]\n\n return (\n <DeviceOverrideBlock as={component} textAlign={data?.textAlign}>\n {nodes?.map((node, idx) => (\n <Node key={idx.toString()} {...node} />\n ))}\n </DeviceOverrideBlock>\n )\n}\n\nfunction Inline({ type, nodes, data }: InlineJSON) {\n const children = nodes?.map((node, idx) => <Node key={idx.toString()} {...node} />)\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (type) {\n case 'code':\n return <code>{children}</code>\n\n case 'superscript':\n return <sup>{children}</sup>\n\n case 'subscript':\n return <sub>{children}</sub>\n\n case 'link':\n return (\n <Link className={linkClassName} link={data as LinkValue | undefined}>\n {children}\n </Link>\n )\n\n default:\n return <>{children}</>\n }\n}\n\nfunction Text({ marks, text = '' }: TextJSON) {\n return (\n <>\n {(marks ?? []).reduce(\n (element, mark) => (\n <Mark {...mark}>{element}</Mark>\n ),\n <>{text === '' ? '\\uFEFF' : text}</>,\n )}\n </>\n )\n}\n\nconst TYPOGRAPHY_MARK_TYPE = 'typography'\n\nfunction Mark({ type, children, data }: MarkJSON & { children: ReactNode }) {\n if (type !== TYPOGRAPHY_MARK_TYPE) return <>{children}</>\n\n return <DeviceOverrideMark value={data?.value}>{children}</DeviceOverrideMark>\n}\n\nfunction getNodeText(node: NodeJSON): string {\n switch (node.object) {\n case 'document':\n return node?.nodes?.map(node => getNodeText(node)).join('\\n') ?? ''\n\n case 'block':\n return (\n node?.nodes\n ?.map(node => getNodeText(node))\n .join(node.nodes.every(node => node.object === 'block') ? '\\n' : '') ?? ''\n )\n\n case 'inline':\n return node?.nodes?.map(node => getNodeText(node)).join('') ?? ''\n\n case 'text':\n return node.text ?? ''\n\n default:\n return ''\n }\n}\n"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","plaintext","document","getNodeText","cx","_jsx","useStyle","display","maxWidth","whiteSpace","opacity","verticalAlign","props","object","nodes","_Fragment","map","node","idx","toString","type","data","component","paragraph","blockquote","DeviceOverrideBlock","textAlign","children","linkClassName","textDecoration","Link","marks","reduce","element","mark","TYPOGRAPHY_MARK_TYPE","DeviceOverrideMark","value","join","every"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBMA,MAAAA,eAAeC,MAAAA,WAAW,uBAC9B;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAMC;AAAAA,EAAOC;AAAAA,GACnBC,KACA;AACA,QAAMC,YAAYJ,8BAAMK,aAAY,OAAO,KAAKC,YAAYN,KAAKK,QAAN;AAGzD,wCAAA,OAAA;AAAA,IAAK;AAAA,IAAU;AAAA,IAAQ,WAAWE,IAAAA,GAAGN,OAAOC,MAAR;AAAA,IAApC,UACGE,cAAc,KAAKI,2BAAA,IAAC,aAApB,EAAA,IAAqCA,2BAAA,IAAC,MAASR,mBAAAA,6BAAMK,SAAhB;AAAA,EAAA,CAF1C;AAKD,CAX8B;AAe/B,qBAAqB;AAAA,EAAEL,OAAO;AAAA,GAA2C;AAErE,wCAAA,QAAA;AAAA,IACE,WAAWS,KAAAA,SAAS;AAAA,MAClBC,SAAS;AAAA,MACTT,OAAO;AAAA,MACPU,UAAU;AAAA,MACVC,YAAY;AAAA,MACZC,SAAS;AAAA,MACTC,eAAe;AAAA,IAAA,CANE;AAAA,IASlBd,UAAAA;AAAAA,EAAAA,CAXL;AAcD;AAED,cAAce,OAAiB;AACrBA,UAAAA,MAAMC;AAAAA,SACP;AACI,4CAAC,UAAaD,mBAAAA,MAArB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GzE;AACIA,aAAAA,yCAAMH,UAANG,mBAAaD,IAAIC,CAAQd,UAAAA,YAAYc,KAAD,GAAQqB,KAAK,QAAjDrB,YAAwD;AAAA,SAE5D;AACH,aAAOA,WAAKpB,SAALoB,YAAa;AAAA;AAGb,aAAA;AAAA;AAEZ;;"}
@@ -21,7 +21,7 @@ import { cx } from "@emotion/css";
21
21
  import { forwardRef } from "react";
22
22
  import { o as useStyle } from "./index.es.js";
23
23
  import { L as Link } from "./index.es3.js";
24
- import { D as DeviceOverrideBlock, M as Mark$1 } from "./index.es5.js";
24
+ import { D as DeviceOverrideBlock, M as Mark$1 } from "./index.es6.js";
25
25
  import { jsx, Fragment } from "react/jsx-runtime";
26
26
  import "use-sync-external-store/shim/with-selector";
27
27
  import "next/dynamic";
@@ -29,7 +29,7 @@ import "./constants.es.js";
29
29
  import "redux";
30
30
  import "redux-thunk";
31
31
  import "./actions.es.js";
32
- import "./slot.es.js";
32
+ import "./rich-text.es.js";
33
33
  import "./control.es.js";
34
34
  import "@emotion/serialize";
35
35
  import "@emotion/utils";
@@ -116,7 +116,10 @@ function Block({
116
116
  "heading-four": "h4",
117
117
  "heading-five": "h5",
118
118
  "heading-six": "h6",
119
- blockquote: "blockquote"
119
+ blockquote: "blockquote",
120
+ "ordered-list": "ol",
121
+ "unordered-list": "ul",
122
+ "list-item": "li"
120
123
  }[type];
121
124
  return /* @__PURE__ */ jsx(DeviceOverrideBlock, {
122
125
  as: component,
@@ -1 +1 @@
1
- {"version":3,"file":"ReadOnlyText.es.js","sources":["../src/components/builtin/Text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef, ReactNode } from 'react'\nimport type { BlockJSON, DocumentJSON, InlineJSON, MarkJSON, NodeJSON, TextJSON } from 'slate'\nimport type {\n ElementIDValue,\n LinkValue,\n RichTextValue,\n} from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport DeviceOverrideBlock from './components/RichTextEditor/components/Block'\nimport DeviceOverrideMark from './components/RichTextEditor/components/Mark'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const plaintext = text?.document == null ? '' : getNodeText(text.document)\n\n return (\n <div ref={ref} id={id} className={cx(width, margin)}>\n {plaintext === '' ? <Placeholder /> : <Node {...text?.document} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nfunction Node(props: NodeJSON) {\n switch (props.object) {\n case 'document':\n return <Document {...props} />\n\n case 'block':\n return <Block {...props} />\n\n case 'inline':\n return <Inline {...props} />\n\n case 'text':\n return <Text {...props} />\n\n default:\n return null\n }\n}\n\nfunction Document({ nodes }: DocumentJSON) {\n return (\n <>\n {nodes?.map((node, idx) => (\n <Node key={idx.toString()} {...node} />\n ))}\n </>\n )\n}\n\nfunction Block({ type, data, nodes }: BlockJSON) {\n const component = {\n paragraph: 'p',\n 'heading-one': 'h1',\n 'heading-two': 'h2',\n 'heading-three': 'h3',\n 'heading-four': 'h4',\n 'heading-five': 'h5',\n 'heading-six': 'h6',\n blockquote: 'blockquote',\n }[type]\n\n return (\n <DeviceOverrideBlock as={component} textAlign={data?.textAlign}>\n {nodes?.map((node, idx) => (\n <Node key={idx.toString()} {...node} />\n ))}\n </DeviceOverrideBlock>\n )\n}\n\nfunction Inline({ type, nodes, data }: InlineJSON) {\n const children = nodes?.map((node, idx) => <Node key={idx.toString()} {...node} />)\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (type) {\n case 'code':\n return <code>{children}</code>\n\n case 'superscript':\n return <sup>{children}</sup>\n\n case 'subscript':\n return <sub>{children}</sub>\n\n case 'link':\n return (\n <Link className={linkClassName} link={data as LinkValue | undefined}>\n {children}\n </Link>\n )\n\n default:\n return <>{children}</>\n }\n}\n\nfunction Text({ marks, text = '' }: TextJSON) {\n return (\n <>\n {(marks ?? []).reduce(\n (element, mark) => (\n <Mark {...mark}>{element}</Mark>\n ),\n <>{text === '' ? '\\uFEFF' : text}</>,\n )}\n </>\n )\n}\n\nconst TYPOGRAPHY_MARK_TYPE = 'typography'\n\nfunction Mark({ type, children, data }: MarkJSON & { children: ReactNode }) {\n if (type !== TYPOGRAPHY_MARK_TYPE) return <>{children}</>\n\n return <DeviceOverrideMark value={data?.value}>{children}</DeviceOverrideMark>\n}\n\nfunction getNodeText(node: NodeJSON): string {\n switch (node.object) {\n case 'document':\n return node?.nodes?.map(node => getNodeText(node)).join('\\n') ?? ''\n\n case 'block':\n return (\n node?.nodes\n ?.map(node => getNodeText(node))\n .join(node.nodes.every(node => node.object === 'block') ? '\\n' : '') ?? ''\n )\n\n case 'inline':\n return node?.nodes?.map(node => getNodeText(node)).join('') ?? ''\n\n case 'text':\n return node.text ?? ''\n\n default:\n return ''\n }\n}\n"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","plaintext","document","getNodeText","cx","_jsx","useStyle","display","maxWidth","whiteSpace","opacity","verticalAlign","props","object","nodes","_Fragment","map","node","idx","toString","type","data","component","paragraph","blockquote","textAlign","children","linkClassName","textDecoration","marks","reduce","element","mark","TYPOGRAPHY_MARK_TYPE","DeviceOverrideMark","value","join","every"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBMA,MAAAA,eAAeC,WAAW,uBAC9B;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAMC;AAAAA,EAAOC;AAAAA,GACnBC,KACA;AACA,QAAMC,YAAYJ,8BAAMK,aAAY,OAAO,KAAK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W;AAAAA,IAAAA,CAAV;AAEnC,6BAAQQ,QAAD;AAAA,IAAoB,OAAOb,6BAAMc;AAAAA,IAAQT;AAAAA,EAAAA,CAAhD;AACD;AAED,qBAAqBT,MAAwB;;AACnCA,UAAAA,KAAKJ;AAAAA,SACN;AACII,aAAAA,yCAAMH,UAANG,mBAAaD,IAAIC,CAAQd,UAAAA,YAAYc,KAAD,GAAQmB,KAAK,UAAjDnB,YAA0D;AAAA,SAE9D;AACH,aACEA,yCAAMH,UAANG,mBACID,IAAIC,WAAQd,YAAYc,KAAD,GACxBmB,KAAKnB,KAAKH,MAAMuB,MAAMpB,WAAQA,MAAKJ,WAAW,OAAzC,IAAoD,OAAO,QAFnEI,YAE0E;AAAA,SAGzE;AACIA,aAAAA,yCAAMH,UAANG,mBAAaD,IAAIC,CAAQd,UAAAA,YAAYc,KAAD,GAAQmB,KAAK,QAAjDnB,YAAwD;AAAA,SAE5D;AACH,aAAOA,WAAKpB,SAALoB,YAAa;AAAA;AAGb,aAAA;AAAA;AAEZ;;"}
1
+ {"version":3,"file":"ReadOnlyText.es.js","sources":["../src/components/builtin/Text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef, ReactNode } from 'react'\nimport type { BlockJSON, DocumentJSON, InlineJSON, MarkJSON, NodeJSON, TextJSON } from 'slate'\nimport type {\n ElementIDValue,\n LinkValue,\n RichTextValue,\n} from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport DeviceOverrideBlock from './components/RichTextEditor/components/Block'\nimport DeviceOverrideMark from './components/RichTextEditor/components/Mark'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const plaintext = text?.document == null ? '' : getNodeText(text.document)\n\n return (\n <div ref={ref} id={id} className={cx(width, margin)}>\n {plaintext === '' ? <Placeholder /> : <Node {...text?.document} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nfunction Node(props: NodeJSON) {\n switch (props.object) {\n case 'document':\n return <Document {...props} />\n\n case 'block':\n return <Block {...props} />\n\n case 'inline':\n return <Inline {...props} />\n\n case 'text':\n return <Text {...props} />\n\n default:\n return null\n }\n}\n\nfunction Document({ nodes }: DocumentJSON) {\n return (\n <>\n {nodes?.map((node, idx) => (\n <Node key={idx.toString()} {...node} />\n ))}\n </>\n )\n}\n\nfunction Block({ type, data, nodes }: BlockJSON) {\n const component = {\n paragraph: 'p',\n 'heading-one': 'h1',\n 'heading-two': 'h2',\n 'heading-three': 'h3',\n 'heading-four': 'h4',\n 'heading-five': 'h5',\n 'heading-six': 'h6',\n blockquote: 'blockquote',\n 'ordered-list': 'ol',\n 'unordered-list': 'ul',\n 'list-item': 'li',\n }[type]\n\n return (\n <DeviceOverrideBlock as={component} textAlign={data?.textAlign}>\n {nodes?.map((node, idx) => (\n <Node key={idx.toString()} {...node} />\n ))}\n </DeviceOverrideBlock>\n )\n}\n\nfunction Inline({ type, nodes, data }: InlineJSON) {\n const children = nodes?.map((node, idx) => <Node key={idx.toString()} {...node} />)\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (type) {\n case 'code':\n return <code>{children}</code>\n\n case 'superscript':\n return <sup>{children}</sup>\n\n case 'subscript':\n return <sub>{children}</sub>\n\n case 'link':\n return (\n <Link className={linkClassName} link={data as LinkValue | undefined}>\n {children}\n </Link>\n )\n\n default:\n return <>{children}</>\n }\n}\n\nfunction Text({ marks, text = '' }: TextJSON) {\n return (\n <>\n {(marks ?? []).reduce(\n (element, mark) => (\n <Mark {...mark}>{element}</Mark>\n ),\n <>{text === '' ? '\\uFEFF' : text}</>,\n )}\n </>\n )\n}\n\nconst TYPOGRAPHY_MARK_TYPE = 'typography'\n\nfunction Mark({ type, children, data }: MarkJSON & { children: ReactNode }) {\n if (type !== TYPOGRAPHY_MARK_TYPE) return <>{children}</>\n\n return <DeviceOverrideMark value={data?.value}>{children}</DeviceOverrideMark>\n}\n\nfunction getNodeText(node: NodeJSON): string {\n switch (node.object) {\n case 'document':\n return node?.nodes?.map(node => getNodeText(node)).join('\\n') ?? ''\n\n case 'block':\n return (\n node?.nodes\n ?.map(node => getNodeText(node))\n .join(node.nodes.every(node => node.object === 'block') ? '\\n' : '') ?? ''\n )\n\n case 'inline':\n return node?.nodes?.map(node => getNodeText(node)).join('') ?? ''\n\n case 'text':\n return node.text ?? ''\n\n default:\n return ''\n }\n}\n"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","plaintext","document","getNodeText","cx","_jsx","useStyle","display","maxWidth","whiteSpace","opacity","verticalAlign","props","object","nodes","_Fragment","map","node","idx","toString","type","data","component","paragraph","blockquote","textAlign","children","linkClassName","textDecoration","marks","reduce","element","mark","TYPOGRAPHY_MARK_TYPE","DeviceOverrideMark","value","join","every"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBMA,MAAAA,eAAeC,WAAW,uBAC9B;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAMC;AAAAA,EAAOC;AAAAA,GACnBC,KACA;AACA,QAAMC,YAAYJ,8BAAMK,aAAY,OAAO,KAAKC,YAAYN,KAAKK,QAAN;AAGzD,6BAAA,OAAA;AAAA,IAAK;AAAA,IAAU;AAAA,IAAQ,WAAWE,GAAGN,OAAOC,MAAR;AAAA,IAApC,UACGE,cAAc,KAAKI,oBAAC,aAApB,EAAA,IAAqCA,oBAAC,MAASR,mBAAAA,6BAAMK,SAAhB;AAAA,EAAA,CAF1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AAA,SACN;AACII,aAAAA,yCAAMH,UAANG,mBAAaD,IAAIC,CAAQd,UAAAA,YAAYc,KAAD,GAAQmB,KAAK,UAAjDnB,YAA0D;AAAA,SAE9D;AACH,aACEA,yCAAMH,UAANG,mBACID,IAAIC,WAAQd,YAAYc,KAAD,GACxBmB,KAAKnB,KAAKH,MAAMuB,MAAMpB,WAAQA,MAAKJ,WAAW,OAAzC,IAAoD,OAAO,QAFnEI,YAE0E;AAAA,SAGzE;AACIA,aAAAA,yCAAMH,UAANG,mBAAaD,IAAIC,CAAQd,UAAAA,YAAYc,KAAD,GAAQmB,KAAK,QAAjDnB,YAAwD;AAAA,SAE5D;AACH,aAAOA,WAAKpB,SAALoB,YAAa;AAAA;AAGb,aAAA;AAAA;AAEZ;;"}
package/dist/Root.cjs.js CHANGED
@@ -15,7 +15,7 @@ require("./constants.cjs.js");
15
15
  require("redux");
16
16
  require("redux-thunk");
17
17
  require("./actions.cjs.js");
18
- require("./slot.cjs.js");
18
+ require("./rich-text.cjs.js");
19
19
  require("./control.cjs.js");
20
20
  require("./text-input.cjs.js");
21
21
  require("./combobox.cjs.js");
package/dist/Root.es.js CHANGED
@@ -14,7 +14,7 @@ import "./constants.es.js";
14
14
  import "redux";
15
15
  import "redux-thunk";
16
16
  import "./actions.es.js";
17
- import "./slot.es.js";
17
+ import "./rich-text.es.js";
18
18
  import "./control.es.js";
19
19
  import "./text-input.es.js";
20
20
  import "./combobox.es.js";
@@ -45,7 +45,7 @@ require("./constants.cjs.js");
45
45
  require("redux");
46
46
  require("redux-thunk");
47
47
  require("./actions.cjs.js");
48
- require("./slot.cjs.js");
48
+ require("./rich-text.cjs.js");
49
49
  require("./control.cjs.js");
50
50
  require("@emotion/serialize");
51
51
  require("@emotion/utils");
@@ -44,7 +44,7 @@ import "./constants.es.js";
44
44
  import "redux";
45
45
  import "redux-thunk";
46
46
  import "./actions.es.js";
47
- import "./slot.es.js";
47
+ import "./rich-text.es.js";
48
48
  import "./control.es.js";
49
49
  import "@emotion/serialize";
50
50
  import "@emotion/utils";
package/dist/Text.cjs.js CHANGED
@@ -28,7 +28,7 @@ require("./constants.cjs.js");
28
28
  require("redux");
29
29
  require("redux-thunk");
30
30
  require("./actions.cjs.js");
31
- require("./slot.cjs.js");
31
+ require("./rich-text.cjs.js");
32
32
  require("./control.cjs.js");
33
33
  require("@emotion/css");
34
34
  require("@emotion/serialize");
package/dist/Text.es.js CHANGED
@@ -26,7 +26,7 @@ import "./constants.es.js";
26
26
  import "redux";
27
27
  import "redux-thunk";
28
28
  import "./actions.es.js";
29
- import "./slot.es.js";
29
+ import "./rich-text.es.js";
30
30
  import "./control.es.js";
31
31
  import "@emotion/css";
32
32
  import "@emotion/serialize";
package/dist/Video.cjs.js CHANGED
@@ -31,7 +31,7 @@ require("./constants.cjs.js");
31
31
  require("redux");
32
32
  require("redux-thunk");
33
33
  require("./actions.cjs.js");
34
- require("./slot.cjs.js");
34
+ require("./rich-text.cjs.js");
35
35
  require("./control.cjs.js");
36
36
  require("@emotion/serialize");
37
37
  require("@emotion/utils");
package/dist/Video.es.js CHANGED
@@ -29,7 +29,7 @@ import "./constants.es.js";
29
29
  import "redux";
30
30
  import "redux-thunk";
31
31
  import "./actions.es.js";
32
- import "./slot.es.js";
32
+ import "./rich-text.es.js";
33
33
  import "./control.es.js";
34
34
  import "@emotion/serialize";
35
35
  import "@emotion/utils";
@@ -2,7 +2,7 @@
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  var controlSerialization = require("./control-serialization.cjs.js");
4
4
  require("./combobox.cjs.js");
5
- require("./slot.cjs.js");
5
+ require("./rich-text.cjs.js");
6
6
  require("./control.cjs.js");
7
7
  exports.deserializeControl = controlSerialization.deserializeControl;
8
8
  exports.deserializeControls = controlSerialization.deserializeControls;
@@ -1,5 +1,5 @@
1
1
  export { d as deserializeControl, b as deserializeControls, e as deserializeFunction, i as isSerializedFunction, s as serializeControl, a as serializeControls, c as serializeFunction } from "./control-serialization.es.js";
2
2
  import "./combobox.es.js";
3
- import "./slot.es.js";
3
+ import "./rich-text.es.js";
4
4
  import "./control.es.js";
5
5
  //# sourceMappingURL=builder.es.js.map
@@ -27,7 +27,7 @@ require("use-sync-external-store/shim/with-selector");
27
27
  require("next/dynamic");
28
28
  require("@emotion/serialize");
29
29
  require("@emotion/utils");
30
- require("./slot.cjs.js");
30
+ require("./rich-text.cjs.js");
31
31
  require("./text-input.cjs.js");
32
32
  require("./combobox.cjs.js");
33
33
  require("./control.cjs.js");
@@ -25,7 +25,7 @@ import "use-sync-external-store/shim/with-selector";
25
25
  import "next/dynamic";
26
26
  import "@emotion/serialize";
27
27
  import "@emotion/utils";
28
- import "./slot.es.js";
28
+ import "./rich-text.es.js";
29
29
  import "./text-input.es.js";
30
30
  import "./combobox.es.js";
31
31
  import "./control.es.js";