@azure/communication-react 1.17.0-alpha-202405170014 → 1.17.0-alpha-202405180013

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.
Files changed (90) hide show
  1. package/dist/dist-cjs/communication-react/{ChatMessageComponentAsRichTextEditBox-BLFNaheX.js → ChatMessageComponentAsRichTextEditBox-r0U_8d3I.js} +22 -17
  2. package/dist/dist-cjs/communication-react/ChatMessageComponentAsRichTextEditBox-r0U_8d3I.js.map +1 -0
  3. package/dist/dist-cjs/communication-react/{RichTextSendBoxWrapper-BhTpuspw.js → RichTextSendBoxWrapper-DNlYAgO2.js} +6 -8
  4. package/dist/dist-cjs/communication-react/{RichTextSendBoxWrapper-BhTpuspw.js.map → RichTextSendBoxWrapper-DNlYAgO2.js.map} +1 -1
  5. package/dist/dist-cjs/communication-react/{index-C9I6Mcil.js → index-BLj9R9ms.js} +894 -462
  6. package/dist/dist-cjs/communication-react/index-BLj9R9ms.js.map +1 -0
  7. package/dist/dist-cjs/communication-react/index.js +5 -7
  8. package/dist/dist-cjs/communication-react/index.js.map +1 -1
  9. package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js +1 -1
  10. package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js.map +1 -1
  11. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.js +17 -10
  12. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.js.map +1 -1
  13. package/dist/dist-esm/react-components/src/components/InputBoxComponent.js +1 -1
  14. package/dist/dist-esm/react-components/src/components/InputBoxComponent.js.map +1 -1
  15. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/ContextMenuPlugin.d.ts +9 -0
  16. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/ContextMenuPlugin.js +29 -0
  17. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/ContextMenuPlugin.js.map +1 -0
  18. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/CopyPastePlugin.d.ts +1 -1
  19. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/CopyPastePlugin.js +15 -20
  20. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/CopyPastePlugin.js.map +1 -1
  21. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/KeyboardInputPlugin.d.ts +12 -0
  22. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/KeyboardInputPlugin.js +23 -0
  23. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/KeyboardInputPlugin.js.map +1 -0
  24. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/PlaceholderPlugin.d.ts +15 -0
  25. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/PlaceholderPlugin.js +39 -0
  26. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/PlaceholderPlugin.js.map +1 -0
  27. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/RichTextToolbarPlugin.d.ts +24 -0
  28. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/RichTextToolbarPlugin.js +66 -0
  29. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/RichTextToolbarPlugin.js.map +1 -0
  30. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/TableEditContextMenuProvider.d.ts +20 -0
  31. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/TableEditContextMenuProvider.js +46 -0
  32. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/TableEditContextMenuProvider.js.map +1 -0
  33. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/UpdateContentPlugin.d.ts +29 -0
  34. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/UpdateContentPlugin.js +71 -0
  35. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/UpdateContentPlugin.js.map +1 -0
  36. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextEditor.d.ts +7 -10
  37. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextEditor.js +170 -91
  38. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextEditor.js.map +1 -1
  39. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextInputBoxComponent.d.ts +0 -1
  40. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextInputBoxComponent.js +29 -12
  41. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextInputBoxComponent.js.map +1 -1
  42. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js +12 -46
  43. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js.map +1 -1
  44. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/RichTextToolbar.d.ts +19 -0
  45. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/RichTextToolbar.js +209 -0
  46. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/RichTextToolbar.js.map +1 -0
  47. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextInsertTableCommandBarItem.d.ts +7 -0
  48. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextInsertTableCommandBarItem.js +49 -0
  49. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextInsertTableCommandBarItem.js.map +1 -0
  50. package/dist/dist-esm/react-components/src/components/RichTextEditor/{Buttons → Toolbar}/Table/RichTextInsertTablePane.d.ts +2 -2
  51. package/dist/dist-esm/react-components/src/components/RichTextEditor/{Buttons → Toolbar}/Table/RichTextInsertTablePane.js +3 -3
  52. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextInsertTablePane.js.map +1 -0
  53. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextToolbarTableIcon.d.ts +6 -0
  54. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextToolbarTableIcon.js +13 -0
  55. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextToolbarTableIcon.js.map +1 -0
  56. package/dist/dist-esm/react-components/src/components/TextFieldWithMention/TextFieldWithMention.js +1 -1
  57. package/dist/dist-esm/react-components/src/components/TextFieldWithMention/TextFieldWithMention.js.map +1 -1
  58. package/dist/dist-esm/react-components/src/components/styles/MessageThread.styles.js +3 -1
  59. package/dist/dist-esm/react-components/src/components/styles/MessageThread.styles.js.map +1 -1
  60. package/dist/dist-esm/react-components/src/components/styles/RichTextEditor.styles.d.ts +3 -3
  61. package/dist/dist-esm/react-components/src/components/styles/RichTextEditor.styles.js +4 -5
  62. package/dist/dist-esm/react-components/src/components/styles/RichTextEditor.styles.js.map +1 -1
  63. package/dist/dist-esm/react-components/src/components/utils/RichTextEditorUtils.d.ts +37 -0
  64. package/dist/dist-esm/react-components/src/components/utils/RichTextEditorUtils.js +60 -0
  65. package/dist/dist-esm/react-components/src/components/utils/RichTextEditorUtils.js.map +1 -0
  66. package/dist/dist-esm/react-components/src/components/utils/RichTextTableUtils.d.ts +11 -0
  67. package/dist/dist-esm/react-components/src/components/utils/RichTextTableUtils.js +95 -0
  68. package/dist/dist-esm/react-components/src/components/utils/RichTextTableUtils.js.map +1 -1
  69. package/dist/dist-esm/react-components/src/components/utils.d.ts +1 -1
  70. package/dist/dist-esm/react-components/src/components/utils.js +1 -3
  71. package/dist/dist-esm/react-components/src/components/utils.js.map +1 -1
  72. package/package.json +6 -8
  73. package/dist/dist-cjs/communication-react/ChatMessageComponentAsRichTextEditBox-BLFNaheX.js.map +0 -1
  74. package/dist/dist-cjs/communication-react/index-C9I6Mcil.js.map +0 -1
  75. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/RichTextRibbonButtons.d.ts +0 -7
  76. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/RichTextRibbonButtons.js +0 -86
  77. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/RichTextRibbonButtons.js.map +0 -1
  78. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/RichTextInsertTableButton.d.ts +0 -7
  79. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/RichTextInsertTableButton.js +0 -55
  80. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/RichTextInsertTableButton.js.map +0 -1
  81. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/RichTextInsertTablePane.js.map +0 -1
  82. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/RichTextTableContextMenu.d.ts +0 -8
  83. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/RichTextTableContextMenu.js +0 -66
  84. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/RichTextTableContextMenu.js.map +0 -1
  85. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/insertTableAction.d.ts +0 -9
  86. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/insertTableAction.js +0 -56
  87. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/insertTableAction.js.map +0 -1
  88. package/dist/dist-esm/react-components/src/components/utils/RichTextEditorStringsUtils.d.ts +0 -15
  89. package/dist/dist-esm/react-components/src/components/utils/RichTextEditorStringsUtils.js +0 -39
  90. package/dist/dist-esm/react-components/src/components/utils/RichTextEditorStringsUtils.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-C9I6Mcil.js');
3
+ var index = require('./index-BLj9R9ms.js');
4
4
  require('react');
5
5
  require('@fluentui/react');
6
6
  require('@fluentui/react-components');
@@ -18,12 +18,10 @@ require('textarea-caret-ts');
18
18
  require('use-debounce');
19
19
  require('@fluentui/react-file-type-icons');
20
20
  require('@griffel/react');
21
- require('roosterjs-editor-plugins');
22
- require('roosterjs-editor-core');
23
- require('roosterjs-editor-types-compatible');
24
- require('roosterjs-react');
25
- require('roosterjs-editor-dom');
26
- require('roosterjs-editor-api');
21
+ require('roosterjs-content-model-core');
22
+ require('roosterjs-content-model-dom');
23
+ require('roosterjs-content-model-plugins');
24
+ require('roosterjs-content-model-api');
27
25
  require('uuid');
28
26
  require('html-react-parser');
29
27
  require('react-linkify');
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -2,5 +2,5 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT License.
4
4
  // GENERATED FILE. DO NOT EDIT MANUALLY.
5
- module.exports = '1.17.0-alpha-202405170014';
5
+ module.exports = '1.17.0-alpha-202405180013';
6
6
  //# sourceMappingURL=telemetryVersion.js.map
@@ -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.17.0-alpha-202405170014';\n"]}
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.17.0-alpha-202405180013';\n"]}
@@ -5,7 +5,7 @@ import { ChatMyMessage } from '@fluentui-contrib/react-chat';
5
5
  import { mergeClasses } from '@fluentui/react-components';
6
6
  import { _formatString } from "../../../../../acs-ui-common/src";
7
7
  import { useTheme } from '../../../theming';
8
- import React, { useCallback, useMemo, useState } from 'react';
8
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
9
9
  /* @conditional-compile-remove(attachment-upload) */
10
10
  import { useReducer } from 'react';
11
11
  import { editBoxWidthStyles, richTextEditBoxActionButtonIcon } from '../../styles/EditBox.styles';
@@ -36,18 +36,25 @@ export const ChatMessageComponentAsRichTextEditBox = (props) => {
36
36
  const [attachmentMetadata, handleAttachmentAction] = useReducer(attachmentMetadataReducer, (_a = getMessageWithAttachmentMetadata(message)) !== null && _a !== void 0 ? _a : []);
37
37
  const editTextFieldRef = React.useRef(null);
38
38
  const theme = useTheme();
39
- const messageState = getMessageState(textValue,
40
- /* @conditional-compile-remove(attachment-upload) */ attachmentMetadata !== null && attachmentMetadata !== void 0 ? attachmentMetadata : []);
39
+ const messageState = useMemo(() => {
40
+ return getMessageState(textValue, /* @conditional-compile-remove(attachment-upload) */ attachmentMetadata !== null && attachmentMetadata !== void 0 ? attachmentMetadata : []);
41
+ }, [/* @conditional-compile-remove(attachment-upload) */ attachmentMetadata, textValue]);
41
42
  const submitEnabled = messageState === 'OK';
42
43
  const editContainerStyles = useChatMessageRichTextEditContainerStyles();
43
44
  const chatMyMessageStyles = useChatMyMessageStyles();
44
45
  const locale = useLocale().strings;
45
- const setText = (newValue) => {
46
+ const setText = useCallback((newValue) => {
46
47
  setTextValue(newValue !== null && newValue !== void 0 ? newValue : '');
47
- };
48
- const textTooLongMessage = messageState === 'too long'
49
- ? _formatString(strings.editBoxTextLimit, { limitNumber: `${MAXIMUM_LENGTH_OF_MESSAGE}` })
50
- : undefined;
48
+ }, []);
49
+ useEffect(() => {
50
+ var _a;
51
+ (_a = editTextFieldRef.current) === null || _a === void 0 ? void 0 : _a.focus();
52
+ }, []);
53
+ const textTooLongMessage = useMemo(() => {
54
+ return messageState === 'too long'
55
+ ? _formatString(strings.editBoxTextLimit, { limitNumber: `${MAXIMUM_LENGTH_OF_MESSAGE}` })
56
+ : undefined;
57
+ }, [messageState, strings.editBoxTextLimit]);
51
58
  const iconClassName = useCallback((isHover) => {
52
59
  const color = isHover ? theme.palette.accent : theme.palette.neutralSecondary;
53
60
  return mergeStyles(richTextEditBoxActionButtonIcon, { color });
@@ -69,7 +76,7 @@ export const ChatMessageComponentAsRichTextEditBox = (props) => {
69
76
  }, id: 'dismissIconWrapper', "data-testId": strings.editBoxCancelButton }),
70
77
  React.createElement(InputBoxButton, { className: richTextActionButtonsStyle, ariaLabel: strings.editBoxSubmitButton, tooltipContent: strings.editBoxSubmitButton, onRenderIcon: onRenderThemedSubmitIcon, onClick: (e) => {
71
78
  // it's very important to pass an empty attachment here
72
- // so when user remvoes all attachments, UI can reflect it instantly
79
+ // so when user removes all attachments, UI can reflect it instantly
73
80
  // if you set it to undefined, the attachments pre-edited would still be there
74
81
  // until edit message event is received
75
82
  submitEnabled &&
@@ -114,7 +121,7 @@ export const ChatMessageComponentAsRichTextEditBox = (props) => {
114
121
  const getContent = () => {
115
122
  return (React.createElement(Stack, { className: mergeStyles(editBoxWidthStyles) },
116
123
  React.createElement(RichTextSendBoxErrors, { textTooLongMessage: textTooLongMessage, systemMessage: message.failureReason }),
117
- 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,
124
+ React.createElement(RichTextInputBoxComponent, { placeholderText: strings.editBoxPlaceholderText, onChange: setText, editorComponentRef: editTextFieldRef, initialContent: message.content, strings: richTextLocaleStrings, disabled: false, actionComponents: actionButtons, richTextEditorStyleProps: editBoxRichTextEditorStyle, isHorizontalLayoutDisabled: true,
118
125
  /* @conditional-compile-remove(attachment-upload) */
119
126
  onRenderAttachmentUploads: onRenderAttachmentUploads })));
120
127
  };
@@ -1 +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,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9D,oDAAoD;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAGhF,OAAO,EAAE,yCAAyC,EAAE,MAAM,0CAA0C,CAAC;AACrG,OAAO,EAA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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,YAAY,CACrB,mBAAmB,CAAC,IAAI;YACxB,oDAAoD;YACpD,sBAAsB,CAAC,CAAC,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAC7E;SACF,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;AAEF,eAAe,qCAAqC,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';\n/* @conditional-compile-remove(attachment-upload) */\nimport { useReducer } 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 '../../Attachment/AttachmentUploadCards';\n/* @conditional-compile-remove(attachment-upload) */\nimport { AttachmentMetadata } from '@internal/acs-ui-common';\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 {\n attachmentMetadataReducer,\n getMessageWithAttachmentMetadata,\n doesMessageContainMultipleAttachments\n} 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 /* @conditional-compile-remove(attachment-upload) */\n attachmentMetadata?: AttachmentMetadata[]\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, handleAttachmentAction] = useReducer(\n attachmentMetadataReducer,\n getMessageWithAttachmentMetadata(message) ?? []\n );\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 /* @conditional-compile-remove(attachment-upload) */\n const hasMultipleAttachments = useMemo(() => {\n return doesMessageContainMultipleAttachments(message);\n }, [message]);\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 data-testId={strings.editBoxCancelButton}\n />\n <InputBoxButton\n className={richTextActionButtonsStyle}\n ariaLabel={strings.editBoxSubmitButton}\n tooltipContent={strings.editBoxSubmitButton}\n onRenderIcon={onRenderThemedSubmitIcon}\n onClick={(e) => {\n // it's very important to pass an empty attachment here\n // so when user remvoes all attachments, UI can reflect it instantly\n // if you set it to undefined, the attachments pre-edited would still be there\n // until edit message event is received\n submitEnabled &&\n onSubmit(textValue, /* @conditional-compile-remove(attachment-upload) */ attachmentMetadata);\n e.stopPropagation();\n }}\n id={'submitIconWrapper'}\n data-testId={strings.editBoxSubmitButton}\n />\n </Stack>\n );\n }, [\n /* @conditional-compile-remove(attachment-upload) */\n attachmentMetadata,\n message.messageId,\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, ...strings };\n return locale.sendBox;\n }, [\n /* @conditional-compile-remove(rich-text-editor) */ locale.richTextSendBox,\n /* @conditional-compile-remove(rich-text-editor) */ strings,\n locale.sendBox\n ]);\n\n /* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\n const onCancelAttachmentUpload = useCallback((attachmentId: string) => {\n // edit box only capable of removing attachments\n // we need to expand attachment actions\n // if we want to support more actions e.g. add\n handleAttachmentAction({ type: 'remove', id: attachmentId });\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 attachments={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: mergeClasses(\n chatMyMessageStyles.root,\n /* @conditional-compile-remove(attachment-upload) */\n hasMultipleAttachments ? chatMyMessageStyles.multipleAttachments : undefined\n )\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\nexport default ChatMessageComponentAsRichTextEditBox;\n"]}
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,EAA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C;IACzG,OAAO,CACL,oBAAC,aAAa,IACZ,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE;YACJ,SAAS,EAAE,YAAY,CACrB,mBAAmB,CAAC,IAAI;YACxB,oDAAoD;YACpD,sBAAsB,CAAC,CAAC,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAC7E;SACF,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;AAEF,eAAe,qCAAqC,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, useEffect, useMemo, useState } from 'react';\n/* @conditional-compile-remove(attachment-upload) */\nimport { useReducer } 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 '../../Attachment/AttachmentUploadCards';\n/* @conditional-compile-remove(attachment-upload) */\nimport { AttachmentMetadata } from '@internal/acs-ui-common';\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 {\n attachmentMetadataReducer,\n getMessageWithAttachmentMetadata,\n doesMessageContainMultipleAttachments\n} 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 /* @conditional-compile-remove(attachment-upload) */\n attachmentMetadata?: AttachmentMetadata[]\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, handleAttachmentAction] = useReducer(\n attachmentMetadataReducer,\n getMessageWithAttachmentMetadata(message) ?? []\n );\n const editTextFieldRef = React.useRef<RichTextEditorComponentRef>(null);\n const theme = useTheme();\n const messageState = useMemo(() => {\n return getMessageState(textValue, /* @conditional-compile-remove(attachment-upload) */ attachmentMetadata ?? []);\n }, [/* @conditional-compile-remove(attachment-upload) */ attachmentMetadata, textValue]);\n\n const submitEnabled = messageState === 'OK';\n\n const editContainerStyles = useChatMessageRichTextEditContainerStyles();\n const chatMyMessageStyles = useChatMyMessageStyles();\n const locale = useLocale().strings;\n\n const setText = useCallback((newValue?: string): void => {\n setTextValue(newValue ?? '');\n }, []);\n\n useEffect(() => {\n editTextFieldRef.current?.focus();\n }, []);\n\n const textTooLongMessage = useMemo(() => {\n return messageState === 'too long'\n ? _formatString(strings.editBoxTextLimit, { limitNumber: `${MAXIMUM_LENGTH_OF_MESSAGE}` })\n : undefined;\n }, [messageState, strings.editBoxTextLimit]);\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 /* @conditional-compile-remove(attachment-upload) */\n const hasMultipleAttachments = useMemo(() => {\n return doesMessageContainMultipleAttachments(message);\n }, [message]);\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 data-testId={strings.editBoxCancelButton}\n />\n <InputBoxButton\n className={richTextActionButtonsStyle}\n ariaLabel={strings.editBoxSubmitButton}\n tooltipContent={strings.editBoxSubmitButton}\n onRenderIcon={onRenderThemedSubmitIcon}\n onClick={(e) => {\n // it's very important to pass an empty attachment here\n // so when user removes all attachments, UI can reflect it instantly\n // if you set it to undefined, the attachments pre-edited would still be there\n // until edit message event is received\n submitEnabled &&\n onSubmit(textValue, /* @conditional-compile-remove(attachment-upload) */ attachmentMetadata);\n e.stopPropagation();\n }}\n id={'submitIconWrapper'}\n data-testId={strings.editBoxSubmitButton}\n />\n </Stack>\n );\n }, [\n /* @conditional-compile-remove(attachment-upload) */\n attachmentMetadata,\n message.messageId,\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, ...strings };\n return locale.sendBox;\n }, [\n /* @conditional-compile-remove(rich-text-editor) */ locale.richTextSendBox,\n /* @conditional-compile-remove(rich-text-editor) */ strings,\n locale.sendBox\n ]);\n\n /* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\n const onCancelAttachmentUpload = useCallback((attachmentId: string) => {\n // edit box only capable of removing attachments\n // we need to expand attachment actions\n // if we want to support more actions e.g. add\n handleAttachmentAction({ type: 'remove', id: attachmentId });\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 attachments={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 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: mergeClasses(\n chatMyMessageStyles.root,\n /* @conditional-compile-remove(attachment-upload) */\n hasMultipleAttachments ? chatMyMessageStyles.multipleAttachments : undefined\n )\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\nexport default ChatMessageComponentAsRichTextEditBox;\n"]}
@@ -23,7 +23,7 @@ export const InputBoxComponent = (props) => {
23
23
  }
24
24
  });
25
25
  const onTextFieldKeyDown = useCallback((ev) => {
26
- if (isEnterKeyEventFromCompositionSession(ev)) {
26
+ if (isEnterKeyEventFromCompositionSession(ev.nativeEvent)) {
27
27
  return;
28
28
  }
29
29
  if (ev.key === 'Enter' && (ev.shiftKey === false || !supportNewline)) {
@@ -1 +1 @@
1
- {"version":3,"file":"InputBoxComponent.js","sourceRoot":"","sources":["../../../../../../react-components/src/components/InputBoxComponent.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,EAAE,EAAwB,WAAW,EAAE,MAAM,OAAO,CAAC;AAEjE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAsB,eAAe,EAAmB,MAAM,iBAAiB,CAAC;AAEtH,OAAO,EAAE,qCAAqC,EAAE,MAAM,SAAS,CAAC;AAEhE,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EACnB,MAAM,kCAAkC,CAAC;AAI1C,0CAA0C;AAC1C,OAAO,EAAE,oBAAoB,EAA6B,MAAM,6CAA6C,CAAC;AAqC9G;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA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QAAQ,EAClB,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACb,4EAA4E;oBAC5E,mEAAmE;oBACnE,CAAC,CAAC,aAAa,CAAC,KAAK,GAAG,EAAE,CAAC;oBAC3B,CAAC,CAAC,aAAa,CAAC,KAAK,GAAG,SAAS,CAAC;gBACpC,CAAC,IACD,CACE,CACP,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,KAAK,IAAC,SAAS,EAAE,eAAe;QAC/B,6BAAK,SAAS,EAAE,wBAAwB,IAAG,eAAe,EAAE,CAAO,CAC7D,CACT,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport React, { ReactNode, FormEvent, useCallback } from 'react';\n\nimport { Stack, TextField, mergeStyles, IStyle, ITextField, concatStyleSets, ITextFieldProps } from '@fluentui/react';\nimport { BaseCustomStyles } from '../types';\nimport { isEnterKeyEventFromCompositionSession } from './utils';\n\nimport {\n inputBoxStyle,\n inputBoxWrapperStyle,\n textFieldStyle,\n textContainerStyle\n} from './styles/InputBoxComponent.style';\n\n/* @conditional-compile-remove(mention) */\nimport { MentionLookupOptions } from './MentionPopover';\n/* @conditional-compile-remove(mention) */\nimport { TextFieldWithMention, TextFieldWithMentionProps } from './TextFieldWithMention/TextFieldWithMention';\n\n/**\n * @private\n */\nexport interface InputBoxStylesProps extends BaseCustomStyles {\n /** Styles for the text field. */\n textField?: IStyle;\n\n /** Styles for the system message; These styles will be ignored when a custom system message component is provided. */\n systemMessage?: IStyle;\n\n /** Styles for customizing the container of the text field */\n textFieldContainer?: IStyle;\n}\n\ntype InputBoxComponentProps = {\n children?: ReactNode;\n 'data-ui-id'?: string;\n id?: string;\n textValue: string; // This could be plain text or HTML.\n onChange: (event?: FormEvent<HTMLInputElement | HTMLTextAreaElement>, newValue?: string) => void;\n textFieldRef?: React.RefObject<ITextField>;\n inputClassName?: string;\n placeholderText?: string;\n supportNewline?: boolean;\n maxLength: number;\n onKeyDown?: (ev: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => void;\n onEnterKeyDown?: () => void;\n errorMessage?: string | React.ReactElement;\n disabled?: boolean;\n styles?: InputBoxStylesProps;\n autoFocus?: 'sendBoxTextField';\n /* @conditional-compile-remove(mention) */\n mentionLookupOptions?: MentionLookupOptions;\n};\n\n/**\n * @private\n */\nexport const InputBoxComponent = (props: InputBoxComponentProps): JSX.Element => {\n const {\n styles,\n id,\n 'data-ui-id': dataUiId,\n textValue,\n onChange,\n textFieldRef,\n placeholderText,\n onKeyDown,\n onEnterKeyDown,\n supportNewline,\n inputClassName,\n errorMessage,\n disabled,\n children\n } = props;\n const mergedRootStyle = mergeStyles(inputBoxWrapperStyle, styles?.root);\n const mergedInputFieldStyle = mergeStyles(inputBoxStyle, inputClassName);\n\n const mergedTextContainerStyle = mergeStyles(textContainerStyle, styles?.textFieldContainer);\n const mergedTextFieldStyle = concatStyleSets(textFieldStyle, {\n fieldGroup: styles?.textField,\n errorMessage: styles?.systemMessage,\n suffix: {\n backgroundColor: 'transparent',\n padding: '0 0'\n }\n });\n\n const onTextFieldKeyDown = useCallback(\n (ev: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (isEnterKeyEventFromCompositionSession(ev)) {\n return;\n }\n if (ev.key === 'Enter' && (ev.shiftKey === false || !supportNewline)) {\n ev.preventDefault();\n onEnterKeyDown && onEnterKeyDown();\n }\n onKeyDown && onKeyDown(ev);\n },\n [onEnterKeyDown, onKeyDown, supportNewline]\n );\n\n const onRenderChildren = (): JSX.Element => {\n return <>{children}</>;\n };\n\n const renderTextField = (): JSX.Element => {\n const textFieldProps: ITextFieldProps = {\n autoFocus: props.autoFocus === 'sendBoxTextField',\n multiline: true,\n autoAdjustHeight: true,\n multiple: false,\n resizable: false,\n componentRef: textFieldRef,\n id,\n inputClassName: mergedInputFieldStyle,\n placeholder: placeholderText,\n autoComplete: 'off',\n styles: mergedTextFieldStyle,\n disabled,\n errorMessage,\n onRenderSuffix: props.children ? onRenderChildren : undefined\n };\n\n /* @conditional-compile-remove(mention) */\n const textFieldWithMentionProps: TextFieldWithMentionProps = {\n textFieldProps: textFieldProps,\n dataUiId: dataUiId,\n textValue: textValue,\n onChange: onChange,\n onKeyDown: onKeyDown,\n onEnterKeyDown: onEnterKeyDown,\n textFieldRef: textFieldRef,\n supportNewline: supportNewline,\n mentionLookupOptions: props.mentionLookupOptions\n };\n /* @conditional-compile-remove(mention) */\n if (props.mentionLookupOptions) {\n return <TextFieldWithMention {...textFieldWithMentionProps} />;\n }\n return (\n <div style={textFieldProps.errorMessage ? { padding: '0 0 5px 5px' } : undefined}>\n <TextField\n {...textFieldProps}\n data-ui-id={dataUiId}\n value={textValue}\n onChange={onChange}\n onKeyDown={onTextFieldKeyDown}\n onFocus={(e) => {\n // Fix for setting the cursor to the correct position when multiline is true\n // This approach should be reviewed during migration to FluentUI v9\n e.currentTarget.value = '';\n e.currentTarget.value = textValue;\n }}\n />\n </div>\n );\n };\n\n return (\n <Stack className={mergedRootStyle}>\n <div className={mergedTextContainerStyle}>{renderTextField()}</div>\n </Stack>\n );\n};\n"]}
1
+ {"version":3,"file":"InputBoxComponent.js","sourceRoot":"","sources":["../../../../../../react-components/src/components/InputBoxComponent.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,EAAE,EAAwB,WAAW,EAAE,MAAM,OAAO,CAAC;AAEjE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAsB,eAAe,EAAmB,MAAM,iBAAiB,CAAC;AAEtH,OAAO,EAAE,qCAAqC,EAAE,MAAM,SAAS,CAAC;AAEhE,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EACnB,MAAM,kCAAkC,CAAC;AAI1C,0CAA0C;AAC1C,OAAO,EAAE,oBAAoB,EAA6B,MAAM,6CAA6C,CAAC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,cAAc,kBACN,QAAQ,EACpB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACb,4EAA4E;oBAC5E,mEAAmE;oBACnE,CAAC,CAAC,aAAa,CAAC,KAAK,GAAG,EAAE,CAAC;oBAC3B,CAAC,CAAC,aAAa,CAAC,KAAK,GAAG,SAAS,CAAC;gBACpC,CAAC,IACD,CACE,CACP,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,KAAK,IAAC,SAAS,EAAE,eAAe;QAC/B,6BAAK,SAAS,EAAE,wBAAwB,IAAG,eAAe,EAAE,CAAO,CAC7D,CACT,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport React, { ReactNode, FormEvent, useCallback } from 'react';\n\nimport { Stack, TextField, mergeStyles, IStyle, ITextField, concatStyleSets, ITextFieldProps } from '@fluentui/react';\nimport { BaseCustomStyles } from '../types';\nimport { isEnterKeyEventFromCompositionSession } from './utils';\n\nimport {\n inputBoxStyle,\n inputBoxWrapperStyle,\n textFieldStyle,\n textContainerStyle\n} from './styles/InputBoxComponent.style';\n\n/* @conditional-compile-remove(mention) */\nimport { MentionLookupOptions } from './MentionPopover';\n/* @conditional-compile-remove(mention) */\nimport { TextFieldWithMention, TextFieldWithMentionProps } from './TextFieldWithMention/TextFieldWithMention';\n\n/**\n * @private\n */\nexport interface InputBoxStylesProps extends BaseCustomStyles {\n /** Styles for the text field. */\n textField?: IStyle;\n\n /** Styles for the system message; These styles will be ignored when a custom system message component is provided. */\n systemMessage?: IStyle;\n\n /** Styles for customizing the container of the text field */\n textFieldContainer?: IStyle;\n}\n\ntype InputBoxComponentProps = {\n children?: ReactNode;\n 'data-ui-id'?: string;\n id?: string;\n textValue: string; // This could be plain text or HTML.\n onChange: (event?: FormEvent<HTMLInputElement | HTMLTextAreaElement>, newValue?: string) => void;\n textFieldRef?: React.RefObject<ITextField>;\n inputClassName?: string;\n placeholderText?: string;\n supportNewline?: boolean;\n maxLength: number;\n onKeyDown?: (ev: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => void;\n onEnterKeyDown?: () => void;\n errorMessage?: string | React.ReactElement;\n disabled?: boolean;\n styles?: InputBoxStylesProps;\n autoFocus?: 'sendBoxTextField';\n /* @conditional-compile-remove(mention) */\n mentionLookupOptions?: MentionLookupOptions;\n};\n\n/**\n * @private\n */\nexport const InputBoxComponent = (props: InputBoxComponentProps): JSX.Element => {\n const {\n styles,\n id,\n 'data-ui-id': dataUiId,\n textValue,\n onChange,\n textFieldRef,\n placeholderText,\n onKeyDown,\n onEnterKeyDown,\n supportNewline,\n inputClassName,\n errorMessage,\n disabled,\n children\n } = props;\n const mergedRootStyle = mergeStyles(inputBoxWrapperStyle, styles?.root);\n const mergedInputFieldStyle = mergeStyles(inputBoxStyle, inputClassName);\n\n const mergedTextContainerStyle = mergeStyles(textContainerStyle, styles?.textFieldContainer);\n const mergedTextFieldStyle = concatStyleSets(textFieldStyle, {\n fieldGroup: styles?.textField,\n errorMessage: styles?.systemMessage,\n suffix: {\n backgroundColor: 'transparent',\n padding: '0 0'\n }\n });\n\n const onTextFieldKeyDown = useCallback(\n (ev: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (isEnterKeyEventFromCompositionSession(ev.nativeEvent)) {\n return;\n }\n if (ev.key === 'Enter' && (ev.shiftKey === false || !supportNewline)) {\n ev.preventDefault();\n onEnterKeyDown && onEnterKeyDown();\n }\n onKeyDown && onKeyDown(ev);\n },\n [onEnterKeyDown, onKeyDown, supportNewline]\n );\n\n const onRenderChildren = (): JSX.Element => {\n return <>{children}</>;\n };\n\n const renderTextField = (): JSX.Element => {\n const textFieldProps: ITextFieldProps = {\n autoFocus: props.autoFocus === 'sendBoxTextField',\n multiline: true,\n autoAdjustHeight: true,\n multiple: false,\n resizable: false,\n componentRef: textFieldRef,\n id,\n inputClassName: mergedInputFieldStyle,\n placeholder: placeholderText,\n autoComplete: 'off',\n styles: mergedTextFieldStyle,\n disabled,\n errorMessage,\n onRenderSuffix: props.children ? onRenderChildren : undefined\n };\n\n /* @conditional-compile-remove(mention) */\n const textFieldWithMentionProps: TextFieldWithMentionProps = {\n textFieldProps: textFieldProps,\n dataUiId: dataUiId,\n textValue: textValue,\n onChange: onChange,\n onKeyDown: onKeyDown,\n onEnterKeyDown: onEnterKeyDown,\n textFieldRef: textFieldRef,\n supportNewline: supportNewline,\n mentionLookupOptions: props.mentionLookupOptions\n };\n /* @conditional-compile-remove(mention) */\n if (props.mentionLookupOptions) {\n return <TextFieldWithMention {...textFieldWithMentionProps} />;\n }\n return (\n <div style={textFieldProps.errorMessage ? { padding: '0 0 5px 5px' } : undefined}>\n <TextField\n {...textFieldProps}\n data-ui-id={dataUiId}\n value={textValue}\n onChange={onChange}\n onKeyDown={onTextFieldKeyDown}\n onFocus={(e) => {\n // Fix for setting the cursor to the correct position when multiline is true\n // This approach should be reviewed during migration to FluentUI v9\n e.currentTarget.value = '';\n e.currentTarget.value = textValue;\n }}\n />\n </div>\n );\n };\n\n return (\n <Stack className={mergedRootStyle}>\n <div className={mergedTextContainerStyle}>{renderTextField()}</div>\n </Stack>\n );\n};\n"]}
@@ -0,0 +1,9 @@
1
+ import { ContextMenuPluginBase } from 'roosterjs-content-model-plugins';
2
+ import type { IContextualMenuItem } from '@fluentui/react/';
3
+ /**
4
+ * Represents a plugin that adds a context menu to the rich text editor.
5
+ */
6
+ export declare class ContextMenuPlugin extends ContextMenuPluginBase<IContextualMenuItem> {
7
+ constructor(onRender: (container: HTMLElement, items: IContextualMenuItem[], onDismiss: () => void) => void, onDismiss: () => void);
8
+ }
9
+ //# sourceMappingURL=ContextMenuPlugin.d.ts.map
@@ -0,0 +1,29 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { ContextMenuPluginBase } from 'roosterjs-content-model-plugins';
4
+ /**
5
+ * Represents a plugin that adds a context menu to the rich text editor.
6
+ */
7
+ export class ContextMenuPlugin extends ContextMenuPluginBase {
8
+ constructor(onRender, onDismiss) {
9
+ super({
10
+ /**
11
+ * Renders the context menu in the specified container with the provided items.
12
+ * @param container - The container element where the context menu should be rendered.
13
+ * @param items - The items to be displayed in the context menu.
14
+ * @param onDismiss - Callback function to be called when the context menu is dismissed. It will call `dismiss` method.
15
+ */
16
+ render: (container, items, onDismissCallback) => {
17
+ const filteredItems = items.filter((item) => item !== null);
18
+ onRender(container, filteredItems, onDismissCallback);
19
+ },
20
+ /**
21
+ * Dismisses the context menu.
22
+ */
23
+ dismiss: () => {
24
+ onDismiss();
25
+ }
26
+ });
27
+ }
28
+ }
29
+ //# sourceMappingURL=ContextMenuPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextMenuPlugin.js","sourceRoot":"","sources":["../../../../../../../../react-components/src/components/RichTextEditor/Plugins/ContextMenuPlugin.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAGxE;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,qBAA0C;IAC/E,YACE,QAA+F,EAC/F,SAAqB;QAErB,KAAK,CAAC;YACJ;;;;;eAKG;YACH,MAAM,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,iBAAiB,EAAE,EAAE;gBAC9C,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAA+B,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;gBACzF,QAAQ,CAAC,SAAS,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAC;YACxD,CAAC;YACD;;eAEG;YACH,OAAO,EAAE,GAAG,EAAE;gBACZ,SAAS,EAAE,CAAC;YACd,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { ContextMenuPluginBase } from 'roosterjs-content-model-plugins';\nimport type { IContextualMenuItem } from '@fluentui/react/';\n\n/**\n * Represents a plugin that adds a context menu to the rich text editor.\n */\nexport class ContextMenuPlugin extends ContextMenuPluginBase<IContextualMenuItem> {\n constructor(\n onRender: (container: HTMLElement, items: IContextualMenuItem[], onDismiss: () => void) => void,\n onDismiss: () => void\n ) {\n super({\n /**\n * Renders the context menu in the specified container with the provided items.\n * @param container - The container element where the context menu should be rendered.\n * @param items - The items to be displayed in the context menu.\n * @param onDismiss - Callback function to be called when the context menu is dismissed. It will call `dismiss` method.\n */\n render: (container, items, onDismissCallback) => {\n const filteredItems = items.filter((item): item is IContextualMenuItem => item !== null);\n onRender(container, filteredItems, onDismissCallback);\n },\n /**\n * Dismisses the context menu.\n */\n dismiss: () => {\n onDismiss();\n }\n });\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { PluginEvent, EditorPlugin, IEditor } from 'roosterjs-editor-types';
1
+ import type { PluginEvent, EditorPlugin, IEditor } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * CopyPastePlugin is a plugin for handling copy and paste events in the editor.
4
4
  */
@@ -1,7 +1,4 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- import { getPositionRect, normalizeRect } from 'roosterjs-editor-dom';
4
- import { CompatiblePluginEventType, CompatiblePasteType, CompatibleChangeSource } from 'roosterjs-editor-types-compatible';
1
+ import { ContentChangedEventSource, PluginEventType } from '../../utils/RichTextEditorUtils';
5
2
  /**
6
3
  * CopyPastePlugin is a plugin for handling copy and paste events in the editor.
7
4
  */
@@ -30,7 +27,7 @@ export default class CopyPastePlugin {
30
27
  */
31
28
  export const removeImageElement = (event) => {
32
29
  // We don't support the pasting options such as paste as image yet.
33
- if (event.eventType === CompatiblePluginEventType.BeforePaste && event.pasteType === CompatiblePasteType.Normal) {
30
+ if (event.eventType === PluginEventType.BeforePaste && event.pasteType === 'normal') {
34
31
  event.fragment.querySelectorAll('img').forEach((image) => {
35
32
  // If the image is the only child of its parent, remove all the parents of this img element.
36
33
  let parentNode = image.parentElement;
@@ -49,25 +46,23 @@ export const removeImageElement = (event) => {
49
46
  * @param editor - The editor instance.
50
47
  */
51
48
  export const scrollToBottomAfterContentPaste = (event, editor) => {
52
- if (event.eventType === CompatiblePluginEventType.ContentChanged && event.source === CompatibleChangeSource.Paste) {
53
- // current focused position in the editor
54
- const focusedPosition = editor.getFocusedPosition();
55
- // the cursor position relative to the viewport
56
- const cursorRect = focusedPosition && getPositionRect(focusedPosition);
57
- // the scroll container of the editor
49
+ if (event.eventType === PluginEventType.ContentChanged && event.source === ContentChangedEventSource.Paste) {
58
50
  const scrollContainer = editor.getScrollContainer();
59
- // the scrollContainer position relative to the viewport
60
- const scrollContainerRect = normalizeRect(scrollContainer.getBoundingClientRect());
61
- if (focusedPosition !== null && cursorRect !== null && cursorRect !== undefined && scrollContainerRect !== null) {
62
- const textElement = focusedPosition.element;
63
- // the caret height is typically the same as the font size of the text
64
- const caretHeight = parseFloat(window.getComputedStyle(textElement).fontSize);
51
+ // get current selection for the editor
52
+ const selection = document.getSelection();
53
+ // if selection exists
54
+ if (selection && selection.rangeCount > 0) {
55
+ // the range for the selection
56
+ const range = selection.getRangeAt(0);
57
+ // the selection position relative to the viewport
58
+ const cursorRect = range.getBoundingClientRect();
59
+ // the scrollContainer position relative to the viewport
60
+ const scrollContainerRect = scrollContainer.getBoundingClientRect();
65
61
  // 1. scrollContainer.scrollTop represents the number of pixels that the content of scrollContainer is scrolled upward.
66
62
  // 2. subtract the top position of the scrollContainer element (scrollContainerRect.top) to
67
63
  // translate the scroll position from being relative to the document to being relative to the viewport.
68
- // 3. add the top position of the cursor (cursorRect.top) to moves the scroll position to the cursor's position.
69
- // 4. subtract a caret height to add some space between the cursor and the top edge of the scrollContainer.
70
- const updatedScrollTop = scrollContainer.scrollTop - scrollContainerRect.top + cursorRect.top - caretHeight;
64
+ // 3. add the top position of the cursor (containerRect.top) to moves the scroll position to the cursor's position.
65
+ const updatedScrollTop = scrollContainer.scrollTop - scrollContainerRect.top + cursorRect.top;
71
66
  scrollContainer.scrollTo({
72
67
  top: updatedScrollTop,
73
68
  behavior: 'smooth'
@@ -1 +1 @@
1
- {"version":3,"file":"CopyPastePlugin.js","sourceRoot":"","sources":["../../../../../../../../react-components/src/components/RichTextEditor/Plugins/CopyPastePlugin.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEtE,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,mCAAmC,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAApC;QACU,WAAM,GAAmB,IAAI,CAAC;IAoBxC,CAAC;IAlBC,OAAO;QACL,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,UAAU,CAAC,MAAe;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,OAAO,KAAU,CAAC;IAElB,aAAa,CAAC,KAAkB;QAC9B,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAE1B,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC;YACtD,kEAAkE;YAClE,+BAA+B,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAkB,EAAQ,EAAE;IAC7D,mEAAmE;IACnE,IAAI,KAAK,CAAC,SAAS,KAAK,yBAAyB,CAAC,WAAW,IAAI,KAAK,CAAC,SAAS,KAAK,mBAAmB,CAAC,MAAM,EAAE,CAAC;QAChH,KAAK,CAAC,QAAQ,C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AgB,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC;YAC9E,uHAAuH;YACvH,2FAA2F;YAC3F,uGAAuG;YACvG,gHAAgH;YAChH,2GAA2G;YAC3G,MAAM,gBAAgB,GAAG,eAAe,CAAC,SAAS,GAAG,mBAAmB,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,GAAG,WAAW,CAAC;YAC5G,eAAe,CAAC,QAAQ,CAAC;gBACvB,GAAG,EAAE,gBAAgB;gBACrB,QAAQ,EAAE,QAAQ;aACnB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { getPositionRect, normalizeRect } from 'roosterjs-editor-dom';\nimport type { PluginEvent, EditorPlugin, IEditor } from 'roosterjs-editor-types';\nimport {\n CompatiblePluginEventType,\n CompatiblePasteType,\n CompatibleChangeSource\n} from 'roosterjs-editor-types-compatible';\n\n/**\n * CopyPastePlugin is a plugin for handling copy and paste events in the editor.\n */\nexport default class CopyPastePlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n\n getName(): string {\n return 'CopyPastePlugin';\n }\n\n initialize(editor: IEditor): void {\n this.editor = editor;\n }\n\n dispose(): void {}\n\n onPluginEvent(event: PluginEvent): void {\n removeImageElement(event);\n\n if (this.editor !== null && !this.editor.isDisposed()) {\n // scroll the editor to the correct position after pasting content\n scrollToBottomAfterContentPaste(event, this.editor);\n }\n }\n}\n\n/**\n * @internal\n * Exported only for unit testing\n */\nexport const removeImageElement = (event: PluginEvent): void => {\n // We don't support the pasting options such as paste as image yet.\n if (event.eventType === CompatiblePluginEventType.BeforePaste && event.pasteType === CompatiblePasteType.Normal) {\n event.fragment.querySelectorAll('img').forEach((image) => {\n // If the image is the only child of its parent, remove all the parents of this img element.\n let parentNode: HTMLElement | null = image.parentElement;\n let currentNode: HTMLElement = image;\n while (parentNode?.childNodes.length === 1) {\n currentNode = parentNode;\n parentNode = parentNode.parentElement;\n }\n currentNode?.remove();\n });\n }\n};\n\n/**\n * Scrolls the editor's scroll container to the bottom after content is pasted.\n * @param event - The plugin event.\n * @param editor - The editor instance.\n */\nexport const scrollToBottomAfterContentPaste = (event: PluginEvent, editor: IEditor): void => {\n if (event.eventType === CompatiblePluginEventType.ContentChanged && event.source === CompatibleChangeSource.Paste) {\n // current focused position in the editor\n const focusedPosition = editor.getFocusedPosition();\n // the cursor position relative to the viewport\n const cursorRect = focusedPosition && getPositionRect(focusedPosition);\n // the scroll container of the editor\n const scrollContainer = editor.getScrollContainer();\n // the scrollContainer position relative to the viewport\n const scrollContainerRect = normalizeRect(scrollContainer.getBoundingClientRect());\n if (focusedPosition !== null && cursorRect !== null && cursorRect !== undefined && scrollContainerRect !== null) {\n const textElement = focusedPosition.element;\n // the caret height is typically the same as the font size of the text\n const caretHeight = parseFloat(window.getComputedStyle(textElement).fontSize);\n // 1. scrollContainer.scrollTop represents the number of pixels that the content of scrollContainer is scrolled upward.\n // 2. subtract the top position of the scrollContainer element (scrollContainerRect.top) to\n // translate the scroll position from being relative to the document to being relative to the viewport.\n // 3. add the top position of the cursor (cursorRect.top) to moves the scroll position to the cursor's position.\n // 4. subtract a caret height to add some space between the cursor and the top edge of the scrollContainer.\n const updatedScrollTop = scrollContainer.scrollTop - scrollContainerRect.top + cursorRect.top - caretHeight;\n scrollContainer.scrollTo({\n top: updatedScrollTop,\n behavior: 'smooth'\n });\n }\n }\n};\n"]}
1
+ {"version":3,"file":"CopyPastePlugin.js","sourceRoot":"","sources":["../../../../../../../../react-components/src/components/RichTextEditor/Plugins/CopyPastePlugin.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAE7F;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAApC;QACU,WAAM,GAAmB,IAAI,CAAC;IAmBxC,CAAC;IAjBC,OAAO;QACL,OAAO,iBAAiB,CAAC;IAC3B,C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CAAC,MAAM,KAAK,yBAAyB,CAAC,KAAK,EAAE,CAAC;QAC3G,MAAM,eAAe,GAAG,MAAM,CAAC,kBAAkB,EAAE,CAAC;QACpD,uCAAuC;QACvC,MAAM,SAAS,GAAG,QAAQ,CAAC,YAAY,EAAE,CAAC;QAC1C,sBAAsB;QACtB,IAAI,SAAS,IAAI,SAAS,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;YAC1C,8BAA8B;YAC9B,MAAM,KAAK,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACtC,kDAAkD;YAClD,MAAM,UAAU,GAAG,KAAK,CAAC,qBAAqB,EAAE,CAAC;YACjD,wDAAwD;YACxD,MAAM,mBAAmB,GAAG,eAAe,CAAC,qBAAqB,EAAE,CAAC;YACpE,uHAAuH;YACvH,2FAA2F;YAC3F,uGAAuG;YACvG,mHAAmH;YACnH,MAAM,gBAAgB,GAAG,eAAe,CAAC,SAAS,GAAG,mBAAmB,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;YAC9F,eAAe,CAAC,QAAQ,CAAC;gBACvB,GAAG,EAAE,gBAAgB;gBACrB,QAAQ,EAAE,QAAQ;aACnB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { PluginEvent, EditorPlugin, IEditor } from 'roosterjs-content-model-types';\nimport { ContentChangedEventSource, PluginEventType } from '../../utils/RichTextEditorUtils';\n\n/**\n * CopyPastePlugin is a plugin for handling copy and paste events in the editor.\n */\nexport default class CopyPastePlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n\n getName(): string {\n return 'CopyPastePlugin';\n }\n\n initialize(editor: IEditor): void {\n this.editor = editor;\n }\n\n dispose(): void {}\n\n onPluginEvent(event: PluginEvent): void {\n removeImageElement(event);\n if (this.editor !== null && !this.editor.isDisposed()) {\n // scroll the editor to the correct position after pasting content\n scrollToBottomAfterContentPaste(event, this.editor);\n }\n }\n}\n\n/**\n * @internal\n * Exported only for unit testing\n */\nexport const removeImageElement = (event: PluginEvent): void => {\n // We don't support the pasting options such as paste as image yet.\n if (event.eventType === PluginEventType.BeforePaste && event.pasteType === 'normal') {\n event.fragment.querySelectorAll('img').forEach((image) => {\n // If the image is the only child of its parent, remove all the parents of this img element.\n let parentNode: HTMLElement | null = image.parentElement;\n let currentNode: HTMLElement = image;\n while (parentNode?.childNodes.length === 1) {\n currentNode = parentNode;\n parentNode = parentNode.parentElement;\n }\n currentNode?.remove();\n });\n }\n};\n\n/**\n * Scrolls the editor's scroll container to the bottom after content is pasted.\n * @param event - The plugin event.\n * @param editor - The editor instance.\n */\nexport const scrollToBottomAfterContentPaste = (event: PluginEvent, editor: IEditor): void => {\n if (event.eventType === PluginEventType.ContentChanged && event.source === ContentChangedEventSource.Paste) {\n const scrollContainer = editor.getScrollContainer();\n // get current selection for the editor\n const selection = document.getSelection();\n // if selection exists\n if (selection && selection.rangeCount > 0) {\n // the range for the selection\n const range = selection.getRangeAt(0);\n // the selection position relative to the viewport\n const cursorRect = range.getBoundingClientRect();\n // the scrollContainer position relative to the viewport\n const scrollContainerRect = scrollContainer.getBoundingClientRect();\n // 1. scrollContainer.scrollTop represents the number of pixels that the content of scrollContainer is scrolled upward.\n // 2. subtract the top position of the scrollContainer element (scrollContainerRect.top) to\n // translate the scroll position from being relative to the document to being relative to the viewport.\n // 3. add the top position of the cursor (containerRect.top) to moves the scroll position to the cursor's position.\n const updatedScrollTop = scrollContainer.scrollTop - scrollContainerRect.top + cursorRect.top;\n scrollContainer.scrollTo({\n top: updatedScrollTop,\n behavior: 'smooth'\n });\n }\n }\n};\n"]}
@@ -0,0 +1,12 @@
1
+ import type { PluginEvent, EditorPlugin } from 'roosterjs-content-model-types';
2
+ /**
3
+ * KeyboardInputPlugin is a plugin for handling keyboard events in the editor.
4
+ */
5
+ export declare class KeyboardInputPlugin implements EditorPlugin {
6
+ onKeyDown?: ((event: KeyboardEvent) => void) | null;
7
+ getName(): string;
8
+ initialize(): void;
9
+ dispose(): void;
10
+ onPluginEvent(event: PluginEvent): void;
11
+ }
12
+ //# sourceMappingURL=KeyboardInputPlugin.d.ts.map
@@ -0,0 +1,23 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { PluginEventType } from '../../utils/RichTextEditorUtils';
4
+ /**
5
+ * KeyboardInputPlugin is a plugin for handling keyboard events in the editor.
6
+ */
7
+ export class KeyboardInputPlugin {
8
+ constructor() {
9
+ // don't set callback in constructor to be able to update callback without plugin recreation
10
+ this.onKeyDown = null;
11
+ }
12
+ getName() {
13
+ return 'KeyboardInputPlugin';
14
+ }
15
+ initialize() { }
16
+ dispose() { }
17
+ onPluginEvent(event) {
18
+ if (this.onKeyDown && event.eventType === PluginEventType.KeyDown && event.rawEvent instanceof KeyboardEvent) {
19
+ this.onKeyDown(event.rawEvent);
20
+ }
21
+ }
22
+ }
23
+ //# sourceMappingURL=KeyboardInputPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyboardInputPlugin.js","sourceRoot":"","sources":["../../../../../../../../react-components/src/components/RichTextEditor/Plugins/KeyboardInputPlugin.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAAhC;QACE,4FAA4F;QAC5F,cAAS,GAA6C,IAAI,CAAC;IAe7D,CAAC;IAbC,OAAO;QACL,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAED,UAAU,KAAU,CAAC;IAErB,OAAO,KAAU,CAAC;IAElB,aAAa,CAAC,KAAkB;QAC9B,IAAI,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,KAAK,eAAe,CAAC,OAAO,IAAI,KAAK,CAAC,QAAQ,YAAY,aAAa,EAAE,CAAC;YAC7G,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PluginEvent, EditorPlugin } from 'roosterjs-content-model-types';\nimport { PluginEventType } from '../../utils/RichTextEditorUtils';\n\n/**\n * KeyboardInputPlugin is a plugin for handling keyboard events in the editor.\n */\nexport class KeyboardInputPlugin implements EditorPlugin {\n // don't set callback in constructor to be able to update callback without plugin recreation\n onKeyDown?: ((event: KeyboardEvent) => void) | null = null;\n\n getName(): string {\n return 'KeyboardInputPlugin';\n }\n\n initialize(): void {}\n\n dispose(): void {}\n\n onPluginEvent(event: PluginEvent): void {\n if (this.onKeyDown && event.eventType === PluginEventType.KeyDown && event.rawEvent instanceof KeyboardEvent) {\n this.onKeyDown(event.rawEvent);\n }\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { WatermarkPlugin } from 'roosterjs-content-model-plugins';
2
+ import type { /*PluginEvent, EditorPlugin,*/ IEditor } from 'roosterjs-content-model-types';
3
+ /**
4
+ * PlaceholderPlugin is a plugin for displaying placeholder and handle localization for it in the editor.
5
+ */
6
+ export default class PlaceholderPlugin extends WatermarkPlugin {
7
+ private isPlaceholderShown;
8
+ private editorValue;
9
+ updatePlaceholder(placeholder: string): void;
10
+ initialize(editor: IEditor): void;
11
+ dispose(): void;
12
+ protected show(editor: IEditor): void;
13
+ protected hide(editor: IEditor): void;
14
+ }
15
+ //# sourceMappingURL=PlaceholderPlugin.d.ts.map
@@ -0,0 +1,39 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { WatermarkPlugin } from 'roosterjs-content-model-plugins';
4
+ /**
5
+ * PlaceholderPlugin is a plugin for displaying placeholder and handle localization for it in the editor.
6
+ */
7
+ export default class PlaceholderPlugin extends WatermarkPlugin {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.isPlaceholderShown = false;
11
+ this.editorValue = null;
12
+ }
13
+ updatePlaceholder(placeholder) {
14
+ this.watermark = placeholder;
15
+ // hide and show the placeholder to show the latest one
16
+ // this needs to be done only if the placeholder is currently shown
17
+ if (this.editorValue && this.isPlaceholderShown) {
18
+ this.hide(this.editorValue);
19
+ this.show(this.editorValue);
20
+ }
21
+ }
22
+ initialize(editor) {
23
+ this.editorValue = editor;
24
+ super.initialize(editor);
25
+ }
26
+ dispose() {
27
+ this.editorValue = null;
28
+ super.dispose();
29
+ }
30
+ show(editor) {
31
+ super.show(editor);
32
+ this.isPlaceholderShown = true;
33
+ }
34
+ hide(editor) {
35
+ super.hide(editor);
36
+ this.isPlaceholderShown = false;
37
+ }
38
+ }
39
+ //# sourceMappingURL=PlaceholderPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlaceholderPlugin.js","sourceRoot":"","sources":["../../../../../../../../react-components/src/components/RichTextEditor/Plugins/PlaceholderPlugin.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAGlE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,eAAe;IAA9D;;QACU,uBAAkB,GAAY,KAAK,CAAC;QACpC,gBAAW,GAAmB,IAAI,CAAC;IA2B7C,CAAC;IAzBC,iBAAiB,CAAC,WAAmB;QACnC,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC;QAC7B,uDAAuD;QACvD,mEAAmE;QACnE,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAChD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC5B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,UAAU,CAAC,MAAe;QACxB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;QAC1B,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO;QACL,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;IACS,IAAI,CAAC,MAAe;QAC5B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnB,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;IACjC,CAAC;IACS,IAAI,CAAC,MAAe;QAC5B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnB,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;IAClC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { WatermarkPlugin } from 'roosterjs-content-model-plugins';\nimport type { /*PluginEvent, EditorPlugin,*/ IEditor } from 'roosterjs-content-model-types';\n\n/**\n * PlaceholderPlugin is a plugin for displaying placeholder and handle localization for it in the editor.\n */\nexport default class PlaceholderPlugin extends WatermarkPlugin {\n private isPlaceholderShown: boolean = false;\n private editorValue: IEditor | null = null;\n\n updatePlaceholder(placeholder: string): void {\n this.watermark = placeholder;\n // hide and show the placeholder to show the latest one\n // this needs to be done only if the placeholder is currently shown\n if (this.editorValue && this.isPlaceholderShown) {\n this.hide(this.editorValue);\n this.show(this.editorValue);\n }\n }\n initialize(editor: IEditor): void {\n this.editorValue = editor;\n super.initialize(editor);\n }\n dispose(): void {\n this.editorValue = null;\n super.dispose();\n }\n protected show(editor: IEditor): void {\n super.show(editor);\n this.isPlaceholderShown = true;\n }\n protected hide(editor: IEditor): void {\n super.hide(editor);\n this.isPlaceholderShown = false;\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import type { ContentModelFormatState, EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
2
+ /**
3
+ * KeyboardInputPlugin is a plugin for handling keyboard events in the editor.
4
+ */
5
+ export declare class RichTextToolbarPlugin implements EditorPlugin {
6
+ private formatState;
7
+ private editor;
8
+ onFormatChanged: ((formatState: ContentModelFormatState) => void) | null;
9
+ getName(): string;
10
+ initialize(editor: IEditor): void;
11
+ dispose(): void;
12
+ onPluginEvent(event: PluginEvent): void;
13
+ /**
14
+ * Handles the click event of a toolbar button.
15
+ * @param buttonAction - The action to be performed when the button is clicked.
16
+ */
17
+ onToolbarButtonClick(buttonAction: (editor: IEditor) => void): void;
18
+ /**
19
+ * Updates the format state of the rich text editor and triggers the `onFormatChanged` callback
20
+ * if there is any difference between the new and the current format states.
21
+ */
22
+ private updateFormat;
23
+ }
24
+ //# sourceMappingURL=RichTextToolbarPlugin.d.ts.map
@@ -0,0 +1,66 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { getFormatState } from 'roosterjs-content-model-api';
4
+ import { getObjectKeys } from 'roosterjs-content-model-dom';
5
+ import { PluginEventType } from '../../utils/RichTextEditorUtils';
6
+ /**
7
+ * KeyboardInputPlugin is a plugin for handling keyboard events in the editor.
8
+ */
9
+ export class RichTextToolbarPlugin {
10
+ constructor() {
11
+ this.formatState = null;
12
+ this.editor = null;
13
+ this.onFormatChanged = null;
14
+ }
15
+ getName() {
16
+ return 'RichTextToolbarPlugin';
17
+ }
18
+ initialize(editor) {
19
+ this.editor = editor;
20
+ }
21
+ dispose() {
22
+ this.editor = null;
23
+ }
24
+ onPluginEvent(event) {
25
+ switch (event.eventType) {
26
+ // KeyDown and MouseUp are used to update the state when the editor is already shown and focused by the user
27
+ case PluginEventType.EditorReady:
28
+ case PluginEventType.ContentChanged:
29
+ case PluginEventType.ZoomChanged:
30
+ case PluginEventType.KeyDown:
31
+ case PluginEventType.MouseUp:
32
+ this.updateFormat();
33
+ break;
34
+ }
35
+ }
36
+ /**
37
+ * Handles the click event of a toolbar button.
38
+ * @param buttonAction - The action to be performed when the button is clicked.
39
+ */
40
+ onToolbarButtonClick(buttonAction) {
41
+ if (this.editor && !this.editor.isDisposed()) {
42
+ buttonAction(this.editor);
43
+ this.updateFormat();
44
+ }
45
+ }
46
+ /**
47
+ * Updates the format state of the rich text editor and triggers the `onFormatChanged` callback
48
+ * if there is any difference between the new and the current format states.
49
+ */
50
+ updateFormat() {
51
+ if (this.editor && this.onFormatChanged) {
52
+ const newFormatState = getFormatState(this.editor);
53
+ // use keys from the format that has more keys or the new format state if there is no current format state
54
+ const keys = !this.formatState || getObjectKeys(newFormatState).length > getObjectKeys(this.formatState).length
55
+ ? getObjectKeys(newFormatState)
56
+ : getObjectKeys(this.formatState);
57
+ // check if there is any difference between the new format state and the current format state
58
+ // otherwise the states will produce new objects every time even when the format state is the same
59
+ if (!this.formatState || keys.some((key) => { var _a; return newFormatState[key] !== ((_a = this.formatState) === null || _a === void 0 ? void 0 : _a[key]); })) {
60
+ this.formatState = newFormatState;
61
+ this.onFormatChanged(newFormatState);
62
+ }
63
+ }
64
+ }
65
+ }
66
+ //# sourceMappingURL=RichTextToolbarPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RichTextToolbarPlugin.js","sourceRoot":"","sources":["../../../../../../../../react-components/src/components/RichTextEditor/Plugins/RichTextToolbarPlugin.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAAlC;QACU,gBAAW,GAAmC,IAAI,CAAC;QACnD,WAAM,GAAmB,IAAI,CAAC;QACtC,oBAAe,GAA4D,IAAI,CAAC;IA0DlF,CAAC;IAxDC,OAAO;QACL,OAAO,uBAAuB,CAAC;IACjC,CAAC;IAED,UAAU,CAAC,MAAe;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,OAAO;QACL,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IAC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C,EAAE,CAAC;gBAC7F,IAAI,CAAC,WAAW,GAAG,cAAc,CAAC;gBAClC,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { getFormatState } from 'roosterjs-content-model-api';\nimport { getObjectKeys } from 'roosterjs-content-model-dom';\nimport type { ContentModelFormatState, EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';\nimport { PluginEventType } from '../../utils/RichTextEditorUtils';\n\n/**\n * KeyboardInputPlugin is a plugin for handling keyboard events in the editor.\n */\nexport class RichTextToolbarPlugin implements EditorPlugin {\n private formatState: ContentModelFormatState | null = null;\n private editor: IEditor | null = null;\n onFormatChanged: ((formatState: ContentModelFormatState) => void) | null = null;\n\n getName(): string {\n return 'RichTextToolbarPlugin';\n }\n\n initialize(editor: IEditor): void {\n this.editor = editor;\n }\n\n dispose(): void {\n this.editor = null;\n }\n\n onPluginEvent(event: PluginEvent): void {\n switch (event.eventType) {\n // KeyDown and MouseUp are used to update the state when the editor is already shown and focused by the user\n case PluginEventType.EditorReady:\n case PluginEventType.ContentChanged:\n case PluginEventType.ZoomChanged:\n case PluginEventType.KeyDown:\n case PluginEventType.MouseUp:\n this.updateFormat();\n break;\n }\n }\n\n /**\n * Handles the click event of a toolbar button.\n * @param buttonAction - The action to be performed when the button is clicked.\n */\n onToolbarButtonClick(buttonAction: (editor: IEditor) => void): void {\n if (this.editor && !this.editor.isDisposed()) {\n buttonAction(this.editor);\n this.updateFormat();\n }\n }\n\n /**\n * Updates the format state of the rich text editor and triggers the `onFormatChanged` callback\n * if there is any difference between the new and the current format states.\n */\n private updateFormat(): void {\n if (this.editor && this.onFormatChanged) {\n const newFormatState = getFormatState(this.editor);\n // use keys from the format that has more keys or the new format state if there is no current format state\n const keys =\n !this.formatState || getObjectKeys(newFormatState).length > getObjectKeys(this.formatState).length\n ? getObjectKeys(newFormatState)\n : getObjectKeys(this.formatState);\n // check if there is any difference between the new format state and the current format state\n // otherwise the states will produce new objects every time even when the format state is the same\n if (!this.formatState || keys.some((key) => newFormatState[key] !== this.formatState?.[key])) {\n this.formatState = newFormatState;\n this.onFormatChanged(newFormatState);\n }\n }\n }\n}\n"]}