@azure/communication-react 1.15.0-alpha-202404050013 → 1.15.0-alpha-202404060012
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/communication-react.d.ts +12 -2
- package/dist/dist-cjs/communication-react/{ChatMessageComponentAsRichTextEditBox-B3cXye-F.js → ChatMessageComponentAsRichTextEditBox-CLkmWBpD.js} +18 -12
- package/dist/dist-cjs/communication-react/ChatMessageComponentAsRichTextEditBox-CLkmWBpD.js.map +1 -0
- package/dist/dist-cjs/communication-react/{index-C4BFVPuO.js → index-CeUuqiwO.js} +126 -50
- package/dist/dist-cjs/communication-react/index-CeUuqiwO.js.map +1 -0
- package/dist/dist-cjs/communication-react/index.js +1 -1
- package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js +1 -1
- package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/AttachmentCard.js +5 -5
- package/dist/dist-esm/react-components/src/components/AttachmentCard.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/AttachmentUploadCards.d.ts +2 -0
- package/dist/dist-esm/react-components/src/components/AttachmentUploadCards.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/{ChatMessageComponentAsEditBox.d.ts → MyMessageComponents/ChatMessageComponentAsEditBox.d.ts} +4 -4
- package/dist/dist-esm/react-components/src/components/ChatMessage/{ChatMessageComponentAsEditBox.js → MyMessageComponents/ChatMessageComponentAsEditBox.js} +11 -11
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBox.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBoxPicker.js +2 -2
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBoxPicker.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/{ChatMessageComponentAsRichTextEditBox.d.ts → MyMessageComponents/ChatMessageComponentAsRichTextEditBox.d.ts} +5 -5
- package/dist/dist-esm/react-components/src/components/ChatMessage/{ChatMessageComponentAsRichTextEditBox.js → MyMessageComponents/ChatMessageComponentAsRichTextEditBox.js} +35 -24
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.js.map +1 -0
- package/dist/dist-esm/react-components/src/components/EndCallButton.js +16 -3
- package/dist/dist-esm/react-components/src/components/EndCallButton.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/insertTableAction.js +14 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/insertTableAction.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextEditor.d.ts +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextEditor.js +24 -4
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextEditor.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextInputBoxComponent.d.ts +1 -0
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextInputBoxComponent.js +2 -2
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextInputBoxComponent.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js +10 -2
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/SendBox.d.ts +4 -0
- package/dist/dist-esm/react-components/src/components/SendBox.js +5 -3
- package/dist/dist-esm/react-components/src/components/SendBox.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/index.d.ts +2 -2
- package/dist/dist-esm/react-components/src/components/index.js +1 -1
- package/dist/dist-esm/react-components/src/components/index.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/AttachmentCard.styles.js +3 -2
- package/dist/dist-esm/react-components/src/components/styles/AttachmentCard.styles.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/MessageThread.styles.js +3 -1
- package/dist/dist-esm/react-components/src/components/styles/MessageThread.styles.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/RichTextEditor.styles.js +8 -3
- package/dist/dist-esm/react-components/src/components/styles/RichTextEditor.styles.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/utils/common.d.ts +1 -1
- package/dist/dist-esm/react-components/src/components/utils/common.js +3 -2
- package/dist/dist-esm/react-components/src/components/utils/common.js.map +1 -1
- package/dist/dist-esm/react-components/src/localization/locales/en-US/strings.json +5 -3
- package/dist/dist-esm/react-components/src/theming/icons.d.ts +1 -0
- package/dist/dist-esm/react-components/src/theming/icons.js +2 -0
- package/dist/dist-esm/react-components/src/theming/icons.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/Strings.d.ts +6 -2
- package/dist/dist-esm/react-composites/src/composites/CallComposite/Strings.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/Prompt.d.ts +2 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/Prompt.js +4 -2
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/Prompt.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/buttons/EndCall.js +26 -21
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/buttons/EndCall.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/icons.d.ts +1 -0
- package/dist/dist-esm/react-composites/src/composites/localization/locales/en-US/strings.json +2 -1
- package/package.json +1 -1
- package/dist/dist-cjs/communication-react/ChatMessageComponentAsRichTextEditBox-B3cXye-F.js.map +0 -1
- package/dist/dist-cjs/communication-react/index-C4BFVPuO.js.map +0 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentAsEditBox.js.map +0 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentAsRichTextEditBox.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"telemetryVersion.js","sourceRoot":"","sources":["../../../../../acs-ui-common/src/telemetryVersion.js"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;AAElC,wCAAwC;AAExC,MAAM,CAAC,OAAO,GAAG,2BAA2B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// GENERATED FILE. DO NOT EDIT MANUALLY.\n\nmodule.exports = '1.15.0-alpha-
|
1
|
+
{"version":3,"file":"telemetryVersion.js","sourceRoot":"","sources":["../../../../../acs-ui-common/src/telemetryVersion.js"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;AAElC,wCAAwC;AAExC,MAAM,CAAC,OAAO,GAAG,2BAA2B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// GENERATED FILE. DO NOT EDIT MANUALLY.\n\nmodule.exports = '1.15.0-alpha-202404060012';\n"]}
|
@@ -18,7 +18,6 @@ import React from 'react';
|
|
18
18
|
import { Announcer } from './Announcer';
|
19
19
|
import { useEffect, useState, useMemo } from 'react';
|
20
20
|
import { useLocaleAttachmentCardStringsTrampoline } from './utils/common';
|
21
|
-
import { MoreHorizontal24Filled } from '@fluentui/react-icons';
|
22
21
|
import { useAttachmentCardStyles, attachmentNameContainerClassName } from './styles/AttachmentCard.styles';
|
23
22
|
/**
|
24
23
|
* @internal
|
@@ -54,7 +53,7 @@ export const _AttachmentCard = (props) => {
|
|
54
53
|
}, [progress, showProgressIndicator, attachment.name, uploadStartedString, uploadCompletedString]);
|
55
54
|
return (React.createElement("div", { "data-is-focusable": true },
|
56
55
|
React.createElement(Announcer, { announcementString: announcerString, ariaLive: 'polite' }),
|
57
|
-
React.createElement(Card, { className: attachmentCardStyles.root, size: "small", role: "listitem" },
|
56
|
+
React.createElement(Card, { className: attachmentCardStyles.root, size: "small", role: "listitem", appearance: "filled-alternative", "aria-label": attachment.name },
|
58
57
|
React.createElement(CardHeader, { image: React.createElement(Icon, { "data-ui-id": 'attachmenttype-icon', iconName: getFileTypeIconProps({
|
59
58
|
extension: useMemo(() => {
|
60
59
|
var _a, _b;
|
@@ -63,11 +62,12 @@ export const _AttachmentCard = (props) => {
|
|
63
62
|
size: 24,
|
64
63
|
imageFileType: 'svg'
|
65
64
|
}).iconName }), header: React.createElement("div", { className: attachmentNameContainerClassName },
|
66
|
-
React.createElement(Text, { title: attachment.name }, attachment.name)), action:
|
65
|
+
React.createElement(Text, { title: attachment.name }, attachment.name)), action: MappedMenuItems(menuActions, attachment, onActionHandlerFailed) })),
|
67
66
|
isUploadComplete ? (React.createElement(CardFooter, null,
|
68
67
|
React.createElement(ProgressBar, { thickness: "medium", value: progress, shape: "rounded" }))) : (React.createElement(React.Fragment, null, " "))));
|
69
68
|
};
|
70
|
-
const
|
69
|
+
const MappedMenuItems = (menuActions, attachment, handleOnClickError) => {
|
70
|
+
const localeStrings = useLocaleAttachmentCardStringsTrampoline();
|
71
71
|
if (menuActions.length === 0) {
|
72
72
|
return React.createElement(React.Fragment, null);
|
73
73
|
}
|
@@ -81,7 +81,7 @@ const getMenuItems = (menuActions, attachment, handleOnClickError) => {
|
|
81
81
|
} })) : (React.createElement(Toolbar, null,
|
82
82
|
React.createElement(Menu, null,
|
83
83
|
React.createElement(MenuTrigger, null,
|
84
|
-
React.createElement(ToolbarButton, {
|
84
|
+
React.createElement(ToolbarButton, { icon: React.createElement(Icon, { iconName: "AttachmentMoreMenu", "aria-label": localeStrings.attachmentMoreMenu }) })),
|
85
85
|
React.createElement(MenuPopover, null,
|
86
86
|
React.createElement(MenuList, null, menuActions.map((menuItem, index) => (React.createElement(MenuItem, { key: index, icon: menuItem.icon, onClick: () => __awaiter(void 0, void 0, void 0, function* () {
|
87
87
|
try {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AttachmentCard.js","sourceRoot":"","sources":["../../../../../../react-components/src/components/AttachmentCard.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;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,OAAO,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC,GACD,CACH,CAAC,CAAC,CAAC,CACF,oBAAC,OAAO;QACN,oBAAC,IAAI;YACH,oBAAC,WAAW;gBACV,oBAAC,aAAa,kBAAY,MAAM,EAAC,IAAI,EAAE,oBAAC,sBAAsB,OAAG,GAAI,CACzD;YACd,oBAAC,WAAW;gBACV,oBAAC,QAAQ,QACN,WAAW,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,CACpC,oBAAC,QAAQ,IACP,GAAG,EAAE,KAAK,EACV,IAAI,EAAE,QAAQ,CAAC,IAAI,EACnB,OAAO,EAAE,GAAS,EAAE;wBAClB,IAAI,CAAC;4BACH,MAAM,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;wBACrC,CAAC;wBAAC,OAAO,CAAC,EAAE,CAAC;4BACX,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAI,CAAW,CAAC,OAAO,CAAC,CAAC;wBAC7C,CAAC;oBACH,CAAC,CAAA,IAEA,QAAQ,CAAC,IAAI,CACL,CACZ,CAAC,CACO,CACC,CACT,CACC,CACX,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n // eslint-disable-next-line no-restricted-imports\n Icon\n} from '@fluentui/react';\nimport {\n Card,\n CardHeader,\n Text,\n Menu,\n MenuTrigger,\n ToolbarButton,\n MenuPopover,\n MenuItem,\n MenuList,\n Toolbar,\n CardFooter,\n ProgressBar\n} from '@fluentui/react-components';\nimport { getFileTypeIconProps } from '@fluentui/react-file-type-icons';\nimport React from 'react';\nimport { _pxToRem } from '@internal/acs-ui-common';\nimport { Announcer } from './Announcer';\nimport { useEffect, useState, useMemo } from 'react';\nimport { _AttachmentUploadCardsStrings } from './AttachmentUploadCards';\nimport { useLocaleAttachmentCardStringsTrampoline } from './utils/common';\nimport { AttachmentMetadata, AttachmentMenuAction } from '../types/Attachment';\nimport { MoreHorizontal24Filled } from '@fluentui/react-icons';\nimport { useAttachmentCardStyles, attachmentNameContainerClassName } from './styles/AttachmentCard.styles';\n\n/**\n * @internal\n * AttachmentCard Component Props.\n */\nexport interface _AttachmentCardProps {\n /**\n * Attachment details including name, extension, url, etc.\n */\n attachment: AttachmentMetadata;\n /**\n * An array of menu actions to be displayed in the attachment card.\n */\n menuActions: AttachmentMenuAction[];\n /**\n * Optional aria label strings for attachment upload cards\n */\n strings?: _AttachmentUploadCardsStrings;\n /**\n * Optional callback that runs if menu bar action onclick throws.\n */\n onActionHandlerFailed?: (errMsg: string) => void;\n}\n\n/**\n * @internal\n * A component for displaying an attachment card with attachment icon and progress bar.\n *\n * `_AttachmentCard` internally uses the `Card` component from `@fluentui/react-components`. You can checkout the details about these components [here](https://react.fluentui.dev/?path=/docs/components-card).\n */\nexport const _AttachmentCard = (props: _AttachmentCardProps): JSX.Element => {\n const { attachment, menuActions, onActionHandlerFailed } = props;\n const attachmentCardStyles = useAttachmentCardStyles();\n const progress = useMemo(() => {\n return attachment.progress;\n }, [attachment.progress]);\n const isUploadComplete = useMemo(() => {\n return progress !== undefined && progress > 0 && progress < 1;\n }, [progress]);\n\n const [announcerString, setAnnouncerString] = useState<string | undefined>(undefined);\n const localeStrings = useLocaleAttachmentCardStringsTrampoline();\n const uploadStartedString = props.strings?.uploading ?? localeStrings.uploading;\n const uploadCompletedString = props.strings?.uploadCompleted ?? localeStrings.uploadCompleted;\n\n const showProgressIndicator = progress !== undefined && progress > 0 && progress < 1;\n\n useEffect(() => {\n if (showProgressIndicator) {\n setAnnouncerString(`${uploadStartedString} ${attachment.name}`);\n } else if (progress === 1) {\n setAnnouncerString(`${attachment.name} ${uploadCompletedString}`);\n } else {\n setAnnouncerString(undefined);\n }\n }, [progress, showProgressIndicator, attachment.name, uploadStartedString, uploadCompletedString]);\n\n return (\n <div data-is-focusable={true}>\n <Announcer announcementString={announcerString} ariaLive={'polite'} />\n <Card className={attachmentCardStyles.root} size=\"small\" role=\"listitem\">\n <CardHeader\n image={\n <Icon\n data-ui-id={'attachmenttype-icon'}\n iconName={\n getFileTypeIconProps({\n extension: useMemo((): string => {\n return attachment.extension ?? attachment.name.split('.').pop() ?? '';\n }, [attachment]),\n size: 24,\n imageFileType: 'svg'\n }).iconName\n }\n />\n }\n header={\n <div className={attachmentNameContainerClassName}>\n <Text title={attachment.name}>{attachment.name}</Text>\n </div>\n }\n action={getMenuItems(menuActions, attachment, onActionHandlerFailed)}\n />\n </Card>\n {isUploadComplete ? (\n <CardFooter>\n <ProgressBar thickness=\"medium\" value={progress} shape=\"rounded\" />\n </CardFooter>\n ) : (\n <> </>\n )}\n </div>\n );\n};\n\nconst getMenuItems = (\n menuActions: AttachmentMenuAction[],\n attachment: AttachmentMetadata,\n handleOnClickError?: (errMsg: string) => void\n): JSX.Element => {\n if (menuActions.length === 0) {\n return <></>;\n }\n return menuActions.length === 1 ? (\n <ToolbarButton\n aria-label={menuActions[0].name}\n icon={menuActions[0].icon}\n onClick={() => {\n try {\n menuActions[0].onClick(attachment);\n } catch (e) {\n handleOnClickError?.((e as Error).message);\n }\n }}\n />\n ) : (\n <Toolbar>\n <Menu>\n <MenuTrigger>\n <ToolbarButton aria-label=\"More\" icon={<MoreHorizontal24Filled />} />\n </MenuTrigger>\n <MenuPopover>\n <MenuList>\n {menuActions.map((menuItem, index) => (\n <MenuItem\n key={index}\n icon={menuItem.icon}\n onClick={async () => {\n try {\n await menuItem.onClick(attachment);\n } catch (e) {\n handleOnClickError?.((e as Error).message);\n }\n }}\n >\n {menuItem.name}\n </MenuItem>\n ))}\n </MenuList>\n </MenuPopover>\n </Menu>\n </Toolbar>\n );\n};\n"]}
|
1
|
+
{"version":3,"file":"AttachmentCard.js","sourceRoot":"","sources":["../../../../../../react-components/src/components/AttachmentCard.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAElC,OAAO;AACL,iDAAiD;AACjD,IAA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,CAAC,OAAO,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC,GACD,CACH,CAAC,CAAC,CAAC,CACF,oBAAC,OAAO;QACN,oBAAC,IAAI;YACH,oBAAC,WAAW;gBACV,oBAAC,aAAa,IAAC,IAAI,EAAE,oBAAC,IAAI,IAAC,QAAQ,EAAC,oBAAoB,gBAAa,aAAa,CAAC,kBAAkB,GAAI,GAAI,CACjG;YACd,oBAAC,WAAW;gBACV,oBAAC,QAAQ,QACN,WAAW,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,CACpC,oBAAC,QAAQ,IACP,GAAG,EAAE,KAAK,EACV,IAAI,EAAE,QAAQ,CAAC,IAAI,EACnB,OAAO,EAAE,GAAS,EAAE;wBAClB,IAAI,CAAC;4BACH,MAAM,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;wBACrC,CAAC;wBAAC,OAAO,CAAC,EAAE,CAAC;4BACX,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAI,CAAW,CAAC,OAAO,CAAC,CAAC;wBAC7C,CAAC;oBACH,CAAC,CAAA,IAEA,QAAQ,CAAC,IAAI,CACL,CACZ,CAAC,CACO,CACC,CACT,CACC,CACX,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n // eslint-disable-next-line no-restricted-imports\n Icon\n} from '@fluentui/react';\nimport {\n Card,\n CardHeader,\n Text,\n Menu,\n MenuTrigger,\n ToolbarButton,\n MenuPopover,\n MenuItem,\n MenuList,\n Toolbar,\n CardFooter,\n ProgressBar\n} from '@fluentui/react-components';\nimport { getFileTypeIconProps } from '@fluentui/react-file-type-icons';\nimport React from 'react';\nimport { _pxToRem } from '@internal/acs-ui-common';\nimport { Announcer } from './Announcer';\nimport { useEffect, useState, useMemo } from 'react';\nimport { _AttachmentUploadCardsStrings } from './AttachmentUploadCards';\nimport { useLocaleAttachmentCardStringsTrampoline } from './utils/common';\nimport { AttachmentMetadata, AttachmentMenuAction } from '../types/Attachment';\nimport { useAttachmentCardStyles, attachmentNameContainerClassName } from './styles/AttachmentCard.styles';\n\n/**\n * @internal\n * AttachmentCard Component Props.\n */\nexport interface _AttachmentCardProps {\n /**\n * Attachment details including name, extension, url, etc.\n */\n attachment: AttachmentMetadata;\n /**\n * An array of menu actions to be displayed in the attachment card.\n */\n menuActions: AttachmentMenuAction[];\n /**\n * Optional aria label strings for attachment upload cards\n */\n strings?: _AttachmentUploadCardsStrings;\n /**\n * Optional callback that runs if menu bar action onclick throws.\n */\n onActionHandlerFailed?: (errMsg: string) => void;\n}\n\n/**\n * @internal\n * A component for displaying an attachment card with attachment icon and progress bar.\n *\n * `_AttachmentCard` internally uses the `Card` component from `@fluentui/react-components`. You can checkout the details about these components [here](https://react.fluentui.dev/?path=/docs/components-card).\n */\nexport const _AttachmentCard = (props: _AttachmentCardProps): JSX.Element => {\n const { attachment, menuActions, onActionHandlerFailed } = props;\n const attachmentCardStyles = useAttachmentCardStyles();\n const progress = useMemo(() => {\n return attachment.progress;\n }, [attachment.progress]);\n const isUploadComplete = useMemo(() => {\n return progress !== undefined && progress > 0 && progress < 1;\n }, [progress]);\n\n const [announcerString, setAnnouncerString] = useState<string | undefined>(undefined);\n const localeStrings = useLocaleAttachmentCardStringsTrampoline();\n const uploadStartedString = props.strings?.uploading ?? localeStrings.uploading;\n const uploadCompletedString = props.strings?.uploadCompleted ?? localeStrings.uploadCompleted;\n\n const showProgressIndicator = progress !== undefined && progress > 0 && progress < 1;\n\n useEffect(() => {\n if (showProgressIndicator) {\n setAnnouncerString(`${uploadStartedString} ${attachment.name}`);\n } else if (progress === 1) {\n setAnnouncerString(`${attachment.name} ${uploadCompletedString}`);\n } else {\n setAnnouncerString(undefined);\n }\n }, [progress, showProgressIndicator, attachment.name, uploadStartedString, uploadCompletedString]);\n\n return (\n <div data-is-focusable={true}>\n <Announcer announcementString={announcerString} ariaLive={'polite'} />\n <Card\n className={attachmentCardStyles.root}\n size=\"small\"\n role=\"listitem\"\n appearance=\"filled-alternative\"\n aria-label={attachment.name}\n >\n <CardHeader\n image={\n <Icon\n data-ui-id={'attachmenttype-icon'}\n iconName={\n getFileTypeIconProps({\n extension: useMemo((): string => {\n return attachment.extension ?? attachment.name.split('.').pop() ?? '';\n }, [attachment]),\n size: 24,\n imageFileType: 'svg'\n }).iconName\n }\n />\n }\n header={\n <div className={attachmentNameContainerClassName}>\n <Text title={attachment.name}>{attachment.name}</Text>\n </div>\n }\n action={MappedMenuItems(menuActions, attachment, onActionHandlerFailed)}\n />\n </Card>\n {isUploadComplete ? (\n <CardFooter>\n <ProgressBar thickness=\"medium\" value={progress} shape=\"rounded\" />\n </CardFooter>\n ) : (\n <> </>\n )}\n </div>\n );\n};\n\nconst MappedMenuItems = (\n menuActions: AttachmentMenuAction[],\n attachment: AttachmentMetadata,\n handleOnClickError?: (errMsg: string) => void\n): JSX.Element => {\n const localeStrings = useLocaleAttachmentCardStringsTrampoline();\n\n if (menuActions.length === 0) {\n return <></>;\n }\n return menuActions.length === 1 ? (\n <ToolbarButton\n aria-label={menuActions[0].name}\n icon={menuActions[0].icon}\n onClick={() => {\n try {\n menuActions[0].onClick(attachment);\n } catch (e) {\n handleOnClickError?.((e as Error).message);\n }\n }}\n />\n ) : (\n <Toolbar>\n <Menu>\n <MenuTrigger>\n <ToolbarButton icon={<Icon iconName=\"AttachmentMoreMenu\" aria-label={localeStrings.attachmentMoreMenu} />} />\n </MenuTrigger>\n <MenuPopover>\n <MenuList>\n {menuActions.map((menuItem, index) => (\n <MenuItem\n key={index}\n icon={menuItem.icon}\n onClick={async () => {\n try {\n await menuItem.onClick(attachment);\n } catch (e) {\n handleOnClickError?.((e as Error).message);\n }\n }}\n >\n {menuItem.name}\n </MenuItem>\n ))}\n </MenuList>\n </MenuPopover>\n </Menu>\n </Toolbar>\n );\n};\n"]}
|
@@ -12,6 +12,8 @@ export interface _AttachmentUploadCardsStrings {
|
|
12
12
|
uploading: string;
|
13
13
|
/** Aria label to notify user attachment is uploaded. */
|
14
14
|
uploadCompleted: string;
|
15
|
+
/** Aria label to notify user more attachment action menu. */
|
16
|
+
attachmentMoreMenu: string;
|
15
17
|
}
|
16
18
|
/**
|
17
19
|
* @internal
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AttachmentUploadCards.js","sourceRoot":"","sources":["../../../../../../react-components/src/components/AttachmentUploadCards.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,wCAAwC,EAAE,MAAM,gBAAgB,CAAC;
|
1
|
+
{"version":3,"file":"AttachmentUploadCards.js","sourceRoot":"","sources":["../../../../../../react-components/src/components/AttachmentUploadCards.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,wCAAwC,EAAE,MAAM,gBAAgB,CAAC;AAsC1E,MAAM,eAAe,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAiC,EAAe,EAAE;;IACvF,MAAM,WAAW,GAAG,KAAK,CAAC,uBAAuB,CAAC;IAClD,MAAM,aAAa,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AAE,CAAW,CAAC,OAAO,CAAC,CAAC;gCAC/B,CAAC;4BACH,CAAC,CAAC,CAAC;wBACL,CAAC;qBACF;iBACF,EACD,OAAO,EAAE,KAAK,CAAC,OAAO,GACtB,CACH,CAAA;SAAA,CAAC,CACe,CACxB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { Icon, mergeStyles } from '@fluentui/react';\nimport React, { useMemo } from 'react';\nimport { _AttachmentCard } from './AttachmentCard';\nimport { _AttachmentCardGroup } from './AttachmentCardGroup';\nimport { AttachmentMetadata } from '../types/Attachment';\nimport { useLocaleAttachmentCardStringsTrampoline } from './utils/common';\n\n/**\n * Strings of _AttachmentUploadCards that can be overridden.\n *\n * @internal\n */\nexport interface _AttachmentUploadCardsStrings {\n /** Aria label to notify user when focus is on cancel attachment upload button. */\n removeAttachment: string;\n /** Aria label to notify user attachment uploading starts. */\n uploading: string;\n /** Aria label to notify user attachment is uploaded. */\n uploadCompleted: string;\n /** Aria label to notify user more attachment action menu. */\n attachmentMoreMenu: string;\n}\n\n/**\n * @internal\n */\nexport interface AttachmentUploadCardsProps {\n /**\n * Optional array of active attachment uploads where each object has attibutes\n * of a attachment upload like name, progress, errormessage etc.\n */\n activeAttachmentUploads?: AttachmentMetadata[];\n /**\n * Optional callback to remove the attachment upload before sending by clicking on\n * cancel icon.\n */\n onCancelAttachmentUpload?: (attachmentId: string) => void;\n /**\n * Optional arialabel strings for attachment upload cards\n */\n strings?: _AttachmentUploadCardsStrings;\n}\n\nconst actionIconStyle = { height: '1rem' };\n\n/**\n * @internal\n */\nexport const _AttachmentUploadCards = (props: AttachmentUploadCardsProps): JSX.Element => {\n const attachments = props.activeAttachmentUploads;\n const localeStrings = useLocaleAttachmentCardStringsTrampoline();\n const removeAttachmentButtonString = useMemo(\n () => () => {\n return props.strings?.removeAttachment ?? localeStrings.removeAttachment;\n },\n [props.strings?.removeAttachment, localeStrings.removeAttachment]\n );\n\n if (!attachments || attachments.length === 0) {\n return <></>;\n }\n\n return (\n <_AttachmentCardGroup>\n {attachments &&\n attachments\n .filter((attachment) => !attachment.uploadError)\n .map((attachment) => (\n <_AttachmentCard\n attachment={attachment}\n key={attachment.id}\n menuActions={[\n {\n name: props.strings?.removeAttachment ?? 'Remove',\n icon: (\n <div aria-label={removeAttachmentButtonString()}>\n <Icon iconName=\"CancelAttachmentUpload\" className={mergeStyles(actionIconStyle)} />\n </div>\n ),\n onClick: (attachment) => {\n return new Promise((resolve, reject) => {\n try {\n props.onCancelAttachmentUpload && props.onCancelAttachmentUpload(attachment.id);\n resolve();\n } catch (e) {\n reject((e as Error).message);\n }\n });\n }\n }\n ]}\n strings={props.strings}\n />\n ))}\n </_AttachmentCardGroup>\n );\n};\n"]}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import { MessageThreadStrings } from '
|
3
|
-
import { ChatMessage } from '
|
4
|
-
import { AttachmentMetadata } from '
|
5
|
-
import { MentionLookupOptions } from '
|
2
|
+
import { MessageThreadStrings } from '../../MessageThread';
|
3
|
+
import { ChatMessage } from '../../../types';
|
4
|
+
import { AttachmentMetadata } from '../../../types/Attachment';
|
5
|
+
import { MentionLookupOptions } from '../../MentionPopover';
|
6
6
|
/** @private */
|
7
7
|
export type ChatMessageComponentAsEditBoxProps = {
|
8
8
|
onCancel?: (messageId: string) => void;
|
@@ -3,19 +3,19 @@
|
|
3
3
|
import { concatStyleSets, mergeStyles, Stack } from '@fluentui/react';
|
4
4
|
import { ChatMyMessage } from '@fluentui-contrib/react-chat';
|
5
5
|
import { mergeClasses } from '@fluentui/react-components';
|
6
|
-
import { _formatString } from "
|
7
|
-
import { useTheme } from '
|
6
|
+
import { _formatString } from "../../../../../acs-ui-common/src";
|
7
|
+
import { useTheme } from '../../../theming/FluentThemeProvider';
|
8
8
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
9
|
-
import { editBoxStyle, editingButtonStyle, editBoxStyleSet, inputBoxIcon } from '
|
10
|
-
import { InputBoxComponent } from '
|
11
|
-
import { InputBoxButton } from '
|
12
|
-
import { useChatMyMessageStyles } from '
|
13
|
-
import { _AttachmentUploadCards } from '
|
14
|
-
import { chatMessageFailedTagStyle, editChatMessageFailedTagStyle, chatMessageFailedTagStackItemStyle, editChatMessageButtonsStackStyle, useChatMessageEditContainerStyles } from '
|
15
|
-
import { MAXIMUM_LENGTH_OF_MESSAGE } from '
|
16
|
-
import { getMessageState, onRenderCancelIcon, onRenderSubmitIcon } from '
|
9
|
+
import { editBoxStyle, editingButtonStyle, editBoxStyleSet, inputBoxIcon } from '../../styles/EditBox.styles';
|
10
|
+
import { InputBoxComponent } from '../../InputBoxComponent';
|
11
|
+
import { InputBoxButton } from '../../InputBoxButton';
|
12
|
+
import { useChatMyMessageStyles } from '../../styles/MessageThread.styles';
|
13
|
+
import { _AttachmentUploadCards } from '../../AttachmentUploadCards';
|
14
|
+
import { chatMessageFailedTagStyle, editChatMessageFailedTagStyle, chatMessageFailedTagStackItemStyle, editChatMessageButtonsStackStyle, useChatMessageEditContainerStyles } from '../../styles/ChatMessageComponent.styles';
|
15
|
+
import { MAXIMUM_LENGTH_OF_MESSAGE } from '../../utils/SendBoxUtils';
|
16
|
+
import { getMessageState, onRenderCancelIcon, onRenderSubmitIcon } from '../../utils/ChatMessageComponentAsEditBoxUtils';
|
17
17
|
/* @conditional-compile-remove(attachment-upload) */
|
18
|
-
import { getMessageWithAttachmentMetadata } from '
|
18
|
+
import { getMessageWithAttachmentMetadata } from '../../utils/ChatMessageComponentAsEditBoxUtils';
|
19
19
|
/**
|
20
20
|
* @private
|
21
21
|
*/
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ChatMessageComponentAsEditBox.js","sourceRoot":"","sources":["../../../../../../../../react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBox.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EA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,CAAC,IAAI,EACxB,OAAO,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,WAAW,EACrG,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAClE;SACF,IAEA,UAAU,EAAE,CACC,CACjB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { concatStyleSets, ITextField, mergeStyles, Stack } from '@fluentui/react';\nimport { ChatMyMessage } from '@fluentui-contrib/react-chat';\nimport { mergeClasses } from '@fluentui/react-components';\nimport { _formatString } from '@internal/acs-ui-common';\nimport { useTheme } from '../../../theming/FluentThemeProvider';\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport { editBoxStyle, editingButtonStyle, editBoxStyleSet, inputBoxIcon } from '../../styles/EditBox.styles';\nimport { InputBoxComponent } from '../../InputBoxComponent';\nimport { InputBoxButton } from '../../InputBoxButton';\nimport { MessageThreadStrings } from '../../MessageThread';\nimport { useChatMyMessageStyles } from '../../styles/MessageThread.styles';\nimport { ChatMessage } from '../../../types';\nimport { _AttachmentUploadCards } from '../../AttachmentUploadCards';\n/* @conditional-compile-remove(attachment-upload) */\nimport { AttachmentMetadata } from '../../../types/Attachment';\nimport {\n chatMessageFailedTagStyle,\n editChatMessageFailedTagStyle,\n chatMessageFailedTagStackItemStyle,\n editChatMessageButtonsStackStyle,\n useChatMessageEditContainerStyles\n} from '../../styles/ChatMessageComponent.styles';\n/* @conditional-compile-remove(mention) */\nimport { MentionLookupOptions } from '../../MentionPopover';\nimport { MAXIMUM_LENGTH_OF_MESSAGE } from '../../utils/SendBoxUtils';\nimport {\n getMessageState,\n onRenderCancelIcon,\n onRenderSubmitIcon\n} from '../../utils/ChatMessageComponentAsEditBoxUtils';\n/* @conditional-compile-remove(attachment-upload) */\nimport { getMessageWithAttachmentMetadata } from '../../utils/ChatMessageComponentAsEditBoxUtils';\n\n/** @private */\nexport type ChatMessageComponentAsEditBoxProps = {\n onCancel?: (messageId: string) => void;\n onSubmit: (\n text: string,\n metadata?: Record<string, string>,\n options?: {\n /* @conditional-compile-remove(attachment-upload) */\n attachmentMetadata?: AttachmentMetadata[];\n }\n ) => void;\n message: ChatMessage;\n strings: MessageThreadStrings;\n /* @conditional-compile-remove(mention) */\n mentionLookupOptions?: MentionLookupOptions;\n};\n\n/**\n * @private\n */\nexport const ChatMessageComponentAsEditBox = (props: ChatMessageComponentAsEditBoxProps): JSX.Element => {\n const { onCancel, onSubmit, strings, message } = props;\n /* @conditional-compile-remove(mention) */\n const { mentionLookupOptions } = props;\n\n const [textValue, setTextValue] = useState<string>(message.content || '');\n /* @conditional-compile-remove(attachment-upload) */\n const [attachmentMetadata, setAttachmentMetadata] = React.useState(getMessageWithAttachmentMetadata(message));\n const editTextFieldRef = React.useRef<ITextField>(null);\n const theme = useTheme();\n const messageState = getMessageState(\n textValue,\n /* @conditional-compile-remove(attachment-upload) */ attachmentMetadata ?? []\n );\n const submitEnabled = messageState === 'OK';\n\n const editContainerStyles = useChatMessageEditContainerStyles();\n const chatMyMessageStyles = useChatMyMessageStyles();\n\n useEffect(() => {\n editTextFieldRef.current?.focus();\n }, []);\n\n const setText = (event?: React.FormEvent<HTMLInputElement | HTMLTextAreaElement>, newValue?: string): void => {\n setTextValue(newValue ?? '');\n };\n\n const textTooLongMessage =\n messageState === 'too long'\n ? _formatString(strings.editBoxTextLimit, { limitNumber: `${MAXIMUM_LENGTH_OF_MESSAGE}` })\n : undefined;\n\n const iconClassName = useCallback(\n (isHover: boolean) => {\n const color = isHover ? theme.palette.accent : theme.palette.neutralSecondary;\n return mergeStyles(inputBoxIcon, { color });\n },\n [theme.palette.accent, theme.palette.neutralSecondary]\n );\n\n const onRenderThemedCancelIcon = useCallback(\n (isHover: boolean) => {\n return onRenderCancelIcon(iconClassName(isHover));\n },\n [iconClassName]\n );\n\n const onRenderThemedSubmitIcon = useCallback(\n (isHover: boolean) => {\n return onRenderSubmitIcon(iconClassName(isHover));\n },\n [iconClassName]\n );\n\n const editBoxStyles = useMemo(() => {\n return concatStyleSets(editBoxStyleSet, { textField: { borderColor: theme.palette.themePrimary } });\n }, [theme.palette.themePrimary]);\n\n /* @conditional-compile-remove(attachment-upload) */\n const onRenderAttachmentUploads = useCallback(() => {\n return (\n !!attachmentMetadata &&\n attachmentMetadata.length > 0 && (\n <div style={{ margin: '0.25rem' }}>\n <_AttachmentUploadCards\n activeAttachmentUploads={attachmentMetadata}\n onCancelAttachmentUpload={(attachmentId) => {\n setAttachmentMetadata(attachmentMetadata?.filter((attachment) => attachment.id !== attachmentId));\n }}\n />\n </div>\n )\n );\n }, [attachmentMetadata]);\n\n const getContent = (): JSX.Element => {\n return (\n <>\n <InputBoxComponent\n data-ui-id=\"edit-box\"\n textFieldRef={editTextFieldRef}\n inputClassName={editBoxStyle}\n placeholderText={strings.editBoxPlaceholderText}\n textValue={textValue}\n onChange={setText}\n onKeyDown={(ev) => {\n if (ev.key === 'ArrowUp' || ev.key === 'ArrowDown') {\n ev.stopPropagation();\n }\n }}\n onEnterKeyDown={() => {\n submitEnabled &&\n onSubmit(\n textValue,\n message.metadata,\n /* @conditional-compile-remove(attachment-upload) */ {\n attachmentMetadata\n }\n );\n }}\n supportNewline={false}\n maxLength={MAXIMUM_LENGTH_OF_MESSAGE}\n errorMessage={textTooLongMessage}\n styles={editBoxStyles}\n /* @conditional-compile-remove(mention) */\n mentionLookupOptions={mentionLookupOptions}\n ></InputBoxComponent>\n <Stack\n horizontal\n horizontalAlign=\"end\"\n className={editChatMessageButtonsStackStyle}\n tokens={{ childrenGap: '0.25rem' }}\n >\n {message.failureReason && (\n <Stack.Item grow align=\"stretch\" className={chatMessageFailedTagStackItemStyle}>\n <div className={mergeStyles(chatMessageFailedTagStyle(theme), editChatMessageFailedTagStyle)}>\n {message.failureReason}\n </div>\n </Stack.Item>\n )}\n <Stack.Item align=\"end\">\n <InputBoxButton\n className={editingButtonStyle}\n ariaLabel={strings.editBoxCancelButton}\n tooltipContent={strings.editBoxCancelButton}\n onRenderIcon={onRenderThemedCancelIcon}\n onClick={() => {\n onCancel && onCancel(message.messageId);\n }}\n id={'dismissIconWrapper'}\n />\n </Stack.Item>\n <Stack.Item align=\"end\">\n <InputBoxButton\n className={editingButtonStyle}\n ariaLabel={strings.editBoxSubmitButton}\n tooltipContent={strings.editBoxSubmitButton}\n onRenderIcon={onRenderThemedSubmitIcon}\n onClick={(e) => {\n submitEnabled &&\n onSubmit(\n textValue,\n message.metadata,\n /* @conditional-compile-remove(attachment-upload) */ {\n attachmentMetadata\n }\n );\n e.stopPropagation();\n }}\n id={'submitIconWrapper'}\n />\n </Stack.Item>\n </Stack>\n {/* @conditional-compile-remove(attachment-upload) */ onRenderAttachmentUploads()}\n </>\n );\n };\n\n const attached = message.attached === true ? 'center' : message.attached === 'bottom' ? 'bottom' : 'top';\n return (\n <ChatMyMessage\n attached={attached}\n root={{\n className: chatMyMessageStyles.root\n }}\n body={{\n className: mergeClasses(\n editContainerStyles.body,\n message.failureReason !== undefined ? editContainerStyles.bodyError : editContainerStyles.bodyDefault,\n attached !== 'top' ? editContainerStyles.bodyAttached : undefined\n )\n }}\n >\n {getContent()}\n </ChatMyMessage>\n );\n};\n"]}
|
@@ -3,9 +3,9 @@
|
|
3
3
|
import React from 'react';
|
4
4
|
/* @conditional-compile-remove(rich-text-editor) */
|
5
5
|
import { Suspense } from 'react';
|
6
|
-
import { ChatMessageComponentAsEditBox } from '
|
6
|
+
import { ChatMessageComponentAsEditBox } from './ChatMessageComponentAsEditBox';
|
7
7
|
/* @conditional-compile-remove(rich-text-editor) */
|
8
|
-
const ChatMessageComponentAsRichTextEditBox = React.lazy(() => import('
|
8
|
+
const ChatMessageComponentAsRichTextEditBox = React.lazy(() => import('./ChatMessageComponentAsRichTextEditBox').then((module) => ({
|
9
9
|
default: module.ChatMessageComponentAsRichTextEditBox
|
10
10
|
})));
|
11
11
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ChatMessageComponentAsEditBoxPicker.js","sourceRoot":"","sources":["../../../../../../../../react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBoxPicker.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,mDAAmD;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAKjC,OAAO,EAAE,6BAA6B,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"ChatMessageComponentAsEditBoxPicker.js","sourceRoot":"","sources":["../../../../../../../../react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBoxPicker.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,mDAAmD;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAKjC,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAIhF,mDAAmD;AACnD,MAAM,qCAAqC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAC5D,MAAM,CAAC,yCAAyC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAClE,OAAO,EAAE,MAAM,CAAC,qCAAqC;CACtD,CAAC,CAAC,CACJ,CAAC;AAsBF;;GAEG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,KAA+C,EAAe,EAAE;IAClH,mDAAmD;IACnD,MAAM,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAEjC,mDAAmD;IACnD,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,CACL,oBAAC,QAAQ;YACP,oBAAC,qCAAqC,oBAAK,KAAK,EAAI,CAC3C,CACZ,CAAC;IACJ,CAAC;IAED,OAAO,oBAAC,6BAA6B,oBAAK,KAAK,EAAI,CAAC;AACtD,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport React from 'react';\n/* @conditional-compile-remove(rich-text-editor) */\nimport { Suspense } from 'react';\nimport { ChatMessage } from '../../../types';\n/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\nimport { AttachmentMetadata } from '../../../types';\nimport { MessageThreadStrings } from '../../MessageThread';\nimport { ChatMessageComponentAsEditBox } from './ChatMessageComponentAsEditBox';\n/* @conditional-compile-remove(mention) */\nimport { MentionLookupOptions } from '../../MentionPopover';\n\n/* @conditional-compile-remove(rich-text-editor) */\nconst ChatMessageComponentAsRichTextEditBox = React.lazy(() =>\n import('./ChatMessageComponentAsRichTextEditBox').then((module) => ({\n default: module.ChatMessageComponentAsRichTextEditBox\n }))\n);\n\n/**\n * @private\n */\nexport type ChatMessageComponentAsEditBoxPickerProps = {\n onCancel?: (messageId: string) => void;\n onSubmit: (\n text: string,\n metadata?: Record<string, string>,\n options?: {\n /* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\n attachmentMetadata?: AttachmentMetadata[];\n }\n ) => void;\n message: ChatMessage;\n strings: MessageThreadStrings;\n /* @conditional-compile-remove(mention) */\n mentionLookupOptions?: MentionLookupOptions;\n richTextEditor?: boolean;\n};\n\n/**\n * @private\n */\nexport const ChatMessageComponentAsEditBoxPicker = (props: ChatMessageComponentAsEditBoxPickerProps): JSX.Element => {\n /* @conditional-compile-remove(rich-text-editor) */\n const { richTextEditor } = props;\n\n /* @conditional-compile-remove(rich-text-editor) */\n if (richTextEditor) {\n return (\n <Suspense>\n <ChatMessageComponentAsRichTextEditBox {...props} />\n </Suspense>\n );\n }\n\n return <ChatMessageComponentAsEditBox {...props} />;\n};\n"]}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import { MessageThreadStrings } from '
|
3
|
-
import { ChatMessage } from '
|
4
|
-
import { AttachmentMetadata } from '
|
5
|
-
/** @
|
2
|
+
import { MessageThreadStrings } from '../../MessageThread';
|
3
|
+
import { ChatMessage } from '../../../types';
|
4
|
+
import { AttachmentMetadata } from '../../../types/Attachment';
|
5
|
+
/** @private */
|
6
6
|
export type ChatMessageComponentAsRichTextEditBoxProps = {
|
7
7
|
onCancel?: (messageId: string) => void;
|
8
8
|
onSubmit: (text: string, metadata?: Record<string, string>, options?: {
|
@@ -12,7 +12,7 @@ export type ChatMessageComponentAsRichTextEditBoxProps = {
|
|
12
12
|
strings: MessageThreadStrings;
|
13
13
|
};
|
14
14
|
/**
|
15
|
-
* @
|
15
|
+
* @private
|
16
16
|
*/
|
17
17
|
export declare const ChatMessageComponentAsRichTextEditBox: (props: ChatMessageComponentAsRichTextEditBoxProps) => JSX.Element;
|
18
18
|
//# sourceMappingURL=ChatMessageComponentAsRichTextEditBox.d.ts.map
|
@@ -3,29 +3,34 @@
|
|
3
3
|
import { mergeStyles, Stack } from '@fluentui/react';
|
4
4
|
import { ChatMyMessage } from '@fluentui-contrib/react-chat';
|
5
5
|
import { mergeClasses } from '@fluentui/react-components';
|
6
|
-
import { _formatString } from "
|
7
|
-
import { useTheme } from '
|
8
|
-
import React, { useCallback,
|
9
|
-
import { editBoxWidthStyles, richTextEditBoxActionButtonIcon } from '
|
10
|
-
import { InputBoxButton } from '
|
11
|
-
import { useChatMyMessageStyles } from '
|
12
|
-
import {
|
13
|
-
import {
|
14
|
-
import {
|
6
|
+
import { _formatString } from "../../../../../acs-ui-common/src";
|
7
|
+
import { useTheme } from '../../../theming';
|
8
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
9
|
+
import { editBoxWidthStyles, richTextEditBoxActionButtonIcon } from '../../styles/EditBox.styles';
|
10
|
+
import { InputBoxButton } from '../../InputBoxButton';
|
11
|
+
import { useChatMyMessageStyles } from '../../styles/MessageThread.styles';
|
12
|
+
import { _AttachmentUploadCards } from '../../AttachmentUploadCards';
|
13
|
+
import { useChatMessageRichTextEditContainerStyles } from '../../styles/ChatMessageComponent.styles';
|
14
|
+
import { MAXIMUM_LENGTH_OF_MESSAGE } from '../../utils/SendBoxUtils';
|
15
|
+
import { getMessageState, onRenderCancelIcon, onRenderSubmitIcon } from '../../utils/ChatMessageComponentAsEditBoxUtils';
|
15
16
|
/* @conditional-compile-remove(attachment-upload) */
|
16
|
-
import { getMessageWithAttachmentMetadata } from '
|
17
|
-
import { RichTextInputBoxComponent } from '
|
18
|
-
import { editBoxRichTextEditorStyle, richTextActionButtonsStyle } from '
|
19
|
-
import { RichTextSendBoxErrors } from '
|
20
|
-
import { useLocale } from '
|
17
|
+
import { getMessageWithAttachmentMetadata } from '../../utils/ChatMessageComponentAsEditBoxUtils';
|
18
|
+
import { RichTextInputBoxComponent } from '../../RichTextEditor/RichTextInputBoxComponent';
|
19
|
+
import { editBoxRichTextEditorStyle, richTextActionButtonsStyle } from '../../styles/RichTextEditor.styles';
|
20
|
+
import { RichTextSendBoxErrors } from '../../RichTextEditor/RichTextSendBoxErrors';
|
21
|
+
import { useLocale } from '../../../localization';
|
22
|
+
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
23
|
+
import { FluentV9ThemeProvider } from '../../../theming/FluentV9ThemeProvider';
|
24
|
+
/* @conditional-compile-remove(attachment-upload) */
|
25
|
+
import { attachmentUploadCardsStyles } from '../../styles/SendBox.styles';
|
21
26
|
/**
|
22
|
-
* @
|
27
|
+
* @private
|
23
28
|
*/
|
24
29
|
export const ChatMessageComponentAsRichTextEditBox = (props) => {
|
25
30
|
const { onCancel, onSubmit, strings, message } = props;
|
26
31
|
const [textValue, setTextValue] = useState(message.content || '');
|
27
|
-
/* @conditional-compile-remove(attachment-upload) */
|
28
|
-
const [attachmentMetadata,
|
32
|
+
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
33
|
+
const [attachmentMetadata, setAttachmentMetadata] = useState(getMessageWithAttachmentMetadata(message));
|
29
34
|
const editTextFieldRef = React.useRef(null);
|
30
35
|
const theme = useTheme();
|
31
36
|
const messageState = getMessageState(textValue,
|
@@ -34,12 +39,6 @@ export const ChatMessageComponentAsRichTextEditBox = (props) => {
|
|
34
39
|
const editContainerStyles = useChatMessageRichTextEditContainerStyles();
|
35
40
|
const chatMyMessageStyles = useChatMyMessageStyles();
|
36
41
|
const locale = useLocale().strings;
|
37
|
-
// TODO: Check if the focus is needed, if so use `focusOnInit` prop
|
38
|
-
// for Rooster component instead as this sets focus too early
|
39
|
-
useEffect(() => {
|
40
|
-
var _a;
|
41
|
-
(_a = editTextFieldRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
42
|
-
}, []);
|
43
42
|
const setText = (newValue) => {
|
44
43
|
setTextValue(newValue !== null && newValue !== void 0 ? newValue : '');
|
45
44
|
};
|
@@ -87,10 +86,22 @@ export const ChatMessageComponentAsRichTextEditBox = (props) => {
|
|
87
86
|
return locale.richTextSendBox;
|
88
87
|
return locale.sendBox;
|
89
88
|
}, [/* @conditional-compile-remove(rich-text-editor) */ locale.richTextSendBox, locale.sendBox]);
|
89
|
+
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
90
|
+
const onCancelAttachmentUpload = useCallback((attachmentId) => {
|
91
|
+
setAttachmentMetadata(attachmentMetadata === null || attachmentMetadata === void 0 ? void 0 : attachmentMetadata.filter((attachment) => attachment.id !== attachmentId));
|
92
|
+
}, [attachmentMetadata]);
|
93
|
+
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
94
|
+
const onRenderAttachmentUploads = useCallback(() => {
|
95
|
+
return (React.createElement(Stack, { className: attachmentUploadCardsStyles },
|
96
|
+
React.createElement(FluentV9ThemeProvider, { v8Theme: theme },
|
97
|
+
React.createElement(_AttachmentUploadCards, { activeAttachmentUploads: attachmentMetadata, onCancelAttachmentUpload: onCancelAttachmentUpload }))));
|
98
|
+
}, [attachmentMetadata, onCancelAttachmentUpload, theme]);
|
90
99
|
const getContent = () => {
|
91
100
|
return (React.createElement(Stack, { className: mergeStyles(editBoxWidthStyles) },
|
92
101
|
React.createElement(RichTextSendBoxErrors, { textTooLongMessage: textTooLongMessage, systemMessage: message.failureReason }),
|
93
|
-
React.createElement(RichTextInputBoxComponent, { placeholderText: strings.editBoxPlaceholderText, onChange: setText, editorComponentRef: editTextFieldRef, initialContent: message.content, strings: richTextLocaleStrings, disabled: false, actionComponents: actionButtons, richTextEditorStyleProps: editBoxRichTextEditorStyle, isHorizontalLayoutDisabled: true
|
102
|
+
React.createElement(RichTextInputBoxComponent, { placeholderText: strings.editBoxPlaceholderText, onChange: setText, editorComponentRef: editTextFieldRef, initialContent: message.content, content: textValue, strings: richTextLocaleStrings, disabled: false, actionComponents: actionButtons, richTextEditorStyleProps: editBoxRichTextEditorStyle, isHorizontalLayoutDisabled: true,
|
103
|
+
/* @conditional-compile-remove(attachment-upload) */
|
104
|
+
onRenderAttachmentUploads: onRenderAttachmentUploads })));
|
94
105
|
};
|
95
106
|
const attached = message.attached === true ? 'center' : message.attached === 'bottom' ? 'bottom' : 'top';
|
96
107
|
return (React.createElement(ChatMyMessage, { attached: attached, root: {
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ChatMessageComponentAsRichTextEditBox.js","sourceRoot":"","sources":["../../../../../../../../react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,yCAAgC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EA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EAC/C,QAAQ,EAAE,OAAO,EACjB,kBAAkB,EAAE,gBAAgB,EACpC,cAAc,EAAE,OAAO,CAAC,OAAO,EAC/B,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,qBAAqB,EAC9B,QAAQ,EAAE,KAAK,EACf,gBAAgB,EAAE,aAAa,EAC/B,wBAAwB,EAAE,0BAA0B,EACpD,0BAA0B,EAAE,IAAI;gBAChC,oDAAoD;gBACpD,yBAAyB,EAAE,yBAAyB,GACpD,CACI,CACT,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;IACzG,OAAO,CACL,oBAAC,aAAa,IACZ,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE;YACJ,SAAS,EAAE,mBAAmB,CAAC,IAAI;SACpC,EACD,IAAI,EAAE;YACJ,SAAS,EAAE,YAAY,CACrB,mBAAmB,CAAC,IAAI,EACxB,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAClE;SACF,IAEA,UAAU,EAAE,CACC,CACjB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { mergeStyles, Stack } from '@fluentui/react';\nimport { ChatMyMessage } from '@fluentui-contrib/react-chat';\nimport { mergeClasses } from '@fluentui/react-components';\nimport { _formatString } from '@internal/acs-ui-common';\nimport { useTheme } from '../../../theming';\nimport React, { useCallback, useMemo, useState } from 'react';\nimport { editBoxWidthStyles, richTextEditBoxActionButtonIcon } from '../../styles/EditBox.styles';\nimport { InputBoxButton } from '../../InputBoxButton';\nimport { MessageThreadStrings } from '../../MessageThread';\nimport { useChatMyMessageStyles } from '../../styles/MessageThread.styles';\nimport { ChatMessage } from '../../../types';\nimport { _AttachmentUploadCards } from '../../AttachmentUploadCards';\n/* @conditional-compile-remove(attachment-upload) */\nimport { AttachmentMetadata } from '../../../types/Attachment';\nimport { useChatMessageRichTextEditContainerStyles } from '../../styles/ChatMessageComponent.styles';\nimport { MAXIMUM_LENGTH_OF_MESSAGE } from '../../utils/SendBoxUtils';\nimport {\n getMessageState,\n onRenderCancelIcon,\n onRenderSubmitIcon\n} from '../../utils/ChatMessageComponentAsEditBoxUtils';\n/* @conditional-compile-remove(attachment-upload) */\nimport { getMessageWithAttachmentMetadata } from '../../utils/ChatMessageComponentAsEditBoxUtils';\nimport { RichTextEditorComponentRef } from '../../RichTextEditor/RichTextEditor';\nimport { RichTextInputBoxComponent } from '../../RichTextEditor/RichTextInputBoxComponent';\nimport { editBoxRichTextEditorStyle, richTextActionButtonsStyle } from '../../styles/RichTextEditor.styles';\nimport { RichTextSendBoxErrors } from '../../RichTextEditor/RichTextSendBoxErrors';\nimport { useLocale } from '../../../localization';\n/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\nimport { FluentV9ThemeProvider } from '../../../theming/FluentV9ThemeProvider';\n/* @conditional-compile-remove(attachment-upload) */\nimport { attachmentUploadCardsStyles } from '../../styles/SendBox.styles';\n\n/** @private */\nexport type ChatMessageComponentAsRichTextEditBoxProps = {\n onCancel?: (messageId: string) => void;\n onSubmit: (\n text: string,\n metadata?: Record<string, string>,\n options?: {\n /* @conditional-compile-remove(attachment-upload) */\n attachmentMetadata?: AttachmentMetadata[];\n }\n ) => void;\n message: ChatMessage;\n strings: MessageThreadStrings;\n};\n\n/**\n * @private\n */\nexport const ChatMessageComponentAsRichTextEditBox = (\n props: ChatMessageComponentAsRichTextEditBoxProps\n): JSX.Element => {\n const { onCancel, onSubmit, strings, message } = props;\n\n const [textValue, setTextValue] = useState<string>(message.content || '');\n /* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\n const [attachmentMetadata, setAttachmentMetadata] = useState(getMessageWithAttachmentMetadata(message));\n const editTextFieldRef = React.useRef<RichTextEditorComponentRef>(null);\n const theme = useTheme();\n const messageState = getMessageState(\n textValue,\n /* @conditional-compile-remove(attachment-upload) */ attachmentMetadata ?? []\n );\n const submitEnabled = messageState === 'OK';\n\n const editContainerStyles = useChatMessageRichTextEditContainerStyles();\n const chatMyMessageStyles = useChatMyMessageStyles();\n const locale = useLocale().strings;\n\n const setText = (newValue?: string): void => {\n setTextValue(newValue ?? '');\n };\n\n const textTooLongMessage =\n messageState === 'too long'\n ? _formatString(strings.editBoxTextLimit, { limitNumber: `${MAXIMUM_LENGTH_OF_MESSAGE}` })\n : undefined;\n\n const iconClassName = useCallback(\n (isHover: boolean) => {\n const color = isHover ? theme.palette.accent : theme.palette.neutralSecondary;\n return mergeStyles(richTextEditBoxActionButtonIcon, { color });\n },\n [theme.palette.accent, theme.palette.neutralSecondary]\n );\n\n const onRenderThemedCancelIcon = useCallback(\n (isHover: boolean) => {\n return onRenderCancelIcon(iconClassName(isHover));\n },\n [iconClassName]\n );\n\n const onRenderThemedSubmitIcon = useCallback(\n (isHover: boolean) => {\n return onRenderSubmitIcon(iconClassName(isHover));\n },\n [iconClassName]\n );\n\n const actionButtons = useMemo(() => {\n return (\n <Stack horizontal>\n <InputBoxButton\n className={richTextActionButtonsStyle}\n ariaLabel={strings.editBoxCancelButton}\n tooltipContent={strings.editBoxCancelButton}\n onRenderIcon={onRenderThemedCancelIcon}\n onClick={() => {\n onCancel && onCancel(message.messageId);\n }}\n id={'dismissIconWrapper'}\n />\n <InputBoxButton\n className={richTextActionButtonsStyle}\n ariaLabel={strings.editBoxSubmitButton}\n tooltipContent={strings.editBoxSubmitButton}\n onRenderIcon={onRenderThemedSubmitIcon}\n onClick={(e) => {\n submitEnabled &&\n onSubmit(\n textValue,\n message.metadata,\n /* @conditional-compile-remove(attachment-upload) */ {\n attachmentMetadata\n }\n );\n e.stopPropagation();\n }}\n id={'submitIconWrapper'}\n />\n </Stack>\n );\n }, [\n /* @conditional-compile-remove(attachment-upload) */ attachmentMetadata,\n message.messageId,\n message.metadata,\n onCancel,\n onRenderThemedCancelIcon,\n onRenderThemedSubmitIcon,\n onSubmit,\n strings.editBoxCancelButton,\n strings.editBoxSubmitButton,\n submitEnabled,\n textValue\n ]);\n const richTextLocaleStrings = useMemo(() => {\n /* @conditional-compile-remove(rich-text-editor) */\n return locale.richTextSendBox;\n return locale.sendBox;\n }, [/* @conditional-compile-remove(rich-text-editor) */ locale.richTextSendBox, locale.sendBox]);\n\n /* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\n const onCancelAttachmentUpload = useCallback(\n (attachmentId: string) => {\n setAttachmentMetadata(attachmentMetadata?.filter((attachment) => attachment.id !== attachmentId));\n },\n [attachmentMetadata]\n );\n\n /* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\n const onRenderAttachmentUploads = useCallback(() => {\n return (\n <Stack className={attachmentUploadCardsStyles}>\n <FluentV9ThemeProvider v8Theme={theme}>\n <_AttachmentUploadCards\n activeAttachmentUploads={attachmentMetadata}\n onCancelAttachmentUpload={onCancelAttachmentUpload}\n />\n </FluentV9ThemeProvider>\n </Stack>\n );\n }, [attachmentMetadata, onCancelAttachmentUpload, theme]);\n\n const getContent = (): JSX.Element => {\n return (\n <Stack className={mergeStyles(editBoxWidthStyles)}>\n <RichTextSendBoxErrors textTooLongMessage={textTooLongMessage} systemMessage={message.failureReason} />\n <RichTextInputBoxComponent\n placeholderText={strings.editBoxPlaceholderText}\n onChange={setText}\n editorComponentRef={editTextFieldRef}\n initialContent={message.content}\n content={textValue}\n strings={richTextLocaleStrings}\n disabled={false}\n actionComponents={actionButtons}\n richTextEditorStyleProps={editBoxRichTextEditorStyle}\n isHorizontalLayoutDisabled={true}\n /* @conditional-compile-remove(attachment-upload) */\n onRenderAttachmentUploads={onRenderAttachmentUploads}\n />\n </Stack>\n );\n };\n\n const attached = message.attached === true ? 'center' : message.attached === 'bottom' ? 'bottom' : 'top';\n return (\n <ChatMyMessage\n attached={attached}\n root={{\n className: chatMyMessageStyles.root\n }}\n body={{\n className: mergeClasses(\n editContainerStyles.body,\n attached !== 'top' ? editContainerStyles.bodyAttached : undefined\n )\n }}\n >\n {getContent()}\n </ChatMyMessage>\n );\n};\n"]}
|
@@ -1,7 +1,9 @@
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
2
2
|
// Licensed under the MIT License.
|
3
3
|
import { concatStyleSets, Icon } from '@fluentui/react';
|
4
|
-
|
4
|
+
/* @conditional-compile-remove(end-call-options) */
|
5
|
+
import { mergeStyles } from '@fluentui/react';
|
6
|
+
import React, { useCallback } from 'react';
|
5
7
|
import { useLocale } from '../localization';
|
6
8
|
import { useTheme } from '../theming';
|
7
9
|
import { darkTheme, lightTheme } from '../theming/themes';
|
@@ -9,7 +11,10 @@ import { isDarkThemed } from '../theming/themeUtils';
|
|
9
11
|
import { ControlBarButton } from './ControlBarButton';
|
10
12
|
/* @conditional-compile-remove(end-call-options) */
|
11
13
|
import { _preventDismissOnEvent as preventDismissOnEvent } from "../../../acs-ui-common/src";
|
12
|
-
|
14
|
+
/* @conditional-compile-remove(end-call-options) */
|
15
|
+
const spacerClass = mergeStyles({
|
16
|
+
width: 4
|
17
|
+
});
|
13
18
|
/**
|
14
19
|
* A button to end an ongoing call.
|
15
20
|
*
|
@@ -24,7 +29,11 @@ export const EndCallButton = (props) => {
|
|
24
29
|
const strings = Object.assign(Object.assign({}, localeStrings), props.strings);
|
25
30
|
const theme = useTheme();
|
26
31
|
const isDarkTheme = isDarkThemed(theme);
|
27
|
-
const componentStyles = concatStyleSets(isDarkTheme ? darkThemeCallButtonStyles : lightThemeCallButtonStyles,
|
32
|
+
const componentStyles = concatStyleSets(isDarkTheme ? darkThemeCallButtonStyles : lightThemeCallButtonStyles,
|
33
|
+
/* @conditional-compile-remove(end-call-options) */ enableEndCallMenu ? menupButtonPadding : {}, styles !== null && styles !== void 0 ? styles : {});
|
34
|
+
const onRenderEndCallIcon = useCallback(() => (React.createElement(React.Fragment, null,
|
35
|
+
React.createElement(Icon, { iconName: "ControlButtonEndCall" }), /* @conditional-compile-remove(end-call-options) */
|
36
|
+
enableEndCallMenu && React.createElement("span", { className: spacerClass }))), [/* @conditional-compile-remove(end-call-options) */ enableEndCallMenu]);
|
28
37
|
/* @conditional-compile-remove(end-call-options) */
|
29
38
|
const defaultMenuProps = {
|
30
39
|
items: [
|
@@ -125,4 +134,8 @@ const lightThemeCallButtonStyles = {
|
|
125
134
|
color: lightTheme.callingPalette.iconWhite
|
126
135
|
}
|
127
136
|
};
|
137
|
+
/* @conditional-compile-remove(end-call-options) */
|
138
|
+
const menupButtonPadding = {
|
139
|
+
root: { padding: '0 0.75rem' }
|
140
|
+
};
|
128
141
|
//# sourceMappingURL=EndCallButton.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EndCallButton.js","sourceRoot":"","sources":["../../../../../../react-components/src/components/EndCallButton.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAwB,MAAM,iBAAiB,CAAC;AAG9E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAgB,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAyB,MAAM,oBAAoB,CAAC;AAC7E,mDAAmD;AACnD,OAAO,EAAE,sBAAsB,IAAI,qBAAqB,EAAE,mCAAgC;AAiD1F,MAAM,mBAAmB,GAAG,GAAgB,EAAE,CAAC,oBAAC,IAAI,IAAC,QAAQ,EAAC,sBAAsB,GAAG,CAAC;AAExF;;;;;;GAM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AAE,sBAAsB,CAAC,OAAO;IACtD,KAAK,EAAE;QACL,KAAK,EAAE,UAAU,CAAC,cAAc,CAAC,SAAS;KAC3C;CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { concatStyleSets, Icon, IStyle, PartialTheme } from '@fluentui/react';\n/* @conditional-compile-remove(end-call-options) */\nimport { IContextualMenuProps } from '@fluentui/react';\nimport React from 'react';\nimport { useLocale } from '../localization';\nimport { useTheme } from '../theming';\nimport { CallingTheme, darkTheme, lightTheme } from '../theming/themes';\nimport { isDarkThemed } from '../theming/themeUtils';\nimport { ControlBarButton, ControlBarButtonProps } from './ControlBarButton';\n/* @conditional-compile-remove(end-call-options) */\nimport { _preventDismissOnEvent as preventDismissOnEvent } from '@internal/acs-ui-common';\n\n/**\n * Strings of {@link EndCallButton} that can be overridden.\n *\n * @public\n */\nexport interface EndCallButtonStrings {\n /**\n * Label of button\n */\n label: string;\n /** Tooltip content. */\n tooltipContent?: string;\n\n /* @conditional-compile-remove(end-call-options) */\n /** Label for leave option when ending call */\n leaveOption?: string;\n\n /* @conditional-compile-remove(end-call-options) */\n /** Label for end the whole call option when ending call */\n endCallOption?: string;\n}\n\n/**\n * Props for {@link EndCallButton}.\n *\n * @public\n */\nexport interface EndCallButtonProps extends ControlBarButtonProps {\n /**\n * Utility property for using this component with `communication react eventHandlers`.\n * Maps directly to the `onClick` property.\n */\n onHangUp?: (forEveryone?: boolean) => Promise<void>;\n\n /* @conditional-compile-remove(end-call-options) */\n /**\n * Set this to true to make it a split button.\n * The split arrow will trigger a contextual menu to allow end for everyone or just for the user.\n */\n enableEndCallMenu?: boolean;\n\n /**\n * Optional strings to override in component\n */\n strings?: EndCallButtonStrings;\n}\n\nconst onRenderEndCallIcon = (): JSX.Element => <Icon iconName=\"ControlButtonEndCall\" />;\n\n/**\n * A button to end an ongoing call.\n *\n * Can be used with {@link ControlBar}.\n *\n * @public\n */\nexport const EndCallButton = (props: EndCallButtonProps): JSX.Element => {\n const { styles, /* @conditional-compile-remove(end-call-options) */ enableEndCallMenu, onHangUp } = props;\n\n const localeStrings = useLocale().strings.endCallButton;\n const strings = { ...localeStrings, ...props.strings };\n\n const theme = useTheme();\n const isDarkTheme = isDarkThemed(theme);\n const componentStyles = concatStyleSets(\n isDarkTheme ? darkThemeCallButtonStyles : lightThemeCallButtonStyles,\n styles ?? {}\n );\n\n /* @conditional-compile-remove(end-call-options) */\n const defaultMenuProps: IContextualMenuProps = {\n items: [\n {\n key: 'endForSelf',\n text: localeStrings.leaveOption,\n title: localeStrings.leaveOption,\n onClick: () => {\n onHangUp && onHangUp(false);\n }\n },\n {\n key: 'endForEveryone',\n text: localeStrings.endCallOption,\n title: localeStrings.endCallOption,\n onClick: () => {\n onHangUp && onHangUp(true);\n }\n }\n ],\n styles: props.styles,\n calloutProps: {\n styles: {\n root: {\n maxWidth: '95%'\n }\n },\n preventDismissOnEvent\n }\n };\n\n return (\n <>\n <ControlBarButton\n {...props}\n /* @conditional-compile-remove(end-call-options) */\n menuProps={enableEndCallMenu ? defaultMenuProps : undefined}\n onClick={onHangUp ? () => onHangUp() : props.onClick}\n styles={componentStyles}\n onRenderIcon={props.onRenderIcon ?? onRenderEndCallIcon}\n strings={strings}\n labelKey={props.labelKey ?? 'endCallButtonLabel'}\n />\n </>\n );\n};\n\nconst getButtonStyles = (\n theme: PartialTheme & CallingTheme\n): { regular: IStyle; pressed: IStyle; hovered: IStyle } => ({\n regular: {\n color: theme.callingPalette.iconWhite,\n background: theme.callingPalette.callRed,\n '@media (forced-colors: active)': {\n forcedColorAdjust: 'auto',\n border: `1px ${theme.palette?.neutralQuaternaryAlt} solid`\n },\n ' i': {\n color: theme.callingPalette.iconWhite\n },\n ':focus::after': { outlineColor: `${theme.callingPalette.iconWhite} !important` } // added !important to avoid override by FluentUI button styles\n },\n pressed: {\n color: theme.callingPalette.iconWhite,\n background: theme.callingPalette.callRedDarker,\n border: 'none',\n ' i': {\n color: theme.callingPalette.iconWhite\n },\n '@media (forced-colors: active)': {\n forcedColorAdjust: 'auto'\n }\n },\n hovered: {\n color: theme.callingPalette.iconWhite,\n background: theme.callingPalette.callRedDark,\n border: 'none',\n ' i': {\n color: theme.callingPalette.iconWhite\n },\n '@media (forced-colors: active)': {\n forcedColorAdjust: 'auto'\n }\n }\n});\n\nconst darkThemeButtonStyles = getButtonStyles(darkTheme);\nconst lightThemeButtonStyles = getButtonStyles(lightTheme);\n\n// using media query to prevent windows from overwriting the button color\nconst darkThemeCallButtonStyles = {\n root: darkThemeButtonStyles.regular,\n rootHovered: darkThemeButtonStyles.hovered,\n rootPressed: darkThemeButtonStyles.pressed,\n label: {\n color: darkTheme.callingPalette.iconWhite\n },\n splitButtonMenuButton: {\n ...(darkThemeButtonStyles.regular as object),\n borderTop: 'none',\n borderRight: 'none',\n borderBottom: 'none',\n '&:hover': darkThemeButtonStyles.hovered\n },\n splitButtonMenuButtonChecked: darkThemeButtonStyles.hovered,\n splitButtonMenuButtonExpanded: darkThemeButtonStyles.pressed\n};\n\nconst lightThemeCallButtonStyles = {\n root: lightThemeButtonStyles.regular,\n rootHovered: lightThemeButtonStyles.hovered,\n rootPressed: lightThemeButtonStyles.pressed,\n splitButtonMenuButton: {\n ...(lightThemeButtonStyles.regular as object),\n borderTop: 'none',\n borderRight: 'none',\n borderBottom: 'none',\n '&:hover': lightThemeButtonStyles.hovered\n },\n splitButtonMenuButtonChecked: lightThemeButtonStyles.hovered,\n splitButtonMenuButtonExpanded: lightThemeButtonStyles.pressed,\n splitButtonMenuFocused: lightThemeButtonStyles.pressed,\n label: {\n color: lightTheme.callingPalette.iconWhite\n }\n};\n"]}
|
1
|
+
{"version":3,"file":"EndCallButton.js","sourceRoot":"","sources":["../../../../../../react-components/src/components/EndCallButton.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAwB,MAAM,iBAAiB,CAAC;AAC9E,mDAAmD;AACn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3D,yEAAyE;AACzE,MAAM,yBAAyB,GAAG;IAChC,IAAI,EAAE,qBAAqB,CAAC,OAAO;IACnC,WAAW,EAAE,qBAAqB,CAAC,OAAO;IAC1C,WAAW,EAAE,qBAAqB,CAAC,OAAO;IAC1C,KAAK,EAAE;QACL,KAAK,EAAE,SAAS,CAAC,cAAc,CAAC,SAAS;KAC1C;IACD,qBAAqB,kCACf,qBAAqB,CAAC,OAAkB,KAC5C,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,qBAAqB,CAAC,OAAO,GACzC;IACD,4BAA4B,EAAE,qBAAqB,CAAC,OAAO;IAC3D,6BAA6B,EAAE,qBAAqB,CAAC,OAAO;CAC7D,CAAC;AAEF,MAAM,0BAA0B,GAAG;IACjC,IAAI,EAAE,sBAAsB,CAAC,OAAO;IACpC,WAAW,EAAE,sBAAsB,CAAC,OAAO;IAC3C,WAAW,EAAE,sBAAsB,CAAC,OAAO;IAC3C,qBAAqB,kCACf,sBAAsB,CAAC,OAAkB,KAC7C,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,sBAAsB,CAAC,OAAO,GAC1C;IACD,4BAA4B,EAAE,sBAAsB,CAAC,OAAO;IAC5D,6BAA6B,EAAE,sBAAsB,CAAC,OAAO;IAC7D,sBAAsB,EAAE,sBAAsB,CAAC,OAAO;IACtD,KAAK,EAAE;QACL,KAAK,EAAE,UAAU,CAAC,cAAc,CAAC,SAAS;KAC3C;CACF,CAAC;AAEF,mDAAmD;AACnD,MAAM,kBAAkB,GAAG;IACzB,IAAI,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE;CAC/B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { concatStyleSets, Icon, IStyle, PartialTheme } from '@fluentui/react';\n/* @conditional-compile-remove(end-call-options) */\nimport { IContextualMenuProps, mergeStyles } from '@fluentui/react';\nimport React, { useCallback } from 'react';\nimport { useLocale } from '../localization';\nimport { useTheme } from '../theming';\nimport { CallingTheme, darkTheme, lightTheme } from '../theming/themes';\nimport { isDarkThemed } from '../theming/themeUtils';\nimport { ControlBarButton, ControlBarButtonProps } from './ControlBarButton';\n/* @conditional-compile-remove(end-call-options) */\nimport { _preventDismissOnEvent as preventDismissOnEvent } from '@internal/acs-ui-common';\n\n/**\n * Strings of {@link EndCallButton} that can be overridden.\n *\n * @public\n */\nexport interface EndCallButtonStrings {\n /**\n * Label of button\n */\n label: string;\n /** Tooltip content. */\n tooltipContent?: string;\n\n /* @conditional-compile-remove(end-call-options) */\n /** Label for leave option when ending call */\n leaveOption?: string;\n\n /* @conditional-compile-remove(end-call-options) */\n /** Label for end the whole call option when ending call */\n endCallOption?: string;\n}\n\n/**\n * Props for {@link EndCallButton}.\n *\n * @public\n */\nexport interface EndCallButtonProps extends ControlBarButtonProps {\n /**\n * Utility property for using this component with `communication react eventHandlers`.\n * Maps directly to the `onClick` property.\n */\n onHangUp?: (forEveryone?: boolean) => Promise<void>;\n\n /* @conditional-compile-remove(end-call-options) */\n /**\n * Set this to true to make it a split button.\n * The split arrow will trigger a contextual menu to allow end for everyone or just for the user.\n */\n enableEndCallMenu?: boolean;\n\n /**\n * Optional strings to override in component\n */\n strings?: EndCallButtonStrings;\n}\n\n/* @conditional-compile-remove(end-call-options) */\nconst spacerClass = mergeStyles({\n width: 4\n});\n\n/**\n * A button to end an ongoing call.\n *\n * Can be used with {@link ControlBar}.\n *\n * @public\n */\nexport const EndCallButton = (props: EndCallButtonProps): JSX.Element => {\n const { styles, /* @conditional-compile-remove(end-call-options) */ enableEndCallMenu, onHangUp } = props;\n\n const localeStrings = useLocale().strings.endCallButton;\n const strings = { ...localeStrings, ...props.strings };\n\n const theme = useTheme();\n const isDarkTheme = isDarkThemed(theme);\n const componentStyles = concatStyleSets(\n isDarkTheme ? darkThemeCallButtonStyles : lightThemeCallButtonStyles,\n /* @conditional-compile-remove(end-call-options) */ enableEndCallMenu ? menupButtonPadding : {},\n styles ?? {}\n );\n\n const onRenderEndCallIcon = useCallback(\n (): JSX.Element => (\n <>\n <Icon iconName=\"ControlButtonEndCall\" />\n {/* @conditional-compile-remove(end-call-options) */ enableEndCallMenu && <span className={spacerClass} />}\n </>\n ),\n [/* @conditional-compile-remove(end-call-options) */ enableEndCallMenu]\n );\n\n /* @conditional-compile-remove(end-call-options) */\n const defaultMenuProps: IContextualMenuProps = {\n items: [\n {\n key: 'endForSelf',\n text: localeStrings.leaveOption,\n title: localeStrings.leaveOption,\n onClick: () => {\n onHangUp && onHangUp(false);\n }\n },\n {\n key: 'endForEveryone',\n text: localeStrings.endCallOption,\n title: localeStrings.endCallOption,\n onClick: () => {\n onHangUp && onHangUp(true);\n }\n }\n ],\n styles: props.styles,\n calloutProps: {\n styles: {\n root: {\n maxWidth: '95%'\n }\n },\n preventDismissOnEvent\n }\n };\n\n return (\n <>\n <ControlBarButton\n {...props}\n /* @conditional-compile-remove(end-call-options) */\n menuProps={enableEndCallMenu ? defaultMenuProps : undefined}\n onClick={onHangUp ? () => onHangUp() : props.onClick}\n styles={componentStyles}\n onRenderIcon={props.onRenderIcon ?? onRenderEndCallIcon}\n strings={strings}\n labelKey={props.labelKey ?? 'endCallButtonLabel'}\n />\n </>\n );\n};\n\nconst getButtonStyles = (\n theme: PartialTheme & CallingTheme\n): { regular: IStyle; pressed: IStyle; hovered: IStyle } => ({\n regular: {\n color: theme.callingPalette.iconWhite,\n background: theme.callingPalette.callRed,\n '@media (forced-colors: active)': {\n forcedColorAdjust: 'auto',\n border: `1px ${theme.palette?.neutralQuaternaryAlt} solid`\n },\n ' i': {\n color: theme.callingPalette.iconWhite\n },\n ':focus::after': { outlineColor: `${theme.callingPalette.iconWhite} !important` } // added !important to avoid override by FluentUI button styles\n },\n pressed: {\n color: theme.callingPalette.iconWhite,\n background: theme.callingPalette.callRedDarker,\n border: 'none',\n ' i': {\n color: theme.callingPalette.iconWhite\n },\n '@media (forced-colors: active)': {\n forcedColorAdjust: 'auto'\n }\n },\n hovered: {\n color: theme.callingPalette.iconWhite,\n background: theme.callingPalette.callRedDark,\n border: 'none',\n ' i': {\n color: theme.callingPalette.iconWhite\n },\n '@media (forced-colors: active)': {\n forcedColorAdjust: 'auto'\n }\n }\n});\n\nconst darkThemeButtonStyles = getButtonStyles(darkTheme);\nconst lightThemeButtonStyles = getButtonStyles(lightTheme);\n\n// using media query to prevent windows from overwriting the button color\nconst darkThemeCallButtonStyles = {\n root: darkThemeButtonStyles.regular,\n rootHovered: darkThemeButtonStyles.hovered,\n rootPressed: darkThemeButtonStyles.pressed,\n label: {\n color: darkTheme.callingPalette.iconWhite\n },\n splitButtonMenuButton: {\n ...(darkThemeButtonStyles.regular as object),\n borderTop: 'none',\n borderRight: 'none',\n borderBottom: 'none',\n '&:hover': darkThemeButtonStyles.hovered\n },\n splitButtonMenuButtonChecked: darkThemeButtonStyles.hovered,\n splitButtonMenuButtonExpanded: darkThemeButtonStyles.pressed\n};\n\nconst lightThemeCallButtonStyles = {\n root: lightThemeButtonStyles.regular,\n rootHovered: lightThemeButtonStyles.hovered,\n rootPressed: lightThemeButtonStyles.pressed,\n splitButtonMenuButton: {\n ...(lightThemeButtonStyles.regular as object),\n borderTop: 'none',\n borderRight: 'none',\n borderBottom: 'none',\n '&:hover': lightThemeButtonStyles.hovered\n },\n splitButtonMenuButtonChecked: lightThemeButtonStyles.hovered,\n splitButtonMenuButtonExpanded: lightThemeButtonStyles.pressed,\n splitButtonMenuFocused: lightThemeButtonStyles.pressed,\n label: {\n color: lightTheme.callingPalette.iconWhite\n }\n};\n\n/* @conditional-compile-remove(end-call-options) */\nconst menupButtonPadding = {\n root: { padding: '0 0.75rem' }\n};\n"]}
|
@@ -19,6 +19,9 @@ export const insertTable = (editor, columns, rows) => {
|
|
19
19
|
const td = document.createElement('td');
|
20
20
|
tr.appendChild(td);
|
21
21
|
td.appendChild(document.createElement('br'));
|
22
|
+
// set the width as otherwise insets doesn't work well in table
|
23
|
+
// review if it's needed when content model packages are used
|
24
|
+
td.style.width = getTableCellWidth(columns);
|
22
25
|
}
|
23
26
|
}
|
24
27
|
editor.focus();
|
@@ -31,4 +34,15 @@ export const insertTable = (editor, columns, rows) => {
|
|
31
34
|
formatApiName: 'insertTable'
|
32
35
|
});
|
33
36
|
};
|
37
|
+
function getTableCellWidth(columns) {
|
38
|
+
if (columns <= 4) {
|
39
|
+
return '120px';
|
40
|
+
}
|
41
|
+
else if (columns <= 6) {
|
42
|
+
return '100px';
|
43
|
+
}
|
44
|
+
else {
|
45
|
+
return '70px';
|
46
|
+
}
|
47
|
+
}
|
34
48
|
//# sourceMappingURL=insertTableAction.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"insertTableAction.js","sourceRoot":"","sources":["../../../../../../../../../react-components/src/components/RichTextEditor/Buttons/Table/insertTableAction.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAEnG,+GAA+G;AAE/G;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAe,EAAE,OAAe,EAAE,IAAY,EAAQ,EAAE;IAClF,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAqB,CAAC;IAClE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAwB,CAAC;QAC/D,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;YACjC,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAyB,CAAC;YAChE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACnB,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;
|
1
|
+
{"version":3,"file":"insertTableAction.js","sourceRoot":"","sources":["../../../../../../../../../react-components/src/components/RichTextEditor/Buttons/Table/insertTableAction.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAEnG,+GAA+G;AAE/G;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAe,EAAE,OAAe,EAAE,IAAY,EAAQ,EAAE;IAClF,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAqB,CAAC;IAClE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAwB,CAAC;QAC/D,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;YACjC,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAyB,CAAC;YAChE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACnB,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;YAE7C,+DAA+D;YAC/D,6DAA6D;YAC7D,EAAE,CAAC,KAAK,CAAC,KAAK,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAED,MAAM,CAAC,KAAK,EAAE,CAAC;IACf,MAAM,CAAC,eAAe,CACpB,GAAG,EAAE;QACH,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,MAAM,CAAC,SAAS,EAAE,CAAC;QACnB,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACzB,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,KAAK,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAC5G,CAAC,EACD,sBAAsB,CAAC,MAAM,EAC7B,SAAS,CAAC,wBAAwB,EAClC;QACE,aAAa,EAAE,aAAa;KAC7B,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,SAAS,iBAAiB,CAAC,OAAe;IACxC,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;QACjB,OAAO,OAAO,CAAC;IACjB,CAAC;SAAM,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;QACxB,OAAO,OAAO,CAAC;IACjB,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,CAAC;IAChB,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { Position, VTable } from 'roosterjs-editor-dom';\nimport type { IEditor } from 'roosterjs-editor-types-compatible';\nimport { CompatibleChangeSource, CompatiblePositionType } from 'roosterjs-editor-types-compatible';\n\n// This file uses RoosterJS React package implementation with updates to change table's size and remove styles\n\n/**\n * Insert table into editor at current selection\n * @param editor The editor instance\n * @param columns Number of columns in table\n * @param rows Number of rows in table\n */\nexport const insertTable = (editor: IEditor, columns: number, rows: number): void => {\n const document = editor.getDocument();\n const table = document.createElement('table') as HTMLTableElement;\n for (let i = 0; i < rows; i++) {\n const tr = document.createElement('tr') as HTMLTableRowElement;\n table.appendChild(tr);\n for (let j = 0; j < columns; j++) {\n const td = document.createElement('td') as HTMLTableCellElement;\n tr.appendChild(td);\n td.appendChild(document.createElement('br'));\n\n // set the width as otherwise insets doesn't work well in table\n // review if it's needed when content model packages are used\n td.style.width = getTableCellWidth(columns);\n }\n }\n\n editor.focus();\n editor.addUndoSnapshot(\n () => {\n const vTable = new VTable(table);\n vTable.writeBack();\n editor.insertNode(table);\n editor.runAsync((editor) => editor.select(new Position(table, CompatiblePositionType.Begin).normalize()));\n },\n CompatibleChangeSource.Format,\n undefined /* canUndoByBackspace */,\n {\n formatApiName: 'insertTable'\n }\n );\n};\n\nfunction getTableCellWidth(columns: number): string {\n if (columns <= 4) {\n return '120px';\n } else if (columns <= 6) {\n return '100px';\n } else {\n return '70px';\n }\n}\n"]}
|
@@ -16,6 +16,7 @@ export interface RichTextEditorStyleProps {
|
|
16
16
|
*/
|
17
17
|
export interface RichTextEditorProps {
|
18
18
|
initialContent?: string;
|
19
|
+
content?: string;
|
19
20
|
onChange: (newValue?: string) => void;
|
20
21
|
onKeyDown?: (ev: React.KeyboardEvent<HTMLElement>) => void;
|
21
22
|
placeholderText?: string;
|