sceyt-chat-react-uikit 1.9.0 → 1.9.1-beta.1

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.
@@ -10,10 +10,11 @@ declare type ScrollContainerComponent = React.ComponentType<any>;
10
10
  declare type MessagesContainerComponent = React.ComponentType<{
11
11
  children?: React.ReactNode;
12
12
  }>;
13
- declare const PinnedMessagesList: ({ channelId, onClose, closeRequested, renderMessage, ScrollContainer, MessagesContainer }: {
13
+ declare const PinnedMessagesList: ({ channelId, onClose, closeRequested, selectionIsActive, renderMessage, ScrollContainer, MessagesContainer }: {
14
14
  channelId: string;
15
15
  onClose: () => void;
16
16
  closeRequested?: boolean | undefined;
17
+ selectionIsActive?: boolean | undefined;
17
18
  renderMessage: RenderPinnedMessage;
18
19
  ScrollContainer: ScrollContainerComponent;
19
20
  MessagesContainer: MessagesContainerComponent;
@@ -1,5 +1,26 @@
1
1
  /// <reference types="react" />
2
2
  import { IMessage, IMember } from '../../../types';
3
+ interface SerializedEditorChild {
4
+ type: string;
5
+ text: string;
6
+ format: number;
7
+ mentionName?: string;
8
+ mentionText?: string;
9
+ metadata?: string;
10
+ }
11
+ interface OffsetRange {
12
+ start: number;
13
+ end: number;
14
+ }
15
+ /**
16
+ * Converts Lexical's display text into the wire format used by message
17
+ * attributes. A mention is only converted to its ID token while its text has
18
+ * not been changed by the user. Once edited, it becomes ordinary text.
19
+ */
20
+ export declare function serializeFormattedMessage(messageText: string, children: SerializedEditorChild[], offsetList: OffsetRange[]): {
21
+ messageText: string;
22
+ bodyAttributes: any[];
23
+ };
3
24
  export default function FormatMessagePlugin({ editorState, setMessageBodyAttributes, setMessageText, setMentionedMember, messageToEdit, activeChannelMembers, contactsMap, getFromContacts }: {
4
25
  editorState: any;
5
26
  setMessageBodyAttributes: (data: any) => void;
@@ -10,3 +31,4 @@ export default function FormatMessagePlugin({ editorState, setMessageBodyAttribu
10
31
  contactsMap: any;
11
32
  getFromContacts: boolean;
12
33
  }): JSX.Element | null;
34
+ export {};
@@ -2,7 +2,10 @@ import type { Spread, DOMConversionMap, DOMExportOutput, EditorConfig, LexicalNo
2
2
  import { TextNode } from 'lexical';
3
3
  export declare type SerializedMentionNode = Spread<{
4
4
  mentionName: string;
5
+ /** The label inserted into the editor, used to detect later text edits. */
6
+ mentionText?: string;
5
7
  }, SerializedTextNode>;
8
+ export declare function isMentionTextUnchanged(originalText: string | null | undefined, currentText: string): boolean;
6
9
  export declare class MentionNode extends TextNode {
7
10
  __mention: any;
8
11
  mentionId: string;
@@ -12,6 +15,8 @@ export declare class MentionNode extends TextNode {
12
15
  constructor(mention: any, text?: string, key?: NodeKey);
13
16
  exportJSON(): SerializedMentionNode;
14
17
  createDOM(config: EditorConfig): HTMLElement;
18
+ updateDOM(prevNode: MentionNode, dom: HTMLElement, config: EditorConfig): boolean;
19
+ private isUnchangedMention;
15
20
  exportDOM(): DOMExportOutput;
16
21
  static importDOM(): DOMConversionMap | null;
17
22
  isTextEntity(): true;
package/index.js CHANGED
@@ -14344,6 +14344,7 @@ var messageSlice = createSlice({
14344
14344
  if (state.pinnedMessagesListOpen) {
14345
14345
  state.pinnedMessagesListOpen = false;
14346
14346
  state.pinnedMessagesListCloseRequested = true;
14347
+ state.selectedMessagesMap = null;
14347
14348
  }
14348
14349
  },
14349
14350
  setMessageForReply: function setMessageForReply(state, action) {
@@ -19324,69 +19325,55 @@ function forwardMessage(action) {
19324
19325
  activeChannelId = getActiveChannelId();
19325
19326
  messageTid = null;
19326
19327
  _context15.p = 1;
19327
- if (!(accompanyingMessage !== null && accompanyingMessage !== void 0 && accompanyingMessage.body)) {
19328
- _context15.n = 2;
19329
- break;
19330
- }
19331
19328
  _context15.n = 2;
19332
- return effects.call(sendTextMessage, {
19333
- type: SEND_TEXT_MESSAGE,
19334
- payload: {
19335
- message: accompanyingMessage,
19336
- channelId: channelId,
19337
- connectionState: connectionState
19338
- }
19339
- });
19340
- case 2:
19341
- _context15.n = 3;
19342
19329
  return effects.call(getChannelFromMap, channelId);
19343
- case 3:
19330
+ case 2:
19344
19331
  channel = _context15.v;
19345
19332
  if (channel) {
19346
- _context15.n = 8;
19333
+ _context15.n = 7;
19347
19334
  break;
19348
19335
  }
19349
19336
  channel = getChannelFromAllChannels(channelId) || null;
19350
19337
  if (channel) {
19351
- _context15.n = 6;
19338
+ _context15.n = 5;
19352
19339
  break;
19353
19340
  }
19354
19341
  _SceytChatClient = getClient();
19355
- _context15.n = 4;
19342
+ _context15.n = 3;
19356
19343
  return effects.call(_SceytChatClient.getChannel, channelId);
19357
- case 4:
19344
+ case 3:
19358
19345
  channel = _context15.v;
19359
19346
  if (!channel) {
19360
- _context15.n = 5;
19347
+ _context15.n = 4;
19361
19348
  break;
19362
19349
  }
19363
19350
  setChannelInMap(channel);
19364
19351
  addChannelToAllChannels(_extends({}, channel));
19365
19352
  parsedChannel = JSON.parse(JSON.stringify(channel));
19366
- _context15.n = 5;
19353
+ _context15.n = 4;
19367
19354
  return effects.put(addChannelAC(parsedChannel));
19368
- case 5:
19369
- _context15.n = 7;
19355
+ case 4:
19356
+ _context15.n = 6;
19370
19357
  break;
19371
- case 6:
19358
+ case 5:
19372
19359
  setChannelInMap(channel);
19373
- case 7:
19360
+ case 6:
19374
19361
  if (!channel) {
19375
19362
  channel = getChannelFromAllChannelsMap(channelId);
19376
19363
  }
19377
- case 8:
19364
+ case 7:
19378
19365
  if (channel) {
19379
- _context15.n = 9;
19366
+ _context15.n = 8;
19380
19367
  break;
19381
19368
  }
19382
19369
  throw new Error('Channel not found');
19383
- case 9:
19370
+ case 8:
19384
19371
  mentionedUserIds = message.mentionedUsers ? message.mentionedUsers.map(function (member) {
19385
19372
  return member.id;
19386
19373
  }) : [];
19387
19374
  attachments = message.attachments;
19388
19375
  if ((channel.type === DEFAULT_CHANNEL_TYPE.BROADCAST || channel.type === DEFAULT_CHANNEL_TYPE.PUBLIC) && !(channel.userRole === 'admin' || channel.userRole === 'owner')) {
19389
- _context15.n = 18;
19376
+ _context15.n = 17;
19390
19377
  break;
19391
19378
  }
19392
19379
  if (message.attachments && message.attachments.length && action.type !== RESEND_MESSAGE) {
@@ -19439,28 +19426,28 @@ function forwardMessage(action) {
19439
19426
  pendingMessage.forwardingDetails.hops = message.forwardingDetails ? message.forwardingDetails.hops : 1;
19440
19427
  }
19441
19428
  if (!pendingMessage) {
19442
- _context15.n = 11;
19429
+ _context15.n = 10;
19443
19430
  break;
19444
19431
  }
19445
19432
  if (!(action.type !== RESEND_MESSAGE)) {
19446
- _context15.n = 11;
19433
+ _context15.n = 10;
19447
19434
  break;
19448
19435
  }
19449
- _context15.n = 10;
19436
+ _context15.n = 9;
19450
19437
  return effects.call(loadOGMetadataForLinkMessages, [pendingMessage], true);
19451
- case 10:
19452
- _context15.n = 11;
19438
+ case 9:
19439
+ _context15.n = 10;
19453
19440
  return effects.call(updateMessage$1, action.type, pendingMessage, channel.id, channelId === activeChannelId, message, isNotShowOwnMessageForward, false);
19454
- case 11:
19441
+ case 10:
19455
19442
  if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
19456
- _context15.n = 17;
19443
+ _context15.n = 16;
19457
19444
  break;
19458
19445
  }
19459
- _context15.n = 12;
19446
+ _context15.n = 11;
19460
19447
  return effects.call(channel.sendMessage, _extends({}, messageToSend, isNotShowOwnMessageForward ? {
19461
19448
  forwardingDetails: null
19462
19449
  } : {}));
19463
- case 12:
19450
+ case 11:
19464
19451
  messageResponse = _context15.v;
19465
19452
  responseAttachments = (messageResponse.attachments || attachments || []).map(function (attachment, index) {
19466
19453
  var localAttachment = attachments[index];
@@ -19476,12 +19463,12 @@ function forwardMessage(action) {
19476
19463
  parentMessage: isForward ? null : messageResponse.parentMessage
19477
19464
  });
19478
19465
  if (!(channelId === activeChannelId)) {
19479
- _context15.n = 13;
19466
+ _context15.n = 12;
19480
19467
  break;
19481
19468
  }
19482
- _context15.n = 13;
19469
+ _context15.n = 12;
19483
19470
  return effects.put(updateMessageAC(messageToSend.tid, JSON.parse(JSON.stringify(messageUpdateData)), true));
19484
- case 13:
19471
+ case 12:
19485
19472
  confirmedForward = JSON.parse(JSON.stringify(messageUpdateData));
19486
19473
  updateMessageOnMap(channel.id, {
19487
19474
  messageId: messageToSend.tid,
@@ -19490,15 +19477,15 @@ function forwardMessage(action) {
19490
19477
  addConfirmedMessageToCache(channel.id, confirmedForward);
19491
19478
  messageToUpdate = JSON.parse(JSON.stringify(messageUpdateData));
19492
19479
  if (!channel.unread) {
19493
- _context15.n = 14;
19480
+ _context15.n = 13;
19494
19481
  break;
19495
19482
  }
19496
- _context15.n = 14;
19483
+ _context15.n = 13;
19497
19484
  return effects.put(markChannelAsReadAC(channel.id));
19498
- case 14:
19485
+ case 13:
19499
19486
  resolvedLastMessage = getResolvedChannelLastMessage(channel.id, messageToUpdate, messageToSend);
19500
19487
  if (!lastMessageNeedsUpdate(getReduxChannelLastMessage(channel.id), resolvedLastMessage)) {
19501
- _context15.n = 16;
19488
+ _context15.n = 15;
19502
19489
  break;
19503
19490
  }
19504
19491
  updateChannelLastMessageOnAllChannels(channel.id, resolvedLastMessage);
@@ -19506,15 +19493,29 @@ function forwardMessage(action) {
19506
19493
  lastMessage: resolvedLastMessage,
19507
19494
  lastReactedMessage: null
19508
19495
  };
19509
- _context15.n = 15;
19496
+ _context15.n = 14;
19510
19497
  return effects.put(updateChannelDataAC(channel.id, _extends({}, channel, channelUpdateParam), true, false, true));
19511
- case 15:
19498
+ case 14:
19512
19499
  updateChannelOnAllChannels(channel.id, channelUpdateParam);
19513
- case 16:
19514
- _context15.n = 18;
19500
+ case 15:
19501
+ _context15.n = 17;
19515
19502
  break;
19516
- case 17:
19503
+ case 16:
19517
19504
  throw new Error('Connection required to forward message');
19505
+ case 17:
19506
+ if (!(accompanyingMessage !== null && accompanyingMessage !== void 0 && accompanyingMessage.body)) {
19507
+ _context15.n = 18;
19508
+ break;
19509
+ }
19510
+ _context15.n = 18;
19511
+ return effects.call(sendTextMessage, {
19512
+ type: SEND_TEXT_MESSAGE,
19513
+ payload: {
19514
+ message: accompanyingMessage,
19515
+ channelId: channelId,
19516
+ connectionState: connectionState
19517
+ }
19518
+ });
19518
19519
  case 18:
19519
19520
  _context15.n = 21;
19520
19521
  break;
@@ -42104,7 +42105,7 @@ function ForwardMessagePopup(_ref2) {
42104
42105
  }, /*#__PURE__*/React__default.createElement(ForwardLinkPreviewIcon, {
42105
42106
  color: accentColor,
42106
42107
  bg: surface1
42107
- }))) : firstForwardAttachment ? (/*#__PURE__*/React__default.createElement(ForwardPreviewIconWrapper, {
42108
+ }))) : firstForwardAttachment && firstForwardAttachment.type !== attachmentTypes.voice ? (/*#__PURE__*/React__default.createElement(ForwardPreviewIconWrapper, {
42108
42109
  backgroundColor: accentColor,
42109
42110
  iconColor: textOnPrimary
42110
42111
  }, /*#__PURE__*/React__default.createElement(SvgChoseFile, null))) : null, /*#__PURE__*/React__default.createElement(ForwardPreviewInfo, null, /*#__PURE__*/React__default.createElement(ForwardPreviewTitle, {
@@ -45735,6 +45736,8 @@ var PinnedMessagesList = function PinnedMessagesList(_ref) {
45735
45736
  var channelId = _ref.channelId,
45736
45737
  onClose = _ref.onClose,
45737
45738
  closeRequested = _ref.closeRequested,
45739
+ _ref$selectionIsActiv = _ref.selectionIsActive,
45740
+ selectionIsActive = _ref$selectionIsActiv === void 0 ? false : _ref$selectionIsActiv,
45738
45741
  renderMessage = _ref.renderMessage,
45739
45742
  ScrollContainer = _ref.ScrollContainer,
45740
45743
  MessagesContainer = _ref.MessagesContainer;
@@ -45886,7 +45889,7 @@ var PinnedMessagesList = function PinnedMessagesList(_ref) {
45886
45889
  prevMessage: previousMessage || null,
45887
45890
  nextMessage: ((_displayedPins2 = displayedPins[index + 1]) === null || _displayedPins2 === void 0 ? void 0 : _displayedPins2.message) || null,
45888
45891
  index: index
45889
- }), (pin.message.id || pin.message.tid) && (/*#__PURE__*/React__default.createElement(GoToMessageButton, {
45892
+ }), !selectionIsActive && (pin.message.id || pin.message.tid) && (/*#__PURE__*/React__default.createElement(GoToMessageButton, {
45890
45893
  background: backgroundSections,
45891
45894
  className: 'pinned-message-navigation',
45892
45895
  type: 'button',
@@ -53034,6 +53037,7 @@ var MessageList = function MessageList(_ref) {
53034
53037
  channelId: channel.id,
53035
53038
  onClose: closePinnedMessagesList,
53036
53039
  closeRequested: pinnedMessagesListCloseRequested,
53040
+ selectionIsActive: Boolean(selectedMessagesMap === null || selectedMessagesMap === void 0 ? void 0 : selectedMessagesMap.size),
53037
53041
  ScrollContainer: Container$j,
53038
53042
  MessagesContainer: MessagesBox,
53039
53043
  renderMessage: function renderMessage(_ref3) {
@@ -53440,6 +53444,9 @@ var MessagesContainer = function MessagesContainer(_ref) {
53440
53444
  }));
53441
53445
  };
53442
53446
 
53447
+ function isMentionTextUnchanged(originalText, currentText) {
53448
+ return originalText == null || originalText === currentText;
53449
+ }
53443
53450
  function convertMentionElement(domNode) {
53444
53451
  var textContent = domNode.textContent;
53445
53452
  if (textContent !== null) {
@@ -53465,6 +53472,7 @@ var MentionNode = /*#__PURE__*/function (_TextNode) {
53465
53472
  value: function exportJSON() {
53466
53473
  return _extends({}, _superPropGet(MentionNode, "exportJSON", this, 3)([]), {
53467
53474
  mentionName: this.__mention.id,
53475
+ mentionText: this.__mention.name,
53468
53476
  type: 'mention',
53469
53477
  version: 1
53470
53478
  });
@@ -53473,9 +53481,26 @@ var MentionNode = /*#__PURE__*/function (_TextNode) {
53473
53481
  key: "createDOM",
53474
53482
  value: function createDOM(config) {
53475
53483
  var dom = _superPropGet(MentionNode, "createDOM", this, 3)([config]);
53476
- dom.className = 'mention';
53484
+ if (this.isUnchangedMention()) {
53485
+ dom.className = 'mention';
53486
+ }
53477
53487
  return dom;
53478
53488
  }
53489
+ }, {
53490
+ key: "updateDOM",
53491
+ value: function updateDOM(prevNode, dom, config) {
53492
+ var wasUnchangedMention = prevNode.isUnchangedMention();
53493
+ var isUnchangedMention = this.isUnchangedMention();
53494
+ if (wasUnchangedMention !== isUnchangedMention) {
53495
+ dom.classList.toggle('mention', isUnchangedMention);
53496
+ }
53497
+ return _superPropGet(MentionNode, "updateDOM", this, 3)([prevNode, dom, config]);
53498
+ }
53499
+ }, {
53500
+ key: "isUnchangedMention",
53501
+ value: function isUnchangedMention() {
53502
+ return isMentionTextUnchanged(this.__mention.name, this.__text);
53503
+ }
53479
53504
  }, {
53480
53505
  key: "exportDOM",
53481
53506
  value: function exportDOM() {
@@ -53514,7 +53539,11 @@ var MentionNode = /*#__PURE__*/function (_TextNode) {
53514
53539
  }, {
53515
53540
  key: "importJSON",
53516
53541
  value: function importJSON(serializedNode) {
53517
- var node = $createMentionNode(serializedNode.mentionName);
53542
+ var _serializedNode$menti;
53543
+ var node = $createMentionNode({
53544
+ id: serializedNode.mentionName,
53545
+ name: (_serializedNode$menti = serializedNode.mentionText) != null ? _serializedNode$menti : serializedNode.text
53546
+ });
53518
53547
  node.setTextContent(serializedNode.text);
53519
53548
  node.setFormat(serializedNode.format);
53520
53549
  node.setDetail(serializedNode.detail);
@@ -54604,6 +54633,48 @@ function EditMessagePlugin(_ref) {
54604
54633
  return null;
54605
54634
  }
54606
54635
 
54636
+ function serializeFormattedMessage(messageText, children, offsetList) {
54637
+ var currentOffsetDiff = 0;
54638
+ var newMessageText = messageText;
54639
+ var messageBodyAttributes = [];
54640
+ children.forEach(function (child, index) {
54641
+ var offsetRange = offsetList[index];
54642
+ if (!offsetRange) return;
54643
+ var offset = offsetRange.start;
54644
+ var length = offsetRange.end - offsetRange.start;
54645
+ var attributeOffset = offset + currentOffsetDiff;
54646
+ var attributeTypes = bodyAttributesMapByType[child.format];
54647
+ var isUnchangedMention = child.type === 'mention' && Boolean(child.mentionName) && isMentionTextUnchanged(child.mentionText, child.text);
54648
+ if (isUnchangedMention) {
54649
+ var mentionId = "@" + child.mentionName;
54650
+ var idLength = mentionId.length;
54651
+ newMessageText = "" + newMessageText.slice(0, attributeOffset) + mentionId + newMessageText.slice(attributeOffset + length);
54652
+ currentOffsetDiff += idLength - length;
54653
+ messageBodyAttributes.push({
54654
+ type: 'mention',
54655
+ metadata: child.mentionName,
54656
+ offset: attributeOffset,
54657
+ length: idLength
54658
+ });
54659
+ }
54660
+ if (attributeTypes) {
54661
+ var formattedLength = isUnchangedMention ? ("@" + child.mentionName).length : length;
54662
+ var formattedOffset = attributeOffset;
54663
+ attributeTypes.forEach(function (attributeType) {
54664
+ messageBodyAttributes.push({
54665
+ type: attributeType,
54666
+ metadata: child.metadata || '',
54667
+ offset: formattedOffset,
54668
+ length: formattedLength
54669
+ });
54670
+ });
54671
+ }
54672
+ });
54673
+ return {
54674
+ messageText: newMessageText,
54675
+ bodyAttributes: messageBodyAttributes
54676
+ };
54677
+ }
54607
54678
  function parseHTMLToFormattedSegments(html) {
54608
54679
  var parser = new DOMParser();
54609
54680
  var doc = parser.parseFromString(html, 'text/html');
@@ -54833,74 +54904,11 @@ function useFormatMessage(editor, editorState, setMessageBodyAttributes, setMess
54833
54904
  var parsedEditorState = editorState.toJSON();
54834
54905
  var offsetView = offset.$createOffsetView(editor);
54835
54906
  var offsetList = Array.from(offsetView._offsetMap.values());
54836
- var messageBodyAttributes = [];
54837
54907
  if (parsedEditorState.root && parsedEditorState.root.children && parsedEditorState.root.children.length && (parsedEditorState.root.children[0].children.length > 1 || parsedEditorState.root.children[0].children[0] && (parsedEditorState.root.children[0].children[0].type === 'mention' || parsedEditorState.root.children[0].children[0].format > 0))) {
54838
- var currentOffsetDiff = 0;
54839
- var newMessageText = messageText;
54840
- parsedEditorState.root.children[0].children.forEach(function (child, index) {
54841
- if (child.type === 'mention') {
54842
- var offset = offsetList[index].start;
54843
- var length = offsetList[index].end - offsetList[index].start;
54844
- var mentionId = "@" + child.mentionName;
54845
- var idLength = mentionId.length;
54846
- newMessageText = "" + newMessageText.slice(0, offset + currentOffsetDiff) + mentionId + newMessageText.slice(offset + currentOffsetDiff + length);
54847
- var menIndex = offset + currentOffsetDiff;
54848
- currentOffsetDiff += idLength - length;
54849
- messageBodyAttributes.push({
54850
- type: 'mention',
54851
- metadata: child.mentionName,
54852
- offset: menIndex,
54853
- length: idLength
54854
- });
54855
- if (child.format) {
54856
- var attributeTypes = bodyAttributesMapByType[child.format];
54857
- if (attributeTypes.length > 1) {
54858
- attributeTypes.forEach(function (attributeType) {
54859
- messageBodyAttributes.push({
54860
- type: attributeType,
54861
- metadata: child.metadata || '',
54862
- offset: menIndex,
54863
- length: length
54864
- });
54865
- });
54866
- } else {
54867
- messageBodyAttributes.push({
54868
- type: attributeTypes[0],
54869
- metadata: child.metadata || '',
54870
- offset: menIndex,
54871
- length: length
54872
- });
54873
- }
54874
- }
54875
- } else {
54876
- var _attributeTypes = bodyAttributesMapByType[child.format];
54877
- if (_attributeTypes) {
54878
- var _offset = offsetList[index].start;
54879
- var _length = offsetList[index].end - offsetList[index].start;
54880
- var attIndex = _offset + currentOffsetDiff;
54881
- if (_attributeTypes.length > 1) {
54882
- _attributeTypes.forEach(function (attributeType) {
54883
- messageBodyAttributes.push({
54884
- type: attributeType,
54885
- metadata: child.metadata || '',
54886
- offset: attIndex,
54887
- length: _length
54888
- });
54889
- });
54890
- } else {
54891
- messageBodyAttributes.push({
54892
- type: _attributeTypes[0],
54893
- metadata: child.metadata || '',
54894
- offset: attIndex,
54895
- length: _length
54896
- });
54897
- }
54898
- }
54899
- }
54900
- });
54908
+ var serializedMessage = serializeFormattedMessage(messageText, parsedEditorState.root.children[0].children, offsetList);
54901
54909
  if (messageText) {
54902
- setMessageText(newMessageText);
54903
- setMessageBodyAttributes(messageBodyAttributes);
54910
+ setMessageText(serializedMessage.messageText);
54911
+ setMessageBodyAttributes(serializedMessage.bodyAttributes);
54904
54912
  } else {
54905
54913
  setMessageText(messageToEdit ? messageToEdit.body : '');
54906
54914
  }
package/index.modern.js CHANGED
@@ -14324,6 +14324,7 @@ var messageSlice = createSlice({
14324
14324
  if (state.pinnedMessagesListOpen) {
14325
14325
  state.pinnedMessagesListOpen = false;
14326
14326
  state.pinnedMessagesListCloseRequested = true;
14327
+ state.selectedMessagesMap = null;
14327
14328
  }
14328
14329
  },
14329
14330
  setMessageForReply: function setMessageForReply(state, action) {
@@ -19304,69 +19305,55 @@ function forwardMessage(action) {
19304
19305
  activeChannelId = getActiveChannelId();
19305
19306
  messageTid = null;
19306
19307
  _context15.p = 1;
19307
- if (!(accompanyingMessage !== null && accompanyingMessage !== void 0 && accompanyingMessage.body)) {
19308
- _context15.n = 2;
19309
- break;
19310
- }
19311
19308
  _context15.n = 2;
19312
- return call(sendTextMessage, {
19313
- type: SEND_TEXT_MESSAGE,
19314
- payload: {
19315
- message: accompanyingMessage,
19316
- channelId: channelId,
19317
- connectionState: connectionState
19318
- }
19319
- });
19320
- case 2:
19321
- _context15.n = 3;
19322
19309
  return call(getChannelFromMap, channelId);
19323
- case 3:
19310
+ case 2:
19324
19311
  channel = _context15.v;
19325
19312
  if (channel) {
19326
- _context15.n = 8;
19313
+ _context15.n = 7;
19327
19314
  break;
19328
19315
  }
19329
19316
  channel = getChannelFromAllChannels(channelId) || null;
19330
19317
  if (channel) {
19331
- _context15.n = 6;
19318
+ _context15.n = 5;
19332
19319
  break;
19333
19320
  }
19334
19321
  _SceytChatClient = getClient();
19335
- _context15.n = 4;
19322
+ _context15.n = 3;
19336
19323
  return call(_SceytChatClient.getChannel, channelId);
19337
- case 4:
19324
+ case 3:
19338
19325
  channel = _context15.v;
19339
19326
  if (!channel) {
19340
- _context15.n = 5;
19327
+ _context15.n = 4;
19341
19328
  break;
19342
19329
  }
19343
19330
  setChannelInMap(channel);
19344
19331
  addChannelToAllChannels(_extends({}, channel));
19345
19332
  parsedChannel = JSON.parse(JSON.stringify(channel));
19346
- _context15.n = 5;
19333
+ _context15.n = 4;
19347
19334
  return put(addChannelAC(parsedChannel));
19348
- case 5:
19349
- _context15.n = 7;
19335
+ case 4:
19336
+ _context15.n = 6;
19350
19337
  break;
19351
- case 6:
19338
+ case 5:
19352
19339
  setChannelInMap(channel);
19353
- case 7:
19340
+ case 6:
19354
19341
  if (!channel) {
19355
19342
  channel = getChannelFromAllChannelsMap(channelId);
19356
19343
  }
19357
- case 8:
19344
+ case 7:
19358
19345
  if (channel) {
19359
- _context15.n = 9;
19346
+ _context15.n = 8;
19360
19347
  break;
19361
19348
  }
19362
19349
  throw new Error('Channel not found');
19363
- case 9:
19350
+ case 8:
19364
19351
  mentionedUserIds = message.mentionedUsers ? message.mentionedUsers.map(function (member) {
19365
19352
  return member.id;
19366
19353
  }) : [];
19367
19354
  attachments = message.attachments;
19368
19355
  if ((channel.type === DEFAULT_CHANNEL_TYPE.BROADCAST || channel.type === DEFAULT_CHANNEL_TYPE.PUBLIC) && !(channel.userRole === 'admin' || channel.userRole === 'owner')) {
19369
- _context15.n = 18;
19356
+ _context15.n = 17;
19370
19357
  break;
19371
19358
  }
19372
19359
  if (message.attachments && message.attachments.length && action.type !== RESEND_MESSAGE) {
@@ -19419,28 +19406,28 @@ function forwardMessage(action) {
19419
19406
  pendingMessage.forwardingDetails.hops = message.forwardingDetails ? message.forwardingDetails.hops : 1;
19420
19407
  }
19421
19408
  if (!pendingMessage) {
19422
- _context15.n = 11;
19409
+ _context15.n = 10;
19423
19410
  break;
19424
19411
  }
19425
19412
  if (!(action.type !== RESEND_MESSAGE)) {
19426
- _context15.n = 11;
19413
+ _context15.n = 10;
19427
19414
  break;
19428
19415
  }
19429
- _context15.n = 10;
19416
+ _context15.n = 9;
19430
19417
  return call(loadOGMetadataForLinkMessages, [pendingMessage], true);
19431
- case 10:
19432
- _context15.n = 11;
19418
+ case 9:
19419
+ _context15.n = 10;
19433
19420
  return call(updateMessage$1, action.type, pendingMessage, channel.id, channelId === activeChannelId, message, isNotShowOwnMessageForward, false);
19434
- case 11:
19421
+ case 10:
19435
19422
  if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
19436
- _context15.n = 17;
19423
+ _context15.n = 16;
19437
19424
  break;
19438
19425
  }
19439
- _context15.n = 12;
19426
+ _context15.n = 11;
19440
19427
  return call(channel.sendMessage, _extends({}, messageToSend, isNotShowOwnMessageForward ? {
19441
19428
  forwardingDetails: null
19442
19429
  } : {}));
19443
- case 12:
19430
+ case 11:
19444
19431
  messageResponse = _context15.v;
19445
19432
  responseAttachments = (messageResponse.attachments || attachments || []).map(function (attachment, index) {
19446
19433
  var localAttachment = attachments[index];
@@ -19456,12 +19443,12 @@ function forwardMessage(action) {
19456
19443
  parentMessage: isForward ? null : messageResponse.parentMessage
19457
19444
  });
19458
19445
  if (!(channelId === activeChannelId)) {
19459
- _context15.n = 13;
19446
+ _context15.n = 12;
19460
19447
  break;
19461
19448
  }
19462
- _context15.n = 13;
19449
+ _context15.n = 12;
19463
19450
  return put(updateMessageAC(messageToSend.tid, JSON.parse(JSON.stringify(messageUpdateData)), true));
19464
- case 13:
19451
+ case 12:
19465
19452
  confirmedForward = JSON.parse(JSON.stringify(messageUpdateData));
19466
19453
  updateMessageOnMap(channel.id, {
19467
19454
  messageId: messageToSend.tid,
@@ -19470,15 +19457,15 @@ function forwardMessage(action) {
19470
19457
  addConfirmedMessageToCache(channel.id, confirmedForward);
19471
19458
  messageToUpdate = JSON.parse(JSON.stringify(messageUpdateData));
19472
19459
  if (!channel.unread) {
19473
- _context15.n = 14;
19460
+ _context15.n = 13;
19474
19461
  break;
19475
19462
  }
19476
- _context15.n = 14;
19463
+ _context15.n = 13;
19477
19464
  return put(markChannelAsReadAC(channel.id));
19478
- case 14:
19465
+ case 13:
19479
19466
  resolvedLastMessage = getResolvedChannelLastMessage(channel.id, messageToUpdate, messageToSend);
19480
19467
  if (!lastMessageNeedsUpdate(getReduxChannelLastMessage(channel.id), resolvedLastMessage)) {
19481
- _context15.n = 16;
19468
+ _context15.n = 15;
19482
19469
  break;
19483
19470
  }
19484
19471
  updateChannelLastMessageOnAllChannels(channel.id, resolvedLastMessage);
@@ -19486,15 +19473,29 @@ function forwardMessage(action) {
19486
19473
  lastMessage: resolvedLastMessage,
19487
19474
  lastReactedMessage: null
19488
19475
  };
19489
- _context15.n = 15;
19476
+ _context15.n = 14;
19490
19477
  return put(updateChannelDataAC(channel.id, _extends({}, channel, channelUpdateParam), true, false, true));
19491
- case 15:
19478
+ case 14:
19492
19479
  updateChannelOnAllChannels(channel.id, channelUpdateParam);
19493
- case 16:
19494
- _context15.n = 18;
19480
+ case 15:
19481
+ _context15.n = 17;
19495
19482
  break;
19496
- case 17:
19483
+ case 16:
19497
19484
  throw new Error('Connection required to forward message');
19485
+ case 17:
19486
+ if (!(accompanyingMessage !== null && accompanyingMessage !== void 0 && accompanyingMessage.body)) {
19487
+ _context15.n = 18;
19488
+ break;
19489
+ }
19490
+ _context15.n = 18;
19491
+ return call(sendTextMessage, {
19492
+ type: SEND_TEXT_MESSAGE,
19493
+ payload: {
19494
+ message: accompanyingMessage,
19495
+ channelId: channelId,
19496
+ connectionState: connectionState
19497
+ }
19498
+ });
19498
19499
  case 18:
19499
19500
  _context15.n = 21;
19500
19501
  break;
@@ -42084,7 +42085,7 @@ function ForwardMessagePopup(_ref2) {
42084
42085
  }, /*#__PURE__*/React__default.createElement(ForwardLinkPreviewIcon, {
42085
42086
  color: accentColor,
42086
42087
  bg: surface1
42087
- }))) : firstForwardAttachment ? (/*#__PURE__*/React__default.createElement(ForwardPreviewIconWrapper, {
42088
+ }))) : firstForwardAttachment && firstForwardAttachment.type !== attachmentTypes.voice ? (/*#__PURE__*/React__default.createElement(ForwardPreviewIconWrapper, {
42088
42089
  backgroundColor: accentColor,
42089
42090
  iconColor: textOnPrimary
42090
42091
  }, /*#__PURE__*/React__default.createElement(SvgChoseFile, null))) : null, /*#__PURE__*/React__default.createElement(ForwardPreviewInfo, null, /*#__PURE__*/React__default.createElement(ForwardPreviewTitle, {
@@ -45715,6 +45716,8 @@ var PinnedMessagesList = function PinnedMessagesList(_ref) {
45715
45716
  var channelId = _ref.channelId,
45716
45717
  onClose = _ref.onClose,
45717
45718
  closeRequested = _ref.closeRequested,
45719
+ _ref$selectionIsActiv = _ref.selectionIsActive,
45720
+ selectionIsActive = _ref$selectionIsActiv === void 0 ? false : _ref$selectionIsActiv,
45718
45721
  renderMessage = _ref.renderMessage,
45719
45722
  ScrollContainer = _ref.ScrollContainer,
45720
45723
  MessagesContainer = _ref.MessagesContainer;
@@ -45866,7 +45869,7 @@ var PinnedMessagesList = function PinnedMessagesList(_ref) {
45866
45869
  prevMessage: previousMessage || null,
45867
45870
  nextMessage: ((_displayedPins2 = displayedPins[index + 1]) === null || _displayedPins2 === void 0 ? void 0 : _displayedPins2.message) || null,
45868
45871
  index: index
45869
- }), (pin.message.id || pin.message.tid) && (/*#__PURE__*/React__default.createElement(GoToMessageButton, {
45872
+ }), !selectionIsActive && (pin.message.id || pin.message.tid) && (/*#__PURE__*/React__default.createElement(GoToMessageButton, {
45870
45873
  background: backgroundSections,
45871
45874
  className: 'pinned-message-navigation',
45872
45875
  type: 'button',
@@ -53014,6 +53017,7 @@ var MessageList = function MessageList(_ref) {
53014
53017
  channelId: channel.id,
53015
53018
  onClose: closePinnedMessagesList,
53016
53019
  closeRequested: pinnedMessagesListCloseRequested,
53020
+ selectionIsActive: Boolean(selectedMessagesMap === null || selectedMessagesMap === void 0 ? void 0 : selectedMessagesMap.size),
53017
53021
  ScrollContainer: Container$j,
53018
53022
  MessagesContainer: MessagesBox,
53019
53023
  renderMessage: function renderMessage(_ref3) {
@@ -53420,6 +53424,9 @@ var MessagesContainer = function MessagesContainer(_ref) {
53420
53424
  }));
53421
53425
  };
53422
53426
 
53427
+ function isMentionTextUnchanged(originalText, currentText) {
53428
+ return originalText == null || originalText === currentText;
53429
+ }
53423
53430
  function convertMentionElement(domNode) {
53424
53431
  var textContent = domNode.textContent;
53425
53432
  if (textContent !== null) {
@@ -53445,6 +53452,7 @@ var MentionNode = /*#__PURE__*/function (_TextNode) {
53445
53452
  value: function exportJSON() {
53446
53453
  return _extends({}, _superPropGet(MentionNode, "exportJSON", this, 3)([]), {
53447
53454
  mentionName: this.__mention.id,
53455
+ mentionText: this.__mention.name,
53448
53456
  type: 'mention',
53449
53457
  version: 1
53450
53458
  });
@@ -53453,9 +53461,26 @@ var MentionNode = /*#__PURE__*/function (_TextNode) {
53453
53461
  key: "createDOM",
53454
53462
  value: function createDOM(config) {
53455
53463
  var dom = _superPropGet(MentionNode, "createDOM", this, 3)([config]);
53456
- dom.className = 'mention';
53464
+ if (this.isUnchangedMention()) {
53465
+ dom.className = 'mention';
53466
+ }
53457
53467
  return dom;
53458
53468
  }
53469
+ }, {
53470
+ key: "updateDOM",
53471
+ value: function updateDOM(prevNode, dom, config) {
53472
+ var wasUnchangedMention = prevNode.isUnchangedMention();
53473
+ var isUnchangedMention = this.isUnchangedMention();
53474
+ if (wasUnchangedMention !== isUnchangedMention) {
53475
+ dom.classList.toggle('mention', isUnchangedMention);
53476
+ }
53477
+ return _superPropGet(MentionNode, "updateDOM", this, 3)([prevNode, dom, config]);
53478
+ }
53479
+ }, {
53480
+ key: "isUnchangedMention",
53481
+ value: function isUnchangedMention() {
53482
+ return isMentionTextUnchanged(this.__mention.name, this.__text);
53483
+ }
53459
53484
  }, {
53460
53485
  key: "exportDOM",
53461
53486
  value: function exportDOM() {
@@ -53494,7 +53519,11 @@ var MentionNode = /*#__PURE__*/function (_TextNode) {
53494
53519
  }, {
53495
53520
  key: "importJSON",
53496
53521
  value: function importJSON(serializedNode) {
53497
- var node = $createMentionNode(serializedNode.mentionName);
53522
+ var _serializedNode$menti;
53523
+ var node = $createMentionNode({
53524
+ id: serializedNode.mentionName,
53525
+ name: (_serializedNode$menti = serializedNode.mentionText) != null ? _serializedNode$menti : serializedNode.text
53526
+ });
53498
53527
  node.setTextContent(serializedNode.text);
53499
53528
  node.setFormat(serializedNode.format);
53500
53529
  node.setDetail(serializedNode.detail);
@@ -54584,6 +54613,48 @@ function EditMessagePlugin(_ref) {
54584
54613
  return null;
54585
54614
  }
54586
54615
 
54616
+ function serializeFormattedMessage(messageText, children, offsetList) {
54617
+ var currentOffsetDiff = 0;
54618
+ var newMessageText = messageText;
54619
+ var messageBodyAttributes = [];
54620
+ children.forEach(function (child, index) {
54621
+ var offsetRange = offsetList[index];
54622
+ if (!offsetRange) return;
54623
+ var offset = offsetRange.start;
54624
+ var length = offsetRange.end - offsetRange.start;
54625
+ var attributeOffset = offset + currentOffsetDiff;
54626
+ var attributeTypes = bodyAttributesMapByType[child.format];
54627
+ var isUnchangedMention = child.type === 'mention' && Boolean(child.mentionName) && isMentionTextUnchanged(child.mentionText, child.text);
54628
+ if (isUnchangedMention) {
54629
+ var mentionId = "@" + child.mentionName;
54630
+ var idLength = mentionId.length;
54631
+ newMessageText = "" + newMessageText.slice(0, attributeOffset) + mentionId + newMessageText.slice(attributeOffset + length);
54632
+ currentOffsetDiff += idLength - length;
54633
+ messageBodyAttributes.push({
54634
+ type: 'mention',
54635
+ metadata: child.mentionName,
54636
+ offset: attributeOffset,
54637
+ length: idLength
54638
+ });
54639
+ }
54640
+ if (attributeTypes) {
54641
+ var formattedLength = isUnchangedMention ? ("@" + child.mentionName).length : length;
54642
+ var formattedOffset = attributeOffset;
54643
+ attributeTypes.forEach(function (attributeType) {
54644
+ messageBodyAttributes.push({
54645
+ type: attributeType,
54646
+ metadata: child.metadata || '',
54647
+ offset: formattedOffset,
54648
+ length: formattedLength
54649
+ });
54650
+ });
54651
+ }
54652
+ });
54653
+ return {
54654
+ messageText: newMessageText,
54655
+ bodyAttributes: messageBodyAttributes
54656
+ };
54657
+ }
54587
54658
  function parseHTMLToFormattedSegments(html) {
54588
54659
  var parser = new DOMParser();
54589
54660
  var doc = parser.parseFromString(html, 'text/html');
@@ -54813,74 +54884,11 @@ function useFormatMessage(editor, editorState, setMessageBodyAttributes, setMess
54813
54884
  var parsedEditorState = editorState.toJSON();
54814
54885
  var offsetView = $createOffsetView(editor);
54815
54886
  var offsetList = Array.from(offsetView._offsetMap.values());
54816
- var messageBodyAttributes = [];
54817
54887
  if (parsedEditorState.root && parsedEditorState.root.children && parsedEditorState.root.children.length && (parsedEditorState.root.children[0].children.length > 1 || parsedEditorState.root.children[0].children[0] && (parsedEditorState.root.children[0].children[0].type === 'mention' || parsedEditorState.root.children[0].children[0].format > 0))) {
54818
- var currentOffsetDiff = 0;
54819
- var newMessageText = messageText;
54820
- parsedEditorState.root.children[0].children.forEach(function (child, index) {
54821
- if (child.type === 'mention') {
54822
- var offset = offsetList[index].start;
54823
- var length = offsetList[index].end - offsetList[index].start;
54824
- var mentionId = "@" + child.mentionName;
54825
- var idLength = mentionId.length;
54826
- newMessageText = "" + newMessageText.slice(0, offset + currentOffsetDiff) + mentionId + newMessageText.slice(offset + currentOffsetDiff + length);
54827
- var menIndex = offset + currentOffsetDiff;
54828
- currentOffsetDiff += idLength - length;
54829
- messageBodyAttributes.push({
54830
- type: 'mention',
54831
- metadata: child.mentionName,
54832
- offset: menIndex,
54833
- length: idLength
54834
- });
54835
- if (child.format) {
54836
- var attributeTypes = bodyAttributesMapByType[child.format];
54837
- if (attributeTypes.length > 1) {
54838
- attributeTypes.forEach(function (attributeType) {
54839
- messageBodyAttributes.push({
54840
- type: attributeType,
54841
- metadata: child.metadata || '',
54842
- offset: menIndex,
54843
- length: length
54844
- });
54845
- });
54846
- } else {
54847
- messageBodyAttributes.push({
54848
- type: attributeTypes[0],
54849
- metadata: child.metadata || '',
54850
- offset: menIndex,
54851
- length: length
54852
- });
54853
- }
54854
- }
54855
- } else {
54856
- var _attributeTypes = bodyAttributesMapByType[child.format];
54857
- if (_attributeTypes) {
54858
- var _offset = offsetList[index].start;
54859
- var _length = offsetList[index].end - offsetList[index].start;
54860
- var attIndex = _offset + currentOffsetDiff;
54861
- if (_attributeTypes.length > 1) {
54862
- _attributeTypes.forEach(function (attributeType) {
54863
- messageBodyAttributes.push({
54864
- type: attributeType,
54865
- metadata: child.metadata || '',
54866
- offset: attIndex,
54867
- length: _length
54868
- });
54869
- });
54870
- } else {
54871
- messageBodyAttributes.push({
54872
- type: _attributeTypes[0],
54873
- metadata: child.metadata || '',
54874
- offset: attIndex,
54875
- length: _length
54876
- });
54877
- }
54878
- }
54879
- }
54880
- });
54888
+ var serializedMessage = serializeFormattedMessage(messageText, parsedEditorState.root.children[0].children, offsetList);
54881
54889
  if (messageText) {
54882
- setMessageText(newMessageText);
54883
- setMessageBodyAttributes(messageBodyAttributes);
54890
+ setMessageText(serializedMessage.messageText);
54891
+ setMessageBodyAttributes(serializedMessage.bodyAttributes);
54884
54892
  } else {
54885
54893
  setMessageText(messageToEdit ? messageToEdit.body : '');
54886
54894
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sceyt-chat-react-uikit",
3
- "version": "1.9.0",
3
+ "version": "1.9.1-beta.1",
4
4
  "description": "Interactive React UI Components for Sceyt Chat.",
5
5
  "author": "Sceyt",
6
6
  "license": "MIT",