@makeswift/runtime 0.11.15 → 0.11.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1251,7 +1251,7 @@ async function fonts(_req, res, { getFonts } = {}) {
1251
1251
  const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
1252
1252
  return res.json(fonts2);
1253
1253
  }
1254
- const version = "0.11.15";
1254
+ const version = "0.11.16";
1255
1255
  async function handler(req, res, { apiKey, siteVersions }) {
1256
1256
  if (req.query.secret !== apiKey) {
1257
1257
  return res.status(401).json({ message: "Unauthorized" });
@@ -316,8 +316,10 @@ function EditableTextV2({
316
316
  }
317
317
  }, [control, editor, editMode]);
318
318
  const handleClick = React.useCallback((e) => {
319
- if (editMode === reactPage.BuilderEditMode.CONTENT)
319
+ if (editMode === reactPage.BuilderEditMode.CONTENT) {
320
320
  e.stopPropagation();
321
+ e.preventDefault();
322
+ }
321
323
  }, [editMode]);
322
324
  const handleBlur = React.useCallback((e) => {
323
325
  var _a;
@@ -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/useRemoteChanges.tsx","../src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.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 } from '../../../../../controls'\nimport { ControlValue } from '../../control'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\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 (renderElement == null) return renderFn(props)\n\n if (control == null || control.getElementValue == null)\n 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 } from '../../../../../controls'\nimport { ControlValue } from '../../control'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\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 { RichTextV2ControlData, richTextV2DataToDescendents } from '../../../../../controls'\nimport { LocalChange } from '../../../../../slate'\nimport { useIsInBuilder } from '../../..'\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 { Descendant } from 'slate'\nimport { BlockType } from '../../../../../slate'\nimport { getBaseBreakpoint, DefaultBreakpointID } from '../../../../../state/modules/breakpoints'\nimport { useBreakpoints } from '../../..'\nimport { useMemo } from 'react'\nimport { RichTextV2ControlDefinition, RichTextV2Mode } from '../../../../../controls'\n\nexport function usePresetValue(definition: RichTextV2ControlDefinition): Descendant[] {\n const breakpoints = useBreakpoints()\n return useMemo(\n () => [\n {\n type: BlockType.Default,\n children: [\n {\n text: definition.config.defaultValue ?? '',\n ...(definition.config.mode === RichTextV2Mode.Inline\n ? {}\n : {\n typography: {\n style: [\n {\n deviceId: getBaseBreakpoint(breakpoints).id,\n value: {\n fontWeight: 400,\n fontSize: { value: 18, unit: 'px' },\n lineHeight: 1.5,\n },\n },\n ...(breakpoints.some(({ id }) => id === DefaultBreakpointID.Mobile)\n ? [\n {\n deviceId: DefaultBreakpointID.Mobile,\n value: { fontSize: { value: 16, unit: 'px' } },\n },\n ]\n : []),\n ],\n },\n }),\n },\n ],\n },\n ],\n [definition.config.mode, definition.config.defaultValue, breakpoints],\n )\n}\n\nexport const defaultValue = [\n {\n type: BlockType.Default,\n children: [\n {\n text: '',\n },\n ],\n },\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 { 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 {\n BlockPlugin,\n InlineModePlugin,\n InlinePlugin,\n LinkPlugin,\n TextAlignPlugin,\n TypographyPlugin,\n withBuilder,\n withLocalChanges,\n} from '../../../../../slate'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { RichTextV2Element } from './render-element'\nimport { RichTextV2Leaf } from './render-leaf'\nimport { richTextV2DataToDescendents } from '../../../../../controls/rich-text-v2/dto'\nimport { useSyncRemoteChanges } from './useRemoteChanges'\nimport { defaultValue, usePresetValue } from './usePresetValue'\n\nexport type RichTextV2ControlValue = ReactNode\n\nexport type Descriptors = { text?: RichTextV2ControlDefinition }\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 /**\n * TODO: we are manually referencing our default plugins for each mode here because\n * Referencing the real LinkPlugin causes a circular dependency.\n * When circular dependencies calm down we should update the plugin definition to use real plugins,\n * and just use the plugins that are defined by our config.\n */\n // ...(definition?.config?.plugins ?? []),\n ...(definition?.config?.mode === RichTextV2Mode.Inline\n ? [InlineModePlugin()]\n : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]),\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 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 // ------ Preserving selection ------\n\n const isPreservingFocus = useRef(false)\n useSyncDOMSelection(editor, isPreservingFocus)\n const editMode = useBuilderEditMode()\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 // ------ Syncing remote changes ------\n\n useSyncRemoteChanges(editor, text)\n\n // ------ Default value ------\n\n const presetValue = usePresetValue(definition)\n\n const initialValue = useMemo(\n () => (text && richTextV2DataToDescendents(text)) ?? presetValue,\n [text, presetValue],\n )\n\n useEffect(() => {\n control?.setEditor(editor)\n control?.setDefaultValue(defaultValue)\n }, [control, editor])\n\n /**\n * When initialValue is set to the default value we need to trigger an local change so that the sidebar updates and so the data is saved\n */\n useEffect(() => {\n if (initialValue === presetValue) {\n control?.onLocalUserChange()\n }\n }, [control, initialValue, presetValue])\n\n // ------ Rendering ------\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 // ------ Event handlers ------\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 control?.redo()\n if (isHotkey('mod+z', e)) return control?.undo()\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","breakpoints","useBreakpoints","useMemo","type","BlockType","Default","text","config","defaultValue","mode","RichTextV2Mode","Inline","typography","style","deviceId","getBaseBreakpoint","id","fontWeight","fontSize","unit","lineHeight","some","DefaultBreakpointID","Mobile","InlineModePlugin","BlockPlugin","TypographyPlugin","TextAlignPlugin","InlinePlugin","LinkPlugin","useState","reduceRight","withPlugin","withLocalChanges","withBuilder","withReact","createEditor","toDOMNode","pollBoxModel","onBoxModelChange","boxModel","changeBoxModel","isPreservingFocus","useRef","useSyncDOMSelection","editMode","useBuilderEditMode","BuilderEditMode","CONTENT","deselect","useSyncRemoteChanges","presetValue","usePresetValue","initialValue","setEditor","setDefaultValue","onLocalUserChange","useCallback","handleFocus","select","handleKeyDown","isHotkey","redo","undo","blur","switchToBuildMode","stopPropagation","forEach","onKeyDown","handleKeyUp","preventDefault","handleClick","handleBlur","relatedTarget","getAttribute","Slate","Editable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,6BAA6BA,QAAgBC,WAAsC;AACxFC,4BAAAA,0BAA0B,MAAM;AAC1B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sx","../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/usePresetValue.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 } from '../../../../../controls'\nimport { ControlValue } from '../../control'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\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 (renderElement == null) return renderFn(props)\n\n if (control == null || control.getElementValue == null)\n 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 } from '../../../../../controls'\nimport { ControlValue } from '../../control'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\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 { RichTextV2ControlData, richTextV2DataToDescendents } from '../../../../../controls'\nimport { LocalChange } from '../../../../../slate'\nimport { useIsInBuilder } from '../../..'\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 { Descendant } from 'slate'\nimport { BlockType } from '../../../../../slate'\nimport { getBaseBreakpoint, DefaultBreakpointID } from '../../../../../state/modules/breakpoints'\nimport { useBreakpoints } from '../../..'\nimport { useMemo } from 'react'\nimport { RichTextV2ControlDefinition, RichTextV2Mode } from '../../../../../controls'\n\nexport function usePresetValue(definition: RichTextV2ControlDefinition): Descendant[] {\n const breakpoints = useBreakpoints()\n return useMemo(\n () => [\n {\n type: BlockType.Default,\n children: [\n {\n text: definition.config.defaultValue ?? '',\n ...(definition.config.mode === RichTextV2Mode.Inline\n ? {}\n : {\n typography: {\n style: [\n {\n deviceId: getBaseBreakpoint(breakpoints).id,\n value: {\n fontWeight: 400,\n fontSize: { value: 18, unit: 'px' },\n lineHeight: 1.5,\n },\n },\n ...(breakpoints.some(({ id }) => id === DefaultBreakpointID.Mobile)\n ? [\n {\n deviceId: DefaultBreakpointID.Mobile,\n value: { fontSize: { value: 16, unit: 'px' } },\n },\n ]\n : []),\n ],\n },\n }),\n },\n ],\n },\n ],\n [definition.config.mode, definition.config.defaultValue, breakpoints],\n )\n}\n\nexport const defaultValue = [\n {\n type: BlockType.Default,\n children: [\n {\n text: '',\n },\n ],\n },\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 { 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 {\n BlockPlugin,\n InlineModePlugin,\n InlinePlugin,\n LinkPlugin,\n TextAlignPlugin,\n TypographyPlugin,\n withBuilder,\n withLocalChanges,\n} from '../../../../../slate'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { RichTextV2Element } from './render-element'\nimport { RichTextV2Leaf } from './render-leaf'\nimport { richTextV2DataToDescendents } from '../../../../../controls/rich-text-v2/dto'\nimport { useSyncRemoteChanges } from './useRemoteChanges'\nimport { defaultValue, usePresetValue } from './usePresetValue'\n\nexport type RichTextV2ControlValue = ReactNode\n\nexport type Descriptors = { text?: RichTextV2ControlDefinition }\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 /**\n * TODO: we are manually referencing our default plugins for each mode here because\n * Referencing the real LinkPlugin causes a circular dependency.\n * When circular dependencies calm down we should update the plugin definition to use real plugins,\n * and just use the plugins that are defined by our config.\n */\n // ...(definition?.config?.plugins ?? []),\n ...(definition?.config?.mode === RichTextV2Mode.Inline\n ? [InlineModePlugin()]\n : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]),\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 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 // ------ Preserving selection ------\n\n const isPreservingFocus = useRef(false)\n useSyncDOMSelection(editor, isPreservingFocus)\n const editMode = useBuilderEditMode()\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 // ------ Syncing remote changes ------\n\n useSyncRemoteChanges(editor, text)\n\n // ------ Default value ------\n\n const presetValue = usePresetValue(definition)\n\n const initialValue = useMemo(\n () => (text && richTextV2DataToDescendents(text)) ?? presetValue,\n [text, presetValue],\n )\n\n useEffect(() => {\n control?.setEditor(editor)\n control?.setDefaultValue(defaultValue)\n }, [control, editor])\n\n /**\n * When initialValue is set to the default value we need to trigger an local change so that the sidebar updates and so the data is saved\n */\n useEffect(() => {\n if (initialValue === presetValue) {\n control?.onLocalUserChange()\n }\n }, [control, initialValue, presetValue])\n\n // ------ Rendering ------\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 // ------ Event handlers ------\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 control?.redo()\n if (isHotkey('mod+z', e)) return control?.undo()\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){\n e.stopPropagation()\n e.preventDefault()\n }\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","breakpoints","useBreakpoints","useMemo","type","BlockType","Default","text","config","defaultValue","mode","RichTextV2Mode","Inline","typography","style","deviceId","getBaseBreakpoint","id","fontWeight","fontSize","unit","lineHeight","some","DefaultBreakpointID","Mobile","InlineModePlugin","BlockPlugin","TypographyPlugin","TextAlignPlugin","InlinePlugin","LinkPlugin","useState","reduceRight","withPlugin","withLocalChanges","withBuilder","withReact","createEditor","toDOMNode","pollBoxModel","onBoxModelChange","boxModel","changeBoxModel","isPreservingFocus","useRef","useSyncDOMSelection","editMode","useBuilderEditMode","BuilderEditMode","CONTENT","deselect","useSyncRemoteChanges","presetValue","usePresetValue","initialValue","setEditor","setDefaultValue","onLocalUserChange","useCallback","handleFocus","select","handleKeyDown","isHotkey","redo","undo","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,yBAAyBR,MAArC;AACPS,YAAAA,eAAeF,KAAKG;AAC1B,YAAMC,cAA4BN,WAAAA,YAAYO,WAAWZ,QAAQA,OAAOI,SAAtC;AAElC,UAAIO,aAAa;AACf,YAAIE,YAAWC,WAAWd,OAAOI,SAA7B,GAA0C;AAC9BW,uDAAAA,iBACZJ,YAAYK,cACZL,YAAYM,WACZN,YAAYO,gBACZP,YAAYQ;AAAAA,QAJd,OAMK;AACSJ,uDAAAA,iBACZJ,YAAYO,gBACZP,YAAYQ,aACZR,YAAYK,cACZL,YAAYM;AAAAA,QAEf;AAAA,MAAA,OACI;AACLR,qDAAcW;AAAAA,MACf;AAAA,aACMC;AACPC,cAAQC,MAAMF,CAAd;AAAA,IACD;AAAA,EAAA,CA5BsB;AA8B1B;AC/BiC,2BAAA,IAA2D;AAA3D,eAAEG;AAAAA;AAAAA,IAAYC;AAAAA,MAAd,IAA0BC,kBAA1B,IAA0BA;AAAAA,IAAxBF;AAAAA,IAAYC;AAAAA;AAC9C,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QAAI/G,SAAE+G,kBAAF/G,mBAAiBgH,aAAa,wBAAuB;AACvDhC,wBAAkBlG,UAAU;AAAA,EAC/B,GAAE,CAN2B,CAAA;AAQ9B,wCACGmI,WAAAA,OAAD;AAAA,IAAO;AAAA,IAAgB,OAAOtB;AAAAA,IAA9B,yCACGuB,qBAAD;AAAA,MACE;AAAA,MACA;AAAA,MACA,SAASlB;AAAAA,MACT,WAAWE;AAAAA,MACX,SAASS;AAAAA,MACT,SAASE;AAAAA,MACT,QAAQC;AAAAA,MACR,UAAU3B,aAAaE,UAAAA,gBAAgBC;AAAAA,MACvC,aAAY;AAAA,IAAA,CATd;AAAA,EAAA,CAFJ;AAeD;;;"}
package/dist/index.es.js CHANGED
@@ -1218,7 +1218,7 @@ async function fonts(_req, res, { getFonts } = {}) {
1218
1218
  const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
1219
1219
  return res.json(fonts2);
1220
1220
  }
1221
- const version = "0.11.15";
1221
+ const version = "0.11.16";
1222
1222
  async function handler(req, res, { apiKey, siteVersions }) {
1223
1223
  if (req.query.secret !== apiKey) {
1224
1224
  return res.status(401).json({ message: "Unauthorized" });
package/dist/index.es9.js CHANGED
@@ -310,8 +310,10 @@ function EditableTextV2({
310
310
  }
311
311
  }, [control, editor, editMode]);
312
312
  const handleClick = useCallback((e) => {
313
- if (editMode === BuilderEditMode.CONTENT)
313
+ if (editMode === BuilderEditMode.CONTENT) {
314
314
  e.stopPropagation();
315
+ e.preventDefault();
316
+ }
315
317
  }, [editMode]);
316
318
  const handleBlur = useCallback((e) => {
317
319
  var _a;
@@ -1 +1 @@
1
- {"version":3,"file":"index.es9.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/usePresetValue.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 } from '../../../../../controls'\nimport { ControlValue } from '../../control'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\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 (renderElement == null) return renderFn(props)\n\n if (control == null || control.getElementValue == null)\n 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 } from '../../../../../controls'\nimport { ControlValue } from '../../control'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\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 { RichTextV2ControlData, richTextV2DataToDescendents } from '../../../../../controls'\nimport { LocalChange } from '../../../../../slate'\nimport { useIsInBuilder } from '../../..'\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 { Descendant } from 'slate'\nimport { BlockType } from '../../../../../slate'\nimport { getBaseBreakpoint, DefaultBreakpointID } from '../../../../../state/modules/breakpoints'\nimport { useBreakpoints } from '../../..'\nimport { useMemo } from 'react'\nimport { RichTextV2ControlDefinition, RichTextV2Mode } from '../../../../../controls'\n\nexport function usePresetValue(definition: RichTextV2ControlDefinition): Descendant[] {\n const breakpoints = useBreakpoints()\n return useMemo(\n () => [\n {\n type: BlockType.Default,\n children: [\n {\n text: definition.config.defaultValue ?? '',\n ...(definition.config.mode === RichTextV2Mode.Inline\n ? {}\n : {\n typography: {\n style: [\n {\n deviceId: getBaseBreakpoint(breakpoints).id,\n value: {\n fontWeight: 400,\n fontSize: { value: 18, unit: 'px' },\n lineHeight: 1.5,\n },\n },\n ...(breakpoints.some(({ id }) => id === DefaultBreakpointID.Mobile)\n ? [\n {\n deviceId: DefaultBreakpointID.Mobile,\n value: { fontSize: { value: 16, unit: 'px' } },\n },\n ]\n : []),\n ],\n },\n }),\n },\n ],\n },\n ],\n [definition.config.mode, definition.config.defaultValue, breakpoints],\n )\n}\n\nexport const defaultValue = [\n {\n type: BlockType.Default,\n children: [\n {\n text: '',\n },\n ],\n },\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 { 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 {\n BlockPlugin,\n InlineModePlugin,\n InlinePlugin,\n LinkPlugin,\n TextAlignPlugin,\n TypographyPlugin,\n withBuilder,\n withLocalChanges,\n} from '../../../../../slate'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { RichTextV2Element } from './render-element'\nimport { RichTextV2Leaf } from './render-leaf'\nimport { richTextV2DataToDescendents } from '../../../../../controls/rich-text-v2/dto'\nimport { useSyncRemoteChanges } from './useRemoteChanges'\nimport { defaultValue, usePresetValue } from './usePresetValue'\n\nexport type RichTextV2ControlValue = ReactNode\n\nexport type Descriptors = { text?: RichTextV2ControlDefinition }\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 /**\n * TODO: we are manually referencing our default plugins for each mode here because\n * Referencing the real LinkPlugin causes a circular dependency.\n * When circular dependencies calm down we should update the plugin definition to use real plugins,\n * and just use the plugins that are defined by our config.\n */\n // ...(definition?.config?.plugins ?? []),\n ...(definition?.config?.mode === RichTextV2Mode.Inline\n ? [InlineModePlugin()]\n : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]),\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 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 // ------ Preserving selection ------\n\n const isPreservingFocus = useRef(false)\n useSyncDOMSelection(editor, isPreservingFocus)\n const editMode = useBuilderEditMode()\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 // ------ Syncing remote changes ------\n\n useSyncRemoteChanges(editor, text)\n\n // ------ Default value ------\n\n const presetValue = usePresetValue(definition)\n\n const initialValue = useMemo(\n () => (text && richTextV2DataToDescendents(text)) ?? presetValue,\n [text, presetValue],\n )\n\n useEffect(() => {\n control?.setEditor(editor)\n control?.setDefaultValue(defaultValue)\n }, [control, editor])\n\n /**\n * When initialValue is set to the default value we need to trigger an local change so that the sidebar updates and so the data is saved\n */\n useEffect(() => {\n if (initialValue === presetValue) {\n control?.onLocalUserChange()\n }\n }, [control, initialValue, presetValue])\n\n // ------ Rendering ------\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 // ------ Event handlers ------\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 control?.redo()\n if (isHotkey('mod+z', e)) return control?.undo()\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","element","value","initialRenderElement","attributes","leaf","className","renderLeaf","getLeafValue","initialRenderLeaf","change","performance","now","time","data","isInBuilder","useIsInBuilder","useEffect","isChangeWithinPreviousSec","localChanges","get","key","richTextV2DataToDescendents","onChange","breakpoints","useBreakpoints","useMemo","type","BlockType","Default","text","config","defaultValue","mode","RichTextV2Mode","Inline","typography","style","deviceId","getBaseBreakpoint","id","fontWeight","fontSize","unit","lineHeight","some","DefaultBreakpointID","Mobile","InlineModePlugin","BlockPlugin","TypographyPlugin","TextAlignPlugin","InlinePlugin","LinkPlugin","useState","reduceRight","withPlugin","withLocalChanges","withBuilder","withReact","createEditor","toDOMNode","pollBoxModel","onBoxModelChange","boxModel","changeBoxModel","isPreservingFocus","useRef","useSyncDOMSelection","editMode","useBuilderEditMode","BuilderEditMode","CONTENT","deselect","useSyncRemoteChanges","presetValue","usePresetValue","initialValue","setEditor","setDefaultValue","onLocalUserChange","useCallback","handleFocus","select","handleKeyDown","isHotkey","redo","undo","blur","switchToBuildMode","stopPropagation","forEach","onKeyDown","handleKeyUp","preventDefault","handleClick","handleBlur","relatedTarget","getAttribute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,6BAA6BA,QAAgBC,WAAsC;AACxFC,4BAA0B,MAAM;AAC1B,QAAA,CAACD,UAAUE,WAAWH,OAAOI,aAAa,QAAQC,YAAYC,UAAUN,MAAtB;AAA+B;AACjF,QAAA;AACIO,YAAAA,OAAOF,YAAYG,yBAAyBR,MAArC;AACPS,YAAAA,eAAeF,KAAKG;AAC1B,YAAMC,cAA4BN,YAAYO,WAAWZ,QAAQA,OAAOI,SAAtC;AAElC,UAAIO,aAAa;AACf,YAAIE,MAAWC,WAAWd,OAAOI,SAA7B,GAA0C;AAC9BW,uDAAAA,iBACZJ,YAAYK,cACZL,YAAYM,WACZN,YAAYO,gBACZP,YAAYQ;AAAAA,QAJd,OAMK;AACSJ,uDAAAA,iBACZJ,YAAYO,gBACZP,YAAYQ,aACZR,YAAYK,cACZL,YAAYM;AAAAA,QAEf;AAAA,MAAA,OACI;AACLR,qDAAcW;AAAAA,MACf;AAAA,aACMC;AACPC,cAAQC,MAAMF,CAAd;AAAA,IACD;AAAA,EAAA,CA5BsB;AA8B1B;AC/BiC,2BAAA,IAA2D;AAA3D,eAAEG;AAAAA;AAAAA,IAAYC;AAAAA,MAAd,IAA0BC,kBAA1B,IAA0BA;AAAAA,IAAxBF;AAAAA,IAAYC;AAAAA;AAC9C,gCAA8BC,QAA2B;AACvD,WAAOA,OAAMC;AAAAA,EACd;AAED,QAAMC,gBAAgBH,QAAQI,OAC5B,CAACC,UAAUC,WAAW,CAACL,WAA8B;AAC7C,UAAA;AAAA,MAAEM;AAAAA,MAASJ,eAAAA;AAAAA,QAAkBG;AAEnC,QAAIH,kBAAiB;AAAM,aAAOE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AYqH,KAAK1H,MAAjB;AACAgC,yCAAS2F;AAAAA,IACV;AAEGpB,QAAAA,aAAaE,gBAAgBC,SAAS;AACxCrF,QAAEuG,gBAAF;AAAA,IACD;AAEDnG,YAAQoG,QAAQ9F,CAAUA,WAAAA;;AAAAA,oDAAQ+F,cAAR/F,gCAAoBV,GAAGrB;AAAAA,KAAjD;AAAA,KAEF,CAACgC,SAASP,SAASzB,QAAQuG,QAA3B,CAhB+B;AAmB3BwB,QAAAA,cAAcZ,YAClB,CAAC9F,MAAqB;AAChBkF,QAAAA,aAAaE,gBAAgBC,SAAS;AACxCrF,QAAEuG,gBAAF;AACAvG,QAAE2G,eAAF;AAAA,IACD;AAAA,EAEH,GAAA,CAAChG,SAAShC,QAAQuG,QAAlB,CAP6B;AAUzB0B,QAAAA,cAAcd,YAClB,CAAC9F,MAAkB;AACjB,QAAIkF,aAAaE,gBAAgBC;AAASrF,QAAEuG,gBAAF;AAAA,EAAA,GAE5C,CAACrB,QAAD,CAJ6B;AAOzB2B,QAAAA,aAAaf,YAAY,CAAC9F,MAAkB;;AAEhD,QAAIA,EAAE8G,iBAAiB;AAAM;AAE7B,QAAI9G,SAAE8G,kBAAF9G,mBAAiB+G,aAAa,wBAAuB;AACvDhC,wBAAkBjG,UAAU;AAAA,EAC/B,GAAE,CAN2B,CAAA;AAQ9B,6BACG,OAAD;AAAA,IAAO;AAAA,IAAgB,OAAO4G;AAAAA,IAA9B,8BACG,UAAD;AAAA,MACE;AAAA,MACA;AAAA,MACA,SAASK;AAAAA,MACT,WAAWE;AAAAA,MACX,SAASS;AAAAA,MACT,SAASE;AAAAA,MACT,QAAQC;AAAAA,MACR,UAAU3B,aAAaE,gBAAgBC;AAAAA,MACvC,aAAY;AAAA,IAAA,CATd;AAAA,EAAA,CAFJ;AAeD;;"}
1
+ {"version":3,"file":"index.es9.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/usePresetValue.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 } from '../../../../../controls'\nimport { ControlValue } from '../../control'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\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 (renderElement == null) return renderFn(props)\n\n if (control == null || control.getElementValue == null)\n 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 } from '../../../../../controls'\nimport { ControlValue } from '../../control'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\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 { RichTextV2ControlData, richTextV2DataToDescendents } from '../../../../../controls'\nimport { LocalChange } from '../../../../../slate'\nimport { useIsInBuilder } from '../../..'\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 { Descendant } from 'slate'\nimport { BlockType } from '../../../../../slate'\nimport { getBaseBreakpoint, DefaultBreakpointID } from '../../../../../state/modules/breakpoints'\nimport { useBreakpoints } from '../../..'\nimport { useMemo } from 'react'\nimport { RichTextV2ControlDefinition, RichTextV2Mode } from '../../../../../controls'\n\nexport function usePresetValue(definition: RichTextV2ControlDefinition): Descendant[] {\n const breakpoints = useBreakpoints()\n return useMemo(\n () => [\n {\n type: BlockType.Default,\n children: [\n {\n text: definition.config.defaultValue ?? '',\n ...(definition.config.mode === RichTextV2Mode.Inline\n ? {}\n : {\n typography: {\n style: [\n {\n deviceId: getBaseBreakpoint(breakpoints).id,\n value: {\n fontWeight: 400,\n fontSize: { value: 18, unit: 'px' },\n lineHeight: 1.5,\n },\n },\n ...(breakpoints.some(({ id }) => id === DefaultBreakpointID.Mobile)\n ? [\n {\n deviceId: DefaultBreakpointID.Mobile,\n value: { fontSize: { value: 16, unit: 'px' } },\n },\n ]\n : []),\n ],\n },\n }),\n },\n ],\n },\n ],\n [definition.config.mode, definition.config.defaultValue, breakpoints],\n )\n}\n\nexport const defaultValue = [\n {\n type: BlockType.Default,\n children: [\n {\n text: '',\n },\n ],\n },\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 { 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 {\n BlockPlugin,\n InlineModePlugin,\n InlinePlugin,\n LinkPlugin,\n TextAlignPlugin,\n TypographyPlugin,\n withBuilder,\n withLocalChanges,\n} from '../../../../../slate'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { RichTextV2Element } from './render-element'\nimport { RichTextV2Leaf } from './render-leaf'\nimport { richTextV2DataToDescendents } from '../../../../../controls/rich-text-v2/dto'\nimport { useSyncRemoteChanges } from './useRemoteChanges'\nimport { defaultValue, usePresetValue } from './usePresetValue'\n\nexport type RichTextV2ControlValue = ReactNode\n\nexport type Descriptors = { text?: RichTextV2ControlDefinition }\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 /**\n * TODO: we are manually referencing our default plugins for each mode here because\n * Referencing the real LinkPlugin causes a circular dependency.\n * When circular dependencies calm down we should update the plugin definition to use real plugins,\n * and just use the plugins that are defined by our config.\n */\n // ...(definition?.config?.plugins ?? []),\n ...(definition?.config?.mode === RichTextV2Mode.Inline\n ? [InlineModePlugin()]\n : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]),\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 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 // ------ Preserving selection ------\n\n const isPreservingFocus = useRef(false)\n useSyncDOMSelection(editor, isPreservingFocus)\n const editMode = useBuilderEditMode()\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 // ------ Syncing remote changes ------\n\n useSyncRemoteChanges(editor, text)\n\n // ------ Default value ------\n\n const presetValue = usePresetValue(definition)\n\n const initialValue = useMemo(\n () => (text && richTextV2DataToDescendents(text)) ?? presetValue,\n [text, presetValue],\n )\n\n useEffect(() => {\n control?.setEditor(editor)\n control?.setDefaultValue(defaultValue)\n }, [control, editor])\n\n /**\n * When initialValue is set to the default value we need to trigger an local change so that the sidebar updates and so the data is saved\n */\n useEffect(() => {\n if (initialValue === presetValue) {\n control?.onLocalUserChange()\n }\n }, [control, initialValue, presetValue])\n\n // ------ Rendering ------\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 // ------ Event handlers ------\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 control?.redo()\n if (isHotkey('mod+z', e)) return control?.undo()\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){\n e.stopPropagation()\n e.preventDefault()\n }\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","element","value","initialRenderElement","attributes","leaf","className","renderLeaf","getLeafValue","initialRenderLeaf","change","performance","now","time","data","isInBuilder","useIsInBuilder","useEffect","isChangeWithinPreviousSec","localChanges","get","key","richTextV2DataToDescendents","onChange","breakpoints","useBreakpoints","useMemo","type","BlockType","Default","text","config","defaultValue","mode","RichTextV2Mode","Inline","typography","style","deviceId","getBaseBreakpoint","id","fontWeight","fontSize","unit","lineHeight","some","DefaultBreakpointID","Mobile","InlineModePlugin","BlockPlugin","TypographyPlugin","TextAlignPlugin","InlinePlugin","LinkPlugin","useState","reduceRight","withPlugin","withLocalChanges","withBuilder","withReact","createEditor","toDOMNode","pollBoxModel","onBoxModelChange","boxModel","changeBoxModel","isPreservingFocus","useRef","useSyncDOMSelection","editMode","useBuilderEditMode","BuilderEditMode","CONTENT","deselect","useSyncRemoteChanges","presetValue","usePresetValue","initialValue","setEditor","setDefaultValue","onLocalUserChange","useCallback","handleFocus","select","handleKeyDown","isHotkey","redo","undo","blur","switchToBuildMode","stopPropagation","forEach","onKeyDown","handleKeyUp","preventDefault","handleClick","handleBlur","relatedTarget","getAttribute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,6BAA6BA,QAAgBC,WAAsC;AACxFC,4BAA0B,MAAM;AAC1B,QAAA,CAACD,UAAUE,WAAWH,OAAOI,aAAa,QAAQC,YAAYC,UAAUN,MAAtB;AAA+B;AACjF,QAAA;AACIO,YAAAA,OAAOF,YAAYG,yBAAyBR,MAArC;AACPS,YAAAA,eAAeF,KAAKG;AAC1B,YAAMC,cAA4BN,YAAYO,WAAWZ,QAAQA,OAAOI,SAAtC;AAElC,UAAIO,aAAa;AACf,YAAIE,MAAWC,WAAWd,OAAOI,SAA7B,GAA0C;AAC9BW,uDAAAA,iBACZJ,YAAYK,cACZL,YAAYM,WACZN,YAAYO,gBACZP,YAAYQ;AAAAA,QAJd,OAMK;AACSJ,uDAAAA,iBACZJ,YAAYO,gBACZP,YAAYQ,aACZR,YAAYK,cACZL,YAAYM;AAAAA,QAEf;AAAA,MAAA,OACI;AACLR,qDAAcW;AAAAA,MACf;AAAA,aACMC;AACPC,cAAQC,MAAMF,CAAd;AAAA,IACD;AAAA,EAAA,CA5BsB;AA8B1B;AC/BiC,2BAAA,IAA2D;AAA3D,eAAEG;AAAAA;AAAAA,IAAYC;AAAAA,MAAd,IAA0BC,kBAA1B,IAA0BA;AAAAA,IAAxBF;AAAAA,IAAYC;AAAAA;AAC9C,gCAA8BC,QAA2B;AACvD,WAAOA,OAAMC;AAAAA,EACd;AAED,QAAMC,gBAAgBH,QAAQI,OAC5B,CA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,aAAY;AAAA,IAAA,CATd;AAAA,EAAA,CAFJ;AAeD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"editable-text-v2.d.ts","sourceRoot":"","sources":["../../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EAMV,MAAM,OAAO,CAAA;AAYd,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,EAE5B,MAAM,yBAAyB,CAAA;AAqBhC,MAAM,MAAM,sBAAsB,GAAG,SAAS,CAAA;AAE9C,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,CAAC,EAAE,2BAA2B,CAAA;CAAE,CAAA;AAEhE,KAAK,KAAK,GAAG;IACX,IAAI,CAAC,EAAE,qBAAqB,CAAA;IAC5B,UAAU,EAAE,2BAA2B,CAAA;IACvC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAA;CAClC,CAAA;AAED,wBAAgB,cAAc,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,KAAK,2CAiKlE;AAED,eAAe,cAAc,CAAA"}
1
+ {"version":3,"file":"editable-text-v2.d.ts","sourceRoot":"","sources":["../../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EAMV,MAAM,OAAO,CAAA;AAYd,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,EAE5B,MAAM,yBAAyB,CAAA;AAqBhC,MAAM,MAAM,sBAAsB,GAAG,SAAS,CAAA;AAE9C,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,CAAC,EAAE,2BAA2B,CAAA;CAAE,CAAA;AAEhE,KAAK,KAAK,GAAG;IACX,IAAI,CAAC,EAAE,qBAAqB,CAAA;IAC5B,UAAU,EAAE,2BAA2B,CAAA;IACvC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAA;CAClC,CAAA;AAED,wBAAgB,cAAc,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,KAAK,2CAoKlE;AAED,eAAe,cAAc,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makeswift/runtime",
3
- "version": "0.11.15",
3
+ "version": "0.11.16",
4
4
  "license": "MIT",
5
5
  "main": "dist/main.cjs",
6
6
  "module": "dist/main.es",