@makeswift/runtime 0.0.0-20230322205328 → 0.0.0-20230323134605

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/Text.cjs.js CHANGED
@@ -769,25 +769,24 @@ const EditableText = React.forwardRef(function EditableText2({
769
769
  const editMode = next.useBuilderEditMode();
770
770
  const [propControllers, setPropControllers] = React.useState(null);
771
771
  const controller = propControllers == null ? void 0 : propControllers.text;
772
+ const [nextEditor, setEditor] = React.useState(null);
772
773
  React.useImperativeHandle(ref, () => ({
773
774
  getDomNode() {
774
- return slateReact.ReactEditor.toDOMNode(editor, editor);
775
+ return nextEditor ? slateReact.ReactEditor.toDOMNode(nextEditor, nextEditor) : null;
775
776
  },
776
777
  getBoxModel() {
777
- return boxModels.getBox(slateReact.ReactEditor.toDOMNode(editor, editor));
778
+ return nextEditor ? boxModels.getBox(slateReact.ReactEditor.toDOMNode(nextEditor, nextEditor)) : null;
778
779
  },
779
780
  setPropControllers: (value) => {
780
781
  console.log("setPropControllers", value);
781
782
  setPropControllers(value);
782
783
  }
783
- }), [editor, setPropControllers]);
784
+ }), [nextEditor, setPropControllers]);
785
+ React.useEffect(() => {
786
+ setEditor(editor);
787
+ }, []);
784
788
  const initialValue = React.useMemo(() => text ? richText.richTextDTOtoDAO(text) : defaultText, [text]);
785
789
  React.useEffect(() => {
786
- console.log("initialize setSlateEditor with", {
787
- propControllers,
788
- controller,
789
- editor
790
- });
791
790
  controller == null ? void 0 : controller.setSlateEditor(editor);
792
791
  }, [controller, editor]);
793
792
  const handleFocus = React.useCallback(() => {
@@ -802,11 +801,6 @@ const EditableText = React.forwardRef(function EditableText2({
802
801
  return controller == null ? void 0 : controller.blur();
803
802
  onKeyDown(e, editor);
804
803
  }, [controller, editor]);
805
- console.log("render", {
806
- propControllers,
807
- controller,
808
- editor
809
- });
810
804
  return /* @__PURE__ */ jsxRuntime.jsx(slateReact.Slate, {
811
805
  editor,
812
806
  value: initialValue,
@@ -1 +1 @@
1
- {"version":3,"file":"Text.cjs.js","sources":["../src/components/builtin/Text/EditableText/Leaf/typography.tsx","../src/components/builtin/Text/EditableText/Leaf/leaf.tsx","../src/components/builtin/Text/EditableText/Element/block.tsx","../src/components/builtin/Text/EditableText/Element/inline.tsx","../src/components/builtin/Text/EditableText/Element/element.tsx","../src/components/builtin/Text/EditableText/useSyncWithBuilder.tsx","../src/components/builtin/Text/EditableText/ListPlugin/lib/utils/element.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/wrapList.ts","../src/components/builtin/Text/EditableText/ListPlugin/constants.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/utils/editor.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/utils/filterForSubtreeRoots.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/utils/location.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/utils/getSelectedListItems.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/unwrapList.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/toggleList.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/indent.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/dedent.ts","../src/components/builtin/Text/EditableText/ListPlugin/ListPlugin.ts","../src/components/builtin/Text/EditableText/editable-text.tsx","../src/components/builtin/Text/Text.tsx"],"sourcesContent":["import { CSSObject } from '@emotion/serialize'\nimport { RenderLeafProps } from 'slate-react'\nimport { Swatch, Typography } from '../../../../../api'\nimport { TypographyText } from '../../../../../controls'\nimport { DeviceOverride, ResponsiveValue } from '../../../../../prop-controllers'\nimport { getTypographyStyleSwatchIds } from '../../../../../prop-controllers/introspection'\nimport { useTypography, useSwatches } from '../../../../../runtimes/react/hooks/makeswift-api'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { colorToString } from '../../../../utils/colorToString'\nimport { findDeviceOverride, shallowMergeFallbacks } from '../../../../utils/devices'\nimport { isNonNullable } from '../../../../utils/isNonNullable'\nimport { responsiveStyle } from '../../../../utils/responsive-style'\nimport { ColorValue } from '../../../../utils/types'\n\nexport type TypographyValue = Typography['style'][number]['value']\n\ntype EnhancedColor = {\n color?: ColorValue\n}\n\ntype EnhancedTypographyValue = Omit<TypographyValue, keyof EnhancedColor> & EnhancedColor\n\nexport type EnhancedTypography = Array<DeviceOverride<EnhancedTypographyValue>>\n\nexport function isDeviceOverride(value: {\n deviceId: string\n value: TypographyValue\n}): value is DeviceOverride<TypographyValue> {\n return value.deviceId === 'desktop' || value.deviceId === 'tablet' || value.deviceId === 'mobile'\n}\n\nconst withColor =\n (swatches: Swatch[]) =>\n (\n deviceRawTypographyValue: DeviceOverride<TypographyValue>,\n ): DeviceOverride<EnhancedTypographyValue> => {\n const { value, deviceId } = deviceRawTypographyValue\n\n if (value.color == null) {\n const { color, ...nextValue } = value\n return {\n deviceId,\n value: nextValue,\n }\n }\n return {\n deviceId,\n value: {\n ...value,\n color: {\n swatch: swatches.find(s => s && s.id === value.color?.swatchId),\n alpha: value.color?.alpha ?? undefined,\n },\n },\n }\n }\n\nconst getDeviceId = ({ deviceId }: DeviceOverride<unknown>) => deviceId\n\nexport default function useEnhancedTypography(value: Typography): EnhancedTypography {\n const typography = useTypography(value?.id ?? null)\n const source = typography?.style.filter(isDeviceOverride) ?? []\n const override = value?.style.filter(isDeviceOverride) ?? []\n\n const swatchIds = [\n ...getTypographyStyleSwatchIds(value?.style),\n ...getTypographyStyleSwatchIds(typography?.style),\n ]\n const swatches = useSwatches(swatchIds).filter(isNonNullable)\n\n const enhancedSource = source.map(withColor(swatches))\n const enhancedOverride = override.map(withColor(swatches))\n\n const devices = [\n ...new Set(enhancedSource.map(getDeviceId).concat(enhancedOverride.map(getDeviceId))),\n ]\n\n return devices\n .map(deviceId => {\n const deviceSource = findDeviceOverride(enhancedSource, deviceId)?.value\n const deviceOverride = findDeviceOverride(enhancedOverride, deviceId)?.value\n\n if (deviceSource && deviceOverride) {\n return {\n deviceId,\n value: { ...deviceSource, ...deviceOverride },\n }\n } else if (deviceOverride) {\n return {\n deviceId,\n value: deviceOverride,\n }\n } else if (deviceSource) {\n return {\n deviceId,\n value: deviceSource,\n }\n }\n return null\n })\n .filter(isNonNullable)\n}\n\nexport function useTypographyClassName(value: EnhancedTypography): string {\n return useStyle(\n responsiveStyle<\n EnhancedTypographyValue,\n [ResponsiveValue<EnhancedTypographyValue> | null | undefined]\n >(\n [value],\n ([value]) => {\n if (value === undefined) return {}\n\n let styles: CSSObject = {}\n if (value.color != null) styles.color = colorToString(value.color)\n if (value.fontFamily != null) styles.fontFamily = value.fontFamily\n if (value.fontSize != null && value.fontSize.value != null && value.fontSize.unit != null)\n styles.fontSize = `${value.fontSize.value}${value.fontSize.unit}`\n if (value.fontWeight != null) styles.fontWeight = value.fontWeight\n if (value.lineHeight != null) styles.lineHeight = value.lineHeight\n if (value.letterSpacing != null) styles.letterSpacing = `${value.letterSpacing / 10}em`\n if (value.uppercase != null)\n styles.textTransform = value.uppercase === true ? 'uppercase' : 'initial'\n if (value.underline != null || value.strikethrough != null)\n styles.textDecoration = [\n Boolean(value.underline) && 'underline',\n Boolean(value.strikethrough) && 'line-through',\n ]\n .filter(Boolean)\n .join(' ')\n if (value.italic != null) styles.fontStyle = value.italic === true ? 'italic' : 'initial'\n\n return styles\n },\n shallowMergeFallbacks,\n ),\n )\n}\n\nexport interface TypographyRenderLeafProps extends RenderLeafProps {\n leaf: TypographyText\n}\n\nexport function TypographyLeaf({ leaf, children, attributes }: TypographyRenderLeafProps) {\n const enhancedTypography = useEnhancedTypography(leaf.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n return (\n <span {...attributes} className={typographyClassName}>\n {children}\n </span>\n )\n}\n","import { RenderLeafProps } from 'slate-react'\nimport { TextType } from '../../../../../controls'\nimport { TypographyLeaf } from './typography'\n\nexport function Leaf({ leaf, ...props }: RenderLeafProps) {\n switch (leaf.type) {\n case TextType.Typography:\n return <TypographyLeaf leaf={leaf} {...props} />\n\n default:\n return <span {...props.attributes}>{props.children}</span>\n }\n}\n","import { cx } from '@emotion/css'\nimport { RenderElementProps } from 'slate-react'\nimport { Block, BlockType } from '../../../../../controls'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { responsiveStyle } from '../../../../utils/responsive-style'\n\nexport interface InlineRenderElementProps extends RenderElementProps {\n element: Block\n}\n\nexport function BlockElement({ element, attributes, children }: InlineRenderElementProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(responsiveStyle([element.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n\n switch (element.type) {\n case BlockType.Paragraph:\n return (\n <p {...attributes} className={cx(...blockStyles)}>\n {children}\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote\n {...attributes}\n className={cx(\n ...blockStyles,\n useStyle({\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n }),\n )}\n >\n {children}\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol\n {...attributes}\n className={cx(...blockStyles, `${element.type}`)}\n style={{ listStylePosition: 'inside' }}\n >\n {children}\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul\n {...attributes}\n className={cx(...blockStyles, `${element.type}`)}\n style={{ listStylePosition: 'inside' }}\n >\n {children}\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li {...attributes} className={cx(...blockStyles, `${element.type}`)}>\n {children}\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span {...attributes} className={cx(...blockStyles, `${element.type}`)}>\n {children}\n </span>\n )\n }\n}\n","import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef } from 'react'\nimport { RenderElementProps } from 'slate-react'\nimport { Inline, InlineType } from '../../../../../controls'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { Link } from '../../../../shared/Link'\n\nfunction StyledLink({ className, ...restOfProps }: ComponentPropsWithoutRef<typeof Link>) {\n return <Link {...restOfProps} className={cx(useStyle({ textDecoration: 'none' }), className)} />\n}\n\nexport interface InlineRenderElementProps extends RenderElementProps {\n element: Inline\n}\n\nexport function InlineElement({ element, attributes, children }: InlineRenderElementProps) {\n switch (element.type) {\n case InlineType.Code:\n return <code {...attributes}>{children}</code>\n case InlineType.SuperScript:\n return <sup {...attributes}>{children}</sup>\n case InlineType.SubScript:\n return <sub {...attributes}>{children}</sub>\n case InlineType.Link:\n return (\n <StyledLink {...attributes} link={element.link}>\n {children}\n </StyledLink>\n )\n }\n}\n","import { RenderElementProps } from 'slate-react'\nimport { BlockType, InlineType } from '../../../../../controls'\nimport { BlockElement } from './block'\nimport { InlineElement } from './inline'\n\nexport function Element({ element, ...props }: RenderElementProps) {\n switch (element.type) {\n case InlineType.Code:\n case InlineType.SuperScript:\n case InlineType.SubScript:\n case InlineType.Link:\n return <InlineElement element={element} {...props} />\n case BlockType.Paragraph:\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement element={element} {...props} />\n default:\n return <span {...props.attributes}>{props.children}</span>\n }\n}\n","import { useState, useEffect, useCallback } from 'react'\nimport { Editor } from 'slate'\nimport {\n compareRichTextDAO,\n compareRichTextSelection,\n richTextDTOtoDAO,\n richTextDTOtoSelection,\n} from '../../../../controls'\nimport { RichTextValue } from '../../../../prop-controllers'\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\nexport function useSyncWithBuilder(editor: Editor, text?: RichTextValue) {\n const [shouldCommit, setShouldCommit] = useState(true)\n\n useEffect(() => {\n if (shouldCommit && text) {\n const nextValue = richTextDTOtoDAO(text)\n const nextSelection = richTextDTOtoSelection(text)\n if (\n !compareRichTextDAO(editor.children, nextValue) ||\n !compareRichTextSelection(editor.selection, nextSelection)\n ) {\n editor.children = nextValue\n editor.selection = nextSelection\n editor.onChange()\n }\n }\n }, [editor, shouldCommit, text])\n\n useEffect(() => {\n if (shouldCommit) return\n\n const timeoutId = window.setTimeout(() => {\n setShouldCommit(true)\n }, COMMIT_DEBOUNCE_DELAY)\n\n return () => {\n window.clearTimeout(timeoutId)\n }\n }, [shouldCommit])\n\n return useCallback(() => setShouldCommit(false), [])\n}\n","import { Node, Element, Text } from 'slate'\nimport {\n TextType,\n BlockType,\n Block,\n ParagraphElement,\n OrderedListElement,\n UnorderedListElement,\n ListItemElement,\n ListItemChildElement,\n} from '../../../../../../../controls'\n\nexport const ElementUtils = {\n isConvertibleToListTextNode(node: Node) {\n return (\n !this.isList(node) &&\n !this.isListItem(node) &&\n !this.isListItemChild(node) &&\n !this.isText(node) &&\n !this.isTypography(node)\n )\n },\n isText(node: Node) {\n return Element.isElementType(node, TextType.Text) || Text.isText(node)\n },\n isTypography(node: Node) {\n return Element.isElementType(node, TextType.Typography)\n },\n isParagraph(node: Node): node is ParagraphElement {\n return Element.isElementType(node, BlockType.Paragraph)\n },\n isList(node: Node): node is OrderedListElement | UnorderedListElement {\n return (\n Element.isElementType(node, BlockType.OrderedList) ||\n Element.isElementType(node, BlockType.UnorderedList)\n )\n },\n isListItem(node: Node): node is ListItemElement {\n return Element.isElementType(node, BlockType.ListItem)\n },\n isListItemChild(node: Node): node is ListItemChildElement {\n return Element.isElementType(node, BlockType.ListItemChild)\n },\n createText() {\n return { text: '', type: TextType.Text }\n },\n createParagraph() {\n return {\n children: [this.createText()],\n type: BlockType.Paragraph,\n }\n },\n createList(type: BlockType = BlockType.UnorderedList): Block {\n return { children: [this.createText()], type }\n },\n createListItem(): Block {\n return {\n children: [this.createListItemChild()],\n type: BlockType.ListItem,\n }\n },\n createListItemChild(): Block {\n return {\n children: [this.createText()],\n type: BlockType.ListItemChild,\n }\n },\n}\n","import { Editor, Element, Transforms } from 'slate'\nimport { BlockType } from '../../../../../../controls'\nimport { ElementUtils } from './utils/element'\n\ntype WrapListOptions = {\n type: typeof BlockType.UnorderedList | typeof BlockType.OrderedList\n}\n\nexport function wrapList(\n editor: Editor,\n options: WrapListOptions = { type: BlockType.UnorderedList },\n) {\n if (!editor.selection) return\n\n const nonListEntries = Array.from(\n Editor.nodes(editor, {\n at: editor.selection,\n match: node => {\n return Element.isElement(node) && ElementUtils.isConvertibleToListTextNode(node)\n },\n }),\n )\n\n const refs = nonListEntries.map(([_, path]) => Editor.pathRef(editor, path))\n\n refs.forEach(ref => {\n const path = ref.current\n if (path) {\n Editor.withoutNormalizing(editor, () => {\n Transforms.setNodes(\n editor,\n { type: BlockType.ListItemChild },\n {\n at: path,\n },\n )\n Transforms.wrapNodes(editor, ElementUtils.createListItem(), {\n at: path,\n })\n Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {\n at: path,\n })\n })\n }\n ref.unref()\n })\n}\n","export const LIST_ITEM_CHILD_POSITION = 0\nexport const LIST_ITEM_LIST_POSITION = 1\n","import { Path, Editor, NodeEntry } from 'slate'\nimport { ListElement, ListItemElement } from '../../../../../../../controls'\nimport { ElementUtils } from './element'\n\nexport const EditorUtils = {\n getFirstAncestorList(editor: Editor, path: Path): NodeEntry<ListElement> | null {\n const parentList = Editor.above(editor, {\n at: path,\n match: (node): node is ListElement => ElementUtils.isList(node),\n })\n return parentList ?? null\n },\n getFirstAncestorListItem(editor: Editor, path: Path): NodeEntry<ListItemElement> | null {\n const parentListItem = Editor.above(editor, {\n at: path,\n match: (node): node is ListItemElement => ElementUtils.isListItem(node),\n })\n\n return parentListItem ?? null\n },\n}\n","import type { Node, NodeEntry } from 'slate'\nimport { Path } from 'slate'\n\nexport function filterForSubtreeRoots(entries: NodeEntry<Node>[]): NodeEntry<Node>[] {\n return entries.filter(\n ([, nodePath]) =>\n !Path.ancestors(nodePath).some(ancestor => {\n return entries.some(([, path]) => Path.equals(path, ancestor))\n }),\n )\n}\n","import { Range, Point, Path, Location } from 'slate'\n\nexport const LocationUtils = {\n getStartPath(location: Location): Path {\n if (Range.isRange(location)) return Range.start(location).path\n if (Point.isPoint(location)) return location.path\n return location\n },\n}\n","import type { Element, NodeEntry } from 'slate'\nimport { Editor, Path } from 'slate'\nimport { EditorUtils } from './editor'\nimport { ElementUtils } from './element'\nimport { LocationUtils } from './location'\n\nexport function getSelectedListItems(editor: Editor): NodeEntry<Element>[] {\n if (!editor.selection) return []\n\n const start = LocationUtils.getStartPath(editor.selection)\n const listItems = Editor.nodes(editor, {\n at: editor.selection,\n match: node => ElementUtils.isListItem(node),\n })\n const firstAncestorPath = EditorUtils.getFirstAncestorListItem(editor, start)?.[1] ?? []\n\n return Array.from(listItems).filter((node): node is NodeEntry<Element> =>\n Path.isDescendant(start, node[1])\n ? Path.equals(node[1], firstAncestorPath)\n : !Path.isAfter(start, node[1]),\n )\n}\n\nexport function getSelectedLists(editor: Editor): NodeEntry<Element>[] {\n if (!editor.selection) return []\n\n const start = LocationUtils.getStartPath(editor.selection)\n const lists = Editor.nodes(editor, {\n at: editor.selection,\n match: node => ElementUtils.isList(node),\n })\n const firstAncestorPath = EditorUtils.getFirstAncestorList(editor, start)?.[1] ?? []\n\n return Array.from(lists).filter((node): node is NodeEntry<Element> =>\n Path.isDescendant(start, node[1])\n ? Path.equals(node[1], firstAncestorPath)\n : !Path.isAfter(start, node[1]),\n )\n}\n","import { Editor, Transforms, Path, Node } from 'slate'\nimport { BlockType } from '../../../../../../controls'\nimport { LIST_ITEM_CHILD_POSITION, LIST_ITEM_LIST_POSITION } from '../constants'\nimport { EditorUtils } from './utils/editor'\nimport { filterForSubtreeRoots } from './utils/filterForSubtreeRoots'\nimport { getSelectedListItems } from './utils/getSelectedListItems'\n\nexport function unwrapPath(editor: Editor, listItemPath: Path) {\n const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath)\n const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath)\n //if this is a nested item we don't want to unwrap it\n if (!parentList || listItemContainingParentList) return\n\n Editor.withoutNormalizing(editor, () => {\n const listItemTextPath = [...listItemPath, LIST_ITEM_CHILD_POSITION]\n const listItemNestedListPath = [...listItemPath, LIST_ITEM_LIST_POSITION]\n\n if (Node.has(editor, listItemNestedListPath)) {\n Transforms.setNodes(editor, { type: parentList[0].type }, { at: listItemNestedListPath })\n Transforms.liftNodes(editor, { at: listItemNestedListPath })\n Transforms.liftNodes(editor, { at: Path.next(listItemPath) })\n }\n\n if (Node.has(editor, listItemTextPath)) {\n Transforms.setNodes(\n editor,\n { type: BlockType.Paragraph },\n {\n at: listItemTextPath,\n },\n )\n Transforms.liftNodes(editor, { at: listItemTextPath })\n Transforms.liftNodes(editor, { at: listItemPath })\n }\n })\n}\n\nexport function unwrapList(editor: Editor) {\n if (!editor.selection) return\n\n const listItems = getSelectedListItems(editor)\n const subRoots = filterForSubtreeRoots(listItems)\n const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path))\n\n refs.forEach(ref => {\n if (ref.current) {\n unwrapPath(editor, ref.current)\n }\n ref.unref()\n })\n}\n","import { Editor, Node, Path, Transforms } from 'slate'\nimport { BlockType } from '../../../../../../controls'\nimport { unwrapList } from './unwrapList'\nimport { ElementUtils } from './utils/element'\nimport { LocationUtils } from './utils/location'\nimport { wrapList } from './wrapList'\n\ntype ToggleListOptions = {\n type: typeof BlockType.UnorderedList | typeof BlockType.OrderedList\n}\n\nexport function toggleList(\n editor: Editor,\n options: ToggleListOptions = { type: BlockType.UnorderedList },\n) {\n if (!editor.selection) return\n const start = LocationUtils.getStartPath(editor.selection)\n const ancestorPath = Path.ancestors(start).at(1)\n if (!ancestorPath || !Node.has(editor, ancestorPath)) return\n const ancestor = Node.get(editor, ancestorPath)\n\n if (!ElementUtils.isList(ancestor)) {\n return wrapList(editor, { type: options.type })\n }\n\n if (ancestor.type === options.type) {\n unwrapList(editor)\n } else {\n Transforms.setNodes(editor, { type: options.type }, { at: ancestorPath })\n }\n}\n","import { Editor, Node, Path, Transforms } from 'slate'\nimport { LIST_ITEM_LIST_POSITION } from '../constants'\nimport { ElementUtils } from './utils/element'\nimport { filterForSubtreeRoots } from './utils/filterForSubtreeRoots'\nimport { getSelectedListItems } from './utils/getSelectedListItems'\n\nexport function indentPath(editor: Editor, path: Path) {\n const parent = Node.parent(editor, path)\n if (!path || !Path.hasPrevious(path) || !ElementUtils.isList(parent) ) return\n\n \n const previosPath = Path.previous(path)\n\n const previousChildListPath = [...previosPath, LIST_ITEM_LIST_POSITION]\n const previousHasChildList = Node.has(editor, previousChildListPath)\n\n Editor.withoutNormalizing(editor, () => {\n if (!previousHasChildList) {\n Transforms.insertNodes(editor, ElementUtils.createList(parent.type), {\n at: previousChildListPath,\n })\n }\n\n const previousChildList = Node.get(editor, previousChildListPath)\n\n if (ElementUtils.isList(previousChildList)) {\n const index = previousHasChildList ? previousChildList.children.length : 0\n Transforms.moveNodes(editor, {\n at: path,\n to: [...previousChildListPath, index],\n })\n }\n })\n}\n\nexport function indent(editor: Editor) {\n if (!editor.selection) return\n\n const listItems = getSelectedListItems(editor)\n const subRoots = filterForSubtreeRoots(listItems)\n const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path))\n\n refs.forEach(ref => {\n if (ref.current) {\n indentPath(editor, ref.current)\n }\n ref.unref()\n })\n}\n","import { Editor, Path, Transforms } from 'slate'\nimport { indentPath } from './indent'\nimport { getSelectedListItems } from './utils/getSelectedListItems'\nimport { filterForSubtreeRoots } from './utils/filterForSubtreeRoots'\nimport { EditorUtils } from './utils/editor'\n\nfunction dedentPath(editor: Editor, listItemPath: Path) {\n const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath)\n const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath)\n if (!parentList || !listItemContainingParentList) return\n\n const [parentListNode, parentListPath] = parentList\n const [_, listItemContainingParentListPath] = listItemContainingParentList\n\n const listItemPosition = listItemPath[listItemPath.length - 1]\n const previousSiblings = parentListNode.children.slice(0, listItemPosition)\n const nextSiblings = parentListNode.children.slice(listItemPosition + 1)\n\n Editor.withoutNormalizing(editor, () => {\n // put next siblings into list item\n nextSiblings.forEach(() => {\n const nextSiblingPath = [...parentListPath, listItemPosition + 1]\n indentPath(editor, nextSiblingPath)\n })\n // move list item to parent list\n Transforms.moveNodes(editor, {\n at: listItemPath,\n to: Path.next(listItemContainingParentListPath),\n })\n // delete old parent list if there are no other list items\n if (previousSiblings.length === 0) {\n Transforms.removeNodes(editor, { at: parentListPath })\n }\n })\n}\n\nexport function dedent(editor: Editor) {\n if (!editor.selection) return\n\n const listItems = getSelectedListItems(editor)\n const subRoots = filterForSubtreeRoots(listItems)\n const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path))\n\n refs.forEach(ref => {\n if (ref.current) {\n dedentPath(editor, ref.current)\n }\n ref.unref()\n })\n}\n","import type { KeyboardEvent } from 'react'\nimport { Editor, Transforms, Range, Node, PathRef } from 'slate'\nimport isHotkey from 'is-hotkey'\nimport { ElementUtils } from './lib/utils/element'\nimport { unwrapList, wrapList, indent, dedent, toggleList } from './lib'\nimport { EditorUtils } from './lib/utils/editor'\nimport { LIST_ITEM_CHILD_POSITION } from './constants'\nimport { BlockType } from '../../../../../controls'\n\nexport const List = {\n unwrapList,\n wrapList,\n indent,\n dedent,\n toggleList,\n}\n\nexport function onKeyDown(e: KeyboardEvent, editor: Editor) {\n if (\n !editor.selection ||\n Array.from(Editor.nodes(editor, { match: node => ElementUtils.isListItem(node) })).length === 0\n )\n return\n\n if (isHotkey('shift+tab', e)) {\n e.preventDefault()\n List.dedent(editor)\n }\n\n if (isHotkey('tab', e)) {\n e.preventDefault()\n List.indent(editor)\n }\n\n if (isHotkey('backspace', e)) {\n if (!editor.selection) return\n if (Range.isExpanded(editor.selection)) return\n const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path)\n if (editor.selection.anchor.offset === 0 && listItem) {\n e.preventDefault()\n const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1])\n const list = EditorUtils.getFirstAncestorList(editor, listItem[1])\n\n if (parentListItem) {\n List.dedent(editor)\n } else if (list) {\n List.unwrapList(editor)\n }\n return\n }\n }\n\n if (isHotkey('enter', e)) {\n e.preventDefault()\n\n if (!editor.selection) return\n\n if (Range.isExpanded(editor.selection)) {\n Transforms.delete(editor)\n return\n }\n\n const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path)\n if (\n editor.selection.anchor.offset === 0 &&\n listItem &&\n Editor.string(editor, listItem[1]) === ''\n ) {\n const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1])\n\n if (parentListItem) {\n List.dedent(editor)\n } else {\n List.unwrapList(editor)\n }\n return\n }\n\n Transforms.splitNodes(editor, {\n at: editor.selection,\n always: true,\n match: node => ElementUtils.isListItem(node),\n })\n }\n\n if (isHotkey('shift+enter', e)) {\n e.preventDefault()\n editor.insertText('\\n')\n }\n}\n\nexport function withList(editor: Editor) {\n editor.normalizeNode = entry => {\n const [normalizationNode, normalizationPath] = entry\n\n // Normalization for converting children of list items to list item children\n // In the case of backspace from position 0 of node into a list this converts the node into a list item.\n if (ElementUtils.isListItem(normalizationNode)) {\n const pathToListItemText = [...normalizationPath, LIST_ITEM_CHILD_POSITION]\n\n if (Node.has(editor, pathToListItemText)) {\n const nodeInListItemTextPosition = Node.get(editor, pathToListItemText)\n if (ElementUtils.isParagraph(nodeInListItemTextPosition)) {\n Transforms.setNodes(\n editor,\n { type: BlockType.ListItemChild },\n {\n at: pathToListItemText,\n },\n )\n return\n }\n } else {\n Transforms.insertNodes(editor, ElementUtils.createListItem(), {\n at: pathToListItemText,\n })\n return\n }\n }\n\n // Normalization for removing stray text elements from lists\n if (ElementUtils.isList(normalizationNode)) {\n Array.from(Node.children(editor, normalizationPath)).forEach(([node, path]) => {\n if (ElementUtils.isText(node)) {\n Transforms.removeNodes(editor, { at: path })\n return\n }\n })\n }\n\n // Normalization for merging adjacent lists of the same type\n if (!ElementUtils.isText(normalizationNode) && !ElementUtils.isTypography(normalizationNode)) {\n const mergeableChildren = Array.from(Node.children(editor, normalizationPath))\n .map((child, index, children) => {\n const potentialNodeToBeMerged = children.at(index + 1)\n if (\n !potentialNodeToBeMerged ||\n !ElementUtils.isList(potentialNodeToBeMerged[0]) ||\n potentialNodeToBeMerged[0].type !== child[0].type\n ) {\n return null\n }\n return [\n Editor.pathRef(editor, child[1]),\n Editor.pathRef(editor, potentialNodeToBeMerged[1]),\n ]\n })\n .filter((mergeableNodes): mergeableNodes is PathRef[] => Boolean(mergeableNodes))\n\n if (mergeableChildren.length !== 0) {\n mergeableChildren.reverse().forEach(([nodePathRef, nodeToBeMergedPathRef]) => {\n const nodePath = nodePathRef.current\n const nodeToBeMergedPath = nodeToBeMergedPathRef.current\n if (nodePath == null || nodeToBeMergedPath == null) return\n const nodeChildren = Array.from(Node.children(editor, nodePath))\n const childrenToBeMerged = Array.from(Node.children(editor, nodeToBeMergedPath))\n Editor.withoutNormalizing(editor, () => {\n childrenToBeMerged.forEach(([_, childPath], index) => {\n Transforms.moveNodes(editor, {\n at: childPath,\n to: [...nodePath, nodeChildren.length + index],\n })\n })\n Transforms.removeNodes(editor, { at: nodeToBeMergedPath })\n })\n nodePathRef.unref()\n nodeToBeMergedPathRef.unref()\n })\n return\n }\n }\n }\n\n return editor\n}\n","import {\n forwardRef,\n KeyboardEvent,\n Ref,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react'\n\nimport { createEditor } from 'slate'\nimport { Slate, Editable, withReact, ReactEditor } from 'slate-react'\n\nimport { ElementIDValue, RichTextValue } from '../../../../prop-controllers/descriptors'\nimport { cx } from '@emotion/css'\nimport { DescriptorsPropControllers } from '../../../../prop-controllers/instances'\nimport { Descriptors } from '../../../../runtimes/react/controls/rich-text'\nimport { getBox } from '../../../../box-model'\nimport { PropControllersHandle } from '../../../../state/modules/prop-controller-handles'\nimport { BlockType, RichTextDAO, richTextDTOtoDAO, TextType } from '../../../../controls'\nimport { Leaf } from './Leaf'\nimport { Element } from './Element'\nimport { useSyncWithBuilder } from './useSyncWithBuilder'\nimport { onKeyDown, withList } from './ListPlugin'\nimport isHotkey from 'is-hotkey'\nimport { useBuilderEditMode } from '../../../../runtimes/react'\nimport { BuilderEditMode } from '../../../../state/modules/builder-edit-mode'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst defaultText: RichTextDAO = [\n { type: BlockType.Paragraph, children: [{ type: TextType.Text, text: '' }] },\n]\n\nexport const EditableText = forwardRef(function EditableText(\n { id, text, width, margin }: Props,\n ref: Ref<PropControllersHandle<Descriptors>>,\n) {\n const [editor] = useState(() => withList(withReact(createEditor())))\n const delaySync = useSyncWithBuilder(editor, text)\n const editMode = useBuilderEditMode()\n\n const [propControllers, setPropControllers] =\n useState<DescriptorsPropControllers<Descriptors> | null>(null)\n const controller = propControllers?.text\n\n useImperativeHandle(\n ref,\n () => ({\n getDomNode() {\n return ReactEditor.toDOMNode(editor, editor)\n },\n getBoxModel() {\n return getBox(ReactEditor.toDOMNode(editor, editor))\n },\n setPropControllers: (value: any) => {\n console.log('setPropControllers', value)\n setPropControllers(value)\n },\n }),\n [editor, setPropControllers],\n )\n\n const initialValue = useMemo(() => (text ? richTextDTOtoDAO(text) : defaultText), [text])\n\n useEffect(() => {\n console.log('initialize setSlateEditor with', { propControllers, controller, editor })\n\n controller?.setSlateEditor(editor)\n }, [controller, editor])\n\n const handleFocus = useCallback(() => {\n controller?.focus()\n }, [controller])\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (isHotkey('mod+shift+z', e)) return controller?.redo()\n if (isHotkey('mod+z', e)) return controller?.undo()\n if (isHotkey('escape')(e)) return controller?.blur()\n onKeyDown(e, editor)\n },\n [controller, editor],\n )\n\n console.log('render', { propControllers, controller, editor })\n\n return (\n <Slate editor={editor} value={initialValue} onChange={delaySync}>\n <Editable\n id={id}\n renderLeaf={Leaf}\n renderElement={Element}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n className={cx(width, margin)}\n readOnly={editMode === BuilderEditMode.INTERACT}\n />\n </Slate>\n )\n})\n","import { ForwardedRef, forwardRef } from 'react'\nimport { RichTextValue } from '../../../prop-controllers'\nimport { ElementIDValue } from '../../../prop-controllers/descriptors'\nimport { EditableText } from './EditableText'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst Text = forwardRef(function Text(props: Props, ref: ForwardedRef<any>) {\n return <EditableText {...props} ref={ref} />\n})\n\nexport default Text\n"],"names":["value","deviceId","withColor","swatches","deviceRawTypographyValue","color","nextValue","swatch","find","s","id","swatchId","alpha","undefined","getDeviceId","typography","useTypography","source","style","filter","isDeviceOverride","override","swatchIds","getTypographyStyleSwatchIds","useSwatches","isNonNullable","enhancedSource","map","enhancedOverride","devices","Set","concat","deviceSource","findDeviceOverride","deviceOverride","useStyle","responsiveStyle","styles","colorToString","fontFamily","fontSize","unit","fontWeight","lineHeight","letterSpacing","uppercase","textTransform","underline","strikethrough","textDecoration","Boolean","join","italic","fontStyle","shallowMergeFallbacks","leaf","children","attributes","enhancedTypography","useEnhancedTypography","typographyClassName","useTypographyClassName","props","type","TextType","Typography","element","blockStyles","margin","textAlign","BlockType","Paragraph","cx","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","padding","borderLeft","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","className","restOfProps","Link","InlineType","Code","SuperScript","SubScript","link","COMMIT_DEBOUNCE_DELAY","editor","text","shouldCommit","setShouldCommit","useState","useEffect","richTextDTOtoDAO","nextSelection","richTextDTOtoSelection","compareRichTextDAO","compareRichTextSelection","selection","onChange","timeoutId","window","setTimeout","clearTimeout","useCallback","Element","Text","Editor","Transforms","Path","Range","Point","Node","isHotkey","defaultText","EditableText","forwardRef","width","ref","withList","withReact","createEditor","delaySync","useSyncWithBuilder","editMode","useBuilderEditMode","propControllers","setPropControllers","controller","useImperativeHandle","getDomNode","ReactEditor","toDOMNode","getBoxModel","getBox","log","initialValue","useMemo","console","setSlateEditor","handleFocus","focus","handleKeyDown","e","redo","undo","blur","onKeyDown","Slate","Editable","Leaf","BuilderEditMode","INTERACT"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBO,0BAA0BA,OAGY;AAC3C,SAAOA,MAAMC,aAAa,aAAaD,MAAMC,aAAa,YAAYD,MAAMC,aAAa;AAC1F;AAED,MAAMC,YACJ,CAACC,aACD,CACEC,6BAC4C;;AACtC,QAAA;AAAA,IAAEJ;AAAAA,IAAOC;AAAAA,MAAaG;AAExBJ,MAAAA,MAAMK,SAAS,MAAM;AACjB,UAA0BL,YAAxBK;AAAAA;AAAAA,QAAwBL,IAAdM,sBAAcN,IAAdM;AAAAA,MAAVD;AAAAA;AACD,WAAA;AAAA,MACLJ;AAAAA,MACAD,OAAOM;AAAAA,IAAAA;AAAAA,EAEV;AACM,SAAA;AAAA,IACLL;AAAAA,IACAD,OAAO,iCACFA,QADE;AAAA,MAELK,OAAO;AAAA,QACLE,QAAQJ,SAASK,KAAKC,CAAAA,MAAKA;;AAAAA,sBAAKA,EAAEC,OAAOV,cAAMK,UAANL,oBAAaW;AAAAA,SAA9C;AAAA,QACRC,OAAOZ,kBAAMK,UAANL,mBAAaY,UAAbZ,YAAsBa;AAAAA,MAFxB;AAAA,IAFF;AAAA,EAAA;AAQV;AAEH,MAAMC,cAA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AAlB;AAAA,IAAyB;AAAA,EAAA,EAAhC;AACD,CAFsB;;"}
1
+ {"version":3,"file":"Text.cjs.js","sources":["../src/components/builtin/Text/EditableText/Leaf/typography.tsx","../src/components/builtin/Text/EditableText/Leaf/leaf.tsx","../src/components/builtin/Text/EditableText/Element/block.tsx","../src/components/builtin/Text/EditableText/Element/inline.tsx","../src/components/builtin/Text/EditableText/Element/element.tsx","../src/components/builtin/Text/EditableText/useSyncWithBuilder.tsx","../src/components/builtin/Text/EditableText/ListPlugin/lib/utils/element.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/wrapList.ts","../src/components/builtin/Text/EditableText/ListPlugin/constants.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/utils/editor.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/utils/filterForSubtreeRoots.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/utils/location.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/utils/getSelectedListItems.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/unwrapList.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/toggleList.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/indent.ts","../src/components/builtin/Text/EditableText/ListPlugin/lib/dedent.ts","../src/components/builtin/Text/EditableText/ListPlugin/ListPlugin.ts","../src/components/builtin/Text/EditableText/editable-text.tsx","../src/components/builtin/Text/Text.tsx"],"sourcesContent":["import { CSSObject } from '@emotion/serialize'\nimport { RenderLeafProps } from 'slate-react'\nimport { Swatch, Typography } from '../../../../../api'\nimport { TypographyText } from '../../../../../controls'\nimport { DeviceOverride, ResponsiveValue } from '../../../../../prop-controllers'\nimport { getTypographyStyleSwatchIds } from '../../../../../prop-controllers/introspection'\nimport { useTypography, useSwatches } from '../../../../../runtimes/react/hooks/makeswift-api'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { colorToString } from '../../../../utils/colorToString'\nimport { findDeviceOverride, shallowMergeFallbacks } from '../../../../utils/devices'\nimport { isNonNullable } from '../../../../utils/isNonNullable'\nimport { responsiveStyle } from '../../../../utils/responsive-style'\nimport { ColorValue } from '../../../../utils/types'\n\nexport type TypographyValue = Typography['style'][number]['value']\n\ntype EnhancedColor = {\n color?: ColorValue\n}\n\ntype EnhancedTypographyValue = Omit<TypographyValue, keyof EnhancedColor> & EnhancedColor\n\nexport type EnhancedTypography = Array<DeviceOverride<EnhancedTypographyValue>>\n\nexport function isDeviceOverride(value: {\n deviceId: string\n value: TypographyValue\n}): value is DeviceOverride<TypographyValue> {\n return value.deviceId === 'desktop' || value.deviceId === 'tablet' || value.deviceId === 'mobile'\n}\n\nconst withColor =\n (swatches: Swatch[]) =>\n (\n deviceRawTypographyValue: DeviceOverride<TypographyValue>,\n ): DeviceOverride<EnhancedTypographyValue> => {\n const { value, deviceId } = deviceRawTypographyValue\n\n if (value.color == null) {\n const { color, ...nextValue } = value\n return {\n deviceId,\n value: nextValue,\n }\n }\n return {\n deviceId,\n value: {\n ...value,\n color: {\n swatch: swatches.find(s => s && s.id === value.color?.swatchId),\n alpha: value.color?.alpha ?? undefined,\n },\n },\n }\n }\n\nconst getDeviceId = ({ deviceId }: DeviceOverride<unknown>) => deviceId\n\nexport default function useEnhancedTypography(value: Typography): EnhancedTypography {\n const typography = useTypography(value?.id ?? null)\n const source = typography?.style.filter(isDeviceOverride) ?? []\n const override = value?.style.filter(isDeviceOverride) ?? []\n\n const swatchIds = [\n ...getTypographyStyleSwatchIds(value?.style),\n ...getTypographyStyleSwatchIds(typography?.style),\n ]\n const swatches = useSwatches(swatchIds).filter(isNonNullable)\n\n const enhancedSource = source.map(withColor(swatches))\n const enhancedOverride = override.map(withColor(swatches))\n\n const devices = [\n ...new Set(enhancedSource.map(getDeviceId).concat(enhancedOverride.map(getDeviceId))),\n ]\n\n return devices\n .map(deviceId => {\n const deviceSource = findDeviceOverride(enhancedSource, deviceId)?.value\n const deviceOverride = findDeviceOverride(enhancedOverride, deviceId)?.value\n\n if (deviceSource && deviceOverride) {\n return {\n deviceId,\n value: { ...deviceSource, ...deviceOverride },\n }\n } else if (deviceOverride) {\n return {\n deviceId,\n value: deviceOverride,\n }\n } else if (deviceSource) {\n return {\n deviceId,\n value: deviceSource,\n }\n }\n return null\n })\n .filter(isNonNullable)\n}\n\nexport function useTypographyClassName(value: EnhancedTypography): string {\n return useStyle(\n responsiveStyle<\n EnhancedTypographyValue,\n [ResponsiveValue<EnhancedTypographyValue> | null | undefined]\n >(\n [value],\n ([value]) => {\n if (value === undefined) return {}\n\n let styles: CSSObject = {}\n if (value.color != null) styles.color = colorToString(value.color)\n if (value.fontFamily != null) styles.fontFamily = value.fontFamily\n if (value.fontSize != null && value.fontSize.value != null && value.fontSize.unit != null)\n styles.fontSize = `${value.fontSize.value}${value.fontSize.unit}`\n if (value.fontWeight != null) styles.fontWeight = value.fontWeight\n if (value.lineHeight != null) styles.lineHeight = value.lineHeight\n if (value.letterSpacing != null) styles.letterSpacing = `${value.letterSpacing / 10}em`\n if (value.uppercase != null)\n styles.textTransform = value.uppercase === true ? 'uppercase' : 'initial'\n if (value.underline != null || value.strikethrough != null)\n styles.textDecoration = [\n Boolean(value.underline) && 'underline',\n Boolean(value.strikethrough) && 'line-through',\n ]\n .filter(Boolean)\n .join(' ')\n if (value.italic != null) styles.fontStyle = value.italic === true ? 'italic' : 'initial'\n\n return styles\n },\n shallowMergeFallbacks,\n ),\n )\n}\n\nexport interface TypographyRenderLeafProps extends RenderLeafProps {\n leaf: TypographyText\n}\n\nexport function TypographyLeaf({ leaf, children, attributes }: TypographyRenderLeafProps) {\n const enhancedTypography = useEnhancedTypography(leaf.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n return (\n <span {...attributes} className={typographyClassName}>\n {children}\n </span>\n )\n}\n","import { RenderLeafProps } from 'slate-react'\nimport { TextType } from '../../../../../controls'\nimport { TypographyLeaf } from './typography'\n\nexport function Leaf({ leaf, ...props }: RenderLeafProps) {\n switch (leaf.type) {\n case TextType.Typography:\n return <TypographyLeaf leaf={leaf} {...props} />\n\n default:\n return <span {...props.attributes}>{props.children}</span>\n }\n}\n","import { cx } from '@emotion/css'\nimport { RenderElementProps } from 'slate-react'\nimport { Block, BlockType } from '../../../../../controls'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { responsiveStyle } from '../../../../utils/responsive-style'\n\nexport interface InlineRenderElementProps extends RenderElementProps {\n element: Block\n}\n\nexport function BlockElement({ element, attributes, children }: InlineRenderElementProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(responsiveStyle([element.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n\n switch (element.type) {\n case BlockType.Paragraph:\n return (\n <p {...attributes} className={cx(...blockStyles)}>\n {children}\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote\n {...attributes}\n className={cx(\n ...blockStyles,\n useStyle({\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n }),\n )}\n >\n {children}\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol\n {...attributes}\n className={cx(...blockStyles, `${element.type}`)}\n style={{ listStylePosition: 'inside' }}\n >\n {children}\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul\n {...attributes}\n className={cx(...blockStyles, `${element.type}`)}\n style={{ listStylePosition: 'inside' }}\n >\n {children}\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li {...attributes} className={cx(...blockStyles, `${element.type}`)}>\n {children}\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span {...attributes} className={cx(...blockStyles, `${element.type}`)}>\n {children}\n </span>\n )\n }\n}\n","import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef } from 'react'\nimport { RenderElementProps } from 'slate-react'\nimport { Inline, InlineType } from '../../../../../controls'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { Link } from '../../../../shared/Link'\n\nfunction StyledLink({ className, ...restOfProps }: ComponentPropsWithoutRef<typeof Link>) {\n return <Link {...restOfProps} className={cx(useStyle({ textDecoration: 'none' }), className)} />\n}\n\nexport interface InlineRenderElementProps extends RenderElementProps {\n element: Inline\n}\n\nexport function InlineElement({ element, attributes, children }: InlineRenderElementProps) {\n switch (element.type) {\n case InlineType.Code:\n return <code {...attributes}>{children}</code>\n case InlineType.SuperScript:\n return <sup {...attributes}>{children}</sup>\n case InlineType.SubScript:\n return <sub {...attributes}>{children}</sub>\n case InlineType.Link:\n return (\n <StyledLink {...attributes} link={element.link}>\n {children}\n </StyledLink>\n )\n }\n}\n","import { RenderElementProps } from 'slate-react'\nimport { BlockType, InlineType } from '../../../../../controls'\nimport { BlockElement } from './block'\nimport { InlineElement } from './inline'\n\nexport function Element({ element, ...props }: RenderElementProps) {\n switch (element.type) {\n case InlineType.Code:\n case InlineType.SuperScript:\n case InlineType.SubScript:\n case InlineType.Link:\n return <InlineElement element={element} {...props} />\n case BlockType.Paragraph:\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement element={element} {...props} />\n default:\n return <span {...props.attributes}>{props.children}</span>\n }\n}\n","import { useState, useEffect, useCallback } from 'react'\nimport { Editor } from 'slate'\nimport {\n compareRichTextDAO,\n compareRichTextSelection,\n richTextDTOtoDAO,\n richTextDTOtoSelection,\n} from '../../../../controls'\nimport { RichTextValue } from '../../../../prop-controllers'\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\nexport function useSyncWithBuilder(editor: Editor, text?: RichTextValue) {\n const [shouldCommit, setShouldCommit] = useState(true)\n\n useEffect(() => {\n if (shouldCommit && text) {\n const nextValue = richTextDTOtoDAO(text)\n const nextSelection = richTextDTOtoSelection(text)\n if (\n !compareRichTextDAO(editor.children, nextValue) ||\n !compareRichTextSelection(editor.selection, nextSelection)\n ) {\n editor.children = nextValue\n editor.selection = nextSelection\n editor.onChange()\n }\n }\n }, [editor, shouldCommit, text])\n\n useEffect(() => {\n if (shouldCommit) return\n\n const timeoutId = window.setTimeout(() => {\n setShouldCommit(true)\n }, COMMIT_DEBOUNCE_DELAY)\n\n return () => {\n window.clearTimeout(timeoutId)\n }\n }, [shouldCommit])\n\n return useCallback(() => setShouldCommit(false), [])\n}\n","import { Node, Element, Text } from 'slate'\nimport {\n TextType,\n BlockType,\n Block,\n ParagraphElement,\n OrderedListElement,\n UnorderedListElement,\n ListItemElement,\n ListItemChildElement,\n} from '../../../../../../../controls'\n\nexport const ElementUtils = {\n isConvertibleToListTextNode(node: Node) {\n return (\n !this.isList(node) &&\n !this.isListItem(node) &&\n !this.isListItemChild(node) &&\n !this.isText(node) &&\n !this.isTypography(node)\n )\n },\n isText(node: Node) {\n return Element.isElementType(node, TextType.Text) || Text.isText(node)\n },\n isTypography(node: Node) {\n return Element.isElementType(node, TextType.Typography)\n },\n isParagraph(node: Node): node is ParagraphElement {\n return Element.isElementType(node, BlockType.Paragraph)\n },\n isList(node: Node): node is OrderedListElement | UnorderedListElement {\n return (\n Element.isElementType(node, BlockType.OrderedList) ||\n Element.isElementType(node, BlockType.UnorderedList)\n )\n },\n isListItem(node: Node): node is ListItemElement {\n return Element.isElementType(node, BlockType.ListItem)\n },\n isListItemChild(node: Node): node is ListItemChildElement {\n return Element.isElementType(node, BlockType.ListItemChild)\n },\n createText() {\n return { text: '', type: TextType.Text }\n },\n createParagraph() {\n return {\n children: [this.createText()],\n type: BlockType.Paragraph,\n }\n },\n createList(type: BlockType = BlockType.UnorderedList): Block {\n return { children: [this.createText()], type }\n },\n createListItem(): Block {\n return {\n children: [this.createListItemChild()],\n type: BlockType.ListItem,\n }\n },\n createListItemChild(): Block {\n return {\n children: [this.createText()],\n type: BlockType.ListItemChild,\n }\n },\n}\n","import { Editor, Element, Transforms } from 'slate'\nimport { BlockType } from '../../../../../../controls'\nimport { ElementUtils } from './utils/element'\n\ntype WrapListOptions = {\n type: typeof BlockType.UnorderedList | typeof BlockType.OrderedList\n}\n\nexport function wrapList(\n editor: Editor,\n options: WrapListOptions = { type: BlockType.UnorderedList },\n) {\n if (!editor.selection) return\n\n const nonListEntries = Array.from(\n Editor.nodes(editor, {\n at: editor.selection,\n match: node => {\n return Element.isElement(node) && ElementUtils.isConvertibleToListTextNode(node)\n },\n }),\n )\n\n const refs = nonListEntries.map(([_, path]) => Editor.pathRef(editor, path))\n\n refs.forEach(ref => {\n const path = ref.current\n if (path) {\n Editor.withoutNormalizing(editor, () => {\n Transforms.setNodes(\n editor,\n { type: BlockType.ListItemChild },\n {\n at: path,\n },\n )\n Transforms.wrapNodes(editor, ElementUtils.createListItem(), {\n at: path,\n })\n Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {\n at: path,\n })\n })\n }\n ref.unref()\n })\n}\n","export const LIST_ITEM_CHILD_POSITION = 0\nexport const LIST_ITEM_LIST_POSITION = 1\n","import { Path, Editor, NodeEntry } from 'slate'\nimport { ListElement, ListItemElement } from '../../../../../../../controls'\nimport { ElementUtils } from './element'\n\nexport const EditorUtils = {\n getFirstAncestorList(editor: Editor, path: Path): NodeEntry<ListElement> | null {\n const parentList = Editor.above(editor, {\n at: path,\n match: (node): node is ListElement => ElementUtils.isList(node),\n })\n return parentList ?? null\n },\n getFirstAncestorListItem(editor: Editor, path: Path): NodeEntry<ListItemElement> | null {\n const parentListItem = Editor.above(editor, {\n at: path,\n match: (node): node is ListItemElement => ElementUtils.isListItem(node),\n })\n\n return parentListItem ?? null\n },\n}\n","import type { Node, NodeEntry } from 'slate'\nimport { Path } from 'slate'\n\nexport function filterForSubtreeRoots(entries: NodeEntry<Node>[]): NodeEntry<Node>[] {\n return entries.filter(\n ([, nodePath]) =>\n !Path.ancestors(nodePath).some(ancestor => {\n return entries.some(([, path]) => Path.equals(path, ancestor))\n }),\n )\n}\n","import { Range, Point, Path, Location } from 'slate'\n\nexport const LocationUtils = {\n getStartPath(location: Location): Path {\n if (Range.isRange(location)) return Range.start(location).path\n if (Point.isPoint(location)) return location.path\n return location\n },\n}\n","import type { Element, NodeEntry } from 'slate'\nimport { Editor, Path } from 'slate'\nimport { EditorUtils } from './editor'\nimport { ElementUtils } from './element'\nimport { LocationUtils } from './location'\n\nexport function getSelectedListItems(editor: Editor): NodeEntry<Element>[] {\n if (!editor.selection) return []\n\n const start = LocationUtils.getStartPath(editor.selection)\n const listItems = Editor.nodes(editor, {\n at: editor.selection,\n match: node => ElementUtils.isListItem(node),\n })\n const firstAncestorPath = EditorUtils.getFirstAncestorListItem(editor, start)?.[1] ?? []\n\n return Array.from(listItems).filter((node): node is NodeEntry<Element> =>\n Path.isDescendant(start, node[1])\n ? Path.equals(node[1], firstAncestorPath)\n : !Path.isAfter(start, node[1]),\n )\n}\n\nexport function getSelectedLists(editor: Editor): NodeEntry<Element>[] {\n if (!editor.selection) return []\n\n const start = LocationUtils.getStartPath(editor.selection)\n const lists = Editor.nodes(editor, {\n at: editor.selection,\n match: node => ElementUtils.isList(node),\n })\n const firstAncestorPath = EditorUtils.getFirstAncestorList(editor, start)?.[1] ?? []\n\n return Array.from(lists).filter((node): node is NodeEntry<Element> =>\n Path.isDescendant(start, node[1])\n ? Path.equals(node[1], firstAncestorPath)\n : !Path.isAfter(start, node[1]),\n )\n}\n","import { Editor, Transforms, Path, Node } from 'slate'\nimport { BlockType } from '../../../../../../controls'\nimport { LIST_ITEM_CHILD_POSITION, LIST_ITEM_LIST_POSITION } from '../constants'\nimport { EditorUtils } from './utils/editor'\nimport { filterForSubtreeRoots } from './utils/filterForSubtreeRoots'\nimport { getSelectedListItems } from './utils/getSelectedListItems'\n\nexport function unwrapPath(editor: Editor, listItemPath: Path) {\n const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath)\n const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath)\n //if this is a nested item we don't want to unwrap it\n if (!parentList || listItemContainingParentList) return\n\n Editor.withoutNormalizing(editor, () => {\n const listItemTextPath = [...listItemPath, LIST_ITEM_CHILD_POSITION]\n const listItemNestedListPath = [...listItemPath, LIST_ITEM_LIST_POSITION]\n\n if (Node.has(editor, listItemNestedListPath)) {\n Transforms.setNodes(editor, { type: parentList[0].type }, { at: listItemNestedListPath })\n Transforms.liftNodes(editor, { at: listItemNestedListPath })\n Transforms.liftNodes(editor, { at: Path.next(listItemPath) })\n }\n\n if (Node.has(editor, listItemTextPath)) {\n Transforms.setNodes(\n editor,\n { type: BlockType.Paragraph },\n {\n at: listItemTextPath,\n },\n )\n Transforms.liftNodes(editor, { at: listItemTextPath })\n Transforms.liftNodes(editor, { at: listItemPath })\n }\n })\n}\n\nexport function unwrapList(editor: Editor) {\n if (!editor.selection) return\n\n const listItems = getSelectedListItems(editor)\n const subRoots = filterForSubtreeRoots(listItems)\n const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path))\n\n refs.forEach(ref => {\n if (ref.current) {\n unwrapPath(editor, ref.current)\n }\n ref.unref()\n })\n}\n","import { Editor, Node, Path, Transforms } from 'slate'\nimport { BlockType } from '../../../../../../controls'\nimport { unwrapList } from './unwrapList'\nimport { ElementUtils } from './utils/element'\nimport { LocationUtils } from './utils/location'\nimport { wrapList } from './wrapList'\n\ntype ToggleListOptions = {\n type: typeof BlockType.UnorderedList | typeof BlockType.OrderedList\n}\n\nexport function toggleList(\n editor: Editor,\n options: ToggleListOptions = { type: BlockType.UnorderedList },\n) {\n if (!editor.selection) return\n const start = LocationUtils.getStartPath(editor.selection)\n const ancestorPath = Path.ancestors(start).at(1)\n if (!ancestorPath || !Node.has(editor, ancestorPath)) return\n const ancestor = Node.get(editor, ancestorPath)\n\n if (!ElementUtils.isList(ancestor)) {\n return wrapList(editor, { type: options.type })\n }\n\n if (ancestor.type === options.type) {\n unwrapList(editor)\n } else {\n Transforms.setNodes(editor, { type: options.type }, { at: ancestorPath })\n }\n}\n","import { Editor, Node, Path, Transforms } from 'slate'\nimport { LIST_ITEM_LIST_POSITION } from '../constants'\nimport { ElementUtils } from './utils/element'\nimport { filterForSubtreeRoots } from './utils/filterForSubtreeRoots'\nimport { getSelectedListItems } from './utils/getSelectedListItems'\n\nexport function indentPath(editor: Editor, path: Path) {\n const parent = Node.parent(editor, path)\n if (!path || !Path.hasPrevious(path) || !ElementUtils.isList(parent) ) return\n\n \n const previosPath = Path.previous(path)\n\n const previousChildListPath = [...previosPath, LIST_ITEM_LIST_POSITION]\n const previousHasChildList = Node.has(editor, previousChildListPath)\n\n Editor.withoutNormalizing(editor, () => {\n if (!previousHasChildList) {\n Transforms.insertNodes(editor, ElementUtils.createList(parent.type), {\n at: previousChildListPath,\n })\n }\n\n const previousChildList = Node.get(editor, previousChildListPath)\n\n if (ElementUtils.isList(previousChildList)) {\n const index = previousHasChildList ? previousChildList.children.length : 0\n Transforms.moveNodes(editor, {\n at: path,\n to: [...previousChildListPath, index],\n })\n }\n })\n}\n\nexport function indent(editor: Editor) {\n if (!editor.selection) return\n\n const listItems = getSelectedListItems(editor)\n const subRoots = filterForSubtreeRoots(listItems)\n const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path))\n\n refs.forEach(ref => {\n if (ref.current) {\n indentPath(editor, ref.current)\n }\n ref.unref()\n })\n}\n","import { Editor, Path, Transforms } from 'slate'\nimport { indentPath } from './indent'\nimport { getSelectedListItems } from './utils/getSelectedListItems'\nimport { filterForSubtreeRoots } from './utils/filterForSubtreeRoots'\nimport { EditorUtils } from './utils/editor'\n\nfunction dedentPath(editor: Editor, listItemPath: Path) {\n const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath)\n const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath)\n if (!parentList || !listItemContainingParentList) return\n\n const [parentListNode, parentListPath] = parentList\n const [_, listItemContainingParentListPath] = listItemContainingParentList\n\n const listItemPosition = listItemPath[listItemPath.length - 1]\n const previousSiblings = parentListNode.children.slice(0, listItemPosition)\n const nextSiblings = parentListNode.children.slice(listItemPosition + 1)\n\n Editor.withoutNormalizing(editor, () => {\n // put next siblings into list item\n nextSiblings.forEach(() => {\n const nextSiblingPath = [...parentListPath, listItemPosition + 1]\n indentPath(editor, nextSiblingPath)\n })\n // move list item to parent list\n Transforms.moveNodes(editor, {\n at: listItemPath,\n to: Path.next(listItemContainingParentListPath),\n })\n // delete old parent list if there are no other list items\n if (previousSiblings.length === 0) {\n Transforms.removeNodes(editor, { at: parentListPath })\n }\n })\n}\n\nexport function dedent(editor: Editor) {\n if (!editor.selection) return\n\n const listItems = getSelectedListItems(editor)\n const subRoots = filterForSubtreeRoots(listItems)\n const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path))\n\n refs.forEach(ref => {\n if (ref.current) {\n dedentPath(editor, ref.current)\n }\n ref.unref()\n })\n}\n","import type { KeyboardEvent } from 'react'\nimport { Editor, Transforms, Range, Node, PathRef } from 'slate'\nimport isHotkey from 'is-hotkey'\nimport { ElementUtils } from './lib/utils/element'\nimport { unwrapList, wrapList, indent, dedent, toggleList } from './lib'\nimport { EditorUtils } from './lib/utils/editor'\nimport { LIST_ITEM_CHILD_POSITION } from './constants'\nimport { BlockType } from '../../../../../controls'\n\nexport const List = {\n unwrapList,\n wrapList,\n indent,\n dedent,\n toggleList,\n}\n\nexport function onKeyDown(e: KeyboardEvent, editor: Editor) {\n if (\n !editor.selection ||\n Array.from(Editor.nodes(editor, { match: node => ElementUtils.isListItem(node) })).length === 0\n )\n return\n\n if (isHotkey('shift+tab', e)) {\n e.preventDefault()\n List.dedent(editor)\n }\n\n if (isHotkey('tab', e)) {\n e.preventDefault()\n List.indent(editor)\n }\n\n if (isHotkey('backspace', e)) {\n if (!editor.selection) return\n if (Range.isExpanded(editor.selection)) return\n const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path)\n if (editor.selection.anchor.offset === 0 && listItem) {\n e.preventDefault()\n const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1])\n const list = EditorUtils.getFirstAncestorList(editor, listItem[1])\n\n if (parentListItem) {\n List.dedent(editor)\n } else if (list) {\n List.unwrapList(editor)\n }\n return\n }\n }\n\n if (isHotkey('enter', e)) {\n e.preventDefault()\n\n if (!editor.selection) return\n\n if (Range.isExpanded(editor.selection)) {\n Transforms.delete(editor)\n return\n }\n\n const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path)\n if (\n editor.selection.anchor.offset === 0 &&\n listItem &&\n Editor.string(editor, listItem[1]) === ''\n ) {\n const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1])\n\n if (parentListItem) {\n List.dedent(editor)\n } else {\n List.unwrapList(editor)\n }\n return\n }\n\n Transforms.splitNodes(editor, {\n at: editor.selection,\n always: true,\n match: node => ElementUtils.isListItem(node),\n })\n }\n\n if (isHotkey('shift+enter', e)) {\n e.preventDefault()\n editor.insertText('\\n')\n }\n}\n\nexport function withList(editor: Editor) {\n editor.normalizeNode = entry => {\n const [normalizationNode, normalizationPath] = entry\n\n // Normalization for converting children of list items to list item children\n // In the case of backspace from position 0 of node into a list this converts the node into a list item.\n if (ElementUtils.isListItem(normalizationNode)) {\n const pathToListItemText = [...normalizationPath, LIST_ITEM_CHILD_POSITION]\n\n if (Node.has(editor, pathToListItemText)) {\n const nodeInListItemTextPosition = Node.get(editor, pathToListItemText)\n if (ElementUtils.isParagraph(nodeInListItemTextPosition)) {\n Transforms.setNodes(\n editor,\n { type: BlockType.ListItemChild },\n {\n at: pathToListItemText,\n },\n )\n return\n }\n } else {\n Transforms.insertNodes(editor, ElementUtils.createListItem(), {\n at: pathToListItemText,\n })\n return\n }\n }\n\n // Normalization for removing stray text elements from lists\n if (ElementUtils.isList(normalizationNode)) {\n Array.from(Node.children(editor, normalizationPath)).forEach(([node, path]) => {\n if (ElementUtils.isText(node)) {\n Transforms.removeNodes(editor, { at: path })\n return\n }\n })\n }\n\n // Normalization for merging adjacent lists of the same type\n if (!ElementUtils.isText(normalizationNode) && !ElementUtils.isTypography(normalizationNode)) {\n const mergeableChildren = Array.from(Node.children(editor, normalizationPath))\n .map((child, index, children) => {\n const potentialNodeToBeMerged = children.at(index + 1)\n if (\n !potentialNodeToBeMerged ||\n !ElementUtils.isList(potentialNodeToBeMerged[0]) ||\n potentialNodeToBeMerged[0].type !== child[0].type\n ) {\n return null\n }\n return [\n Editor.pathRef(editor, child[1]),\n Editor.pathRef(editor, potentialNodeToBeMerged[1]),\n ]\n })\n .filter((mergeableNodes): mergeableNodes is PathRef[] => Boolean(mergeableNodes))\n\n if (mergeableChildren.length !== 0) {\n mergeableChildren.reverse().forEach(([nodePathRef, nodeToBeMergedPathRef]) => {\n const nodePath = nodePathRef.current\n const nodeToBeMergedPath = nodeToBeMergedPathRef.current\n if (nodePath == null || nodeToBeMergedPath == null) return\n const nodeChildren = Array.from(Node.children(editor, nodePath))\n const childrenToBeMerged = Array.from(Node.children(editor, nodeToBeMergedPath))\n Editor.withoutNormalizing(editor, () => {\n childrenToBeMerged.forEach(([_, childPath], index) => {\n Transforms.moveNodes(editor, {\n at: childPath,\n to: [...nodePath, nodeChildren.length + index],\n })\n })\n Transforms.removeNodes(editor, { at: nodeToBeMergedPath })\n })\n nodePathRef.unref()\n nodeToBeMergedPathRef.unref()\n })\n return\n }\n }\n }\n\n return editor\n}\n","import {\n forwardRef,\n KeyboardEvent,\n Ref,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react'\n\nimport { createEditor } from 'slate'\nimport { Slate, Editable, withReact, ReactEditor } from 'slate-react'\n\nimport { ElementIDValue, RichTextValue } from '../../../../prop-controllers/descriptors'\nimport { cx } from '@emotion/css'\nimport { DescriptorsPropControllers } from '../../../../prop-controllers/instances'\nimport { Descriptors } from '../../../../runtimes/react/controls/rich-text'\nimport { getBox } from '../../../../box-model'\nimport { PropControllersHandle } from '../../../../state/modules/prop-controller-handles'\nimport { BlockType, RichTextDAO, richTextDTOtoDAO, TextType } from '../../../../controls'\nimport { Leaf } from './Leaf'\nimport { Element } from './Element'\nimport { useSyncWithBuilder } from './useSyncWithBuilder'\nimport { onKeyDown, withList } from './ListPlugin'\nimport isHotkey from 'is-hotkey'\nimport { useBuilderEditMode } from '../../../../runtimes/react'\nimport { BuilderEditMode } from '../../../../state/modules/builder-edit-mode'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst defaultText: RichTextDAO = [\n { type: BlockType.Paragraph, children: [{ type: TextType.Text, text: '' }] },\n]\n\nexport const EditableText = forwardRef(function EditableText(\n { id, text, width, margin }: Props,\n ref: Ref<PropControllersHandle<Descriptors>>,\n) {\n const [editor] = useState(() => withList(withReact(createEditor())))\n const delaySync = useSyncWithBuilder(editor, text)\n const editMode = useBuilderEditMode()\n\n const [propControllers, setPropControllers] =\n useState<DescriptorsPropControllers<Descriptors> | null>(null)\n const controller = propControllers?.text\n\n const [nextEditor, setEditor] = useState<any>(null)\n\n useImperativeHandle(\n ref,\n () => ({\n getDomNode() {\n return nextEditor ? ReactEditor.toDOMNode(nextEditor, nextEditor) : null\n },\n getBoxModel() {\n return nextEditor ? getBox(ReactEditor.toDOMNode(nextEditor, nextEditor)) : null\n },\n setPropControllers: (value: any) => {\n console.log('setPropControllers', value)\n setPropControllers(value)\n },\n }),\n [nextEditor, setPropControllers],\n )\n\n useEffect(() => {\n setEditor(editor)\n }, [])\n\n const initialValue = useMemo(() => (text ? richTextDTOtoDAO(text) : defaultText), [text])\n\n useEffect(() => {\n // console.log('initialize setSlateEditor with', { propControllers, controller, editor })\n\n controller?.setSlateEditor(editor)\n }, [controller, editor])\n\n const handleFocus = useCallback(() => {\n controller?.focus()\n }, [controller])\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (isHotkey('mod+shift+z', e)) return controller?.redo()\n if (isHotkey('mod+z', e)) return controller?.undo()\n if (isHotkey('escape')(e)) return controller?.blur()\n onKeyDown(e, editor)\n },\n [controller, editor],\n )\n\n // console.log('render', { propControllers, controller, editor })\n\n return (\n <Slate editor={editor} value={initialValue} onChange={delaySync}>\n <Editable\n id={id}\n renderLeaf={Leaf}\n renderElement={Element}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n className={cx(width, margin)}\n readOnly={editMode === BuilderEditMode.INTERACT}\n />\n </Slate>\n )\n})\n","import { ForwardedRef, forwardRef } from 'react'\nimport { RichTextValue } from '../../../prop-controllers'\nimport { ElementIDValue } from '../../../prop-controllers/descriptors'\nimport { EditableText } from './EditableText'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst Text = forwardRef(function Text(props: Props, ref: ForwardedRef<any>) {\n return <EditableText {...props} ref={ref} />\n})\n\nexport default Text\n"],"names":["value","deviceId","withColor","swatches","deviceRawTypographyValue","color","nextValue","swatch","find","s","id","swatchId","alpha","undefined","getDeviceId","typography","useTypography","source","style","filter","isDeviceOverride","override","swatchIds","getTypographyStyleSwatchIds","useSwatches","isNonNullable","enhancedSource","map","enhancedOverride","devices","Set","concat","deviceSource","findDeviceOverride","deviceOverride","useStyle","responsiveStyle","styles","colorToString","fontFamily","fontSize","unit","fontWeight","lineHeight","letterSpacing","uppercase","textTransform","underline","strikethrough","textDecoration","Boolean","join","italic","fontStyle","shallowMergeFallbacks","leaf","children","attributes","enhancedTypography","useEnhancedTypography","typographyClassName","useTypographyClassName","props","type","TextType","Typography","element","blockStyles","margin","textAlign","BlockType","Paragraph","cx","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","padding","borderLeft","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","className","restOfProps","Link","InlineType","Code","SuperScript","SubScript","link","COMMIT_DEBOUNCE_DELAY","editor","text","shouldCommit","setShouldCommit","useState","useEffect","richTextDTOtoDAO","nextSelection","richTextDTOtoSelection","compareRichTextDAO","compareRichTextSelection","selection","onChange","timeoutId","window","setTimeout","clearTimeout","useCallback","Element","Text","Editor","Transforms","Path","Range","Point","Node","isHotkey","defaultText","EditableText","forwardRef","width","ref","withList","withReact","createEditor","delaySync","useSyncWithBuilder","editMode","useBuilderEditMode","propControllers","setPropControllers","controller","nextEditor","setEditor","useImperativeHandle","getDomNode","ReactEditor","toDOMNode","getBoxModel","getBox","log","initialValue","useMemo","setSlateEditor","handleFocus","focus","handleKeyDown","e","redo","undo","blur","onKeyDown","Slate","Editable","Leaf","BuilderEditMode","INTERACT"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBO,0BAA0BA,OAGY;AAC3C,SAAOA,MAAMC,aAAa,aAAaD,MAAMC,aAAa,YAAYD,MAAMC,aAAa;AAC1F;AAED,MAAMC,YACJ,CAACC,aACD,CACEC,6BAC4C;;AACtC,QAAA;AAAA,IAAEJ;AAAAA,IAAOC;AAAAA,MAAaG;AAExBJ,MAAAA,MAAMK,SAAS,MAAM;AACjB,UAA0BL,YAAxBK;AAAAA;AAAAA,QAAwBL,IAAdM,sBAAcN,IAAdM;AAAAA,MAAVD;AAAAA;AACD,WAAA;AAAA,MACLJ;AAAAA,MACAD,OAAOM;AAAAA,IAAAA;AAAAA,EAEV;AACM,SAAA;AAAA,IACLL;AAAAA,IACAD,OAAO,iCACFA,QADE;AAAA,MAELK,OAAO;AAAA,QACLE,QAAQJ,SAASK,KAAKC,CAAAA,MAAKA;;AAAAA,sBAAKA,EAAEC,OAA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AAA,CAPzC;AAAA,EAAA,CAFJ;AAaD,CAxEqC;AC5BtC,MAAM/C,OAAOU,MAAAA,WAAW,eAAc/D,OAAciE,KAAwB;AACnE,wCAAC,cAAD,iCAAkBjE,QAAlB;AAAA,IAAyB;AAAA,EAAA,EAAhC;AACD,CAFsB;;"}
package/dist/Text.es.js CHANGED
@@ -763,25 +763,24 @@ const EditableText = forwardRef(function EditableText2({
763
763
  const editMode = useBuilderEditMode();
764
764
  const [propControllers, setPropControllers] = useState(null);
765
765
  const controller = propControllers == null ? void 0 : propControllers.text;
766
+ const [nextEditor, setEditor] = useState(null);
766
767
  useImperativeHandle(ref, () => ({
767
768
  getDomNode() {
768
- return ReactEditor.toDOMNode(editor, editor);
769
+ return nextEditor ? ReactEditor.toDOMNode(nextEditor, nextEditor) : null;
769
770
  },
770
771
  getBoxModel() {
771
- return getBox(ReactEditor.toDOMNode(editor, editor));
772
+ return nextEditor ? getBox(ReactEditor.toDOMNode(nextEditor, nextEditor)) : null;
772
773
  },
773
774
  setPropControllers: (value) => {
774
775
  console.log("setPropControllers", value);
775
776
  setPropControllers(value);
776
777
  }
777
- }), [editor, setPropControllers]);
778
+ }), [nextEditor, setPropControllers]);
779
+ useEffect(() => {
780
+ setEditor(editor);
781
+ }, []);
778
782
  const initialValue = useMemo(() => text ? richTextDTOtoDAO(text) : defaultText, [text]);
779
783
  useEffect(() => {
780
- console.log("initialize setSlateEditor with", {
781
- propControllers,
782
- controller,
783
- editor
784
- });
785
784
  controller == null ? void 0 : controller.setSlateEditor(editor);
786
785
  }, [controller, editor]);
787
786
  const handleFocus = useCallback(() => {
@@ -796,11 +795,6 @@ const EditableText = forwardRef(function EditableText2({
796
795
  return controller == null ? void 0 : controller.blur();
797
796
  onKeyDown(e, editor);
798
797
  }, [controller, editor]);
799
- console.log("render", {
800
- propControllers,
801
- controller,
802
- editor
803
- });
804
798
  return /* @__PURE__ */ jsx(Slate, {
805
799
  editor,
806
800
  value: initialValue,