@botonic/react 0.24.0-alpha.3 → 0.24.0-alpha.4
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/lib/cjs/components/index-types.d.ts +1 -0
- package/lib/cjs/components/index-types.js.map +1 -1
- package/lib/cjs/components/{message.js → message/index.js} +20 -65
- package/lib/cjs/components/message/index.js.map +1 -0
- package/lib/cjs/components/message/message-image.d.ts +7 -0
- package/lib/cjs/components/message/message-image.js +18 -0
- package/lib/cjs/components/message/message-image.js.map +1 -0
- package/lib/cjs/components/message/styles.d.ts +8 -0
- package/lib/cjs/components/message/styles.js +69 -0
- package/lib/cjs/components/message/styles.js.map +1 -0
- package/lib/cjs/components/{timestamps.d.ts → message/timestamps.d.ts} +2 -1
- package/lib/cjs/components/message/timestamps.js +36 -0
- package/lib/cjs/components/message/timestamps.js.map +1 -0
- package/lib/cjs/constants.d.ts +1 -0
- package/lib/cjs/constants.js +2 -0
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/webchat/trigger-button/index.js +3 -2
- package/lib/cjs/webchat/trigger-button/index.js.map +1 -1
- package/lib/esm/app.d.ts +2 -0
- package/lib/esm/app.js +6 -0
- package/lib/esm/app.js.map +1 -0
- package/lib/esm/assets/index-types.d.ts +4 -0
- package/lib/esm/assets/index-types.js +2 -0
- package/lib/esm/assets/index-types.js.map +1 -0
- package/lib/esm/botonic-tester.d.ts +18 -0
- package/lib/esm/botonic-tester.js +62 -0
- package/lib/esm/botonic-tester.js.map +1 -0
- package/lib/esm/components/audio.d.ts +8 -0
- package/lib/esm/components/audio.js +18 -0
- package/lib/esm/components/audio.js.map +1 -0
- package/lib/esm/components/button.d.ts +15 -0
- package/lib/esm/components/button.js +140 -0
- package/lib/esm/components/button.js.map +1 -0
- package/lib/esm/components/buttons-disabler.d.ts +24 -0
- package/lib/esm/components/buttons-disabler.js +84 -0
- package/lib/esm/components/buttons-disabler.js.map +1 -0
- package/lib/esm/components/carousel.d.ts +10 -0
- package/lib/esm/components/carousel.js +102 -0
- package/lib/esm/components/carousel.js.map +1 -0
- package/lib/esm/components/components.d.ts +12 -0
- package/lib/esm/components/components.js +17 -0
- package/lib/esm/components/components.js.map +1 -0
- package/lib/esm/components/custom-message.d.ts +12 -0
- package/lib/esm/components/custom-message.js +55 -0
- package/lib/esm/components/custom-message.js.map +1 -0
- package/lib/esm/components/document.d.ts +8 -0
- package/lib/esm/components/document.js +42 -0
- package/lib/esm/components/document.js.map +1 -0
- package/lib/esm/components/element.d.ts +4 -0
- package/lib/esm/components/element.js +51 -0
- package/lib/esm/components/element.js.map +1 -0
- package/lib/esm/components/handoff.d.ts +1 -0
- package/lib/esm/components/handoff.js +49 -0
- package/lib/esm/components/handoff.js.map +1 -0
- package/lib/esm/components/image.d.ts +8 -0
- package/lib/esm/components/image.js +35 -0
- package/lib/esm/components/image.js.map +1 -0
- package/lib/esm/components/index-types.d.ts +190 -0
- package/lib/esm/components/index-types.js +16 -0
- package/lib/esm/components/index-types.js.map +1 -0
- package/lib/esm/components/index.d.ts +23 -0
- package/lib/esm/components/index.js +24 -0
- package/lib/esm/components/index.js.map +1 -0
- package/lib/esm/components/location.d.ts +11 -0
- package/lib/esm/components/location.js +27 -0
- package/lib/esm/components/location.js.map +1 -0
- package/lib/esm/components/markdown.d.ts +7 -0
- package/lib/esm/components/markdown.js +152 -0
- package/lib/esm/components/markdown.js.map +1 -0
- package/lib/esm/components/message/index.d.ts +1 -0
- package/lib/esm/components/message/index.js +143 -0
- package/lib/esm/components/message/index.js.map +1 -0
- package/lib/esm/components/message/message-image.d.ts +7 -0
- package/lib/esm/components/message/message-image.js +14 -0
- package/lib/esm/components/message/message-image.js.map +1 -0
- package/lib/esm/components/message/styles.d.ts +8 -0
- package/lib/esm/components/message/styles.js +65 -0
- package/lib/esm/components/message/styles.js.map +1 -0
- package/lib/esm/components/message/timestamps.d.ts +11 -0
- package/lib/esm/components/message/timestamps.js +30 -0
- package/lib/esm/components/message/timestamps.js.map +1 -0
- package/lib/esm/components/message-template.d.ts +1 -0
- package/lib/esm/components/message-template.js +9 -0
- package/lib/esm/components/message-template.js.map +1 -0
- package/lib/esm/components/multichannel/facebook/facebook.d.ts +17 -0
- package/lib/esm/components/multichannel/facebook/facebook.js +43 -0
- package/lib/esm/components/multichannel/facebook/facebook.js.map +1 -0
- package/lib/esm/components/multichannel/index-types.d.ts +46 -0
- package/lib/esm/components/multichannel/index-types.js +2 -0
- package/lib/esm/components/multichannel/index-types.js.map +1 -0
- package/lib/esm/components/multichannel/index.d.ts +11 -0
- package/lib/esm/components/multichannel/index.js +12 -0
- package/lib/esm/components/multichannel/index.js.map +1 -0
- package/lib/esm/components/multichannel/multichannel-button.d.ts +1 -0
- package/lib/esm/components/multichannel/multichannel-button.js +71 -0
- package/lib/esm/components/multichannel/multichannel-button.js.map +1 -0
- package/lib/esm/components/multichannel/multichannel-carousel.d.ts +1 -0
- package/lib/esm/components/multichannel/multichannel-carousel.js +73 -0
- package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -0
- package/lib/esm/components/multichannel/multichannel-context.d.ts +11 -0
- package/lib/esm/components/multichannel/multichannel-context.js +12 -0
- package/lib/esm/components/multichannel/multichannel-context.js.map +1 -0
- package/lib/esm/components/multichannel/multichannel-reply.d.ts +1 -0
- package/lib/esm/components/multichannel/multichannel-reply.js +20 -0
- package/lib/esm/components/multichannel/multichannel-reply.js.map +1 -0
- package/lib/esm/components/multichannel/multichannel-text.d.ts +1 -0
- package/lib/esm/components/multichannel/multichannel-text.js +153 -0
- package/lib/esm/components/multichannel/multichannel-text.js.map +1 -0
- package/lib/esm/components/multichannel/multichannel-utils.d.ts +26 -0
- package/lib/esm/components/multichannel/multichannel-utils.js +69 -0
- package/lib/esm/components/multichannel/multichannel-utils.js.map +1 -0
- package/lib/esm/components/multichannel/multichannel.d.ts +1 -0
- package/lib/esm/components/multichannel/multichannel.js +55 -0
- package/lib/esm/components/multichannel/multichannel.js.map +1 -0
- package/lib/esm/components/multichannel/whatsapp/markdown.d.ts +1 -0
- package/lib/esm/components/multichannel/whatsapp/markdown.js +53 -0
- package/lib/esm/components/multichannel/whatsapp/markdown.js.map +1 -0
- package/lib/esm/components/pic.d.ts +6 -0
- package/lib/esm/components/pic.js +25 -0
- package/lib/esm/components/pic.js.map +1 -0
- package/lib/esm/components/raw.d.ts +9 -0
- package/lib/esm/components/raw.js +39 -0
- package/lib/esm/components/raw.js.map +1 -0
- package/lib/esm/components/reply.d.ts +9 -0
- package/lib/esm/components/reply.js +49 -0
- package/lib/esm/components/reply.js.map +1 -0
- package/lib/esm/components/share-button.d.ts +1 -0
- package/lib/esm/components/share-button.js +9 -0
- package/lib/esm/components/share-button.js.map +1 -0
- package/lib/esm/components/subtitle.d.ts +6 -0
- package/lib/esm/components/subtitle.js +19 -0
- package/lib/esm/components/subtitle.js.map +1 -0
- package/lib/esm/components/text.d.ts +8 -0
- package/lib/esm/components/text.js +42 -0
- package/lib/esm/components/text.js.map +1 -0
- package/lib/esm/components/title.d.ts +6 -0
- package/lib/esm/components/title.js +17 -0
- package/lib/esm/components/title.js.map +1 -0
- package/lib/esm/components/video.d.ts +8 -0
- package/lib/esm/components/video.js +26 -0
- package/lib/esm/components/video.js.map +1 -0
- package/lib/esm/components/webchat-settings.d.ts +3 -0
- package/lib/esm/components/webchat-settings.js +69 -0
- package/lib/esm/components/webchat-settings.js.map +1 -0
- package/lib/esm/components/whatsapp-button-list.d.ts +17 -0
- package/lib/esm/components/whatsapp-button-list.js +22 -0
- package/lib/esm/components/whatsapp-button-list.js.map +1 -0
- package/lib/esm/components/whatsapp-template.d.ts +1 -0
- package/lib/esm/components/whatsapp-template.js +20 -0
- package/lib/esm/components/whatsapp-template.js.map +1 -0
- package/lib/esm/constants.d.ts +173 -0
- package/lib/esm/constants.js +194 -0
- package/lib/esm/constants.js.map +1 -0
- package/lib/esm/contexts.d.ts +12 -0
- package/lib/esm/contexts.js +67 -0
- package/lib/esm/contexts.js.map +1 -0
- package/lib/esm/dev-app.d.ts +30 -0
- package/lib/esm/dev-app.js +74 -0
- package/lib/esm/dev-app.js.map +1 -0
- package/lib/esm/index-types.d.ts +128 -0
- package/lib/esm/index-types.js +12 -0
- package/lib/esm/index-types.js.map +1 -0
- package/lib/esm/index.d.ts +11 -0
- package/lib/esm/index.js +12 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/message-utils.d.ts +19 -0
- package/lib/esm/message-utils.js +41 -0
- package/lib/esm/message-utils.js.map +1 -0
- package/lib/esm/msg-to-botonic.d.ts +18 -0
- package/lib/esm/msg-to-botonic.js +135 -0
- package/lib/esm/msg-to-botonic.js.map +1 -0
- package/lib/esm/node-app.d.ts +12 -0
- package/lib/esm/node-app.js +21 -0
- package/lib/esm/node-app.js.map +1 -0
- package/lib/esm/react-bot.d.ts +8 -0
- package/lib/esm/react-bot.js +29 -0
- package/lib/esm/react-bot.js.map +1 -0
- package/lib/esm/util/dom.d.ts +13 -0
- package/lib/esm/util/dom.js +46 -0
- package/lib/esm/util/dom.js.map +1 -0
- package/lib/esm/util/environment.d.ts +6 -0
- package/lib/esm/util/environment.js +61 -0
- package/lib/esm/util/environment.js.map +1 -0
- package/lib/esm/util/error-boundary.d.ts +7 -0
- package/lib/esm/util/error-boundary.js +28 -0
- package/lib/esm/util/error-boundary.js.map +1 -0
- package/lib/esm/util/index.d.ts +8 -0
- package/lib/esm/util/index.js +9 -0
- package/lib/esm/util/index.js.map +1 -0
- package/lib/esm/util/logs.d.ts +2 -0
- package/lib/esm/util/logs.js +15 -0
- package/lib/esm/util/logs.js.map +1 -0
- package/lib/esm/util/objects.d.ts +3 -0
- package/lib/esm/util/objects.js +38 -0
- package/lib/esm/util/objects.js.map +1 -0
- package/lib/esm/util/react.d.ts +12 -0
- package/lib/esm/util/react.js +34 -0
- package/lib/esm/util/react.js.map +1 -0
- package/lib/esm/util/regexs.d.ts +2 -0
- package/lib/esm/util/regexs.js +18 -0
- package/lib/esm/util/regexs.js.map +1 -0
- package/lib/esm/util/webchat.d.ts +11 -0
- package/lib/esm/util/webchat.js +53 -0
- package/lib/esm/util/webchat.js.map +1 -0
- package/lib/esm/webchat/actions.d.ts +27 -0
- package/lib/esm/webchat/actions.js +29 -0
- package/lib/esm/webchat/actions.js.map +1 -0
- package/lib/esm/webchat/components/attachment.d.ts +5 -0
- package/lib/esm/webchat/components/attachment.js +24 -0
- package/lib/esm/webchat/components/attachment.js.map +1 -0
- package/lib/esm/webchat/components/common.d.ts +1 -0
- package/lib/esm/webchat/components/common.js +9 -0
- package/lib/esm/webchat/components/common.js.map +1 -0
- package/lib/esm/webchat/components/conditional-animation.d.ts +1 -0
- package/lib/esm/webchat/components/conditional-animation.js +12 -0
- package/lib/esm/webchat/components/conditional-animation.js.map +1 -0
- package/lib/esm/webchat/components/emoji-picker.d.ts +5 -0
- package/lib/esm/webchat/components/emoji-picker.js +37 -0
- package/lib/esm/webchat/components/emoji-picker.js.map +1 -0
- package/lib/esm/webchat/components/persistent-menu.d.ts +10 -0
- package/lib/esm/webchat/components/persistent-menu.js +39 -0
- package/lib/esm/webchat/components/persistent-menu.js.map +1 -0
- package/lib/esm/webchat/components/send-button.d.ts +3 -0
- package/lib/esm/webchat/components/send-button.js +14 -0
- package/lib/esm/webchat/components/send-button.js.map +1 -0
- package/lib/esm/webchat/components/styled-scrollbar.d.ts +1 -0
- package/lib/esm/webchat/components/styled-scrollbar.js +50 -0
- package/lib/esm/webchat/components/styled-scrollbar.js.map +1 -0
- package/lib/esm/webchat/components/typing-indicator.d.ts +1 -0
- package/lib/esm/webchat/components/typing-indicator.js +6 -0
- package/lib/esm/webchat/components/typing-indicator.js.map +1 -0
- package/lib/esm/webchat/devices/device-adapter.d.ts +12 -0
- package/lib/esm/webchat/devices/device-adapter.js +43 -0
- package/lib/esm/webchat/devices/device-adapter.js.map +1 -0
- package/lib/esm/webchat/devices/index.d.ts +11 -0
- package/lib/esm/webchat/devices/index.js +18 -0
- package/lib/esm/webchat/devices/index.js.map +1 -0
- package/lib/esm/webchat/devices/scrollbar-controller.d.ts +12 -0
- package/lib/esm/webchat/devices/scrollbar-controller.js +99 -0
- package/lib/esm/webchat/devices/scrollbar-controller.js.map +1 -0
- package/lib/esm/webchat/devices/webchat-resizer.d.ts +9 -0
- package/lib/esm/webchat/devices/webchat-resizer.js +43 -0
- package/lib/esm/webchat/devices/webchat-resizer.js.map +1 -0
- package/lib/esm/webchat/header.d.ts +3 -0
- package/lib/esm/webchat/header.js +79 -0
- package/lib/esm/webchat/header.js.map +1 -0
- package/lib/esm/webchat/hooks/index.d.ts +5 -0
- package/lib/esm/webchat/hooks/index.js +6 -0
- package/lib/esm/webchat/hooks/index.js.map +1 -0
- package/lib/esm/webchat/hooks/use-component-visible.d.ts +8 -0
- package/lib/esm/webchat/hooks/use-component-visible.js +20 -0
- package/lib/esm/webchat/hooks/use-component-visible.js.map +1 -0
- package/lib/esm/webchat/hooks/use-component-will-mount.d.ts +1 -0
- package/lib/esm/webchat/hooks/use-component-will-mount.js +5 -0
- package/lib/esm/webchat/hooks/use-component-will-mount.js.map +1 -0
- package/lib/esm/webchat/hooks/use-previous.d.ts +1 -0
- package/lib/esm/webchat/hooks/use-previous.js +9 -0
- package/lib/esm/webchat/hooks/use-previous.js.map +1 -0
- package/lib/esm/webchat/hooks/use-typing.d.ts +10 -0
- package/lib/esm/webchat/hooks/use-typing.js +26 -0
- package/lib/esm/webchat/hooks/use-typing.js.map +1 -0
- package/lib/esm/webchat/hooks/use-webchat.d.ts +41 -0
- package/lib/esm/webchat/hooks/use-webchat.js +177 -0
- package/lib/esm/webchat/hooks/use-webchat.js.map +1 -0
- package/lib/esm/webchat/index-types.d.ts +62 -0
- package/lib/esm/webchat/index-types.js +2 -0
- package/lib/esm/webchat/index-types.js.map +1 -0
- package/lib/esm/webchat/index.d.ts +4 -0
- package/lib/esm/webchat/index.js +10 -0
- package/lib/esm/webchat/index.js.map +1 -0
- package/lib/esm/webchat/message-list/index.d.ts +1 -0
- package/lib/esm/webchat/message-list/index.js +73 -0
- package/lib/esm/webchat/message-list/index.js.map +1 -0
- package/lib/esm/webchat/message-list/intro-message.d.ts +1 -0
- package/lib/esm/webchat/message-list/intro-message.js +18 -0
- package/lib/esm/webchat/message-list/intro-message.js.map +1 -0
- package/lib/esm/webchat/message-list/scroll-button.d.ts +5 -0
- package/lib/esm/webchat/message-list/scroll-button.js +17 -0
- package/lib/esm/webchat/message-list/scroll-button.js.map +1 -0
- package/lib/esm/webchat/message-list/styles.d.ts +4 -0
- package/lib/esm/webchat/message-list/styles.js +46 -0
- package/lib/esm/webchat/message-list/styles.js.map +1 -0
- package/lib/esm/webchat/message-list/unread-messages-banner.d.ts +6 -0
- package/lib/esm/webchat/message-list/unread-messages-banner.js +16 -0
- package/lib/esm/webchat/message-list/unread-messages-banner.js.map +1 -0
- package/lib/esm/webchat/message-list/use-debounce.d.ts +1 -0
- package/lib/esm/webchat/message-list/use-debounce.js +14 -0
- package/lib/esm/webchat/message-list/use-debounce.js.map +1 -0
- package/lib/esm/webchat/messages-reducer.d.ts +6 -0
- package/lib/esm/webchat/messages-reducer.js +82 -0
- package/lib/esm/webchat/messages-reducer.js.map +1 -0
- package/lib/esm/webchat/replies.d.ts +1 -0
- package/lib/esm/webchat/replies.js +38 -0
- package/lib/esm/webchat/replies.js.map +1 -0
- package/lib/esm/webchat/session-view.d.ts +1 -0
- package/lib/esm/webchat/session-view.js +96 -0
- package/lib/esm/webchat/session-view.js.map +1 -0
- package/lib/esm/webchat/trigger-button/index.d.ts +1 -0
- package/lib/esm/webchat/trigger-button/index.js +28 -0
- package/lib/esm/webchat/trigger-button/index.js.map +1 -0
- package/lib/esm/webchat/trigger-button/styles.d.ts +3 -0
- package/lib/esm/webchat/trigger-button/styles.js +36 -0
- package/lib/esm/webchat/trigger-button/styles.js.map +1 -0
- package/lib/esm/webchat/use-storage-state-hook.d.ts +1 -0
- package/lib/esm/webchat/use-storage-state-hook.js +38 -0
- package/lib/esm/webchat/use-storage-state-hook.js.map +1 -0
- package/lib/esm/webchat/webchat-dev.d.ts +7 -0
- package/lib/esm/webchat/webchat-dev.js +56 -0
- package/lib/esm/webchat/webchat-dev.js.map +1 -0
- package/lib/esm/webchat/webchat-reducer.d.ts +6 -0
- package/lib/esm/webchat/webchat-reducer.js +46 -0
- package/lib/esm/webchat/webchat-reducer.js.map +1 -0
- package/lib/esm/webchat/webchat.d.ts +3 -0
- package/lib/esm/webchat/webchat.js +637 -0
- package/lib/esm/webchat/webchat.js.map +1 -0
- package/lib/esm/webchat/webview.d.ts +2 -0
- package/lib/esm/webchat/webview.js +78 -0
- package/lib/esm/webchat/webview.js.map +1 -0
- package/lib/esm/webchat-app.d.ts +99 -0
- package/lib/esm/webchat-app.js +281 -0
- package/lib/esm/webchat-app.js.map +1 -0
- package/lib/esm/webview-app.d.ts +7 -0
- package/lib/esm/webview-app.js +95 -0
- package/lib/esm/webview-app.js.map +1 -0
- package/package.json +2 -2
- package/src/.DS_Store +0 -0
- package/src/components/index-types.ts +1 -0
- package/src/components/{message.jsx → message/index.jsx} +32 -92
- package/src/components/message/message-image.tsx +52 -0
- package/src/components/message/styles.ts +73 -0
- package/src/components/message/timestamps.jsx +62 -0
- package/src/constants.js +2 -0
- package/src/webchat/trigger-button/index.tsx +10 -5
- package/lib/cjs/components/message.js.map +0 -1
- package/lib/cjs/components/timestamps.js +0 -51
- package/lib/cjs/components/timestamps.js.map +0 -1
- package/src/components/timestamps.jsx +0 -68
- /package/lib/cjs/components/{message.d.ts → message/index.d.ts} +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useContext, useState } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { COLORS } from '../constants';
|
|
5
|
+
import { WebchatContext } from '../contexts';
|
|
6
|
+
const Container = styled.div `
|
|
7
|
+
display: flex;
|
|
8
|
+
font-family: inherit;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
align-items: center;
|
|
12
|
+
padding: 24px;
|
|
13
|
+
`;
|
|
14
|
+
const TransferredContainer = styled.div `
|
|
15
|
+
text-align: center;
|
|
16
|
+
white-space: normal;
|
|
17
|
+
`;
|
|
18
|
+
const EndedContainer = styled.div `
|
|
19
|
+
text-align: center;
|
|
20
|
+
white-space: normal;
|
|
21
|
+
`;
|
|
22
|
+
const StyledButton = styled.button `
|
|
23
|
+
max-width: 60%;
|
|
24
|
+
padding: 12px 24px;
|
|
25
|
+
background-color: ${COLORS.SOLID_WHITE};
|
|
26
|
+
border: none;
|
|
27
|
+
border-radius: 4px;
|
|
28
|
+
margin-top: 8px;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
`;
|
|
31
|
+
export const Handoff = props => {
|
|
32
|
+
const { resolveCase } = useContext(WebchatContext);
|
|
33
|
+
const [state, setState] = useState({ showContinue: true });
|
|
34
|
+
const continueClick = () => {
|
|
35
|
+
setState({ showContinue: false });
|
|
36
|
+
resolveCase();
|
|
37
|
+
};
|
|
38
|
+
const bgColor = state.showContinue
|
|
39
|
+
? COLORS.FRINGY_FLOWER_GREEN
|
|
40
|
+
: COLORS.TASMAN_GRAY;
|
|
41
|
+
const fontColor = state.showContinue
|
|
42
|
+
? COLORS.APPLE_GREEN
|
|
43
|
+
: COLORS.CACTUS_GREEN;
|
|
44
|
+
return (_jsxs(Container, Object.assign({ style: {
|
|
45
|
+
color: fontColor,
|
|
46
|
+
backgroundColor: bgColor,
|
|
47
|
+
} }, { children: [state.showContinue ? (_jsx(TransferredContainer, { children: "Conversation transferred to a human agent..." })) : (_jsx(EndedContainer, { children: "Human handoff ended" })), state.showContinue && (_jsx(StyledButton, Object.assign({ onClick: continueClick }, { children: "Continue" })))] })));
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=handoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handoff.js","sourceRoot":"src/","sources":["components/handoff.jsx"],"names":[],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C,YAAY,CAAC,CAAC,CAAC,CACpB,KAAC,oBAAoB,+DAEE,CACxB,CAAC,CAAC,CAAC,CACF,KAAC,cAAc,sCAAqC,CACrD,EACA,KAAK,CAAC,YAAY,IAAI,CACrB,KAAC,YAAY,kBAAC,OAAO,EAAE,aAAa,8BAAyB,CAC9D,KACS,CACb,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { INPUT, isBrowser } from '@botonic/core';
|
|
3
|
+
import React, { useContext, useState } from 'react';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import { ROLES, WEBCHAT } from '../constants';
|
|
6
|
+
import { WebchatContext } from '../contexts';
|
|
7
|
+
import { staticAsset } from '../util/environment';
|
|
8
|
+
import { Message } from './message';
|
|
9
|
+
const StyledImage = styled.img `
|
|
10
|
+
border-radius: 8px;
|
|
11
|
+
max-width: 150px;
|
|
12
|
+
max-height: 150px;
|
|
13
|
+
margin: -3px -6px;
|
|
14
|
+
cursor: ${({ hasPreviewer }) => (hasPreviewer ? 'pointer' : 'auto')};
|
|
15
|
+
`;
|
|
16
|
+
const serialize = imageProps => {
|
|
17
|
+
return { image: imageProps.src };
|
|
18
|
+
};
|
|
19
|
+
export const Image = props => {
|
|
20
|
+
var _a;
|
|
21
|
+
props = ((_a = props.input) === null || _a === void 0 ? void 0 : _a.data)
|
|
22
|
+
? Object.assign(Object.assign({}, props), { src: props.input.data }) : Object.assign(Object.assign({}, props), { src: staticAsset(props.src) });
|
|
23
|
+
let content = props.children;
|
|
24
|
+
const [isPreviewerOpened, setIsPreviewerOpened] = useState(false);
|
|
25
|
+
const openPreviewer = () => setIsPreviewerOpened(true);
|
|
26
|
+
const closePreviewer = () => setIsPreviewerOpened(false);
|
|
27
|
+
const { getThemeProperty } = useContext(WebchatContext);
|
|
28
|
+
const ImagePreviewer = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.imagePreviewer, null);
|
|
29
|
+
if (isBrowser()) {
|
|
30
|
+
content = (_jsxs(_Fragment, { children: [_jsx(StyledImage, { src: props.src, onClick: openPreviewer, hasPreviewer: Boolean(ImagePreviewer) }), ImagePreviewer && (_jsx(ImagePreviewer, { src: props.src, isPreviewerOpened: isPreviewerOpened, openPreviewer: openPreviewer, closePreviewer: closePreviewer }))] }));
|
|
31
|
+
}
|
|
32
|
+
return (_jsx(Message, Object.assign({ role: ROLES.IMAGE_MESSAGE, json: serialize(props) }, props, { type: INPUT.IMAGE }, { children: content })));
|
|
33
|
+
};
|
|
34
|
+
Image.serialize = serialize;
|
|
35
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"src/","sources":["components/image.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACnD,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;YAKlB,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;CACpE,CAAA;AAED,MAAM,SAAS,GAAG,UAAU,CAAC,EAAE;IAC7B,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,GAAG,EAAE,CAAA;AAClC,CAAC,CAAA;AAED,MA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AEhB,OAAO,IACA,CACX,CAAA;AACH,CAAC,CAAA;AAED,KAAK,CAAC,SAAS,GAAG,SAAS,CAAA"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SENDERS } from '../index-types';
|
|
3
|
+
import { CoverComponentProps } from '../webchat/index-types';
|
|
4
|
+
export type MessageType = 'audio' | 'buttonmessage' | 'carousel' | 'custom' | 'document' | 'image' | 'location' | 'text' | 'video';
|
|
5
|
+
export interface MessageProps {
|
|
6
|
+
blob?: boolean;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
delay?: number;
|
|
9
|
+
enabletimestamps?: boolean;
|
|
10
|
+
sentBy?: SENDERS;
|
|
11
|
+
json?: Record<string, unknown>;
|
|
12
|
+
style?: Record<string, unknown>;
|
|
13
|
+
type?: MessageType;
|
|
14
|
+
typing?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface TextProps extends MessageProps {
|
|
17
|
+
markdown?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface Webview {
|
|
20
|
+
name: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ButtonProps {
|
|
23
|
+
params?: any;
|
|
24
|
+
path?: string;
|
|
25
|
+
payload?: string;
|
|
26
|
+
target?: string;
|
|
27
|
+
url?: string;
|
|
28
|
+
webview?: Webview;
|
|
29
|
+
onClick?: () => void;
|
|
30
|
+
autodisable?: boolean;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
disabledstyle?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface ReplyProps {
|
|
35
|
+
path?: string;
|
|
36
|
+
payload?: string;
|
|
37
|
+
children: string;
|
|
38
|
+
}
|
|
39
|
+
export interface PicProps {
|
|
40
|
+
src: string;
|
|
41
|
+
}
|
|
42
|
+
export type ImageProps = PicProps;
|
|
43
|
+
export interface TitleProps {
|
|
44
|
+
children: React.ReactNode;
|
|
45
|
+
style: string;
|
|
46
|
+
}
|
|
47
|
+
export type SubtitleProps = TitleProps;
|
|
48
|
+
export type CustomProp = {
|
|
49
|
+
custom?: React.ComponentType;
|
|
50
|
+
};
|
|
51
|
+
export type EnableProp = {
|
|
52
|
+
enable?: boolean;
|
|
53
|
+
};
|
|
54
|
+
export type ImageProp = {
|
|
55
|
+
image?: string;
|
|
56
|
+
};
|
|
57
|
+
export type PersistentMenuCloseOption = {
|
|
58
|
+
closeLabel: string;
|
|
59
|
+
};
|
|
60
|
+
export type PersistentMenuOption = {
|
|
61
|
+
label: string;
|
|
62
|
+
} & ButtonProps;
|
|
63
|
+
export type StyleProp = {
|
|
64
|
+
style?: any;
|
|
65
|
+
};
|
|
66
|
+
export type PersistentMenuTheme = (PersistentMenuCloseOption | PersistentMenuOption)[];
|
|
67
|
+
export interface PersistentMenuProps {
|
|
68
|
+
onClick: () => void;
|
|
69
|
+
options: any;
|
|
70
|
+
}
|
|
71
|
+
export type BlockInputOption = {
|
|
72
|
+
preprocess?: (message: string) => string;
|
|
73
|
+
match: RegExp[];
|
|
74
|
+
message: string;
|
|
75
|
+
};
|
|
76
|
+
export interface BlobProps {
|
|
77
|
+
blobTick?: boolean;
|
|
78
|
+
blobTickStyle?: any;
|
|
79
|
+
blobWidth?: string;
|
|
80
|
+
imageStyle?: any;
|
|
81
|
+
}
|
|
82
|
+
export interface ScrollbarProps {
|
|
83
|
+
autoHide?: boolean;
|
|
84
|
+
thumb?: {
|
|
85
|
+
bgcolor?: string;
|
|
86
|
+
border?: string;
|
|
87
|
+
color?: string;
|
|
88
|
+
opacity?: string;
|
|
89
|
+
};
|
|
90
|
+
track?: {
|
|
91
|
+
bgcolor?: string;
|
|
92
|
+
border?: string;
|
|
93
|
+
color?: string;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export interface ThemeProps extends StyleProp {
|
|
97
|
+
mobileBreakpoint?: number;
|
|
98
|
+
mobileStyle?: any;
|
|
99
|
+
webview?: StyleProp & {
|
|
100
|
+
header?: StyleProp;
|
|
101
|
+
};
|
|
102
|
+
animations?: EnableProp;
|
|
103
|
+
intro?: StyleProp & ImageProp & CustomProp;
|
|
104
|
+
brand?: {
|
|
105
|
+
color?: string;
|
|
106
|
+
} & ImageProp;
|
|
107
|
+
header?: {
|
|
108
|
+
title?: string;
|
|
109
|
+
subtitle?: string;
|
|
110
|
+
} & ImageProp & StyleProp & CustomProp;
|
|
111
|
+
message?: {
|
|
112
|
+
bot?: BlobProps & ImageProp & StyleProp;
|
|
113
|
+
agent?: ImageProp;
|
|
114
|
+
user?: BlobProps & StyleProp;
|
|
115
|
+
customTypes?: React.ComponentType[];
|
|
116
|
+
} & StyleProp & {
|
|
117
|
+
timestamps?: {
|
|
118
|
+
enable?: boolean;
|
|
119
|
+
format: () => string;
|
|
120
|
+
} & StyleProp;
|
|
121
|
+
};
|
|
122
|
+
button?: {
|
|
123
|
+
autodisable?: boolean;
|
|
124
|
+
disabledstyle?: any;
|
|
125
|
+
hoverBackground?: string;
|
|
126
|
+
hoverTextColor?: string;
|
|
127
|
+
messageType?: 'text' | 'payload';
|
|
128
|
+
} & StyleProp & CustomProp;
|
|
129
|
+
replies?: {
|
|
130
|
+
align?: 'left' | 'center' | 'right';
|
|
131
|
+
wrap?: 'wrap' | 'nowrap';
|
|
132
|
+
};
|
|
133
|
+
carousel?: {
|
|
134
|
+
arrow?: {
|
|
135
|
+
left: CustomProp;
|
|
136
|
+
right: CustomProp;
|
|
137
|
+
};
|
|
138
|
+
enableArrows?: boolean;
|
|
139
|
+
};
|
|
140
|
+
reply?: StyleProp & CustomProp;
|
|
141
|
+
triggerButton?: ImageProp & StyleProp & CustomProp;
|
|
142
|
+
notifications?: EnableProp & {
|
|
143
|
+
banner?: CustomProp & EnableProp & {
|
|
144
|
+
text?: string;
|
|
145
|
+
};
|
|
146
|
+
triggerButton?: EnableProp;
|
|
147
|
+
};
|
|
148
|
+
scrollButton?: EnableProp & CustomProp;
|
|
149
|
+
markdownStyle?: string;
|
|
150
|
+
scrollbar?: ScrollbarProps & EnableProp;
|
|
151
|
+
userInput?: {
|
|
152
|
+
attachments?: EnableProp & CustomProp;
|
|
153
|
+
blockInputs?: BlockInputOption[];
|
|
154
|
+
box?: {
|
|
155
|
+
placeholder: string;
|
|
156
|
+
} & StyleProp;
|
|
157
|
+
emojiPicker?: EnableProp & CustomProp;
|
|
158
|
+
menu?: {
|
|
159
|
+
darkBackground?: boolean;
|
|
160
|
+
} & {
|
|
161
|
+
custom?: React.ComponentType<PersistentMenuProps>;
|
|
162
|
+
};
|
|
163
|
+
menuButton?: CustomProp;
|
|
164
|
+
persistentMenu?: PersistentMenuTheme;
|
|
165
|
+
sendButton?: EnableProp & CustomProp;
|
|
166
|
+
} & EnableProp & StyleProp;
|
|
167
|
+
imagePreviewer?: React.ComponentType<ImagePreviewerProps>;
|
|
168
|
+
}
|
|
169
|
+
interface ImagePreviewerProps {
|
|
170
|
+
src: string;
|
|
171
|
+
isPreviewerOpened: boolean;
|
|
172
|
+
closePreviewer: () => void;
|
|
173
|
+
}
|
|
174
|
+
export interface CoverComponentOptions {
|
|
175
|
+
component: React.ComponentType<CoverComponentProps>;
|
|
176
|
+
props?: any;
|
|
177
|
+
}
|
|
178
|
+
export interface WebchatSettingsProps {
|
|
179
|
+
blockInputs?: BlockInputOption[];
|
|
180
|
+
enableAnimations?: boolean;
|
|
181
|
+
enableAttachments?: boolean;
|
|
182
|
+
enableEmojiPicker?: boolean;
|
|
183
|
+
enableUserInput?: boolean;
|
|
184
|
+
persistentMenu?: PersistentMenuTheme;
|
|
185
|
+
theme?: ThemeProps;
|
|
186
|
+
}
|
|
187
|
+
export type WrappedComponent<Props> = React.FunctionComponent<Props> & {
|
|
188
|
+
customTypeName: string;
|
|
189
|
+
};
|
|
190
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
// TODO: Reuse types to be typed in respective functions
|
|
3
|
+
// export class ErrorBoundary<Props> extends React.Component<Props> {
|
|
4
|
+
// componentDidCatch(error: Error, errorInfo: ErrorInfo): void
|
|
5
|
+
// }
|
|
6
|
+
// export function createErrorBoundary<Props>(_?: {
|
|
7
|
+
// errorComponent: React.ComponentType
|
|
8
|
+
// }): ErrorBoundary<Props>
|
|
9
|
+
// export function customMessage<Props>(_: {
|
|
10
|
+
// name: string
|
|
11
|
+
// component: React.ComponentType<Props>
|
|
12
|
+
// defaultProps?: Record<string, unknown>
|
|
13
|
+
// errorBoundary?: ErrorBoundary<Props>
|
|
14
|
+
// }): WrappedComponent<Props>
|
|
15
|
+
// export function getDisplayName(component: React.ComponentType): string
|
|
16
|
+
//# sourceMappingURL=index-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-types.js","sourceRoot":"src/","sources":["components/index-types.ts"],"names":[],"mappings":";AA4MA,wDAAwD;AACxD,qEAAqE;AACrE,gEAAgE;AAChE,IAAI;AAEJ,mDAAmD;AACnD,wCAAwC;AACxC,2BAA2B;AAE3B,4CAA4C;AAC5C,iBAAiB;AACjB,0CAA0C;AAC1C,2CAA2C;AAC3C,yCAAyC;AACzC,8BAA8B;AAE9B,yEAAyE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { Audio } from './audio';
|
|
2
|
+
export { Button } from './button';
|
|
3
|
+
export { Carousel } from './carousel';
|
|
4
|
+
export { customMessage } from './custom-message';
|
|
5
|
+
export { Document } from './document';
|
|
6
|
+
export { Element } from './element';
|
|
7
|
+
export { Image } from './image';
|
|
8
|
+
export * from './index-types';
|
|
9
|
+
export { Location } from './location';
|
|
10
|
+
export { Message } from './message';
|
|
11
|
+
export { MessageTemplate } from './message-template';
|
|
12
|
+
export * from './multichannel';
|
|
13
|
+
export { Pic } from './pic';
|
|
14
|
+
export { Raw } from './raw';
|
|
15
|
+
export { Reply } from './reply';
|
|
16
|
+
export { ShareButton } from './share-button';
|
|
17
|
+
export { Subtitle } from './subtitle';
|
|
18
|
+
export { Text } from './text';
|
|
19
|
+
export { Title } from './title';
|
|
20
|
+
export { Video } from './video';
|
|
21
|
+
export { WebchatSettings } from './webchat-settings';
|
|
22
|
+
export { WhatsappButtonList, WhatsappButtonListProps, WhatsappButtonListRowProps, WhatsappButtonListSectionProps, } from './whatsapp-button-list';
|
|
23
|
+
export { WhatsappTemplate } from './whatsapp-template';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export { Audio } from './audio';
|
|
2
|
+
export { Button } from './button';
|
|
3
|
+
export { Carousel } from './carousel';
|
|
4
|
+
export { customMessage } from './custom-message';
|
|
5
|
+
export { Document } from './document';
|
|
6
|
+
export { Element } from './element';
|
|
7
|
+
export { Image } from './image';
|
|
8
|
+
export * from './index-types';
|
|
9
|
+
export { Location } from './location';
|
|
10
|
+
export { Message } from './message';
|
|
11
|
+
export { MessageTemplate } from './message-template';
|
|
12
|
+
export * from './multichannel';
|
|
13
|
+
export { Pic } from './pic';
|
|
14
|
+
export { Raw } from './raw';
|
|
15
|
+
export { Reply } from './reply';
|
|
16
|
+
export { ShareButton } from './share-button';
|
|
17
|
+
export { Subtitle } from './subtitle';
|
|
18
|
+
export { Text } from './text';
|
|
19
|
+
export { Title } from './title';
|
|
20
|
+
export { Video } from './video';
|
|
21
|
+
export { WebchatSettings } from './webchat-settings';
|
|
22
|
+
export { WhatsappButtonList, } from './whatsapp-button-list';
|
|
23
|
+
export { WhatsappTemplate } from './whatsapp-template';
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EACL,kBAAkB,GAInB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { INPUT } from '@botonic/core';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import { renderComponent } from '../util/react';
|
|
6
|
+
import { Message } from './message';
|
|
7
|
+
const Link = styled.a `
|
|
8
|
+
text-decoration: none;
|
|
9
|
+
font-weight: bold;
|
|
10
|
+
target: blank;
|
|
11
|
+
`;
|
|
12
|
+
const serialize = locationProps => {
|
|
13
|
+
return { location: { lat: locationProps.lat, long: locationProps.long } };
|
|
14
|
+
};
|
|
15
|
+
export const Location = props => {
|
|
16
|
+
const { lat, long } = props;
|
|
17
|
+
const renderBrowser = () => {
|
|
18
|
+
const locationUrl = `https://www.google.com/maps/search/?api=1&query=${lat},${long}`;
|
|
19
|
+
return (_jsx(Message, Object.assign({ json: serialize(props) }, props, { type: INPUT.LOCATION }, { children: _jsx(Link, Object.assign({ href: locationUrl, target: '_blank', rel: 'noopener noreferrer' }, { children: props.text || 'Open Location' })) })));
|
|
20
|
+
};
|
|
21
|
+
const renderNode = () => {
|
|
22
|
+
return (_jsxs("message", Object.assign({ type: INPUT.LOCATION }, { children: [_jsx("lat", { children: lat }), _jsx("long", { children: long })] })));
|
|
23
|
+
};
|
|
24
|
+
return renderComponent({ renderBrowser, renderNode });
|
|
25
|
+
};
|
|
26
|
+
Location.serialize = serialize;
|
|
27
|
+
//# sourceMappingURL=location.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"location.js","sourceRoot":"src/","sources":["components/location.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAA;;;;CAIpB,CAAA;AAED,MAAM,SAAS,GAAG,aAAa,CAAC,EAAE;IAChC,OAAO,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE,EAAE,CAAA;AAC3E,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC,EAAE;IAC9B,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,CAAA;IAE3B,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,MAAM,WAAW,GAAG,mDAAmD,GAAG,IAAI,IAAI,EAAE,CAAA;QACpF,OAAO,CACL,KAAC,OAAO,kBAAC,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,IAAM,KAAK,IAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,gBAC9D,KAAC,IAAI,kBAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAC,QAAQ,EAAC,GAAG,EAAC,qBAAqB,gBAC/D,KAAK,CAAC,IAAI,IAAI,eAAe,IACzB,IACC,CACX,CAAA;IACH,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,OAAO,CACL,iCAAS,IAAI,EAAE,KAAK,CAAC,QAAQ,iBAC3B,wBAAM,GAAG,GAAO,EAChB,yBAAO,IAAI,GAAQ,KACX,CACX,CAAA;IACH,CAAC,CAAA;IAED,OAAO,eAAe,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAA;AACvD,CAAC,CAAA;AAED,QAAQ,CAAC,SAAS,GAAG,SAAS,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const ESCAPED_LINE_BREAK: "<br>";
|
|
2
|
+
export function renderMarkdown(text: any): any;
|
|
3
|
+
export function renderLinks(text: any): any;
|
|
4
|
+
export function serializeMarkdown(children: any): any;
|
|
5
|
+
export function toMarkdownChildren(children: any): any;
|
|
6
|
+
export function getMarkdownStyle(getThemeFn: any, defaultColor: any): any;
|
|
7
|
+
export function getDefaultMarkdownStyle(color: any): string;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import MarkdownIt from 'markdown-it';
|
|
2
|
+
const BR_STRING_TAG = '<br/>';
|
|
3
|
+
const BR_STRING_TAG_REGEX = new RegExp('<br\\s*/?>', 'g');
|
|
4
|
+
export const ESCAPED_LINE_BREAK = '<br>';
|
|
5
|
+
const ESCAPED_LINE_BREAK_REGEX = new RegExp(ESCAPED_LINE_BREAK, 'g');
|
|
6
|
+
const isLineBreakElement = element => element.type === 'br';
|
|
7
|
+
const withLinksTarget = (renderer, target = '_blank') => {
|
|
8
|
+
// Support opening links in new tabs: https://github.com/markdown-it/markdown-it/blob/master/docs/architecture.md#renderer
|
|
9
|
+
const newRenderer = renderer.renderer.rules.link_open ||
|
|
10
|
+
function (tokens, idx, options, env, self) {
|
|
11
|
+
return self.renderToken(tokens, idx, options);
|
|
12
|
+
};
|
|
13
|
+
renderer.renderer.rules.link_open = function (tokens, idx, options, env, self) {
|
|
14
|
+
const aIndex = tokens[idx].attrIndex('target');
|
|
15
|
+
if (aIndex < 0)
|
|
16
|
+
tokens[idx].attrPush(['target', target]);
|
|
17
|
+
else
|
|
18
|
+
tokens[idx].attrs[aIndex][1] = target;
|
|
19
|
+
return newRenderer(tokens, idx, options, env, self);
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const configureLinksRenderer = () => {
|
|
23
|
+
// zero preset comes with all options disabled, only enabling links
|
|
24
|
+
const linksRenderer = new MarkdownIt('zero', { linkify: true }).enable([
|
|
25
|
+
'linkify',
|
|
26
|
+
]);
|
|
27
|
+
withLinksTarget(linksRenderer);
|
|
28
|
+
return linksRenderer;
|
|
29
|
+
};
|
|
30
|
+
const configureMarkdownRenderer = () => {
|
|
31
|
+
const markdownRenderer = new MarkdownIt({
|
|
32
|
+
html: true,
|
|
33
|
+
linkify: true,
|
|
34
|
+
typographer: true,
|
|
35
|
+
});
|
|
36
|
+
withLinksTarget(markdownRenderer);
|
|
37
|
+
return markdownRenderer;
|
|
38
|
+
};
|
|
39
|
+
const markdownRenderer = configureMarkdownRenderer();
|
|
40
|
+
export const renderMarkdown = text => {
|
|
41
|
+
// markdown-it renderer expects '<br/>' strings to render correctly line breaks
|
|
42
|
+
// Supporting multiline: https://stackoverflow.com/a/20543835
|
|
43
|
+
text = text
|
|
44
|
+
.map(e => {
|
|
45
|
+
if (isLineBreakElement(e))
|
|
46
|
+
return BR_STRING_TAG;
|
|
47
|
+
else if (typeof e === 'string')
|
|
48
|
+
return e
|
|
49
|
+
.replace(BR_STRING_TAG_REGEX, BR_STRING_TAG)
|
|
50
|
+
.replace(ESCAPED_LINE_BREAK_REGEX, BR_STRING_TAG);
|
|
51
|
+
else
|
|
52
|
+
return String(e);
|
|
53
|
+
})
|
|
54
|
+
.join('');
|
|
55
|
+
return markdownRenderer.render(text);
|
|
56
|
+
};
|
|
57
|
+
const linksRenderer = configureLinksRenderer();
|
|
58
|
+
export const renderLinks = text => {
|
|
59
|
+
return linksRenderer.render(text);
|
|
60
|
+
};
|
|
61
|
+
export const serializeMarkdown = children => {
|
|
62
|
+
children = Array.isArray(children) ? children : [children];
|
|
63
|
+
const text = children
|
|
64
|
+
.filter(e => isLineBreakElement(e) || !e.type)
|
|
65
|
+
.map(e => {
|
|
66
|
+
if (Array.isArray(e))
|
|
67
|
+
return serializeMarkdown(e);
|
|
68
|
+
if (isLineBreakElement(e))
|
|
69
|
+
return ESCAPED_LINE_BREAK;
|
|
70
|
+
else
|
|
71
|
+
return String(e).replace(BR_STRING_TAG_REGEX, ESCAPED_LINE_BREAK);
|
|
72
|
+
})
|
|
73
|
+
.join('');
|
|
74
|
+
return text;
|
|
75
|
+
};
|
|
76
|
+
export const toMarkdownChildren = children => children.map(e => (isLineBreakElement(e) ? ESCAPED_LINE_BREAK : e));
|
|
77
|
+
export const getMarkdownStyle = (getThemeFn, defaultColor) => getThemeFn('markdownStyle', getDefaultMarkdownStyle(defaultColor));
|
|
78
|
+
export const getDefaultMarkdownStyle = color => `
|
|
79
|
+
*{
|
|
80
|
+
margin: 0px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
a {
|
|
84
|
+
text-decoration:none;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
a:link{
|
|
88
|
+
color:${color};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
a:visited {
|
|
92
|
+
color:${color};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
a:hover {
|
|
96
|
+
text-shadow: 0px 1px black;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
blockquote {
|
|
100
|
+
margin: 0;
|
|
101
|
+
padding-left: 1.4rem;
|
|
102
|
+
border-left: 4px solid #dadada;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
pre code {
|
|
106
|
+
margin: 0;
|
|
107
|
+
padding: 0;
|
|
108
|
+
white-space: pre;
|
|
109
|
+
border: none;
|
|
110
|
+
background: transparent;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
pre {
|
|
114
|
+
background-color: #f8f8f8;
|
|
115
|
+
border: 1px solid #cccccc;
|
|
116
|
+
font-size: 13px;
|
|
117
|
+
line-height: 19px;
|
|
118
|
+
overflow: auto;
|
|
119
|
+
padding: 6px 10px;
|
|
120
|
+
border-radius: 3px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
code, tt {
|
|
124
|
+
margin: 0 2px;
|
|
125
|
+
padding: 0 5px;
|
|
126
|
+
white-space: nowrap;
|
|
127
|
+
border: 1px solid #eaeaea;
|
|
128
|
+
background-color: #f8f8f8;
|
|
129
|
+
border-radius: 3px;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
pre {
|
|
133
|
+
background-color: #f8f8f8;
|
|
134
|
+
border: 1px solid #cccccc;
|
|
135
|
+
font-size: 13px;
|
|
136
|
+
line-height: 19px;
|
|
137
|
+
overflow: auto;
|
|
138
|
+
padding: 6px 10px;
|
|
139
|
+
border-radius: 3px;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
pre code, pre tt {
|
|
143
|
+
background-color: transparent;
|
|
144
|
+
border: none;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
table, td, th {
|
|
148
|
+
border: 1px solid black;
|
|
149
|
+
padding:10px;
|
|
150
|
+
}
|
|
151
|
+
`;
|
|
152
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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