stream-chat-react 9.3.0 → 9.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.full-bundle.js +1225 -2995
- package/dist/browser.full-bundle.js.map +1 -1
- package/dist/browser.full-bundle.min.js +4 -4
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/components/AutoCompleteTextarea/Textarea.d.ts +7 -0
- package/dist/components/AutoCompleteTextarea/Textarea.d.ts.map +1 -1
- package/dist/components/AutoCompleteTextarea/Textarea.js +10 -1
- package/dist/components/Channel/Channel.d.ts.map +1 -1
- package/dist/components/Channel/Channel.js +26 -24
- package/dist/components/MessageInput/hooks/useAttachments.d.ts.map +1 -1
- package/dist/components/MessageInput/hooks/useAttachments.js +8 -1
- package/dist/components/MessageInput/hooks/useImageUploads.d.ts.map +1 -1
- package/dist/components/MessageInput/hooks/useImageUploads.js +17 -36
- package/dist/components/MessageInput/hooks/useSubmitHandler.d.ts.map +1 -1
- package/dist/components/MessageInput/hooks/useSubmitHandler.js +1 -1
- package/dist/context/ChannelActionContext.d.ts +1 -1
- package/dist/context/ChannelActionContext.d.ts.map +1 -1
- package/dist/context/DefaultEmoji.d.ts +3 -0
- package/dist/context/DefaultEmoji.d.ts.map +1 -0
- package/dist/context/DefaultEmoji.js +3 -0
- package/dist/context/DefaultEmojiPicker.d.ts +3 -0
- package/dist/context/DefaultEmojiPicker.d.ts.map +1 -0
- package/dist/context/DefaultEmojiPicker.js +3 -0
- package/dist/context/EmojiContext.d.ts.map +1 -1
- package/dist/context/EmojiContext.js +2 -58
- package/dist/css/index.css +1 -1
- package/dist/index.cjs.js +805 -91
- package/dist/index.cjs.js.map +1 -1
- package/dist/scss/Gallery.scss +6 -0
- package/dist/scss/Message.scss +67 -34
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +17 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +8 -5
package/dist/index.cjs.js
CHANGED
|
@@ -32,7 +32,6 @@ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
|
32
32
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
33
33
|
var emojiRegex = require('emoji-regex');
|
|
34
34
|
var linkify = require('linkifyjs');
|
|
35
|
-
var findAndReplace = require('mdast-util-find-and-replace');
|
|
36
35
|
var RootReactMarkdown = require('react-markdown');
|
|
37
36
|
var ReactMarkdown = require('react-markdown/with-html');
|
|
38
37
|
var uniqBy = require('lodash.uniqby');
|
|
@@ -55,6 +54,8 @@ var deepequal = require('react-fast-compare');
|
|
|
55
54
|
var DefaultEmojiIndex = require('emoji-mart/dist/utils/emoji-index/nimble-emoji-index.js');
|
|
56
55
|
var resizeObserver = require('@juggle/resize-observer');
|
|
57
56
|
var reactVirtuoso = require('react-virtuoso');
|
|
57
|
+
var nimbleEmoji = require('emoji-mart/dist/components/emoji/nimble-emoji');
|
|
58
|
+
var nimblePicker = require('emoji-mart/dist/components/picker/nimble-picker');
|
|
58
59
|
|
|
59
60
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
60
61
|
|
|
@@ -93,7 +94,6 @@ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_definePropert
|
|
|
93
94
|
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
94
95
|
var emojiRegex__default = /*#__PURE__*/_interopDefaultLegacy(emojiRegex);
|
|
95
96
|
var linkify__namespace = /*#__PURE__*/_interopNamespace(linkify);
|
|
96
|
-
var findAndReplace__default = /*#__PURE__*/_interopDefaultLegacy(findAndReplace);
|
|
97
97
|
var RootReactMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(RootReactMarkdown);
|
|
98
98
|
var ReactMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(ReactMarkdown);
|
|
99
99
|
var uniqBy__default = /*#__PURE__*/_interopDefaultLegacy(uniqBy);
|
|
@@ -112,6 +112,8 @@ var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
|
|
|
112
112
|
var throttle__default = /*#__PURE__*/_interopDefaultLegacy(throttle);
|
|
113
113
|
var deepequal__default = /*#__PURE__*/_interopDefaultLegacy(deepequal);
|
|
114
114
|
var DefaultEmojiIndex__default = /*#__PURE__*/_interopDefaultLegacy(DefaultEmojiIndex);
|
|
115
|
+
var nimbleEmoji__default = /*#__PURE__*/_interopDefaultLegacy(nimbleEmoji);
|
|
116
|
+
var nimblePicker__default = /*#__PURE__*/_interopDefaultLegacy(nimblePicker);
|
|
115
117
|
|
|
116
118
|
/*! *****************************************************************************
|
|
117
119
|
Copyright (c) Microsoft Corporation.
|
|
@@ -1333,6 +1335,718 @@ var withComponentContext = function (Component) {
|
|
|
1333
1335
|
return WithComponentContextComponent;
|
|
1334
1336
|
};
|
|
1335
1337
|
|
|
1338
|
+
function escapeStringRegexp(string) {
|
|
1339
|
+
if (typeof string !== 'string') {
|
|
1340
|
+
throw new TypeError('Expected a string');
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
// Escape characters with special meaning either inside or outside character sets.
|
|
1344
|
+
// Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
|
|
1345
|
+
return string
|
|
1346
|
+
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
|
|
1347
|
+
.replace(/-/g, '\\x2d');
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* @typedef {import('unist').Node} Node
|
|
1352
|
+
* @typedef {import('unist').Parent} Parent
|
|
1353
|
+
*
|
|
1354
|
+
* @typedef {string} Type
|
|
1355
|
+
* @typedef {Object<string, unknown>} Props
|
|
1356
|
+
*
|
|
1357
|
+
* @typedef {null|undefined|Type|Props|TestFunctionAnything|Array.<Type|Props|TestFunctionAnything>} Test
|
|
1358
|
+
*/
|
|
1359
|
+
|
|
1360
|
+
const convert$1 =
|
|
1361
|
+
/**
|
|
1362
|
+
* @type {(
|
|
1363
|
+
* (<T extends Node>(test: T['type']|Partial<T>|TestFunctionPredicate<T>) => AssertPredicate<T>) &
|
|
1364
|
+
* ((test?: Test) => AssertAnything)
|
|
1365
|
+
* )}
|
|
1366
|
+
*/
|
|
1367
|
+
(
|
|
1368
|
+
/**
|
|
1369
|
+
* Generate an assertion from a check.
|
|
1370
|
+
* @param {Test} [test]
|
|
1371
|
+
* When nullish, checks if `node` is a `Node`.
|
|
1372
|
+
* When `string`, works like passing `function (node) {return node.type === test}`.
|
|
1373
|
+
* When `function` checks if function passed the node is true.
|
|
1374
|
+
* When `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
|
|
1375
|
+
* When `array`, checks any one of the subtests pass.
|
|
1376
|
+
* @returns {AssertAnything}
|
|
1377
|
+
*/
|
|
1378
|
+
function (test) {
|
|
1379
|
+
if (test === undefined || test === null) {
|
|
1380
|
+
return ok$1
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
if (typeof test === 'string') {
|
|
1384
|
+
return typeFactory$1(test)
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
if (typeof test === 'object') {
|
|
1388
|
+
return Array.isArray(test) ? anyFactory$1(test) : propsFactory$1(test)
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
if (typeof test === 'function') {
|
|
1392
|
+
return castFactory$1(test)
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
throw new Error('Expected function, string, or object as test')
|
|
1396
|
+
}
|
|
1397
|
+
);
|
|
1398
|
+
/**
|
|
1399
|
+
* @param {Array.<Type|Props|TestFunctionAnything>} tests
|
|
1400
|
+
* @returns {AssertAnything}
|
|
1401
|
+
*/
|
|
1402
|
+
function anyFactory$1(tests) {
|
|
1403
|
+
/** @type {Array.<AssertAnything>} */
|
|
1404
|
+
const checks = [];
|
|
1405
|
+
let index = -1;
|
|
1406
|
+
|
|
1407
|
+
while (++index < tests.length) {
|
|
1408
|
+
checks[index] = convert$1(tests[index]);
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
return castFactory$1(any)
|
|
1412
|
+
|
|
1413
|
+
/**
|
|
1414
|
+
* @this {unknown}
|
|
1415
|
+
* @param {unknown[]} parameters
|
|
1416
|
+
* @returns {boolean}
|
|
1417
|
+
*/
|
|
1418
|
+
function any(...parameters) {
|
|
1419
|
+
let index = -1;
|
|
1420
|
+
|
|
1421
|
+
while (++index < checks.length) {
|
|
1422
|
+
if (checks[index].call(this, ...parameters)) return true
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
return false
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
/**
|
|
1430
|
+
* Utility to assert each property in `test` is represented in `node`, and each
|
|
1431
|
+
* values are strictly equal.
|
|
1432
|
+
*
|
|
1433
|
+
* @param {Props} check
|
|
1434
|
+
* @returns {AssertAnything}
|
|
1435
|
+
*/
|
|
1436
|
+
function propsFactory$1(check) {
|
|
1437
|
+
return castFactory$1(all)
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* @param {Node} node
|
|
1441
|
+
* @returns {boolean}
|
|
1442
|
+
*/
|
|
1443
|
+
function all(node) {
|
|
1444
|
+
/** @type {string} */
|
|
1445
|
+
let key;
|
|
1446
|
+
|
|
1447
|
+
for (key in check) {
|
|
1448
|
+
// @ts-expect-error: hush, it sure works as an index.
|
|
1449
|
+
if (node[key] !== check[key]) return false
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
return true
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
/**
|
|
1457
|
+
* Utility to convert a string into a function which checks a given node’s type
|
|
1458
|
+
* for said string.
|
|
1459
|
+
*
|
|
1460
|
+
* @param {Type} check
|
|
1461
|
+
* @returns {AssertAnything}
|
|
1462
|
+
*/
|
|
1463
|
+
function typeFactory$1(check) {
|
|
1464
|
+
return castFactory$1(type)
|
|
1465
|
+
|
|
1466
|
+
/**
|
|
1467
|
+
* @param {Node} node
|
|
1468
|
+
*/
|
|
1469
|
+
function type(node) {
|
|
1470
|
+
return node && node.type === check
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
/**
|
|
1475
|
+
* Utility to convert a string into a function which checks a given node’s type
|
|
1476
|
+
* for said string.
|
|
1477
|
+
* @param {TestFunctionAnything} check
|
|
1478
|
+
* @returns {AssertAnything}
|
|
1479
|
+
*/
|
|
1480
|
+
function castFactory$1(check) {
|
|
1481
|
+
return assertion
|
|
1482
|
+
|
|
1483
|
+
/**
|
|
1484
|
+
* @this {unknown}
|
|
1485
|
+
* @param {Array.<unknown>} parameters
|
|
1486
|
+
* @returns {boolean}
|
|
1487
|
+
*/
|
|
1488
|
+
function assertion(...parameters) {
|
|
1489
|
+
// @ts-expect-error: spreading is fine.
|
|
1490
|
+
return Boolean(check.call(this, ...parameters))
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
// Utility to return true.
|
|
1495
|
+
function ok$1() {
|
|
1496
|
+
return true
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
/**
|
|
1500
|
+
* @param {string} d
|
|
1501
|
+
* @returns {string}
|
|
1502
|
+
*/
|
|
1503
|
+
function color(d) {
|
|
1504
|
+
return '\u001B[33m' + d + '\u001B[39m'
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
/**
|
|
1508
|
+
* @typedef {import('unist').Node} Node
|
|
1509
|
+
* @typedef {import('unist').Parent} Parent
|
|
1510
|
+
* @typedef {import('unist-util-is').Test} Test
|
|
1511
|
+
* @typedef {import('./complex-types').Action} Action
|
|
1512
|
+
* @typedef {import('./complex-types').Index} Index
|
|
1513
|
+
* @typedef {import('./complex-types').ActionTuple} ActionTuple
|
|
1514
|
+
* @typedef {import('./complex-types').VisitorResult} VisitorResult
|
|
1515
|
+
* @typedef {import('./complex-types').Visitor} Visitor
|
|
1516
|
+
*/
|
|
1517
|
+
|
|
1518
|
+
/**
|
|
1519
|
+
* Continue traversing as normal
|
|
1520
|
+
*/
|
|
1521
|
+
const CONTINUE = true;
|
|
1522
|
+
/**
|
|
1523
|
+
* Do not traverse this node’s children
|
|
1524
|
+
*/
|
|
1525
|
+
const SKIP = 'skip';
|
|
1526
|
+
/**
|
|
1527
|
+
* Stop traversing immediately
|
|
1528
|
+
*/
|
|
1529
|
+
const EXIT = false;
|
|
1530
|
+
|
|
1531
|
+
/**
|
|
1532
|
+
* Visit children of tree which pass a test
|
|
1533
|
+
*
|
|
1534
|
+
* @param tree Abstract syntax tree to walk
|
|
1535
|
+
* @param test Test node, optional
|
|
1536
|
+
* @param visitor Function to run for each node
|
|
1537
|
+
* @param reverse Visit the tree in reverse order, defaults to false
|
|
1538
|
+
*/
|
|
1539
|
+
const visitParents =
|
|
1540
|
+
/**
|
|
1541
|
+
* @type {(
|
|
1542
|
+
* (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: import('./complex-types').BuildVisitor<Tree, Check>, reverse?: boolean) => void) &
|
|
1543
|
+
* (<Tree extends Node>(tree: Tree, visitor: import('./complex-types').BuildVisitor<Tree>, reverse?: boolean) => void)
|
|
1544
|
+
* )}
|
|
1545
|
+
*/
|
|
1546
|
+
(
|
|
1547
|
+
/**
|
|
1548
|
+
* @param {Node} tree
|
|
1549
|
+
* @param {Test} test
|
|
1550
|
+
* @param {import('./complex-types').Visitor<Node>} visitor
|
|
1551
|
+
* @param {boolean} [reverse]
|
|
1552
|
+
*/
|
|
1553
|
+
function (tree, test, visitor, reverse) {
|
|
1554
|
+
if (typeof test === 'function' && typeof visitor !== 'function') {
|
|
1555
|
+
reverse = visitor;
|
|
1556
|
+
// @ts-expect-error no visitor given, so `visitor` is test.
|
|
1557
|
+
visitor = test;
|
|
1558
|
+
test = null;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
const is = convert$1(test);
|
|
1562
|
+
const step = reverse ? -1 : 1;
|
|
1563
|
+
|
|
1564
|
+
factory(tree, null, [])();
|
|
1565
|
+
|
|
1566
|
+
/**
|
|
1567
|
+
* @param {Node} node
|
|
1568
|
+
* @param {number?} index
|
|
1569
|
+
* @param {Array.<Parent>} parents
|
|
1570
|
+
*/
|
|
1571
|
+
function factory(node, index, parents) {
|
|
1572
|
+
/** @type {Object.<string, unknown>} */
|
|
1573
|
+
// @ts-expect-error: hush
|
|
1574
|
+
const value = typeof node === 'object' && node !== null ? node : {};
|
|
1575
|
+
/** @type {string|undefined} */
|
|
1576
|
+
let name;
|
|
1577
|
+
|
|
1578
|
+
if (typeof value.type === 'string') {
|
|
1579
|
+
name =
|
|
1580
|
+
typeof value.tagName === 'string'
|
|
1581
|
+
? value.tagName
|
|
1582
|
+
: typeof value.name === 'string'
|
|
1583
|
+
? value.name
|
|
1584
|
+
: undefined;
|
|
1585
|
+
|
|
1586
|
+
Object.defineProperty(visit, 'name', {
|
|
1587
|
+
value:
|
|
1588
|
+
'node (' +
|
|
1589
|
+
color(value.type + (name ? '<' + name + '>' : '')) +
|
|
1590
|
+
')'
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
return visit
|
|
1595
|
+
|
|
1596
|
+
function visit() {
|
|
1597
|
+
/** @type {ActionTuple} */
|
|
1598
|
+
let result = [];
|
|
1599
|
+
/** @type {ActionTuple} */
|
|
1600
|
+
let subresult;
|
|
1601
|
+
/** @type {number} */
|
|
1602
|
+
let offset;
|
|
1603
|
+
/** @type {Array.<Parent>} */
|
|
1604
|
+
let grandparents;
|
|
1605
|
+
|
|
1606
|
+
if (!test || is(node, index, parents[parents.length - 1] || null)) {
|
|
1607
|
+
result = toResult(visitor(node, parents));
|
|
1608
|
+
|
|
1609
|
+
if (result[0] === EXIT) {
|
|
1610
|
+
return result
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
// @ts-expect-error looks like a parent.
|
|
1615
|
+
if (node.children && result[0] !== SKIP) {
|
|
1616
|
+
// @ts-expect-error looks like a parent.
|
|
1617
|
+
offset = (reverse ? node.children.length : -1) + step;
|
|
1618
|
+
// @ts-expect-error looks like a parent.
|
|
1619
|
+
grandparents = parents.concat(node);
|
|
1620
|
+
|
|
1621
|
+
// @ts-expect-error looks like a parent.
|
|
1622
|
+
while (offset > -1 && offset < node.children.length) {
|
|
1623
|
+
// @ts-expect-error looks like a parent.
|
|
1624
|
+
subresult = factory(node.children[offset], offset, grandparents)();
|
|
1625
|
+
|
|
1626
|
+
if (subresult[0] === EXIT) {
|
|
1627
|
+
return subresult
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
offset =
|
|
1631
|
+
typeof subresult[1] === 'number' ? subresult[1] : offset + step;
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
return result
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
);
|
|
1640
|
+
|
|
1641
|
+
/**
|
|
1642
|
+
* @param {VisitorResult} value
|
|
1643
|
+
* @returns {ActionTuple}
|
|
1644
|
+
*/
|
|
1645
|
+
function toResult(value) {
|
|
1646
|
+
if (Array.isArray(value)) {
|
|
1647
|
+
return value
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
if (typeof value === 'number') {
|
|
1651
|
+
return [CONTINUE, value]
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
return [value]
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
/**
|
|
1658
|
+
* @typedef {import('unist').Node} Node
|
|
1659
|
+
* @typedef {import('unist').Parent} Parent
|
|
1660
|
+
*
|
|
1661
|
+
* @typedef {string} Type
|
|
1662
|
+
* @typedef {Object<string, unknown>} Props
|
|
1663
|
+
*
|
|
1664
|
+
* @typedef {null|undefined|Type|Props|TestFunctionAnything|Array.<Type|Props|TestFunctionAnything>} Test
|
|
1665
|
+
*/
|
|
1666
|
+
|
|
1667
|
+
const convert =
|
|
1668
|
+
/**
|
|
1669
|
+
* @type {(
|
|
1670
|
+
* (<T extends Node>(test: T['type']|Partial<T>|TestFunctionPredicate<T>) => AssertPredicate<T>) &
|
|
1671
|
+
* ((test?: Test) => AssertAnything)
|
|
1672
|
+
* )}
|
|
1673
|
+
*/
|
|
1674
|
+
(
|
|
1675
|
+
/**
|
|
1676
|
+
* Generate an assertion from a check.
|
|
1677
|
+
* @param {Test} [test]
|
|
1678
|
+
* When nullish, checks if `node` is a `Node`.
|
|
1679
|
+
* When `string`, works like passing `function (node) {return node.type === test}`.
|
|
1680
|
+
* When `function` checks if function passed the node is true.
|
|
1681
|
+
* When `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
|
|
1682
|
+
* When `array`, checks any one of the subtests pass.
|
|
1683
|
+
* @returns {AssertAnything}
|
|
1684
|
+
*/
|
|
1685
|
+
function (test) {
|
|
1686
|
+
if (test === undefined || test === null) {
|
|
1687
|
+
return ok
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
if (typeof test === 'string') {
|
|
1691
|
+
return typeFactory(test)
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
if (typeof test === 'object') {
|
|
1695
|
+
return Array.isArray(test) ? anyFactory(test) : propsFactory(test)
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
if (typeof test === 'function') {
|
|
1699
|
+
return castFactory(test)
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
throw new Error('Expected function, string, or object as test')
|
|
1703
|
+
}
|
|
1704
|
+
);
|
|
1705
|
+
/**
|
|
1706
|
+
* @param {Array.<Type|Props|TestFunctionAnything>} tests
|
|
1707
|
+
* @returns {AssertAnything}
|
|
1708
|
+
*/
|
|
1709
|
+
function anyFactory(tests) {
|
|
1710
|
+
/** @type {Array.<AssertAnything>} */
|
|
1711
|
+
const checks = [];
|
|
1712
|
+
let index = -1;
|
|
1713
|
+
|
|
1714
|
+
while (++index < tests.length) {
|
|
1715
|
+
checks[index] = convert(tests[index]);
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
return castFactory(any)
|
|
1719
|
+
|
|
1720
|
+
/**
|
|
1721
|
+
* @this {unknown}
|
|
1722
|
+
* @param {unknown[]} parameters
|
|
1723
|
+
* @returns {boolean}
|
|
1724
|
+
*/
|
|
1725
|
+
function any(...parameters) {
|
|
1726
|
+
let index = -1;
|
|
1727
|
+
|
|
1728
|
+
while (++index < checks.length) {
|
|
1729
|
+
if (checks[index].call(this, ...parameters)) return true
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
return false
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
/**
|
|
1737
|
+
* Utility to assert each property in `test` is represented in `node`, and each
|
|
1738
|
+
* values are strictly equal.
|
|
1739
|
+
*
|
|
1740
|
+
* @param {Props} check
|
|
1741
|
+
* @returns {AssertAnything}
|
|
1742
|
+
*/
|
|
1743
|
+
function propsFactory(check) {
|
|
1744
|
+
return castFactory(all)
|
|
1745
|
+
|
|
1746
|
+
/**
|
|
1747
|
+
* @param {Node} node
|
|
1748
|
+
* @returns {boolean}
|
|
1749
|
+
*/
|
|
1750
|
+
function all(node) {
|
|
1751
|
+
/** @type {string} */
|
|
1752
|
+
let key;
|
|
1753
|
+
|
|
1754
|
+
for (key in check) {
|
|
1755
|
+
// @ts-expect-error: hush, it sure works as an index.
|
|
1756
|
+
if (node[key] !== check[key]) return false
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
return true
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
/**
|
|
1764
|
+
* Utility to convert a string into a function which checks a given node’s type
|
|
1765
|
+
* for said string.
|
|
1766
|
+
*
|
|
1767
|
+
* @param {Type} check
|
|
1768
|
+
* @returns {AssertAnything}
|
|
1769
|
+
*/
|
|
1770
|
+
function typeFactory(check) {
|
|
1771
|
+
return castFactory(type)
|
|
1772
|
+
|
|
1773
|
+
/**
|
|
1774
|
+
* @param {Node} node
|
|
1775
|
+
*/
|
|
1776
|
+
function type(node) {
|
|
1777
|
+
return node && node.type === check
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
/**
|
|
1782
|
+
* Utility to convert a string into a function which checks a given node’s type
|
|
1783
|
+
* for said string.
|
|
1784
|
+
* @param {TestFunctionAnything} check
|
|
1785
|
+
* @returns {AssertAnything}
|
|
1786
|
+
*/
|
|
1787
|
+
function castFactory(check) {
|
|
1788
|
+
return assertion
|
|
1789
|
+
|
|
1790
|
+
/**
|
|
1791
|
+
* @this {unknown}
|
|
1792
|
+
* @param {Array.<unknown>} parameters
|
|
1793
|
+
* @returns {boolean}
|
|
1794
|
+
*/
|
|
1795
|
+
function assertion(...parameters) {
|
|
1796
|
+
// @ts-expect-error: spreading is fine.
|
|
1797
|
+
return Boolean(check.call(this, ...parameters))
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
// Utility to return true.
|
|
1802
|
+
function ok() {
|
|
1803
|
+
return true
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
/**
|
|
1807
|
+
* @typedef Options
|
|
1808
|
+
* Configuration (optional).
|
|
1809
|
+
* @property {Test} [ignore]
|
|
1810
|
+
* `unist-util-is` test used to assert parents
|
|
1811
|
+
*
|
|
1812
|
+
* @typedef {import('mdast').Root} Root
|
|
1813
|
+
* @typedef {import('mdast').Content} Content
|
|
1814
|
+
* @typedef {import('mdast').PhrasingContent} PhrasingContent
|
|
1815
|
+
* @typedef {import('mdast').Text} Text
|
|
1816
|
+
* @typedef {Content|Root} Node
|
|
1817
|
+
* @typedef {Exclude<Extract<Node, import('mdast').Parent>, Root>} Parent
|
|
1818
|
+
*
|
|
1819
|
+
* @typedef {import('unist-util-visit-parents').Test} Test
|
|
1820
|
+
* @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult
|
|
1821
|
+
*
|
|
1822
|
+
* @typedef RegExpMatchObject
|
|
1823
|
+
* @property {number} index
|
|
1824
|
+
* @property {string} input
|
|
1825
|
+
* @property {[Root, ...Array<Parent>, Text]} stack
|
|
1826
|
+
*
|
|
1827
|
+
* @typedef {string|RegExp} Find
|
|
1828
|
+
* @typedef {string|ReplaceFunction} Replace
|
|
1829
|
+
*
|
|
1830
|
+
* @typedef {[Find, Replace]} FindAndReplaceTuple
|
|
1831
|
+
* @typedef {Record<string, Replace>} FindAndReplaceSchema
|
|
1832
|
+
* @typedef {Array<FindAndReplaceTuple>} FindAndReplaceList
|
|
1833
|
+
*
|
|
1834
|
+
* @typedef {[RegExp, ReplaceFunction]} Pair
|
|
1835
|
+
* @typedef {Array<Pair>} Pairs
|
|
1836
|
+
*/
|
|
1837
|
+
|
|
1838
|
+
const own = {}.hasOwnProperty;
|
|
1839
|
+
|
|
1840
|
+
/**
|
|
1841
|
+
* @param tree mdast tree
|
|
1842
|
+
* @param find Value to find and remove. When `string`, escaped and made into a global `RegExp`
|
|
1843
|
+
* @param [replace] Value to insert.
|
|
1844
|
+
* * When `string`, turned into a Text node.
|
|
1845
|
+
* * When `Function`, called with the results of calling `RegExp.exec` as
|
|
1846
|
+
* arguments, in which case it can return a single or a list of `Node`,
|
|
1847
|
+
* a `string` (which is wrapped in a `Text` node), or `false` to not replace
|
|
1848
|
+
* @param [options] Configuration.
|
|
1849
|
+
*/
|
|
1850
|
+
const findAndReplace =
|
|
1851
|
+
/**
|
|
1852
|
+
* @type {(
|
|
1853
|
+
* ((tree: Node, find: Find, replace?: Replace, options?: Options) => Node) &
|
|
1854
|
+
* ((tree: Node, schema: FindAndReplaceSchema|FindAndReplaceList, options?: Options) => Node)
|
|
1855
|
+
* )}
|
|
1856
|
+
**/
|
|
1857
|
+
(
|
|
1858
|
+
/**
|
|
1859
|
+
* @param {Node} tree
|
|
1860
|
+
* @param {Find|FindAndReplaceSchema|FindAndReplaceList} find
|
|
1861
|
+
* @param {Replace|Options} [replace]
|
|
1862
|
+
* @param {Options} [options]
|
|
1863
|
+
*/
|
|
1864
|
+
function (tree, find, replace, options) {
|
|
1865
|
+
/** @type {Options|undefined} */
|
|
1866
|
+
let settings;
|
|
1867
|
+
/** @type {FindAndReplaceSchema|FindAndReplaceList} */
|
|
1868
|
+
let schema;
|
|
1869
|
+
|
|
1870
|
+
if (typeof find === 'string' || find instanceof RegExp) {
|
|
1871
|
+
// @ts-expect-error don’t expect options twice.
|
|
1872
|
+
schema = [[find, replace]];
|
|
1873
|
+
settings = options;
|
|
1874
|
+
} else {
|
|
1875
|
+
schema = find;
|
|
1876
|
+
// @ts-expect-error don’t expect replace twice.
|
|
1877
|
+
settings = replace;
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
if (!settings) {
|
|
1881
|
+
settings = {};
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1884
|
+
const ignored = convert(settings.ignore || []);
|
|
1885
|
+
const pairs = toPairs(schema);
|
|
1886
|
+
let pairIndex = -1;
|
|
1887
|
+
|
|
1888
|
+
while (++pairIndex < pairs.length) {
|
|
1889
|
+
visitParents(tree, 'text', visitor);
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
return tree
|
|
1893
|
+
|
|
1894
|
+
/** @type {import('unist-util-visit-parents/complex-types').BuildVisitor<Root, 'text'>} */
|
|
1895
|
+
function visitor(node, parents) {
|
|
1896
|
+
let index = -1;
|
|
1897
|
+
/** @type {Parent|undefined} */
|
|
1898
|
+
let grandparent;
|
|
1899
|
+
|
|
1900
|
+
while (++index < parents.length) {
|
|
1901
|
+
const parent = /** @type {Parent} */ (parents[index]);
|
|
1902
|
+
|
|
1903
|
+
if (
|
|
1904
|
+
ignored(
|
|
1905
|
+
parent,
|
|
1906
|
+
// @ts-expect-error mdast vs. unist parent.
|
|
1907
|
+
grandparent ? grandparent.children.indexOf(parent) : undefined,
|
|
1908
|
+
grandparent
|
|
1909
|
+
)
|
|
1910
|
+
) {
|
|
1911
|
+
return
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
grandparent = parent;
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
if (grandparent) {
|
|
1918
|
+
// @ts-expect-error: stack is fine.
|
|
1919
|
+
return handler(node, parents)
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
/**
|
|
1924
|
+
* @param {Text} node
|
|
1925
|
+
* @param {[Root, ...Array<Parent>]} parents
|
|
1926
|
+
* @returns {VisitorResult}
|
|
1927
|
+
*/
|
|
1928
|
+
function handler(node, parents) {
|
|
1929
|
+
const parent = parents[parents.length - 1];
|
|
1930
|
+
const find = pairs[pairIndex][0];
|
|
1931
|
+
const replace = pairs[pairIndex][1];
|
|
1932
|
+
let start = 0;
|
|
1933
|
+
// @ts-expect-error: TS is wrong, some of these children can be text.
|
|
1934
|
+
const index = parent.children.indexOf(node);
|
|
1935
|
+
let change = false;
|
|
1936
|
+
/** @type {Array<PhrasingContent>} */
|
|
1937
|
+
let nodes = [];
|
|
1938
|
+
/** @type {number|undefined} */
|
|
1939
|
+
let position;
|
|
1940
|
+
|
|
1941
|
+
find.lastIndex = 0;
|
|
1942
|
+
|
|
1943
|
+
let match = find.exec(node.value);
|
|
1944
|
+
|
|
1945
|
+
while (match) {
|
|
1946
|
+
position = match.index;
|
|
1947
|
+
/** @type {RegExpMatchObject} */
|
|
1948
|
+
const matchObject = {
|
|
1949
|
+
index: match.index,
|
|
1950
|
+
input: match.input,
|
|
1951
|
+
stack: [...parents, node]
|
|
1952
|
+
};
|
|
1953
|
+
let value = replace(...match, matchObject);
|
|
1954
|
+
|
|
1955
|
+
if (typeof value === 'string') {
|
|
1956
|
+
value = value.length > 0 ? {type: 'text', value} : undefined;
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
if (value !== false) {
|
|
1960
|
+
if (start !== position) {
|
|
1961
|
+
nodes.push({
|
|
1962
|
+
type: 'text',
|
|
1963
|
+
value: node.value.slice(start, position)
|
|
1964
|
+
});
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
if (Array.isArray(value)) {
|
|
1968
|
+
nodes.push(...value);
|
|
1969
|
+
} else if (value) {
|
|
1970
|
+
nodes.push(value);
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
start = position + match[0].length;
|
|
1974
|
+
change = true;
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
if (!find.global) {
|
|
1978
|
+
break
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
match = find.exec(node.value);
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
if (change) {
|
|
1985
|
+
if (start < node.value.length) {
|
|
1986
|
+
nodes.push({type: 'text', value: node.value.slice(start)});
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
parent.children.splice(index, 1, ...nodes);
|
|
1990
|
+
} else {
|
|
1991
|
+
nodes = [node];
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
return index + nodes.length
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
);
|
|
1998
|
+
|
|
1999
|
+
/**
|
|
2000
|
+
* @param {FindAndReplaceSchema|FindAndReplaceList} schema
|
|
2001
|
+
* @returns {Pairs}
|
|
2002
|
+
*/
|
|
2003
|
+
function toPairs(schema) {
|
|
2004
|
+
/** @type {Pairs} */
|
|
2005
|
+
const result = [];
|
|
2006
|
+
|
|
2007
|
+
if (typeof schema !== 'object') {
|
|
2008
|
+
throw new TypeError('Expected array or object as schema')
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
if (Array.isArray(schema)) {
|
|
2012
|
+
let index = -1;
|
|
2013
|
+
|
|
2014
|
+
while (++index < schema.length) {
|
|
2015
|
+
result.push([
|
|
2016
|
+
toExpression(schema[index][0]),
|
|
2017
|
+
toFunction(schema[index][1])
|
|
2018
|
+
]);
|
|
2019
|
+
}
|
|
2020
|
+
} else {
|
|
2021
|
+
/** @type {string} */
|
|
2022
|
+
let key;
|
|
2023
|
+
|
|
2024
|
+
for (key in schema) {
|
|
2025
|
+
if (own.call(schema, key)) {
|
|
2026
|
+
result.push([toExpression(key), toFunction(schema[key])]);
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
return result
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
/**
|
|
2035
|
+
* @param {Find} find
|
|
2036
|
+
* @returns {RegExp}
|
|
2037
|
+
*/
|
|
2038
|
+
function toExpression(find) {
|
|
2039
|
+
return typeof find === 'string' ? new RegExp(escapeStringRegexp(find), 'g') : find
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
/**
|
|
2043
|
+
* @param {Replace} replace
|
|
2044
|
+
* @returns {ReplaceFunction}
|
|
2045
|
+
*/
|
|
2046
|
+
function toFunction(replace) {
|
|
2047
|
+
return typeof replace === 'function' ? replace : () => replace
|
|
2048
|
+
}
|
|
2049
|
+
|
|
1336
2050
|
var isOnlyEmojis = function (text) {
|
|
1337
2051
|
if (!text)
|
|
1338
2052
|
return false;
|
|
@@ -1413,7 +2127,7 @@ var emojiMarkdownPlugin = function () {
|
|
|
1413
2127
|
};
|
|
1414
2128
|
}
|
|
1415
2129
|
var transform = function (markdownAST) {
|
|
1416
|
-
|
|
2130
|
+
findAndReplace(markdownAST, emojiRegex__default['default'](), replace);
|
|
1417
2131
|
return markdownAST;
|
|
1418
2132
|
};
|
|
1419
2133
|
return transform;
|
|
@@ -1440,7 +2154,7 @@ var mentionsMarkdownPlugin = function (mentioned_users) { return function () {
|
|
|
1440
2154
|
return markdownAST;
|
|
1441
2155
|
}
|
|
1442
2156
|
var mentionedUsersRegex = new RegExp(mentioned_usernames.map(function (username) { return "@" + username; }).join('|'), 'g');
|
|
1443
|
-
|
|
2157
|
+
findAndReplace(markdownAST, mentionedUsersRegex, replace);
|
|
1444
2158
|
return markdownAST;
|
|
1445
2159
|
};
|
|
1446
2160
|
return transform;
|
|
@@ -1471,6 +2185,22 @@ var renderText = function (text, mentioned_users, options) {
|
|
|
1471
2185
|
if (noParsingNeeded.length > 0 || linkIsInBlock)
|
|
1472
2186
|
return;
|
|
1473
2187
|
try {
|
|
2188
|
+
// special case for mentions:
|
|
2189
|
+
// it could happen that a user's name matches with an e-mail format pattern.
|
|
2190
|
+
// in that case, we check whether the found e-mail is actually a mention
|
|
2191
|
+
// by naively checking for an existence of @ sign in front of it.
|
|
2192
|
+
if (type === 'email' && mentioned_users) {
|
|
2193
|
+
var emailMatchesWithName = mentioned_users.some(function (u) { return u.name === value; });
|
|
2194
|
+
if (emailMatchesWithName) {
|
|
2195
|
+
newText = newText.replace(new RegExp(escapeRegExp(value), 'g'), function (match, position) {
|
|
2196
|
+
var isMention = newText.charAt(position - 1) === '@';
|
|
2197
|
+
// in case of mention, we leave the match in its original form,
|
|
2198
|
+
// and we let `mentionsMarkdownPlugin` to do its job
|
|
2199
|
+
return isMention ? match : "[" + match + "](" + encodeDecode(href) + ")";
|
|
2200
|
+
});
|
|
2201
|
+
return;
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
1474
2204
|
var displayLink = type === 'email' ? value : formatUrlForDisplay(href);
|
|
1475
2205
|
newText = newText.replace(new RegExp(escapeRegExp(value), 'g'), "[" + displayLink + "](" + encodeDecode(href) + ")");
|
|
1476
2206
|
}
|
|
@@ -1866,7 +2596,7 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
|
|
|
1866
2596
|
});
|
|
1867
2597
|
|
|
1868
2598
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "_defaultShouldSubmit", function (event) {
|
|
1869
|
-
return event.key === 'Enter' && !event.shiftKey;
|
|
2599
|
+
return event.key === 'Enter' && !event.shiftKey && !event.nativeEvent.isComposing;
|
|
1870
2600
|
});
|
|
1871
2601
|
|
|
1872
2602
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "_handleKeyDown", function (event) {
|
|
@@ -4120,32 +4850,12 @@ var UnMemoizedMessageTextComponent = function (props) {
|
|
|
4120
4850
|
};
|
|
4121
4851
|
var MessageText = React__default['default'].memo(UnMemoizedMessageTextComponent);
|
|
4122
4852
|
|
|
4123
|
-
var DefaultEmoji = React__default['default'].lazy(function () { return
|
|
4124
|
-
|
|
4125
|
-
return __generator(this, function (_a) {
|
|
4126
|
-
switch (_a.label) {
|
|
4127
|
-
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('emoji-mart/dist/components/emoji/nimble-emoji.js')); })];
|
|
4128
|
-
case 1:
|
|
4129
|
-
emoji = _a.sent();
|
|
4130
|
-
return [2 /*return*/, { default: emoji.default }];
|
|
4131
|
-
}
|
|
4132
|
-
});
|
|
4133
|
-
}); });
|
|
4134
|
-
var DefaultEmojiPicker = React__default['default'].lazy(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
4135
|
-
var emojiPicker;
|
|
4136
|
-
return __generator(this, function (_a) {
|
|
4137
|
-
switch (_a.label) {
|
|
4138
|
-
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('emoji-mart/dist/components/picker/nimble-picker.js')); })];
|
|
4139
|
-
case 1:
|
|
4140
|
-
emojiPicker = _a.sent();
|
|
4141
|
-
return [2 /*return*/, { default: emojiPicker.default }];
|
|
4142
|
-
}
|
|
4143
|
-
});
|
|
4144
|
-
}); });
|
|
4853
|
+
var DefaultEmoji$1 = React__default['default'].lazy(function () { return Promise.resolve().then(function () { return DefaultEmoji; }); });
|
|
4854
|
+
var DefaultEmojiPicker$1 = React__default['default'].lazy(function () { return Promise.resolve().then(function () { return DefaultEmojiPicker; }); });
|
|
4145
4855
|
var EmojiContext = React__default['default'].createContext(undefined);
|
|
4146
4856
|
var EmojiProvider = function (_a) {
|
|
4147
4857
|
var children = _a.children, value = _a.value;
|
|
4148
|
-
var _b = value.Emoji, Emoji = _b === void 0 ? DefaultEmoji : _b, emojiConfig = value.emojiConfig, _c = value.EmojiIndex, EmojiIndex = _c === void 0 ? DefaultEmojiIndex__default['default'] : _c, _d = value.EmojiPicker, EmojiPicker = _d === void 0 ? DefaultEmojiPicker : _d;
|
|
4858
|
+
var _b = value.Emoji, Emoji = _b === void 0 ? DefaultEmoji$1 : _b, emojiConfig = value.emojiConfig, _c = value.EmojiIndex, EmojiIndex = _c === void 0 ? DefaultEmojiIndex__default['default'] : _c, _d = value.EmojiPicker, EmojiPicker = _d === void 0 ? DefaultEmojiPicker$1 : _d;
|
|
4149
4859
|
var emojiContextValue = {
|
|
4150
4860
|
Emoji: Emoji,
|
|
4151
4861
|
emojiConfig: emojiConfig,
|
|
@@ -4858,8 +5568,9 @@ var useImageUploads = function (props, state, dispatch) {
|
|
|
4858
5568
|
}, []);
|
|
4859
5569
|
var uploadImage = React.useCallback(function (id) { return __awaiter(void 0, void 0, void 0, function () {
|
|
4860
5570
|
var img, file, canUpload, response, error_1, errorMessage, alreadyRemoved;
|
|
4861
|
-
|
|
4862
|
-
|
|
5571
|
+
var _a;
|
|
5572
|
+
return __generator(this, function (_b) {
|
|
5573
|
+
switch (_b.label) {
|
|
4863
5574
|
case 0:
|
|
4864
5575
|
img = imageUploads[id];
|
|
4865
5576
|
if (!img)
|
|
@@ -4876,24 +5587,24 @@ var useImageUploads = function (props, state, dispatch) {
|
|
|
4876
5587
|
uploadType: 'image',
|
|
4877
5588
|
})];
|
|
4878
5589
|
case 1:
|
|
4879
|
-
canUpload =
|
|
5590
|
+
canUpload = _b.sent();
|
|
4880
5591
|
if (!canUpload)
|
|
4881
5592
|
return [2 /*return*/, removeImage(id)];
|
|
4882
|
-
|
|
5593
|
+
_b.label = 2;
|
|
4883
5594
|
case 2:
|
|
4884
|
-
|
|
5595
|
+
_b.trys.push([2, 7, , 8]);
|
|
4885
5596
|
if (!doImageUploadRequest) return [3 /*break*/, 4];
|
|
4886
5597
|
return [4 /*yield*/, doImageUploadRequest(file, channel)];
|
|
4887
5598
|
case 3:
|
|
4888
|
-
response =
|
|
5599
|
+
response = _b.sent();
|
|
4889
5600
|
return [3 /*break*/, 6];
|
|
4890
5601
|
case 4: return [4 /*yield*/, channel.sendImage(file)];
|
|
4891
5602
|
case 5:
|
|
4892
|
-
response =
|
|
4893
|
-
|
|
5603
|
+
response = _b.sent();
|
|
5604
|
+
_b.label = 6;
|
|
4894
5605
|
case 6: return [3 /*break*/, 8];
|
|
4895
5606
|
case 7:
|
|
4896
|
-
error_1 =
|
|
5607
|
+
error_1 = _b.sent();
|
|
4897
5608
|
errorMessage = typeof error_1.message === 'string'
|
|
4898
5609
|
? error_1.message
|
|
4899
5610
|
: t('Error uploading image');
|
|
@@ -4917,8 +5628,11 @@ var useImageUploads = function (props, state, dispatch) {
|
|
|
4917
5628
|
removeImage(id);
|
|
4918
5629
|
return [2 /*return*/];
|
|
4919
5630
|
}
|
|
5631
|
+
if (img.previewUri)
|
|
5632
|
+
(_a = URL.revokeObjectURL) === null || _a === void 0 ? void 0 : _a.call(URL, img.previewUri);
|
|
4920
5633
|
dispatch({
|
|
4921
5634
|
id: id,
|
|
5635
|
+
previewUri: undefined,
|
|
4922
5636
|
state: 'finished',
|
|
4923
5637
|
type: 'setImageUpload',
|
|
4924
5638
|
url: response.file,
|
|
@@ -4928,33 +5642,10 @@ var useImageUploads = function (props, state, dispatch) {
|
|
|
4928
5642
|
});
|
|
4929
5643
|
}); }, [imageUploads, channel, doImageUploadRequest, errorHandler, removeImage]);
|
|
4930
5644
|
React.useEffect(function () {
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
if (upload) {
|
|
4936
|
-
var file = upload.file, id_1 = upload.id;
|
|
4937
|
-
// TODO: Possibly use URL.createObjectURL instead. However, then we need
|
|
4938
|
-
// to release the previews when not used anymore though.
|
|
4939
|
-
var reader_1 = new FileReader();
|
|
4940
|
-
reader_1.onload = function (event) {
|
|
4941
|
-
var _a;
|
|
4942
|
-
if (typeof ((_a = event.target) === null || _a === void 0 ? void 0 : _a.result) !== 'string')
|
|
4943
|
-
return;
|
|
4944
|
-
dispatch({
|
|
4945
|
-
id: id_1,
|
|
4946
|
-
previewUri: event.target.result,
|
|
4947
|
-
type: 'setImageUpload',
|
|
4948
|
-
});
|
|
4949
|
-
};
|
|
4950
|
-
reader_1.readAsDataURL(file);
|
|
4951
|
-
uploadImage(id_1);
|
|
4952
|
-
return function () {
|
|
4953
|
-
reader_1.onload = null;
|
|
4954
|
-
};
|
|
4955
|
-
}
|
|
4956
|
-
}
|
|
4957
|
-
return;
|
|
5645
|
+
var upload = Object.values(imageUploads).find(function (imageUpload) { return imageUpload.state === 'uploading' && imageUpload.file; });
|
|
5646
|
+
if (!upload)
|
|
5647
|
+
return;
|
|
5648
|
+
uploadImage(upload.id);
|
|
4958
5649
|
}, [imageUploads, uploadImage]);
|
|
4959
5650
|
return {
|
|
4960
5651
|
removeImage: removeImage,
|
|
@@ -5078,11 +5769,18 @@ var useAttachments = function (props, state, dispatch, textareaRef) {
|
|
|
5078
5769
|
Array.from(files)
|
|
5079
5770
|
.slice(0, maxFilesLeft)
|
|
5080
5771
|
.forEach(function (file) {
|
|
5772
|
+
var _a;
|
|
5081
5773
|
var id = nanoid.nanoid();
|
|
5082
5774
|
if (file.type.startsWith('image/') &&
|
|
5083
5775
|
!file.type.endsWith('.photoshop') // photoshop files begin with 'image/'
|
|
5084
5776
|
) {
|
|
5085
|
-
dispatch({
|
|
5777
|
+
dispatch({
|
|
5778
|
+
file: file,
|
|
5779
|
+
id: id,
|
|
5780
|
+
previewUri: (_a = URL.createObjectURL) === null || _a === void 0 ? void 0 : _a.call(URL, file),
|
|
5781
|
+
state: 'uploading',
|
|
5782
|
+
type: 'setImageUpload',
|
|
5783
|
+
});
|
|
5086
5784
|
}
|
|
5087
5785
|
else if (file instanceof File && !noFiles) {
|
|
5088
5786
|
dispatch({ file: file, id: id, state: 'uploading', type: 'setFileUpload' });
|
|
@@ -5337,7 +6035,7 @@ var useSubmitHandler = function (props, state, dispatch, numberOfUploads) {
|
|
|
5337
6035
|
_a.label = 1;
|
|
5338
6036
|
case 1:
|
|
5339
6037
|
_a.trys.push([1, 3, , 4]);
|
|
5340
|
-
return [4 /*yield*/, editMessage(__assign(__assign({}, message), updatedMessage))];
|
|
6038
|
+
return [4 /*yield*/, editMessage(__assign(__assign(__assign({}, message), updatedMessage), customMessageData))];
|
|
5341
6039
|
case 2:
|
|
5342
6040
|
_a.sent();
|
|
5343
6041
|
clearEditingState === null || clearEditingState === void 0 ? void 0 : clearEditingState();
|
|
@@ -6184,7 +6882,6 @@ var makeAddNotifications = function (setNotifications, notificationTimeouts) { r
|
|
|
6184
6882
|
notificationTimeouts.push(timeout);
|
|
6185
6883
|
}; };
|
|
6186
6884
|
|
|
6187
|
-
var JUMP_MESSAGE_PAGE_SIZE = 25;
|
|
6188
6885
|
var UnMemoizedChannel = function (props) {
|
|
6189
6886
|
var propsChannel = props.channel, _a = props.EmptyPlaceholder, EmptyPlaceholder = _a === void 0 ? null : _a, LoadingErrorIndicator = props.LoadingErrorIndicator, LoadingIndicator = props.LoadingIndicator;
|
|
6190
6887
|
var _b = useChatContext('Channel'), contextChannel = _b.channel, channelsQueryState = _b.channelsQueryState;
|
|
@@ -6454,30 +7151,33 @@ var ChannelInner = function (props) {
|
|
|
6454
7151
|
});
|
|
6455
7152
|
});
|
|
6456
7153
|
};
|
|
6457
|
-
var jumpToMessage = function (messageId
|
|
6458
|
-
|
|
6459
|
-
return
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
7154
|
+
var jumpToMessage = function (messageId, messageLimit) {
|
|
7155
|
+
if (messageLimit === void 0) { messageLimit = 100; }
|
|
7156
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
7157
|
+
var indexOfMessage, hasMoreMessages;
|
|
7158
|
+
return __generator(this, function (_a) {
|
|
7159
|
+
switch (_a.label) {
|
|
7160
|
+
case 0:
|
|
7161
|
+
dispatch({ loadingMore: true, type: 'setLoadingMore' });
|
|
7162
|
+
return [4 /*yield*/, channel.state.loadMessageIntoState(messageId, undefined, messageLimit)];
|
|
7163
|
+
case 1:
|
|
7164
|
+
_a.sent();
|
|
7165
|
+
indexOfMessage = channel.state.messages.findIndex(function (message) { return message.id === messageId; });
|
|
7166
|
+
hasMoreMessages = indexOfMessage >= Math.floor(messageLimit / 2);
|
|
7167
|
+
loadMoreFinished(hasMoreMessages, channel.state.messages);
|
|
7168
|
+
dispatch({
|
|
7169
|
+
hasMoreNewer: channel.state.messages !== channel.state.latestMessages,
|
|
7170
|
+
highlightedMessageId: messageId,
|
|
7171
|
+
type: 'jumpToMessageFinished',
|
|
7172
|
+
});
|
|
7173
|
+
setTimeout(function () {
|
|
7174
|
+
dispatch({ type: 'clearHighlightedMessage' });
|
|
7175
|
+
}, 500);
|
|
7176
|
+
return [2 /*return*/];
|
|
7177
|
+
}
|
|
7178
|
+
});
|
|
6479
7179
|
});
|
|
6480
|
-
}
|
|
7180
|
+
};
|
|
6481
7181
|
var jumpToLatestMessage = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
6482
7182
|
var hasMoreOlder;
|
|
6483
7183
|
return __generator(this, function (_a) {
|
|
@@ -7691,7 +8391,7 @@ var UnMemoizedChannelList = function (props) {
|
|
|
7691
8391
|
*/
|
|
7692
8392
|
var ChannelList = React__default['default'].memo(UnMemoizedChannelList);
|
|
7693
8393
|
|
|
7694
|
-
var version = '9.
|
|
8394
|
+
var version = '9.5.0';
|
|
7695
8395
|
|
|
7696
8396
|
var useChat = function (_a) {
|
|
7697
8397
|
var _b, _c;
|
|
@@ -9490,6 +10190,20 @@ var UnMemoizedWindow = function (props) {
|
|
|
9490
10190
|
*/
|
|
9491
10191
|
var Window = React__default['default'].memo(UnMemoizedWindow);
|
|
9492
10192
|
|
|
10193
|
+
// @ts-expect-error
|
|
10194
|
+
|
|
10195
|
+
var DefaultEmoji = /*#__PURE__*/Object.freeze({
|
|
10196
|
+
__proto__: null,
|
|
10197
|
+
'default': nimbleEmoji__default['default']
|
|
10198
|
+
});
|
|
10199
|
+
|
|
10200
|
+
// @ts-expect-error
|
|
10201
|
+
|
|
10202
|
+
var DefaultEmojiPicker = /*#__PURE__*/Object.freeze({
|
|
10203
|
+
__proto__: null,
|
|
10204
|
+
'default': nimblePicker__default['default']
|
|
10205
|
+
});
|
|
10206
|
+
|
|
9493
10207
|
exports.ActionsIcon = ActionsIcon;
|
|
9494
10208
|
exports.Attachment = Attachment;
|
|
9495
10209
|
exports.AttachmentActions = AttachmentActions;
|