@mittwald/flow-react-components 1.6.0-next.64 → 1.6.0-next.66
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/assets/component-index.json +1 -1
- package/dist/assets/doc-properties.json +1 -1
- package/dist/js/packages/components/src/components/Markdown/Markdown.mjs +2 -2
- package/dist/js/packages/components/src/components/Markdown/Markdown.mjs.map +1 -1
- package/dist/js/packages/components/src/components/MarkdownEditor/MarkdownEditor.mjs +3 -1
- package/dist/js/packages/components/src/components/MarkdownEditor/MarkdownEditor.mjs.map +1 -1
- package/dist/js/packages/components/src/components/MarkdownEditor/lib/fileUpload.mjs +2 -2
- package/dist/js/packages/components/src/components/MarkdownEditor/lib/fileUpload.mjs.map +1 -1
- package/dist/js/packages/components/src/components/MarkdownEditor/lib/useFileUpload.mjs +2 -2
- package/dist/js/packages/components/src/components/MarkdownEditor/lib/useFileUpload.mjs.map +1 -1
- package/dist/types/components/Markdown/Markdown.d.ts +2 -0
- package/dist/types/components/MarkdownEditor/MarkdownEditor.d.ts +1 -1
- package/package.json +10 -10
|
@@ -23,7 +23,7 @@ import remarkGfm from "remark-gfm";
|
|
|
23
23
|
* @flr-ignore-props components
|
|
24
24
|
*/
|
|
25
25
|
var Markdown = (props) => {
|
|
26
|
-
const { children, color = "default", className, headingOffset = 0, components: customComponents, ref, allowElement, allowedElements, disallowedElements, rehypePlugins, remarkPlugins, remarkRehypeOptions, skipHtml, unwrapDisallowed, urlTransform, ...rest } = props;
|
|
26
|
+
const { children, color = "default", className, headingOffset = 0, disableImages = false, components: customComponents, ref, allowElement, allowedElements, disallowedElements, rehypePlugins, remarkPlugins, remarkRehypeOptions, skipHtml, unwrapDisallowed, urlTransform, ...rest } = props;
|
|
27
27
|
const isSkeleton = useSkeletonMode();
|
|
28
28
|
const clobberPrefix = `user-content-${useId().replace(/[^\w-]/g, "")}-`;
|
|
29
29
|
const defaultComponents = useMemo(() => ({
|
|
@@ -134,7 +134,7 @@ var Markdown = (props) => {
|
|
|
134
134
|
...rest,
|
|
135
135
|
ref,
|
|
136
136
|
children: /* @__PURE__ */ jsx(ReactMarkdown, {
|
|
137
|
-
allowElement,
|
|
137
|
+
allowElement: (element, index, parent) => !(disableImages && element.tagName === "img") && (allowElement?.(element, index, parent) ?? true),
|
|
138
138
|
allowedElements,
|
|
139
139
|
disallowedElements,
|
|
140
140
|
rehypePlugins,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.mjs","names":["styles"],"sources":["../../../../../../../src/components/Markdown/Markdown.tsx"],"sourcesContent":["import { CodeBlock } from \"@/components/CodeBlock\";\nimport { Heading } from \"@/components/Heading\";\nimport { InlineCode } from \"@/components/InlineCode\";\nimport { Link } from \"@/components/Link\";\nimport { Separator } from \"@/components/Separator\";\nimport { Text } from \"@/components/Text\";\nimport type { CSSProperties, FC, Ref } from \"react\";\nimport { Children, isValidElement, useId, useMemo } from \"react\";\nimport type { Components, Options } from \"react-markdown\";\nimport ReactMarkdown from \"react-markdown\";\nimport styles from \"./Markdown.module.scss\";\nimport { extractTextFromFirstChild } from \"@/lib/react/remote\";\nimport type { AlphaColor, PropsWithClassName } from \"@/lib/types/props\";\nimport clsx from \"clsx\";\nimport remarkGfm from \"remark-gfm\";\nimport { getHeadingLevelWithOffset } from \"@/components/Markdown/lib/getHeadingLevelWithOffset\";\nimport { isExternalHref } from \"@/components/Markdown/lib/isExternalHref\";\nimport type { CodeEditorLanguage } from \"@/components/CodeEditor/languages\";\nimport {\n SkeletonBlockText,\n SkeletonInlineContent,\n} from \"@/components/Markdown/components/SkeletonBlocks\";\nimport { useSkeletonMode } from \"@/components/SkeletonMode/skeletonModeContext\";\n\nexport interface MarkdownProps\n extends PropsWithClassName, Omit<Options, \"components\"> {\n /** The color schema of the markdown component. @default \"default\" */\n color?: \"default\" | AlphaColor;\n /** Shifts all heading levels by the given offset. @default 0 */\n headingOffset?: number;\n /** Allows overriding markdown element renderers from outside. */\n components?: Components;\n /** @internal */\n style?: CSSProperties;\n /** A ref to the elements root. */\n ref?: Ref<HTMLDivElement>;\n}\n\n/**\n * @flr-generate all\n * @flr-ignore-props components\n */\nexport const Markdown: FC<MarkdownProps> = (props) => {\n const {\n children,\n color = \"default\",\n className,\n headingOffset = 0,\n components: customComponents,\n ref,\n allowElement,\n allowedElements,\n disallowedElements,\n rehypePlugins,\n remarkPlugins,\n remarkRehypeOptions,\n skipHtml,\n unwrapDisallowed,\n urlTransform,\n ...rest\n } = props;\n\n const isSkeleton = useSkeletonMode();\n /* Footnote ids are per document, so two instances on one page would share\n them and a back link would jump into the other one. */\n const clobberPrefix = `user-content-${useId().replace(/[^\\w-]/g, \"\")}-`;\n\n /* react-markdown uses the renderers as element types: new ones on every\n render would remount the whole tree. */\n const defaultComponents = useMemo<Components>(\n () => ({\n /* GFM footnotes link through `id` (the back link's target), `aria-label`\n and `aria-describedby`. */\n a: (props) => (\n <Link\n id={props.id}\n aria-label={props[\"aria-label\"]}\n aria-describedby={props[\"aria-describedby\"]}\n target={isExternalHref(props.href) ? \"_blank\" : undefined}\n color={color}\n href={props.href}\n >\n {props.children}\n </Link>\n ),\n p: (props) => (\n <Text elementType=\"p\" color={color}>\n {props.children}\n </Text>\n ),\n code: (props) => <InlineCode color={color}>{props.children}</InlineCode>,\n h1: (props) => (\n <Heading\n id={props.id}\n level={getHeadingLevelWithOffset(1, headingOffset)}\n color={color}\n >\n {props.children}\n </Heading>\n ),\n h2: (props) => (\n <Heading\n id={props.id}\n level={getHeadingLevelWithOffset(2, headingOffset)}\n color={color}\n >\n {props.children}\n </Heading>\n ),\n h3: (props) => (\n <Heading\n id={props.id}\n level={getHeadingLevelWithOffset(3, headingOffset)}\n color={color}\n >\n {props.children}\n </Heading>\n ),\n h4: (props) => (\n <Heading\n id={props.id}\n level={getHeadingLevelWithOffset(4, headingOffset)}\n color={color}\n >\n {props.children}\n </Heading>\n ),\n h5: (props) => (\n <Heading\n id={props.id}\n level={getHeadingLevelWithOffset(5, headingOffset)}\n color={color}\n >\n {props.children}\n </Heading>\n ),\n h6: (props) => (\n <Heading\n id={props.id}\n level={getHeadingLevelWithOffset(6, headingOffset)}\n color={color}\n >\n {props.children}\n </Heading>\n ),\n hr: () => <Separator />,\n pre: (props) => {\n const preElementContent = Children.toArray(props.children)[0];\n\n return (\n <CodeBlock\n copyable={false}\n language={\n isValidElement<{ className?: string }>(preElementContent) &&\n preElementContent.props.className\n ? (preElementContent.props.className.replace(\n \"language-\",\n \"\",\n ) as CodeEditorLanguage)\n : undefined\n }\n code={String(\n isValidElement<{ children: string }>(preElementContent)\n ? preElementContent.props.children\n : preElementContent,\n ).trim()}\n />\n );\n },\n ul: ({ node: ignoredNode, ...props }) => (\n <SkeletonBlockText color={color}>\n <ul {...props} />\n </SkeletonBlockText>\n ),\n ol: ({ node: ignoredNode, ...props }) => (\n <SkeletonBlockText color={color}>\n <ol {...props} />\n </SkeletonBlockText>\n ),\n li: ({ node: ignoredNode, children, ...props }) => (\n <li {...props}>\n <SkeletonInlineContent>{children}</SkeletonInlineContent>\n </li>\n ),\n /* A table cannot shrink below its content, so the box around it scrolls\n instead of the table overflowing the markdown. */\n table: ({ node: ignoredNode, ...props }) => (\n <div className={styles.tableContainer}>\n <table {...props} />\n </div>\n ),\n th: ({ node: ignoredNode, children, ...props }) => (\n <th {...props}>\n <SkeletonInlineContent>{children}</SkeletonInlineContent>\n </th>\n ),\n td: ({ node: ignoredNode, children, ...props }) => (\n <td {...props}>\n <SkeletonInlineContent>{children}</SkeletonInlineContent>\n </td>\n ),\n /* A text bar resets the mode for its content, so the image reads it\n from here. A skeleton issues no request. */\n img: ({ node: ignoredNode, ...props }) =>\n isSkeleton ? null : <img {...props} />,\n blockquote: (props) => (\n <SkeletonBlockText color={color}>\n <blockquote>{props.children}</blockquote>\n </SkeletonBlockText>\n ),\n }),\n [color, headingOffset, isSkeleton],\n );\n\n const textContent = extractTextFromFirstChild(children);\n const mergedComponents = useMemo<Components>(\n () => ({\n ...defaultComponents,\n ...customComponents,\n }),\n [defaultComponents, customComponents],\n );\n\n return (\n <div className={clsx(styles.markdown, className)} {...rest} ref={ref}>\n <ReactMarkdown\n allowElement={allowElement}\n allowedElements={allowedElements}\n disallowedElements={disallowedElements}\n rehypePlugins={rehypePlugins}\n remarkPlugins={remarkPlugins ?? [remarkGfm]}\n remarkRehypeOptions={{ clobberPrefix, ...remarkRehypeOptions }}\n skipHtml={skipHtml}\n unwrapDisallowed={unwrapDisallowed}\n urlTransform={urlTransform}\n components={mergedComponents}\n >\n {textContent}\n </ReactMarkdown>\n </div>\n );\n};\n\nexport default Markdown;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAa,YAA+B,UAAU;CACpD,MAAM,EACJ,UACA,QAAQ,WACR,WACA,gBAAgB,GAChB,YAAY,kBACZ,KACA,cACA,iBACA,oBACA,eACA,eACA,qBACA,UACA,kBACA,cACA,GAAG,SACD;CAEJ,MAAM,aAAa,gBAAgB;CAGnC,MAAM,gBAAgB,gBAAgB,MAAM,CAAC,CAAC,QAAQ,WAAW,EAAE,EAAE;CAIrE,MAAM,oBAAoB,eACjB;EAGL,IAAI,UACF,oBAAC,MAAD;GACE,IAAI,MAAM;GACV,cAAY,MAAM;GAClB,oBAAkB,MAAM;GACxB,QAAQ,eAAe,MAAM,IAAI,IAAI,WAAW,KAAA;GACzC;GACP,MAAM,MAAM;GAEX,UAAA,MAAM;EACH,CAAA;EAER,IAAI,UACF,oBAAC,MAAD;GAAM,aAAY;GAAW;GAC1B,UAAA,MAAM;EACH,CAAA;EAER,OAAO,UAAU,oBAAC,YAAD;GAAmB;GAAQ,UAAA,MAAM;EAAqB,CAAA;EACvE,KAAK,UACH,oBAAC,SAAD;GACE,IAAI,MAAM;GACV,OAAO,0BAA0B,GAAG,aAAa;GAC1C;GAEN,UAAA,MAAM;EACA,CAAA;EAEX,KAAK,UACH,oBAAC,SAAD;GACE,IAAI,MAAM;GACV,OAAO,0BAA0B,GAAG,a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IN,QAAQ,EAAE,MAAM,aAAa,GAAG,YAC9B,oBAAC,OAAD;GAAK,WAAWA,wBAAO;GACrB,UAAA,oBAAC,SAAD,EAAO,GAAI,MAAQ,CAAA;EAChB,CAAA;EAEP,KAAK,EAAE,MAAM,aAAa,UAAU,GAAG,YACrC,oBAAC,MAAD;GAAI,GAAI;GACN,UAAA,oBAAC,uBAAD,EAAwB,SAAgC,CAAA;EACtD,CAAA;EAEN,KAAK,EAAE,MAAM,aAAa,UAAU,GAAG,YACrC,oBAAC,MAAD;GAAI,GAAI;GACN,UAAA,oBAAC,uBAAD,EAAwB,SAAgC,CAAA;EACtD,CAAA;EAIN,MAAM,EAAE,MAAM,aAAa,GAAG,YAC5B,aAAa,OAAO,oBAAC,OAAD,EAAK,GAAI,MAAQ,CAAA;EACvC,aAAa,UACX,oBAAC,mBAAD;GAA0B;GACxB,UAAA,oBAAC,cAAD,EAAA,UAAa,MAAM,SAAqB,CAAA;EACvB,CAAA;CAEvB,IACA;EAAC;EAAO;EAAe;CAAU,CACnC;CAEA,MAAM,cAAc,0BAA0B,QAAQ;CACtD,MAAM,mBAAmB,eAChB;EACL,GAAG;EACH,GAAG;CACL,IACA,CAAC,mBAAmB,gBAAgB,CACtC;CAEA,OACE,oBAAC,OAAD;EAAK,WAAW,KAAKA,wBAAO,UAAU,SAAS;EAAG,GAAI;EAAW;EAC/D,UAAA,oBAAC,eAAD;GACgB;GACG;GACG;GACL;GACf,eAAe,iBAAiB,CAAC,SAAS;GAC1C,qBAAqB;IAAE;IAAe,GAAG;GAAoB;GACnD;GACQ;GACJ;GACd,YAAY;GAEX,UAAA;EACY,CAAA;CACZ,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"Markdown.mjs","names":["styles"],"sources":["../../../../../../../src/components/Markdown/Markdown.tsx"],"sourcesContent":["import { CodeBlock } from \"@/components/CodeBlock\";\nimport { Heading } from \"@/components/Heading\";\nimport { InlineCode } from \"@/components/InlineCode\";\nimport { Link } from \"@/components/Link\";\nimport { Separator } from \"@/components/Separator\";\nimport { Text } from \"@/components/Text\";\nimport type { CSSProperties, FC, Ref } from \"react\";\nimport { Children, isValidElement, useId, useMemo } from \"react\";\nimport type { Components, Options } from \"react-markdown\";\nimport ReactMarkdown from \"react-markdown\";\nimport styles from \"./Markdown.module.scss\";\nimport { extractTextFromFirstChild } from \"@/lib/react/remote\";\nimport type { AlphaColor, PropsWithClassName } from \"@/lib/types/props\";\nimport clsx from \"clsx\";\nimport remarkGfm from \"remark-gfm\";\nimport { getHeadingLevelWithOffset } from \"@/components/Markdown/lib/getHeadingLevelWithOffset\";\nimport { isExternalHref } from \"@/components/Markdown/lib/isExternalHref\";\nimport type { CodeEditorLanguage } from \"@/components/CodeEditor/languages\";\nimport {\n SkeletonBlockText,\n SkeletonInlineContent,\n} from \"@/components/Markdown/components/SkeletonBlocks\";\nimport { useSkeletonMode } from \"@/components/SkeletonMode/skeletonModeContext\";\n\nexport interface MarkdownProps\n extends PropsWithClassName, Omit<Options, \"components\"> {\n /** The color schema of the markdown component. @default \"default\" */\n color?: \"default\" | AlphaColor;\n /** Shifts all heading levels by the given offset. @default 0 */\n headingOffset?: number;\n /** Whether images are left out of the rendered markdown. @default false */\n disableImages?: boolean;\n /** Allows overriding markdown element renderers from outside. */\n components?: Components;\n /** @internal */\n style?: CSSProperties;\n /** A ref to the elements root. */\n ref?: Ref<HTMLDivElement>;\n}\n\n/**\n * @flr-generate all\n * @flr-ignore-props components\n */\nexport const Markdown: FC<MarkdownProps> = (props) => {\n const {\n children,\n color = \"default\",\n className,\n headingOffset = 0,\n disableImages = false,\n components: customComponents,\n ref,\n allowElement,\n allowedElements,\n disallowedElements,\n rehypePlugins,\n remarkPlugins,\n remarkRehypeOptions,\n skipHtml,\n unwrapDisallowed,\n urlTransform,\n ...rest\n } = props;\n\n const isSkeleton = useSkeletonMode();\n /* Footnote ids are per document, so two instances on one page would share\n them and a back link would jump into the other one. */\n const clobberPrefix = `user-content-${useId().replace(/[^\\w-]/g, \"\")}-`;\n\n /* react-markdown uses the renderers as element types: new ones on every\n render would remount the whole tree. */\n const defaultComponents = useMemo<Components>(\n () => ({\n /* GFM footnotes link through `id` (the back link's target), `aria-label`\n and `aria-describedby`. */\n a: (props) => (\n <Link\n id={props.id}\n aria-label={props[\"aria-label\"]}\n aria-describedby={props[\"aria-describedby\"]}\n target={isExternalHref(props.href) ? \"_blank\" : undefined}\n color={color}\n href={props.href}\n >\n {props.children}\n </Link>\n ),\n p: (props) => (\n <Text elementType=\"p\" color={color}>\n {props.children}\n </Text>\n ),\n code: (props) => <InlineCode color={color}>{props.children}</InlineCode>,\n h1: (props) => (\n <Heading\n id={props.id}\n level={getHeadingLevelWithOffset(1, headingOffset)}\n color={color}\n >\n {props.children}\n </Heading>\n ),\n h2: (props) => (\n <Heading\n id={props.id}\n level={getHeadingLevelWithOffset(2, headingOffset)}\n color={color}\n >\n {props.children}\n </Heading>\n ),\n h3: (props) => (\n <Heading\n id={props.id}\n level={getHeadingLevelWithOffset(3, headingOffset)}\n color={color}\n >\n {props.children}\n </Heading>\n ),\n h4: (props) => (\n <Heading\n id={props.id}\n level={getHeadingLevelWithOffset(4, headingOffset)}\n color={color}\n >\n {props.children}\n </Heading>\n ),\n h5: (props) => (\n <Heading\n id={props.id}\n level={getHeadingLevelWithOffset(5, headingOffset)}\n color={color}\n >\n {props.children}\n </Heading>\n ),\n h6: (props) => (\n <Heading\n id={props.id}\n level={getHeadingLevelWithOffset(6, headingOffset)}\n color={color}\n >\n {props.children}\n </Heading>\n ),\n hr: () => <Separator />,\n pre: (props) => {\n const preElementContent = Children.toArray(props.children)[0];\n\n return (\n <CodeBlock\n copyable={false}\n language={\n isValidElement<{ className?: string }>(preElementContent) &&\n preElementContent.props.className\n ? (preElementContent.props.className.replace(\n \"language-\",\n \"\",\n ) as CodeEditorLanguage)\n : undefined\n }\n code={String(\n isValidElement<{ children: string }>(preElementContent)\n ? preElementContent.props.children\n : preElementContent,\n ).trim()}\n />\n );\n },\n ul: ({ node: ignoredNode, ...props }) => (\n <SkeletonBlockText color={color}>\n <ul {...props} />\n </SkeletonBlockText>\n ),\n ol: ({ node: ignoredNode, ...props }) => (\n <SkeletonBlockText color={color}>\n <ol {...props} />\n </SkeletonBlockText>\n ),\n li: ({ node: ignoredNode, children, ...props }) => (\n <li {...props}>\n <SkeletonInlineContent>{children}</SkeletonInlineContent>\n </li>\n ),\n /* A table cannot shrink below its content, so the box around it scrolls\n instead of the table overflowing the markdown. */\n table: ({ node: ignoredNode, ...props }) => (\n <div className={styles.tableContainer}>\n <table {...props} />\n </div>\n ),\n th: ({ node: ignoredNode, children, ...props }) => (\n <th {...props}>\n <SkeletonInlineContent>{children}</SkeletonInlineContent>\n </th>\n ),\n td: ({ node: ignoredNode, children, ...props }) => (\n <td {...props}>\n <SkeletonInlineContent>{children}</SkeletonInlineContent>\n </td>\n ),\n /* A text bar resets the mode for its content, so the image reads it\n from here. A skeleton issues no request. */\n img: ({ node: ignoredNode, ...props }) =>\n isSkeleton ? null : <img {...props} />,\n blockquote: (props) => (\n <SkeletonBlockText color={color}>\n <blockquote>{props.children}</blockquote>\n </SkeletonBlockText>\n ),\n }),\n [color, headingOffset, isSkeleton],\n );\n\n const textContent = extractTextFromFirstChild(children);\n const mergedComponents = useMemo<Components>(\n () => ({\n ...defaultComponents,\n ...customComponents,\n }),\n [defaultComponents, customComponents],\n );\n\n return (\n <div className={clsx(styles.markdown, className)} {...rest} ref={ref}>\n <ReactMarkdown\n allowElement={(element, index, parent) =>\n !(disableImages && element.tagName === \"img\") &&\n (allowElement?.(element, index, parent) ?? true)\n }\n allowedElements={allowedElements}\n disallowedElements={disallowedElements}\n rehypePlugins={rehypePlugins}\n remarkPlugins={remarkPlugins ?? [remarkGfm]}\n remarkRehypeOptions={{ clobberPrefix, ...remarkRehypeOptions }}\n skipHtml={skipHtml}\n unwrapDisallowed={unwrapDisallowed}\n urlTransform={urlTransform}\n components={mergedComponents}\n >\n {textContent}\n </ReactMarkdown>\n </div>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AA,oBAAC,uBAAD,EAAwB,SAAgC,CAAA;EACtD,CAAA;EAIN,MAAM,EAAE,MAAM,aAAa,GAAG,YAC5B,aAAa,OAAO,oBAAC,OAAD,EAAK,GAAI,MAAQ,CAAA;EACvC,aAAa,UACX,oBAAC,mBAAD;GAA0B;GACxB,UAAA,oBAAC,cAAD,EAAA,UAAa,MAAM,SAAqB,CAAA;EACvB,CAAA;CAEvB,IACA;EAAC;EAAO;EAAe;CAAU,CACnC;CAEA,MAAM,cAAc,0BAA0B,QAAQ;CACtD,MAAM,mBAAmB,eAChB;EACL,GAAG;EACH,GAAG;CACL,IACA,CAAC,mBAAmB,gBAAgB,CACtC;CAEA,OACE,oBAAC,OAAD;EAAK,WAAW,KAAKA,wBAAO,UAAU,SAAS;EAAG,GAAI;EAAW;EAC/D,UAAA,oBAAC,eAAD;GACE,eAAe,SAAS,OAAO,WAC7B,EAAE,iBAAiB,QAAQ,YAAY,WACtC,eAAe,SAAS,OAAO,MAAM,KAAK;GAE5B;GACG;GACL;GACf,eAAe,iBAAiB,CAAC,SAAS;GAC1C,qBAAqB;IAAE;IAAe,GAAG;GAAoB;GACnD;GACQ;GACJ;GACd,YAAY;GAEX,UAAA;EACY,CAAA;CACZ,CAAA;AAET"}
|
|
@@ -23,13 +23,14 @@ var toolbarActionsTunnel = {
|
|
|
23
23
|
};
|
|
24
24
|
/** @flr-generate all */
|
|
25
25
|
var MarkdownEditor = flowComponent("MarkdownEditor", (props) => {
|
|
26
|
-
const { isDisabled, isReadOnly, children, className, rows = 5, autoResizeMaxRows, headingOffset, markdownComponent: MarkdownComponent = Markdown, value, onChange, uploadFile, accept, ref, ...rest } = useControlledHostValueProps(props, "");
|
|
26
|
+
const { isDisabled, isReadOnly, children, className, rows = 5, autoResizeMaxRows, headingOffset, disableImages, markdownComponent: MarkdownComponent = Markdown, value, onChange, uploadFile, accept, ref, ...rest } = useControlledHostValueProps(props, "");
|
|
27
27
|
const inputRef = useObjectRef(ref);
|
|
28
28
|
const [mode, setMode] = useState("editor");
|
|
29
29
|
const toolbarActionsDisabled = isDisabled || mode === "preview";
|
|
30
30
|
const { dropProps, isDropTarget, uploadFiles } = useFileUpload({
|
|
31
31
|
accept,
|
|
32
32
|
uploadFile,
|
|
33
|
+
disableImages,
|
|
33
34
|
isDisabled: isDisabled || isReadOnly || mode === "preview",
|
|
34
35
|
value,
|
|
35
36
|
onChange,
|
|
@@ -95,6 +96,7 @@ var MarkdownEditor = flowComponent("MarkdownEditor", (props) => {
|
|
|
95
96
|
children,
|
|
96
97
|
mode === "preview" && /* @__PURE__ */ jsx(MarkdownComponent, {
|
|
97
98
|
headingOffset,
|
|
99
|
+
disableImages,
|
|
98
100
|
className: MarkdownEditor_module_default.markdown,
|
|
99
101
|
children: value
|
|
100
102
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownEditor.mjs","names":["DefaultMarkdown","styles"],"sources":["../../../../../../../src/components/MarkdownEditor/MarkdownEditor.tsx"],"sourcesContent":["import { type ComponentType, type KeyboardEventHandler, useState } from \"react\";\nimport styles from \"./MarkdownEditor.module.scss\";\nimport {\n Markdown as DefaultMarkdown,\n type MarkdownProps,\n} from \"@/components/Markdown\";\nimport { TextArea, type TextAreaProps } from \"@/components/TextArea\";\nimport { Toolbar } from \"@/components/MarkdownEditor/components/Toolbar\";\nimport clsx from \"clsx\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport {\n modifyValueByMarkdownSyntax,\n scrollToCursor,\n} from \"@/components/MarkdownEditor/lib/modifyValueByMarkdownSyntax\";\nimport {\n type InsertType,\n modifyValueByType,\n} from \"@/components/MarkdownEditor/lib/modifyValueByType\";\nimport type { MarkdownEditorUpload } from \"@/components/MarkdownEditor/lib/fileUpload\";\nimport { useFileUpload } from \"@/components/MarkdownEditor/lib/useFileUpload\";\nimport { useControlledHostValueProps } from \"@/lib/remote/useControlledHostValueProps\";\nimport {\n overlayTriggersTunneledTo,\n type PropsContext,\n PropsContextProvider,\n} from \"@/lib/propsContext\";\nimport {\n SkeletonModeReset,\n useSkeletonMode,\n} from \"@/components/SkeletonMode/skeletonModeContext\";\n\nexport type MarkdownEditorMode = \"editor\" | \"preview\";\n\nexport type { MarkdownEditorUpload };\n\nconst toolbarActionsTunnel = {\n id: \"toolbarActions\",\n component: \"MarkdownEditor\",\n} as const;\n\nexport interface MarkdownEditorProps\n extends
|
|
1
|
+
{"version":3,"file":"MarkdownEditor.mjs","names":["DefaultMarkdown","styles"],"sources":["../../../../../../../src/components/MarkdownEditor/MarkdownEditor.tsx"],"sourcesContent":["import { type ComponentType, type KeyboardEventHandler, useState } from \"react\";\nimport styles from \"./MarkdownEditor.module.scss\";\nimport {\n Markdown as DefaultMarkdown,\n type MarkdownProps,\n} from \"@/components/Markdown\";\nimport { TextArea, type TextAreaProps } from \"@/components/TextArea\";\nimport { Toolbar } from \"@/components/MarkdownEditor/components/Toolbar\";\nimport clsx from \"clsx\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport {\n modifyValueByMarkdownSyntax,\n scrollToCursor,\n} from \"@/components/MarkdownEditor/lib/modifyValueByMarkdownSyntax\";\nimport {\n type InsertType,\n modifyValueByType,\n} from \"@/components/MarkdownEditor/lib/modifyValueByType\";\nimport type { MarkdownEditorUpload } from \"@/components/MarkdownEditor/lib/fileUpload\";\nimport { useFileUpload } from \"@/components/MarkdownEditor/lib/useFileUpload\";\nimport { useControlledHostValueProps } from \"@/lib/remote/useControlledHostValueProps\";\nimport {\n overlayTriggersTunneledTo,\n type PropsContext,\n PropsContextProvider,\n} from \"@/lib/propsContext\";\nimport {\n SkeletonModeReset,\n useSkeletonMode,\n} from \"@/components/SkeletonMode/skeletonModeContext\";\n\nexport type MarkdownEditorMode = \"editor\" | \"preview\";\n\nexport type { MarkdownEditorUpload };\n\nconst toolbarActionsTunnel = {\n id: \"toolbarActions\",\n component: \"MarkdownEditor\",\n} as const;\n\nexport interface MarkdownEditorProps\n extends\n TextAreaProps,\n Pick<MarkdownProps, \"headingOffset\" | \"disableImages\"> {\n /**\n * Allows replacing the markdown preview renderer implementation. Defaults to\n * the internal `Markdown` component.\n */\n markdownComponent?: ComponentType<MarkdownProps>;\n /**\n * Uploads a file the user dropped onto the editor, pasted into it or picked\n * with its attachment button. A placeholder comment sits at the cursor while\n * the returned promise is pending: resolving replaces it with markdown\n * linking to the file — an image embed for an image — and rejecting takes it\n * back out. Without this prop the editor takes no files at all.\n *\n * Named without an `on` prefix on purpose: the remote generator turns an\n * `on*` prop into a fire-and-forget event, and this one has to hand a result\n * back.\n */\n uploadFile?: (file: File) => Promise<MarkdownEditorUpload>;\n /**\n * Which file types the editor takes, as the `accept` attribute of a file\n * input: a comma separated list of MIME types (`image/png`), MIME wildcards\n * (`image/*`) and file extensions (`.png`). Defaults to every type.\n */\n accept?: string;\n}\n\n/** @flr-generate all */\nexport const MarkdownEditor = flowComponent(\"MarkdownEditor\", (props) => {\n const {\n isDisabled,\n isReadOnly,\n children,\n className,\n rows = 5,\n autoResizeMaxRows,\n headingOffset,\n disableImages,\n markdownComponent: MarkdownComponent = DefaultMarkdown,\n value,\n onChange,\n uploadFile,\n accept,\n ref,\n ...rest\n } = useControlledHostValueProps(props, \"\");\n\n const inputRef = useObjectRef(ref);\n const [mode, setMode] = useState<MarkdownEditorMode>(\"editor\");\n const toolbarActionsDisabled = isDisabled || mode === \"preview\";\n\n const { dropProps, isDropTarget, uploadFiles } = useFileUpload({\n accept,\n uploadFile,\n disableImages,\n isDisabled: isDisabled || isReadOnly || mode === \"preview\",\n value,\n onChange,\n textAreaRef: inputRef,\n });\n\n const isSkeleton = useSkeletonMode();\n\n const rootClassName = clsx(\n styles.markdownEditor,\n styles[`mode-${mode}`],\n isDropTarget && styles.dropTarget,\n isSkeleton && styles.skeleton,\n className,\n );\n\n const toolbarActionsPropsContext: PropsContext = {\n ...overlayTriggersTunneledTo(toolbarActionsTunnel),\n Button: {\n tunnel: toolbarActionsTunnel,\n size: \"s\",\n variant: \"plain\",\n color: \"dark\",\n isDisabled: toolbarActionsDisabled,\n },\n };\n\n const handleKeyDown: KeyboardEventHandler = (event) => {\n if (event.key !== \"Enter\") {\n return;\n }\n\n const modifyParams = modifyValueByMarkdownSyntax(value, inputRef);\n if (!modifyParams) {\n return;\n }\n\n const { newValue, newSelectionStart, newSelectionEnd } = modifyParams;\n\n requestAnimationFrame(() => {\n if (inputRef.current) {\n inputRef.current.value = newValue;\n inputRef.current?.setSelectionRange(newSelectionStart, newSelectionEnd);\n scrollToCursor(newValue, inputRef.current);\n }\n });\n\n event.preventDefault();\n onChange(newValue);\n };\n\n const handleToolButtonPressed = (type: InsertType) => {\n const { newValue, newSelectionStart, newSelectionEnd } = modifyValueByType(\n value,\n type,\n inputRef,\n );\n\n requestAnimationFrame(() => {\n if (inputRef.current) {\n inputRef.current.value = newValue;\n inputRef.current.setSelectionRange(newSelectionStart, newSelectionEnd);\n inputRef.current.focus();\n }\n });\n\n onChange(newValue);\n };\n\n return (\n <div\n {...dropProps}\n className={rootClassName}\n inert={isSkeleton || undefined}\n >\n <TextArea\n {...rest}\n aria-hidden={mode === \"preview\"}\n isReadOnly={isReadOnly || mode === \"preview\"}\n isDisabled={isDisabled}\n ref={inputRef}\n value={value}\n rows={rows}\n autoResizeMaxRows={autoResizeMaxRows}\n onChange={onChange}\n onKeyDown={handleKeyDown}\n >\n <PropsContextProvider\n props={toolbarActionsPropsContext}\n dependencies={[toolbarActionsDisabled]}\n >\n {children}\n {mode === \"preview\" && (\n <MarkdownComponent\n headingOffset={headingOffset}\n disableImages={disableImages}\n className={styles.markdown}\n >\n {value}\n </MarkdownComponent>\n )}\n {/* Covered by the skeleton surface, so its buttons draw none. */}\n <SkeletonModeReset>\n <Toolbar\n currentMode={mode}\n isDisabled={isDisabled}\n onModeChange={setMode}\n onToolPressed={handleToolButtonPressed}\n accept={accept}\n isReadOnly={isReadOnly}\n onFilesSelected={uploadFiles}\n />\n </SkeletonModeReset>\n </PropsContextProvider>\n </TextArea>\n {/* One surface over toolbar and text area. The label and the field\n description keep their own skeleton rule. */}\n {isSkeleton && <div className={styles.skeletonSurface} />}\n </div>\n );\n});\n\nexport default MarkdownEditor;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoCA,IAAM,uBAAuB;CAC3B,IAAI;CACJ,WAAW;AACb;;AAgCA,IAAa,iBAAiB,cAAc,mBAAmB,UAAU;CACvE,MAAM,EACJ,YACA,YACA,UACA,WACA,OAAO,GACP,mBACA,eACA,eACA,mBAAmB,oBAAoBA,UACvC,OACA,UACA,YACA,QACA,KACA,GAAG,SACD,4BAA4B,OAAO,EAAE;CAEzC,MAAM,WAAW,aAAa,GAAG;CACjC,MAAM,CAAC,MAAM,WAAW,SAA6B,QAAQ;CAC7D,MAAM,yBAAyB,cAAc,SAAS;CAEtD,MAAM,EAAE,WAAW,cAAc,gBAAgB,cAAc;EAC7D;EACA;EACA;EACA,YAAY,cAAc,cAAc,SAAS;EACjD;EACA;EACA,aAAa;CACf,CAAC;CAED,MAAM,aAAa,gBAAgB;CAEnC,MAAM,gBAAgB,KACpBC,8BAAO,gBACPA,8BAAO,QAAQ,SACf,gBAAgBA,8BAAO,YACvB,cAAcA,8BAAO,UACrB,SACF;CAEA,MAAM,6BAA2C;EAC/C,GAAG,0BAA0B,oBAAoB;EACjD,QAAQ;GACN,QAAQ;GACR,MAAM;GACN,SAAS;GACT,OAAO;GACP,YAAY;EACd;CACF;CAEA,MAAM,iBAAuC,UAAU;EACrD,IAAI,MAAM,QAAQ,SAChB;EAGF,MAAM,eAAe,4BAA4B,OAAO,QAAQ;EAChE,IAAI,CAAC,cACH;EAGF,MAAM,EAAE,UAAU,mBAAmB,oBAAoB;EAEzD,4BAA4B;GAC1B,IAAI,SAAS,SAAS;IACpB,SAAS,QAAQ,QAAQ;IACzB,SAAS,SAAS,kBAAkB,mBAAmB,eAAe;IACtE,eAAe,UAAU,SAAS,OAAO;GAC3C;EACF,CAAC;EAED,MAAM,eAAe;EACrB,SAAS,QAAQ;CACnB;CAEA,MAAM,2BAA2B,SAAqB;EACpD,MAAM,EAAE,UAAU,mBAAmB,oBAAoB,kBACvD,OACA,MACA,QACF;EAEA,4BAA4B;GAC1B,IAAI,SAAS,SAAS;IACpB,SAAS,QAAQ,QAAQ;IACzB,SAAS,QAAQ,kBAAkB,mBAAmB,eAAe;IACrE,SAAS,QAAQ,MAAM;GACzB;EACF,CAAC;EAED,SAAS,QAAQ;CACnB;CAEA,OACE,qBAAC,OAAD;EACE,GAAI;EACJ,WAAW;EACX,OAAO,cAAc,KAAA;EAHvB,UAAA,CAKE,oBAAC,UAAD;GACE,GAAI;GACJ,eAAa,SAAS;GACtB,YAAY,cAAc,SAAS;GACvB;GACZ,KAAK;GACE;GACD;GACa;GACT;GACV,WAAW;GAEX,UAAA,qBAAC,sBAAD;IACE,OAAO;IACP,cAAc,CAAC,sBAAsB;IAFvC,UAAA;KAIG;KACA,SAAS,aACR,oBAAC,mBAAD;MACiB;MACA;MACf,WAAWA,8BAAO;MAEjB,UAAA;KACgB,CAAA;KAGrB,oBAAC,mBAAD,EAAA,UACE,oBAAC,SAAD;MACE,aAAa;MACD;MACZ,cAAc;MACd,eAAe;MACP;MACI;MACZ,iBAAiB;KAClB,CAAA,EACgB,CAAA;IACC;;EACd,CAAA,GAGT,cAAc,oBAAC,OAAD,EAAK,WAAWA,8BAAO,gBAAkB,CAAA,CACrD;;AAET,CAAC"}
|
|
@@ -18,9 +18,9 @@ var uploadPlaceholder = (fileName) => `<!-- Uploading "${escapeComment(fileName)
|
|
|
18
18
|
*
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
|
-
var uploadedFileMarkdown = (file, upload) => {
|
|
21
|
+
var uploadedFileMarkdown = (file, upload, disableImages = false) => {
|
|
22
22
|
const link = `[${escapeLinkLabel(upload.name ?? file.name)}](${escapeLinkTarget(upload.url)})`;
|
|
23
|
-
return file.type.startsWith("image/") ? `!${link}` : link;
|
|
23
|
+
return file.type.startsWith("image/") && !disableImages ? `!${link}` : link;
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
26
|
* Splices `insert` into `value` at `caret`, on a line of its own, and reports
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileUpload.mjs","names":[],"sources":["../../../../../../../../src/components/MarkdownEditor/lib/fileUpload.ts"],"sourcesContent":["/**\n * The result of uploading a file dropped into, pasted into or selected in a\n * `MarkdownEditor`.\n */\nexport interface MarkdownEditorUpload {\n /** The URL the uploaded file is available at. */\n url: string;\n /**\n * The link text of the inserted markdown — the alt text for an image.\n * Defaults to the name of the uploaded file.\n */\n name?: string;\n}\n\n/** A new editor value together with where the cursor ends up in it. */\nexport interface ValueEdit {\n value: string;\n selectionStart: number;\n selectionEnd: number;\n}\n\n/*\n * A file name that closes the comment early would leave the rest of it as\n * visible text. Every way to close one starts with `--`: `-->` does, `--!>`\n * does too, and dropping only `-->` can forge a new one — `a-->>b` collapses to\n * `a-->b`. Breaking up every `--` is what holds in all three.\n */\nconst escapeComment = (fileName: string) => fileName.replace(/-(?=-)/g, \"- \");\n\n/*\n * Brackets are what ends a markdown link label, and a line break ends the link\n * altogether. A file name may legally contain both.\n *\n * The backslash is escaped in the same pass, and has to be: escaping only the\n * brackets turns `a\\]b` into `a\\\\]b`, which markdown reads as an escaped\n * backslash followed by a bare `]` — the label ends right there.\n */\nconst escapeLinkLabel = (label: string) =>\n label\n .replace(/[\\\\[\\]]/g, \"\\\\$&\")\n .replace(/\\s+/g, \" \")\n .trim();\n\n/*\n * A bare link target ends at the first whitespace or unbalanced parenthesis.\n * Pointy brackets take a target that contains either — and are themselves the\n * only thing that cannot appear inside them.\n */\nconst escapeLinkTarget = (url: string) =>\n /[\\s()]/.test(url) ? `<${url.replace(/[<>]/g, encodeURIComponent)}>` : url;\n\n/**\n * What sits at the cursor while a file uploads. An HTML comment, so it stays\n * out of the rendered preview and out of a message sent before the upload\n * finished — the same marker GitHub leaves behind.\n *\n * @internal\n */\nexport const uploadPlaceholder = (fileName: string): string =>\n `<!-- Uploading \"${escapeComment(fileName)}\"... -->`;\n\n/**\n * The markdown a finished upload leaves behind: an embed for an image, a link\n * for everything else.\n *\n * @internal\n */\nexport const uploadedFileMarkdown = (\n file: Pick<File, \"name\" | \"type\">,\n upload: MarkdownEditorUpload,\n): string => {\n const label = escapeLinkLabel(upload.name ?? file.name);\n const target = escapeLinkTarget(upload.url);\n const link = `[${label}](${target})`;\n\n return file.type.startsWith(\"image/\") ? `!${link}` : link;\n};\n\n/**\n * Splices `insert` into `value` at `caret`, on a line of its own, and reports\n * where the cursor ends up.\n *\n * @internal\n */\nexport const insertAtCaret = (\n value: string,\n insert: string,\n caret: number,\n): ValueEdit => {\n const before = value.slice(0, caret);\n const after = value.slice(caret);\n\n const prefix = before.length > 0 && !before.endsWith(\"\\n\") ? \"\\n\" : \"\";\n const suffix = after.startsWith(\"\\n\") ? \"\" : \"\\n\";\n const inserted = `${prefix}${insert}${suffix}`;\n\n return {\n value: `${before}${inserted}${after}`,\n selectionStart: caret + inserted.length,\n selectionEnd: caret + inserted.length,\n };\n};\n\n/**\n * Replaces the first occurrence of `search`, carrying the cursor along. Returns\n * `null` when the editor no longer contains it — the user deleted the\n * placeholder while the upload was running, and the result is dropped.\n *\n * @internal\n */\nexport const replacePlaceholder = (\n value: string,\n search: string,\n replacement: string,\n selectionStart: number,\n selectionEnd: number,\n): ValueEdit | null => {\n const index = value.indexOf(search);\n\n if (index === -1) {\n return null;\n }\n\n const end = index + search.length;\n const delta = replacement.length - search.length;\n\n /*\n * A cursor before the placeholder does not move, one after it moves by the\n * length difference, and one inside it — the user was typing where the file\n * landed — comes to rest behind the replacement.\n */\n const shift = (position: number) => {\n if (position <= index) {\n return position;\n }\n return position >= end ? position + delta : index + replacement.length;\n };\n\n return {\n value: value.slice(0, index) + replacement + value.slice(end),\n selectionStart: shift(selectionStart),\n selectionEnd: shift(selectionEnd),\n };\n};\n\n/**\n * Takes a placeholder back out after a failed upload, including the line break\n * it was inserted with.\n *\n * @internal\n */\nexport const removePlaceholder = (\n value: string,\n placeholder: string,\n selectionStart: number,\n selectionEnd: number,\n): ValueEdit | null =>\n replacePlaceholder(\n value,\n `${placeholder}\\n`,\n \"\",\n selectionStart,\n selectionEnd,\n ) ?? replacePlaceholder(value, placeholder, \"\", selectionStart, selectionEnd);\n"],"mappings":";;;AA2BA,IAAM,iBAAiB,aAAqB,SAAS,QAAQ,WAAW,IAAI;AAU5E,IAAM,mBAAmB,UACvB,MACG,QAAQ,YAAY,MAAM,CAAC,CAC3B,QAAQ,QAAQ,GAAG,CAAC,CACpB,KAAK;AAOV,IAAM,oBAAoB,QACxB,SAAS,KAAK,GAAG,IAAI,IAAI,IAAI,QAAQ,SAAS,kBAAkB,EAAE,KAAK;;;;;;;;AASzE,IAAa,qBAAqB,aAChC,mBAAmB,cAAc,QAAQ,EAAE;;;;;;;AAQ7C,IAAa,wBACX,MACA,
|
|
1
|
+
{"version":3,"file":"fileUpload.mjs","names":[],"sources":["../../../../../../../../src/components/MarkdownEditor/lib/fileUpload.ts"],"sourcesContent":["/**\n * The result of uploading a file dropped into, pasted into or selected in a\n * `MarkdownEditor`.\n */\nexport interface MarkdownEditorUpload {\n /** The URL the uploaded file is available at. */\n url: string;\n /**\n * The link text of the inserted markdown — the alt text for an image.\n * Defaults to the name of the uploaded file.\n */\n name?: string;\n}\n\n/** A new editor value together with where the cursor ends up in it. */\nexport interface ValueEdit {\n value: string;\n selectionStart: number;\n selectionEnd: number;\n}\n\n/*\n * A file name that closes the comment early would leave the rest of it as\n * visible text. Every way to close one starts with `--`: `-->` does, `--!>`\n * does too, and dropping only `-->` can forge a new one — `a-->>b` collapses to\n * `a-->b`. Breaking up every `--` is what holds in all three.\n */\nconst escapeComment = (fileName: string) => fileName.replace(/-(?=-)/g, \"- \");\n\n/*\n * Brackets are what ends a markdown link label, and a line break ends the link\n * altogether. A file name may legally contain both.\n *\n * The backslash is escaped in the same pass, and has to be: escaping only the\n * brackets turns `a\\]b` into `a\\\\]b`, which markdown reads as an escaped\n * backslash followed by a bare `]` — the label ends right there.\n */\nconst escapeLinkLabel = (label: string) =>\n label\n .replace(/[\\\\[\\]]/g, \"\\\\$&\")\n .replace(/\\s+/g, \" \")\n .trim();\n\n/*\n * A bare link target ends at the first whitespace or unbalanced parenthesis.\n * Pointy brackets take a target that contains either — and are themselves the\n * only thing that cannot appear inside them.\n */\nconst escapeLinkTarget = (url: string) =>\n /[\\s()]/.test(url) ? `<${url.replace(/[<>]/g, encodeURIComponent)}>` : url;\n\n/**\n * What sits at the cursor while a file uploads. An HTML comment, so it stays\n * out of the rendered preview and out of a message sent before the upload\n * finished — the same marker GitHub leaves behind.\n *\n * @internal\n */\nexport const uploadPlaceholder = (fileName: string): string =>\n `<!-- Uploading \"${escapeComment(fileName)}\"... -->`;\n\n/**\n * The markdown a finished upload leaves behind: an embed for an image, a link\n * for everything else.\n *\n * @internal\n */\nexport const uploadedFileMarkdown = (\n file: Pick<File, \"name\" | \"type\">,\n upload: MarkdownEditorUpload,\n disableImages = false,\n): string => {\n const label = escapeLinkLabel(upload.name ?? file.name);\n const target = escapeLinkTarget(upload.url);\n const link = `[${label}](${target})`;\n\n return file.type.startsWith(\"image/\") && !disableImages ? `!${link}` : link;\n};\n\n/**\n * Splices `insert` into `value` at `caret`, on a line of its own, and reports\n * where the cursor ends up.\n *\n * @internal\n */\nexport const insertAtCaret = (\n value: string,\n insert: string,\n caret: number,\n): ValueEdit => {\n const before = value.slice(0, caret);\n const after = value.slice(caret);\n\n const prefix = before.length > 0 && !before.endsWith(\"\\n\") ? \"\\n\" : \"\";\n const suffix = after.startsWith(\"\\n\") ? \"\" : \"\\n\";\n const inserted = `${prefix}${insert}${suffix}`;\n\n return {\n value: `${before}${inserted}${after}`,\n selectionStart: caret + inserted.length,\n selectionEnd: caret + inserted.length,\n };\n};\n\n/**\n * Replaces the first occurrence of `search`, carrying the cursor along. Returns\n * `null` when the editor no longer contains it — the user deleted the\n * placeholder while the upload was running, and the result is dropped.\n *\n * @internal\n */\nexport const replacePlaceholder = (\n value: string,\n search: string,\n replacement: string,\n selectionStart: number,\n selectionEnd: number,\n): ValueEdit | null => {\n const index = value.indexOf(search);\n\n if (index === -1) {\n return null;\n }\n\n const end = index + search.length;\n const delta = replacement.length - search.length;\n\n /*\n * A cursor before the placeholder does not move, one after it moves by the\n * length difference, and one inside it — the user was typing where the file\n * landed — comes to rest behind the replacement.\n */\n const shift = (position: number) => {\n if (position <= index) {\n return position;\n }\n return position >= end ? position + delta : index + replacement.length;\n };\n\n return {\n value: value.slice(0, index) + replacement + value.slice(end),\n selectionStart: shift(selectionStart),\n selectionEnd: shift(selectionEnd),\n };\n};\n\n/**\n * Takes a placeholder back out after a failed upload, including the line break\n * it was inserted with.\n *\n * @internal\n */\nexport const removePlaceholder = (\n value: string,\n placeholder: string,\n selectionStart: number,\n selectionEnd: number,\n): ValueEdit | null =>\n replacePlaceholder(\n value,\n `${placeholder}\\n`,\n \"\",\n selectionStart,\n selectionEnd,\n ) ?? replacePlaceholder(value, placeholder, \"\", selectionStart, selectionEnd);\n"],"mappings":";;;AA2BA,IAAM,iBAAiB,aAAqB,SAAS,QAAQ,WAAW,IAAI;AAU5E,IAAM,mBAAmB,UACvB,MACG,QAAQ,YAAY,MAAM,CAAC,CAC3B,QAAQ,QAAQ,GAAG,CAAC,CACpB,KAAK;AAOV,IAAM,oBAAoB,QACxB,SAAS,KAAK,GAAG,IAAI,IAAI,IAAI,QAAQ,SAAS,kBAAkB,EAAE,KAAK;;;;;;;;AASzE,IAAa,qBAAqB,aAChC,mBAAmB,cAAc,QAAQ,EAAE;;;;;;;AAQ7C,IAAa,wBACX,MACA,QACA,gBAAgB,UACL;CAGX,MAAM,OAAO,IAFC,gBAAgB,OAAO,QAAQ,KAAK,IAEjC,EAAM,IADR,iBAAiB,OAAO,GACZ,EAAO;CAElC,OAAO,KAAK,KAAK,WAAW,QAAQ,KAAK,CAAC,gBAAgB,IAAI,SAAS;AACzE;;;;;;;AAQA,IAAa,iBACX,OACA,QACA,UACc;CACd,MAAM,SAAS,MAAM,MAAM,GAAG,KAAK;CACnC,MAAM,QAAQ,MAAM,MAAM,KAAK;CAI/B,MAAM,WAAW,GAFF,OAAO,SAAS,KAAK,CAAC,OAAO,SAAS,IAAI,IAAI,OAAO,KAEvC,SADd,MAAM,WAAW,IAAI,IAAI,KAAK;CAG7C,OAAO;EACL,OAAO,GAAG,SAAS,WAAW;EAC9B,gBAAgB,QAAQ,SAAS;EACjC,cAAc,QAAQ,SAAS;CACjC;AACF;;;;;;;;AASA,IAAa,sBACX,OACA,QACA,aACA,gBACA,iBACqB;CACrB,MAAM,QAAQ,MAAM,QAAQ,MAAM;CAElC,IAAI,UAAU,IACZ,OAAO;CAGT,MAAM,MAAM,QAAQ,OAAO;CAC3B,MAAM,QAAQ,YAAY,SAAS,OAAO;CAO1C,MAAM,SAAS,aAAqB;EAClC,IAAI,YAAY,OACd,OAAO;EAET,OAAO,YAAY,MAAM,WAAW,QAAQ,QAAQ,YAAY;CAClE;CAEA,OAAO;EACL,OAAO,MAAM,MAAM,GAAG,KAAK,IAAI,cAAc,MAAM,MAAM,GAAG;EAC5D,gBAAgB,MAAM,cAAc;EACpC,cAAc,MAAM,YAAY;CAClC;AACF;;;;;;;AAQA,IAAa,qBACX,OACA,aACA,gBACA,iBAEA,mBACE,OACA,GAAG,YAAY,KACf,IACA,gBACA,YACF,KAAK,mBAAmB,OAAO,aAAa,IAAI,gBAAgB,YAAY"}
|
|
@@ -17,7 +17,7 @@ var acceptedFrom = (files, accept) => Array.from(files ?? []).filter((file) => m
|
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
19
|
var useFileUpload = (options) => {
|
|
20
|
-
const { accept, uploadFile, isDisabled, value, onChange, textAreaRef } = options;
|
|
20
|
+
const { accept, uploadFile, disableImages, isDisabled, value, onChange, textAreaRef } = options;
|
|
21
21
|
const stringFormatter = useLocalizedStringFormatter(__locale_default, "MarkdownEditor");
|
|
22
22
|
const isEnabled = !!uploadFile && !isDisabled;
|
|
23
23
|
const valueRef = useRef(value);
|
|
@@ -59,7 +59,7 @@ var useFileUpload = (options) => {
|
|
|
59
59
|
try {
|
|
60
60
|
const result = await upload(file);
|
|
61
61
|
const selection = readSelection();
|
|
62
|
-
const edit = replacePlaceholder(readValue(), placeholder, uploadedFileMarkdown(file, result), selection.start, selection.end);
|
|
62
|
+
const edit = replacePlaceholder(readValue(), placeholder, uploadedFileMarkdown(file, result, disableImages), selection.start, selection.end);
|
|
63
63
|
if (edit) applyEdit(edit);
|
|
64
64
|
announce(stringFormatter.format("upload.succeeded", { name: file.name }), "polite");
|
|
65
65
|
} catch {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFileUpload.mjs","names":["locales"],"sources":["../../../../../../../../src/components/MarkdownEditor/lib/useFileUpload.ts"],"sourcesContent":["import {\n type DragEvent as ReactDragEvent,\n type DragEventHandler,\n type RefObject,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { announce } from \"@react-aria/live-announcer\";\nimport { matchesAccept } from \"@/lib/files/acceptedFiles\";\nimport {\n insertAtCaret,\n type MarkdownEditorUpload,\n removePlaceholder,\n replacePlaceholder,\n uploadedFileMarkdown,\n uploadPlaceholder,\n type ValueEdit,\n} from \"@/components/MarkdownEditor/lib/fileUpload\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\nimport locales from \"../locales/*.locale.json\";\n\n/** The files of a paste or a drop that `accept` covers. */\nconst acceptedFrom = (files: FileList | null | undefined, accept?: string) =>\n Array.from(files ?? []).filter((file) => matchesAccept(file, accept));\n\n/** @internal */\nexport type MarkdownEditorFileUploadHandler = (\n file: File,\n) => Promise<MarkdownEditorUpload>;\n\ninterface Options {\n /** Which file types to take, as an `accept` attribute value. */\n accept?: string;\n /** Uploads one file. Uploading is off entirely while this is undefined. */\n uploadFile?: MarkdownEditorFileUploadHandler;\n /** Turns dropping, pasting and the toolbar button off. */\n isDisabled?: boolean;\n value: string;\n onChange: (value: string) => void;\n textAreaRef: RefObject<HTMLTextAreaElement | null>;\n}\n\ninterface DropProps {\n onDragEnter?: DragEventHandler;\n onDragOver?: DragEventHandler;\n onDragLeave?: DragEventHandler;\n onDrop?: DragEventHandler;\n}\n\ninterface FileUpload {\n /** Drop handling for the editor's root element. */\n dropProps: DropProps;\n /** Whether a drag is currently over the editor. */\n isDropTarget: boolean;\n /**\n * Uploads the files the toolbar button picked. `undefined` while uploading is\n * off.\n */\n uploadFiles?: (files: File[]) => void;\n}\n\n/**\n * Drop, paste and toolbar uploads for the `MarkdownEditor`: a placeholder\n * comment goes to the cursor right away and is replaced by a markdown link once\n * the consumer's upload resolves.\n *\n * @internal\n */\nexport const useFileUpload = (options: Options): FileUpload => {\n const { accept, uploadFile, isDisabled, value, onChange, textAreaRef } =\n options;\n\n const stringFormatter = useLocalizedStringFormatter(\n locales,\n \"MarkdownEditor\",\n );\n\n const isEnabled = !!uploadFile && !isDisabled;\n\n /*\n * An upload resolves long after the drop, and the editor has kept taking\n * input in the meantime. The textarea's own value is the only one that is\n * current by then — the `value` prop is a render old whenever two uploads\n * resolve in the same tick.\n */\n const valueRef = useRef(value);\n useEffect(() => {\n valueRef.current = value;\n }, [value]);\n\n const readValue = () => textAreaRef.current?.value ?? valueRef.current;\n\n /*\n * A textarea keeps its `selectionStart` after losing focus, so the caret is\n * still readable once the attachment button has taken the focus away. What it\n * cannot tell apart is a caret at position 0 from one that was never placed —\n * both read 0, and appending is the better answer for the second.\n */\n const wasFocusedRef = useRef(false);\n useEffect(() => {\n const textArea = textAreaRef.current;\n\n if (!textArea) {\n return;\n }\n\n const rememberFocus = () => {\n wasFocusedRef.current = true;\n };\n\n textArea.addEventListener(\"focus\", rememberFocus);\n return () => textArea.removeEventListener(\"focus\", rememberFocus);\n }, [textAreaRef]);\n\n const readSelection = () => {\n const textArea = textAreaRef.current;\n const fallback = readValue().length;\n return {\n start: textArea?.selectionStart ?? fallback,\n end: textArea?.selectionEnd ?? fallback,\n };\n };\n\n const applyEdit = (edit: ValueEdit) => {\n valueRef.current = edit.value;\n\n const textArea = textAreaRef.current;\n if (textArea) {\n /*\n * Written before the re-render so an upload resolving in the same tick\n * reads this one's result, and the selection restored after it, once\n * React has rendered the controlled value.\n */\n textArea.value = edit.value;\n requestAnimationFrame(() => {\n textArea.setSelectionRange(edit.selectionStart, edit.selectionEnd);\n });\n }\n\n onChange(edit.value);\n };\n\n const runUpload = async (\n upload: MarkdownEditorFileUploadHandler,\n file: File,\n placeholder: string,\n ) => {\n announce(\n stringFormatter.format(\"upload.pending\", { name: file.name }),\n \"polite\",\n );\n\n try {\n const result = await upload(file);\n const selection = readSelection();\n const edit = replacePlaceholder(\n readValue(),\n placeholder,\n uploadedFileMarkdown(file, result),\n selection.start,\n selection.end,\n );\n\n if (edit) {\n applyEdit(edit);\n }\n\n announce(\n stringFormatter.format(\"upload.succeeded\", { name: file.name }),\n \"polite\",\n );\n } catch {\n const selection = readSelection();\n const edit = removePlaceholder(\n readValue(),\n placeholder,\n selection.start,\n selection.end,\n );\n\n if (edit) {\n applyEdit(edit);\n }\n\n announce(\n stringFormatter.format(\"upload.failed\", { name: file.name }),\n \"assertive\",\n );\n }\n };\n\n const uploadFiles = (files: File[]) => {\n if (!uploadFile || files.length === 0) {\n return;\n }\n\n const textArea = textAreaRef.current;\n const caret =\n textArea && wasFocusedRef.current\n ? textArea.selectionStart\n : readValue().length;\n\n const uploads = files.map((file) => ({\n file,\n placeholder: uploadPlaceholder(file.name),\n }));\n\n applyEdit(\n insertAtCaret(\n readValue(),\n uploads.map((upload) => upload.placeholder).join(\"\\n\"),\n caret,\n ),\n );\n textArea?.focus();\n\n for (const upload of uploads) {\n void runUpload(uploadFile, upload.file, upload.placeholder);\n }\n };\n\n const uploadFilesRef = useRef(uploadFiles);\n uploadFilesRef.current = uploadFiles;\n\n /*\n * The paste listener is attached imperatively rather than through react-aria's\n * `useClipboard`, which calls `preventDefault` on every paste it sees and\n * would take plain text pasting with it.\n */\n useEffect(() => {\n const textArea = textAreaRef.current;\n\n if (!textArea || !isEnabled) {\n return;\n }\n\n const handlePaste = (event: ClipboardEvent) => {\n const files = acceptedFrom(event.clipboardData?.files, accept);\n\n if (files.length === 0) {\n return;\n }\n\n event.preventDefault();\n uploadFilesRef.current(files);\n };\n\n textArea.addEventListener(\"paste\", handlePaste);\n return () => textArea.removeEventListener(\"paste\", handlePaste);\n }, [isEnabled, accept, textAreaRef]);\n\n /*\n * Native handlers rather than react-aria's `useDrop`: that one claims every\n * drag it sees — its `onDrop` calls `preventDefault` and `stopPropagation`\n * unconditionally — which is right for a dedicated drop surface like\n * `FileDropZone`, but here it would swallow a plain text drag into the\n * textarea. A drag is claimed only when it carries files, and\n * `dataTransfer.types` is the only place that says so: the public\n * `DragTypes` of `getDropOperation` offers just `has(type)`, which cannot\n * express it — the wildcard type is always true, and WebKit reports every\n * file drag as an unknown type that answers true to anything.\n */\n const dragHasFiles = (event: ReactDragEvent) =>\n event.dataTransfer.types.includes(\"Files\");\n\n /*\n * `dragenter` and `dragleave` fire again for every child the pointer\n * crosses, so the highlight follows their balance rather than the last one.\n */\n const dragDepth = useRef(0);\n const [isDropTarget, setIsDropTarget] = useState(false);\n\n const endDrag = () => {\n dragDepth.current = 0;\n setIsDropTarget(false);\n };\n\n const dropProps: DropProps = isEnabled\n ? {\n onDragEnter: (event) => {\n if (!dragHasFiles(event)) {\n return;\n }\n event.preventDefault();\n dragDepth.current += 1;\n setIsDropTarget(true);\n },\n onDragOver: (event) => {\n if (!dragHasFiles(event)) {\n return;\n }\n // Without this the browser refuses the drop and opens the file instead.\n event.preventDefault();\n event.dataTransfer.dropEffect = \"copy\";\n },\n onDragLeave: (event) => {\n if (!dragHasFiles(event)) {\n return;\n }\n dragDepth.current = Math.max(0, dragDepth.current - 1);\n if (dragDepth.current === 0) {\n setIsDropTarget(false);\n }\n },\n onDrop: (event) => {\n if (!dragHasFiles(event)) {\n return;\n }\n event.preventDefault();\n endDrag();\n uploadFilesRef.current(\n acceptedFrom(event.dataTransfer.files, accept),\n );\n },\n }\n : {};\n\n return {\n dropProps,\n isDropTarget,\n uploadFiles: uploadFile ? uploadFiles : undefined,\n };\n};\n"],"mappings":";;;;;;;;;;AAuBA,IAAM,gBAAgB,OAAoC,WACxD,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,SAAS,cAAc,MAAM,MAAM,CAAC;;;;;;;;AA6CtE,IAAa,iBAAiB,YAAiC;CAC7D,MAAM,EAAE,QAAQ,YAAY,YAAY,OAAO,UAAU,gBACvD;CAEF,MAAM,kBAAkB,4BACtBA,kBACA,gBACF;CAEA,MAAM,YAAY,CAAC,CAAC,cAAc,CAAC;CAQnC,MAAM,WAAW,OAAO,KAAK;CAC7B,gBAAgB;EACd,SAAS,UAAU;CACrB,GAAG,CAAC,KAAK,CAAC;CAEV,MAAM,kBAAkB,YAAY,SAAS,SAAS,SAAS;CAQ/D,MAAM,gBAAgB,OAAO,KAAK;CAClC,gBAAgB;EACd,MAAM,WAAW,YAAY;EAE7B,IAAI,CAAC,UACH;EAGF,MAAM,sBAAsB;GAC1B,cAAc,UAAU;EAC1B;EAEA,SAAS,iBAAiB,SAAS,aAAa;EAChD,aAAa,SAAS,oBAAoB,SAAS,aAAa;CAClE,GAAG,CAAC,WAAW,CAAC;CAEhB,MAAM,sBAAsB;EAC1B,MAAM,WAAW,YAAY;EAC7B,MAAM,WAAW,UAAU,CAAC,CAAC;EAC7B,OAAO;GACL,OAAO,UAAU,kBAAkB;GACnC,KAAK,UAAU,gBAAgB;EACjC;CACF;CAEA,MAAM,aAAa,SAAoB;EACrC,SAAS,UAAU,KAAK;EAExB,MAAM,WAAW,YAAY;EAC7B,IAAI,UAAU;GAMZ,SAAS,QAAQ,KAAK;GACtB,4BAA4B;IAC1B,SAAS,kBAAkB,KAAK,gBAAgB,KAAK,YAAY;GACnE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M,QAAQ,aAAa,MAAM,eAAe,OAAO,MAAM;GAE7D,IAAI,MAAM,WAAW,GACnB;GAGF,MAAM,eAAe;GACrB,eAAe,QAAQ,KAAK;EAC9B;EAEA,SAAS,iBAAiB,SAAS,WAAW;EAC9C,aAAa,SAAS,oBAAoB,SAAS,WAAW;CAChE,GAAG;EAAC;EAAW;EAAQ;CAAW,CAAC;CAanC,MAAM,gBAAgB,UACpB,MAAM,aAAa,MAAM,SAAS,OAAO;CAM3C,MAAM,YAAY,OAAO,CAAC;CAC1B,MAAM,CAAC,cAAc,mBAAmB,SAAS,KAAK;CAEtD,MAAM,gBAAgB;EACpB,UAAU,UAAU;EACpB,gBAAgB,KAAK;CACvB;CA0CA,OAAO;EACL,WAzC2B,YACzB;GACE,cAAc,UAAU;IACtB,IAAI,CAAC,aAAa,KAAK,GACrB;IAEF,MAAM,eAAe;IACrB,UAAU,WAAW;IACrB,gBAAgB,IAAI;GACtB;GACA,aAAa,UAAU;IACrB,IAAI,CAAC,aAAa,KAAK,GACrB;IAGF,MAAM,eAAe;IACrB,MAAM,aAAa,aAAa;GAClC;GACA,cAAc,UAAU;IACtB,IAAI,CAAC,aAAa,KAAK,GACrB;IAEF,UAAU,UAAU,KAAK,IAAI,GAAG,UAAU,UAAU,CAAC;IACrD,IAAI,UAAU,YAAY,GACxB,gBAAgB,KAAK;GAEzB;GACA,SAAS,UAAU;IACjB,IAAI,CAAC,aAAa,KAAK,GACrB;IAEF,MAAM,eAAe;IACrB,QAAQ;IACR,eAAe,QACb,aAAa,MAAM,aAAa,OAAO,MAAM,CAC/C;GACF;EACF,IACA,CAAC;EAIH;EACA,aAAa,aAAa,cAAc,KAAA;CAC1C;AACF"}
|
|
1
|
+
{"version":3,"file":"useFileUpload.mjs","names":["locales"],"sources":["../../../../../../../../src/components/MarkdownEditor/lib/useFileUpload.ts"],"sourcesContent":["import {\n type DragEvent as ReactDragEvent,\n type DragEventHandler,\n type RefObject,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { announce } from \"@react-aria/live-announcer\";\nimport { matchesAccept } from \"@/lib/files/acceptedFiles\";\nimport {\n insertAtCaret,\n type MarkdownEditorUpload,\n removePlaceholder,\n replacePlaceholder,\n uploadedFileMarkdown,\n uploadPlaceholder,\n type ValueEdit,\n} from \"@/components/MarkdownEditor/lib/fileUpload\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\nimport locales from \"../locales/*.locale.json\";\n\n/** The files of a paste or a drop that `accept` covers. */\nconst acceptedFrom = (files: FileList | null | undefined, accept?: string) =>\n Array.from(files ?? []).filter((file) => matchesAccept(file, accept));\n\n/** @internal */\nexport type MarkdownEditorFileUploadHandler = (\n file: File,\n) => Promise<MarkdownEditorUpload>;\n\ninterface Options {\n /** Which file types to take, as an `accept` attribute value. */\n accept?: string;\n disableImages?: boolean;\n /** Uploads one file. Uploading is off entirely while this is undefined. */\n uploadFile?: MarkdownEditorFileUploadHandler;\n /** Turns dropping, pasting and the toolbar button off. */\n isDisabled?: boolean;\n value: string;\n onChange: (value: string) => void;\n textAreaRef: RefObject<HTMLTextAreaElement | null>;\n}\n\ninterface DropProps {\n onDragEnter?: DragEventHandler;\n onDragOver?: DragEventHandler;\n onDragLeave?: DragEventHandler;\n onDrop?: DragEventHandler;\n}\n\ninterface FileUpload {\n /** Drop handling for the editor's root element. */\n dropProps: DropProps;\n /** Whether a drag is currently over the editor. */\n isDropTarget: boolean;\n /**\n * Uploads the files the toolbar button picked. `undefined` while uploading is\n * off.\n */\n uploadFiles?: (files: File[]) => void;\n}\n\n/**\n * Drop, paste and toolbar uploads for the `MarkdownEditor`: a placeholder\n * comment goes to the cursor right away and is replaced by a markdown link once\n * the consumer's upload resolves.\n *\n * @internal\n */\nexport const useFileUpload = (options: Options): FileUpload => {\n const {\n accept,\n uploadFile,\n disableImages,\n isDisabled,\n value,\n onChange,\n textAreaRef,\n } = options;\n\n const stringFormatter = useLocalizedStringFormatter(\n locales,\n \"MarkdownEditor\",\n );\n\n const isEnabled = !!uploadFile && !isDisabled;\n\n /*\n * An upload resolves long after the drop, and the editor has kept taking\n * input in the meantime. The textarea's own value is the only one that is\n * current by then — the `value` prop is a render old whenever two uploads\n * resolve in the same tick.\n */\n const valueRef = useRef(value);\n useEffect(() => {\n valueRef.current = value;\n }, [value]);\n\n const readValue = () => textAreaRef.current?.value ?? valueRef.current;\n\n /*\n * A textarea keeps its `selectionStart` after losing focus, so the caret is\n * still readable once the attachment button has taken the focus away. What it\n * cannot tell apart is a caret at position 0 from one that was never placed —\n * both read 0, and appending is the better answer for the second.\n */\n const wasFocusedRef = useRef(false);\n useEffect(() => {\n const textArea = textAreaRef.current;\n\n if (!textArea) {\n return;\n }\n\n const rememberFocus = () => {\n wasFocusedRef.current = true;\n };\n\n textArea.addEventListener(\"focus\", rememberFocus);\n return () => textArea.removeEventListener(\"focus\", rememberFocus);\n }, [textAreaRef]);\n\n const readSelection = () => {\n const textArea = textAreaRef.current;\n const fallback = readValue().length;\n return {\n start: textArea?.selectionStart ?? fallback,\n end: textArea?.selectionEnd ?? fallback,\n };\n };\n\n const applyEdit = (edit: ValueEdit) => {\n valueRef.current = edit.value;\n\n const textArea = textAreaRef.current;\n if (textArea) {\n /*\n * Written before the re-render so an upload resolving in the same tick\n * reads this one's result, and the selection restored after it, once\n * React has rendered the controlled value.\n */\n textArea.value = edit.value;\n requestAnimationFrame(() => {\n textArea.setSelectionRange(edit.selectionStart, edit.selectionEnd);\n });\n }\n\n onChange(edit.value);\n };\n\n const runUpload = async (\n upload: MarkdownEditorFileUploadHandler,\n file: File,\n placeholder: string,\n ) => {\n announce(\n stringFormatter.format(\"upload.pending\", { name: file.name }),\n \"polite\",\n );\n\n try {\n const result = await upload(file);\n const selection = readSelection();\n const edit = replacePlaceholder(\n readValue(),\n placeholder,\n uploadedFileMarkdown(file, result, disableImages),\n selection.start,\n selection.end,\n );\n\n if (edit) {\n applyEdit(edit);\n }\n\n announce(\n stringFormatter.format(\"upload.succeeded\", { name: file.name }),\n \"polite\",\n );\n } catch {\n const selection = readSelection();\n const edit = removePlaceholder(\n readValue(),\n placeholder,\n selection.start,\n selection.end,\n );\n\n if (edit) {\n applyEdit(edit);\n }\n\n announce(\n stringFormatter.format(\"upload.failed\", { name: file.name }),\n \"assertive\",\n );\n }\n };\n\n const uploadFiles = (files: File[]) => {\n if (!uploadFile || files.length === 0) {\n return;\n }\n\n const textArea = textAreaRef.current;\n const caret =\n textArea && wasFocusedRef.current\n ? textArea.selectionStart\n : readValue().length;\n\n const uploads = files.map((file) => ({\n file,\n placeholder: uploadPlaceholder(file.name),\n }));\n\n applyEdit(\n insertAtCaret(\n readValue(),\n uploads.map((upload) => upload.placeholder).join(\"\\n\"),\n caret,\n ),\n );\n textArea?.focus();\n\n for (const upload of uploads) {\n void runUpload(uploadFile, upload.file, upload.placeholder);\n }\n };\n\n const uploadFilesRef = useRef(uploadFiles);\n uploadFilesRef.current = uploadFiles;\n\n /*\n * The paste listener is attached imperatively rather than through react-aria's\n * `useClipboard`, which calls `preventDefault` on every paste it sees and\n * would take plain text pasting with it.\n */\n useEffect(() => {\n const textArea = textAreaRef.current;\n\n if (!textArea || !isEnabled) {\n return;\n }\n\n const handlePaste = (event: ClipboardEvent) => {\n const files = acceptedFrom(event.clipboardData?.files, accept);\n\n if (files.length === 0) {\n return;\n }\n\n event.preventDefault();\n uploadFilesRef.current(files);\n };\n\n textArea.addEventListener(\"paste\", handlePaste);\n return () => textArea.removeEventListener(\"paste\", handlePaste);\n }, [isEnabled, accept, textAreaRef]);\n\n /*\n * Native handlers rather than react-aria's `useDrop`: that one claims every\n * drag it sees — its `onDrop` calls `preventDefault` and `stopPropagation`\n * unconditionally — which is right for a dedicated drop surface like\n * `FileDropZone`, but here it would swallow a plain text drag into the\n * textarea. A drag is claimed only when it carries files, and\n * `dataTransfer.types` is the only place that says so: the public\n * `DragTypes` of `getDropOperation` offers just `has(type)`, which cannot\n * express it — the wildcard type is always true, and WebKit reports every\n * file drag as an unknown type that answers true to anything.\n */\n const dragHasFiles = (event: ReactDragEvent) =>\n event.dataTransfer.types.includes(\"Files\");\n\n /*\n * `dragenter` and `dragleave` fire again for every child the pointer\n * crosses, so the highlight follows their balance rather than the last one.\n */\n const dragDepth = useRef(0);\n const [isDropTarget, setIsDropTarget] = useState(false);\n\n const endDrag = () => {\n dragDepth.current = 0;\n setIsDropTarget(false);\n };\n\n const dropProps: DropProps = isEnabled\n ? {\n onDragEnter: (event) => {\n if (!dragHasFiles(event)) {\n return;\n }\n event.preventDefault();\n dragDepth.current += 1;\n setIsDropTarget(true);\n },\n onDragOver: (event) => {\n if (!dragHasFiles(event)) {\n return;\n }\n // Without this the browser refuses the drop and opens the file instead.\n event.preventDefault();\n event.dataTransfer.dropEffect = \"copy\";\n },\n onDragLeave: (event) => {\n if (!dragHasFiles(event)) {\n return;\n }\n dragDepth.current = Math.max(0, dragDepth.current - 1);\n if (dragDepth.current === 0) {\n setIsDropTarget(false);\n }\n },\n onDrop: (event) => {\n if (!dragHasFiles(event)) {\n return;\n }\n event.preventDefault();\n endDrag();\n uploadFilesRef.current(\n acceptedFrom(event.dataTransfer.files, accept),\n );\n },\n }\n : {};\n\n return {\n dropProps,\n isDropTarget,\n uploadFiles: uploadFile ? uploadFiles : undefined,\n };\n};\n"],"mappings":";;;;;;;;;;AAuBA,IAAM,gBAAgB,OAAoC,WACxD,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,SAAS,cAAc,MAAM,MAAM,CAAC;;;;;;;;AA8CtE,IAAa,iBAAiB,YAAiC;CAC7D,MAAM,EACJ,QACA,YACA,eACA,YACA,OACA,UACA,gBACE;CAEJ,MAAM,kBAAkB,4BACtBA,kBACA,gBACF;CAEA,MAAM,YAAY,CAAC,CAAC,cAAc,CAAC;CAQnC,MAAM,WAAW,OAAO,KAAK;CAC7B,gBAAgB;EACd,SAAS,UAAU;CACrB,GAAG,CAAC,KAAK,CAAC;CAEV,MAAM,kBAAkB,YAAY,S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C,aAAa,KAAK,GACrB;IAGF,MAAM,eAAe;IACrB,MAAM,aAAa,aAAa;GAClC;GACA,cAAc,UAAU;IACtB,IAAI,CAAC,aAAa,KAAK,GACrB;IAEF,UAAU,UAAU,KAAK,IAAI,GAAG,UAAU,UAAU,CAAC;IACrD,IAAI,UAAU,YAAY,GACxB,gBAAgB,KAAK;GAEzB;GACA,SAAS,UAAU;IACjB,IAAI,CAAC,aAAa,KAAK,GACrB;IAEF,MAAM,eAAe;IACrB,QAAQ;IACR,eAAe,QACb,aAAa,MAAM,aAAa,OAAO,MAAM,CAC/C;GACF;EACF,IACA,CAAC;EAIH;EACA,aAAa,aAAa,cAAc,KAAA;CAC1C;AACF"}
|
|
@@ -6,6 +6,8 @@ export interface MarkdownProps extends PropsWithClassName, Omit<Options, "compon
|
|
|
6
6
|
color?: "default" | AlphaColor;
|
|
7
7
|
/** Shifts all heading levels by the given offset. @default 0 */
|
|
8
8
|
headingOffset?: number;
|
|
9
|
+
/** Whether images are left out of the rendered markdown. @default false */
|
|
10
|
+
disableImages?: boolean;
|
|
9
11
|
/** Allows overriding markdown element renderers from outside. */
|
|
10
12
|
components?: Components;
|
|
11
13
|
/** A ref to the elements root. */
|
|
@@ -4,7 +4,7 @@ import { TextAreaProps } from '../TextArea';
|
|
|
4
4
|
import { MarkdownEditorUpload } from './lib/fileUpload';
|
|
5
5
|
export type MarkdownEditorMode = "editor" | "preview";
|
|
6
6
|
export type { MarkdownEditorUpload };
|
|
7
|
-
export interface MarkdownEditorProps extends TextAreaProps, Pick<MarkdownProps, "headingOffset"> {
|
|
7
|
+
export interface MarkdownEditorProps extends TextAreaProps, Pick<MarkdownProps, "headingOffset" | "disableImages"> {
|
|
8
8
|
/**
|
|
9
9
|
* Allows replacing the markdown preview renderer implementation. Defaults to
|
|
10
10
|
* the internal `Markdown` component.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/flow-react-components",
|
|
3
|
-
"version": "1.6.0-next.
|
|
3
|
+
"version": "1.6.0-next.66",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React implementation of Flow, mittwald’s design system",
|
|
6
6
|
"homepage": "https://flow.mittwald.de",
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
"@internationalized/string-compiler": "^3.4.1",
|
|
85
85
|
"@lezer/common": "^1.5.2",
|
|
86
86
|
"@lezer/highlight": "^1.2.3",
|
|
87
|
-
"@mittwald/flow-icons": "^1.6.0-next.
|
|
87
|
+
"@mittwald/flow-icons": "^1.6.0-next.66",
|
|
88
88
|
"@mittwald/password-tools-js": "^3.0.0",
|
|
89
|
-
"@mittwald/react-tunnel": "^1.6.0-next.
|
|
89
|
+
"@mittwald/react-tunnel": "^1.6.0-next.66",
|
|
90
90
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
91
91
|
"@react-aria/form": "^3.2.1",
|
|
92
92
|
"@react-aria/i18n": "^3.13.1",
|
|
@@ -139,13 +139,13 @@
|
|
|
139
139
|
"@internationalized/date": "^3.12.3",
|
|
140
140
|
"@lezer/generator": "^1.8.0",
|
|
141
141
|
"@lezer/lr": "^1.4.10",
|
|
142
|
-
"@mittwald/flow-components-base": "1.6.0-next.
|
|
143
|
-
"@mittwald/flow-core": "1.6.0-next.
|
|
144
|
-
"@mittwald/flow-design-tokens": "1.6.0-next.
|
|
145
|
-
"@mittwald/flow-icons-base": "1.6.0-next.
|
|
142
|
+
"@mittwald/flow-components-base": "1.6.0-next.66",
|
|
143
|
+
"@mittwald/flow-core": "1.6.0-next.66",
|
|
144
|
+
"@mittwald/flow-design-tokens": "1.6.0-next.66",
|
|
145
|
+
"@mittwald/flow-icons-base": "1.6.0-next.66",
|
|
146
146
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
147
147
|
"@mittwald/remote-dom-react": "1.2.2-mittwald.10",
|
|
148
|
-
"@mittwald/typescript-config": "1.6.0-next.
|
|
148
|
+
"@mittwald/typescript-config": "1.6.0-next.66",
|
|
149
149
|
"@nx/storybook": "^22.7.6",
|
|
150
150
|
"@storybook/addon-a11y": "^10.5.10",
|
|
151
151
|
"@storybook/addon-actions": "^9.0.8",
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
},
|
|
200
200
|
"peerDependencies": {
|
|
201
201
|
"@internationalized/date": "^3.12.2",
|
|
202
|
-
"@mittwald/flow-icons-pro": "1.6.0-next.
|
|
202
|
+
"@mittwald/flow-icons-pro": "1.6.0-next.66",
|
|
203
203
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
204
204
|
"next": "^16.2.3",
|
|
205
205
|
"react": "^19.2.0",
|
|
@@ -223,5 +223,5 @@
|
|
|
223
223
|
"browserslist": [
|
|
224
224
|
"baseline widely available"
|
|
225
225
|
],
|
|
226
|
-
"gitHead": "
|
|
226
|
+
"gitHead": "f9f3409e7855275222bc6f42ec82b9d150d0ab88"
|
|
227
227
|
}
|