forked from microsoft/BotFramework-WebChat
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAddFullBundle.tsx
More file actions
80 lines (70 loc) · 2.86 KB
/
AddFullBundle.tsx
File metadata and controls
80 lines (70 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { warnOnce } from '@msinternal/botframework-webchat-base/utils';
import {
type AttachmentForScreenReaderMiddleware,
type AttachmentMiddleware,
type StyleOptions
} from 'botframework-webchat-api';
import { type HTMLContentTransformMiddleware } from 'botframework-webchat-component';
import { singleToArray, type OneOrMany } from 'botframework-webchat-core';
import React, { memo, type ReactNode } from 'react';
import AdaptiveCardsComposer from './adaptiveCards/AdaptiveCardsComposer';
import { type AdaptiveCardsStyleOptions } from './adaptiveCards/AdaptiveCardsStyleOptions';
import ShikiComposer from './codeHighlighter/ShikiComposer';
import { type AdaptiveCardsPackage } from './types/AdaptiveCardsPackage';
import { type StrictFullBundleStyleOptions } from './types/FullBundleStyleOptions';
import useComposerProps from './useComposerProps';
type AddFullBundleChildren = ({ extraStyleSet }: { extraStyleSet: any }) => ReactNode;
type AddFullBundleProps = Readonly<{
adaptiveCardsHostConfig?: any;
adaptiveCardsPackage?: AdaptiveCardsPackage;
attachmentForScreenReaderMiddleware?: OneOrMany<AttachmentForScreenReaderMiddleware>;
attachmentMiddleware?: OneOrMany<AttachmentMiddleware>;
children: AddFullBundleChildren;
htmlContentTransformMiddleware?: HTMLContentTransformMiddleware[];
renderMarkdown?: (
markdown: string,
newLineOptions: { markdownRespectCRLF: boolean },
linkOptions: { externalLinkAlt: string }
) => string;
styleOptions?: StyleOptions & AdaptiveCardsStyleOptions;
styleSet?: any & { options: StrictFullBundleStyleOptions };
/** @deprecated Rename to "adaptiveCardsHostConfig" */
adaptiveCardHostConfig?: any;
}>;
const adaptiveCardHostConfigDeprecation = warnOnce(
'"adaptiveCardHostConfig" is deprecated. Please use "adaptiveCardsHostConfig" instead. "adaptiveCardHostConfig" will be removed on or after 2022-01-01.'
);
function AddFullBundle({
adaptiveCardHostConfig,
adaptiveCardsHostConfig,
adaptiveCardsPackage,
attachmentForScreenReaderMiddleware,
attachmentMiddleware,
children,
htmlContentTransformMiddleware,
renderMarkdown,
styleOptions,
styleSet
}: AddFullBundleProps) {
adaptiveCardHostConfig && adaptiveCardHostConfigDeprecation();
const patchedProps = useComposerProps({
attachmentForScreenReaderMiddleware: singleToArray(attachmentForScreenReaderMiddleware),
attachmentMiddleware: singleToArray(attachmentMiddleware),
htmlContentTransformMiddleware,
renderMarkdown,
styleOptions,
styleSet
});
return (
<ShikiComposer>
<AdaptiveCardsComposer
adaptiveCardsHostConfig={adaptiveCardHostConfig || adaptiveCardsHostConfig}
adaptiveCardsPackage={adaptiveCardsPackage}
>
{children(patchedProps)}
</AdaptiveCardsComposer>
</ShikiComposer>
);
}
export default memo(AddFullBundle);
export type { AddFullBundleChildren, AddFullBundleProps };