botframework-webchat 4.13.0 → 4.15.0
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/.eslintrc.yml +5 -104
- package/.prettierrc.yml +1 -1
- package/README.md +33 -36
- package/babel.config.json +2 -2
- package/babel.sanitize-html.config.json +10 -0
- package/lib/AddFullBundle.d.ts +30 -0
- package/lib/AddFullBundle.d.ts.map +1 -0
- package/lib/AddFullBundle.js +76 -0
- package/lib/FullComposer.d.ts +8 -0
- package/lib/FullComposer.d.ts.map +1 -0
- package/lib/FullComposer.js +6 -16
- package/lib/FullReactWebChat.d.ts +8 -0
- package/lib/FullReactWebChat.d.ts.map +1 -0
- package/lib/FullReactWebChat.js +8 -23
- package/lib/adaptiveCards/AdaptiveCardsComposer.d.ts +10 -0
- package/lib/adaptiveCards/AdaptiveCardsComposer.d.ts.map +1 -0
- package/lib/adaptiveCards/AdaptiveCardsComposer.js +6 -2
- package/lib/adaptiveCards/AdaptiveCardsContext.d.ts +8 -0
- package/lib/adaptiveCards/AdaptiveCardsContext.d.ts.map +1 -0
- package/lib/adaptiveCards/AdaptiveCardsContext.js +3 -3
- package/lib/adaptiveCards/AdaptiveCardsStyleOptions.d.ts +5 -3
- package/lib/adaptiveCards/AdaptiveCardsStyleOptions.d.ts.map +1 -1
- package/lib/adaptiveCards/AdaptiveCardsStyleSet.d.ts +7 -0
- package/lib/adaptiveCards/AdaptiveCardsStyleSet.d.ts.map +1 -0
- package/lib/{FullBundleStyleOptions.js → adaptiveCards/AdaptiveCardsStyleSet.js} +0 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardAttachment.d.ts +9 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardAttachment.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardAttachment.js +1 -1
- package/lib/adaptiveCards/Attachment/AdaptiveCardBuilder.d.ts +28 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardBuilder.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardBuilder.js +13 -6
- package/lib/adaptiveCards/Attachment/AdaptiveCardContent.d.ts +9 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardContent.js +8 -4
- package/lib/adaptiveCards/Attachment/AdaptiveCardRenderer.d.ts +12 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardRenderer.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardRenderer.js +310 -85
- package/lib/adaptiveCards/Attachment/AnimationCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/AnimationCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AnimationCardContent.js +1 -1
- package/lib/adaptiveCards/Attachment/AudioCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/AudioCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AudioCardContent.js +1 -1
- package/lib/adaptiveCards/Attachment/CommonCard.js +11 -6
- package/lib/adaptiveCards/Attachment/HeroCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/HeroCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/HeroCardContent.js +11 -6
- package/lib/adaptiveCards/Attachment/OAuthCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/OAuthCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/OAuthCardContent.js +11 -6
- package/lib/adaptiveCards/Attachment/ReceiptCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/ReceiptCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/ReceiptCardContent.js +11 -6
- package/lib/adaptiveCards/Attachment/SignInCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/SignInCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/SignInCardContent.js +1 -1
- package/lib/adaptiveCards/Attachment/ThumbnailCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/ThumbnailCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/ThumbnailCardContent.js +11 -6
- package/lib/adaptiveCards/Attachment/VideoCardContent.d.ts +20 -0
- package/lib/adaptiveCards/Attachment/VideoCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/VideoCardContent.js +7 -5
- package/lib/adaptiveCards/AttachmentForScreenReader/AdaptiveCardAttachment.js +7 -3
- package/lib/adaptiveCards/AttachmentForScreenReader/RichCardAttachment.js +1 -1
- package/lib/adaptiveCards/Styles/StyleSet/AdaptiveCardRenderer.d.ts +59 -0
- package/lib/adaptiveCards/Styles/StyleSet/AdaptiveCardRenderer.d.ts.map +1 -0
- package/lib/adaptiveCards/Styles/StyleSet/AdaptiveCardRenderer.js +8 -1
- package/lib/adaptiveCards/Styles/adaptiveCardHostConfig.d.ts +126 -0
- package/lib/adaptiveCards/Styles/adaptiveCardHostConfig.d.ts.map +1 -0
- package/lib/adaptiveCards/Styles/adaptiveCardHostConfig.js +29 -9
- package/lib/adaptiveCards/Styles/createAdaptiveCardsStyleSet.d.ts +5 -0
- package/lib/adaptiveCards/Styles/createAdaptiveCardsStyleSet.d.ts.map +1 -0
- package/lib/adaptiveCards/Styles/createAdaptiveCardsStyleSet.js +2 -2
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentForScreenReaderMiddleware.d.ts +3 -0
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentForScreenReaderMiddleware.d.ts.map +1 -0
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentForScreenReaderMiddleware.js +5 -11
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentMiddleware.d.ts +3 -0
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentMiddleware.d.ts.map +1 -0
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentMiddleware.js +2 -15
- package/lib/adaptiveCards/defaultStyleOptions.d.ts +4 -0
- package/lib/adaptiveCards/defaultStyleOptions.d.ts.map +1 -0
- package/lib/adaptiveCards/defaultStyleOptions.js +3 -2
- package/lib/adaptiveCards/hooks/internal/useAdaptiveCardsContext.d.ts +3 -0
- package/lib/adaptiveCards/hooks/internal/useAdaptiveCardsContext.d.ts.map +1 -0
- package/lib/adaptiveCards/hooks/internal/useAdaptiveCardsContext.js +1 -1
- package/lib/adaptiveCards/hooks/internal/useParseAdaptiveCardJSON.d.ts +2 -0
- package/lib/adaptiveCards/hooks/internal/useParseAdaptiveCardJSON.d.ts.map +1 -0
- package/lib/adaptiveCards/hooks/internal/useParseAdaptiveCardJSON.js +7 -5
- package/lib/adaptiveCards/hooks/internal/useUniqueId.js +1 -1
- package/lib/adaptiveCards/hooks/useAdaptiveCardsHostConfig.d.ts +2 -0
- package/lib/adaptiveCards/hooks/useAdaptiveCardsHostConfig.d.ts.map +1 -0
- package/lib/adaptiveCards/hooks/useAdaptiveCardsHostConfig.js +3 -5
- package/lib/adaptiveCards/hooks/useAdaptiveCardsPackage.d.ts +3 -0
- package/lib/adaptiveCards/hooks/useAdaptiveCardsPackage.d.ts.map +1 -0
- package/lib/adaptiveCards/hooks/useAdaptiveCardsPackage.js +1 -1
- package/lib/adaptiveCards/normalizeStyleOptions.d.ts +3 -0
- package/lib/adaptiveCards/normalizeStyleOptions.d.ts.map +1 -0
- package/lib/adaptiveCards/normalizeStyleOptions.js +1 -1
- package/lib/addVersion.js +2 -2
- package/lib/createBrowserWebSpeechPonyfillFactory.d.ts +3 -0
- package/lib/createBrowserWebSpeechPonyfillFactory.d.ts.map +1 -0
- package/lib/createBrowserWebSpeechPonyfillFactory.js +7 -4
- package/lib/createCognitiveServicesSpeechServicesPonyfillFactory.d.ts +17 -0
- package/lib/createCognitiveServicesSpeechServicesPonyfillFactory.d.ts.map +1 -0
- package/lib/createCognitiveServicesSpeechServicesPonyfillFactory.js +17 -11
- package/lib/createDirectLine.d.ts +17 -0
- package/lib/createDirectLine.d.ts.map +1 -0
- package/lib/createDirectLine.js +3 -2
- package/lib/createDirectLineAppServiceExtension.d.ts +7 -0
- package/lib/createDirectLineAppServiceExtension.d.ts.map +1 -0
- package/lib/createDirectLineAppServiceExtension.js +1 -1
- package/lib/createDirectLineSpeechAdapters.d.ts +25 -0
- package/lib/createDirectLineSpeechAdapters.d.ts.map +1 -0
- package/lib/createDirectLineSpeechAdapters.js +57 -3
- package/lib/createFullStyleSet.d.ts +1375 -0
- package/lib/createFullStyleSet.d.ts.map +1 -0
- package/lib/createFullStyleSet.js +2 -2
- package/lib/fullBundleDefaultStyleOptions.js +4 -4
- package/lib/hooks/useStyleOptions.d.ts +3 -0
- package/lib/hooks/useStyleOptions.d.ts.map +1 -0
- package/lib/hooks/useStyleOptions.js +21 -0
- package/lib/index-es5.d.ts +4 -20
- package/lib/index-es5.d.ts.map +1 -1
- package/lib/index-es5.js +3 -43
- package/lib/index-minimal.d.ts +9 -6
- package/lib/index-minimal.d.ts.map +1 -1
- package/lib/index-minimal.js +27 -21
- package/lib/index.d.ts +164 -18
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +19 -12
- package/lib/polyfill.d.ts +23 -0
- package/lib/polyfill.d.ts.map +1 -0
- package/lib/polyfill.js +46 -0
- package/lib/renderMarkdown.d.ts +6 -0
- package/lib/renderMarkdown.d.ts.map +1 -0
- package/lib/renderMarkdown.js +36 -5
- package/lib/renderWebChat.d.ts +3 -0
- package/lib/renderWebChat.d.ts.map +1 -0
- package/lib/renderWebChat.js +1 -1
- package/lib/speech/CustomAudioInputStream.d.ts +94 -0
- package/lib/speech/CustomAudioInputStream.d.ts.map +1 -0
- package/lib/speech/CustomAudioInputStream.js +441 -0
- package/lib/speech/bytesPerSample.d.ts +2 -0
- package/lib/speech/bytesPerSample.d.ts.map +1 -0
- package/lib/speech/bytesPerSample.js +12 -0
- package/lib/speech/createAudioConfig.d.ts +23 -0
- package/lib/speech/createAudioConfig.d.ts.map +1 -0
- package/lib/speech/createAudioConfig.js +90 -0
- package/lib/speech/createAudioContext.d.ts +3 -0
- package/lib/speech/createAudioContext.d.ts.map +1 -0
- package/lib/speech/createAudioContext.js +22 -0
- package/lib/speech/createMicrophoneAudioConfigAndAudioContext.d.ts +9 -0
- package/lib/speech/createMicrophoneAudioConfigAndAudioContext.d.ts.map +1 -0
- package/lib/speech/createMicrophoneAudioConfigAndAudioContext.js +161 -0
- package/lib/speech/getUserMedia.d.ts +2 -0
- package/lib/speech/getUserMedia.d.ts.map +1 -0
- package/lib/speech/getUserMedia.js +25 -0
- package/lib/types/AdaptiveCardsPackage.d.ts +13 -0
- package/lib/types/AdaptiveCardsPackage.d.ts.map +1 -0
- package/lib/types/AdaptiveCardsPackage.js +2 -0
- package/lib/types/CognitiveServicesAudioOutputFormat.d.ts +3 -0
- package/lib/types/CognitiveServicesAudioOutputFormat.d.ts.map +1 -0
- package/lib/types/CognitiveServicesAudioOutputFormat.js +2 -0
- package/lib/types/CognitiveServicesCredentials.d.ts +18 -0
- package/lib/types/CognitiveServicesCredentials.d.ts.map +1 -0
- package/lib/types/CognitiveServicesCredentials.js +2 -0
- package/lib/types/CognitiveServicesTextNormalization.d.ts +3 -0
- package/lib/types/CognitiveServicesTextNormalization.d.ts.map +1 -0
- package/lib/types/CognitiveServicesTextNormalization.js +2 -0
- package/lib/{FullBundleStyleOptions.d.ts → types/FullBundleStyleOptions.d.ts} +1 -1
- package/lib/types/FullBundleStyleOptions.d.ts.map +1 -0
- package/lib/types/FullBundleStyleOptions.js +2 -0
- package/lib/useComposerProps.d.ts +22 -0
- package/lib/useComposerProps.d.ts.map +1 -0
- package/lib/useComposerProps.js +6 -8
- package/package.json +46 -48
- package/src/AddFullBundle.tsx +93 -0
- package/src/FullComposer.tsx +38 -0
- package/src/FullReactWebChat.tsx +32 -0
- package/src/__tests__/createDirectLine.spec.js +2 -0
- package/src/__tests__/renderMarkdown.spec.js +1 -1
- package/src/__tests__/versionTag.es5.spec.js +3 -0
- package/src/__tests__/versionTag.full.spec.js +3 -0
- package/src/__tests__/versionTag.minimal.spec.js +3 -0
- package/src/adaptiveCards/{AdaptiveCardsComposer.js → AdaptiveCardsComposer.tsx} +17 -5
- package/src/adaptiveCards/AdaptiveCardsContext.ts +12 -0
- package/src/adaptiveCards/AdaptiveCardsStyleOptions.ts +5 -3
- package/src/adaptiveCards/AdaptiveCardsStyleSet.ts +7 -0
- package/src/adaptiveCards/Attachment/{AdaptiveCardAttachment.js → AdaptiveCardAttachment.tsx} +8 -2
- package/src/adaptiveCards/Attachment/AdaptiveCardBuilder.ts +27 -17
- package/src/adaptiveCards/Attachment/{AdaptiveCardContent.js → AdaptiveCardContent.tsx} +8 -2
- package/src/adaptiveCards/Attachment/AdaptiveCardRenderer.tsx +768 -0
- package/src/adaptiveCards/Attachment/{AnimationCardContent.js → AnimationCardContent.tsx} +9 -2
- package/src/adaptiveCards/Attachment/{AudioCardContent.js → AudioCardContent.tsx} +9 -2
- package/src/adaptiveCards/Attachment/CommonCard.js +2 -1
- package/src/adaptiveCards/Attachment/{HeroCardContent.js → HeroCardContent.tsx} +12 -3
- package/src/adaptiveCards/Attachment/{OAuthCardContent.js → OAuthCardContent.tsx} +11 -3
- package/src/adaptiveCards/Attachment/{ReceiptCardContent.js → ReceiptCardContent.tsx} +58 -28
- package/src/adaptiveCards/Attachment/{SignInCardContent.js → SignInCardContent.tsx} +9 -2
- package/src/adaptiveCards/Attachment/{ThumbnailCardContent.js → ThumbnailCardContent.tsx} +12 -3
- package/src/adaptiveCards/Attachment/{VideoCardContent.js → VideoCardContent.tsx} +15 -3
- package/src/adaptiveCards/Styles/StyleSet/AdaptiveCardRenderer.ts +9 -1
- package/src/adaptiveCards/Styles/adaptiveCardHostConfig.ts +28 -8
- package/src/adaptiveCards/Styles/createAdaptiveCardsStyleSet.spec.js +2 -0
- package/src/adaptiveCards/Styles/createAdaptiveCardsStyleSet.ts +7 -4
- package/src/adaptiveCards/{createAdaptiveCardsAttachmentForScreenReaderMiddleware.js → createAdaptiveCardsAttachmentForScreenReaderMiddleware.tsx} +16 -15
- package/src/adaptiveCards/createAdaptiveCardsAttachmentMiddleware.tsx +44 -0
- package/src/adaptiveCards/defaultStyleOptions.ts +2 -1
- package/src/adaptiveCards/hooks/internal/{useAdaptiveCardsContext.js → useAdaptiveCardsContext.ts} +1 -1
- package/src/adaptiveCards/hooks/internal/{useParseAdaptiveCardJSON.js → useParseAdaptiveCardJSON.ts} +5 -2
- package/src/adaptiveCards/hooks/internal/{useUniqueId.js → useUniqueId.ts} +1 -1
- package/src/adaptiveCards/hooks/{useAdaptiveCardsHostConfig.js → useAdaptiveCardsHostConfig.ts} +6 -8
- package/src/adaptiveCards/hooks/{useAdaptiveCardsPackage.js → useAdaptiveCardsPackage.ts} +2 -1
- package/src/createBrowserWebSpeechPonyfillFactory.ts +21 -0
- package/src/createCognitiveServicesSpeechServicesPonyfillFactory.spec.js +36 -6
- package/src/createCognitiveServicesSpeechServicesPonyfillFactory.ts +78 -0
- package/src/createDirectLine.ts +65 -0
- package/src/createDirectLineAppServiceExtension.ts +22 -0
- package/src/createDirectLineSpeechAdapters.ts +84 -0
- package/src/createFullStyleSet.ts +2 -2
- package/src/fullBundleDefaultStyleOptions.ts +3 -3
- package/src/hooks/useStyleOptions.ts +9 -0
- package/src/index-es5.ts +3 -28
- package/src/index-minimal.ts +3 -2
- package/src/index.ts +22 -10
- package/src/polyfill.ts +29 -0
- package/src/renderMarkdown.ts +140 -0
- package/src/renderWebChat.tsx +6 -0
- package/src/speech/CustomAudioInputStream.ts +356 -0
- package/src/speech/bytesPerSample.ts +4 -0
- package/src/speech/createAudioConfig.spec.js +23 -0
- package/src/speech/createAudioConfig.ts +77 -0
- package/src/speech/createAudioContext.ts +16 -0
- package/src/speech/createMicrophoneAudioConfigAndAudioContext.ts +146 -0
- package/src/speech/getUserMedia.ts +14 -0
- package/src/tsconfig.json +1 -1
- package/src/types/AdaptiveCardsPackage.ts +23 -0
- package/src/types/CognitiveServicesAudioOutputFormat.ts +28 -0
- package/src/types/CognitiveServicesCredentials.ts +28 -0
- package/src/types/CognitiveServicesTextNormalization.ts +3 -0
- package/src/{FullBundleStyleOptions.ts → types/FullBundleStyleOptions.ts} +1 -1
- package/src/{useComposerProps.js → useComposerProps.ts} +21 -11
- package/webpack.config.js +46 -6
- package/.eslintignore +0 -9
- package/lib/FullBundleStyleOptions.d.ts.map +0 -1
- package/src/FullComposer.js +0 -40
- package/src/FullReactWebChat.js +0 -47
- package/src/adaptiveCards/AdaptiveCardsContext.js +0 -5
- package/src/adaptiveCards/Attachment/AdaptiveCardRenderer.js +0 -492
- package/src/adaptiveCards/createAdaptiveCardsAttachmentMiddleware.js +0 -41
- package/src/createBrowserWebSpeechPonyfillFactory.js +0 -16
- package/src/createCognitiveServicesSpeechServicesPonyfillFactory.js +0 -58
- package/src/createDirectLine.js +0 -38
- package/src/createDirectLineAppServiceExtension.js +0 -12
- package/src/createDirectLineSpeechAdapters.js +0 -5
- package/src/index-es5.tsx +0 -49
- package/src/index-minimal.tsx +0 -9
- package/src/index.tsx +0 -45
- package/src/renderMarkdown.js +0 -97
- package/src/renderWebChat.js +0 -6
package/src/index-es5.tsx
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Components as ComponentsFromComponent,
|
|
4
|
-
ComposerProps,
|
|
5
|
-
ReactWebChatProps
|
|
6
|
-
} from 'botframework-webchat-component';
|
|
7
|
-
|
|
8
|
-
import StyleOptions from './FullBundleStyleOptions';
|
|
9
|
-
|
|
10
|
-
type Replace<T1, T2> = Omit<T1, keyof T2> & T2;
|
|
11
|
-
|
|
12
|
-
/** Creates a set of styles with support of Adaptive Cards */
|
|
13
|
-
declare function createStyleSet(styleOptions: StyleOptions): any;
|
|
14
|
-
|
|
15
|
-
declare const Components: Omit<typeof ComponentsFromComponent, 'Composer'> & {
|
|
16
|
-
Composer: FC<
|
|
17
|
-
Replace<
|
|
18
|
-
ComposerProps,
|
|
19
|
-
{
|
|
20
|
-
/** Style options with support of Adaptive Cards */
|
|
21
|
-
styleOptions?: StyleOptions;
|
|
22
|
-
}
|
|
23
|
-
>
|
|
24
|
-
>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/** React-based Web Chat with support of Adaptive Cards */
|
|
28
|
-
declare const ReactWebChat: FC<
|
|
29
|
-
Replace<
|
|
30
|
-
ReactWebChatProps,
|
|
31
|
-
{
|
|
32
|
-
/** Style options with support of Adaptive Cards */
|
|
33
|
-
styleOptions?: StyleOptions;
|
|
34
|
-
}
|
|
35
|
-
>
|
|
36
|
-
>;
|
|
37
|
-
|
|
38
|
-
export default ReactWebChat;
|
|
39
|
-
export { Components, createStyleSet };
|
|
40
|
-
export type { StyleOptions };
|
|
41
|
-
|
|
42
|
-
// Doc:
|
|
43
|
-
// - We don't want to export the whole index.ts, we just want to export what the user actually needed
|
|
44
|
-
// - That's why we only exporting index.tsx (we cannot name it index.d.ts because TSC won't pick it up)
|
|
45
|
-
// - Changing between full bundle and minimal should be very smooth
|
|
46
|
-
// - That's why we name both StyleOptions the same
|
|
47
|
-
// - To use minimal, import 'botframework-webchat/lib/index-minimal';
|
|
48
|
-
// - Declarations need to be emitted to /lib/*.d.ts for code-splitting purpose
|
|
49
|
-
// - import 'botframework-webchat/lib/index-minimal' should see IntelliSense support
|
package/src/index-minimal.tsx
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { StyleOptions } from 'botframework-webchat-api';
|
|
2
|
-
import ReactWebChat, { Components } from 'botframework-webchat-component';
|
|
3
|
-
|
|
4
|
-
/** Creates a set of styles */
|
|
5
|
-
declare function createStyleSet(styleOptions: StyleOptions): any;
|
|
6
|
-
|
|
7
|
-
export default ReactWebChat;
|
|
8
|
-
export { Components, createStyleSet };
|
|
9
|
-
export type { StyleOptions };
|
package/src/index.tsx
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { ComposerProps, ReactWebChatProps } from 'botframework-webchat-component';
|
|
3
|
-
|
|
4
|
-
import StyleOptions from './FullBundleStyleOptions';
|
|
5
|
-
|
|
6
|
-
type Replace<T1, T2> = Omit<T1, keyof T2> & T2;
|
|
7
|
-
|
|
8
|
-
/** Creates a set of styles with support of Adaptive Cards */
|
|
9
|
-
declare function createStyleSet(styleOptions: StyleOptions): any;
|
|
10
|
-
|
|
11
|
-
declare const Components: {
|
|
12
|
-
Composer: FC<
|
|
13
|
-
Replace<
|
|
14
|
-
ComposerProps,
|
|
15
|
-
{
|
|
16
|
-
/** Style options with support of Adaptive Cards */
|
|
17
|
-
styleOptions?: StyleOptions;
|
|
18
|
-
}
|
|
19
|
-
>
|
|
20
|
-
>;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/** React-based Web Chat with support of Adaptive Cards */
|
|
24
|
-
declare const ReactWebChat: FC<
|
|
25
|
-
Replace<
|
|
26
|
-
ReactWebChatProps,
|
|
27
|
-
{
|
|
28
|
-
/** Style options with support of Adaptive Cards */
|
|
29
|
-
styleOptions?: StyleOptions;
|
|
30
|
-
}
|
|
31
|
-
>
|
|
32
|
-
>;
|
|
33
|
-
|
|
34
|
-
export default ReactWebChat;
|
|
35
|
-
export { Components, createStyleSet };
|
|
36
|
-
export type { StyleOptions };
|
|
37
|
-
|
|
38
|
-
// Doc:
|
|
39
|
-
// - We don't want to export the whole index.ts, we just want to export what the user actually needed
|
|
40
|
-
// - That's why we only exporting index.tsx (we cannot name it index.d.ts because TSC won't pick it up)
|
|
41
|
-
// - Changing between full bundle and minimal should be very smooth
|
|
42
|
-
// - That's why we name both StyleOptions the same
|
|
43
|
-
// - To use minimal, import 'botframework-webchat/lib/index-minimal';
|
|
44
|
-
// - Declarations need to be emitted to /lib/*.d.ts for code-splitting purpose
|
|
45
|
-
// - import 'botframework-webchat/lib/index-minimal' should see IntelliSense support
|
package/src/renderMarkdown.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/* eslint no-magic-numbers: ["error", { "ignore": [0, 1, 2] }] */
|
|
2
|
-
|
|
3
|
-
import iterator from 'markdown-it-for-inline';
|
|
4
|
-
import MarkdownIt from 'markdown-it';
|
|
5
|
-
import markdownItAttrs from 'markdown-it-attrs-es5';
|
|
6
|
-
import sanitizeHTML from 'sanitize-html';
|
|
7
|
-
|
|
8
|
-
const SANITIZE_HTML_OPTIONS = {
|
|
9
|
-
allowedAttributes: {
|
|
10
|
-
a: ['aria-label', 'href', 'name', 'rel', 'target', 'title'],
|
|
11
|
-
img: ['alt', 'class', 'src']
|
|
12
|
-
},
|
|
13
|
-
allowedSchemes: ['data', 'http', 'https', 'ftp', 'mailto', 'sip', 'tel'],
|
|
14
|
-
allowedTags: [
|
|
15
|
-
'a',
|
|
16
|
-
'b',
|
|
17
|
-
'blockquote',
|
|
18
|
-
'br',
|
|
19
|
-
'caption',
|
|
20
|
-
'code',
|
|
21
|
-
'del',
|
|
22
|
-
'div',
|
|
23
|
-
'em',
|
|
24
|
-
'h1',
|
|
25
|
-
'h2',
|
|
26
|
-
'h3',
|
|
27
|
-
'h4',
|
|
28
|
-
'h5',
|
|
29
|
-
'h6',
|
|
30
|
-
'hr',
|
|
31
|
-
'i',
|
|
32
|
-
'img',
|
|
33
|
-
'ins',
|
|
34
|
-
'li',
|
|
35
|
-
'nl',
|
|
36
|
-
'ol',
|
|
37
|
-
'p',
|
|
38
|
-
'pre',
|
|
39
|
-
's',
|
|
40
|
-
'span',
|
|
41
|
-
'strike',
|
|
42
|
-
'strong',
|
|
43
|
-
'table',
|
|
44
|
-
'tbody',
|
|
45
|
-
'td',
|
|
46
|
-
'tfoot',
|
|
47
|
-
'th',
|
|
48
|
-
'thead',
|
|
49
|
-
'tr',
|
|
50
|
-
'ul'
|
|
51
|
-
]
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
|
|
55
|
-
const TRANSPARENT_GIF = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
|
56
|
-
|
|
57
|
-
// This is used for parsing Markdown for external links.
|
|
58
|
-
const internalMarkdownIt = new MarkdownIt();
|
|
59
|
-
|
|
60
|
-
export default function render(markdown, { markdownRespectCRLF }, { externalLinkAlt = '' } = {}) {
|
|
61
|
-
if (markdownRespectCRLF) {
|
|
62
|
-
markdown = markdown.replace(/\n\r|\r\n/gu, carriageReturn => (carriageReturn === '\n\r' ? '\r\n' : '\n\r'));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const html = new MarkdownIt({
|
|
66
|
-
breaks: false,
|
|
67
|
-
html: false,
|
|
68
|
-
linkify: true,
|
|
69
|
-
typographer: true,
|
|
70
|
-
xhtmlOut: true
|
|
71
|
-
})
|
|
72
|
-
.use(markdownItAttrs)
|
|
73
|
-
.use(iterator, 'url_new_win', 'link_open', (tokens, index) => {
|
|
74
|
-
const token = tokens[index];
|
|
75
|
-
|
|
76
|
-
token.attrSet('rel', 'noopener noreferrer');
|
|
77
|
-
token.attrSet('target', '_blank');
|
|
78
|
-
|
|
79
|
-
const linkOpenToken = tokens.find(({ type }) => type === 'link_open');
|
|
80
|
-
const [, href] = linkOpenToken.attrs.find(([name]) => name === 'href');
|
|
81
|
-
|
|
82
|
-
// Adds a new icon if the link is http: or https:.
|
|
83
|
-
// Don't add if it's a phone number, etc.
|
|
84
|
-
if (/^https?:/iu.test(href)) {
|
|
85
|
-
externalLinkAlt && token.attrSet('title', externalLinkAlt);
|
|
86
|
-
|
|
87
|
-
const iconTokens = internalMarkdownIt.parseInline(``)[0].children;
|
|
88
|
-
|
|
89
|
-
iconTokens[0].attrJoin('class', 'webchat__markdown__external-link-icon');
|
|
90
|
-
|
|
91
|
-
tokens.splice(index + 2, 0, ...iconTokens);
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
.render(markdown);
|
|
95
|
-
|
|
96
|
-
return sanitizeHTML(html, SANITIZE_HTML_OPTIONS);
|
|
97
|
-
}
|