stream-chat-react 9.4.0 → 9.5.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.
- package/dist/browser.full-bundle.js +460 -2760
- 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 +31 -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/context/ChannelActionContext.d.ts +1 -1
- package/dist/context/ChannelActionContext.d.ts.map +1 -1
- package/dist/context/ChannelStateContext.d.ts +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 +793 -89
- package/dist/index.cjs.js.map +1 -1
- package/dist/scss/Gallery.scss +6 -0
- package/dist/scss/Message.scss +67 -34
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -3
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 mdastUtilFindAndReplace = 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
|
|
|
@@ -111,6 +112,8 @@ var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
|
|
|
111
112
|
var throttle__default = /*#__PURE__*/_interopDefaultLegacy(throttle);
|
|
112
113
|
var deepequal__default = /*#__PURE__*/_interopDefaultLegacy(deepequal);
|
|
113
114
|
var DefaultEmojiIndex__default = /*#__PURE__*/_interopDefaultLegacy(DefaultEmojiIndex);
|
|
115
|
+
var nimbleEmoji__default = /*#__PURE__*/_interopDefaultLegacy(nimbleEmoji);
|
|
116
|
+
var nimblePicker__default = /*#__PURE__*/_interopDefaultLegacy(nimblePicker);
|
|
114
117
|
|
|
115
118
|
/*! *****************************************************************************
|
|
116
119
|
Copyright (c) Microsoft Corporation.
|
|
@@ -1332,6 +1335,718 @@ var withComponentContext = function (Component) {
|
|
|
1332
1335
|
return WithComponentContextComponent;
|
|
1333
1336
|
};
|
|
1334
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
|
+
|
|
1335
2050
|
var isOnlyEmojis = function (text) {
|
|
1336
2051
|
if (!text)
|
|
1337
2052
|
return false;
|
|
@@ -1412,7 +2127,7 @@ var emojiMarkdownPlugin = function () {
|
|
|
1412
2127
|
};
|
|
1413
2128
|
}
|
|
1414
2129
|
var transform = function (markdownAST) {
|
|
1415
|
-
|
|
2130
|
+
findAndReplace(markdownAST, emojiRegex__default['default'](), replace);
|
|
1416
2131
|
return markdownAST;
|
|
1417
2132
|
};
|
|
1418
2133
|
return transform;
|
|
@@ -1439,7 +2154,7 @@ var mentionsMarkdownPlugin = function (mentioned_users) { return function () {
|
|
|
1439
2154
|
return markdownAST;
|
|
1440
2155
|
}
|
|
1441
2156
|
var mentionedUsersRegex = new RegExp(mentioned_usernames.map(function (username) { return "@" + username; }).join('|'), 'g');
|
|
1442
|
-
|
|
2157
|
+
findAndReplace(markdownAST, mentionedUsersRegex, replace);
|
|
1443
2158
|
return markdownAST;
|
|
1444
2159
|
};
|
|
1445
2160
|
return transform;
|
|
@@ -1881,7 +2596,7 @@ var ReactTextareaAutocomplete = /*#__PURE__*/function (_React$Component) {
|
|
|
1881
2596
|
});
|
|
1882
2597
|
|
|
1883
2598
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "_defaultShouldSubmit", function (event) {
|
|
1884
|
-
return event.key === 'Enter' && !event.shiftKey;
|
|
2599
|
+
return event.key === 'Enter' && !event.shiftKey && !event.nativeEvent.isComposing;
|
|
1885
2600
|
});
|
|
1886
2601
|
|
|
1887
2602
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "_handleKeyDown", function (event) {
|
|
@@ -4135,32 +4850,12 @@ var UnMemoizedMessageTextComponent = function (props) {
|
|
|
4135
4850
|
};
|
|
4136
4851
|
var MessageText = React__default['default'].memo(UnMemoizedMessageTextComponent);
|
|
4137
4852
|
|
|
4138
|
-
var DefaultEmoji = React__default['default'].lazy(function () { return
|
|
4139
|
-
|
|
4140
|
-
return __generator(this, function (_a) {
|
|
4141
|
-
switch (_a.label) {
|
|
4142
|
-
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('emoji-mart/dist/components/emoji/nimble-emoji.js')); })];
|
|
4143
|
-
case 1:
|
|
4144
|
-
emoji = _a.sent();
|
|
4145
|
-
return [2 /*return*/, { default: emoji.default }];
|
|
4146
|
-
}
|
|
4147
|
-
});
|
|
4148
|
-
}); });
|
|
4149
|
-
var DefaultEmojiPicker = React__default['default'].lazy(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
4150
|
-
var emojiPicker;
|
|
4151
|
-
return __generator(this, function (_a) {
|
|
4152
|
-
switch (_a.label) {
|
|
4153
|
-
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('emoji-mart/dist/components/picker/nimble-picker.js')); })];
|
|
4154
|
-
case 1:
|
|
4155
|
-
emojiPicker = _a.sent();
|
|
4156
|
-
return [2 /*return*/, { default: emojiPicker.default }];
|
|
4157
|
-
}
|
|
4158
|
-
});
|
|
4159
|
-
}); });
|
|
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; }); });
|
|
4160
4855
|
var EmojiContext = React__default['default'].createContext(undefined);
|
|
4161
4856
|
var EmojiProvider = function (_a) {
|
|
4162
4857
|
var children = _a.children, value = _a.value;
|
|
4163
|
-
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;
|
|
4164
4859
|
var emojiContextValue = {
|
|
4165
4860
|
Emoji: Emoji,
|
|
4166
4861
|
emojiConfig: emojiConfig,
|
|
@@ -4873,8 +5568,9 @@ var useImageUploads = function (props, state, dispatch) {
|
|
|
4873
5568
|
}, []);
|
|
4874
5569
|
var uploadImage = React.useCallback(function (id) { return __awaiter(void 0, void 0, void 0, function () {
|
|
4875
5570
|
var img, file, canUpload, response, error_1, errorMessage, alreadyRemoved;
|
|
4876
|
-
|
|
4877
|
-
|
|
5571
|
+
var _a;
|
|
5572
|
+
return __generator(this, function (_b) {
|
|
5573
|
+
switch (_b.label) {
|
|
4878
5574
|
case 0:
|
|
4879
5575
|
img = imageUploads[id];
|
|
4880
5576
|
if (!img)
|
|
@@ -4891,24 +5587,24 @@ var useImageUploads = function (props, state, dispatch) {
|
|
|
4891
5587
|
uploadType: 'image',
|
|
4892
5588
|
})];
|
|
4893
5589
|
case 1:
|
|
4894
|
-
canUpload =
|
|
5590
|
+
canUpload = _b.sent();
|
|
4895
5591
|
if (!canUpload)
|
|
4896
5592
|
return [2 /*return*/, removeImage(id)];
|
|
4897
|
-
|
|
5593
|
+
_b.label = 2;
|
|
4898
5594
|
case 2:
|
|
4899
|
-
|
|
5595
|
+
_b.trys.push([2, 7, , 8]);
|
|
4900
5596
|
if (!doImageUploadRequest) return [3 /*break*/, 4];
|
|
4901
5597
|
return [4 /*yield*/, doImageUploadRequest(file, channel)];
|
|
4902
5598
|
case 3:
|
|
4903
|
-
response =
|
|
5599
|
+
response = _b.sent();
|
|
4904
5600
|
return [3 /*break*/, 6];
|
|
4905
5601
|
case 4: return [4 /*yield*/, channel.sendImage(file)];
|
|
4906
5602
|
case 5:
|
|
4907
|
-
response =
|
|
4908
|
-
|
|
5603
|
+
response = _b.sent();
|
|
5604
|
+
_b.label = 6;
|
|
4909
5605
|
case 6: return [3 /*break*/, 8];
|
|
4910
5606
|
case 7:
|
|
4911
|
-
error_1 =
|
|
5607
|
+
error_1 = _b.sent();
|
|
4912
5608
|
errorMessage = typeof error_1.message === 'string'
|
|
4913
5609
|
? error_1.message
|
|
4914
5610
|
: t('Error uploading image');
|
|
@@ -4932,8 +5628,11 @@ var useImageUploads = function (props, state, dispatch) {
|
|
|
4932
5628
|
removeImage(id);
|
|
4933
5629
|
return [2 /*return*/];
|
|
4934
5630
|
}
|
|
5631
|
+
if (img.previewUri)
|
|
5632
|
+
(_a = URL.revokeObjectURL) === null || _a === void 0 ? void 0 : _a.call(URL, img.previewUri);
|
|
4935
5633
|
dispatch({
|
|
4936
5634
|
id: id,
|
|
5635
|
+
previewUri: undefined,
|
|
4937
5636
|
state: 'finished',
|
|
4938
5637
|
type: 'setImageUpload',
|
|
4939
5638
|
url: response.file,
|
|
@@ -4943,33 +5642,10 @@ var useImageUploads = function (props, state, dispatch) {
|
|
|
4943
5642
|
});
|
|
4944
5643
|
}); }, [imageUploads, channel, doImageUploadRequest, errorHandler, removeImage]);
|
|
4945
5644
|
React.useEffect(function () {
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
if (upload) {
|
|
4951
|
-
var file = upload.file, id_1 = upload.id;
|
|
4952
|
-
// TODO: Possibly use URL.createObjectURL instead. However, then we need
|
|
4953
|
-
// to release the previews when not used anymore though.
|
|
4954
|
-
var reader_1 = new FileReader();
|
|
4955
|
-
reader_1.onload = function (event) {
|
|
4956
|
-
var _a;
|
|
4957
|
-
if (typeof ((_a = event.target) === null || _a === void 0 ? void 0 : _a.result) !== 'string')
|
|
4958
|
-
return;
|
|
4959
|
-
dispatch({
|
|
4960
|
-
id: id_1,
|
|
4961
|
-
previewUri: event.target.result,
|
|
4962
|
-
type: 'setImageUpload',
|
|
4963
|
-
});
|
|
4964
|
-
};
|
|
4965
|
-
reader_1.readAsDataURL(file);
|
|
4966
|
-
uploadImage(id_1);
|
|
4967
|
-
return function () {
|
|
4968
|
-
reader_1.onload = null;
|
|
4969
|
-
};
|
|
4970
|
-
}
|
|
4971
|
-
}
|
|
4972
|
-
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);
|
|
4973
5649
|
}, [imageUploads, uploadImage]);
|
|
4974
5650
|
return {
|
|
4975
5651
|
removeImage: removeImage,
|
|
@@ -5093,11 +5769,18 @@ var useAttachments = function (props, state, dispatch, textareaRef) {
|
|
|
5093
5769
|
Array.from(files)
|
|
5094
5770
|
.slice(0, maxFilesLeft)
|
|
5095
5771
|
.forEach(function (file) {
|
|
5772
|
+
var _a;
|
|
5096
5773
|
var id = nanoid.nanoid();
|
|
5097
5774
|
if (file.type.startsWith('image/') &&
|
|
5098
5775
|
!file.type.endsWith('.photoshop') // photoshop files begin with 'image/'
|
|
5099
5776
|
) {
|
|
5100
|
-
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
|
+
});
|
|
5101
5784
|
}
|
|
5102
5785
|
else if (file instanceof File && !noFiles) {
|
|
5103
5786
|
dispatch({ file: file, id: id, state: 'uploading', type: 'setFileUpload' });
|
|
@@ -6199,7 +6882,6 @@ var makeAddNotifications = function (setNotifications, notificationTimeouts) { r
|
|
|
6199
6882
|
notificationTimeouts.push(timeout);
|
|
6200
6883
|
}; };
|
|
6201
6884
|
|
|
6202
|
-
var JUMP_MESSAGE_PAGE_SIZE = 25;
|
|
6203
6885
|
var UnMemoizedChannel = function (props) {
|
|
6204
6886
|
var propsChannel = props.channel, _a = props.EmptyPlaceholder, EmptyPlaceholder = _a === void 0 ? null : _a, LoadingErrorIndicator = props.LoadingErrorIndicator, LoadingIndicator = props.LoadingIndicator;
|
|
6205
6887
|
var _b = useChatContext('Channel'), contextChannel = _b.channel, channelsQueryState = _b.channelsQueryState;
|
|
@@ -6469,30 +7151,38 @@ var ChannelInner = function (props) {
|
|
|
6469
7151
|
});
|
|
6470
7152
|
});
|
|
6471
7153
|
};
|
|
6472
|
-
var
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
7154
|
+
var clearHighlightedMessageTimeoutId = React.useRef(null);
|
|
7155
|
+
var jumpToMessage = function (messageId, messageLimit) {
|
|
7156
|
+
if (messageLimit === void 0) { messageLimit = 100; }
|
|
7157
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
7158
|
+
var indexOfMessage, hasMoreMessages;
|
|
7159
|
+
return __generator(this, function (_a) {
|
|
7160
|
+
switch (_a.label) {
|
|
7161
|
+
case 0:
|
|
7162
|
+
dispatch({ loadingMore: true, type: 'setLoadingMore' });
|
|
7163
|
+
return [4 /*yield*/, channel.state.loadMessageIntoState(messageId, undefined, messageLimit)];
|
|
7164
|
+
case 1:
|
|
7165
|
+
_a.sent();
|
|
7166
|
+
indexOfMessage = channel.state.messages.findIndex(function (message) { return message.id === messageId; });
|
|
7167
|
+
hasMoreMessages = indexOfMessage >= Math.floor(messageLimit / 2);
|
|
7168
|
+
loadMoreFinished(hasMoreMessages, channel.state.messages);
|
|
7169
|
+
dispatch({
|
|
7170
|
+
hasMoreNewer: channel.state.messages !== channel.state.latestMessages,
|
|
7171
|
+
highlightedMessageId: messageId,
|
|
7172
|
+
type: 'jumpToMessageFinished',
|
|
7173
|
+
});
|
|
7174
|
+
if (clearHighlightedMessageTimeoutId.current) {
|
|
7175
|
+
clearTimeout(clearHighlightedMessageTimeoutId.current);
|
|
7176
|
+
}
|
|
7177
|
+
clearHighlightedMessageTimeoutId.current = setTimeout(function () {
|
|
7178
|
+
clearHighlightedMessageTimeoutId.current = null;
|
|
7179
|
+
dispatch({ type: 'clearHighlightedMessage' });
|
|
7180
|
+
}, 500);
|
|
7181
|
+
return [2 /*return*/];
|
|
7182
|
+
}
|
|
7183
|
+
});
|
|
6494
7184
|
});
|
|
6495
|
-
}
|
|
7185
|
+
};
|
|
6496
7186
|
var jumpToLatestMessage = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
6497
7187
|
var hasMoreOlder;
|
|
6498
7188
|
return __generator(this, function (_a) {
|
|
@@ -7706,7 +8396,7 @@ var UnMemoizedChannelList = function (props) {
|
|
|
7706
8396
|
*/
|
|
7707
8397
|
var ChannelList = React__default['default'].memo(UnMemoizedChannelList);
|
|
7708
8398
|
|
|
7709
|
-
var version = '9.
|
|
8399
|
+
var version = '9.5.1';
|
|
7710
8400
|
|
|
7711
8401
|
var useChat = function (_a) {
|
|
7712
8402
|
var _b, _c;
|
|
@@ -9505,6 +10195,20 @@ var UnMemoizedWindow = function (props) {
|
|
|
9505
10195
|
*/
|
|
9506
10196
|
var Window = React__default['default'].memo(UnMemoizedWindow);
|
|
9507
10197
|
|
|
10198
|
+
// @ts-expect-error
|
|
10199
|
+
|
|
10200
|
+
var DefaultEmoji = /*#__PURE__*/Object.freeze({
|
|
10201
|
+
__proto__: null,
|
|
10202
|
+
'default': nimbleEmoji__default['default']
|
|
10203
|
+
});
|
|
10204
|
+
|
|
10205
|
+
// @ts-expect-error
|
|
10206
|
+
|
|
10207
|
+
var DefaultEmojiPicker = /*#__PURE__*/Object.freeze({
|
|
10208
|
+
__proto__: null,
|
|
10209
|
+
'default': nimblePicker__default['default']
|
|
10210
|
+
});
|
|
10211
|
+
|
|
9508
10212
|
exports.ActionsIcon = ActionsIcon;
|
|
9509
10213
|
exports.Attachment = Attachment;
|
|
9510
10214
|
exports.AttachmentActions = AttachmentActions;
|