@makeswift/runtime 0.8.11 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Box.cjs.js +16 -15
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +11 -10
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +13 -12
- package/dist/Button.cjs.js.map +1 -1
- package/dist/Button.es.js +11 -10
- package/dist/Button.es.js.map +1 -1
- package/dist/Carousel.cjs.js +28 -27
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Carousel.es.js +7 -6
- package/dist/Carousel.es.js.map +1 -1
- package/dist/Countdown.cjs.js +16 -15
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +8 -7
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +13 -12
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +11 -10
- package/dist/Divider.es.js.map +1 -1
- package/dist/Embed.cjs.js +4 -29
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +3 -28
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +52 -51
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +8 -7
- package/dist/Form.es.js.map +1 -1
- package/dist/Image.cjs.js +9 -8
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +8 -7
- package/dist/Image.es.js.map +1 -1
- package/dist/LiveProvider.cjs.js +6 -5
- package/dist/LiveProvider.cjs.js.map +1 -1
- package/dist/LiveProvider.es.js +8 -7
- package/dist/LiveProvider.es.js.map +1 -1
- package/dist/Navigation.cjs.js +28 -27
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +7 -6
- package/dist/Navigation.es.js.map +1 -1
- package/dist/PreviewProvider.cjs.js +23 -7
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +24 -8
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +22 -20
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +18 -16
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +19 -17
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +16 -14
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/Root.cjs.js +8 -7
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +6 -5
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.cjs.js +15 -14
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +11 -10
- package/dist/SocialLinks.es.js.map +1 -1
- package/dist/Text.cjs.js +5 -4
- package/dist/Text.cjs.js.map +1 -1
- package/dist/Text.es.js +6 -5
- package/dist/Text.es.js.map +1 -1
- package/dist/Video.cjs.js +4 -29
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +3 -28
- package/dist/Video.es.js.map +1 -1
- package/dist/actions.cjs.js +16 -1
- package/dist/actions.cjs.js.map +1 -1
- package/dist/actions.es.js +14 -2
- package/dist/actions.es.js.map +1 -1
- package/dist/builder.cjs.js +5 -0
- package/dist/builder.cjs.js.map +1 -1
- package/dist/builder.es.js +5 -0
- package/dist/builder.es.js.map +1 -1
- package/dist/components.cjs.js +10 -9
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +10 -9
- package/dist/components.es.js.map +1 -1
- package/dist/control-serialization.cjs.js +89 -10
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +90 -11
- package/dist/control-serialization.es.js.map +1 -1
- package/dist/controls.cjs.js +12 -3
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +6 -2
- package/dist/controls.es.js.map +1 -1
- package/dist/deepEqual.cjs.js +40 -0
- package/dist/deepEqual.cjs.js.map +1 -0
- package/dist/deepEqual.es.js +39 -0
- package/dist/deepEqual.es.js.map +1 -0
- package/dist/index.cjs.js +298 -292
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs10.js +18 -16
- package/dist/index.cjs10.js.map +1 -1
- package/dist/index.cjs2.js +14 -14
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs4.js +2 -1
- package/dist/index.cjs4.js.map +1 -1
- package/dist/index.cjs5.js +0 -522
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +1 -2
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.cjs7.js +0 -52
- package/dist/index.cjs7.js.map +1 -1
- package/dist/index.cjs8.js +5 -4
- package/dist/index.cjs8.js.map +1 -1
- package/dist/index.cjs9.js +72 -69
- package/dist/index.cjs9.js.map +1 -1
- package/dist/index.es.js +282 -275
- package/dist/index.es.js.map +1 -1
- package/dist/index.es10.js +16 -14
- package/dist/index.es10.js.map +1 -1
- package/dist/index.es2.js +3 -3
- package/dist/index.es3.js +1 -1
- package/dist/index.es4.js +2 -1
- package/dist/index.es4.js.map +1 -1
- package/dist/index.es5.js +2 -514
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +1 -2
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es7.js +2 -53
- package/dist/index.es7.js.map +1 -1
- package/dist/index.es8.js +5 -4
- package/dist/index.es8.js.map +1 -1
- package/dist/index.es9.js +74 -71
- package/dist/index.es9.js.map +1 -1
- package/dist/leaf.cjs.js +1 -1
- package/dist/leaf.cjs.js.map +1 -1
- package/dist/leaf.es.js +2 -2
- package/dist/main.cjs.js +8 -0
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +7 -2
- package/dist/main.es.js.map +1 -1
- package/dist/next.cjs.js +5 -4
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +6 -5
- package/dist/next.es.js.map +1 -1
- package/dist/prop-controllers.cjs.js +5 -0
- package/dist/prop-controllers.cjs.js.map +1 -1
- package/dist/prop-controllers.es.js +5 -0
- package/dist/prop-controllers.es.js.map +1 -1
- package/dist/react-page.cjs.js +1013 -190
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +968 -185
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs.js +5 -4
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +5 -4
- package/dist/react.es.js.map +1 -1
- package/dist/slate.cjs.js +96 -14
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +89 -6
- package/dist/slate.es.js.map +1 -1
- package/dist/types/src/api/graphql/documents/queries.d.ts.map +1 -1
- package/dist/types/src/api/graphql/generated/types.d.ts +0 -8
- package/dist/types/src/api/graphql/generated/types.d.ts.map +1 -1
- package/dist/types/src/builder/serialization/control-serialization.d.ts +3 -3
- package/dist/types/src/builder/serialization/control-serialization.d.ts.map +1 -1
- package/dist/types/src/builder/serialization/controls/rich-text-v2.d.ts +2 -2
- package/dist/types/src/builder/serialization/controls/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/builder/serialization/controls/style-v2.d.ts +5 -0
- package/dist/types/src/builder/serialization/controls/style-v2.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
- package/dist/types/src/components/builtin/Carousel/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Countdown/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Divider/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Embed/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
- package/dist/types/src/components/builtin/Form/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Navigation/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/SocialLinks/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/components/Element/block.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Video/register.d.ts.map +1 -1
- package/dist/types/src/components/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
- package/dist/types/src/components/hooks/useIsomorphicLayoutEffect.d.ts.map +1 -1
- package/dist/types/src/controls/control.d.ts +3 -2
- package/dist/types/src/controls/control.d.ts.map +1 -1
- package/dist/types/src/controls/index.d.ts +1 -0
- package/dist/types/src/controls/index.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +10 -5
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/controls/style-v2.d.ts +55 -0
- package/dist/types/src/controls/style-v2.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/next/api-handler/handlers/manifest.d.ts +3 -1
- package/dist/types/src/next/api-handler/handlers/manifest.d.ts.map +1 -1
- package/dist/types/src/next/api-handler/handlers/proxy-preview-mode.d.ts.map +1 -1
- package/dist/types/src/next/api-handler/index.d.ts +2 -1
- package/dist/types/src/next/api-handler/index.d.ts.map +1 -1
- package/dist/types/src/next/client.d.ts +7 -7
- package/dist/types/src/next/client.d.ts.map +1 -1
- package/dist/types/src/next/index.d.ts +8 -5
- package/dist/types/src/next/index.d.ts.map +1 -1
- package/dist/types/src/next/preview-mode.d.ts +17 -3
- package/dist/types/src/next/preview-mode.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/descriptors.d.ts +4 -3
- package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/instances.d.ts +2 -2
- package/dist/types/src/prop-controllers/instances.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/control.d.ts +3 -2
- package/dist/types/src/runtimes/react/controls/control.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts +2 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/style-v2.d.ts +4 -0
- package/dist/types/src/runtimes/react/controls/style-v2.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/index.d.ts +3 -1
- package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/constants.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/dedent.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/indent.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/index.d.ts +29 -3
- package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/toggleList.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/unwrapList.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/utils/filterForSubtreeRoots.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/utils/getSelectedListItems.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/utils/location.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/wrapList.d.ts.map +1 -0
- package/dist/types/src/slate/InlineModePlugin/index.d.ts +2 -1
- package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts +9 -0
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts.map +1 -0
- package/dist/types/src/slate/index.d.ts +1 -1
- package/dist/types/src/slate/index.d.ts.map +1 -1
- package/dist/types/src/slate/types.d.ts +18 -0
- package/dist/types/src/slate/types.d.ts.map +1 -1
- package/dist/types/src/slate/utils/element.d.ts +1 -2
- package/dist/types/src/slate/utils/element.d.ts.map +1 -1
- package/dist/types/src/state/actions.d.ts +26 -1
- package/dist/types/src/state/actions.d.ts.map +1 -1
- package/dist/types/src/state/modules/components-meta.d.ts +25 -1
- package/dist/types/src/state/modules/components-meta.d.ts.map +1 -1
- package/dist/types/src/state/modules/locales.d.ts +16 -0
- package/dist/types/src/state/modules/locales.d.ts.map +1 -0
- package/dist/types/src/state/react-builder-preview.d.ts +2 -0
- package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
- package/dist/types/src/state/react-page.d.ts +5 -1
- package/dist/types/src/state/react-page.d.ts.map +1 -1
- package/dist/useMediaQuery.es.js +1 -1
- package/package.json +6 -3
- package/dist/select.cjs.js +0 -8
- package/dist/select.cjs.js.map +0 -1
- package/dist/select.es.js +0 -6
- package/dist/select.es.js.map +0 -1
- package/dist/types/src/slate/ListPlugin/constants.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/dedent.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/indent.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/index.d.ts +0 -17
- package/dist/types/src/slate/ListPlugin/index.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/toggleList.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/unwrapList.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/utils/filterForSubtreeRoots.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/utils/getSelectedListItems.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/utils/location.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/wrapList.d.ts.map +0 -1
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/constants.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/dedent.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/indent.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/toggleList.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/unwrapList.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/filterForSubtreeRoots.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/getSelectedListItems.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/location.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/wrapList.d.ts +0 -0
package/dist/index.es5.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es5.js","sources":["../src/slate/ListPlugin/constants.ts","../src/slate/utils/editor.ts","../src/slate/ListPlugin/utils/filterForSubtreeRoots.ts","../src/slate/ListPlugin/utils/location.ts","../src/slate/ListPlugin/utils/getSelectedListItems.ts","../src/slate/ListPlugin/indent.ts","../src/slate/ListPlugin/dedent.ts","../src/slate/ListPlugin/unwrapList.ts","../src/slate/ListPlugin/wrapList.ts","../src/slate/ListPlugin/toggleList.ts","../src/slate/ListPlugin/index.ts","../src/slate/TypographyPlugin/clearActiveTypographyStyle.ts","../src/slate/TypographyPlugin/clearDeviceActiveTypography.ts","../src/slate/TypographyPlugin/detachActiveTypography.ts","../src/slate/TypographyPlugin/setActiveTypographyId.ts","../src/slate/TypographyPlugin/setActiveTypographyStyle.ts","../src/slate/TypographyPlugin/index.ts","../src/slate/utils/unhangRange.ts","../src/slate/selectors.ts","../src/slate/BlockPlugin/setBlockKeyForDevice.ts","../src/slate/BlockPlugin/clearBlockKeyForDevice.ts","../src/slate/BlockPlugin/wrapInline.ts","../src/slate/BlockPlugin/unwrapInline.ts","../src/slate/BlockPlugin/index.ts"],"sourcesContent":["export const LIST_ITEM_CHILD_POSITION = 0\nexport const LIST_ITEM_LIST_POSITION = 1\n","import { Path, Editor, NodeEntry } from 'slate'\n\nimport { ElementUtils } from './element'\nimport { ListElement, ListItemElement } from '../types'\n\nexport const EditorUtils = {\n getFirstAncestorList(editor: Editor, path: Path): NodeEntry<ListElement> | null {\n try {\n const parentList = Editor.above(editor, {\n at: path,\n match: (node): node is ListElement => ElementUtils.isList(node),\n })\n return parentList ?? null\n } catch (e) {\n return null\n }\n },\n getFirstAncestorListItem(editor: Editor, path: Path): NodeEntry<ListItemElement> | null {\n try {\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 } catch (e) {\n return null\n }\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 '../../utils/editor'\nimport { ElementUtils } from '../../utils/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","import { Editor, Node, Path, Transforms } from 'slate'\nimport { ElementUtils } from '../utils/element'\nimport { LIST_ITEM_LIST_POSITION } from './constants'\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 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 { Editor, Element, Transforms, Path, Node, Location, Span } from 'slate'\nimport { EditorUtils } from '../utils/editor'\nimport { LIST_ITEM_CHILD_POSITION, LIST_ITEM_LIST_POSITION } from './constants'\nimport { filterForSubtreeRoots } from './utils/filterForSubtreeRoots'\nimport { ElementUtils } from '../utils/element'\nimport { BlockType } from '../types'\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\ntype UnwrapListOptions = {\n at?: Location | Span\n}\n\nexport function unwrapList(editor: Editor, options?: UnwrapListOptions) {\n const at = options?.at ?? editor.selection\n if (!at) return\n\n const listItems = Array.from(\n Editor.nodes(editor, {\n at,\n match: node => {\n return Element.isElement(node) && ElementUtils.isListItem(node)\n },\n }),\n )\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, Element, Location, Span, Transforms } from 'slate'\nimport { ElementUtils } from '../utils/element'\nimport { BlockType } from '../types'\n\ntype WrapListOptions = {\n type: typeof BlockType.UnorderedList | typeof BlockType.OrderedList\n at?: Location | Span\n}\n\nexport function wrapList(\n editor: Editor,\n options: WrapListOptions = { type: BlockType.UnorderedList },\n) {\n const at = options.at ?? editor.selection\n if (!at) return\n\n const nonListEntries = Array.from(\n Editor.nodes(editor, {\n at,\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 match: node => ElementUtils.isListItemChild(node),\n at: path,\n })\n Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {\n at: path,\n })\n })\n }\n ref.unref()\n })\n}\n","import { Editor, Location, Node, Path, Transforms } from 'slate'\nimport { ElementUtils } from '../utils/element'\nimport { unwrapList } from './unwrapList'\nimport { LocationUtils } from './utils/location'\nimport { wrapList } from './wrapList'\nimport { BlockType } from '../types'\n\ntype ToggleListOptions = {\n type: typeof BlockType.UnorderedList | typeof BlockType.OrderedList\n at?: Location\n}\n\nexport function toggleList(\n editor: Editor,\n options: ToggleListOptions = { type: BlockType.UnorderedList },\n) {\n const at = options.at ?? editor.selection\n if (at == null) return\n const start = LocationUtils.getStartPath(at)\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, at })\n }\n\n if (ancestor.type === options.type) {\n unwrapList(editor, { at })\n } else {\n Transforms.setNodes(editor, { type: options.type }, { at: ancestorPath })\n }\n}\n","import type { KeyboardEvent } from 'react'\nimport { Editor, Transforms, Range, Node, PathRef, Text } from 'slate'\nimport isHotkey from 'is-hotkey'\nimport { LIST_ITEM_CHILD_POSITION } from './constants'\nimport { EditorUtils } from '../utils/editor'\nimport { ElementUtils } from '../utils/element'\nimport { dedent } from './dedent'\nimport { indent } from './indent'\nimport { toggleList } from './toggleList'\nimport { unwrapList } from './unwrapList'\nimport { wrapList } from './wrapList'\nimport { BlockType } from '../types'\n\nexport const ListActions = {\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 ListActions.dedent(editor)\n }\n\n if (isHotkey('tab', e)) {\n e.preventDefault()\n ListActions.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 ListActions.dedent(editor)\n } else if (list) {\n ListActions.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 ListActions.dedent(editor)\n } else {\n ListActions.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 const { normalizeNode } = 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 merging adjacent lists of the same type\n if (!Text.isText(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 !ElementUtils.isList(child[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.reverse().forEach(([_, childPath]) => {\n Transforms.moveNodes(editor, {\n at: childPath,\n to: [...nodePath, nodeChildren.length],\n })\n })\n Transforms.removeNodes(editor, { at: nodeToBeMergedPath })\n })\n nodePathRef.unref()\n nodeToBeMergedPathRef.unref()\n })\n return\n }\n }\n\n normalizeNode(entry)\n }\n\n return editor\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\nimport { RichTextTypography } from '../types'\n\ntype ClearActiveTypographyStyleOptions = {\n at?: Range\n}\n\nexport function clearActiveTypographyStyle(\n editor: Editor,\n options?: ClearActiveTypographyStyleOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n const typography: RichTextTypography = {\n ...node.typography,\n style: [],\n }\n\n Transforms.setNodes(\n editor,\n {\n typography,\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\nimport { RichTextTypography } from '../types'\n\ntype ClearDeviceActiveTypographyOptions = {\n at?: Range\n}\n\nexport function clearDeviceActiveTypography(\n editor: Editor,\n currentDeviceId: string,\n options?: ClearDeviceActiveTypographyOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n const typography: RichTextTypography = {\n ...node.typography,\n style:\n node?.typography?.style.filter(({ deviceId }) => deviceId !== currentDeviceId) ?? [],\n }\n\n Transforms.setNodes(\n editor,\n {\n typography,\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\nimport { RichTextTypography } from '../types'\n\ntype SetActiveTypographyIdOptions = {\n at?: Range\n}\n\nexport function detachActiveTypography(\n editor: Editor,\n value: RichTextTypography['style'],\n options?: SetActiveTypographyIdOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n Transforms.setNodes(\n editor,\n {\n typography: {\n style: value,\n },\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\n\ntype SetActiveTypographyIdOptions = {\n at?: Range\n}\n\nexport function setActiveTypographyId(\n editor: Editor,\n id?: string,\n options?: SetActiveTypographyIdOptions,\n) {\n const at = options?.at ?? editor.selection\n if (!at) return\n Transforms.setNodes(\n editor,\n {\n typography: {\n id,\n style: [],\n },\n },\n {\n at,\n match: node => Text.isText(node),\n split: Range.isExpanded(at),\n },\n )\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\nimport { Breakpoints, findBreakpointOverride, BreakpointId } from '../../state/modules/breakpoints'\nimport { RichTextTypography } from '../types'\n\ntype SetActiveTypographyStyleOptions = {\n at?: Range\n}\n\nexport function setActiveTypographyStyle(\n editor: Editor,\n breakpoints: Breakpoints,\n deviceId: string,\n prop: string,\n value?: unknown,\n options?: SetActiveTypographyStyleOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n const deviceOverrides = node?.typography?.style ?? []\n const deviceStyle = findBreakpointOverride(\n breakpoints,\n deviceOverrides,\n deviceId as BreakpointId,\n v => v,\n ) || {\n value: {},\n }\n const nextDeviceStyle = {\n deviceId,\n value: { ...deviceStyle.value, [prop]: value },\n }\n\n const nextTypography: RichTextTypography = {\n ...node.typography,\n style: [...deviceOverrides.filter(v => v.deviceId !== deviceId), nextDeviceStyle],\n }\n\n Transforms.setNodes(\n editor,\n {\n typography: nextTypography,\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Text, Transforms } from 'slate'\nimport { clearActiveTypographyStyle } from './clearActiveTypographyStyle'\nimport { clearDeviceActiveTypography } from './clearDeviceActiveTypography'\nimport { detachActiveTypography } from './detachActiveTypography'\nimport { setActiveTypographyId } from './setActiveTypographyId'\nimport { setActiveTypographyStyle } from './setActiveTypographyStyle'\n\nexport const TypographyActions = {\n setActiveTypographyId,\n setActiveTypographyStyle,\n clearActiveTypographyStyle,\n clearDeviceActiveTypography,\n detachActiveTypography,\n}\n\nexport function withTypography(editor: Editor) {\n const { normalizeNode } = editor\n editor.normalizeNode = entry => {\n const [normalizationNode, normalizationPath] = entry\n if (\n Text.isText(normalizationNode) &&\n normalizationNode?.typography?.id == null &&\n normalizationNode?.typography?.style.length === 0\n ) {\n Transforms.unsetNodes(editor, 'typography', { at: normalizationPath })\n return\n }\n\n if (Text.isText(normalizationNode) && normalizationNode?.slice != null) {\n Transforms.unsetNodes(editor, 'slice', { at: normalizationPath })\n return\n }\n\n normalizeNode(entry)\n }\n\n return editor\n}\n","import { Editor, Range, Element, Text, Path } from 'slate'\n\n/**\n * The `Editor.unhangeRange` within Slate early exits if `Path.hasPrevious(end.path)` ie if this isn't a root block.\n * Unfortunately when you `setNode(..., {split:true})` or `wrapNodes()` you also have a hanging selection, but not in the root position.\n *\n * This c/p removes the `Path.hasPrevious(end.path)` from the early exit but it the same otherwise\n */\nfunction unhangRange(editor: Editor, range: Range): Range {\n // eslint-disable-next-line prefer-const\n let [start, end] = Range.edges(range)\n // PERF: exit early if we can guarantee that the range isn't hanging.\n if (start.offset !== 0 || end.offset !== 0 || Range.isCollapsed(range)) {\n return range\n }\n\n const endBlock = Editor.above(editor, {\n at: end,\n match: n => Element.isElement(n) && Editor.isBlock(editor, n),\n })\n const blockPath = endBlock ? endBlock[1] : []\n const first = Editor.start(editor, start)\n const before = { anchor: first, focus: end }\n let skip = true\n\n for (const [node, path] of Editor.nodes(editor, {\n at: before,\n match: Text.isText,\n reverse: true,\n })) {\n if (skip) {\n skip = false\n continue\n }\n\n if (node.text !== '' || Path.isBefore(path, blockPath)) {\n end = { path, offset: node.text.length }\n break\n }\n }\n\n return { anchor: start, focus: end }\n}\n\nexport default unhangRange\n","import { Editor, NodeEntry, Range, Text } from 'slate'\nimport { EditableBlockKey } from './BlockPlugin/types'\nimport { ElementUtils } from './utils/element'\n\nimport unhangRange from './utils/unhangRange'\nimport shallowEqual from '../utils/shallowEqual'\nimport { isNonNullable } from '../utils/isNonNullable'\n\nimport { Breakpoints, BreakpointId, findBreakpointOverride } from '../state/modules/breakpoints'\nimport deepEqual from '../utils/deepEqual'\nimport keys from '../utils/keys'\nimport {\n RootBlock,\n Inline,\n RootBlockType,\n ResponsiveBlockTextAlignment,\n BlockTextAlignment,\n RichTextTypography,\n} from './types'\n\nexport function getSelection(editor: Editor): Range {\n if (editor.selection) return unhangRange(editor, editor.selection)\n return {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n }\n}\n\nexport function getBlocksInSelection(editor: Editor): NodeEntry<RootBlock>[] {\n return Array.from(\n Editor.nodes(editor, {\n at: getSelection(editor),\n match: node => ElementUtils.isRootBlock(node),\n }),\n ).filter((entry): entry is NodeEntry<RootBlock> => ElementUtils.isRootBlock(entry[0]))\n}\n\nexport function getInlinesInSelection(editor: Editor): NodeEntry<Inline>[] {\n return Array.from(\n Editor.nodes(editor, {\n at: getSelection(editor),\n match: node => ElementUtils.isInline(node),\n }),\n ).filter((entry): entry is NodeEntry<Inline> => ElementUtils.isInline(entry[0]))\n}\n\nexport function getActiveBlockType(editor: Editor): RootBlockType | null {\n const rootBlocks = getBlocksInSelection(editor).map(([node]) => node.type)\n\n return rootBlocks.reduce<RootBlockType | null>(\n (a, b) => (a === b ? b : null),\n rootBlocks.at(0) ?? null,\n )\n}\n\nexport function getActiveBlockValue(editor: Editor, key: EditableBlockKey) {\n const blocks = getBlocksInSelection(editor)\n\n const active = blocks.map(\n ([block]) => block[key] ?? null,\n ) as (ResponsiveBlockTextAlignment | null)[]\n\n return active.length === 0 ? null : active.reduce((a, b) => (shallowEqual(a, b) ? b : null))\n}\n\nexport function getActiveBlockDeviceOverrideValue(\n editor: Editor,\n key: EditableBlockKey,\n breakpoints: Breakpoints,\n deviceId: BreakpointId,\n) {\n const active: (BlockTextAlignment | null)[] = []\n const blocks = getBlocksInSelection(editor)\n\n blocks.forEach(([block]) => {\n const deviceOverride =\n findBreakpointOverride<BlockTextAlignment>(breakpoints, block[key], deviceId) || null\n active.push(deviceOverride?.value ?? null)\n })\n\n return active.length === 0 ? null : active.reduce((a, b) => (shallowEqual(a, b) ? b : null))\n}\n\n// Typography\n\nconst concat = (a: unknown[], b: unknown[]) => a.concat(b)\n\n// TODO: This is more cruft from trying to remove null from the typography type. This optimization is not worth it.\n/**\n * This is a c/p of the intersection of the utils from the root utils folder.\n * The only change is defaulting to undefined instead of to null.\n */\nexport default function intersection<A extends Record<string, unknown>, B extends A>(\n a: A,\n b: B,\n isEqual: (a: unknown, b: unknown) => boolean = deepEqual,\n): { [K in keyof A]: A[K] | undefined } {\n const allKeys = [...new Set([...keys(a), ...keys(b)])] as (keyof A)[]\n\n return allKeys.reduce((acc, k) => {\n if (isEqual(a[k], b[k])) acc[k] = a[k]\n else acc[k] = undefined\n\n return acc\n }, {} as { [K in keyof A]: A[K] | undefined })\n}\n\nconst fuseTypographyMarks = (\n values: Array<RichTextTypography | null | undefined>,\n breakpoints: Breakpoints,\n): RichTextTypography => {\n const devices = [\n ...new Set(\n values\n .filter(isNonNullable)\n .map(({ style }) => style.map(({ deviceId }) => deviceId))\n .reduce(concat, []),\n ),\n ] as BreakpointId[]\n\n return {\n id: values.map(v => v && v.id).reduce((a, b) => (a === b ? a : undefined)) ?? undefined,\n style: devices.map(deviceId =>\n values\n .map(\n v =>\n (v && findBreakpointOverride(breakpoints, v.style, deviceId)) || {\n deviceId,\n value: {},\n },\n )\n .reduce((acc, { value }) => {\n const a = intersection(acc.value, value)\n return {\n deviceId,\n value: a,\n }\n }),\n ),\n }\n}\n\nexport function getActiveTypographyMark(\n editor: Editor,\n breakpoints: Breakpoints,\n): RichTextTypography {\n const active: RichTextTypography[] = []\n\n const textNodes = Editor.nodes(editor, {\n at: getSelection(editor),\n match: node => Text.isText(node),\n })\n\n for (const [node] of textNodes) {\n if (Text.isText(node) && 'typography' in node && node.typography != undefined) {\n active.push(node.typography)\n }\n }\n return active.length === 0 ? { style: [] } : fuseTypographyMarks(active, breakpoints)\n}\n","import { Editor, Transforms, Location } from 'slate'\nimport { getBlocksInSelection } from '../selectors'\nimport { ElementUtils } from '../utils/element'\nimport { EditableBlockKey, EditableBlockValue } from './types'\nimport { Breakpoints, BreakpointId, findBreakpointOverride } from '../../state/modules/breakpoints'\n\ntype SetBlockKeyForDeviceOptions = {\n at?: Location\n}\n\nexport function setBlockKeyForDevice(\n editor: Editor,\n breakpoints: Breakpoints,\n deviceId: BreakpointId,\n key: EditableBlockKey,\n value: EditableBlockValue[number]['value'],\n options?: SetBlockKeyForDeviceOptions,\n) {\n const at = options?.at ?? editor.selection\n if (!at) return\n\n const rootElements = getBlocksInSelection(editor)\n\n for (const [node, path] of rootElements) {\n if (ElementUtils.isBlock(node)) {\n const deviceValues = node[key] ?? []\n const currentDeviceValue = findBreakpointOverride(breakpoints, deviceValues, deviceId, v => v)\n const nextDeviceValue = {\n ...currentDeviceValue,\n deviceId,\n value,\n }\n Transforms.setNodes(\n editor,\n {\n [key]: [...deviceValues.filter(v => v.deviceId !== deviceId), nextDeviceValue],\n },\n { at: path },\n )\n }\n }\n}\n","import { Editor, Transforms } from 'slate'\nimport { ElementUtils } from '../utils/element'\nimport { EditableBlockKey } from './types'\nimport { getBlocksInSelection } from '../selectors'\nimport { BreakpointId } from '../../state/modules/breakpoints'\n\nexport function clearBlockKeyForDevice(\n editor: Editor,\n deviceId: BreakpointId,\n key: EditableBlockKey,\n) {\n const rootElements = getBlocksInSelection(editor)\n\n for (const [node, path] of rootElements) {\n if (ElementUtils.isBlock(node)) {\n const deviceOverrides = node[key] ?? []\n Transforms.setNodes(\n editor,\n {\n [key]: deviceOverrides.filter(v => v.deviceId !== deviceId),\n },\n { at: path },\n )\n }\n }\n}\n","import { Editor, Transforms } from 'slate'\nimport { getSelection } from '../selectors'\nimport { Inline } from '../types'\n\nexport function wrapInline(editor: Editor, inline: Inline) {\n Transforms.wrapNodes(editor, inline, {\n at: getSelection(editor),\n split: true,\n })\n}\n","import { Editor, Transforms } from 'slate'\nimport { ElementUtils } from '../utils/element'\nimport { getSelection } from '../selectors'\nimport { InlineType } from '../types'\n\nexport function unwrapInline(editor: Editor, type: InlineType) {\n Transforms.unwrapNodes(editor, {\n match: node => ElementUtils.isInline(node) && node.type === type,\n at: getSelection(editor),\n })\n}\n","import { Editor, Transforms } from 'slate'\nimport { setBlockKeyForDevice } from './setBlockKeyForDevice'\nimport { clearBlockKeyForDevice } from './clearBlockKeyForDevice'\nimport { wrapInline } from './wrapInline'\nimport { unwrapInline } from './unwrapInline'\nimport { getSelection } from '../selectors'\nimport { ElementUtils } from '../utils/element'\nimport { Select, createRichTextV2Plugin } from '../../controls'\nimport { getActiveBlockType } from '../selectors'\nimport { BlockType, RootBlockType } from '../types'\n\nexport const BlockActions = {\n setBlockKeyForDevice,\n clearBlockKeyForDevice,\n wrapInline,\n unwrapInline,\n}\n\nexport function withBlock(editor: Editor) {\n const { normalizeNode } = editor\n\n editor.isInline = entry => {\n return ElementUtils.isInline(entry)\n }\n\n editor.normalizeNode = entry => {\n const [normalizationNode, normalizationPath] = entry\n // Normalization textAlign with empty array of values\n if (ElementUtils.isBlock(normalizationNode) && normalizationNode?.textAlign?.length == 0) {\n Transforms.unsetNodes(editor, 'textAlign', { at: normalizationPath })\n return\n }\n\n normalizeNode(entry)\n }\n\n return editor\n}\n\nexport function BlockPlugin() {\n return createRichTextV2Plugin({\n withPlugin: withBlock,\n control: {\n definition: Select({\n label: 'Block',\n options: [\n {\n value: BlockType.Heading1,\n label: 'Heading1',\n },\n {\n value: BlockType.Heading2,\n label: 'Heading2',\n },\n {\n value: BlockType.Heading3,\n label: 'Heading3',\n },\n {\n value: BlockType.Heading4,\n label: 'Heading4',\n },\n {\n value: BlockType.Heading5,\n label: 'Heading5',\n },\n {\n value: BlockType.Heading6,\n label: 'Heading6',\n },\n {\n value: BlockType.Paragraph,\n label: 'Paragraph',\n },\n ],\n defaultValue: BlockType.Paragraph,\n }),\n onChange: (editor, value) => {\n Transforms.setNodes(\n editor,\n {\n type: value ?? BlockType.Default,\n },\n { at: getSelection(editor) },\n )\n },\n getValue: editor => {\n const activeBlock = getActiveBlockType(editor)\n\n // todo: these types are unhandled in for this mid milestone checkin\n if (\n activeBlock === RootBlockType.BlockQuote ||\n activeBlock === RootBlockType.OrderedList ||\n activeBlock === RootBlockType.UnorderedList ||\n activeBlock === RootBlockType.Text ||\n activeBlock === RootBlockType.Default\n )\n return undefined\n\n return activeBlock\n },\n },\n })\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,2BAA2B;AACjC,MAAM,0BAA0B;ACIhC,MAAM,cAAc;AAAA,EACzB,qBAAqB,QAAgB,MAA2C;AAC1E,QAAA;AACI,YAAA,aAAa,OAAO,MAAM,QAAQ;AAAA,QACtC,IAAI;AAAA,QACJ,OAAO,CAAC,SAA8B,aAAa,OAAO,IAAI;AAAA,MAAA,CAC/D;AACD,aAAO,kCAAc;AAAA,aACd;AACA,aAAA;AAAA,IACT;AAAA,EACF;AAAA,EACA,yBAAyB,QAAgB,MAA+C;AAClF,QAAA;AACI,YAAA,iBAAiB,OAAO,MAAM,QAAQ;AAAA,QAC1C,IAAI;AAAA,QACJ,OAAO,CAAC,SAAkC,aAAa,WAAW,IAAI;AAAA,MAAA,CACvE;AAED,aAAO,0CAAkB;AAAA,aAClB;AACA,aAAA;AAAA,IACT;AAAA,EACF;AACF;AC1BO,+BAA+B,SAA+C;AACnF,SAAO,QAAQ,OACb,CAAC,CAAA,EAAG,cACF,CAAC,KAAK,UAAU,QAAQ,EAAE,KAAK,CAAY,aAAA;AACl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YAAY;AAAA,IACZ,SAAS;AAAA,MACP,YAAY,OAAO;AAAA,QACjB,OAAO;AAAA,QACP,SAAS;AAAA,UACP;AAAA,YACE,OAAO,UAAU;AAAA,YACjB,OAAO;AAAA,UACT;AAAA,UACA;AAAA,YACE,OAAO,UAAU;AAAA,YACjB,OAAO;AAAA,UACT;AAAA,UACA;AAAA,YACE,OAAO,UAAU;AAAA,YACjB,OAAO;AAAA,UACT;AAAA,UACA;AAAA,YACE,OAAO,UAAU;AAAA,YACjB,OAAO;AAAA,UACT;AAAA,UACA;AAAA,YACE,OAAO,UAAU;AAAA,YACjB,OAAO;AAAA,UACT;AAAA,UACA;AAAA,YACE,OAAO,UAAU;AAAA,YACjB,OAAO;AAAA,UACT;AAAA,UACA;AAAA,YACE,OAAO,UAAU;AAAA,YACjB,OAAO;AAAA,UACT;AAAA,QACF;AAAA,QACA,cAAc,UAAU;AAAA,MAAA,CACzB;AAAA,MACD,UAAU,CAAC,QAAQ,UAAU;AAC3B,mBAAW,SACT,QACA;AAAA,UACE,MAAM,wBAAS,UAAU;AAAA,WAE3B,EAAE,IAAI,aAAa,MAAM,EAC3B,CAAA;AAAA,MACF;AAAA,MACA,UAAU,CAAU,WAAA;AACZ,cAAA,cAAc,mBAAmB,MAAM;AAG7C,YACE,gBAAgB,cAAc,cAC9B,gBAAgB,cAAc,eAC9B,gBAAgB,cAAc,iBAC9B,gBAAgB,cAAc,QAC9B,gBAAgB,cAAc;AAEvB,iBAAA;AAEF,eAAA;AAAA,MACT;AAAA,IACF;AAAA,EAAA,CACD;AACH;;"}
|
|
1
|
+
{"version":3,"file":"index.es5.js","sources":["../src/slate/TypographyPlugin/clearActiveTypographyStyle.ts","../src/slate/TypographyPlugin/clearDeviceActiveTypography.ts","../src/slate/TypographyPlugin/detachActiveTypography.ts","../src/slate/TypographyPlugin/setActiveTypographyId.ts","../src/slate/TypographyPlugin/setActiveTypographyStyle.ts","../src/slate/TypographyPlugin/index.ts"],"sourcesContent":["import { Editor, Transforms, Text, Range } from 'slate'\nimport { RichTextTypography } from '../types'\n\ntype ClearActiveTypographyStyleOptions = {\n at?: Range\n}\n\nexport function clearActiveTypographyStyle(\n editor: Editor,\n options?: ClearActiveTypographyStyleOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n const typography: RichTextTypography = {\n ...node.typography,\n style: [],\n }\n\n Transforms.setNodes(\n editor,\n {\n typography,\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\nimport { RichTextTypography } from '../types'\n\ntype ClearDeviceActiveTypographyOptions = {\n at?: Range\n}\n\nexport function clearDeviceActiveTypography(\n editor: Editor,\n currentDeviceId: string,\n options?: ClearDeviceActiveTypographyOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n const typography: RichTextTypography = {\n ...node.typography,\n style:\n node?.typography?.style.filter(({ deviceId }) => deviceId !== currentDeviceId) ?? [],\n }\n\n Transforms.setNodes(\n editor,\n {\n typography,\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\nimport { RichTextTypography } from '../types'\n\ntype SetActiveTypographyIdOptions = {\n at?: Range\n}\n\nexport function detachActiveTypography(\n editor: Editor,\n value: RichTextTypography['style'],\n options?: SetActiveTypographyIdOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n Transforms.setNodes(\n editor,\n {\n typography: {\n style: value,\n },\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\n\ntype SetActiveTypographyIdOptions = {\n at?: Range\n}\n\nexport function setActiveTypographyId(\n editor: Editor,\n id?: string,\n options?: SetActiveTypographyIdOptions,\n) {\n const at = options?.at ?? editor.selection\n if (!at) return\n Transforms.setNodes(\n editor,\n {\n typography: {\n id,\n style: [],\n },\n },\n {\n at,\n match: node => Text.isText(node),\n split: Range.isExpanded(at),\n },\n )\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\nimport { Breakpoints, findBreakpointOverride, BreakpointId } from '../../state/modules/breakpoints'\nimport { RichTextTypography } from '../types'\n\ntype SetActiveTypographyStyleOptions = {\n at?: Range\n}\n\nexport function setActiveTypographyStyle(\n editor: Editor,\n breakpoints: Breakpoints,\n deviceId: string,\n prop: string,\n value?: unknown,\n options?: SetActiveTypographyStyleOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n const deviceOverrides = node?.typography?.style ?? []\n const deviceStyle = findBreakpointOverride(\n breakpoints,\n deviceOverrides,\n deviceId as BreakpointId,\n v => v,\n ) || {\n value: {},\n }\n const nextDeviceStyle = {\n deviceId,\n value: { ...deviceStyle.value, [prop]: value },\n }\n\n const nextTypography: RichTextTypography = {\n ...node.typography,\n style: [...deviceOverrides.filter(v => v.deviceId !== deviceId), nextDeviceStyle],\n }\n\n Transforms.setNodes(\n editor,\n {\n typography: nextTypography,\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Text, Transforms } from 'slate'\nimport { clearActiveTypographyStyle } from './clearActiveTypographyStyle'\nimport { clearDeviceActiveTypography } from './clearDeviceActiveTypography'\nimport { detachActiveTypography } from './detachActiveTypography'\nimport { setActiveTypographyId } from './setActiveTypographyId'\nimport { setActiveTypographyStyle } from './setActiveTypographyStyle'\n\nexport const TypographyActions = {\n setActiveTypographyId,\n setActiveTypographyStyle,\n clearActiveTypographyStyle,\n clearDeviceActiveTypography,\n detachActiveTypography,\n}\n\nexport function withTypography(editor: Editor) {\n const { normalizeNode } = editor\n editor.normalizeNode = entry => {\n const [normalizationNode, normalizationPath] = entry\n if (\n Text.isText(normalizationNode) &&\n normalizationNode?.typography?.id == null &&\n normalizationNode?.typography?.style.length === 0\n ) {\n Transforms.unsetNodes(editor, 'typography', { at: normalizationPath })\n return\n }\n\n if (Text.isText(normalizationNode) && normalizationNode?.slice != null) {\n Transforms.unsetNodes(editor, 'slice', { at: normalizationPath })\n return\n }\n\n norm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ate";
|
|
2
2
|
import isHotkey from "is-hotkey";
|
|
3
|
-
import {
|
|
4
|
-
import { E as ElementUtils } from "./index.es7.js";
|
|
3
|
+
import { bd as ElementUtils, bk as BlockType, b8 as createRichTextV2Plugin } from "./react-page.es.js";
|
|
5
4
|
const BLOCK_ONE_PATH = [0];
|
|
6
5
|
const BLOCK_TWO_PATH = [1];
|
|
7
6
|
function withInlineMode(editor) {
|
package/dist/index.es6.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es6.js","sources":["../src/slate/InlineModePlugin/index.ts"],"sourcesContent":["import { Editor, Path, Transforms } from 'slate'\nimport { KeyboardEvent } from 'react'\nimport isHotkey from 'is-hotkey'\nimport { createRichTextV2Plugin } from '../../controls/rich-text-v2'\nimport { ElementUtils } from '../utils/element'\nimport { BlockType } from '../types'\n\nconst BLOCK_ONE_PATH = [0]\nconst BLOCK_TWO_PATH = [1]\n\nexport function withInlineMode(editor: Editor): Editor {\n const { normalizeNode } = editor\n editor.normalizeNode = entry => {\n const [normalizationNode, normalizationPath] = entry\n\n /**\n * Merge root nodes past the first one\n */\n if (Path.equals(BLOCK_TWO_PATH, normalizationPath)) {\n Transforms.mergeNodes(editor, { at: BLOCK_TWO_PATH })\n return\n }\n /**\n * Unwrap non text nodes of first root node\n */\n if (\n Path.isAncestor(BLOCK_ONE_PATH, normalizationPath) &&\n ElementUtils.isBlock(normalizationNode)\n ) {\n Transforms.unwrapNodes(editor, {\n at: normalizationPath,\n })\n return\n }\n /**\n * Update type of root nodes to be `text-block`\n */\n if (Path.equals(BLOCK_ONE_PATH, normalizationPath)) {\n Transforms.setNodes(editor, { type: BlockType.Text }, { at: normalizationPath })\n return\n }\n\n normalizeNode(entry)\n }\n\n return editor\n}\n\nexport const InlineModePlugin = createRichTextV2Plugin({\n onKeyDown: (e: KeyboardEvent) => {\n if (isHotkey('enter', e)) e.preventDefault()\n },\n withPlugin: withInlineMode,\n})\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.es6.js","sources":["../src/slate/InlineModePlugin/index.ts"],"sourcesContent":["import { Editor, Path, Transforms } from 'slate'\nimport { KeyboardEvent } from 'react'\nimport isHotkey from 'is-hotkey'\nimport { createRichTextV2Plugin } from '../../controls/rich-text-v2'\nimport { ElementUtils } from '../utils/element'\nimport { BlockType } from '../types'\n\nconst BLOCK_ONE_PATH = [0]\nconst BLOCK_TWO_PATH = [1]\n\nexport function withInlineMode(editor: Editor): Editor {\n const { normalizeNode } = editor\n editor.normalizeNode = entry => {\n const [normalizationNode, normalizationPath] = entry\n\n /**\n * Merge root nodes past the first one\n */\n if (Path.equals(BLOCK_TWO_PATH, normalizationPath)) {\n Transforms.mergeNodes(editor, { at: BLOCK_TWO_PATH })\n return\n }\n /**\n * Unwrap non text nodes of first root node\n */\n if (\n Path.isAncestor(BLOCK_ONE_PATH, normalizationPath) &&\n ElementUtils.isBlock(normalizationNode)\n ) {\n Transforms.unwrapNodes(editor, {\n at: normalizationPath,\n })\n return\n }\n /**\n * Update type of root nodes to be `text-block`\n */\n if (Path.equals(BLOCK_ONE_PATH, normalizationPath)) {\n Transforms.setNodes(editor, { type: BlockType.Text }, { at: normalizationPath })\n return\n }\n\n normalizeNode(entry)\n }\n\n return editor\n}\n\nexport const InlineModePlugin = createRichTextV2Plugin({\n onKeyDown: (e: KeyboardEvent) => {\n if (isHotkey('enter', e)) e.preventDefault()\n },\n withPlugin: withInlineMode,\n})\n"],"names":[],"mappings":";;;AAOA,MAAM,iBAAiB,CAAC,CAAC;AACzB,MAAM,iBAAiB,CAAC,CAAC;AAElB,wBAAwB,QAAwB;AACrD,QAAM,EAAE,kBAAkB;AAC1B,SAAO,gBAAgB,CAAS,UAAA;AACxB,UAAA,CAAC,mBAAmB,qBAAqB;AAK/C,QAAI,KAAK,OAAO,gBAAgB,iBAAiB,GAAG;AAClD,iBAAW,WAAW,QAAQ,EAAE,IAAI,eAAgB,CAAA;AACpD;AAAA,IACF;AAKE,QAAA,KAAK,WAAW,gBAAgB,iBAAiB,KACjD,aAAa,QAAQ,iBAAiB,GACtC;AACA,iBAAW,YAAY,QAAQ;AAAA,QAC7B,IAAI;AAAA,MAAA,CACL;AACD;AAAA,IACF;AAIA,QAAI,KAAK,OAAO,gBAAgB,iBAAiB,GAAG;AACvC,iBAAA,SAAS,QAAQ,EAAE,MAAM,UAAU,QAAQ,EAAE,IAAI,kBAAA,CAAmB;AAC/E;AAAA,IACF;AAEA,kBAAc,KAAK;AAAA,EAAA;AAGd,SAAA;AACT;AAEO,MAAM,mBAAmB,uBAAuB;AAAA,EACrD,WAAW,CAAC,MAAqB;AAC3B,QAAA,SAAS,SAAS,CAAC;AAAG,QAAE,eAAe;AAAA,EAC7C;AAAA,EACA,YAAY;AACd,CAAC;;"}
|
package/dist/index.es7.js
CHANGED
|
@@ -1,56 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { b4 as BlockType, b5 as InlineType } from "./react-page.es.js";
|
|
1
|
+
import { Transforms, Editor } from "slate";
|
|
3
2
|
import { ReactEditor } from "slate-react";
|
|
4
|
-
const ElementUtils = {
|
|
5
|
-
isRootBlock(node) {
|
|
6
|
-
return Element.isElement(node) && (Element.isElementType(node, BlockType.Paragraph) || Element.isElementType(node, BlockType.Heading1) || Element.isElementType(node, BlockType.Heading2) || Element.isElementType(node, BlockType.Heading3) || Element.isElementType(node, BlockType.Heading3) || Element.isElementType(node, BlockType.Heading4) || Element.isElementType(node, BlockType.Heading5) || Element.isElementType(node, BlockType.Heading6) || Element.isElementType(node, BlockType.BlockQuote) || Element.isElementType(node, BlockType.UnorderedList) || Element.isElementType(node, BlockType.OrderedList) || Element.isElementType(node, BlockType.Text) || Element.isElementType(node, BlockType.Default));
|
|
7
|
-
},
|
|
8
|
-
isBlock(node) {
|
|
9
|
-
return Element.isElement(node) && (this.isRootBlock(node) || Element.isElementType(node, BlockType.ListItem) || Element.isElementType(node, BlockType.ListItemChild));
|
|
10
|
-
},
|
|
11
|
-
isInline(node) {
|
|
12
|
-
return Element.isElementType(node, InlineType.Code) || Element.isElementType(node, InlineType.Link) || Element.isElementType(node, InlineType.SubScript) || Element.isElementType(node, InlineType.SuperScript);
|
|
13
|
-
},
|
|
14
|
-
isConvertibleToListTextNode(node) {
|
|
15
|
-
return !this.isList(node) && !this.isListItem(node) && !this.isListItemChild(node);
|
|
16
|
-
},
|
|
17
|
-
isParagraph(node) {
|
|
18
|
-
return Element.isElementType(node, BlockType.Paragraph);
|
|
19
|
-
},
|
|
20
|
-
isList(node) {
|
|
21
|
-
return Element.isElementType(node, BlockType.OrderedList) || Element.isElementType(node, BlockType.UnorderedList);
|
|
22
|
-
},
|
|
23
|
-
isListItem(node) {
|
|
24
|
-
return Element.isElementType(node, BlockType.ListItem);
|
|
25
|
-
},
|
|
26
|
-
isListItemChild(node) {
|
|
27
|
-
return Element.isElementType(node, BlockType.ListItemChild);
|
|
28
|
-
},
|
|
29
|
-
createText() {
|
|
30
|
-
return { text: "" };
|
|
31
|
-
},
|
|
32
|
-
createParagraph() {
|
|
33
|
-
return {
|
|
34
|
-
children: [this.createText()],
|
|
35
|
-
type: BlockType.Paragraph
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
createList(type = BlockType.UnorderedList) {
|
|
39
|
-
return { children: [this.createText()], type };
|
|
40
|
-
},
|
|
41
|
-
createListItem() {
|
|
42
|
-
return {
|
|
43
|
-
children: [this.createListItemChild()],
|
|
44
|
-
type: BlockType.ListItem
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
createListItemChild() {
|
|
48
|
-
return {
|
|
49
|
-
children: [this.createText()],
|
|
50
|
-
type: BlockType.ListItemChild
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
3
|
function withBuilder(editor) {
|
|
55
4
|
editor.deselectAndBlur = function() {
|
|
56
5
|
ReactEditor.deselect(editor);
|
|
@@ -65,5 +14,5 @@ function withBuilder(editor) {
|
|
|
65
14
|
};
|
|
66
15
|
return editor;
|
|
67
16
|
}
|
|
68
|
-
export {
|
|
17
|
+
export { withBuilder as w };
|
|
69
18
|
//# sourceMappingURL=index.es7.js.map
|
package/dist/index.es7.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es7.js","sources":["../src/slate/
|
|
1
|
+
{"version":3,"file":"index.es7.js","sources":["../src/slate/BuilderPlugin/index.ts"],"sourcesContent":["import { BaseEditor, Editor, Transforms } from 'slate'\nimport { ReactEditor } from 'slate-react'\n\nexport interface BuilderEditor extends BaseEditor {\n focusAndSelectAll: () => void\n deselectAndBlur: () => void\n}\n\nexport function withBuilder(editor: Editor) {\n editor.deselectAndBlur = function () {\n ReactEditor.deselect(editor)\n ReactEditor.blur(editor)\n }\n\n editor.focusAndSelectAll = function () {\n ReactEditor.focus(editor)\n Transforms.select(editor, {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n })\n }\n\n return editor\n}\n"],"names":[],"mappings":";;AAQO,qBAAqB,QAAgB;AAC1C,SAAO,kBAAkB,WAAY;AACnC,gBAAY,SAAS,MAAM;AAC3B,gBAAY,KAAK,MAAM;AAAA,EAAA;AAGzB,SAAO,oBAAoB,WAAY;AACrC,gBAAY,MAAM,MAAM;AACxB,eAAW,OAAO,QAAQ;AAAA,MACxB,QAAQ,OAAO,MAAM,QAAQ,CAAA,CAAE;AAAA,MAC/B,OAAO,OAAO,IAAI,QAAQ,CAAA,CAAE;AAAA,IAAA,CAC7B;AAAA,EAAA;AAGI,SAAA;AACT;;"}
|
package/dist/index.es8.js
CHANGED
|
@@ -8,18 +8,18 @@ import "redux";
|
|
|
8
8
|
import "redux-thunk";
|
|
9
9
|
import "./actions.es.js";
|
|
10
10
|
import "./state/breakpoints.es.js";
|
|
11
|
-
import "slate";
|
|
12
|
-
import "is-hotkey";
|
|
13
|
-
import "slate-react";
|
|
14
11
|
import "@emotion/css";
|
|
15
12
|
import "@emotion/serialize";
|
|
16
13
|
import "@emotion/utils";
|
|
14
|
+
import "slate";
|
|
15
|
+
import "is-hotkey";
|
|
16
|
+
import "slate-react";
|
|
17
17
|
import "react/jsx-runtime";
|
|
18
18
|
import "./text-input.es.js";
|
|
19
19
|
import "./combobox.es.js";
|
|
20
|
-
import "./select.es.js";
|
|
21
20
|
import "use-sync-external-store/shim";
|
|
22
21
|
import "./types.es.js";
|
|
22
|
+
import "./deepEqual.es.js";
|
|
23
23
|
import "./box-models.es.js";
|
|
24
24
|
import "css-box-model";
|
|
25
25
|
import "color";
|
|
@@ -27,6 +27,7 @@ import "scroll-into-view-if-needed";
|
|
|
27
27
|
import "react-dom";
|
|
28
28
|
import "html-react-parser";
|
|
29
29
|
import "next/head";
|
|
30
|
+
import "zod";
|
|
30
31
|
import "@emotion/server/create-instance";
|
|
31
32
|
import "next/document";
|
|
32
33
|
import "cors";
|
package/dist/index.es8.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es8.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.es8.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.es9.js
CHANGED
|
@@ -17,31 +17,43 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
20
32
|
import { useMemo, useState, useRef, useEffect, useCallback } from "react";
|
|
21
33
|
import { Range, createEditor } from "slate";
|
|
22
34
|
import isHotkey from "is-hotkey";
|
|
23
35
|
import { withHistory, HistoryEditor } from "slate-history";
|
|
24
36
|
import { ReactEditor, withReact, Slate, Editable } from "slate-react";
|
|
25
|
-
import {
|
|
37
|
+
import { bk as BlockType, b7 as RichTextV2Mode, bt as BuilderEditMode, Z as useStyle } from "./react-page.es.js";
|
|
26
38
|
import "./state/breakpoints.es.js";
|
|
27
39
|
import { I as InlineModePlugin } from "./index.es6.js";
|
|
28
40
|
import { w as withBuilder } from "./index.es7.js";
|
|
29
|
-
import {
|
|
41
|
+
import { N as useBuilderEditMode, O as pollBoxModel, Q as ControlValue } from "./index.es.js";
|
|
30
42
|
import { u as useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.es.js";
|
|
31
43
|
import { cx } from "@emotion/css";
|
|
32
44
|
import { jsx } from "react/jsx-runtime";
|
|
33
45
|
import "redux";
|
|
34
46
|
import "redux-thunk";
|
|
35
47
|
import "./actions.es.js";
|
|
36
|
-
import "use-sync-external-store/shim/with-selector";
|
|
37
|
-
import "next/dynamic";
|
|
38
48
|
import "@emotion/serialize";
|
|
39
49
|
import "@emotion/utils";
|
|
50
|
+
import "use-sync-external-store/shim/with-selector";
|
|
51
|
+
import "next/dynamic";
|
|
40
52
|
import "./text-input.es.js";
|
|
41
53
|
import "./combobox.es.js";
|
|
42
|
-
import "./select.es.js";
|
|
43
54
|
import "use-sync-external-store/shim";
|
|
44
55
|
import "./types.es.js";
|
|
56
|
+
import "./deepEqual.es.js";
|
|
45
57
|
import "./box-models.es.js";
|
|
46
58
|
import "css-box-model";
|
|
47
59
|
import "color";
|
|
@@ -49,6 +61,7 @@ import "scroll-into-view-if-needed";
|
|
|
49
61
|
import "react-dom";
|
|
50
62
|
import "html-react-parser";
|
|
51
63
|
import "next/head";
|
|
64
|
+
import "zod";
|
|
52
65
|
import "@emotion/server/create-instance";
|
|
53
66
|
import "next/document";
|
|
54
67
|
import "cors";
|
|
@@ -81,21 +94,66 @@ function useSyncDOMSelection(editor, isEnabled) {
|
|
|
81
94
|
}
|
|
82
95
|
});
|
|
83
96
|
}
|
|
97
|
+
function RichTextV2Element(_a) {
|
|
98
|
+
var _b = _a, {
|
|
99
|
+
definition,
|
|
100
|
+
plugins
|
|
101
|
+
} = _b, props = __objRest(_b, [
|
|
102
|
+
"definition",
|
|
103
|
+
"plugins"
|
|
104
|
+
]);
|
|
105
|
+
const blockStyles = [useStyle({
|
|
106
|
+
margin: 0
|
|
107
|
+
})];
|
|
108
|
+
function initialRenderElement(props2) {
|
|
109
|
+
switch (props2.element.type) {
|
|
110
|
+
case BlockType.Default:
|
|
111
|
+
default:
|
|
112
|
+
if (definition.config.mode === RichTextV2Mode.Inline) {
|
|
113
|
+
return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, props2.attributes), {
|
|
114
|
+
className: cx(...blockStyles),
|
|
115
|
+
children: props2.children
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
return /* @__PURE__ */ jsx("p", __spreadProps(__spreadValues({}, props2.attributes), {
|
|
119
|
+
className: cx(...blockStyles),
|
|
120
|
+
children: props2.children
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const renderElement = plugins.reduce((renderFn, plugin) => (props2) => {
|
|
125
|
+
const {
|
|
126
|
+
control,
|
|
127
|
+
renderElement: renderElement2
|
|
128
|
+
} = plugin;
|
|
129
|
+
if ((control == null ? void 0 : control.definition) == null || renderElement2 == null)
|
|
130
|
+
return renderFn(props2);
|
|
131
|
+
if (control.getElementValue == null)
|
|
132
|
+
return renderElement2(renderFn, void 0)(props2);
|
|
133
|
+
return /* @__PURE__ */ jsx(ControlValue, {
|
|
134
|
+
definition: control.definition,
|
|
135
|
+
data: control.getElementValue(props2.element),
|
|
136
|
+
children: (value) => renderElement2(renderFn, value)(props2)
|
|
137
|
+
});
|
|
138
|
+
}, initialRenderElement);
|
|
139
|
+
return renderElement(props);
|
|
140
|
+
}
|
|
84
141
|
const defaultText = [{
|
|
85
|
-
type: BlockType.
|
|
142
|
+
type: BlockType.Default,
|
|
86
143
|
children: [{
|
|
87
144
|
text: ""
|
|
88
145
|
}]
|
|
89
146
|
}];
|
|
90
147
|
function EditableTextV2({
|
|
91
148
|
text,
|
|
149
|
+
definition,
|
|
92
150
|
control
|
|
93
151
|
}) {
|
|
94
152
|
const plugins = useMemo(() => {
|
|
95
|
-
var _a, _b, _c
|
|
96
|
-
const plugins2 = [...(
|
|
153
|
+
var _a, _b, _c;
|
|
154
|
+
const plugins2 = [...(_b = (_a = definition == null ? void 0 : definition.config) == null ? void 0 : _a.plugins) != null ? _b : [], ...((_c = definition == null ? void 0 : definition.config) == null ? void 0 : _c.mode) === RichTextV2Mode.Inline ? [InlineModePlugin] : []];
|
|
97
155
|
return plugins2;
|
|
98
|
-
}, [
|
|
156
|
+
}, [definition]);
|
|
99
157
|
const [editor] = useState(() => plugins.reduceRight((editor2, plugin) => {
|
|
100
158
|
var _a, _b;
|
|
101
159
|
return (_b = (_a = plugin == null ? void 0 : plugin.withPlugin) == null ? void 0 : _a.call(plugin, editor2)) != null ? _b : editor2;
|
|
@@ -112,67 +170,12 @@ function EditableTextV2({
|
|
|
112
170
|
onBoxModelChange: (boxModel) => control.changeBoxModel(boxModel)
|
|
113
171
|
});
|
|
114
172
|
}, [editor, control]);
|
|
115
|
-
const renderElement = useCallback(({
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
margin: 0
|
|
122
|
-
})];
|
|
123
|
-
switch (element.type) {
|
|
124
|
-
case BlockType.Text:
|
|
125
|
-
return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, attributes), {
|
|
126
|
-
className: cx(...blockStyles),
|
|
127
|
-
children
|
|
128
|
-
}));
|
|
129
|
-
case BlockType.Paragraph:
|
|
130
|
-
return /* @__PURE__ */ jsx("p", __spreadProps(__spreadValues({}, attributes), {
|
|
131
|
-
className: cx(...blockStyles),
|
|
132
|
-
children
|
|
133
|
-
}));
|
|
134
|
-
case BlockType.Heading1:
|
|
135
|
-
return /* @__PURE__ */ jsx("h1", __spreadProps(__spreadValues({}, attributes), {
|
|
136
|
-
className: cx(...blockStyles),
|
|
137
|
-
children
|
|
138
|
-
}));
|
|
139
|
-
case BlockType.Heading2:
|
|
140
|
-
return /* @__PURE__ */ jsx("h2", __spreadProps(__spreadValues({}, attributes), {
|
|
141
|
-
className: cx(...blockStyles),
|
|
142
|
-
children
|
|
143
|
-
}));
|
|
144
|
-
case BlockType.Heading3:
|
|
145
|
-
return /* @__PURE__ */ jsx("h3", __spreadProps(__spreadValues({}, attributes), {
|
|
146
|
-
className: cx(...blockStyles),
|
|
147
|
-
children
|
|
148
|
-
}));
|
|
149
|
-
case BlockType.Heading4:
|
|
150
|
-
return /* @__PURE__ */ jsx("h4", __spreadProps(__spreadValues({}, attributes), {
|
|
151
|
-
className: cx(...blockStyles),
|
|
152
|
-
children
|
|
153
|
-
}));
|
|
154
|
-
case BlockType.Heading5:
|
|
155
|
-
return /* @__PURE__ */ jsx("h5", __spreadProps(__spreadValues({}, attributes), {
|
|
156
|
-
className: cx(...blockStyles),
|
|
157
|
-
children
|
|
158
|
-
}));
|
|
159
|
-
case BlockType.Heading6:
|
|
160
|
-
return /* @__PURE__ */ jsx("h6", __spreadProps(__spreadValues({}, attributes), {
|
|
161
|
-
className: cx(...blockStyles),
|
|
162
|
-
children
|
|
163
|
-
}));
|
|
164
|
-
case BlockType.Default:
|
|
165
|
-
default:
|
|
166
|
-
if ((control == null ? void 0 : control.descriptor.config.mode) === RichTextV2Mode.Inline) {
|
|
167
|
-
return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, attributes), {
|
|
168
|
-
children
|
|
169
|
-
}));
|
|
170
|
-
}
|
|
171
|
-
return /* @__PURE__ */ jsx("p", __spreadProps(__spreadValues({}, attributes), {
|
|
172
|
-
children
|
|
173
|
-
}));
|
|
174
|
-
}
|
|
175
|
-
}, []);
|
|
173
|
+
const renderElement = useCallback((props) => {
|
|
174
|
+
return /* @__PURE__ */ jsx(RichTextV2Element, __spreadProps(__spreadValues({}, props), {
|
|
175
|
+
definition,
|
|
176
|
+
plugins
|
|
177
|
+
}));
|
|
178
|
+
}, [plugins, definition]);
|
|
176
179
|
const renderLeaf = useCallback(({
|
|
177
180
|
attributes,
|
|
178
181
|
children
|
|
@@ -208,7 +211,7 @@ function EditableTextV2({
|
|
|
208
211
|
}
|
|
209
212
|
plugins.forEach((plugin) => {
|
|
210
213
|
var _a;
|
|
211
|
-
return (_a = plugin == null ? void 0 : plugin.onKeyDown) == null ? void 0 : _a.call(plugin, e);
|
|
214
|
+
return (_a = plugin == null ? void 0 : plugin.onKeyDown) == null ? void 0 : _a.call(plugin, e, editor);
|
|
212
215
|
});
|
|
213
216
|
}, [control, plugins, editor]);
|
|
214
217
|
const handleKeyUp = useCallback((e) => {
|
package/dist/index.es9.js.map
CHANGED
|
@@ -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/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 {\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport { Descendant, createEditor } from 'slate'\nimport isHotkey from 'is-hotkey'\nimport { withHistory, HistoryEditor } from 'slate-history'\nimport {\n withReact,\n ReactEditor,\n RenderElementProps,\n RenderLeafProps,\n Slate,\n Editable,\n} from 'slate-react'\n\nimport {\n RichTextV2Control,\n RichTextV2ControlData,\n RichTextV2ControlDefinition,\n RichTextV2Mode,\n} from '../../../../../controls'\nimport { useBuilderEditMode } from '../../..'\nimport { BuilderEditMode } from '../../../../../state/modules/builder-edit-mode'\nimport { pollBoxModel } from '../../../poll-box-model'\nimport { InlineModePlugin, withBuilder } from '../../../../../slate'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { BlockType } from '../../../../../slate'\nimport { useStyle } from '../../../use-style'\nimport { cx } from '@emotion/css'\n\nexport type RichTextV2ControlValue = ReactNode\n\nexport type Descriptors = { text?: RichTextV2ControlDefinition }\n\nconst defaultText: Descendant[] = [{ type: BlockType.Text, children: [{ text: '' }] }]\n\ntype Props = {\n text: RichTextV2ControlData\n control: RichTextV2Control | null\n}\n\nexport function EditableTextV2({ text, control }: Props) {\n const plugins = useMemo(() => {\n const plugins = [\n ...(control?.descriptor?.config?.plugins ?? []),\n ...(control?.descriptor?.config?.mode === RichTextV2Mode.Inline ? [InlineModePlugin] : []),\n ]\n return plugins\n }, [control?.descriptor.config])\n\n const [editor] = useState(() =>\n plugins.reduceRight(\n (editor, plugin) => plugin?.withPlugin?.(editor) ?? editor,\n withBuilder(withHistory(withReact(createEditor()))),\n ),\n )\n\n const isPreservingFocus = useRef(false)\n useSyncDOMSelection(editor, isPreservingFocus)\n\n const editMode = useBuilderEditMode()\n\n useEffect(() => {\n if (control == null) return\n\n const element = ReactEditor.toDOMNode(editor, editor)\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeBoxModel(boxModel),\n })\n }, [editor, control])\n\n const renderElement = useCallback(({ attributes, children, element }: RenderElementProps) => {\n // TODO: move this markup into the block plugin once we have a way of composing render functionality.\n const blockStyles = [useStyle({ margin: 0 })]\n\n switch (element.type) {\n case BlockType.Text:\n return (\n <span {...attributes} className={cx(...blockStyles)}>\n {children}\n </span>\n )\n case BlockType.Paragraph:\n return (\n <p {...attributes} className={cx(...blockStyles)}>\n {children}\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 {...attributes} className={cx(...blockStyles)}>\n {children}\n </h6>\n )\n case BlockType.Default:\n default:\n if (control?.descriptor.config.mode === RichTextV2Mode.Inline) {\n return <span {...attributes}>{children}</span>\n }\n\n return <p {...attributes}>{children}</p>\n }\n }, [])\n\n const renderLeaf = useCallback(({ attributes, children }: RenderLeafProps) => {\n return <span {...attributes}>{children}</span>\n }, [])\n\n const initialValue = useMemo(() => text ?? defaultText, [text])\n\n useEffect(() => {\n /**\n * This is required because clicking on the overlay has `relatedTarget` null just like the sidebar, but\n * - in the case of the overlay we switch to BUILD mode\n * - in the case of the sidebar we preserve the selection\n */\n if (editMode !== BuilderEditMode.CONTENT) {\n isPreservingFocus.current = false\n ReactEditor.deselect(editor)\n }\n }, [editMode])\n\n useEffect(() => {\n control?.setEditor(editor)\n control?.setDefaultValue(defaultText)\n }, [control, editor, defaultText])\n\n const handleFocus = useCallback(() => {\n isPreservingFocus.current = true\n control?.select()\n }, [control])\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (isHotkey('mod+shift+z', e)) return HistoryEditor.redo(editor)\n if (isHotkey('mod+z', e)) return HistoryEditor.undo(editor)\n if (isHotkey('escape')(e)) {\n isPreservingFocus.current = false\n ReactEditor.blur(editor)\n control?.switchToBuildMode()\n }\n\n plugins.forEach(plugin => plugin?.onKeyDown?.(e))\n },\n [control, plugins, editor],\n )\n\n const handleKeyUp = useCallback(\n (e: KeyboardEvent) => {\n if (editMode === BuilderEditMode.CONTENT) e.preventDefault()\n },\n [control, editor, editMode],\n )\n\n const handleClick = useCallback(\n (e: MouseEvent) => {\n if (editMode === BuilderEditMode.CONTENT) e.stopPropagation()\n },\n [editMode],\n )\n\n const handleBlur = useCallback((e: FocusEvent) => {\n // outside of iframe (overlay, sidebar, etc)\n if (e.relatedTarget == null) return\n // another text\n if (e.relatedTarget?.getAttribute('contenteditable') === 'true')\n isPreservingFocus.current = false\n }, [])\n\n const handleOnChange = useCallback(\n (value: Descendant[]) => {\n control?.onChange(value)\n },\n [control],\n )\n\n return (\n <Slate editor={editor} onChange={handleOnChange} value={initialValue}>\n <Editable\n renderLeaf={renderLeaf}\n renderElement={renderElement}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n onClick={handleClick}\n onBlur={handleBlur}\n readOnly={editMode !== BuilderEditMode.CONTENT}\n placeholder=\"Write some text...\"\n />\n </Slate>\n )\n}\n\nexport default EditableTextV2\n"],"names":["editor","isEnabled","useIsomorphicLayoutEffect","current","selection","ReactEditor","isFocused","root","findDocumentOrShadowRoot","domSelection","getSelection","newDomRange","toDOMRange","SlateRange","isBackward","setBaseAndExtent","endContainer","endOffset","startContainer","startOffset","removeAllRanges","e","console","error","defaultText","type","BlockType","Text","children","text","control","plugins","useMemo","descriptor","config","mode","RichTextV2Mode","Inline","InlineModePlugin","useState","reduceRight","plugin","withPlugin","withBuilder","withHistory","withReact","createEditor","isPreservingFocus","useRef","useSyncDOMSelection","editMode","useBuilderEditMode","useEffect","element","toDOMNode","pollBoxModel","onBoxModelChange","boxModel","changeBoxModel","renderElement","useCallback","attributes","blockStyles","useStyle","margin","cx","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","Default","renderLeaf","initialValue","BuilderEditMode","CONTENT","deselect","setEditor","setDefaultValue","handleFocus","select","handleKeyDown","isHotkey","HistoryEditor","redo","undo","blur","switchToBuildMode","forEach","onKeyDown","handleKeyUp","preventDefault","handleClick","stopPropagation","handleBlur","relatedTarget","getAttribute","handleOnChange","value","onChange"],"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;AACXE,YAAAA,MAAWC,WAAWd,OAAOI,SAA7B,GAA0C;AAC9BW,uDAAAA,iBACZJ,YAAYK,cACZL,YAAYM,WACZN,YAAYO,gBACZP,YAAYQ;AAAAA,QAJd,OA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BAAgBC;AAASxD,QAAEwE,eAAF;AAAA,EAE5C,GAAA,CAAC/D,SAAS9B,QAAQkD,QAAlB,CAJ6B;AAOzB4C,QAAAA,cAAclC,YAClB,CAACvC,MAAkB;AACb6B,QAAAA,aAAa0B,gBAAgBC;AAASxD,QAAE0E,gBAAF;AAAA,EAAA,GAE5C,CAAC7C,QAAD,CAJ6B;AAOzB8C,QAAAA,aAAapC,YAAY,CAACvC,MAAkB;;AAEhD,QAAIA,EAAE4E,iBAAiB;AAAM;AAE7B,QAAI5E,SAAE4E,kBAAF5E,mBAAiB6E,aAAa,wBAAuB;AACvDnD,wBAAkB5C,UAAU;AAAA,EALF,GAM3B,CAN2B,CAAA;AAQxBgG,QAAAA,iBAAiBvC,YACrB,CAACwC,UAAwB;AACvBtE,uCAASuE,SAASD;AAAAA,EAAlB,GAEF,CAACtE,OAAD,CAJgC;AAOlC,6BACG,OAAD;AAAA,IAAO;AAAA,IAAgB,UAAUqE;AAAAA,IAAgB,OAAOxB;AAAAA,IAAxD,8BACG,UAAD;AAAA,MACE;AAAA,MACA;AAAA,MACA,SAASM;AAAAA,MACT,WAAWE;AAAAA,MACX,SAASS;AAAAA,MACT,SAASE;AAAAA,MACT,QAAQE;AAAAA,MACR,UAAU9C,aAAa0B,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/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 {\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport { Descendant, createEditor } from 'slate'\nimport isHotkey from 'is-hotkey'\nimport { withHistory, HistoryEditor } from 'slate-history'\nimport {\n withReact,\n ReactEditor,\n RenderElementProps,\n RenderLeafProps,\n Slate,\n Editable,\n} from 'slate-react'\n\nimport {\n RichTextV2Control,\n RichTextV2ControlData,\n RichTextV2ControlDefinition,\n RichTextV2Mode,\n RichTextV2Plugin,\n} from '../../../../../controls'\nimport { useBuilderEditMode } from '../../..'\nimport { BuilderEditMode } from '../../../../../state/modules/builder-edit-mode'\nimport { pollBoxModel } from '../../../poll-box-model'\nimport { InlineModePlugin, withBuilder } from '../../../../../slate'\nimport { useSyncDOMSelection } from './useSyncDOMSelection'\nimport { BlockType } from '../../../../../slate'\nimport { useStyle } from '../../../use-style'\nimport { cx } from '@emotion/css'\nimport { ControlValue } from '../../control'\n\ntype RichTextV2ElementProps = RenderElementProps & {\n definition: RichTextV2ControlDefinition\n plugins: RichTextV2Plugin[]\n}\n\nfunction RichTextV2Element({ definition, plugins, ...props }: RichTextV2ElementProps) {\n const blockStyles = [useStyle({ margin: 0 })]\n\n function initialRenderElement(props: RenderElementProps) {\n switch (props.element.type) {\n case BlockType.Default:\n default:\n if (definition.config.mode === RichTextV2Mode.Inline) {\n return (\n <span {...props.attributes} className={cx(...blockStyles)}>\n {props.children}\n </span>\n )\n }\n\n return (\n <p {...props.attributes} className={cx(...blockStyles)}>\n {props.children}\n </p>\n )\n }\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement(props)\n}\n\nexport type RichTextV2ControlValue = ReactNode\n\nexport type Descriptors = { text?: RichTextV2ControlDefinition }\n\nconst defaultText: Descendant[] = [{ type: BlockType.Default, children: [{ text: '' }] }]\n\ntype Props = {\n text: RichTextV2ControlData\n definition: RichTextV2ControlDefinition\n control: RichTextV2Control | null\n}\n\nexport function EditableTextV2({ text, definition, control }: Props) {\n const plugins = useMemo(() => {\n const plugins = [\n ...(definition?.config?.plugins ?? []),\n ...(definition?.config?.mode === RichTextV2Mode.Inline ? [InlineModePlugin] : []),\n ]\n return plugins\n }, [definition])\n\n const [editor] = useState(() =>\n plugins.reduceRight(\n (editor, plugin) => plugin?.withPlugin?.(editor) ?? editor,\n withBuilder(withHistory(withReact(createEditor()))),\n ),\n )\n\n const isPreservingFocus = useRef(false)\n useSyncDOMSelection(editor, isPreservingFocus)\n\n const editMode = useBuilderEditMode()\n\n useEffect(() => {\n if (control == null) return\n\n const element = ReactEditor.toDOMNode(editor, editor)\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeBoxModel(boxModel),\n })\n }, [editor, control])\n\n const renderElement = useCallback(\n (props: RenderElementProps) => {\n return <RichTextV2Element {...props} definition={definition} plugins={plugins} />\n },\n [plugins, definition],\n )\n\n const renderLeaf = useCallback(({ attributes, children }: RenderLeafProps) => {\n return <span {...attributes}>{children}</span>\n }, [])\n\n const initialValue = useMemo(() => text ?? defaultText, [text])\n\n useEffect(() => {\n /**\n * This is required because clicking on the overlay has `relatedTarget` null just like the sidebar, but\n * - in the case of the overlay we switch to BUILD mode\n * - in the case of the sidebar we preserve the selection\n */\n if (editMode !== BuilderEditMode.CONTENT) {\n isPreservingFocus.current = false\n ReactEditor.deselect(editor)\n }\n }, [editMode])\n\n useEffect(() => {\n control?.setEditor(editor)\n control?.setDefaultValue(defaultText)\n }, [control, editor, defaultText])\n\n const handleFocus = useCallback(() => {\n isPreservingFocus.current = true\n control?.select()\n }, [control])\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (isHotkey('mod+shift+z', e)) return HistoryEditor.redo(editor)\n if (isHotkey('mod+z', e)) return HistoryEditor.undo(editor)\n if (isHotkey('escape')(e)) {\n isPreservingFocus.current = false\n ReactEditor.blur(editor)\n control?.switchToBuildMode()\n }\n\n plugins.forEach(plugin => plugin?.onKeyDown?.(e, editor))\n },\n [control, plugins, editor],\n )\n\n const handleKeyUp = useCallback(\n (e: KeyboardEvent) => {\n if (editMode === BuilderEditMode.CONTENT) e.preventDefault()\n },\n [control, editor, editMode],\n )\n\n const handleClick = useCallback(\n (e: MouseEvent) => {\n if (editMode === BuilderEditMode.CONTENT) e.stopPropagation()\n },\n [editMode],\n )\n\n const handleBlur = useCallback((e: FocusEvent) => {\n // outside of iframe (overlay, sidebar, etc)\n if (e.relatedTarget == null) return\n // another text\n if (e.relatedTarget?.getAttribute('contenteditable') === 'true')\n isPreservingFocus.current = false\n }, [])\n\n const handleOnChange = useCallback(\n (value: Descendant[]) => {\n control?.onChange(value)\n },\n [control],\n )\n\n return (\n <Slate editor={editor} onChange={handleOnChange} value={initialValue}>\n <Editable\n renderLeaf={renderLeaf}\n renderElement={renderElement}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n onClick={handleClick}\n onBlur={handleBlur}\n readOnly={editMode !== BuilderEditMode.CONTENT}\n placeholder=\"Write some text...\"\n />\n </Slate>\n )\n}\n\nexport default EditableTextV2\n"],"names":["editor","isEnabled","useIsomorphicLayoutEffect","current","selection","ReactEditor","isFocused","root","findDocumentOrShadowRoot","domSelection","getSelection","newDomRange","toDOMRange","SlateRange","isBackward","setBaseAndExtent","endContainer","endOffset","startContainer","startOffset","removeAllRanges","e","console","error","definition","plugins","props","blockStyles","useStyle","margin","element","type","BlockType","Default","config","mode","RichTextV2Mode","Inline","attributes","cx","children","renderElement","reduce","renderFn","plugin","control","getElementValue","undefined","value","initialRenderElement","defaultText","text","useMemo","InlineModePlugin","useState","reduceRight","withPlugin","withBuilder","withHistory","withReact","createEditor","isPreservingFocus","useRef","useSyncDOMSelection","editMode","useBuilderEditMode","useEffect","toDOMNode","pollBoxModel","onBoxModelChange","boxModel","changeBoxModel","useCallback","renderLeaf","initialValue","BuilderEditMode","CONTENT","deselect","setEditor","setDefaultValue","handleFocus","select","handleKeyDown","isHotkey","HistoryEditor","redo","undo","blur","switchToBuildMode","forEach","onKeyDown","handleKeyUp","preventDefault","handleClick","stopPropagation","handleBlur","relatedTarget","getAttribute","handleOnChange","onChange"],"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,OAA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
140
140
|
function useTypographyClassName(value) {
|
|
141
|
-
return
|
|
141
|
+
return reactPage.useStyle(next.useResponsiveStyle([value], ([value2]) => {
|
|
142
142
|
if (value2 === void 0)
|
|
143
143
|
return {};
|
|
144
144
|
let styles = {};
|