@makeswift/runtime 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Box.cjs.js +1 -1
- package/dist/Box.es.js +1 -1
- package/dist/Button.cjs.js +1 -1
- package/dist/Button.es.js +1 -1
- package/dist/Carousel.cjs.js +1 -1
- package/dist/Carousel.es.js +1 -1
- package/dist/Countdown.cjs.js +1 -1
- package/dist/Countdown.es.js +1 -1
- package/dist/Divider.cjs.js +1 -1
- package/dist/Divider.es.js +1 -1
- package/dist/EditableText.cjs.js +11 -2
- package/dist/EditableText.cjs.js.map +1 -1
- package/dist/EditableText.es.js +13 -4
- package/dist/EditableText.es.js.map +1 -1
- package/dist/Embed.cjs.js +1 -1
- package/dist/Embed.es.js +1 -1
- package/dist/Form.cjs.js +1 -1
- package/dist/Form.es.js +1 -1
- package/dist/Image.cjs.js +3 -6
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +4 -7
- package/dist/Image.es.js.map +1 -1
- package/dist/LiveProvider.cjs.js +1 -1
- package/dist/LiveProvider.es.js +1 -1
- package/dist/Navigation.cjs.js +1 -1
- package/dist/Navigation.es.js +1 -1
- package/dist/PreviewProvider.cjs.js +2 -2
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +2 -2
- package/dist/ReadOnlyText.cjs.js +6 -3
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +6 -3
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/Root.cjs.js +1 -1
- package/dist/Root.es.js +1 -1
- package/dist/SocialLinks.cjs.js +1 -1
- package/dist/SocialLinks.es.js +1 -1
- package/dist/Text.cjs.js +1 -1
- package/dist/Text.es.js +1 -1
- package/dist/Video.cjs.js +1 -1
- package/dist/Video.es.js +1 -1
- package/dist/builder.cjs.js +1 -1
- package/dist/builder.es.js +1 -1
- package/dist/components.cjs.js +1 -1
- package/dist/components.es.js +1 -1
- package/dist/constants.cjs.js +20 -20
- package/dist/constants.cjs.js.map +1 -1
- package/dist/constants.es.js +2 -2
- package/dist/control-serialization.cjs.js +37 -37
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +1 -1
- package/dist/control.cjs.js +22 -22
- package/dist/control.cjs.js.map +1 -1
- package/dist/control.es.js +1 -1
- package/dist/controls.cjs.js +21 -17
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +1 -1
- package/dist/index.cjs.js +237 -208
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs2.js +1 -1
- package/dist/index.cjs5.js +36 -139
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +141 -0
- package/dist/index.cjs6.js.map +1 -0
- package/dist/index.es.js +52 -26
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +1 -1
- package/dist/index.es5.js +34 -138
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +139 -0
- package/dist/index.es6.js.map +1 -0
- package/dist/main.cjs.js +1 -1
- package/dist/main.es.js +1 -1
- package/dist/next.cjs.js +1 -1
- package/dist/next.es.js +2 -2
- package/dist/prop-controllers.cjs.js +4 -4
- package/dist/prop-controllers.es.js +1 -1
- package/dist/react.cjs.js +1 -1
- package/dist/react.es.js +1 -1
- package/dist/{slot.cjs.js → rich-text.cjs.js} +84 -8
- package/dist/rich-text.cjs.js.map +1 -0
- package/dist/{slot.es.js → rich-text.es.js} +80 -8
- package/dist/rich-text.es.js.map +1 -0
- package/dist/types/src/components/builtin/Box/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Image/Image.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/EditableText.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.d.ts +66 -0
- package/dist/types/src/controls/rich-text.d.ts.map +1 -0
- package/dist/types/src/controls/style.d.ts +16 -4
- package/dist/types/src/controls/style.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/descriptors.d.ts +4 -2
- package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/instances.d.ts +13 -3
- package/dist/types/src/prop-controllers/instances.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text.d.ts +8 -0
- package/dist/types/src/runtimes/react/controls/rich-text.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/slot.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/poll-box-model.d.ts +6 -0
- package/dist/types/src/runtimes/react/poll-box-model.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/slot.cjs.js.map +0 -1
- package/dist/slot.es.js.map +0 -1
package/dist/Box.cjs.js
CHANGED
|
@@ -44,7 +44,7 @@ require("./constants.cjs.js");
|
|
|
44
44
|
require("redux");
|
|
45
45
|
require("redux-thunk");
|
|
46
46
|
require("./actions.cjs.js");
|
|
47
|
-
require("./
|
|
47
|
+
require("./rich-text.cjs.js");
|
|
48
48
|
require("./control.cjs.js");
|
|
49
49
|
require("@emotion/serialize");
|
|
50
50
|
require("@emotion/utils");
|
package/dist/Box.es.js
CHANGED
package/dist/Button.cjs.js
CHANGED
|
@@ -43,7 +43,7 @@ require("./constants.cjs.js");
|
|
|
43
43
|
require("redux");
|
|
44
44
|
require("redux-thunk");
|
|
45
45
|
require("./actions.cjs.js");
|
|
46
|
-
require("./
|
|
46
|
+
require("./rich-text.cjs.js");
|
|
47
47
|
require("./control.cjs.js");
|
|
48
48
|
require("@emotion/serialize");
|
|
49
49
|
require("@emotion/utils");
|
package/dist/Button.es.js
CHANGED
package/dist/Carousel.cjs.js
CHANGED
|
@@ -37,7 +37,7 @@ var reactUseGesture = require("react-use-gesture");
|
|
|
37
37
|
var popcorn = require("@popmotion/popcorn");
|
|
38
38
|
var next = require("./index.cjs.js");
|
|
39
39
|
require("use-sync-external-store/shim");
|
|
40
|
-
require("./
|
|
40
|
+
require("./rich-text.cjs.js");
|
|
41
41
|
var Image = require("./Image.cjs.js");
|
|
42
42
|
var css = require("@emotion/css");
|
|
43
43
|
var jsxRuntime = require("react/jsx-runtime");
|
package/dist/Carousel.es.js
CHANGED
|
@@ -35,7 +35,7 @@ import { useGesture } from "react-use-gesture";
|
|
|
35
35
|
import { wrap } from "@popmotion/popcorn";
|
|
36
36
|
import { m as useMediaQuery, o as useStyle, r as responsiveStyle, s as colorToString } from "./index.es.js";
|
|
37
37
|
import "use-sync-external-store/shim";
|
|
38
|
-
import "./
|
|
38
|
+
import "./rich-text.es.js";
|
|
39
39
|
import ImageComponent from "./Image.es.js";
|
|
40
40
|
import { cx } from "@emotion/css";
|
|
41
41
|
import { jsxs, jsx } from "react/jsx-runtime";
|
package/dist/Countdown.cjs.js
CHANGED
|
@@ -41,7 +41,7 @@ require("./constants.cjs.js");
|
|
|
41
41
|
require("redux");
|
|
42
42
|
require("redux-thunk");
|
|
43
43
|
require("./actions.cjs.js");
|
|
44
|
-
require("./
|
|
44
|
+
require("./rich-text.cjs.js");
|
|
45
45
|
require("./control.cjs.js");
|
|
46
46
|
require("@emotion/serialize");
|
|
47
47
|
require("@emotion/utils");
|
package/dist/Countdown.es.js
CHANGED
package/dist/Divider.cjs.js
CHANGED
|
@@ -10,7 +10,7 @@ require("./constants.cjs.js");
|
|
|
10
10
|
require("redux");
|
|
11
11
|
require("redux-thunk");
|
|
12
12
|
require("./actions.cjs.js");
|
|
13
|
-
require("./
|
|
13
|
+
require("./rich-text.cjs.js");
|
|
14
14
|
require("./control.cjs.js");
|
|
15
15
|
require("@emotion/serialize");
|
|
16
16
|
require("@emotion/utils");
|
package/dist/Divider.es.js
CHANGED
package/dist/EditableText.cjs.js
CHANGED
|
@@ -38,13 +38,13 @@ var isHotkey = require("is-hotkey");
|
|
|
38
38
|
var boxModels = require("./box-models.cjs.js");
|
|
39
39
|
var slateReact = require("slate-react");
|
|
40
40
|
var Lists = require("@convertkit/slate-lists");
|
|
41
|
-
var index = require("./index.
|
|
41
|
+
var index = require("./index.cjs6.js");
|
|
42
42
|
var jsxRuntime = require("react/jsx-runtime");
|
|
43
43
|
var css = require("@emotion/css");
|
|
44
44
|
var next = require("./index.cjs.js");
|
|
45
45
|
var index$1 = require("./index.cjs3.js");
|
|
46
46
|
require("use-sync-external-store/shim");
|
|
47
|
-
require("./
|
|
47
|
+
require("./rich-text.cjs.js");
|
|
48
48
|
require("css-box-model");
|
|
49
49
|
require("./actions.cjs.js");
|
|
50
50
|
require("./constants.cjs.js");
|
|
@@ -264,6 +264,15 @@ const EditableText = React.forwardRef(function EditableText2({
|
|
|
264
264
|
const [editor, setEditor] = React.useState(null);
|
|
265
265
|
const [propControllers, setPropControllers] = React.useState(null);
|
|
266
266
|
const controller = propControllers == null ? void 0 : propControllers.text;
|
|
267
|
+
React.useEffect(() => {
|
|
268
|
+
const element = editor == null ? void 0 : editor.findDOMNode([]);
|
|
269
|
+
if (element == null || !(element instanceof HTMLElement) || controller == null)
|
|
270
|
+
return;
|
|
271
|
+
return next.pollBoxModel({
|
|
272
|
+
element,
|
|
273
|
+
onBoxModelChange: (boxModel) => controller.changeBoxModel(boxModel)
|
|
274
|
+
});
|
|
275
|
+
}, [editor, controller]);
|
|
267
276
|
React.useImperativeHandle(ref, () => ({
|
|
268
277
|
getBoxModel() {
|
|
269
278
|
const el = editor == null ? void 0 : editor.findDOMNode([]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditableText.cjs.js","sources":["../src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesMarks.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesBlocks.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/Link.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/Inlines.tsx","../src/components/builtin/Text/components/RichTextEditor/index.tsx","../src/components/builtin/Text/EditableText.tsx"],"sourcesContent":["import type { Plugin } from 'slate-react'\n\nimport Mark from '../components/Mark'\n\nconst TYPOGRAPHY_TYPE = 'typography'\n\nexport default function DeviceOverridesMarksPlugin(): Plugin {\n return {\n renderMark({ mark, children }, _editor, next) {\n if (mark.type === TYPOGRAPHY_TYPE) {\n return <Mark value={mark.data.get('value')}>{children}</Mark>\n }\n\n return next()\n },\n }\n}\n","import { Plugin } from 'slate-react'\n\nimport Block from '../components/Block'\n\nexport default function DeviceOverridesBlockPlugin(): Plugin {\n return {\n renderBlock(props, _editor, next): JSX.Element {\n const { node, attributes, children } = props\n const blockProps = { textAlign: node.data.get('textAlign') }\n\n switch (node.type) {\n case 'paragraph':\n return (\n <Block {...attributes} {...blockProps} as=\"p\">\n {children}\n </Block>\n )\n\n case 'heading-one':\n return (\n <Block {...attributes} {...blockProps} as=\"h1\">\n {children}\n </Block>\n )\n\n case 'heading-two':\n return (\n <Block {...attributes} {...blockProps} as=\"h2\">\n {children}\n </Block>\n )\n\n case 'heading-three':\n return (\n <Block {...attributes} {...blockProps} as=\"h3\">\n {children}\n </Block>\n )\n\n case 'heading-four':\n return (\n <Block {...attributes} {...blockProps} as=\"h4\">\n {children}\n </Block>\n )\n\n case 'heading-five':\n return (\n <Block {...attributes} {...blockProps} as=\"h5\">\n {children}\n </Block>\n )\n\n case 'heading-six':\n return (\n <Block {...attributes} {...blockProps} as=\"h6\">\n {children}\n </Block>\n )\n\n case 'blockquote':\n return (\n <Block {...attributes} {...blockProps} as=\"blockquote\">\n {children}\n </Block>\n )\n\n default:\n return next()\n }\n },\n }\n}\n","import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef } from 'react'\nimport { Plugin } from 'slate-react'\nimport { useStyle } from '../../../../../../runtimes/react/use-style'\n\nimport { Link } from '../../../../../shared/Link'\n\nfunction StyledLink({ className, ...restOfProps }: ComponentPropsWithoutRef<typeof Link>) {\n return <Link {...restOfProps} className={cx(useStyle({ textDecoration: 'none' }), className)} />\n}\n\nexport default function LinkPlugin(): Plugin {\n return {\n renderInline(props, _editor, next) {\n const { attributes, children, node } = props\n\n switch (node.type) {\n case 'link': {\n const { data } = node\n\n return (\n <StyledLink {...attributes} link={data.toJS()}>\n {children}\n </StyledLink>\n )\n }\n\n default: {\n return next()\n }\n }\n },\n }\n}\n","import { Plugin } from 'slate-react'\n\nexport default function Inlines(): Plugin {\n return {\n renderInline(props, _editor, next) {\n const { attributes, children, node } = props\n\n switch (node.type) {\n case 'code': {\n return <code {...attributes}>{children}</code>\n }\n\n case 'superscript': {\n return <sup {...attributes}>{children}</sup>\n }\n\n case 'subscript': {\n return <sub {...attributes}>{children}</sub>\n }\n\n default: {\n return next()\n }\n }\n },\n }\n}\n","import { ComponentPropsWithoutRef, forwardRef, useMemo } from 'react'\n\nimport { Editor as SlateEditor } from 'slate-react'\n\n// @ts-expect-error: no types for '@convertkit/slate-lists'\nimport Lists from '@convertkit/slate-lists'\n\nimport DeviceOverridesMarks from './plugins/DeviceOverridesMarks'\nimport DeviceOverridesBlocks from './plugins/DeviceOverridesBlocks'\nimport Link from './plugins/Link'\nimport Inlines from './plugins/Inlines'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\nexport { overrideTypographyStyle } from './components/Mark'\n\ntype Props = ComponentPropsWithoutRef<typeof SlateEditor>\n\nexport const RichTextEditor = forwardRef<SlateEditor, Props>(function RichTextEditor(\n { placeholder = 'Write some text...', className, ...restOfProps }: Props,\n ref,\n) {\n const plugins = useMemo(\n () => [Lists(), Link(), Inlines(), DeviceOverridesBlocks(), DeviceOverridesMarks()],\n [],\n )\n\n return (\n <SlateEditor\n {...restOfProps}\n // Workaround because our Slate editor is broken on Chrome 105\n // Problem: https://linear.app/makeswift/issue/PRD-434/our-rich-text-component-breaks-in-the-latest-version-of-chrome\n // Workaround: https://github.com/ianstormtaylor/slate/issues/5110#issuecomment-1234951122\n style={{ WebkitUserModify: undefined }}\n className={cx(useStyle({ 'ul, ol': { margin: 0 } }), className)}\n ref={ref}\n autoFocus={false}\n plugins={plugins}\n placeholder={placeholder}\n />\n )\n})\n","import {\n useState,\n Ref,\n useImperativeHandle,\n forwardRef,\n useEffect,\n useCallback,\n useRef,\n KeyboardEvent as ReactKeyboardEvent,\n FocusEvent as ReactFocusEvent,\n} from 'react'\nimport { Editor, OnChangeParam } from 'slate-react'\nimport { Value, ValueJSON } from 'slate'\n// @ts-expect-error: no types for 'slate-hotkeys'\nimport Hotkeys from 'slate-hotkeys'\nimport { isHotkey } from 'is-hotkey'\n\nimport {\n ElementIDValue,\n RichTextDescriptor,\n RichTextValue,\n} from '../../../prop-controllers/descriptors'\nimport { BoxModelHandle, getBox } from '../../../box-model'\nimport { PropControllersHandle } from '../../../state/modules/prop-controller-handles'\nimport { RichTextEditor } from './components/RichTextEditor'\nimport { DescriptorsPropControllers } from '../../../prop-controllers/instances'\nimport { cx } from '@emotion/css'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { useIsInBuilder } from '../../../runtimes/react'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst defaultText: ValueJSON = {\n document: { nodes: [{ object: 'block' as const, type: 'paragraph' as const, nodes: [] }] },\n data: {},\n}\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\ntype Descriptors = { text?: RichTextDescriptor }\n\nconst EditableText = forwardRef(function EditableText(\n { id, text, width, margin }: Props,\n ref: Ref<BoxModelHandle & PropControllersHandle<Descriptors>>,\n) {\n const [editor, setEditor] = useState<Editor | null>(null)\n const [propControllers, setPropControllers] =\n useState<DescriptorsPropControllers<Descriptors> | null>(null)\n const controller = propControllers?.text\n\n useImperativeHandle(\n ref,\n () => ({\n getBoxModel() {\n const el = editor?.findDOMNode([])\n\n return el instanceof Element ? getBox(el) : null\n },\n setPropControllers,\n }),\n [editor, setPropControllers],\n )\n\n useEffect(() => {\n if (editor) controller?.setSlateEditor(editor)\n }, [controller, editor])\n\n /**\n * We must keep local state so that we can reflect the user's typed changes immediately. At the\n * same time, though, the source of truth for the data is the prop data. This presents a\n * challenge: how do we keep local state in sync with the prop data without mangling user input as\n * data comes in?\n *\n * Consider, for example, that the user types \"Hello\". If at a later time, when the user is trying\n * to type \", world\" the component re-renders with prop data \"H\", \"He\", \"Hel\", \"Hell\", \"Hello\", it\n * will disrupt the user's typing. This could also happen as a result of the prop data changing\n * for other reasons, like collaborators changing the prop data concurrently. We want to avoid to\n * disrupt the user's typing, while at the same time display the \"true\" value as quickly as\n * possible.\n *\n * The approach we take here is to commit the prop data at an opportune time: as the user is\n * typing we avoid to commit prop data. But once they've stopped typing, we commit it as soon as\n * possible. This is known as a debounce.\n */\n const [value, setValue] = useState(() => {\n const { selection, ...textWithoutSelection } = text ?? defaultText\n\n return Value.fromJSON(textWithoutSelection)\n })\n const [shouldCommit, setShouldCommit] = useState(true)\n\n useEffect(() => {\n if (shouldCommit) {\n const nextValue = Value.fromJSON(text ?? defaultText)\n\n setValue(currentValue =>\n currentValue.selection.isBlurred\n ? Value.fromJSON(nextValue.toJSON({ preserveSelection: false }))\n : nextValue,\n )\n }\n }, [shouldCommit, text])\n\n useEffect(() => {\n if (shouldCommit) return\n\n const timeoutId = window.setTimeout(() => {\n setShouldCommit(true)\n }, COMMIT_DEBOUNCE_DELAY)\n\n return () => {\n window.clearTimeout(timeoutId)\n }\n }, [shouldCommit])\n\n function handleChange(change: OnChangeParam) {\n setValue(change.value as Value)\n\n if (change.value !== value) {\n setShouldCommit(false)\n\n controller?.onChange(change)\n }\n }\n\n // HACK: Slate holds on to the very first DOM event handlers passed in and doesn't update them\n // even if they change. Since `controller` is first `undefined` then we must use a ref.\n const lastController = useRef(controller)\n if (lastController.current !== controller) lastController.current = controller\n const handleFocus = useCallback(() => {\n lastController.current?.focus()\n }, [])\n const handleKeyDown = useCallback(\n (event: ReactKeyboardEvent, _editor: Editor, next: () => any) => {\n if (Hotkeys.isUndo(event)) {\n lastController.current?.undo()\n\n return true\n }\n\n if (Hotkeys.isRedo(event)) {\n lastController.current?.redo()\n\n return true\n }\n\n if (isHotkey('escape')(event)) {\n lastController.current?.blur()\n\n return true\n }\n\n return next()\n },\n [],\n )\n const handleBlur = useCallback((event: ReactFocusEvent, editor: Editor, next: () => any) => {\n const selection = editor.value.selection\n\n next()\n\n // Normally, after a user highlight a text, clicking on the panel will remove the text selection.\n // This line is a workaround for that. Because the panel is not in the iframe, relatedTarget\n // would be null, and we select the previous text selection to maintain the text highlight.\n // Inspiration: https://github.com/ianstormtaylor/slate/issues/3412#issuecomment-663906003\n if (event.relatedTarget == null) editor.select(selection)\n }, [])\n\n const isInBuilder = useIsInBuilder()\n\n return (\n <RichTextEditor\n // @ts-expect-error: types don't allow for 'id' prop even though it's used.\n id={id}\n ref={setEditor}\n className={cx(useStyle({ 'ul, ol': { margin: 0 } }), width, margin)}\n value={value}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n readOnly={!isInBuilder || controller == null}\n />\n )\n})\n\nexport default EditableText\n"],"names":["TYPOGRAPHY_TYPE","renderMark","mark","children","_editor","next","type","Mark","data","get","renderBlock","props","node","attributes","blockProps","textAlign","Block","className","restOfProps","Link","cx","useStyle","textDecoration","renderInline","toJS","RichTextEditor","forwardRef","ref","placeholder","plugins","useMemo","Lists","Inlines","DeviceOverridesBlocks","DeviceOverridesMarks","SlateEditor","WebkitUserModify","undefined","margin","defaultText","document","nodes","object","COMMIT_DEBOUNCE_DELAY","EditableText","id","text","width","editor","setEditor","useState","propControllers","setPropControllers","controller","useImperativeHandle","getBoxModel","el","findDOMNode","Element","getBox","useEffect","setSlateEditor","value","setValue","selection","textWithoutSelection","Value","fromJSON","shouldCommit","setShouldCommit","nextValue","currentValue","isBlurred","toJSON","preserveSelection","timeoutId","window","setTimeout","clearTimeout","change","onChange","lastController","useRef","current","handleFocus","useCallback","focus","handleKeyDown","event","Hotkeys","isUndo","undo","isRedo","redo","isHotkey","blur","handleBlur","relatedTarget","select","isInBuilder","useIsInB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W7B,OAAGC,cAAS;AAAA,MAAY,UAAA;AAAA,QAAEiB,QAAQ;AAAA,MAAV;AAAA,IAAA,CAAb,GAA+BS,OAAOT,MAA/C;AAAA,IACb;AAAA,IACA,UAAU+D;AAAAA,IACV,SAASjB;AAAAA,IACT,WAAWG;AAAAA,IACX,QAAQS;AAAAA,IACR,UAAU,CAACG,eAAe9C,cAAc;AAAA,EAAA,CAX5C;AAcD,CA/I8B;;"}
|
|
1
|
+
{"version":3,"file":"EditableText.cjs.js","sources":["../src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesMarks.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesBlocks.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/Link.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/Inlines.tsx","../src/components/builtin/Text/components/RichTextEditor/index.tsx","../src/components/builtin/Text/EditableText.tsx"],"sourcesContent":["import type { Plugin } from 'slate-react'\n\nimport Mark from '../components/Mark'\n\nconst TYPOGRAPHY_TYPE = 'typography'\n\nexport default function DeviceOverridesMarksPlugin(): Plugin {\n return {\n renderMark({ mark, children }, _editor, next) {\n if (mark.type === TYPOGRAPHY_TYPE) {\n return <Mark value={mark.data.get('value')}>{children}</Mark>\n }\n\n return next()\n },\n }\n}\n","import { Plugin } from 'slate-react'\n\nimport Block from '../components/Block'\n\nexport default function DeviceOverridesBlockPlugin(): Plugin {\n return {\n renderBlock(props, _editor, next): JSX.Element {\n const { node, attributes, children } = props\n const blockProps = { textAlign: node.data.get('textAlign') }\n\n switch (node.type) {\n case 'paragraph':\n return (\n <Block {...attributes} {...blockProps} as=\"p\">\n {children}\n </Block>\n )\n\n case 'heading-one':\n return (\n <Block {...attributes} {...blockProps} as=\"h1\">\n {children}\n </Block>\n )\n\n case 'heading-two':\n return (\n <Block {...attributes} {...blockProps} as=\"h2\">\n {children}\n </Block>\n )\n\n case 'heading-three':\n return (\n <Block {...attributes} {...blockProps} as=\"h3\">\n {children}\n </Block>\n )\n\n case 'heading-four':\n return (\n <Block {...attributes} {...blockProps} as=\"h4\">\n {children}\n </Block>\n )\n\n case 'heading-five':\n return (\n <Block {...attributes} {...blockProps} as=\"h5\">\n {children}\n </Block>\n )\n\n case 'heading-six':\n return (\n <Block {...attributes} {...blockProps} as=\"h6\">\n {children}\n </Block>\n )\n\n case 'blockquote':\n return (\n <Block {...attributes} {...blockProps} as=\"blockquote\">\n {children}\n </Block>\n )\n\n default:\n return next()\n }\n },\n }\n}\n","import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef } from 'react'\nimport { Plugin } from 'slate-react'\nimport { useStyle } from '../../../../../../runtimes/react/use-style'\n\nimport { Link } from '../../../../../shared/Link'\n\nfunction StyledLink({ className, ...restOfProps }: ComponentPropsWithoutRef<typeof Link>) {\n return <Link {...restOfProps} className={cx(useStyle({ textDecoration: 'none' }), className)} />\n}\n\nexport default function LinkPlugin(): Plugin {\n return {\n renderInline(props, _editor, next) {\n const { attributes, children, node } = props\n\n switch (node.type) {\n case 'link': {\n const { data } = node\n\n return (\n <StyledLink {...attributes} link={data.toJS()}>\n {children}\n </StyledLink>\n )\n }\n\n default: {\n return next()\n }\n }\n },\n }\n}\n","import { Plugin } from 'slate-react'\n\nexport default function Inlines(): Plugin {\n return {\n renderInline(props, _editor, next) {\n const { attributes, children, node } = props\n\n switch (node.type) {\n case 'code': {\n return <code {...attributes}>{children}</code>\n }\n\n case 'superscript': {\n return <sup {...attributes}>{children}</sup>\n }\n\n case 'subscript': {\n return <sub {...attributes}>{children}</sub>\n }\n\n default: {\n return next()\n }\n }\n },\n }\n}\n","import { ComponentPropsWithoutRef, forwardRef, useMemo } from 'react'\n\nimport { Editor as SlateEditor } from 'slate-react'\n\n// @ts-expect-error: no types for '@convertkit/slate-lists'\nimport Lists from '@convertkit/slate-lists'\n\nimport DeviceOverridesMarks from './plugins/DeviceOverridesMarks'\nimport DeviceOverridesBlocks from './plugins/DeviceOverridesBlocks'\nimport Link from './plugins/Link'\nimport Inlines from './plugins/Inlines'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\nexport { overrideTypographyStyle } from './components/Mark'\n\ntype Props = ComponentPropsWithoutRef<typeof SlateEditor>\n\nexport const RichTextEditor = forwardRef<SlateEditor, Props>(function RichTextEditor(\n { placeholder = 'Write some text...', className, ...restOfProps }: Props,\n ref,\n) {\n const plugins = useMemo(\n () => [Lists(), Link(), Inlines(), DeviceOverridesBlocks(), DeviceOverridesMarks()],\n [],\n )\n\n return (\n <SlateEditor\n {...restOfProps}\n // Workaround because our Slate editor is broken on Chrome 105\n // Problem: https://linear.app/makeswift/issue/PRD-434/our-rich-text-component-breaks-in-the-latest-version-of-chrome\n // Workaround: https://github.com/ianstormtaylor/slate/issues/5110#issuecomment-1234951122\n style={{ WebkitUserModify: undefined }}\n className={cx(useStyle({ 'ul, ol': { margin: 0 } }), className)}\n ref={ref}\n autoFocus={false}\n plugins={plugins}\n placeholder={placeholder}\n />\n )\n})\n","import {\n useState,\n Ref,\n useImperativeHandle,\n forwardRef,\n useEffect,\n useCallback,\n useRef,\n KeyboardEvent as ReactKeyboardEvent,\n FocusEvent as ReactFocusEvent,\n} from 'react'\nimport { Editor, OnChangeParam } from 'slate-react'\nimport { Value, ValueJSON } from 'slate'\n// @ts-expect-error: no types for 'slate-hotkeys'\nimport Hotkeys from 'slate-hotkeys'\nimport { isHotkey } from 'is-hotkey'\n\nimport {\n ElementIDValue,\n RichTextDescriptor,\n RichTextValue,\n} from '../../../prop-controllers/descriptors'\nimport { BoxModelHandle, getBox } from '../../../box-model'\nimport { PropControllersHandle } from '../../../state/modules/prop-controller-handles'\nimport { RichTextEditor } from './components/RichTextEditor'\nimport { DescriptorsPropControllers } from '../../../prop-controllers/instances'\nimport { cx } from '@emotion/css'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { useIsInBuilder } from '../../../runtimes/react'\nimport { pollBoxModel } from '../../../runtimes/react/poll-box-model'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst defaultText: ValueJSON = {\n document: { nodes: [{ object: 'block' as const, type: 'paragraph' as const, nodes: [] }] },\n data: {},\n}\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\ntype Descriptors = { text?: RichTextDescriptor }\n\nconst EditableText = forwardRef(function EditableText(\n { id, text, width, margin }: Props,\n ref: Ref<BoxModelHandle & PropControllersHandle<Descriptors>>,\n) {\n const [editor, setEditor] = useState<Editor | null>(null)\n const [propControllers, setPropControllers] =\n useState<DescriptorsPropControllers<Descriptors> | null>(null)\n const controller = propControllers?.text\n\n useEffect(() => {\n const element = editor?.findDOMNode([])\n if (element == null || !(element instanceof HTMLElement) || controller == null) return\n return pollBoxModel({\n element: element,\n onBoxModelChange: boxModel => controller.changeBoxModel(boxModel),\n })\n }, [editor, controller])\n\n useImperativeHandle(\n ref,\n () => ({\n getBoxModel() {\n const el = editor?.findDOMNode([])\n\n return el instanceof Element ? getBox(el) : null\n },\n setPropControllers,\n }),\n [editor, setPropControllers],\n )\n\n useEffect(() => {\n if (editor) controller?.setSlateEditor(editor)\n }, [controller, editor])\n\n /**\n * We must keep local state so that we can reflect the user's typed changes immediately. At the\n * same time, though, the source of truth for the data is the prop data. This presents a\n * challenge: how do we keep local state in sync with the prop data without mangling user input as\n * data comes in?\n *\n * Consider, for example, that the user types \"Hello\". If at a later time, when the user is trying\n * to type \", world\" the component re-renders with prop data \"H\", \"He\", \"Hel\", \"Hell\", \"Hello\", it\n * will disrupt the user's typing. This could also happen as a result of the prop data changing\n * for other reasons, like collaborators changing the prop data concurrently. We want to avoid to\n * disrupt the user's typing, while at the same time display the \"true\" value as quickly as\n * possible.\n *\n * The approach we take here is to commit the prop data at an opportune time: as the user is\n * typing we avoid to commit prop data. But once they've stopped typing, we commit it as soon as\n * possible. This is known as a debounce.\n */\n const [value, setValue] = useState(() => {\n const { selection, ...textWithoutSelection } = text ?? defaultText\n\n return Value.fromJSON(textWithoutSelection)\n })\n const [shouldCommit, setShouldCommit] = useState(true)\n\n useEffect(() => {\n if (shouldCommit) {\n const nextValue = Value.fromJSON(text ?? defaultText)\n\n setValue(currentValue =>\n currentValue.selection.isBlurred\n ? Value.fromJSON(nextValue.toJSON({ preserveSelection: false }))\n : nextValue,\n )\n }\n }, [shouldCommit, text])\n\n useEffect(() => {\n if (shouldCommit) return\n\n const timeoutId = window.setTimeout(() => {\n setShouldCommit(true)\n }, COMMIT_DEBOUNCE_DELAY)\n\n return () => {\n window.clearTimeout(timeoutId)\n }\n }, [shouldCommit])\n\n function handleChange(change: OnChangeParam) {\n setValue(change.value as Value)\n\n if (change.value !== value) {\n setShouldCommit(false)\n\n controller?.onChange(change)\n }\n }\n\n // HACK: Slate holds on to the very first DOM event handlers passed in and doesn't update them\n // even if they change. Since `controller` is first `undefined` then we must use a ref.\n const lastController = useRef(controller)\n if (lastController.current !== controller) lastController.current = controller\n const handleFocus = useCallback(() => {\n lastController.current?.focus()\n }, [])\n const handleKeyDown = useCallback(\n (event: ReactKeyboardEvent, _editor: Editor, next: () => any) => {\n if (Hotkeys.isUndo(event)) {\n lastController.current?.undo()\n\n return true\n }\n\n if (Hotkeys.isRedo(event)) {\n lastController.current?.redo()\n\n return true\n }\n\n if (isHotkey('escape')(event)) {\n lastController.current?.blur()\n\n return true\n }\n\n return next()\n },\n [],\n )\n const handleBlur = useCallback((event: ReactFocusEvent, editor: Editor, next: () => any) => {\n const selection = editor.value.selection\n\n next()\n\n // Normally, after a user highlight a text, clicking on the panel will remove the text selection.\n // This line is a workaround for that. Because the panel is not in the iframe, relatedTarget\n // would be null, and we select the previous text selection to maintain the text highlight.\n // Inspiration: https://github.com/ianstormtaylor/slate/issues/3412#issuecomment-663906003\n if (event.relatedTarget == null) editor.select(selection)\n }, [])\n\n const isInBuilder = useIsInBuilder()\n\n return (\n <RichTextEditor\n // @ts-expect-error: types don't allow for 'id' prop even though it's used.\n id={id}\n ref={setEditor}\n className={cx(useStyle({ 'ul, ol': { margin: 0 } }), width, margin)}\n value={value}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n readOnly={!isInBuilder || controller == null}\n />\n )\n})\n\nexport default EditableText\n"],"names":["TYPOGRAPHY_TYPE","renderMark","mark","children","_editor","next","type","Mark","data","get","renderBlock","props","node","attributes","blockProps","textAlign","Block","className","restOfProps","Link","cx","useStyle","textDecoration","renderInline","toJS","RichTextEditor","forwardRef","ref","placeholder","plugins","useMemo","Lists","Inlines","DeviceOverridesBlocks","DeviceOverridesMarks","SlateEditor","WebkitUserModify","undefined","margin","defaultText","document","nodes","object","COMMIT_DEBOUNCE_DELAY","EditableText","id","text","width","editor","setEditor","useState","propControllers","setPropControllers","controller","useEffect","element","findDOMNode","HTMLElement","pollBoxModel","onBoxModelChange","boxModel","changeBoxModel","useImperativeHandle","getBoxModel","el","Element","getBox","setSlateEditor","value","setValue","selection","textWithoutSelection","Value","fromJSON","shouldCommit","setShouldCommit","nextValue","currentValue","isBlurred","toJSON","preserveSelection","timeoutId","window","setTimeout","clearTimeout","change","onChange","lastController","useRef","current","handleFocus","useCallback","focus","handleKeyDown","event","Hotkeys","isUndo","undo","isRedo","redo","isHotkey","blur","handleBlur","relatedTarget","select","isInBuilder","useIsInBuilder","handleChange"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAMA,kBAAkB;AAEqC,sCAAA;AACpD,SAAA;AAAA,IACLC,WAAW;AAAA,MAAEC;AAAAA,MAAMC;AAAAA,OAAYC,SAASC,OAAM;AACxCH,UAAAA,KAAKI,SAASN,iBAAiB;AACjC,8CAAQO,MAAAA,MAAD;AAAA,UAAM,OAAOL,KAAKM,KAAKC,IAAI,OAAd;AAAA,UAAyBN;AAAAA,QAAAA,CAA7C;AAAA,MACD;AAED,aAAOE,MAAP;AAAA,IACD;AAAA,EAAA;AA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E;AAAAA,IACV,SAASjB;AAAAA,IACT,WAAWG;AAAAA,IACX,QAAQS;AAAAA,IACR,UAAU,CAACG,eAAepD,cAAc;AAAA,EAAA,CAX5C;AAcD,CAxJ8B;;"}
|
package/dist/EditableText.es.js
CHANGED
|
@@ -29,20 +29,20 @@ var __objRest = (source, exclude) => {
|
|
|
29
29
|
}
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
|
-
import { forwardRef, useMemo, useState,
|
|
32
|
+
import { forwardRef, useMemo, useState, useEffect, useImperativeHandle, useRef, useCallback } from "react";
|
|
33
33
|
import { Value } from "slate";
|
|
34
34
|
import Hotkeys from "slate-hotkeys";
|
|
35
35
|
import { isHotkey } from "is-hotkey";
|
|
36
36
|
import { g as getBox } from "./box-models.es.js";
|
|
37
37
|
import { Editor } from "slate-react";
|
|
38
38
|
import Lists from "@convertkit/slate-lists";
|
|
39
|
-
import { M as Mark, D as DeviceOverrideBlock } from "./index.
|
|
39
|
+
import { M as Mark, D as DeviceOverrideBlock } from "./index.es6.js";
|
|
40
40
|
import { jsx } from "react/jsx-runtime";
|
|
41
41
|
import { cx } from "@emotion/css";
|
|
42
|
-
import { o as useStyle, u as useIsInBuilder } from "./index.es.js";
|
|
42
|
+
import { o as useStyle, U as pollBoxModel, u as useIsInBuilder } from "./index.es.js";
|
|
43
43
|
import { L as Link } from "./index.es3.js";
|
|
44
44
|
import "use-sync-external-store/shim";
|
|
45
|
-
import "./
|
|
45
|
+
import "./rich-text.es.js";
|
|
46
46
|
import "css-box-model";
|
|
47
47
|
import "./actions.es.js";
|
|
48
48
|
import "./constants.es.js";
|
|
@@ -257,6 +257,15 @@ const EditableText = forwardRef(function EditableText2({
|
|
|
257
257
|
const [editor, setEditor] = useState(null);
|
|
258
258
|
const [propControllers, setPropControllers] = useState(null);
|
|
259
259
|
const controller = propControllers == null ? void 0 : propControllers.text;
|
|
260
|
+
useEffect(() => {
|
|
261
|
+
const element = editor == null ? void 0 : editor.findDOMNode([]);
|
|
262
|
+
if (element == null || !(element instanceof HTMLElement) || controller == null)
|
|
263
|
+
return;
|
|
264
|
+
return pollBoxModel({
|
|
265
|
+
element,
|
|
266
|
+
onBoxModelChange: (boxModel) => controller.changeBoxModel(boxModel)
|
|
267
|
+
});
|
|
268
|
+
}, [editor, controller]);
|
|
260
269
|
useImperativeHandle(ref, () => ({
|
|
261
270
|
getBoxModel() {
|
|
262
271
|
const el = editor == null ? void 0 : editor.findDOMNode([]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditableText.es.js","sources":["../src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesMarks.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesBlocks.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/Link.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/Inlines.tsx","../src/components/builtin/Text/components/RichTextEditor/index.tsx","../src/components/builtin/Text/EditableText.tsx"],"sourcesContent":["import type { Plugin } from 'slate-react'\n\nimport Mark from '../components/Mark'\n\nconst TYPOGRAPHY_TYPE = 'typography'\n\nexport default function DeviceOverridesMarksPlugin(): Plugin {\n return {\n renderMark({ mark, children }, _editor, next) {\n if (mark.type === TYPOGRAPHY_TYPE) {\n return <Mark value={mark.data.get('value')}>{children}</Mark>\n }\n\n return next()\n },\n }\n}\n","import { Plugin } from 'slate-react'\n\nimport Block from '../components/Block'\n\nexport default function DeviceOverridesBlockPlugin(): Plugin {\n return {\n renderBlock(props, _editor, next): JSX.Element {\n const { node, attributes, children } = props\n const blockProps = { textAlign: node.data.get('textAlign') }\n\n switch (node.type) {\n case 'paragraph':\n return (\n <Block {...attributes} {...blockProps} as=\"p\">\n {children}\n </Block>\n )\n\n case 'heading-one':\n return (\n <Block {...attributes} {...blockProps} as=\"h1\">\n {children}\n </Block>\n )\n\n case 'heading-two':\n return (\n <Block {...attributes} {...blockProps} as=\"h2\">\n {children}\n </Block>\n )\n\n case 'heading-three':\n return (\n <Block {...attributes} {...blockProps} as=\"h3\">\n {children}\n </Block>\n )\n\n case 'heading-four':\n return (\n <Block {...attributes} {...blockProps} as=\"h4\">\n {children}\n </Block>\n )\n\n case 'heading-five':\n return (\n <Block {...attributes} {...blockProps} as=\"h5\">\n {children}\n </Block>\n )\n\n case 'heading-six':\n return (\n <Block {...attributes} {...blockProps} as=\"h6\">\n {children}\n </Block>\n )\n\n case 'blockquote':\n return (\n <Block {...attributes} {...blockProps} as=\"blockquote\">\n {children}\n </Block>\n )\n\n default:\n return next()\n }\n },\n }\n}\n","import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef } from 'react'\nimport { Plugin } from 'slate-react'\nimport { useStyle } from '../../../../../../runtimes/react/use-style'\n\nimport { Link } from '../../../../../shared/Link'\n\nfunction StyledLink({ className, ...restOfProps }: ComponentPropsWithoutRef<typeof Link>) {\n return <Link {...restOfProps} className={cx(useStyle({ textDecoration: 'none' }), className)} />\n}\n\nexport default function LinkPlugin(): Plugin {\n return {\n renderInline(props, _editor, next) {\n const { attributes, children, node } = props\n\n switch (node.type) {\n case 'link': {\n const { data } = node\n\n return (\n <StyledLink {...attributes} link={data.toJS()}>\n {children}\n </StyledLink>\n )\n }\n\n default: {\n return next()\n }\n }\n },\n }\n}\n","import { Plugin } from 'slate-react'\n\nexport default function Inlines(): Plugin {\n return {\n renderInline(props, _editor, next) {\n const { attributes, children, node } = props\n\n switch (node.type) {\n case 'code': {\n return <code {...attributes}>{children}</code>\n }\n\n case 'superscript': {\n return <sup {...attributes}>{children}</sup>\n }\n\n case 'subscript': {\n return <sub {...attributes}>{children}</sub>\n }\n\n default: {\n return next()\n }\n }\n },\n }\n}\n","import { ComponentPropsWithoutRef, forwardRef, useMemo } from 'react'\n\nimport { Editor as SlateEditor } from 'slate-react'\n\n// @ts-expect-error: no types for '@convertkit/slate-lists'\nimport Lists from '@convertkit/slate-lists'\n\nimport DeviceOverridesMarks from './plugins/DeviceOverridesMarks'\nimport DeviceOverridesBlocks from './plugins/DeviceOverridesBlocks'\nimport Link from './plugins/Link'\nimport Inlines from './plugins/Inlines'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\nexport { overrideTypographyStyle } from './components/Mark'\n\ntype Props = ComponentPropsWithoutRef<typeof SlateEditor>\n\nexport const RichTextEditor = forwardRef<SlateEditor, Props>(function RichTextEditor(\n { placeholder = 'Write some text...', className, ...restOfProps }: Props,\n ref,\n) {\n const plugins = useMemo(\n () => [Lists(), Link(), Inlines(), DeviceOverridesBlocks(), DeviceOverridesMarks()],\n [],\n )\n\n return (\n <SlateEditor\n {...restOfProps}\n // Workaround because our Slate editor is broken on Chrome 105\n // Problem: https://linear.app/makeswift/issue/PRD-434/our-rich-text-component-breaks-in-the-latest-version-of-chrome\n // Workaround: https://github.com/ianstormtaylor/slate/issues/5110#issuecomment-1234951122\n style={{ WebkitUserModify: undefined }}\n className={cx(useStyle({ 'ul, ol': { margin: 0 } }), className)}\n ref={ref}\n autoFocus={false}\n plugins={plugins}\n placeholder={placeholder}\n />\n )\n})\n","import {\n useState,\n Ref,\n useImperativeHandle,\n forwardRef,\n useEffect,\n useCallback,\n useRef,\n KeyboardEvent as ReactKeyboardEvent,\n FocusEvent as ReactFocusEvent,\n} from 'react'\nimport { Editor, OnChangeParam } from 'slate-react'\nimport { Value, ValueJSON } from 'slate'\n// @ts-expect-error: no types for 'slate-hotkeys'\nimport Hotkeys from 'slate-hotkeys'\nimport { isHotkey } from 'is-hotkey'\n\nimport {\n ElementIDValue,\n RichTextDescriptor,\n RichTextValue,\n} from '../../../prop-controllers/descriptors'\nimport { BoxModelHandle, getBox } from '../../../box-model'\nimport { PropControllersHandle } from '../../../state/modules/prop-controller-handles'\nimport { RichTextEditor } from './components/RichTextEditor'\nimport { DescriptorsPropControllers } from '../../../prop-controllers/instances'\nimport { cx } from '@emotion/css'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { useIsInBuilder } from '../../../runtimes/react'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst defaultText: ValueJSON = {\n document: { nodes: [{ object: 'block' as const, type: 'paragraph' as const, nodes: [] }] },\n data: {},\n}\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\ntype Descriptors = { text?: RichTextDescriptor }\n\nconst EditableText = forwardRef(function EditableText(\n { id, text, width, margin }: Props,\n ref: Ref<BoxModelHandle & PropControllersHandle<Descriptors>>,\n) {\n const [editor, setEditor] = useState<Editor | null>(null)\n const [propControllers, setPropControllers] =\n useState<DescriptorsPropControllers<Descriptors> | null>(null)\n const controller = propControllers?.text\n\n useImperativeHandle(\n ref,\n () => ({\n getBoxModel() {\n const el = editor?.findDOMNode([])\n\n return el instanceof Element ? getBox(el) : null\n },\n setPropControllers,\n }),\n [editor, setPropControllers],\n )\n\n useEffect(() => {\n if (editor) controller?.setSlateEditor(editor)\n }, [controller, editor])\n\n /**\n * We must keep local state so that we can reflect the user's typed changes immediately. At the\n * same time, though, the source of truth for the data is the prop data. This presents a\n * challenge: how do we keep local state in sync with the prop data without mangling user input as\n * data comes in?\n *\n * Consider, for example, that the user types \"Hello\". If at a later time, when the user is trying\n * to type \", world\" the component re-renders with prop data \"H\", \"He\", \"Hel\", \"Hell\", \"Hello\", it\n * will disrupt the user's typing. This could also happen as a result of the prop data changing\n * for other reasons, like collaborators changing the prop data concurrently. We want to avoid to\n * disrupt the user's typing, while at the same time display the \"true\" value as quickly as\n * possible.\n *\n * The approach we take here is to commit the prop data at an opportune time: as the user is\n * typing we avoid to commit prop data. But once they've stopped typing, we commit it as soon as\n * possible. This is known as a debounce.\n */\n const [value, setValue] = useState(() => {\n const { selection, ...textWithoutSelection } = text ?? defaultText\n\n return Value.fromJSON(textWithoutSelection)\n })\n const [shouldCommit, setShouldCommit] = useState(true)\n\n useEffect(() => {\n if (shouldCommit) {\n const nextValue = Value.fromJSON(text ?? defaultText)\n\n setValue(currentValue =>\n currentValue.selection.isBlurred\n ? Value.fromJSON(nextValue.toJSON({ preserveSelection: false }))\n : nextValue,\n )\n }\n }, [shouldCommit, text])\n\n useEffect(() => {\n if (shouldCommit) return\n\n const timeoutId = window.setTimeout(() => {\n setShouldCommit(true)\n }, COMMIT_DEBOUNCE_DELAY)\n\n return () => {\n window.clearTimeout(timeoutId)\n }\n }, [shouldCommit])\n\n function handleChange(change: OnChangeParam) {\n setValue(change.value as Value)\n\n if (change.value !== value) {\n setShouldCommit(false)\n\n controller?.onChange(change)\n }\n }\n\n // HACK: Slate holds on to the very first DOM event handlers passed in and doesn't update them\n // even if they change. Since `controller` is first `undefined` then we must use a ref.\n const lastController = useRef(controller)\n if (lastController.current !== controller) lastController.current = controller\n const handleFocus = useCallback(() => {\n lastController.current?.focus()\n }, [])\n const handleKeyDown = useCallback(\n (event: ReactKeyboardEvent, _editor: Editor, next: () => any) => {\n if (Hotkeys.isUndo(event)) {\n lastController.current?.undo()\n\n return true\n }\n\n if (Hotkeys.isRedo(event)) {\n lastController.current?.redo()\n\n return true\n }\n\n if (isHotkey('escape')(event)) {\n lastController.current?.blur()\n\n return true\n }\n\n return next()\n },\n [],\n )\n const handleBlur = useCallback((event: ReactFocusEvent, editor: Editor, next: () => any) => {\n const selection = editor.value.selection\n\n next()\n\n // Normally, after a user highlight a text, clicking on the panel will remove the text selection.\n // This line is a workaround for that. Because the panel is not in the iframe, relatedTarget\n // would be null, and we select the previous text selection to maintain the text highlight.\n // Inspiration: https://github.com/ianstormtaylor/slate/issues/3412#issuecomment-663906003\n if (event.relatedTarget == null) editor.select(selection)\n }, [])\n\n const isInBuilder = useIsInBuilder()\n\n return (\n <RichTextEditor\n // @ts-expect-error: types don't allow for 'id' prop even though it's used.\n id={id}\n ref={setEditor}\n className={cx(useStyle({ 'ul, ol': { margin: 0 } }), width, margin)}\n value={value}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n readOnly={!isInBuilder || controller == null}\n />\n )\n})\n\nexport default EditableText\n"],"names":["TYPOGRAPHY_TYPE","renderMark","mark","children","_editor","next","type","data","get","renderBlock","props","node","attributes","blockProps","textAlign","Block","className","restOfProps","cx","useStyle","textDecoration","renderInline","toJS","RichTextEditor","forwardRef","ref","placeholder","plugins","useMemo","Lists","Link","Inlines","DeviceOverridesBlocks","DeviceOverridesMarks","SlateEditor","WebkitUserModify","undefined","margin","defaultText","document","nodes","object","COMMIT_DEBOUNCE_DELAY","EditableText","id","text","width","editor","setEditor","useState","propControllers","setPropControllers","controller","useImperativeHandle","getBoxModel","el","findDOMNode","Element","getBox","useEffect","setSlateEditor","value","setValue","selection","textWithoutSelection","Value","fromJSON","shouldCommit","setShouldCommit","nextValue","currentValue","isBlurred","toJSON","preserveSelection","timeoutId","window","setTimeout","clearTimeout","change","onChange","lastController","useRef","current","handleFocus","useCallback","focus","handleKeyDown","event","Hotkeys","isUndo","undo","isRedo","redo","isHotkey","blur","handleBlur","relatedTarget","select","isInBuilder","useIsInBuilder","handleChange"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAMA,kBAAkB;AAEqC,sCAAA;AACpD,SAAA;AAAA,IACLC,WAAW;AAAA,MAAEC;AAAAA,MAAMC;AAAAA,OAAYC,SAASC,MAAM;AACxCH,UAAAA,KAAKI,SAASN,iBAAiB;AACjC,mCAAQ,MAAD;AAAA,UAAM,OAAOE,KAAKK,KAAKC,IAAI,OAAd;AAAA,UAAyBL;AAAAA,QAAAA,CAA7C;AAAA,MACD;AAED,aAAOE,KAAP;AAAA,IACD;AAAA,EAAA;AAEJ;ACZ4D,sCAAA;AACpD,SAAA;AAAA,IACLI,YAAYC,OAAON,SAASC,MAAmB;AACvC,YAAA;AAAA,QAAEM;AAAAA,QAAMC;AAAAA,QAAYT;AAAAA,UAAaO;AACvC,YAAMG,aAAa;AAAA,QAAEC,WAAWH,KAAKJ,KAAKC,IAAI,WAAd;AAAA,MAAA;AAEx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ED,WAAOzF,KAAP;AAAA,EApB6B,GAsB/B,CAtB+B,CAAA;AAwBjC,QAAM0F,aAAaX,YAAY,CAACG,OAAwBxC,SAAgB1C,SAAoB;AACpF0D,UAAAA,YAAYhB,QAAOc,MAAME;;AAQ3BwB,QAAAA,MAAMS,iBAAiB;AAAMjD,cAAOkD,OAAOlC,SAAd;AAAA,EATL,GAU3B,CAV2B,CAAA;AAYxBmC,QAAAA,cAAcC;AAGlB,6BAAC,gBAAD;AAAA,IAEE;AAAA,IACA,KAAKnD;AAAAA,IACL,WAAW9B,GAAGC,SAAS;AAAA,MAAY,UAAA;AAAA,QAAEkB,QAAQ;AAAA,MAAV;AAAA,IAAA,CAAb,GAA+BS,OAAOT,MAA/C;AAAA,IACb;AAAA,IACA,UAAU+D;AAAAA,IACV,SAASjB;AAAAA,IACT,WAAWG;AAAAA,IACX,QAAQS;AAAAA,IACR,UAAU,CAACG,eAAe9C,cAAc;AAAA,EAAA,CAX5C;AAcD,CA/I8B;;"}
|
|
1
|
+
{"version":3,"file":"EditableText.es.js","sources":["../src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesMarks.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesBlocks.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/Link.tsx","../src/components/builtin/Text/components/RichTextEditor/plugins/Inlines.tsx","../src/components/builtin/Text/components/RichTextEditor/index.tsx","../src/components/builtin/Text/EditableText.tsx"],"sourcesContent":["import type { Plugin } from 'slate-react'\n\nimport Mark from '../components/Mark'\n\nconst TYPOGRAPHY_TYPE = 'typography'\n\nexport default function DeviceOverridesMarksPlugin(): Plugin {\n return {\n renderMark({ mark, children }, _editor, next) {\n if (mark.type === TYPOGRAPHY_TYPE) {\n return <Mark value={mark.data.get('value')}>{children}</Mark>\n }\n\n return next()\n },\n }\n}\n","import { Plugin } from 'slate-react'\n\nimport Block from '../components/Block'\n\nexport default function DeviceOverridesBlockPlugin(): Plugin {\n return {\n renderBlock(props, _editor, next): JSX.Element {\n const { node, attributes, children } = props\n const blockProps = { textAlign: node.data.get('textAlign') }\n\n switch (node.type) {\n case 'paragraph':\n return (\n <Block {...attributes} {...blockProps} as=\"p\">\n {children}\n </Block>\n )\n\n case 'heading-one':\n return (\n <Block {...attributes} {...blockProps} as=\"h1\">\n {children}\n </Block>\n )\n\n case 'heading-two':\n return (\n <Block {...attributes} {...blockProps} as=\"h2\">\n {children}\n </Block>\n )\n\n case 'heading-three':\n return (\n <Block {...attributes} {...blockProps} as=\"h3\">\n {children}\n </Block>\n )\n\n case 'heading-four':\n return (\n <Block {...attributes} {...blockProps} as=\"h4\">\n {children}\n </Block>\n )\n\n case 'heading-five':\n return (\n <Block {...attributes} {...blockProps} as=\"h5\">\n {children}\n </Block>\n )\n\n case 'heading-six':\n return (\n <Block {...attributes} {...blockProps} as=\"h6\">\n {children}\n </Block>\n )\n\n case 'blockquote':\n return (\n <Block {...attributes} {...blockProps} as=\"blockquote\">\n {children}\n </Block>\n )\n\n default:\n return next()\n }\n },\n }\n}\n","import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef } from 'react'\nimport { Plugin } from 'slate-react'\nimport { useStyle } from '../../../../../../runtimes/react/use-style'\n\nimport { Link } from '../../../../../shared/Link'\n\nfunction StyledLink({ className, ...restOfProps }: ComponentPropsWithoutRef<typeof Link>) {\n return <Link {...restOfProps} className={cx(useStyle({ textDecoration: 'none' }), className)} />\n}\n\nexport default function LinkPlugin(): Plugin {\n return {\n renderInline(props, _editor, next) {\n const { attributes, children, node } = props\n\n switch (node.type) {\n case 'link': {\n const { data } = node\n\n return (\n <StyledLink {...attributes} link={data.toJS()}>\n {children}\n </StyledLink>\n )\n }\n\n default: {\n return next()\n }\n }\n },\n }\n}\n","import { Plugin } from 'slate-react'\n\nexport default function Inlines(): Plugin {\n return {\n renderInline(props, _editor, next) {\n const { attributes, children, node } = props\n\n switch (node.type) {\n case 'code': {\n return <code {...attributes}>{children}</code>\n }\n\n case 'superscript': {\n return <sup {...attributes}>{children}</sup>\n }\n\n case 'subscript': {\n return <sub {...attributes}>{children}</sub>\n }\n\n default: {\n return next()\n }\n }\n },\n }\n}\n","import { ComponentPropsWithoutRef, forwardRef, useMemo } from 'react'\n\nimport { Editor as SlateEditor } from 'slate-react'\n\n// @ts-expect-error: no types for '@convertkit/slate-lists'\nimport Lists from '@convertkit/slate-lists'\n\nimport DeviceOverridesMarks from './plugins/DeviceOverridesMarks'\nimport DeviceOverridesBlocks from './plugins/DeviceOverridesBlocks'\nimport Link from './plugins/Link'\nimport Inlines from './plugins/Inlines'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\nexport { overrideTypographyStyle } from './components/Mark'\n\ntype Props = ComponentPropsWithoutRef<typeof SlateEditor>\n\nexport const RichTextEditor = forwardRef<SlateEditor, Props>(function RichTextEditor(\n { placeholder = 'Write some text...', className, ...restOfProps }: Props,\n ref,\n) {\n const plugins = useMemo(\n () => [Lists(), Link(), Inlines(), DeviceOverridesBlocks(), DeviceOverridesMarks()],\n [],\n )\n\n return (\n <SlateEditor\n {...restOfProps}\n // Workaround because our Slate editor is broken on Chrome 105\n // Problem: https://linear.app/makeswift/issue/PRD-434/our-rich-text-component-breaks-in-the-latest-version-of-chrome\n // Workaround: https://github.com/ianstormtaylor/slate/issues/5110#issuecomment-1234951122\n style={{ WebkitUserModify: undefined }}\n className={cx(useStyle({ 'ul, ol': { margin: 0 } }), className)}\n ref={ref}\n autoFocus={false}\n plugins={plugins}\n placeholder={placeholder}\n />\n )\n})\n","import {\n useState,\n Ref,\n useImperativeHandle,\n forwardRef,\n useEffect,\n useCallback,\n useRef,\n KeyboardEvent as ReactKeyboardEvent,\n FocusEvent as ReactFocusEvent,\n} from 'react'\nimport { Editor, OnChangeParam } from 'slate-react'\nimport { Value, ValueJSON } from 'slate'\n// @ts-expect-error: no types for 'slate-hotkeys'\nimport Hotkeys from 'slate-hotkeys'\nimport { isHotkey } from 'is-hotkey'\n\nimport {\n ElementIDValue,\n RichTextDescriptor,\n RichTextValue,\n} from '../../../prop-controllers/descriptors'\nimport { BoxModelHandle, getBox } from '../../../box-model'\nimport { PropControllersHandle } from '../../../state/modules/prop-controller-handles'\nimport { RichTextEditor } from './components/RichTextEditor'\nimport { DescriptorsPropControllers } from '../../../prop-controllers/instances'\nimport { cx } from '@emotion/css'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { useIsInBuilder } from '../../../runtimes/react'\nimport { pollBoxModel } from '../../../runtimes/react/poll-box-model'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst defaultText: ValueJSON = {\n document: { nodes: [{ object: 'block' as const, type: 'paragraph' as const, nodes: [] }] },\n data: {},\n}\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\ntype Descriptors = { text?: RichTextDescriptor }\n\nconst EditableText = forwardRef(function EditableText(\n { id, text, width, margin }: Props,\n ref: Ref<BoxModelHandle & PropControllersHandle<Descriptors>>,\n) {\n const [editor, setEditor] = useState<Editor | null>(null)\n const [propControllers, setPropControllers] =\n useState<DescriptorsPropControllers<Descriptors> | null>(null)\n const controller = propControllers?.text\n\n useEffect(() => {\n const element = editor?.findDOMNode([])\n if (element == null || !(element instanceof HTMLElement) || controller == null) return\n return pollBoxModel({\n element: element,\n onBoxModelChange: boxModel => controller.changeBoxModel(boxModel),\n })\n }, [editor, controller])\n\n useImperativeHandle(\n ref,\n () => ({\n getBoxModel() {\n const el = editor?.findDOMNode([])\n\n return el instanceof Element ? getBox(el) : null\n },\n setPropControllers,\n }),\n [editor, setPropControllers],\n )\n\n useEffect(() => {\n if (editor) controller?.setSlateEditor(editor)\n }, [controller, editor])\n\n /**\n * We must keep local state so that we can reflect the user's typed changes immediately. At the\n * same time, though, the source of truth for the data is the prop data. This presents a\n * challenge: how do we keep local state in sync with the prop data without mangling user input as\n * data comes in?\n *\n * Consider, for example, that the user types \"Hello\". If at a later time, when the user is trying\n * to type \", world\" the component re-renders with prop data \"H\", \"He\", \"Hel\", \"Hell\", \"Hello\", it\n * will disrupt the user's typing. This could also happen as a result of the prop data changing\n * for other reasons, like collaborators changing the prop data concurrently. We want to avoid to\n * disrupt the user's typing, while at the same time display the \"true\" value as quickly as\n * possible.\n *\n * The approach we take here is to commit the prop data at an opportune time: as the user is\n * typing we avoid to commit prop data. But once they've stopped typing, we commit it as soon as\n * possible. This is known as a debounce.\n */\n const [value, setValue] = useState(() => {\n const { selection, ...textWithoutSelection } = text ?? defaultText\n\n return Value.fromJSON(textWithoutSelection)\n })\n const [shouldCommit, setShouldCommit] = useState(true)\n\n useEffect(() => {\n if (shouldCommit) {\n const nextValue = Value.fromJSON(text ?? defaultText)\n\n setValue(currentValue =>\n currentValue.selection.isBlurred\n ? Value.fromJSON(nextValue.toJSON({ preserveSelection: false }))\n : nextValue,\n )\n }\n }, [shouldCommit, text])\n\n useEffect(() => {\n if (shouldCommit) return\n\n const timeoutId = window.setTimeout(() => {\n setShouldCommit(true)\n }, COMMIT_DEBOUNCE_DELAY)\n\n return () => {\n window.clearTimeout(timeoutId)\n }\n }, [shouldCommit])\n\n function handleChange(change: OnChangeParam) {\n setValue(change.value as Value)\n\n if (change.value !== value) {\n setShouldCommit(false)\n\n controller?.onChange(change)\n }\n }\n\n // HACK: Slate holds on to the very first DOM event handlers passed in and doesn't update them\n // even if they change. Since `controller` is first `undefined` then we must use a ref.\n const lastController = useRef(controller)\n if (lastController.current !== controller) lastController.current = controller\n const handleFocus = useCallback(() => {\n lastController.current?.focus()\n }, [])\n const handleKeyDown = useCallback(\n (event: ReactKeyboardEvent, _editor: Editor, next: () => any) => {\n if (Hotkeys.isUndo(event)) {\n lastController.current?.undo()\n\n return true\n }\n\n if (Hotkeys.isRedo(event)) {\n lastController.current?.redo()\n\n return true\n }\n\n if (isHotkey('escape')(event)) {\n lastController.current?.blur()\n\n return true\n }\n\n return next()\n },\n [],\n )\n const handleBlur = useCallback((event: ReactFocusEvent, editor: Editor, next: () => any) => {\n const selection = editor.value.selection\n\n next()\n\n // Normally, after a user highlight a text, clicking on the panel will remove the text selection.\n // This line is a workaround for that. Because the panel is not in the iframe, relatedTarget\n // would be null, and we select the previous text selection to maintain the text highlight.\n // Inspiration: https://github.com/ianstormtaylor/slate/issues/3412#issuecomment-663906003\n if (event.relatedTarget == null) editor.select(selection)\n }, [])\n\n const isInBuilder = useIsInBuilder()\n\n return (\n <RichTextEditor\n // @ts-expect-error: types don't allow for 'id' prop even though it's used.\n id={id}\n ref={setEditor}\n className={cx(useStyle({ 'ul, ol': { margin: 0 } }), width, margin)}\n value={value}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n readOnly={!isInBuilder || controller == null}\n />\n )\n})\n\nexport default EditableText\n"],"names":["TYPOGRAPHY_TYPE","renderMark","mark","children","_editor","next","type","data","get","renderBlock","props","node","attributes","blockProps","textAlign","Block","className","restOfProps","cx","useStyle","textDecoration","renderInline","toJS","RichTextEditor","forwardRef","ref","placeholder","plugins","useMemo","Lists","Link","Inlines","DeviceOverridesBlocks","DeviceOverridesMarks","SlateEditor","WebkitUserModify","undefined","margin","defaultText","document","nodes","object","COMMIT_DEBOUNCE_DELAY","EditableText","id","text","width","editor","setEditor","useState","propControllers","setPropControllers","controller","useEffect","element","findDOMNode","HTMLElement","pollBoxModel","onBoxModelChange","boxModel","changeBoxModel","useImperativeHandle","getBoxModel","el","Element","getBox","setSlateEditor","value","setValue","selection","textWithoutSelection","Value","fromJSON","shouldCommit","setShouldCommit","nextValue","currentValue","isBlurred","toJSON","preserveSelection","timeoutId","window","setTimeout","clearTimeout","change","onChange","lastController","useRef","current","handleFocus","useCallback","focus","handleKeyDown","event","Hotkeys","isUndo","undo","isRedo","redo","isHotkey","blur","handleBlur","relatedTarget","select","isInBuilder","useIsInBuilder","handleChange"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AA,MAAV;AAAA,IAAA,CAAb,GAA+BS,OAAOT,MAA/C;AAAA,IACb;AAAA,IACA,UAAUqE;AAAAA,IACV,SAASjB;AAAAA,IACT,WAAWG;AAAAA,IACX,QAAQS;AAAAA,IACR,UAAU,CAACG,eAAepD,cAAc;AAAA,EAAA,CAX5C;AAcD,CAxJ8B;;"}
|
package/dist/Embed.cjs.js
CHANGED
|
@@ -11,7 +11,7 @@ require("./constants.cjs.js");
|
|
|
11
11
|
require("redux");
|
|
12
12
|
require("redux-thunk");
|
|
13
13
|
require("./actions.cjs.js");
|
|
14
|
-
require("./
|
|
14
|
+
require("./rich-text.cjs.js");
|
|
15
15
|
require("./control.cjs.js");
|
|
16
16
|
require("@emotion/serialize");
|
|
17
17
|
require("@emotion/utils");
|
package/dist/Embed.es.js
CHANGED
package/dist/Form.cjs.js
CHANGED
|
@@ -46,7 +46,7 @@ require("./constants.cjs.js");
|
|
|
46
46
|
require("redux");
|
|
47
47
|
require("redux-thunk");
|
|
48
48
|
require("./actions.cjs.js");
|
|
49
|
-
require("./
|
|
49
|
+
require("./rich-text.cjs.js");
|
|
50
50
|
require("./control.cjs.js");
|
|
51
51
|
require("@emotion/serialize");
|
|
52
52
|
require("@emotion/utils");
|
package/dist/Form.es.js
CHANGED
package/dist/Image.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ require("./constants.cjs.js");
|
|
|
14
14
|
require("redux");
|
|
15
15
|
require("redux-thunk");
|
|
16
16
|
require("./actions.cjs.js");
|
|
17
|
-
require("./
|
|
17
|
+
require("./rich-text.cjs.js");
|
|
18
18
|
require("./control.cjs.js");
|
|
19
19
|
require("@emotion/serialize");
|
|
20
20
|
require("@emotion/utils");
|
|
@@ -82,7 +82,6 @@ const ImageComponent = React.forwardRef(function Image2({
|
|
|
82
82
|
const imageSrc = (fileData == null ? void 0 : fileData.publicUrl) ? fileData.publicUrl : placeholder.src;
|
|
83
83
|
const dataDimensions = (fileData == null ? void 0 : fileData.publicUrl) ? fileData == null ? void 0 : fileData.dimensions : placeholder.dimensions;
|
|
84
84
|
const [measuredDimensions, setMeasuredDimensions] = React.useState(null);
|
|
85
|
-
const isInBuilder = next.useIsInBuilder();
|
|
86
85
|
React.useEffect(() => {
|
|
87
86
|
if (dataDimensions)
|
|
88
87
|
return;
|
|
@@ -120,8 +119,7 @@ const ImageComponent = React.forwardRef(function Image2({
|
|
|
120
119
|
sizes: imageSizes(width),
|
|
121
120
|
alt: altText,
|
|
122
121
|
width: dimensions.width,
|
|
123
|
-
height: dimensions.height
|
|
124
|
-
unoptimized: isInBuilder
|
|
122
|
+
height: dimensions.height
|
|
125
123
|
}) : /* @__PURE__ */ jsxRuntime.jsx(NextImage__default["default"], {
|
|
126
124
|
src: imageSrc,
|
|
127
125
|
sizes: imageSizes(width),
|
|
@@ -131,8 +129,7 @@ const ImageComponent = React.forwardRef(function Image2({
|
|
|
131
129
|
style: {
|
|
132
130
|
width: "100%",
|
|
133
131
|
height: "auto"
|
|
134
|
-
}
|
|
135
|
-
unoptimized: isInBuilder
|
|
132
|
+
}
|
|
136
133
|
})
|
|
137
134
|
});
|
|
138
135
|
});
|
package/dist/Image.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.cjs.js","sources":["../src/components/builtin/Image/Image.tsx"],"sourcesContent":["import { useState, useEffect, Ref, forwardRef } from 'react'\nimport NextImage from 'next/image'\nimport type NextLegacyImageType from 'next/legacy/image'\n\nimport {\n ElementIDValue,\n ImageValue,\n LinkValue,\n ResponsiveOpacityValue,\n TextInputValue,\n WidthValue,\n} from '../../../prop-controllers/descriptors'\nimport { DEVICES, findDeviceOverride } from '../../utils/devices'\nimport { placeholders } from '../../utils/placeholders'\nimport {
|
|
1
|
+
{"version":3,"file":"Image.cjs.js","sources":["../src/components/builtin/Image/Image.tsx"],"sourcesContent":["import { useState, useEffect, Ref, forwardRef } from 'react'\nimport NextImage from 'next/image'\nimport type NextLegacyImageType from 'next/legacy/image'\n\nimport {\n ElementIDValue,\n ImageValue,\n LinkValue,\n ResponsiveOpacityValue,\n TextInputValue,\n WidthValue,\n} from '../../../prop-controllers/descriptors'\nimport { DEVICES, findDeviceOverride } from '../../utils/devices'\nimport { placeholders } from '../../utils/placeholders'\nimport { Link } from '../../shared/Link'\nimport { cx } from '@emotion/css'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { responsiveStyle, responsiveWidth } from '../../utils/responsive-style'\nimport { useFile } from '../../../runtimes/react/hooks/makeswift-api'\nimport { major as nextMajorVersion } from '../../../next/next-version'\n\nconst NextLegacyImage = NextImage as typeof NextLegacyImageType\n\ntype Props = {\n id?: ElementIDValue\n file?: ImageValue\n altText?: TextInputValue\n link?: LinkValue\n width?: WidthValue\n margin?: string\n padding?: string\n border?: string\n borderRadius?: string\n boxShadow?: string\n opacity?: ResponsiveOpacityValue\n placeholder?: { src: string; dimensions: { width: number; height: number } }\n className?: string\n}\n\nfunction loadImage(src: string): Promise<HTMLImageElement> {\n return new Promise<HTMLImageElement>((resolve, reject) => {\n const image = new Image()\n\n image.onload = () => resolve(image)\n image.onerror = reject\n image.src = src\n })\n}\n\nfunction imageSizes(width?: Props['width']): string {\n const baseDevice = DEVICES.find(device => device.maxWidth == null)\n const baseWidth = baseDevice && width && findDeviceOverride(width, baseDevice.id)\n const baseWidthSize =\n baseWidth == null || baseWidth.value.unit !== 'px' ? '100vw' : `${baseWidth.value.value}px`\n\n return DEVICES.map(device => {\n const override = findDeviceOverride(width, device.id)\n\n if (override == null || device.maxWidth == null || override.value.unit !== 'px') return null\n\n return `(max-width: ${device.maxWidth}px) ${Math.min(device.maxWidth, override.value.value)}px`\n })\n .filter((size): size is NonNullable<typeof size> => size != null)\n .reduce((sourceSizes, sourceSize) => `${sourceSize}, ${sourceSizes}`, baseWidthSize)\n}\n\ntype Dimensions = {\n width: number\n height: number\n}\n\nconst ImageComponent = forwardRef(function Image(\n {\n id,\n width,\n margin,\n padding,\n file,\n border,\n borderRadius,\n altText,\n link,\n opacity,\n boxShadow,\n placeholder = placeholders.image,\n className,\n }: Props,\n ref: Ref<HTMLAnchorElement & HTMLDivElement>,\n) {\n const fileData = useFile(file ?? null)\n const imageSrc = fileData?.publicUrl ? fileData.publicUrl : placeholder.src\n const dataDimensions = fileData?.publicUrl ? fileData?.dimensions : placeholder.dimensions\n const [measuredDimensions, setMeasuredDimensions] = useState<Dimensions | null>(null)\n\n useEffect(() => {\n if (dataDimensions) return\n\n let cleanedUp = false\n\n loadImage(imageSrc)\n .then(image => {\n if (!cleanedUp) {\n setMeasuredDimensions({ width: image.naturalWidth, height: image.naturalHeight })\n }\n })\n .catch(console.error)\n\n return () => {\n cleanedUp = true\n }\n }, [dataDimensions, imageSrc])\n\n const dimensions = dataDimensions ?? measuredDimensions\n const Container = link ? Link : 'div'\n const containerClassName = cx(\n useStyle({ lineHeight: 0, overflow: 'hidden' }),\n useStyle(responsiveWidth(width, dimensions?.width)),\n useStyle(responsiveStyle([opacity] as const, ([opacity = 1]) => ({ opacity }))),\n margin,\n padding,\n border,\n borderRadius,\n boxShadow,\n className,\n )\n\n if (!dimensions) return null\n\n return (\n <Container link={link} ref={ref} id={id} className={containerClassName}>\n {nextMajorVersion < 13 ? (\n <NextLegacyImage\n layout=\"responsive\"\n src={imageSrc}\n sizes={imageSizes(width)}\n alt={altText}\n width={dimensions.width}\n height={dimensions.height}\n />\n ) : (\n <NextImage\n src={imageSrc}\n sizes={imageSizes(width)}\n alt={altText ?? ''}\n width={dimensions.width}\n height={dimensions.height}\n style={{\n width: '100%',\n height: 'auto',\n }}\n />\n )}\n </Container>\n )\n})\n\nexport default ImageComponent\n"],"names":["NextLegacyImage","NextImage","src","Promise","resolve","reject","image","Image","onload","onerror","width","baseDevice","DEVICES","find","device","maxWidth","baseWidth","findDeviceOverride","id","baseWidthSize","value","unit","map","override","Math","min","filter","size","reduce","sourceSizes","sourceSize","ImageComponent","forwardRef","margin","padding","file","border","borderRadius","altText","link","opacity","boxShadow","placeholder","placeholders","className","ref","fileData","useFile","imageSrc","publicUrl","dataDimensions","dimensions","measuredDimensions","setMeasuredDimensions","useState","useEffect","cleanedUp","then","naturalWidth","height","naturalHeight","catch","console","error","Container","Link","containerClassName","cx","useStyle","lineHeight","overflow","responsiveWidth","responsiveStyle","nextMajorVersion","_jsx","imageSizes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAMA,kBAAkBC,mBAAAA;AAkBxB,mBAAmBC,KAAwC;AAClD,SAAA,IAAIC,QAA0B,CAACC,SAASC,WAAW;AAClDC,UAAAA,QAAQ,IAAIC;AAEZC,UAAAA,SAAS,MAAMJ,QAAQE,KAAD;AAC5BA,UAAMG,UAAUJ;AAChBC,UAAMJ,MAAMA;AAAAA,EAAAA,CALP;AAOR;AAED,oBAAoBQ,OAAgC;AAClD,QAAMC,aAAaC,KAAQC,QAAAA,KAAKC,CAAUA,WAAAA,OAAOC,YAAY,IAA1C;AACnB,QAAMC,YAAYL,cAAcD,SAASO,KAAmBP,mBAAAA,OAAOC,WAAWO,EAAnB;AACrDC,QAAAA,gBACJH,aAAa,QAAQA,UAAUI,MAAMC,SAAS,OAAO,UAAW,GAAEL,UAAUI,MAAMA;AAE7ER,SAAAA,KAAAA,QAAQU,IAAIR,CAAU,WAAA;AACrBS,UAAAA,WAAWN,KAAAA,mBAAmBP,OAAOI,OAAOI,EAAf;AAEnC,QAAIK,YAAY,QAAQT,OAAOC,YAAY,QAAQQ,SAASH,MAAMC,SAAS;AAAa,aAAA;AAEhF,WAAA,eAAcP,OAAOC,eAAeS,KAAKC,IAAIX,OAAOC,UAAUQ,SAASH,MAAMA,KAAzC;AAAA,EAAA,CALvC,EAOJM,OAAO,CAACC,SAA2CA,QAAQ,IAPvD,EAQJC,OAAO,CAACC,aAAaC,eAAgB,GAAEA,eAAeD,eAAeV,aARjE;AASR;AAOKY,MAAAA,iBAAiBC,MAAAA,WAAW,gBAChC;AAAA,EACEd;AAAAA,EACAR;AA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AmB,WAAA;AAExB,wCACG,WAAD;AAAA,IAAW;AAAA,IAAY;AAAA,IAAU;AAAA,IAAQ,WAAWe;AAAAA,IAApD,UACGO,YAAAA,QAAmB,KAClBC,2BAAAA,IAAC,iBAAD;AAAA,MACE,QAAO;AAAA,MACP,KAAK1B;AAAAA,MACL,OAAO2B,WAAWjE,KAAD;AAAA,MACjB,KAAK4B;AAAAA,MACL,OAAOa,WAAWzC;AAAAA,MAClB,QAAQyC,WAAWQ;AAAAA,IAAAA,CAPtB,IAUCe,2BAAA,IAACzE,+BAAD;AAAA,MACE,KAAK+C;AAAAA,MACL,OAAO2B,WAAWjE,KAAD;AAAA,MACjB,KAAK4B,4BAAW;AAAA,MAChB,OAAOa,WAAWzC;AAAAA,MAClB,QAAQyC,WAAWQ;AAAAA,MACnB,OAAO;AAAA,QACLjD,OAAO;AAAA,QACPiD,QAAQ;AAAA,MAFH;AAAA,IAAA,CANT;AAAA,EAAA,CAZN;AA0BD,CAnFgC;;"}
|
package/dist/Image.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forwardRef, useState, useEffect } from "react";
|
|
2
2
|
import NextImage from "next/image";
|
|
3
|
-
import { B as useFile,
|
|
3
|
+
import { B as useFile, o as useStyle, p as responsiveWidth, r as responsiveStyle, F as DEVICES, G as findDeviceOverride } from "./index.es.js";
|
|
4
4
|
import { p as placeholders } from "./placeholders.es.js";
|
|
5
5
|
import { L as Link } from "./index.es3.js";
|
|
6
6
|
import { cx } from "@emotion/css";
|
|
@@ -12,7 +12,7 @@ import "./constants.es.js";
|
|
|
12
12
|
import "redux";
|
|
13
13
|
import "redux-thunk";
|
|
14
14
|
import "./actions.es.js";
|
|
15
|
-
import "./
|
|
15
|
+
import "./rich-text.es.js";
|
|
16
16
|
import "./control.es.js";
|
|
17
17
|
import "@emotion/serialize";
|
|
18
18
|
import "@emotion/utils";
|
|
@@ -76,7 +76,6 @@ const ImageComponent = forwardRef(function Image2({
|
|
|
76
76
|
const imageSrc = (fileData == null ? void 0 : fileData.publicUrl) ? fileData.publicUrl : placeholder.src;
|
|
77
77
|
const dataDimensions = (fileData == null ? void 0 : fileData.publicUrl) ? fileData == null ? void 0 : fileData.dimensions : placeholder.dimensions;
|
|
78
78
|
const [measuredDimensions, setMeasuredDimensions] = useState(null);
|
|
79
|
-
const isInBuilder = useIsInBuilder();
|
|
80
79
|
useEffect(() => {
|
|
81
80
|
if (dataDimensions)
|
|
82
81
|
return;
|
|
@@ -114,8 +113,7 @@ const ImageComponent = forwardRef(function Image2({
|
|
|
114
113
|
sizes: imageSizes(width),
|
|
115
114
|
alt: altText,
|
|
116
115
|
width: dimensions.width,
|
|
117
|
-
height: dimensions.height
|
|
118
|
-
unoptimized: isInBuilder
|
|
116
|
+
height: dimensions.height
|
|
119
117
|
}) : /* @__PURE__ */ jsx(NextImage, {
|
|
120
118
|
src: imageSrc,
|
|
121
119
|
sizes: imageSizes(width),
|
|
@@ -125,8 +123,7 @@ const ImageComponent = forwardRef(function Image2({
|
|
|
125
123
|
style: {
|
|
126
124
|
width: "100%",
|
|
127
125
|
height: "auto"
|
|
128
|
-
}
|
|
129
|
-
unoptimized: isInBuilder
|
|
126
|
+
}
|
|
130
127
|
})
|
|
131
128
|
});
|
|
132
129
|
});
|
package/dist/Image.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.es.js","sources":["../src/components/builtin/Image/Image.tsx"],"sourcesContent":["import { useState, useEffect, Ref, forwardRef } from 'react'\nimport NextImage from 'next/image'\nimport type NextLegacyImageType from 'next/legacy/image'\n\nimport {\n ElementIDValue,\n ImageValue,\n LinkValue,\n ResponsiveOpacityValue,\n TextInputValue,\n WidthValue,\n} from '../../../prop-controllers/descriptors'\nimport { DEVICES, findDeviceOverride } from '../../utils/devices'\nimport { placeholders } from '../../utils/placeholders'\nimport {
|
|
1
|
+
{"version":3,"file":"Image.es.js","sources":["../src/components/builtin/Image/Image.tsx"],"sourcesContent":["import { useState, useEffect, Ref, forwardRef } from 'react'\nimport NextImage from 'next/image'\nimport type NextLegacyImageType from 'next/legacy/image'\n\nimport {\n ElementIDValue,\n ImageValue,\n LinkValue,\n ResponsiveOpacityValue,\n TextInputValue,\n WidthValue,\n} from '../../../prop-controllers/descriptors'\nimport { DEVICES, findDeviceOverride } from '../../utils/devices'\nimport { placeholders } from '../../utils/placeholders'\nimport { Link } from '../../shared/Link'\nimport { cx } from '@emotion/css'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { responsiveStyle, responsiveWidth } from '../../utils/responsive-style'\nimport { useFile } from '../../../runtimes/react/hooks/makeswift-api'\nimport { major as nextMajorVersion } from '../../../next/next-version'\n\nconst NextLegacyImage = NextImage as typeof NextLegacyImageType\n\ntype Props = {\n id?: ElementIDValue\n file?: ImageValue\n altText?: TextInputValue\n link?: LinkValue\n width?: WidthValue\n margin?: string\n padding?: string\n border?: string\n borderRadius?: string\n boxShadow?: string\n opacity?: ResponsiveOpacityValue\n placeholder?: { src: string; dimensions: { width: number; height: number } }\n className?: string\n}\n\nfunction loadImage(src: string): Promise<HTMLImageElement> {\n return new Promise<HTMLImageElement>((resolve, reject) => {\n const image = new Image()\n\n image.onload = () => resolve(image)\n image.onerror = reject\n image.src = src\n })\n}\n\nfunction imageSizes(width?: Props['width']): string {\n const baseDevice = DEVICES.find(device => device.maxWidth == null)\n const baseWidth = baseDevice && width && findDeviceOverride(width, baseDevice.id)\n const baseWidthSize =\n baseWidth == null || baseWidth.value.unit !== 'px' ? '100vw' : `${baseWidth.value.value}px`\n\n return DEVICES.map(device => {\n const override = findDeviceOverride(width, device.id)\n\n if (override == null || device.maxWidth == null || override.value.unit !== 'px') return null\n\n return `(max-width: ${device.maxWidth}px) ${Math.min(device.maxWidth, override.value.value)}px`\n })\n .filter((size): size is NonNullable<typeof size> => size != null)\n .reduce((sourceSizes, sourceSize) => `${sourceSize}, ${sourceSizes}`, baseWidthSize)\n}\n\ntype Dimensions = {\n width: number\n height: number\n}\n\nconst ImageComponent = forwardRef(function Image(\n {\n id,\n width,\n margin,\n padding,\n file,\n border,\n borderRadius,\n altText,\n link,\n opacity,\n boxShadow,\n placeholder = placeholders.image,\n className,\n }: Props,\n ref: Ref<HTMLAnchorElement & HTMLDivElement>,\n) {\n const fileData = useFile(file ?? null)\n const imageSrc = fileData?.publicUrl ? fileData.publicUrl : placeholder.src\n const dataDimensions = fileData?.publicUrl ? fileData?.dimensions : placeholder.dimensions\n const [measuredDimensions, setMeasuredDimensions] = useState<Dimensions | null>(null)\n\n useEffect(() => {\n if (dataDimensions) return\n\n let cleanedUp = false\n\n loadImage(imageSrc)\n .then(image => {\n if (!cleanedUp) {\n setMeasuredDimensions({ width: image.naturalWidth, height: image.naturalHeight })\n }\n })\n .catch(console.error)\n\n return () => {\n cleanedUp = true\n }\n }, [dataDimensions, imageSrc])\n\n const dimensions = dataDimensions ?? measuredDimensions\n const Container = link ? Link : 'div'\n const containerClassName = cx(\n useStyle({ lineHeight: 0, overflow: 'hidden' }),\n useStyle(responsiveWidth(width, dimensions?.width)),\n useStyle(responsiveStyle([opacity] as const, ([opacity = 1]) => ({ opacity }))),\n margin,\n padding,\n border,\n borderRadius,\n boxShadow,\n className,\n )\n\n if (!dimensions) return null\n\n return (\n <Container link={link} ref={ref} id={id} className={containerClassName}>\n {nextMajorVersion < 13 ? (\n <NextLegacyImage\n layout=\"responsive\"\n src={imageSrc}\n sizes={imageSizes(width)}\n alt={altText}\n width={dimensions.width}\n height={dimensions.height}\n />\n ) : (\n <NextImage\n src={imageSrc}\n sizes={imageSizes(width)}\n alt={altText ?? ''}\n width={dimensions.width}\n height={dimensions.height}\n style={{\n width: '100%',\n height: 'auto',\n }}\n />\n )}\n </Container>\n )\n})\n\nexport default ImageComponent\n"],"names":["NextLegacyImage","NextImage","src","Promise","resolve","reject","image","Image","onload","onerror","width","baseDevice","DEVICES","find","device","maxWidth","baseWidth","findDeviceOverride","id","baseWidthSize","value","unit","map","override","Math","min","filter","size","reduce","sourceSizes","sourceSize","ImageComponent","forwardRef","margin","padding","file","border","borderRadius","altText","link","opacity","boxShadow","placeholder","placeholders","className","ref","fileData","useFile","imageSrc","publicUrl","dataDimensions","dimensions","measuredDimensions","setMeasuredDimensions","useState","useEffect","cleanedUp","then","naturalWidth","height","naturalHeight","catch","console","error","Container","Link","containerClassName","cx","useStyle","lineHeight","overflow","responsiveWidth","responsiveStyle","nextMajorVersion","_jsx","imageSizes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAMA,kBAAkBC;AAkBxB,mBAAmBC,KAAwC;AAClD,SAAA,IAAIC,QAA0B,CAACC,SAASC,WAAW;AAClDC,UAAAA,QAAQ,IAAIC;AAEZC,UAAAA,SAAS,MAAMJ,QAAQE,KAAD;AAC5BA,UAAMG,UAAUJ;AAChBC,UAAMJ,MAAMA;AAAAA,EAAAA,CALP;AAOR;AAED,oBAAoBQ,OAAgC;AAClD,QAAMC,aAAaC,QAAQC,KAAKC,CAAUA,WAAAA,OAAOC,YAAY,IAA1C;AACnB,QAAMC,YAAYL,cAAcD,SAASO,mBAAmBP,OAAOC,WAAWO,EAAnB;AACrDC,QAAAA,gBACJH,aAAa,QAAQA,UAAUI,MAAMC,SAAS,OAAO,UAAW,GAAEL,UAAUI,MAAMA;AAE7ER,SAAAA,QAAQU,IAAIR,CAAU,WAAA;AACrBS,UAAAA,WAAWN,mBAAmBP,OAAOI,OAAOI,EAAf;AAEnC,QAAIK,YAAY,QAAQT,OAAOC,YAAY,QAAQQ,SAASH,MAAMC,SAAS;AAAa,aAAA;AAEhF,WAAA,eAAcP,OAAOC,eAAeS,KAAKC,IAAIX,OAAOC,UAAUQ,SAASH,MAAMA,KAAzC;AAAA,EAAA,CALvC,EAOJM,OAAO,CAACC,SAA2CA,QAAQ,IAPvD,EAQJC,OAAO,CAACC,aAAaC,eAAgB,GAAEA,eAAeD,eAAeV,aARjE;AASR;AAOKY,MAAAA,iBAAiBC,WAAW,gBA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AD;AAAA,IAAW;AAAA,IAAY;AAAA,IAAU;AAAA,IAAQ,WAAWe;AAAAA,IAApD,UACGO,QAAmB,KAClBC,oBAAC,iBAAD;AAAA,MACE,QAAO;AAAA,MACP,KAAK1B;AAAAA,MACL,OAAO2B,WAAWjE,KAAD;AAAA,MACjB,KAAK4B;AAAAA,MACL,OAAOa,WAAWzC;AAAAA,MAClB,QAAQyC,WAAWQ;AAAAA,IAAAA,CAPtB,IAUCe,oBAAC,WAAD;AAAA,MACE,KAAK1B;AAAAA,MACL,OAAO2B,WAAWjE,KAAD;AAAA,MACjB,KAAK4B,4BAAW;AAAA,MAChB,OAAOa,WAAWzC;AAAAA,MAClB,QAAQyC,WAAWQ;AAAAA,MACnB,OAAO;AAAA,QACLjD,OAAO;AAAA,QACPiD,QAAQ;AAAA,MAFH;AAAA,IAAA,CANT;AAAA,EAAA,CAZN;AA0BD,CAnFgC;;"}
|
package/dist/LiveProvider.cjs.js
CHANGED
|
@@ -10,7 +10,7 @@ require("./actions.cjs.js");
|
|
|
10
10
|
require("@emotion/css");
|
|
11
11
|
require("@emotion/serialize");
|
|
12
12
|
require("@emotion/utils");
|
|
13
|
-
require("./
|
|
13
|
+
require("./rich-text.cjs.js");
|
|
14
14
|
require("./text-input.cjs.js");
|
|
15
15
|
require("./combobox.cjs.js");
|
|
16
16
|
require("./control.cjs.js");
|