stream-chat-react 11.0.0-rc.5 → 11.0.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/browser.full-bundle.js +89 -45
- package/dist/browser.full-bundle.js.map +1 -1
- package/dist/browser.full-bundle.min.js +5 -5
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/components/Emojis/EmojiPicker.d.ts +14 -1
- package/dist/components/Emojis/EmojiPicker.d.ts.map +1 -1
- package/dist/components/Emojis/EmojiPicker.js +7 -10
- package/dist/components/Emojis/index.cjs.js +7 -10
- package/dist/components/Message/renderText/index.d.ts +3 -1
- package/dist/components/Message/renderText/index.d.ts.map +1 -1
- package/dist/components/Message/renderText/index.js +2 -1
- package/dist/components/Message/renderText/rehypePlugins/emojiMarkdownPlugin.d.ts +3 -0
- package/dist/components/Message/renderText/rehypePlugins/emojiMarkdownPlugin.d.ts.map +1 -0
- package/dist/components/Message/renderText/rehypePlugins/emojiMarkdownPlugin.js +10 -0
- package/dist/components/Message/renderText/rehypePlugins/index.d.ts +3 -0
- package/dist/components/Message/renderText/rehypePlugins/index.d.ts.map +1 -0
- package/dist/components/Message/renderText/rehypePlugins/index.js +2 -0
- package/dist/components/Message/renderText/rehypePlugins/mentionsMarkdownPlugin.d.ts +5 -0
- package/dist/components/Message/renderText/rehypePlugins/mentionsMarkdownPlugin.d.ts.map +1 -0
- package/dist/components/Message/renderText/{rehypePlugins.js → rehypePlugins/mentionsMarkdownPlugin.js} +1 -9
- package/dist/components/Message/renderText/remarkPlugins/htmlToTextPlugin.d.ts +3 -0
- package/dist/components/Message/renderText/remarkPlugins/htmlToTextPlugin.d.ts.map +1 -0
- package/dist/components/Message/renderText/remarkPlugins/htmlToTextPlugin.js +10 -0
- package/dist/components/Message/renderText/remarkPlugins/index.d.ts +3 -0
- package/dist/components/Message/renderText/remarkPlugins/index.d.ts.map +1 -0
- package/dist/components/Message/renderText/remarkPlugins/index.js +2 -0
- package/dist/components/Message/renderText/remarkPlugins/keepLineBreaksPlugin.d.ts +3 -0
- package/dist/components/Message/renderText/remarkPlugins/keepLineBreaksPlugin.d.ts.map +1 -0
- package/dist/components/Message/renderText/remarkPlugins/keepLineBreaksPlugin.js +32 -0
- package/dist/components/Message/renderText/types.d.ts +3 -0
- package/dist/components/Message/renderText/types.d.ts.map +1 -0
- package/dist/components/Message/renderText/types.js +1 -0
- package/dist/index.cjs.js +72 -29
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/components/Message/renderText/rehypePlugins.d.ts +0 -7
- package/dist/components/Message/renderText/rehypePlugins.d.ts.map +0 -1
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { Options } from '@popperjs/core';
|
|
2
3
|
export declare type EmojiPickerProps = {
|
|
3
4
|
ButtonIconComponent?: React.ComponentType;
|
|
4
5
|
buttonClassName?: string;
|
|
5
|
-
|
|
6
|
+
pickerContainerClassName?: string;
|
|
6
7
|
wrapperClassName?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Untyped [properties](https://github.com/missive/emoji-mart/tree/v5.5.2#options--props) to be
|
|
10
|
+
* passed to the [emoji-mart `Picker`](https://github.com/missive/emoji-mart/tree/v5.5.2#-picker) component
|
|
11
|
+
*/
|
|
12
|
+
pickerProps?: Partial<{
|
|
13
|
+
theme: 'auto' | 'light' | 'dark';
|
|
14
|
+
} & Record<string, unknown>>;
|
|
15
|
+
/**
|
|
16
|
+
* [React Popper options](https://popper.js.org/docs/v2/constructors/#options) to be
|
|
17
|
+
* passed to the [react-popper `usePopper`](https://popper.js.org/react-popper/v2/hook/) hook
|
|
18
|
+
*/
|
|
19
|
+
popperOptions?: Partial<Options>;
|
|
7
20
|
};
|
|
8
21
|
export declare const EmojiPicker: (props: EmojiPickerProps) => JSX.Element;
|
|
9
22
|
//# sourceMappingURL=EmojiPicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmojiPicker.d.ts","sourceRoot":"","sources":["../../../src/components/Emojis/EmojiPicker.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"EmojiPicker.d.ts","sourceRoot":"","sources":["../../../src/components/Emojis/EmojiPicker.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAW9C,oBAAY,gBAAgB,GAAG;IAC7B,mBAAmB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC1C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACtF;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;CAClC,CAAC;AAeF,eAAO,MAAM,WAAW,UAAW,gBAAgB,gBAkElD,CAAC"}
|
|
@@ -9,12 +9,12 @@ import { Tooltip } from '../Tooltip';
|
|
|
9
9
|
var classNames = {
|
|
10
10
|
1: {
|
|
11
11
|
buttonClassName: 'str-chat__input-flat-emojiselect',
|
|
12
|
-
|
|
12
|
+
pickerContainerClassName: undefined,
|
|
13
13
|
wrapperClassName: 'str-chat__emojiselect-wrapper',
|
|
14
14
|
},
|
|
15
15
|
2: {
|
|
16
16
|
buttonClassName: 'str-chat__emoji-picker-button',
|
|
17
|
-
|
|
17
|
+
pickerContainerClassName: 'str-chat__message-textarea-emoji-picker-container',
|
|
18
18
|
wrapperClassName: 'str-chat__message-textarea-emoji-picker',
|
|
19
19
|
},
|
|
20
20
|
};
|
|
@@ -26,10 +26,8 @@ export var EmojiPicker = function (props) {
|
|
|
26
26
|
var _e = useState(false), displayPicker = _e[0], setDisplayPicker = _e[1];
|
|
27
27
|
var _f = useState(null), referenceElement = _f[0], setReferenceElement = _f[1];
|
|
28
28
|
var _g = useState(null), popperElement = _g[0], setPopperElement = _g[1];
|
|
29
|
-
var _h = usePopper(referenceElement, popperElement, {
|
|
30
|
-
|
|
31
|
-
}), attributes = _h.attributes, styles = _h.styles;
|
|
32
|
-
var _j = classNames[themeVersion], buttonClassName = _j.buttonClassName, emojiPickerContainerClassName = _j.emojiPickerContainerClassName, wrapperClassName = _j.wrapperClassName;
|
|
29
|
+
var _h = usePopper(referenceElement, popperElement, __assign({ placement: themeVersion === '2' ? 'top-end' : 'top-start' }, props.popperOptions)), attributes = _h.attributes, styles = _h.styles;
|
|
30
|
+
var _j = classNames[themeVersion], buttonClassName = _j.buttonClassName, pickerContainerClassName = _j.pickerContainerClassName, wrapperClassName = _j.wrapperClassName;
|
|
33
31
|
var _k = props.ButtonIconComponent, ButtonIconComponent = _k === void 0 ? themeVersion === '2' ? EmojiPickerIcon : EmojiIconLarge : _k;
|
|
34
32
|
useEffect(function () {
|
|
35
33
|
if (!popperElement || !referenceElement)
|
|
@@ -44,18 +42,17 @@ export var EmojiPicker = function (props) {
|
|
|
44
42
|
return function () { return window.removeEventListener('pointerdown', handlePointerDown); };
|
|
45
43
|
}, [referenceElement, popperElement]);
|
|
46
44
|
return (React.createElement("div", { className: (_a = props.wrapperClassName) !== null && _a !== void 0 ? _a : wrapperClassName },
|
|
47
|
-
displayPicker && (React.createElement("div", __assign({ className: (_b = props.
|
|
48
|
-
React.createElement(Picker, { data: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
45
|
+
displayPicker && (React.createElement("div", __assign({ className: (_b = props.pickerContainerClassName) !== null && _b !== void 0 ? _b : pickerContainerClassName, style: styles.popper }, attributes.popper, { ref: setPopperElement }),
|
|
46
|
+
React.createElement(Picker, __assign({ data: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
49
47
|
switch (_a.label) {
|
|
50
48
|
case 0: return [4 /*yield*/, import('@emoji-mart/data')];
|
|
51
49
|
case 1: return [2 /*return*/, (_a.sent()).default];
|
|
52
50
|
}
|
|
53
51
|
}); }); }, onEmojiSelect: function (e) {
|
|
54
52
|
var _a;
|
|
55
|
-
// @ts-ignore emoji-mart is missing types
|
|
56
53
|
insertText(e.native);
|
|
57
54
|
(_a = textareaRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
58
|
-
} }))),
|
|
55
|
+
} }, props.pickerProps)))),
|
|
59
56
|
themeVersion === '1' && (React.createElement(Tooltip, null, displayPicker ? t('Close emoji picker') : t('Open emoji picker'))),
|
|
60
57
|
React.createElement("button", { "aria-label": 'Emoji picker', className: (_c = props.buttonClassName) !== null && _c !== void 0 ? _c : buttonClassName, onClick: function () { return setDisplayPicker(function (cv) { return !cv; }); }, ref: setReferenceElement, type: 'button' }, ButtonIconComponent && React.createElement(ButtonIconComponent, null))));
|
|
61
58
|
};
|
|
@@ -56,12 +56,12 @@ var Picker__default = /*#__PURE__*/_interopDefaultLegacy(Picker);
|
|
|
56
56
|
var classNames = {
|
|
57
57
|
1: {
|
|
58
58
|
buttonClassName: 'str-chat__input-flat-emojiselect',
|
|
59
|
-
|
|
59
|
+
pickerContainerClassName: undefined,
|
|
60
60
|
wrapperClassName: 'str-chat__emojiselect-wrapper',
|
|
61
61
|
},
|
|
62
62
|
2: {
|
|
63
63
|
buttonClassName: 'str-chat__emoji-picker-button',
|
|
64
|
-
|
|
64
|
+
pickerContainerClassName: 'str-chat__message-textarea-emoji-picker-container',
|
|
65
65
|
wrapperClassName: 'str-chat__message-textarea-emoji-picker',
|
|
66
66
|
},
|
|
67
67
|
};
|
|
@@ -73,10 +73,8 @@ var EmojiPicker = function (props) {
|
|
|
73
73
|
var _e = React.useState(false), displayPicker = _e[0], setDisplayPicker = _e[1];
|
|
74
74
|
var _f = React.useState(null), referenceElement = _f[0], setReferenceElement = _f[1];
|
|
75
75
|
var _g = React.useState(null), popperElement = _g[0], setPopperElement = _g[1];
|
|
76
|
-
var _h = icons.usePopper(referenceElement, popperElement, {
|
|
77
|
-
|
|
78
|
-
}), attributes = _h.attributes, styles = _h.styles;
|
|
79
|
-
var _j = classNames[themeVersion], buttonClassName = _j.buttonClassName, emojiPickerContainerClassName = _j.emojiPickerContainerClassName, wrapperClassName = _j.wrapperClassName;
|
|
76
|
+
var _h = icons.usePopper(referenceElement, popperElement, icons.__assign({ placement: themeVersion === '2' ? 'top-end' : 'top-start' }, props.popperOptions)), attributes = _h.attributes, styles = _h.styles;
|
|
77
|
+
var _j = classNames[themeVersion], buttonClassName = _j.buttonClassName, pickerContainerClassName = _j.pickerContainerClassName, wrapperClassName = _j.wrapperClassName;
|
|
80
78
|
var _k = props.ButtonIconComponent, ButtonIconComponent = _k === void 0 ? themeVersion === '2' ? icons.EmojiPickerIcon : icons.EmojiIconLarge : _k;
|
|
81
79
|
React.useEffect(function () {
|
|
82
80
|
if (!popperElement || !referenceElement)
|
|
@@ -91,18 +89,17 @@ var EmojiPicker = function (props) {
|
|
|
91
89
|
return function () { return window.removeEventListener('pointerdown', handlePointerDown); };
|
|
92
90
|
}, [referenceElement, popperElement]);
|
|
93
91
|
return (React__default["default"].createElement("div", { className: (_a = props.wrapperClassName) !== null && _a !== void 0 ? _a : wrapperClassName },
|
|
94
|
-
displayPicker && (React__default["default"].createElement("div", icons.__assign({ className: (_b = props.
|
|
95
|
-
React__default["default"].createElement(Picker__default["default"], { data: function () { return icons.__awaiter(void 0, void 0, void 0, function () { return icons.__generator(this, function (_a) {
|
|
92
|
+
displayPicker && (React__default["default"].createElement("div", icons.__assign({ className: (_b = props.pickerContainerClassName) !== null && _b !== void 0 ? _b : pickerContainerClassName, style: styles.popper }, attributes.popper, { ref: setPopperElement }),
|
|
93
|
+
React__default["default"].createElement(Picker__default["default"], icons.__assign({ data: function () { return icons.__awaiter(void 0, void 0, void 0, function () { return icons.__generator(this, function (_a) {
|
|
96
94
|
switch (_a.label) {
|
|
97
95
|
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@emoji-mart/data')); })];
|
|
98
96
|
case 1: return [2 /*return*/, (_a.sent()).default];
|
|
99
97
|
}
|
|
100
98
|
}); }); }, onEmojiSelect: function (e) {
|
|
101
99
|
var _a;
|
|
102
|
-
// @ts-ignore emoji-mart is missing types
|
|
103
100
|
insertText(e.native);
|
|
104
101
|
(_a = textareaRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
105
|
-
} }))),
|
|
102
|
+
} }, props.pickerProps)))),
|
|
106
103
|
themeVersion === '1' && (React__default["default"].createElement(icons.Tooltip, null, displayPicker ? t('Close emoji picker') : t('Open emoji picker'))),
|
|
107
104
|
React__default["default"].createElement("button", { "aria-label": 'Emoji picker', className: (_c = props.buttonClassName) !== null && _c !== void 0 ? _c : buttonClassName, onClick: function () { return setDisplayPicker(function (cv) { return !cv; }); }, ref: setReferenceElement, type: 'button' }, ButtonIconComponent && React__default["default"].createElement(ButtonIconComponent, null))));
|
|
108
105
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { MentionProps } from './Mention';
|
|
2
|
-
export { emojiMarkdownPlugin, mentionsMarkdownPlugin } from './rehypePlugins';
|
|
3
2
|
export { escapeRegExp, matchMarkdownLinks, messageCodeBlocks } from './regex';
|
|
3
|
+
export * from './rehypePlugins';
|
|
4
|
+
export * from './remarkPlugins';
|
|
4
5
|
export * from './renderText';
|
|
6
|
+
export { HNode } from './types';
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Message/renderText/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Message/renderText/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC9E,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emojiMarkdownPlugin.d.ts","sourceRoot":"","sources":["../../../../../src/components/Message/renderText/rehypePlugins/emojiMarkdownPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC,eAAO,MAAM,mBAAmB,eAIL,KAAK,kDAG/B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { findAndReplace } from 'hast-util-find-and-replace';
|
|
2
|
+
import { u } from 'unist-builder';
|
|
3
|
+
import emojiRegex from 'emoji-regex';
|
|
4
|
+
export var emojiMarkdownPlugin = function () {
|
|
5
|
+
var replace = function (match) {
|
|
6
|
+
return u('element', { tagName: 'emoji' }, [u('text', match)]);
|
|
7
|
+
};
|
|
8
|
+
var transform = function (node) { return findAndReplace(node, emojiRegex(), replace); };
|
|
9
|
+
return transform;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Message/renderText/rehypePlugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DefaultStreamChatGenerics } from '../../../../types/types';
|
|
2
|
+
import { UserResponse } from 'stream-chat';
|
|
3
|
+
import type { HNode } from '../types';
|
|
4
|
+
export declare const mentionsMarkdownPlugin: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(mentioned_users: UserResponse<StreamChatGenerics>[]) => () => (tree: HNode) => HNode;
|
|
5
|
+
//# sourceMappingURL=mentionsMarkdownPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mentionsMarkdownPlugin.d.ts","sourceRoot":"","sources":["../../../../../src/components/Message/renderText/rehypePlugins/mentionsMarkdownPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC,eAAO,MAAM,sBAAsB,0JAuBR,KAAK,KAAG,KAoClC,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { escapeRegExp } from '../regex';
|
|
1
2
|
import { findAndReplace } from 'hast-util-find-and-replace';
|
|
2
3
|
import { u } from 'unist-builder';
|
|
3
4
|
import { visit } from 'unist-util-visit';
|
|
4
|
-
import emojiRegex from 'emoji-regex';
|
|
5
|
-
import { escapeRegExp } from './regex';
|
|
6
5
|
export var mentionsMarkdownPlugin = function (mentioned_users) { return function () {
|
|
7
6
|
var mentioned_usernames = mentioned_users
|
|
8
7
|
.map(function (user) { return user.name || user.id; })
|
|
@@ -51,10 +50,3 @@ export var mentionsMarkdownPlugin = function (mentioned_users) { return function
|
|
|
51
50
|
};
|
|
52
51
|
return transform;
|
|
53
52
|
}; };
|
|
54
|
-
export var emojiMarkdownPlugin = function () {
|
|
55
|
-
var replace = function (match) {
|
|
56
|
-
return u('element', { tagName: 'emoji' }, [u('text', match)]);
|
|
57
|
-
};
|
|
58
|
-
var transform = function (node) { return findAndReplace(node, emojiRegex(), replace); };
|
|
59
|
-
return transform;
|
|
60
|
-
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"htmlToTextPlugin.d.ts","sourceRoot":"","sources":["../../../../../src/components/Message/renderText/remarkPlugins/htmlToTextPlugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAWtC,eAAO,MAAM,gBAAgB,eAJJ,KAAK,SAIiB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { visit } from 'unist-util-visit';
|
|
2
|
+
var visitor = function (node) {
|
|
3
|
+
if (node.type !== 'html')
|
|
4
|
+
return;
|
|
5
|
+
node.type = 'text';
|
|
6
|
+
};
|
|
7
|
+
var transform = function (tree) {
|
|
8
|
+
visit(tree, visitor);
|
|
9
|
+
};
|
|
10
|
+
export var htmlToTextPlugin = function () { return transform; };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Message/renderText/remarkPlugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keepLineBreaksPlugin.d.ts","sourceRoot":"","sources":["../../../../../src/components/Message/renderText/remarkPlugins/keepLineBreaksPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAmCtC,eAAO,MAAM,oBAAoB,eAJR,KAAK,SAIqB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { __spreadArray } from "tslib";
|
|
2
|
+
import { visit } from 'unist-util-visit';
|
|
3
|
+
import { u } from 'unist-builder';
|
|
4
|
+
var visitor = function (node, index, parent) {
|
|
5
|
+
if (index === null || index === 0)
|
|
6
|
+
return;
|
|
7
|
+
if (!parent)
|
|
8
|
+
return;
|
|
9
|
+
if (!node.position)
|
|
10
|
+
return;
|
|
11
|
+
var prevSibling = parent.children.at(index - 1);
|
|
12
|
+
if (!(prevSibling === null || prevSibling === void 0 ? void 0 : prevSibling.position))
|
|
13
|
+
return;
|
|
14
|
+
if (node.position.start.line === prevSibling.position.start.line)
|
|
15
|
+
return false;
|
|
16
|
+
var ownStartLine = node.position.start.line;
|
|
17
|
+
var prevEndLine = prevSibling.position.end.line;
|
|
18
|
+
// the -1 is adjustment for the single line break into which multiple line breaks are converted
|
|
19
|
+
var countTruncatedLineBreaks = ownStartLine - prevEndLine - 1;
|
|
20
|
+
if (countTruncatedLineBreaks < 1)
|
|
21
|
+
return;
|
|
22
|
+
var lineBreaks = Array.from({ length: countTruncatedLineBreaks }, function () {
|
|
23
|
+
return u('break', { tagName: 'br' });
|
|
24
|
+
});
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
parent.children = __spreadArray(__spreadArray(__spreadArray([], parent.children.slice(0, index), true), lineBreaks, true), parent.children.slice(index), true);
|
|
27
|
+
return;
|
|
28
|
+
};
|
|
29
|
+
var transform = function (tree) {
|
|
30
|
+
visit(tree, visitor);
|
|
31
|
+
};
|
|
32
|
+
export var keepLineBreaksPlugin = function () { return transform; };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/Message/renderText/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAErC,oBAAY,KAAK,GAAG,OAAO,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.cjs.js
CHANGED
|
@@ -3388,6 +3388,28 @@ var DefaultSuggestionListHeader = function (props) {
|
|
|
3388
3388
|
return null;
|
|
3389
3389
|
};
|
|
3390
3390
|
|
|
3391
|
+
function escapeRegExp(text) {
|
|
3392
|
+
return text.replace(/[-[\]{}()*+?.,/\\^$|#]/g, '\\$&');
|
|
3393
|
+
}
|
|
3394
|
+
var detectHttp = /(http(s?):\/\/)?(www\.)?/;
|
|
3395
|
+
var messageCodeBlocks = function (message) {
|
|
3396
|
+
var codeRegex = /```[a-z]*\n[\s\S]*?\n```|`[a-z]*[\s\S]*?`/gm;
|
|
3397
|
+
var matches = message.match(codeRegex);
|
|
3398
|
+
return matches || [];
|
|
3399
|
+
};
|
|
3400
|
+
var matchMarkdownLinks = function (message) {
|
|
3401
|
+
var regexMdLinks = /\[([^[]+)\](\(.*\))/gm;
|
|
3402
|
+
var matches = message.match(regexMdLinks);
|
|
3403
|
+
var singleMatch = /\[([^[]+)\]\((.*)\)/;
|
|
3404
|
+
var links = matches
|
|
3405
|
+
? matches.map(function (match) {
|
|
3406
|
+
var i = singleMatch.exec(match);
|
|
3407
|
+
return i && [i[1], i[2]];
|
|
3408
|
+
})
|
|
3409
|
+
: [];
|
|
3410
|
+
return links.flat();
|
|
3411
|
+
};
|
|
3412
|
+
|
|
3391
3413
|
/**
|
|
3392
3414
|
* @typedef {import('unist').Node} Node
|
|
3393
3415
|
* @typedef {import('unist').Parent} Parent
|
|
@@ -4111,6 +4133,14 @@ var u = /**
|
|
|
4111
4133
|
}
|
|
4112
4134
|
);
|
|
4113
4135
|
|
|
4136
|
+
var emojiMarkdownPlugin = function () {
|
|
4137
|
+
var replace = function (match) {
|
|
4138
|
+
return u('element', { tagName: 'emoji' }, [u('text', match)]);
|
|
4139
|
+
};
|
|
4140
|
+
var transform = function (node) { return findAndReplace$1(node, emojiRegex__default["default"](), replace); };
|
|
4141
|
+
return transform;
|
|
4142
|
+
};
|
|
4143
|
+
|
|
4114
4144
|
/**
|
|
4115
4145
|
* @param {string} d
|
|
4116
4146
|
* @returns {string}
|
|
@@ -4331,28 +4361,6 @@ const visit =
|
|
|
4331
4361
|
}
|
|
4332
4362
|
);
|
|
4333
4363
|
|
|
4334
|
-
function escapeRegExp(text) {
|
|
4335
|
-
return text.replace(/[-[\]{}()*+?.,/\\^$|#]/g, '\\$&');
|
|
4336
|
-
}
|
|
4337
|
-
var detectHttp = /(http(s?):\/\/)?(www\.)?/;
|
|
4338
|
-
var messageCodeBlocks = function (message) {
|
|
4339
|
-
var codeRegex = /```[a-z]*\n[\s\S]*?\n```|`[a-z]*[\s\S]*?`/gm;
|
|
4340
|
-
var matches = message.match(codeRegex);
|
|
4341
|
-
return matches || [];
|
|
4342
|
-
};
|
|
4343
|
-
var matchMarkdownLinks = function (message) {
|
|
4344
|
-
var regexMdLinks = /\[([^[]+)\](\(.*\))/gm;
|
|
4345
|
-
var matches = message.match(regexMdLinks);
|
|
4346
|
-
var singleMatch = /\[([^[]+)\]\((.*)\)/;
|
|
4347
|
-
var links = matches
|
|
4348
|
-
? matches.map(function (match) {
|
|
4349
|
-
var i = singleMatch.exec(match);
|
|
4350
|
-
return i && [i[1], i[2]];
|
|
4351
|
-
})
|
|
4352
|
-
: [];
|
|
4353
|
-
return links.flat();
|
|
4354
|
-
};
|
|
4355
|
-
|
|
4356
4364
|
var mentionsMarkdownPlugin = function (mentioned_users) { return function () {
|
|
4357
4365
|
var mentioned_usernames = mentioned_users
|
|
4358
4366
|
.map(function (user) { return user.name || user.id; })
|
|
@@ -4401,13 +4409,46 @@ var mentionsMarkdownPlugin = function (mentioned_users) { return function () {
|
|
|
4401
4409
|
};
|
|
4402
4410
|
return transform;
|
|
4403
4411
|
}; };
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4412
|
+
|
|
4413
|
+
var visitor$1 = function (node) {
|
|
4414
|
+
if (node.type !== 'html')
|
|
4415
|
+
return;
|
|
4416
|
+
node.type = 'text';
|
|
4417
|
+
};
|
|
4418
|
+
var transform$1 = function (tree) {
|
|
4419
|
+
visit(tree, visitor$1);
|
|
4420
|
+
};
|
|
4421
|
+
var htmlToTextPlugin = function () { return transform$1; };
|
|
4422
|
+
|
|
4423
|
+
var visitor = function (node, index, parent) {
|
|
4424
|
+
if (index === null || index === 0)
|
|
4425
|
+
return;
|
|
4426
|
+
if (!parent)
|
|
4427
|
+
return;
|
|
4428
|
+
if (!node.position)
|
|
4429
|
+
return;
|
|
4430
|
+
var prevSibling = parent.children.at(index - 1);
|
|
4431
|
+
if (!(prevSibling === null || prevSibling === void 0 ? void 0 : prevSibling.position))
|
|
4432
|
+
return;
|
|
4433
|
+
if (node.position.start.line === prevSibling.position.start.line)
|
|
4434
|
+
return false;
|
|
4435
|
+
var ownStartLine = node.position.start.line;
|
|
4436
|
+
var prevEndLine = prevSibling.position.end.line;
|
|
4437
|
+
// the -1 is adjustment for the single line break into which multiple line breaks are converted
|
|
4438
|
+
var countTruncatedLineBreaks = ownStartLine - prevEndLine - 1;
|
|
4439
|
+
if (countTruncatedLineBreaks < 1)
|
|
4440
|
+
return;
|
|
4441
|
+
var lineBreaks = Array.from({ length: countTruncatedLineBreaks }, function () {
|
|
4442
|
+
return u('break', { tagName: 'br' });
|
|
4443
|
+
});
|
|
4444
|
+
// @ts-ignore
|
|
4445
|
+
parent.children = icons.__spreadArray(icons.__spreadArray(icons.__spreadArray([], parent.children.slice(0, index), true), lineBreaks, true), parent.children.slice(index), true);
|
|
4446
|
+
return;
|
|
4447
|
+
};
|
|
4448
|
+
var transform = function (tree) {
|
|
4449
|
+
visit(tree, visitor);
|
|
4410
4450
|
};
|
|
4451
|
+
var keepLineBreaksPlugin = function () { return transform; };
|
|
4411
4452
|
|
|
4412
4453
|
const protocols = ['http', 'https', 'mailto', 'tel'];
|
|
4413
4454
|
|
|
@@ -31949,7 +31990,7 @@ var UnMemoizedChannelList = function (props) {
|
|
|
31949
31990
|
*/
|
|
31950
31991
|
var ChannelList = React__default["default"].memo(UnMemoizedChannelList);
|
|
31951
31992
|
|
|
31952
|
-
var version = '11.0.0-rc.
|
|
31993
|
+
var version = '11.0.0-rc.7';
|
|
31953
31994
|
|
|
31954
31995
|
var useChat = function (_a) {
|
|
31955
31996
|
var _b, _c;
|
|
@@ -34242,6 +34283,7 @@ exports.getWholeChar = getWholeChar;
|
|
|
34242
34283
|
exports.handleActionWarning = handleActionWarning;
|
|
34243
34284
|
exports.hasMoreMessagesProbably = hasMoreMessagesProbably;
|
|
34244
34285
|
exports.hasNotMoreMessages = hasNotMoreMessages;
|
|
34286
|
+
exports.htmlToTextPlugin = htmlToTextPlugin;
|
|
34245
34287
|
exports.insertIntro = insertIntro;
|
|
34246
34288
|
exports.isAudioAttachment = isAudioAttachment;
|
|
34247
34289
|
exports.isChannel = isChannel;
|
|
@@ -34253,6 +34295,7 @@ exports.isScrapedContent = isScrapedContent;
|
|
|
34253
34295
|
exports.isSvgAttachment = isSvgAttachment;
|
|
34254
34296
|
exports.isUploadedImage = isUploadedImage;
|
|
34255
34297
|
exports.isUserMuted = isUserMuted;
|
|
34298
|
+
exports.keepLineBreaksPlugin = keepLineBreaksPlugin;
|
|
34256
34299
|
exports.makeDateMessageId = makeDateMessageId;
|
|
34257
34300
|
exports.mapToUserNameOrId = mapToUserNameOrId;
|
|
34258
34301
|
exports.markDownRenderers = markDownRenderers;
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "11.0.0-rc.
|
|
1
|
+
export declare const version = "11.0.0-rc.7";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var version = '11.0.0-rc.
|
|
1
|
+
export var version = '11.0.0-rc.7';
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Content, Root } from 'hast';
|
|
2
|
-
import type { UserResponse } from 'stream-chat';
|
|
3
|
-
import type { DefaultStreamChatGenerics } from '../../../types/types';
|
|
4
|
-
export declare type HNode = Content | Root;
|
|
5
|
-
export declare const mentionsMarkdownPlugin: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(mentioned_users: UserResponse<StreamChatGenerics>[]) => () => (tree: HNode) => HNode;
|
|
6
|
-
export declare const emojiMarkdownPlugin: () => (node: HNode) => import("hast-util-find-and-replace/lib").Node;
|
|
7
|
-
//# sourceMappingURL=rehypePlugins.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rehypePlugins.d.ts","sourceRoot":"","sources":["../../../../src/components/Message/renderText/rehypePlugins.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,oBAAY,KAAK,GAAG,OAAO,GAAG,IAAI,CAAC;AACnC,eAAO,MAAM,sBAAsB,0JAuBR,KAAK,KAAG,KAoClC,CAAC;AAEF,eAAO,MAAM,mBAAmB,eAIL,KAAK,kDAG/B,CAAC"}
|