artalk 2.8.7 → 2.9.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/Artalk.cjs +2 -2
- package/dist/Artalk.cjs.map +1 -1
- package/dist/Artalk.css +1 -1
- package/dist/Artalk.iife.js +2 -2
- package/dist/Artalk.iife.js.map +1 -1
- package/dist/Artalk.js +2 -2
- package/dist/Artalk.js.map +1 -1
- package/dist/Artalk.mjs +604 -1111
- package/dist/Artalk.mjs.map +1 -1
- package/dist/ArtalkLite.cjs +2 -2
- package/dist/ArtalkLite.cjs.map +1 -1
- package/dist/ArtalkLite.css +1 -1
- package/dist/ArtalkLite.iife.js +2 -2
- package/dist/ArtalkLite.iife.js.map +1 -1
- package/dist/ArtalkLite.js +2 -2
- package/dist/ArtalkLite.js.map +1 -1
- package/dist/ArtalkLite.mjs +320 -866
- package/dist/ArtalkLite.mjs.map +1 -1
- package/dist/i18n/fr.cjs +1 -0
- package/dist/i18n/fr.js +1 -0
- package/dist/i18n/fr.mjs +123 -0
- package/dist/i18n/{jp.cjs → ja.cjs} +1 -1
- package/dist/i18n/ja.d.cts +3 -0
- package/dist/i18n/ja.d.ts +3 -0
- package/dist/i18n/{jp.js → ja.js} +1 -1
- package/dist/i18n/{jp.mjs → ja.mjs} +12 -9
- package/dist/i18n/ko.cjs +1 -0
- package/dist/i18n/ko.d.cts +3 -0
- package/dist/i18n/ko.d.ts +3 -0
- package/dist/i18n/ko.js +1 -0
- package/dist/i18n/ko.mjs +123 -0
- package/dist/i18n/ru.cjs +1 -0
- package/dist/i18n/ru.d.cts +3 -0
- package/dist/i18n/ru.d.ts +3 -0
- package/dist/i18n/ru.js +1 -0
- package/dist/i18n/ru.mjs +123 -0
- package/dist/i18n/zh-TW.cjs +1 -1
- package/dist/i18n/zh-TW.js +1 -1
- package/dist/i18n/zh-TW.mjs +6 -3
- package/dist/main.d.cts +146 -85
- package/dist/main.d.ts +146 -85
- package/package.json +49 -15
- /package/dist/i18n/{jp.d.cts → fr.d.cts} +0 -0
- /package/dist/i18n/{jp.d.ts → fr.d.ts} +0 -0
package/dist/Artalk.mjs
CHANGED
|
@@ -29,23 +29,7 @@ var __objRest = (source, exclude) => {
|
|
|
29
29
|
}
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
|
-
var __publicField = (obj, key, value) =>
|
|
33
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
|
-
return value;
|
|
35
|
-
};
|
|
36
|
-
var __accessCheck = (obj, member, msg) => {
|
|
37
|
-
if (!member.has(obj))
|
|
38
|
-
throw TypeError("Cannot " + msg);
|
|
39
|
-
};
|
|
40
|
-
var __privateAdd = (obj, member, value) => {
|
|
41
|
-
if (member.has(obj))
|
|
42
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
43
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
44
|
-
};
|
|
45
|
-
var __privateMethod = (obj, member, method) => {
|
|
46
|
-
__accessCheck(obj, member, "access private method");
|
|
47
|
-
return method;
|
|
48
|
-
};
|
|
32
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
49
33
|
var __async = (__this, __arguments, generator) => {
|
|
50
34
|
return new Promise((resolve, reject) => {
|
|
51
35
|
var fulfilled = (value) => {
|
|
@@ -66,7 +50,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
66
50
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
67
51
|
});
|
|
68
52
|
};
|
|
69
|
-
var _parseMarkdown, parseMarkdown_fn, _onError, onError_fn;
|
|
70
53
|
class HttpClient {
|
|
71
54
|
constructor(apiConfig = {}) {
|
|
72
55
|
__publicField(this, "baseUrl", "/api/v2");
|
|
@@ -163,7 +146,7 @@ class HttpClient {
|
|
|
163
146
|
body: typeof body === "undefined" || body === null ? null : payloadFormatter(body)
|
|
164
147
|
})
|
|
165
148
|
).then((response) => __async(this, null, function* () {
|
|
166
|
-
const r = response;
|
|
149
|
+
const r = response.clone();
|
|
167
150
|
r.data = null;
|
|
168
151
|
r.error = null;
|
|
169
152
|
const data = !responseFormat ? r : yield response[responseFormat]().then((data2) => {
|
|
@@ -180,8 +163,7 @@ class HttpClient {
|
|
|
180
163
|
if (cancelToken) {
|
|
181
164
|
this.abortControllers.delete(cancelToken);
|
|
182
165
|
}
|
|
183
|
-
if (!response.ok)
|
|
184
|
-
throw data;
|
|
166
|
+
if (!response.ok) throw data;
|
|
185
167
|
return data;
|
|
186
168
|
}));
|
|
187
169
|
}));
|
|
@@ -253,7 +235,7 @@ let Api$1 = class Api extends HttpClient {
|
|
|
253
235
|
format: "json"
|
|
254
236
|
}, params)),
|
|
255
237
|
/**
|
|
256
|
-
* @description Register by email and verify code (if user exists, will update user, like forget password. Need send email verify code first)
|
|
238
|
+
* @description Register by email and verify code (if user exists, will update user, like forget or change password. Need send email verify code first)
|
|
257
239
|
*
|
|
258
240
|
* @tags Auth
|
|
259
241
|
* @name RegisterByEmail
|
|
@@ -1232,6 +1214,32 @@ let Api$1 = class Api extends HttpClient {
|
|
|
1232
1214
|
secure: true,
|
|
1233
1215
|
format: "json"
|
|
1234
1216
|
}, params)),
|
|
1217
|
+
/**
|
|
1218
|
+
* @description Update user profile when user is logged in
|
|
1219
|
+
*
|
|
1220
|
+
* @tags Auth
|
|
1221
|
+
* @name UpdateProfile
|
|
1222
|
+
* @summary Update user profile
|
|
1223
|
+
* @request POST:/user
|
|
1224
|
+
* @secure
|
|
1225
|
+
* @response `200` `HandlerResponseUserInfoUpdate` OK
|
|
1226
|
+
* @response `400` `(HandlerMap & {
|
|
1227
|
+
msg?: string,
|
|
1228
|
+
|
|
1229
|
+
})` Bad Request
|
|
1230
|
+
* @response `500` `(HandlerMap & {
|
|
1231
|
+
msg?: string,
|
|
1232
|
+
|
|
1233
|
+
})` Internal Server Error
|
|
1234
|
+
*/
|
|
1235
|
+
updateProfile: (data, params = {}) => this.request(__spreadValues({
|
|
1236
|
+
path: `/user`,
|
|
1237
|
+
method: "POST",
|
|
1238
|
+
body: data,
|
|
1239
|
+
secure: true,
|
|
1240
|
+
type: "application/json",
|
|
1241
|
+
format: "json"
|
|
1242
|
+
}, params)),
|
|
1235
1243
|
/**
|
|
1236
1244
|
* @description Login user by name or email
|
|
1237
1245
|
*
|
|
@@ -1466,411 +1474,12 @@ let Api$1 = class Api extends HttpClient {
|
|
|
1466
1474
|
});
|
|
1467
1475
|
}
|
|
1468
1476
|
};
|
|
1469
|
-
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
1470
|
-
function getDefaultExportFromCjs(x) {
|
|
1471
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
1472
|
-
}
|
|
1473
|
-
(function(factory) {
|
|
1474
|
-
factory();
|
|
1475
|
-
})(function() {
|
|
1476
|
-
function _classCallCheck(instance2, Constructor) {
|
|
1477
|
-
if (!(instance2 instanceof Constructor)) {
|
|
1478
|
-
throw new TypeError("Cannot call a class as a function");
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
function _defineProperties(target, props) {
|
|
1482
|
-
for (var i = 0; i < props.length; i++) {
|
|
1483
|
-
var descriptor = props[i];
|
|
1484
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
1485
|
-
descriptor.configurable = true;
|
|
1486
|
-
if ("value" in descriptor)
|
|
1487
|
-
descriptor.writable = true;
|
|
1488
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1489
|
-
}
|
|
1490
|
-
}
|
|
1491
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
1492
|
-
if (protoProps)
|
|
1493
|
-
_defineProperties(Constructor.prototype, protoProps);
|
|
1494
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
1495
|
-
writable: false
|
|
1496
|
-
});
|
|
1497
|
-
return Constructor;
|
|
1498
|
-
}
|
|
1499
|
-
function _inherits(subClass, superClass) {
|
|
1500
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
1501
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
1502
|
-
}
|
|
1503
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
1504
|
-
constructor: {
|
|
1505
|
-
value: subClass,
|
|
1506
|
-
writable: true,
|
|
1507
|
-
configurable: true
|
|
1508
|
-
}
|
|
1509
|
-
});
|
|
1510
|
-
Object.defineProperty(subClass, "prototype", {
|
|
1511
|
-
writable: false
|
|
1512
|
-
});
|
|
1513
|
-
if (superClass)
|
|
1514
|
-
_setPrototypeOf(subClass, superClass);
|
|
1515
|
-
}
|
|
1516
|
-
function _getPrototypeOf(o) {
|
|
1517
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
|
|
1518
|
-
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
1519
|
-
};
|
|
1520
|
-
return _getPrototypeOf(o);
|
|
1521
|
-
}
|
|
1522
|
-
function _setPrototypeOf(o, p) {
|
|
1523
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
|
|
1524
|
-
o2.__proto__ = p2;
|
|
1525
|
-
return o2;
|
|
1526
|
-
};
|
|
1527
|
-
return _setPrototypeOf(o, p);
|
|
1528
|
-
}
|
|
1529
|
-
function _isNativeReflectConstruct() {
|
|
1530
|
-
if (typeof Reflect === "undefined" || !Reflect.construct)
|
|
1531
|
-
return false;
|
|
1532
|
-
if (Reflect.construct.sham)
|
|
1533
|
-
return false;
|
|
1534
|
-
if (typeof Proxy === "function")
|
|
1535
|
-
return true;
|
|
1536
|
-
try {
|
|
1537
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
1538
|
-
}));
|
|
1539
|
-
return true;
|
|
1540
|
-
} catch (e) {
|
|
1541
|
-
return false;
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
function _assertThisInitialized(self2) {
|
|
1545
|
-
if (self2 === void 0) {
|
|
1546
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
1547
|
-
}
|
|
1548
|
-
return self2;
|
|
1549
|
-
}
|
|
1550
|
-
function _possibleConstructorReturn(self2, call) {
|
|
1551
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
1552
|
-
return call;
|
|
1553
|
-
} else if (call !== void 0) {
|
|
1554
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
1555
|
-
}
|
|
1556
|
-
return _assertThisInitialized(self2);
|
|
1557
|
-
}
|
|
1558
|
-
function _createSuper(Derived) {
|
|
1559
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
1560
|
-
return function _createSuperInternal() {
|
|
1561
|
-
var Super = _getPrototypeOf(Derived), result;
|
|
1562
|
-
if (hasNativeReflectConstruct) {
|
|
1563
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
1564
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
1565
|
-
} else {
|
|
1566
|
-
result = Super.apply(this, arguments);
|
|
1567
|
-
}
|
|
1568
|
-
return _possibleConstructorReturn(this, result);
|
|
1569
|
-
};
|
|
1570
|
-
}
|
|
1571
|
-
function _superPropBase(object, property) {
|
|
1572
|
-
while (!Object.prototype.hasOwnProperty.call(object, property)) {
|
|
1573
|
-
object = _getPrototypeOf(object);
|
|
1574
|
-
if (object === null)
|
|
1575
|
-
break;
|
|
1576
|
-
}
|
|
1577
|
-
return object;
|
|
1578
|
-
}
|
|
1579
|
-
function _get() {
|
|
1580
|
-
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
1581
|
-
_get = Reflect.get.bind();
|
|
1582
|
-
} else {
|
|
1583
|
-
_get = function _get2(target, property, receiver) {
|
|
1584
|
-
var base = _superPropBase(target, property);
|
|
1585
|
-
if (!base)
|
|
1586
|
-
return;
|
|
1587
|
-
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
1588
|
-
if (desc.get) {
|
|
1589
|
-
return desc.get.call(arguments.length < 3 ? target : receiver);
|
|
1590
|
-
}
|
|
1591
|
-
return desc.value;
|
|
1592
|
-
};
|
|
1593
|
-
}
|
|
1594
|
-
return _get.apply(this, arguments);
|
|
1595
|
-
}
|
|
1596
|
-
var Emitter = /* @__PURE__ */ function() {
|
|
1597
|
-
function Emitter2() {
|
|
1598
|
-
_classCallCheck(this, Emitter2);
|
|
1599
|
-
Object.defineProperty(this, "listeners", {
|
|
1600
|
-
value: {},
|
|
1601
|
-
writable: true,
|
|
1602
|
-
configurable: true
|
|
1603
|
-
});
|
|
1604
|
-
}
|
|
1605
|
-
_createClass(Emitter2, [{
|
|
1606
|
-
key: "addEventListener",
|
|
1607
|
-
value: function addEventListener(type, callback, options) {
|
|
1608
|
-
if (!(type in this.listeners)) {
|
|
1609
|
-
this.listeners[type] = [];
|
|
1610
|
-
}
|
|
1611
|
-
this.listeners[type].push({
|
|
1612
|
-
callback,
|
|
1613
|
-
options
|
|
1614
|
-
});
|
|
1615
|
-
}
|
|
1616
|
-
}, {
|
|
1617
|
-
key: "removeEventListener",
|
|
1618
|
-
value: function removeEventListener(type, callback) {
|
|
1619
|
-
if (!(type in this.listeners)) {
|
|
1620
|
-
return;
|
|
1621
|
-
}
|
|
1622
|
-
var stack = this.listeners[type];
|
|
1623
|
-
for (var i = 0, l = stack.length; i < l; i++) {
|
|
1624
|
-
if (stack[i].callback === callback) {
|
|
1625
|
-
stack.splice(i, 1);
|
|
1626
|
-
return;
|
|
1627
|
-
}
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
}, {
|
|
1631
|
-
key: "dispatchEvent",
|
|
1632
|
-
value: function dispatchEvent(event) {
|
|
1633
|
-
if (!(event.type in this.listeners)) {
|
|
1634
|
-
return;
|
|
1635
|
-
}
|
|
1636
|
-
var stack = this.listeners[event.type];
|
|
1637
|
-
var stackToCall = stack.slice();
|
|
1638
|
-
for (var i = 0, l = stackToCall.length; i < l; i++) {
|
|
1639
|
-
var listener = stackToCall[i];
|
|
1640
|
-
try {
|
|
1641
|
-
listener.callback.call(this, event);
|
|
1642
|
-
} catch (e) {
|
|
1643
|
-
Promise.resolve().then(function() {
|
|
1644
|
-
throw e;
|
|
1645
|
-
});
|
|
1646
|
-
}
|
|
1647
|
-
if (listener.options && listener.options.once) {
|
|
1648
|
-
this.removeEventListener(event.type, listener.callback);
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
return !event.defaultPrevented;
|
|
1652
|
-
}
|
|
1653
|
-
}]);
|
|
1654
|
-
return Emitter2;
|
|
1655
|
-
}();
|
|
1656
|
-
var AbortSignal = /* @__PURE__ */ function(_Emitter) {
|
|
1657
|
-
_inherits(AbortSignal2, _Emitter);
|
|
1658
|
-
var _super = _createSuper(AbortSignal2);
|
|
1659
|
-
function AbortSignal2() {
|
|
1660
|
-
var _this;
|
|
1661
|
-
_classCallCheck(this, AbortSignal2);
|
|
1662
|
-
_this = _super.call(this);
|
|
1663
|
-
if (!_this.listeners) {
|
|
1664
|
-
Emitter.call(_assertThisInitialized(_this));
|
|
1665
|
-
}
|
|
1666
|
-
Object.defineProperty(_assertThisInitialized(_this), "aborted", {
|
|
1667
|
-
value: false,
|
|
1668
|
-
writable: true,
|
|
1669
|
-
configurable: true
|
|
1670
|
-
});
|
|
1671
|
-
Object.defineProperty(_assertThisInitialized(_this), "onabort", {
|
|
1672
|
-
value: null,
|
|
1673
|
-
writable: true,
|
|
1674
|
-
configurable: true
|
|
1675
|
-
});
|
|
1676
|
-
Object.defineProperty(_assertThisInitialized(_this), "reason", {
|
|
1677
|
-
value: void 0,
|
|
1678
|
-
writable: true,
|
|
1679
|
-
configurable: true
|
|
1680
|
-
});
|
|
1681
|
-
return _this;
|
|
1682
|
-
}
|
|
1683
|
-
_createClass(AbortSignal2, [{
|
|
1684
|
-
key: "toString",
|
|
1685
|
-
value: function toString() {
|
|
1686
|
-
return "[object AbortSignal]";
|
|
1687
|
-
}
|
|
1688
|
-
}, {
|
|
1689
|
-
key: "dispatchEvent",
|
|
1690
|
-
value: function dispatchEvent(event) {
|
|
1691
|
-
if (event.type === "abort") {
|
|
1692
|
-
this.aborted = true;
|
|
1693
|
-
if (typeof this.onabort === "function") {
|
|
1694
|
-
this.onabort.call(this, event);
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
_get(_getPrototypeOf(AbortSignal2.prototype), "dispatchEvent", this).call(this, event);
|
|
1698
|
-
}
|
|
1699
|
-
}]);
|
|
1700
|
-
return AbortSignal2;
|
|
1701
|
-
}(Emitter);
|
|
1702
|
-
var AbortController2 = /* @__PURE__ */ function() {
|
|
1703
|
-
function AbortController3() {
|
|
1704
|
-
_classCallCheck(this, AbortController3);
|
|
1705
|
-
Object.defineProperty(this, "signal", {
|
|
1706
|
-
value: new AbortSignal(),
|
|
1707
|
-
writable: true,
|
|
1708
|
-
configurable: true
|
|
1709
|
-
});
|
|
1710
|
-
}
|
|
1711
|
-
_createClass(AbortController3, [{
|
|
1712
|
-
key: "abort",
|
|
1713
|
-
value: function abort(reason) {
|
|
1714
|
-
var event;
|
|
1715
|
-
try {
|
|
1716
|
-
event = new Event("abort");
|
|
1717
|
-
} catch (e) {
|
|
1718
|
-
if (typeof document !== "undefined") {
|
|
1719
|
-
if (!document.createEvent) {
|
|
1720
|
-
event = document.createEventObject();
|
|
1721
|
-
event.type = "abort";
|
|
1722
|
-
} else {
|
|
1723
|
-
event = document.createEvent("Event");
|
|
1724
|
-
event.initEvent("abort", false, false);
|
|
1725
|
-
}
|
|
1726
|
-
} else {
|
|
1727
|
-
event = {
|
|
1728
|
-
type: "abort",
|
|
1729
|
-
bubbles: false,
|
|
1730
|
-
cancelable: false
|
|
1731
|
-
};
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
var signalReason = reason;
|
|
1735
|
-
if (signalReason === void 0) {
|
|
1736
|
-
if (typeof document === "undefined") {
|
|
1737
|
-
signalReason = new Error("This operation was aborted");
|
|
1738
|
-
signalReason.name = "AbortError";
|
|
1739
|
-
} else {
|
|
1740
|
-
try {
|
|
1741
|
-
signalReason = new DOMException("signal is aborted without reason");
|
|
1742
|
-
} catch (err) {
|
|
1743
|
-
signalReason = new Error("This operation was aborted");
|
|
1744
|
-
signalReason.name = "AbortError";
|
|
1745
|
-
}
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
this.signal.reason = signalReason;
|
|
1749
|
-
this.signal.dispatchEvent(event);
|
|
1750
|
-
}
|
|
1751
|
-
}, {
|
|
1752
|
-
key: "toString",
|
|
1753
|
-
value: function toString() {
|
|
1754
|
-
return "[object AbortController]";
|
|
1755
|
-
}
|
|
1756
|
-
}]);
|
|
1757
|
-
return AbortController3;
|
|
1758
|
-
}();
|
|
1759
|
-
if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
|
|
1760
|
-
AbortController2.prototype[Symbol.toStringTag] = "AbortController";
|
|
1761
|
-
AbortSignal.prototype[Symbol.toStringTag] = "AbortSignal";
|
|
1762
|
-
}
|
|
1763
|
-
function polyfillNeeded(self2) {
|
|
1764
|
-
if (self2.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {
|
|
1765
|
-
console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill");
|
|
1766
|
-
return true;
|
|
1767
|
-
}
|
|
1768
|
-
return typeof self2.Request === "function" && !self2.Request.prototype.hasOwnProperty("signal") || !self2.AbortController;
|
|
1769
|
-
}
|
|
1770
|
-
function abortableFetchDecorator(patchTargets) {
|
|
1771
|
-
if ("function" === typeof patchTargets) {
|
|
1772
|
-
patchTargets = {
|
|
1773
|
-
fetch: patchTargets
|
|
1774
|
-
};
|
|
1775
|
-
}
|
|
1776
|
-
var _patchTargets = patchTargets, fetch2 = _patchTargets.fetch, _patchTargets$Request = _patchTargets.Request, NativeRequest = _patchTargets$Request === void 0 ? fetch2.Request : _patchTargets$Request, NativeAbortController = _patchTargets.AbortController, _patchTargets$__FORCE = _patchTargets.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL, __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL = _patchTargets$__FORCE === void 0 ? false : _patchTargets$__FORCE;
|
|
1777
|
-
if (!polyfillNeeded({
|
|
1778
|
-
fetch: fetch2,
|
|
1779
|
-
Request: NativeRequest,
|
|
1780
|
-
AbortController: NativeAbortController,
|
|
1781
|
-
__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL
|
|
1782
|
-
})) {
|
|
1783
|
-
return {
|
|
1784
|
-
fetch: fetch2,
|
|
1785
|
-
Request
|
|
1786
|
-
};
|
|
1787
|
-
}
|
|
1788
|
-
var Request = NativeRequest;
|
|
1789
|
-
if (Request && !Request.prototype.hasOwnProperty("signal") || __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {
|
|
1790
|
-
Request = function Request2(input, init2) {
|
|
1791
|
-
var signal;
|
|
1792
|
-
if (init2 && init2.signal) {
|
|
1793
|
-
signal = init2.signal;
|
|
1794
|
-
delete init2.signal;
|
|
1795
|
-
}
|
|
1796
|
-
var request = new NativeRequest(input, init2);
|
|
1797
|
-
if (signal) {
|
|
1798
|
-
Object.defineProperty(request, "signal", {
|
|
1799
|
-
writable: false,
|
|
1800
|
-
enumerable: false,
|
|
1801
|
-
configurable: true,
|
|
1802
|
-
value: signal
|
|
1803
|
-
});
|
|
1804
|
-
}
|
|
1805
|
-
return request;
|
|
1806
|
-
};
|
|
1807
|
-
Request.prototype = NativeRequest.prototype;
|
|
1808
|
-
}
|
|
1809
|
-
var realFetch = fetch2;
|
|
1810
|
-
var abortableFetch = function abortableFetch2(input, init2) {
|
|
1811
|
-
var signal = Request && Request.prototype.isPrototypeOf(input) ? input.signal : init2 ? init2.signal : void 0;
|
|
1812
|
-
if (signal) {
|
|
1813
|
-
var abortError;
|
|
1814
|
-
try {
|
|
1815
|
-
abortError = new DOMException("Aborted", "AbortError");
|
|
1816
|
-
} catch (err) {
|
|
1817
|
-
abortError = new Error("Aborted");
|
|
1818
|
-
abortError.name = "AbortError";
|
|
1819
|
-
}
|
|
1820
|
-
if (signal.aborted) {
|
|
1821
|
-
return Promise.reject(abortError);
|
|
1822
|
-
}
|
|
1823
|
-
var cancellation = new Promise(function(_, reject) {
|
|
1824
|
-
signal.addEventListener("abort", function() {
|
|
1825
|
-
return reject(abortError);
|
|
1826
|
-
}, {
|
|
1827
|
-
once: true
|
|
1828
|
-
});
|
|
1829
|
-
});
|
|
1830
|
-
if (init2 && init2.signal) {
|
|
1831
|
-
delete init2.signal;
|
|
1832
|
-
}
|
|
1833
|
-
return Promise.race([cancellation, realFetch(input, init2)]);
|
|
1834
|
-
}
|
|
1835
|
-
return realFetch(input, init2);
|
|
1836
|
-
};
|
|
1837
|
-
return {
|
|
1838
|
-
fetch: abortableFetch,
|
|
1839
|
-
Request
|
|
1840
|
-
};
|
|
1841
|
-
}
|
|
1842
|
-
(function(self2) {
|
|
1843
|
-
if (!polyfillNeeded(self2)) {
|
|
1844
|
-
return;
|
|
1845
|
-
}
|
|
1846
|
-
if (!self2.fetch) {
|
|
1847
|
-
console.warn("fetch() is not available, cannot install abortcontroller-polyfill");
|
|
1848
|
-
return;
|
|
1849
|
-
}
|
|
1850
|
-
var _abortableFetch = abortableFetchDecorator(self2), fetch2 = _abortableFetch.fetch, Request = _abortableFetch.Request;
|
|
1851
|
-
self2.fetch = fetch2;
|
|
1852
|
-
self2.Request = Request;
|
|
1853
|
-
Object.defineProperty(self2, "AbortController", {
|
|
1854
|
-
writable: true,
|
|
1855
|
-
enumerable: false,
|
|
1856
|
-
configurable: true,
|
|
1857
|
-
value: AbortController2
|
|
1858
|
-
});
|
|
1859
|
-
Object.defineProperty(self2, "AbortSignal", {
|
|
1860
|
-
writable: true,
|
|
1861
|
-
enumerable: false,
|
|
1862
|
-
configurable: true,
|
|
1863
|
-
value: AbortSignal
|
|
1864
|
-
});
|
|
1865
|
-
})(typeof self !== "undefined" ? self : commonjsGlobal);
|
|
1866
|
-
});
|
|
1867
1477
|
const Fetch$1 = (opts, input, init2) => __async(void 0, null, function* () {
|
|
1868
1478
|
const apiToken = opts.getApiToken && opts.getApiToken();
|
|
1869
1479
|
const headers = new Headers(__spreadValues({
|
|
1870
1480
|
Authorization: apiToken ? `Bearer ${apiToken}` : ""
|
|
1871
1481
|
}, init2 == null ? void 0 : init2.headers));
|
|
1872
|
-
if (!headers.get("Authorization"))
|
|
1873
|
-
headers.delete("Authorization");
|
|
1482
|
+
if (!headers.get("Authorization")) headers.delete("Authorization");
|
|
1874
1483
|
const resp = yield fetch(input, __spreadProps(__spreadValues({}, init2), {
|
|
1875
1484
|
headers
|
|
1876
1485
|
}));
|
|
@@ -1885,8 +1494,7 @@ const Fetch$1 = (opts, input, init2) => __async(void 0, null, function* () {
|
|
|
1885
1494
|
retry = true;
|
|
1886
1495
|
}
|
|
1887
1496
|
}), Promise.resolve()));
|
|
1888
|
-
if (retry)
|
|
1889
|
-
return Fetch$1(opts, input, init2);
|
|
1497
|
+
if (retry) return Fetch$1(opts, input, init2);
|
|
1890
1498
|
throw createError(resp.status, json);
|
|
1891
1499
|
}
|
|
1892
1500
|
return resp;
|
|
@@ -1913,6 +1521,10 @@ function createApiHandlers() {
|
|
|
1913
1521
|
add: (action, handler) => {
|
|
1914
1522
|
handlers.push({ action, handler });
|
|
1915
1523
|
},
|
|
1524
|
+
remove: (action) => {
|
|
1525
|
+
const index = handlers.findIndex((h) => h.action === action);
|
|
1526
|
+
if (index !== -1) handlers.splice(index, 1);
|
|
1527
|
+
},
|
|
1916
1528
|
get: () => handlers
|
|
1917
1529
|
};
|
|
1918
1530
|
}
|
|
@@ -1932,8 +1544,7 @@ class Api2 extends Api$1 {
|
|
|
1932
1544
|
*/
|
|
1933
1545
|
getUserFields() {
|
|
1934
1546
|
const user = this._opts.userInfo;
|
|
1935
|
-
if (!(user == null ? void 0 : user.name) || !(user == null ? void 0 : user.email))
|
|
1936
|
-
return void 0;
|
|
1547
|
+
if (!(user == null ? void 0 : user.name) || !(user == null ? void 0 : user.email)) return void 0;
|
|
1937
1548
|
return { name: user.name, email: user.email };
|
|
1938
1549
|
}
|
|
1939
1550
|
}
|
|
@@ -1979,18 +1590,6 @@ function escape$1(html2, encode) {
|
|
|
1979
1590
|
}
|
|
1980
1591
|
return html2;
|
|
1981
1592
|
}
|
|
1982
|
-
const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
1983
|
-
function unescape(html2) {
|
|
1984
|
-
return html2.replace(unescapeTest, (_, n) => {
|
|
1985
|
-
n = n.toLowerCase();
|
|
1986
|
-
if (n === "colon")
|
|
1987
|
-
return ":";
|
|
1988
|
-
if (n.charAt(0) === "#") {
|
|
1989
|
-
return n.charAt(1) === "x" ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
|
|
1990
|
-
}
|
|
1991
|
-
return "";
|
|
1992
|
-
});
|
|
1993
|
-
}
|
|
1994
1593
|
const caret = /(^|[^\[])\^/g;
|
|
1995
1594
|
function edit(regex, opt) {
|
|
1996
1595
|
let source = typeof regex === "string" ? regex : regex.source;
|
|
@@ -2198,22 +1797,70 @@ class _Tokenizer {
|
|
|
2198
1797
|
if (cap) {
|
|
2199
1798
|
return {
|
|
2200
1799
|
type: "hr",
|
|
2201
|
-
raw: cap[0]
|
|
1800
|
+
raw: rtrim(cap[0], "\n")
|
|
2202
1801
|
};
|
|
2203
1802
|
}
|
|
2204
1803
|
}
|
|
2205
1804
|
blockquote(src) {
|
|
2206
1805
|
const cap = this.rules.block.blockquote.exec(src);
|
|
2207
1806
|
if (cap) {
|
|
2208
|
-
let
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
1807
|
+
let lines = rtrim(cap[0], "\n").split("\n");
|
|
1808
|
+
let raw = "";
|
|
1809
|
+
let text = "";
|
|
1810
|
+
const tokens = [];
|
|
1811
|
+
while (lines.length > 0) {
|
|
1812
|
+
let inBlockquote = false;
|
|
1813
|
+
const currentLines = [];
|
|
1814
|
+
let i;
|
|
1815
|
+
for (i = 0; i < lines.length; i++) {
|
|
1816
|
+
if (/^ {0,3}>/.test(lines[i])) {
|
|
1817
|
+
currentLines.push(lines[i]);
|
|
1818
|
+
inBlockquote = true;
|
|
1819
|
+
} else if (!inBlockquote) {
|
|
1820
|
+
currentLines.push(lines[i]);
|
|
1821
|
+
} else {
|
|
1822
|
+
break;
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
lines = lines.slice(i);
|
|
1826
|
+
const currentRaw = currentLines.join("\n");
|
|
1827
|
+
const currentText = currentRaw.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, "\n $1").replace(/^ {0,3}>[ \t]?/gm, "");
|
|
1828
|
+
raw = raw ? `${raw}
|
|
1829
|
+
${currentRaw}` : currentRaw;
|
|
1830
|
+
text = text ? `${text}
|
|
1831
|
+
${currentText}` : currentText;
|
|
1832
|
+
const top = this.lexer.state.top;
|
|
1833
|
+
this.lexer.state.top = true;
|
|
1834
|
+
this.lexer.blockTokens(currentText, tokens, true);
|
|
1835
|
+
this.lexer.state.top = top;
|
|
1836
|
+
if (lines.length === 0) {
|
|
1837
|
+
break;
|
|
1838
|
+
}
|
|
1839
|
+
const lastToken = tokens[tokens.length - 1];
|
|
1840
|
+
if ((lastToken == null ? void 0 : lastToken.type) === "code") {
|
|
1841
|
+
break;
|
|
1842
|
+
} else if ((lastToken == null ? void 0 : lastToken.type) === "blockquote") {
|
|
1843
|
+
const oldToken = lastToken;
|
|
1844
|
+
const newText = oldToken.raw + "\n" + lines.join("\n");
|
|
1845
|
+
const newToken = this.blockquote(newText);
|
|
1846
|
+
tokens[tokens.length - 1] = newToken;
|
|
1847
|
+
raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
|
|
1848
|
+
text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
|
|
1849
|
+
break;
|
|
1850
|
+
} else if ((lastToken == null ? void 0 : lastToken.type) === "list") {
|
|
1851
|
+
const oldToken = lastToken;
|
|
1852
|
+
const newText = oldToken.raw + "\n" + lines.join("\n");
|
|
1853
|
+
const newToken = this.list(newText);
|
|
1854
|
+
tokens[tokens.length - 1] = newToken;
|
|
1855
|
+
raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
|
|
1856
|
+
text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
|
|
1857
|
+
lines = newText.substring(tokens[tokens.length - 1].raw.length).split("\n");
|
|
1858
|
+
continue;
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
2214
1861
|
return {
|
|
2215
1862
|
type: "blockquote",
|
|
2216
|
-
raw
|
|
1863
|
+
raw,
|
|
2217
1864
|
tokens,
|
|
2218
1865
|
text
|
|
2219
1866
|
};
|
|
@@ -2237,11 +1884,11 @@ class _Tokenizer {
|
|
|
2237
1884
|
bull = isordered ? bull : "[*+-]";
|
|
2238
1885
|
}
|
|
2239
1886
|
const itemRegex = new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`);
|
|
2240
|
-
let raw = "";
|
|
2241
|
-
let itemContents = "";
|
|
2242
1887
|
let endsWithBlankLine = false;
|
|
2243
1888
|
while (src) {
|
|
2244
1889
|
let endEarly = false;
|
|
1890
|
+
let raw = "";
|
|
1891
|
+
let itemContents = "";
|
|
2245
1892
|
if (!(cap = itemRegex.exec(src))) {
|
|
2246
1893
|
break;
|
|
2247
1894
|
}
|
|
@@ -2252,18 +1899,20 @@ class _Tokenizer {
|
|
|
2252
1899
|
src = src.substring(raw.length);
|
|
2253
1900
|
let line = cap[2].split("\n", 1)[0].replace(/^\t+/, (t2) => " ".repeat(3 * t2.length));
|
|
2254
1901
|
let nextLine = src.split("\n", 1)[0];
|
|
1902
|
+
let blankLine = !line.trim();
|
|
2255
1903
|
let indent = 0;
|
|
2256
1904
|
if (this.options.pedantic) {
|
|
2257
1905
|
indent = 2;
|
|
2258
1906
|
itemContents = line.trimStart();
|
|
1907
|
+
} else if (blankLine) {
|
|
1908
|
+
indent = cap[1].length + 1;
|
|
2259
1909
|
} else {
|
|
2260
1910
|
indent = cap[2].search(/[^ ]/);
|
|
2261
1911
|
indent = indent > 4 ? 1 : indent;
|
|
2262
1912
|
itemContents = line.slice(indent);
|
|
2263
1913
|
indent += cap[1].length;
|
|
2264
1914
|
}
|
|
2265
|
-
|
|
2266
|
-
if (!line && /^ *$/.test(nextLine)) {
|
|
1915
|
+
if (blankLine && /^ *$/.test(nextLine)) {
|
|
2267
1916
|
raw += nextLine + "\n";
|
|
2268
1917
|
src = src.substring(nextLine.length + 1);
|
|
2269
1918
|
endEarly = true;
|
|
@@ -2346,8 +1995,8 @@ class _Tokenizer {
|
|
|
2346
1995
|
});
|
|
2347
1996
|
list2.raw += raw;
|
|
2348
1997
|
}
|
|
2349
|
-
list2.items[list2.items.length - 1].raw = raw.trimEnd();
|
|
2350
|
-
list2.items[list2.items.length - 1].text =
|
|
1998
|
+
list2.items[list2.items.length - 1].raw = list2.items[list2.items.length - 1].raw.trimEnd();
|
|
1999
|
+
list2.items[list2.items.length - 1].text = list2.items[list2.items.length - 1].text.trimEnd();
|
|
2351
2000
|
list2.raw = list2.raw.trimEnd();
|
|
2352
2001
|
for (let i = 0; i < list2.items.length; i++) {
|
|
2353
2002
|
this.lexer.state.top = false;
|
|
@@ -2426,17 +2075,21 @@ class _Tokenizer {
|
|
|
2426
2075
|
item.align.push(null);
|
|
2427
2076
|
}
|
|
2428
2077
|
}
|
|
2429
|
-
for (
|
|
2078
|
+
for (let i = 0; i < headers.length; i++) {
|
|
2430
2079
|
item.header.push({
|
|
2431
|
-
text:
|
|
2432
|
-
tokens: this.lexer.inline(
|
|
2080
|
+
text: headers[i],
|
|
2081
|
+
tokens: this.lexer.inline(headers[i]),
|
|
2082
|
+
header: true,
|
|
2083
|
+
align: item.align[i]
|
|
2433
2084
|
});
|
|
2434
2085
|
}
|
|
2435
2086
|
for (const row of rows) {
|
|
2436
|
-
item.rows.push(splitCells(row, item.header.length).map((cell) => {
|
|
2087
|
+
item.rows.push(splitCells(row, item.header.length).map((cell, i) => {
|
|
2437
2088
|
return {
|
|
2438
2089
|
text: cell,
|
|
2439
|
-
tokens: this.lexer.inline(cell)
|
|
2090
|
+
tokens: this.lexer.inline(cell),
|
|
2091
|
+
header: false,
|
|
2092
|
+
align: item.align[i]
|
|
2440
2093
|
};
|
|
2441
2094
|
}));
|
|
2442
2095
|
}
|
|
@@ -2927,7 +2580,7 @@ class _Lexer {
|
|
|
2927
2580
|
this.inlineQueue = [];
|
|
2928
2581
|
return this.tokens;
|
|
2929
2582
|
}
|
|
2930
|
-
blockTokens(src, tokens = []) {
|
|
2583
|
+
blockTokens(src, tokens = [], lastParagraphClipped = false) {
|
|
2931
2584
|
if (this.options.pedantic) {
|
|
2932
2585
|
src = src.replace(/\t/g, " ").replace(/^ +$/gm, "");
|
|
2933
2586
|
} else {
|
|
@@ -2938,7 +2591,6 @@ class _Lexer {
|
|
|
2938
2591
|
let token;
|
|
2939
2592
|
let lastToken;
|
|
2940
2593
|
let cutSrc;
|
|
2941
|
-
let lastParagraphClipped;
|
|
2942
2594
|
while (src) {
|
|
2943
2595
|
if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((extTokenizer) => {
|
|
2944
2596
|
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
|
|
@@ -3043,7 +2695,7 @@ class _Lexer {
|
|
|
3043
2695
|
}
|
|
3044
2696
|
if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
|
|
3045
2697
|
lastToken = tokens[tokens.length - 1];
|
|
3046
|
-
if (lastParagraphClipped && lastToken.type === "paragraph") {
|
|
2698
|
+
if (lastParagraphClipped && (lastToken == null ? void 0 : lastToken.type) === "paragraph") {
|
|
3047
2699
|
lastToken.raw += "\n" + token.raw;
|
|
3048
2700
|
lastToken.text += "\n" + token.text;
|
|
3049
2701
|
this.inlineQueue.pop();
|
|
@@ -3230,85 +2882,136 @@ class _Lexer {
|
|
|
3230
2882
|
}
|
|
3231
2883
|
}
|
|
3232
2884
|
class _Renderer {
|
|
2885
|
+
// set by the parser
|
|
3233
2886
|
constructor(options) {
|
|
3234
2887
|
__publicField(this, "options");
|
|
2888
|
+
__publicField(this, "parser");
|
|
3235
2889
|
this.options = options || _defaults;
|
|
3236
2890
|
}
|
|
3237
|
-
|
|
2891
|
+
space(token) {
|
|
2892
|
+
return "";
|
|
2893
|
+
}
|
|
2894
|
+
code({ text, lang, escaped }) {
|
|
3238
2895
|
var _a;
|
|
3239
|
-
const
|
|
3240
|
-
code =
|
|
3241
|
-
if (!
|
|
2896
|
+
const langString = (_a = (lang || "").match(/^\S*/)) == null ? void 0 : _a[0];
|
|
2897
|
+
const code = text.replace(/\n$/, "") + "\n";
|
|
2898
|
+
if (!langString) {
|
|
3242
2899
|
return "<pre><code>" + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
|
|
3243
2900
|
}
|
|
3244
|
-
return '<pre><code class="language-' + escape$1(
|
|
2901
|
+
return '<pre><code class="language-' + escape$1(langString) + '">' + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
|
|
3245
2902
|
}
|
|
3246
|
-
blockquote(
|
|
2903
|
+
blockquote({ tokens }) {
|
|
2904
|
+
const body = this.parser.parse(tokens);
|
|
3247
2905
|
return `<blockquote>
|
|
3248
|
-
${
|
|
2906
|
+
${body}</blockquote>
|
|
3249
2907
|
`;
|
|
3250
2908
|
}
|
|
3251
|
-
html(
|
|
3252
|
-
return
|
|
2909
|
+
html({ text }) {
|
|
2910
|
+
return text;
|
|
3253
2911
|
}
|
|
3254
|
-
heading(
|
|
3255
|
-
return `<h${
|
|
2912
|
+
heading({ tokens, depth }) {
|
|
2913
|
+
return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>
|
|
3256
2914
|
`;
|
|
3257
2915
|
}
|
|
3258
|
-
hr() {
|
|
2916
|
+
hr(token) {
|
|
3259
2917
|
return "<hr>\n";
|
|
3260
2918
|
}
|
|
3261
|
-
list(
|
|
2919
|
+
list(token) {
|
|
2920
|
+
const ordered = token.ordered;
|
|
2921
|
+
const start = token.start;
|
|
2922
|
+
let body = "";
|
|
2923
|
+
for (let j = 0; j < token.items.length; j++) {
|
|
2924
|
+
const item = token.items[j];
|
|
2925
|
+
body += this.listitem(item);
|
|
2926
|
+
}
|
|
3262
2927
|
const type = ordered ? "ol" : "ul";
|
|
3263
|
-
const
|
|
3264
|
-
return "<" + type +
|
|
3265
|
-
}
|
|
3266
|
-
listitem(
|
|
3267
|
-
|
|
2928
|
+
const startAttr = ordered && start !== 1 ? ' start="' + start + '"' : "";
|
|
2929
|
+
return "<" + type + startAttr + ">\n" + body + "</" + type + ">\n";
|
|
2930
|
+
}
|
|
2931
|
+
listitem(item) {
|
|
2932
|
+
let itemBody = "";
|
|
2933
|
+
if (item.task) {
|
|
2934
|
+
const checkbox = this.checkbox({ checked: !!item.checked });
|
|
2935
|
+
if (item.loose) {
|
|
2936
|
+
if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
|
|
2937
|
+
item.tokens[0].text = checkbox + " " + item.tokens[0].text;
|
|
2938
|
+
if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
|
|
2939
|
+
item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
|
|
2940
|
+
}
|
|
2941
|
+
} else {
|
|
2942
|
+
item.tokens.unshift({
|
|
2943
|
+
type: "text",
|
|
2944
|
+
raw: checkbox + " ",
|
|
2945
|
+
text: checkbox + " "
|
|
2946
|
+
});
|
|
2947
|
+
}
|
|
2948
|
+
} else {
|
|
2949
|
+
itemBody += checkbox + " ";
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
itemBody += this.parser.parse(item.tokens, !!item.loose);
|
|
2953
|
+
return `<li>${itemBody}</li>
|
|
3268
2954
|
`;
|
|
3269
2955
|
}
|
|
3270
|
-
checkbox(checked) {
|
|
2956
|
+
checkbox({ checked }) {
|
|
3271
2957
|
return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
|
|
3272
2958
|
}
|
|
3273
|
-
paragraph(
|
|
3274
|
-
return `<p>${
|
|
2959
|
+
paragraph({ tokens }) {
|
|
2960
|
+
return `<p>${this.parser.parseInline(tokens)}</p>
|
|
3275
2961
|
`;
|
|
3276
2962
|
}
|
|
3277
|
-
table(
|
|
2963
|
+
table(token) {
|
|
2964
|
+
let header = "";
|
|
2965
|
+
let cell = "";
|
|
2966
|
+
for (let j = 0; j < token.header.length; j++) {
|
|
2967
|
+
cell += this.tablecell(token.header[j]);
|
|
2968
|
+
}
|
|
2969
|
+
header += this.tablerow({ text: cell });
|
|
2970
|
+
let body = "";
|
|
2971
|
+
for (let j = 0; j < token.rows.length; j++) {
|
|
2972
|
+
const row = token.rows[j];
|
|
2973
|
+
cell = "";
|
|
2974
|
+
for (let k = 0; k < row.length; k++) {
|
|
2975
|
+
cell += this.tablecell(row[k]);
|
|
2976
|
+
}
|
|
2977
|
+
body += this.tablerow({ text: cell });
|
|
2978
|
+
}
|
|
3278
2979
|
if (body)
|
|
3279
2980
|
body = `<tbody>${body}</tbody>`;
|
|
3280
2981
|
return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
|
|
3281
2982
|
}
|
|
3282
|
-
tablerow(
|
|
2983
|
+
tablerow({ text }) {
|
|
3283
2984
|
return `<tr>
|
|
3284
|
-
${
|
|
2985
|
+
${text}</tr>
|
|
3285
2986
|
`;
|
|
3286
2987
|
}
|
|
3287
|
-
tablecell(
|
|
3288
|
-
const
|
|
3289
|
-
const
|
|
2988
|
+
tablecell(token) {
|
|
2989
|
+
const content = this.parser.parseInline(token.tokens);
|
|
2990
|
+
const type = token.header ? "th" : "td";
|
|
2991
|
+
const tag2 = token.align ? `<${type} align="${token.align}">` : `<${type}>`;
|
|
3290
2992
|
return tag2 + content + `</${type}>
|
|
3291
2993
|
`;
|
|
3292
2994
|
}
|
|
3293
2995
|
/**
|
|
3294
2996
|
* span level renderer
|
|
3295
2997
|
*/
|
|
3296
|
-
strong(
|
|
3297
|
-
return `<strong>${
|
|
2998
|
+
strong({ tokens }) {
|
|
2999
|
+
return `<strong>${this.parser.parseInline(tokens)}</strong>`;
|
|
3298
3000
|
}
|
|
3299
|
-
em(
|
|
3300
|
-
return `<em>${
|
|
3001
|
+
em({ tokens }) {
|
|
3002
|
+
return `<em>${this.parser.parseInline(tokens)}</em>`;
|
|
3301
3003
|
}
|
|
3302
|
-
codespan(text) {
|
|
3004
|
+
codespan({ text }) {
|
|
3303
3005
|
return `<code>${text}</code>`;
|
|
3304
3006
|
}
|
|
3305
|
-
br() {
|
|
3007
|
+
br(token) {
|
|
3306
3008
|
return "<br>";
|
|
3307
3009
|
}
|
|
3308
|
-
del(
|
|
3309
|
-
return `<del>${
|
|
3010
|
+
del({ tokens }) {
|
|
3011
|
+
return `<del>${this.parser.parseInline(tokens)}</del>`;
|
|
3310
3012
|
}
|
|
3311
|
-
link(href, title,
|
|
3013
|
+
link({ href, title, tokens }) {
|
|
3014
|
+
const text = this.parser.parseInline(tokens);
|
|
3312
3015
|
const cleanHref = cleanUrl(href);
|
|
3313
3016
|
if (cleanHref === null) {
|
|
3314
3017
|
return text;
|
|
@@ -3321,7 +3024,7 @@ ${content}</tr>
|
|
|
3321
3024
|
out += ">" + text + "</a>";
|
|
3322
3025
|
return out;
|
|
3323
3026
|
}
|
|
3324
|
-
image(href, title, text) {
|
|
3027
|
+
image({ href, title, text }) {
|
|
3325
3028
|
const cleanHref = cleanUrl(href);
|
|
3326
3029
|
if (cleanHref === null) {
|
|
3327
3030
|
return text;
|
|
@@ -3334,34 +3037,34 @@ ${content}</tr>
|
|
|
3334
3037
|
out += ">";
|
|
3335
3038
|
return out;
|
|
3336
3039
|
}
|
|
3337
|
-
text(
|
|
3338
|
-
return text;
|
|
3040
|
+
text(token) {
|
|
3041
|
+
return "tokens" in token && token.tokens ? this.parser.parseInline(token.tokens) : token.text;
|
|
3339
3042
|
}
|
|
3340
3043
|
}
|
|
3341
3044
|
class _TextRenderer {
|
|
3342
3045
|
// no need for block level renderers
|
|
3343
|
-
strong(text) {
|
|
3046
|
+
strong({ text }) {
|
|
3344
3047
|
return text;
|
|
3345
3048
|
}
|
|
3346
|
-
em(text) {
|
|
3049
|
+
em({ text }) {
|
|
3347
3050
|
return text;
|
|
3348
3051
|
}
|
|
3349
|
-
codespan(text) {
|
|
3052
|
+
codespan({ text }) {
|
|
3350
3053
|
return text;
|
|
3351
3054
|
}
|
|
3352
|
-
del(text) {
|
|
3055
|
+
del({ text }) {
|
|
3353
3056
|
return text;
|
|
3354
3057
|
}
|
|
3355
|
-
html(text) {
|
|
3058
|
+
html({ text }) {
|
|
3356
3059
|
return text;
|
|
3357
3060
|
}
|
|
3358
|
-
text(text) {
|
|
3061
|
+
text({ text }) {
|
|
3359
3062
|
return text;
|
|
3360
3063
|
}
|
|
3361
|
-
link(
|
|
3064
|
+
link({ text }) {
|
|
3362
3065
|
return "" + text;
|
|
3363
3066
|
}
|
|
3364
|
-
image(
|
|
3067
|
+
image({ text }) {
|
|
3365
3068
|
return "" + text;
|
|
3366
3069
|
}
|
|
3367
3070
|
br() {
|
|
@@ -3377,6 +3080,7 @@ class _Parser {
|
|
|
3377
3080
|
this.options.renderer = this.options.renderer || new _Renderer();
|
|
3378
3081
|
this.renderer = this.options.renderer;
|
|
3379
3082
|
this.renderer.options = this.options;
|
|
3083
|
+
this.renderer.parser = this;
|
|
3380
3084
|
this.textRenderer = new _TextRenderer();
|
|
3381
3085
|
}
|
|
3382
3086
|
/**
|
|
@@ -3399,112 +3103,70 @@ class _Parser {
|
|
|
3399
3103
|
parse(tokens, top = true) {
|
|
3400
3104
|
let out = "";
|
|
3401
3105
|
for (let i = 0; i < tokens.length; i++) {
|
|
3402
|
-
const
|
|
3403
|
-
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[
|
|
3404
|
-
const genericToken =
|
|
3106
|
+
const anyToken = tokens[i];
|
|
3107
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[anyToken.type]) {
|
|
3108
|
+
const genericToken = anyToken;
|
|
3405
3109
|
const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
|
|
3406
3110
|
if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
|
|
3407
3111
|
out += ret || "";
|
|
3408
3112
|
continue;
|
|
3409
3113
|
}
|
|
3410
3114
|
}
|
|
3115
|
+
const token = anyToken;
|
|
3411
3116
|
switch (token.type) {
|
|
3412
3117
|
case "space": {
|
|
3118
|
+
out += this.renderer.space(token);
|
|
3413
3119
|
continue;
|
|
3414
3120
|
}
|
|
3415
3121
|
case "hr": {
|
|
3416
|
-
out += this.renderer.hr();
|
|
3122
|
+
out += this.renderer.hr(token);
|
|
3417
3123
|
continue;
|
|
3418
3124
|
}
|
|
3419
3125
|
case "heading": {
|
|
3420
|
-
|
|
3421
|
-
out += this.renderer.heading(this.parseInline(headingToken.tokens), headingToken.depth, unescape(this.parseInline(headingToken.tokens, this.textRenderer)));
|
|
3126
|
+
out += this.renderer.heading(token);
|
|
3422
3127
|
continue;
|
|
3423
3128
|
}
|
|
3424
3129
|
case "code": {
|
|
3425
|
-
|
|
3426
|
-
out += this.renderer.code(codeToken.text, codeToken.lang, !!codeToken.escaped);
|
|
3130
|
+
out += this.renderer.code(token);
|
|
3427
3131
|
continue;
|
|
3428
3132
|
}
|
|
3429
3133
|
case "table": {
|
|
3430
|
-
|
|
3431
|
-
let header = "";
|
|
3432
|
-
let cell = "";
|
|
3433
|
-
for (let j = 0; j < tableToken.header.length; j++) {
|
|
3434
|
-
cell += this.renderer.tablecell(this.parseInline(tableToken.header[j].tokens), { header: true, align: tableToken.align[j] });
|
|
3435
|
-
}
|
|
3436
|
-
header += this.renderer.tablerow(cell);
|
|
3437
|
-
let body = "";
|
|
3438
|
-
for (let j = 0; j < tableToken.rows.length; j++) {
|
|
3439
|
-
const row = tableToken.rows[j];
|
|
3440
|
-
cell = "";
|
|
3441
|
-
for (let k = 0; k < row.length; k++) {
|
|
3442
|
-
cell += this.renderer.tablecell(this.parseInline(row[k].tokens), { header: false, align: tableToken.align[k] });
|
|
3443
|
-
}
|
|
3444
|
-
body += this.renderer.tablerow(cell);
|
|
3445
|
-
}
|
|
3446
|
-
out += this.renderer.table(header, body);
|
|
3134
|
+
out += this.renderer.table(token);
|
|
3447
3135
|
continue;
|
|
3448
3136
|
}
|
|
3449
3137
|
case "blockquote": {
|
|
3450
|
-
|
|
3451
|
-
const body = this.parse(blockquoteToken.tokens);
|
|
3452
|
-
out += this.renderer.blockquote(body);
|
|
3138
|
+
out += this.renderer.blockquote(token);
|
|
3453
3139
|
continue;
|
|
3454
3140
|
}
|
|
3455
3141
|
case "list": {
|
|
3456
|
-
|
|
3457
|
-
const ordered = listToken.ordered;
|
|
3458
|
-
const start = listToken.start;
|
|
3459
|
-
const loose = listToken.loose;
|
|
3460
|
-
let body = "";
|
|
3461
|
-
for (let j = 0; j < listToken.items.length; j++) {
|
|
3462
|
-
const item = listToken.items[j];
|
|
3463
|
-
const checked = item.checked;
|
|
3464
|
-
const task = item.task;
|
|
3465
|
-
let itemBody = "";
|
|
3466
|
-
if (item.task) {
|
|
3467
|
-
const checkbox = this.renderer.checkbox(!!checked);
|
|
3468
|
-
if (loose) {
|
|
3469
|
-
if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
|
|
3470
|
-
item.tokens[0].text = checkbox + " " + item.tokens[0].text;
|
|
3471
|
-
if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
|
|
3472
|
-
item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
|
|
3473
|
-
}
|
|
3474
|
-
} else {
|
|
3475
|
-
item.tokens.unshift({
|
|
3476
|
-
type: "text",
|
|
3477
|
-
text: checkbox + " "
|
|
3478
|
-
});
|
|
3479
|
-
}
|
|
3480
|
-
} else {
|
|
3481
|
-
itemBody += checkbox + " ";
|
|
3482
|
-
}
|
|
3483
|
-
}
|
|
3484
|
-
itemBody += this.parse(item.tokens, loose);
|
|
3485
|
-
body += this.renderer.listitem(itemBody, task, !!checked);
|
|
3486
|
-
}
|
|
3487
|
-
out += this.renderer.list(body, ordered, start);
|
|
3142
|
+
out += this.renderer.list(token);
|
|
3488
3143
|
continue;
|
|
3489
3144
|
}
|
|
3490
3145
|
case "html": {
|
|
3491
|
-
|
|
3492
|
-
out += this.renderer.html(htmlToken.text, htmlToken.block);
|
|
3146
|
+
out += this.renderer.html(token);
|
|
3493
3147
|
continue;
|
|
3494
3148
|
}
|
|
3495
3149
|
case "paragraph": {
|
|
3496
|
-
|
|
3497
|
-
out += this.renderer.paragraph(this.parseInline(paragraphToken.tokens));
|
|
3150
|
+
out += this.renderer.paragraph(token);
|
|
3498
3151
|
continue;
|
|
3499
3152
|
}
|
|
3500
3153
|
case "text": {
|
|
3501
3154
|
let textToken = token;
|
|
3502
|
-
let body =
|
|
3155
|
+
let body = this.renderer.text(textToken);
|
|
3503
3156
|
while (i + 1 < tokens.length && tokens[i + 1].type === "text") {
|
|
3504
3157
|
textToken = tokens[++i];
|
|
3505
|
-
body += "\n" +
|
|
3158
|
+
body += "\n" + this.renderer.text(textToken);
|
|
3159
|
+
}
|
|
3160
|
+
if (top) {
|
|
3161
|
+
out += this.renderer.paragraph({
|
|
3162
|
+
type: "paragraph",
|
|
3163
|
+
raw: body,
|
|
3164
|
+
text: body,
|
|
3165
|
+
tokens: [{ type: "text", raw: body, text: body }]
|
|
3166
|
+
});
|
|
3167
|
+
} else {
|
|
3168
|
+
out += body;
|
|
3506
3169
|
}
|
|
3507
|
-
out += top ? this.renderer.paragraph(body) : body;
|
|
3508
3170
|
continue;
|
|
3509
3171
|
}
|
|
3510
3172
|
default: {
|
|
@@ -3527,62 +3189,54 @@ class _Parser {
|
|
|
3527
3189
|
renderer = renderer || this.renderer;
|
|
3528
3190
|
let out = "";
|
|
3529
3191
|
for (let i = 0; i < tokens.length; i++) {
|
|
3530
|
-
const
|
|
3531
|
-
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[
|
|
3532
|
-
const ret = this.options.extensions.renderers[
|
|
3533
|
-
if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(
|
|
3192
|
+
const anyToken = tokens[i];
|
|
3193
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[anyToken.type]) {
|
|
3194
|
+
const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);
|
|
3195
|
+
if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(anyToken.type)) {
|
|
3534
3196
|
out += ret || "";
|
|
3535
3197
|
continue;
|
|
3536
3198
|
}
|
|
3537
3199
|
}
|
|
3200
|
+
const token = anyToken;
|
|
3538
3201
|
switch (token.type) {
|
|
3539
3202
|
case "escape": {
|
|
3540
|
-
|
|
3541
|
-
out += renderer.text(escapeToken.text);
|
|
3203
|
+
out += renderer.text(token);
|
|
3542
3204
|
break;
|
|
3543
3205
|
}
|
|
3544
3206
|
case "html": {
|
|
3545
|
-
|
|
3546
|
-
out += renderer.html(tagToken.text);
|
|
3207
|
+
out += renderer.html(token);
|
|
3547
3208
|
break;
|
|
3548
3209
|
}
|
|
3549
3210
|
case "link": {
|
|
3550
|
-
|
|
3551
|
-
out += renderer.link(linkToken.href, linkToken.title, this.parseInline(linkToken.tokens, renderer));
|
|
3211
|
+
out += renderer.link(token);
|
|
3552
3212
|
break;
|
|
3553
3213
|
}
|
|
3554
3214
|
case "image": {
|
|
3555
|
-
|
|
3556
|
-
out += renderer.image(imageToken.href, imageToken.title, imageToken.text);
|
|
3215
|
+
out += renderer.image(token);
|
|
3557
3216
|
break;
|
|
3558
3217
|
}
|
|
3559
3218
|
case "strong": {
|
|
3560
|
-
|
|
3561
|
-
out += renderer.strong(this.parseInline(strongToken.tokens, renderer));
|
|
3219
|
+
out += renderer.strong(token);
|
|
3562
3220
|
break;
|
|
3563
3221
|
}
|
|
3564
3222
|
case "em": {
|
|
3565
|
-
|
|
3566
|
-
out += renderer.em(this.parseInline(emToken.tokens, renderer));
|
|
3223
|
+
out += renderer.em(token);
|
|
3567
3224
|
break;
|
|
3568
3225
|
}
|
|
3569
3226
|
case "codespan": {
|
|
3570
|
-
|
|
3571
|
-
out += renderer.codespan(codespanToken.text);
|
|
3227
|
+
out += renderer.codespan(token);
|
|
3572
3228
|
break;
|
|
3573
3229
|
}
|
|
3574
3230
|
case "br": {
|
|
3575
|
-
out += renderer.br();
|
|
3231
|
+
out += renderer.br(token);
|
|
3576
3232
|
break;
|
|
3577
3233
|
}
|
|
3578
3234
|
case "del": {
|
|
3579
|
-
|
|
3580
|
-
out += renderer.del(this.parseInline(delToken.tokens, renderer));
|
|
3235
|
+
out += renderer.del(token);
|
|
3581
3236
|
break;
|
|
3582
3237
|
}
|
|
3583
3238
|
case "text": {
|
|
3584
|
-
|
|
3585
|
-
out += renderer.text(textToken.text);
|
|
3239
|
+
out += renderer.text(token);
|
|
3586
3240
|
break;
|
|
3587
3241
|
}
|
|
3588
3242
|
default: {
|
|
@@ -3602,6 +3256,7 @@ class _Parser {
|
|
|
3602
3256
|
class _Hooks {
|
|
3603
3257
|
constructor(options) {
|
|
3604
3258
|
__publicField(this, "options");
|
|
3259
|
+
__publicField(this, "block");
|
|
3605
3260
|
this.options = options || _defaults;
|
|
3606
3261
|
}
|
|
3607
3262
|
/**
|
|
@@ -3622,6 +3277,18 @@ class _Hooks {
|
|
|
3622
3277
|
processAllTokens(tokens) {
|
|
3623
3278
|
return tokens;
|
|
3624
3279
|
}
|
|
3280
|
+
/**
|
|
3281
|
+
* Provide function to tokenize markdown
|
|
3282
|
+
*/
|
|
3283
|
+
provideLexer() {
|
|
3284
|
+
return this.block ? _Lexer.lex : _Lexer.lexInline;
|
|
3285
|
+
}
|
|
3286
|
+
/**
|
|
3287
|
+
* Provide function to parse tokens
|
|
3288
|
+
*/
|
|
3289
|
+
provideParser() {
|
|
3290
|
+
return this.block ? _Parser.parse : _Parser.parseInline;
|
|
3291
|
+
}
|
|
3625
3292
|
}
|
|
3626
3293
|
__publicField(_Hooks, "passThroughHooks", /* @__PURE__ */ new Set([
|
|
3627
3294
|
"preprocess",
|
|
@@ -3630,12 +3297,10 @@ __publicField(_Hooks, "passThroughHooks", /* @__PURE__ */ new Set([
|
|
|
3630
3297
|
]));
|
|
3631
3298
|
class Marked {
|
|
3632
3299
|
constructor(...args) {
|
|
3633
|
-
__privateAdd(this, _parseMarkdown);
|
|
3634
|
-
__privateAdd(this, _onError);
|
|
3635
3300
|
__publicField(this, "defaults", _getDefaults());
|
|
3636
3301
|
__publicField(this, "options", this.setOptions);
|
|
3637
|
-
__publicField(this, "parse",
|
|
3638
|
-
__publicField(this, "parseInline",
|
|
3302
|
+
__publicField(this, "parse", this.parseMarkdown(true));
|
|
3303
|
+
__publicField(this, "parseInline", this.parseMarkdown(false));
|
|
3639
3304
|
__publicField(this, "Parser", _Parser);
|
|
3640
3305
|
__publicField(this, "Renderer", _Renderer);
|
|
3641
3306
|
__publicField(this, "TextRenderer", _TextRenderer);
|
|
@@ -3747,7 +3412,7 @@ class Marked {
|
|
|
3747
3412
|
if (!(prop in renderer)) {
|
|
3748
3413
|
throw new Error(`renderer '${prop}' does not exist`);
|
|
3749
3414
|
}
|
|
3750
|
-
if (
|
|
3415
|
+
if (["options", "parser"].includes(prop)) {
|
|
3751
3416
|
continue;
|
|
3752
3417
|
}
|
|
3753
3418
|
const rendererProp = prop;
|
|
@@ -3791,7 +3456,7 @@ class Marked {
|
|
|
3791
3456
|
if (!(prop in hooks)) {
|
|
3792
3457
|
throw new Error(`hook '${prop}' does not exist`);
|
|
3793
3458
|
}
|
|
3794
|
-
if (
|
|
3459
|
+
if (["options", "block"].includes(prop)) {
|
|
3795
3460
|
continue;
|
|
3796
3461
|
}
|
|
3797
3462
|
const hooksProp = prop;
|
|
@@ -3845,69 +3510,68 @@ class Marked {
|
|
|
3845
3510
|
parser(tokens, options) {
|
|
3846
3511
|
return _Parser.parse(tokens, options != null ? options : this.defaults);
|
|
3847
3512
|
}
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
if (!opt.silent) {
|
|
3856
|
-
console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored.");
|
|
3513
|
+
parseMarkdown(blockType) {
|
|
3514
|
+
const parse = (src, options) => {
|
|
3515
|
+
const origOpt = __spreadValues({}, options);
|
|
3516
|
+
const opt = __spreadValues(__spreadValues({}, this.defaults), origOpt);
|
|
3517
|
+
const throwError = this.onError(!!opt.silent, !!opt.async);
|
|
3518
|
+
if (this.defaults.async === true && origOpt.async === false) {
|
|
3519
|
+
return throwError(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
|
|
3857
3520
|
}
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
}
|
|
3864
|
-
if (typeof src !== "string") {
|
|
3865
|
-
return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
|
|
3866
|
-
}
|
|
3867
|
-
if (opt.hooks) {
|
|
3868
|
-
opt.hooks.options = opt;
|
|
3869
|
-
}
|
|
3870
|
-
if (opt.async) {
|
|
3871
|
-
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html2) => opt.hooks ? opt.hooks.postprocess(html2) : html2).catch(throwError);
|
|
3872
|
-
}
|
|
3873
|
-
try {
|
|
3874
|
-
if (opt.hooks) {
|
|
3875
|
-
src = opt.hooks.preprocess(src);
|
|
3521
|
+
if (typeof src === "undefined" || src === null) {
|
|
3522
|
+
return throwError(new Error("marked(): input parameter is undefined or null"));
|
|
3523
|
+
}
|
|
3524
|
+
if (typeof src !== "string") {
|
|
3525
|
+
return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
|
|
3876
3526
|
}
|
|
3877
|
-
let tokens = lexer(src, opt);
|
|
3878
3527
|
if (opt.hooks) {
|
|
3879
|
-
|
|
3528
|
+
opt.hooks.options = opt;
|
|
3529
|
+
opt.hooks.block = blockType;
|
|
3880
3530
|
}
|
|
3881
|
-
|
|
3882
|
-
|
|
3531
|
+
const lexer = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
|
|
3532
|
+
const parser2 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
|
|
3533
|
+
if (opt.async) {
|
|
3534
|
+
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html2) => opt.hooks ? opt.hooks.postprocess(html2) : html2).catch(throwError);
|
|
3883
3535
|
}
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3536
|
+
try {
|
|
3537
|
+
if (opt.hooks) {
|
|
3538
|
+
src = opt.hooks.preprocess(src);
|
|
3539
|
+
}
|
|
3540
|
+
let tokens = lexer(src, opt);
|
|
3541
|
+
if (opt.hooks) {
|
|
3542
|
+
tokens = opt.hooks.processAllTokens(tokens);
|
|
3543
|
+
}
|
|
3544
|
+
if (opt.walkTokens) {
|
|
3545
|
+
this.walkTokens(tokens, opt.walkTokens);
|
|
3546
|
+
}
|
|
3547
|
+
let html2 = parser2(tokens, opt);
|
|
3548
|
+
if (opt.hooks) {
|
|
3549
|
+
html2 = opt.hooks.postprocess(html2);
|
|
3550
|
+
}
|
|
3551
|
+
return html2;
|
|
3552
|
+
} catch (e) {
|
|
3553
|
+
return throwError(e);
|
|
3554
|
+
}
|
|
3555
|
+
};
|
|
3556
|
+
return parse;
|
|
3557
|
+
}
|
|
3558
|
+
onError(silent, async) {
|
|
3559
|
+
return (e) => {
|
|
3560
|
+
e.message += "\nPlease report this to https://github.com/markedjs/marked.";
|
|
3561
|
+
if (silent) {
|
|
3562
|
+
const msg = "<p>An error occurred:</p><pre>" + escape$1(e.message + "", true) + "</pre>";
|
|
3563
|
+
if (async) {
|
|
3564
|
+
return Promise.resolve(msg);
|
|
3565
|
+
}
|
|
3566
|
+
return msg;
|
|
3887
3567
|
}
|
|
3888
|
-
return html2;
|
|
3889
|
-
} catch (e) {
|
|
3890
|
-
return throwError(e);
|
|
3891
|
-
}
|
|
3892
|
-
};
|
|
3893
|
-
};
|
|
3894
|
-
_onError = new WeakSet();
|
|
3895
|
-
onError_fn = function(silent, async) {
|
|
3896
|
-
return (e) => {
|
|
3897
|
-
e.message += "\nPlease report this to https://github.com/markedjs/marked.";
|
|
3898
|
-
if (silent) {
|
|
3899
|
-
const msg = "<p>An error occurred:</p><pre>" + escape$1(e.message + "", true) + "</pre>";
|
|
3900
3568
|
if (async) {
|
|
3901
|
-
return Promise.
|
|
3569
|
+
return Promise.reject(e);
|
|
3902
3570
|
}
|
|
3903
|
-
|
|
3904
|
-
}
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
}
|
|
3908
|
-
throw e;
|
|
3909
|
-
};
|
|
3910
|
-
};
|
|
3571
|
+
throw e;
|
|
3572
|
+
};
|
|
3573
|
+
}
|
|
3574
|
+
}
|
|
3911
3575
|
const markedInstance = new Marked();
|
|
3912
3576
|
function marked$1(src, opt) {
|
|
3913
3577
|
return markedInstance.parse(src, opt);
|
|
@@ -3946,6 +3610,10 @@ marked$1.walkTokens;
|
|
|
3946
3610
|
marked$1.parseInline;
|
|
3947
3611
|
_Parser.parse;
|
|
3948
3612
|
_Lexer.lex;
|
|
3613
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
3614
|
+
function getDefaultExportFromCjs(x) {
|
|
3615
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
3616
|
+
}
|
|
3949
3617
|
var escapes = {
|
|
3950
3618
|
"&": "&",
|
|
3951
3619
|
"<": "<",
|
|
@@ -4444,11 +4112,9 @@ var hanabi$1 = { exports: {} };
|
|
|
4444
4112
|
});
|
|
4445
4113
|
var defaultColors = ["23AC69", "91C132", "F19726", "E8552D", "1AAB8E", "E1147F", "2980C1", "1BA1E6", "9FA0A0", "F19726", "E30B20", "E30B20", "A3338B"];
|
|
4446
4114
|
var index = function(input, ref) {
|
|
4447
|
-
if (ref === void 0)
|
|
4448
|
-
ref = {};
|
|
4115
|
+
if (ref === void 0) ref = {};
|
|
4449
4116
|
var colors = ref.colors;
|
|
4450
|
-
if (colors === void 0)
|
|
4451
|
-
colors = defaultColors;
|
|
4117
|
+
if (colors === void 0) colors = defaultColors;
|
|
4452
4118
|
var index2 = 0;
|
|
4453
4119
|
var cache = {};
|
|
4454
4120
|
var wordRe = /[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/;
|
|
@@ -4491,7 +4157,7 @@ function getRenderer(options) {
|
|
|
4491
4157
|
renderer.image = markedImageRenderer(renderer, renderer.image, options);
|
|
4492
4158
|
return renderer;
|
|
4493
4159
|
}
|
|
4494
|
-
const markedLinkRenderer = (renderer, orgLinkRenderer) => (
|
|
4160
|
+
const markedLinkRenderer = (renderer, orgLinkRenderer) => (args) => {
|
|
4495
4161
|
const getLinkOrigin = (link2) => {
|
|
4496
4162
|
try {
|
|
4497
4163
|
return new URL(link2).origin;
|
|
@@ -4499,31 +4165,30 @@ const markedLinkRenderer = (renderer, orgLinkRenderer) => (href, title, text) =>
|
|
|
4499
4165
|
return "";
|
|
4500
4166
|
}
|
|
4501
4167
|
};
|
|
4502
|
-
const isSameOriginLink = getLinkOrigin(href) === window.location.origin;
|
|
4503
|
-
const html2 = orgLinkRenderer.call(renderer,
|
|
4168
|
+
const isSameOriginLink = getLinkOrigin(args.href) === window.location.origin;
|
|
4169
|
+
const html2 = orgLinkRenderer.call(renderer, args);
|
|
4504
4170
|
return html2.replace(
|
|
4505
4171
|
/^<a /,
|
|
4506
4172
|
`<a target="_blank" ${!isSameOriginLink ? `rel="noreferrer noopener nofollow"` : ""} `
|
|
4507
4173
|
);
|
|
4508
4174
|
};
|
|
4509
|
-
const markedCodeRenderer = () => (
|
|
4175
|
+
const markedCodeRenderer = () => ({ lang, text }) => {
|
|
4510
4176
|
const realLang = !lang ? "plaintext" : lang;
|
|
4511
|
-
let colorized =
|
|
4177
|
+
let colorized = text;
|
|
4512
4178
|
if (window.hljs) {
|
|
4513
4179
|
if (realLang && window.hljs.getLanguage(realLang)) {
|
|
4514
|
-
colorized = window.hljs.highlight(realLang,
|
|
4180
|
+
colorized = window.hljs.highlight(realLang, text).value;
|
|
4515
4181
|
}
|
|
4516
4182
|
} else {
|
|
4517
|
-
colorized = renderCode(
|
|
4183
|
+
colorized = renderCode(text);
|
|
4518
4184
|
}
|
|
4519
4185
|
return `<pre rel="${realLang}">
|
|
4520
4186
|
<code class="hljs language-${realLang}">${colorized.replace(/&/g, "&")}</code>
|
|
4521
4187
|
</pre>`;
|
|
4522
4188
|
};
|
|
4523
|
-
const markedImageRenderer = (renderer, orgImageRenderer, { imgLazyLoad }) => (
|
|
4524
|
-
const html2 = orgImageRenderer.call(renderer,
|
|
4525
|
-
if (!imgLazyLoad)
|
|
4526
|
-
return html2;
|
|
4189
|
+
const markedImageRenderer = (renderer, orgImageRenderer, { imgLazyLoad }) => (args) => {
|
|
4190
|
+
const html2 = orgImageRenderer.call(renderer, args);
|
|
4191
|
+
if (!imgLazyLoad) return html2;
|
|
4527
4192
|
if (imgLazyLoad === "native" || imgLazyLoad === true)
|
|
4528
4193
|
return html2.replace(/^<img /, '<img class="lazyload" loading="lazy" ');
|
|
4529
4194
|
if (imgLazyLoad === "data-src")
|
|
@@ -4545,17 +4210,17 @@ function setReplacers(arr) {
|
|
|
4545
4210
|
}
|
|
4546
4211
|
function initMarked(options) {
|
|
4547
4212
|
try {
|
|
4548
|
-
if (!
|
|
4549
|
-
return;
|
|
4213
|
+
if (!Marked.name) return;
|
|
4550
4214
|
} catch (e) {
|
|
4551
4215
|
return;
|
|
4552
4216
|
}
|
|
4553
|
-
|
|
4217
|
+
const marked2 = new Marked();
|
|
4218
|
+
marked2.setOptions(__spreadValues(__spreadValues({
|
|
4554
4219
|
renderer: getRenderer({
|
|
4555
4220
|
imgLazyLoad: options.imgLazyLoad
|
|
4556
4221
|
})
|
|
4557
4222
|
}, markedOptions), options.markedOptions));
|
|
4558
|
-
instance =
|
|
4223
|
+
instance = marked2;
|
|
4559
4224
|
}
|
|
4560
4225
|
function marked(src) {
|
|
4561
4226
|
var _a;
|
|
@@ -4565,8 +4230,7 @@ function marked(src) {
|
|
|
4565
4230
|
}
|
|
4566
4231
|
let dest = sanitize(markedContent);
|
|
4567
4232
|
replacers.forEach((replacer) => {
|
|
4568
|
-
if (typeof replacer === "function")
|
|
4569
|
-
dest = replacer(dest);
|
|
4233
|
+
if (typeof replacer === "function") dest = replacer(dest);
|
|
4570
4234
|
});
|
|
4571
4235
|
return dest;
|
|
4572
4236
|
}
|
|
@@ -4649,8 +4313,7 @@ class DataManager {
|
|
|
4649
4313
|
}
|
|
4650
4314
|
updateComment(comment) {
|
|
4651
4315
|
this.comments = this.comments.map((c) => {
|
|
4652
|
-
if (c.id === comment.id)
|
|
4653
|
-
return comment;
|
|
4316
|
+
if (c.id === comment.id) return comment;
|
|
4654
4317
|
return c;
|
|
4655
4318
|
});
|
|
4656
4319
|
this.events.trigger("comment-updated", comment);
|
|
@@ -4658,8 +4321,7 @@ class DataManager {
|
|
|
4658
4321
|
}
|
|
4659
4322
|
deleteComment(id) {
|
|
4660
4323
|
const comment = this.comments.find((c) => c.id === id);
|
|
4661
|
-
if (!comment)
|
|
4662
|
-
throw new Error(`Comment ${id} not found`);
|
|
4324
|
+
if (!comment) throw new Error(`Comment ${id} not found`);
|
|
4663
4325
|
this.comments = this.comments.filter((c) => c.id !== id);
|
|
4664
4326
|
this.events.trigger("comment-deleted", comment);
|
|
4665
4327
|
this.events.trigger("list-loaded", this.comments);
|
|
@@ -4715,8 +4377,7 @@ function getOffset(el, relativeTo) {
|
|
|
4715
4377
|
};
|
|
4716
4378
|
};
|
|
4717
4379
|
const elOffset = getOffsetRecursive(el);
|
|
4718
|
-
if (!relativeTo)
|
|
4719
|
-
return elOffset;
|
|
4380
|
+
if (!relativeTo) return elOffset;
|
|
4720
4381
|
const relativeToOffset = getOffsetRecursive(relativeTo);
|
|
4721
4382
|
return {
|
|
4722
4383
|
top: elOffset.top - relativeToOffset.top,
|
|
@@ -4751,16 +4412,14 @@ function timeAgo(date, $t = (n) => n) {
|
|
|
4751
4412
|
if (minutes === 0) {
|
|
4752
4413
|
const leave3 = leave2 % (60 * 1e3);
|
|
4753
4414
|
const seconds = Math.round(leave3 / 1e3);
|
|
4754
|
-
if (seconds < 10)
|
|
4755
|
-
return $t("now");
|
|
4415
|
+
if (seconds < 10) return $t("now");
|
|
4756
4416
|
return `${seconds} ${$t("seconds")}`;
|
|
4757
4417
|
}
|
|
4758
4418
|
return `${minutes} ${$t("minutes")}`;
|
|
4759
4419
|
}
|
|
4760
4420
|
return `${hours} ${$t("hours")}`;
|
|
4761
4421
|
}
|
|
4762
|
-
if (days < 0)
|
|
4763
|
-
return $t("now");
|
|
4422
|
+
if (days < 0) return $t("now");
|
|
4764
4423
|
if (days < 8) {
|
|
4765
4424
|
return `${days} ${$t("days")}`;
|
|
4766
4425
|
}
|
|
@@ -4779,14 +4438,10 @@ function versionCompare(a, b) {
|
|
|
4779
4438
|
for (let i = 0; i < 3; i++) {
|
|
4780
4439
|
const na = Number(pa[i]);
|
|
4781
4440
|
const nb = Number(pb[i]);
|
|
4782
|
-
if (na > nb)
|
|
4783
|
-
|
|
4784
|
-
if (nb
|
|
4785
|
-
|
|
4786
|
-
if (!Number.isNaN(na) && Number.isNaN(nb))
|
|
4787
|
-
return 1;
|
|
4788
|
-
if (Number.isNaN(na) && !Number.isNaN(nb))
|
|
4789
|
-
return -1;
|
|
4441
|
+
if (na > nb) return 1;
|
|
4442
|
+
if (nb > na) return -1;
|
|
4443
|
+
if (!Number.isNaN(na) && Number.isNaN(nb)) return 1;
|
|
4444
|
+
if (Number.isNaN(na) && !Number.isNaN(nb)) return -1;
|
|
4790
4445
|
}
|
|
4791
4446
|
return 0;
|
|
4792
4447
|
}
|
|
@@ -4900,21 +4555,25 @@ const en = {
|
|
|
4900
4555
|
cancel: "Cancel",
|
|
4901
4556
|
/* Sidebar */
|
|
4902
4557
|
msgCenter: "Messages",
|
|
4903
|
-
ctrlCenter: "
|
|
4558
|
+
ctrlCenter: "Dashboard",
|
|
4904
4559
|
/* Auth */
|
|
4560
|
+
userProfile: "Profile",
|
|
4905
4561
|
noAccountPrompt: "Don't have an account?",
|
|
4906
4562
|
haveAccountPrompt: "Already have an account?",
|
|
4907
4563
|
forgetPassword: "Forget Password",
|
|
4908
4564
|
resetPassword: "Reset Password",
|
|
4565
|
+
changePassword: "Change Password",
|
|
4566
|
+
confirmPassword: "Confirm Password",
|
|
4567
|
+
passwordMismatch: "Passwords do not match",
|
|
4909
4568
|
verificationCode: "Verification Code",
|
|
4910
|
-
verifySend: "
|
|
4569
|
+
verifySend: "Send Code",
|
|
4911
4570
|
verifyResend: "Resend",
|
|
4912
4571
|
waitSeconds: "Wait {seconds}s",
|
|
4913
4572
|
emailVerified: "Email has been verified",
|
|
4914
4573
|
password: "Password",
|
|
4915
4574
|
username: "Username",
|
|
4916
4575
|
nextStep: "Next Step",
|
|
4917
|
-
|
|
4576
|
+
skipVerify: "Skip verification",
|
|
4918
4577
|
logoutConfirm: "Are you sure to logout?",
|
|
4919
4578
|
accountMergeNotice: "Your email has multiple accounts with different id.",
|
|
4920
4579
|
accountMergeSelectOne: "Please select one you want to merge all the data into it.",
|
|
@@ -5004,10 +4663,14 @@ const zhCN = {
|
|
|
5004
4663
|
msgCenter: "通知中心",
|
|
5005
4664
|
ctrlCenter: "控制中心",
|
|
5006
4665
|
/* Auth */
|
|
4666
|
+
userProfile: "个人资料",
|
|
5007
4667
|
noAccountPrompt: "没有账号?",
|
|
5008
4668
|
haveAccountPrompt: "已有账号?",
|
|
5009
4669
|
forgetPassword: "忘记密码",
|
|
5010
4670
|
resetPassword: "重置密码",
|
|
4671
|
+
changePassword: "修改密码",
|
|
4672
|
+
confirmPassword: "确认密码",
|
|
4673
|
+
passwordMismatch: "两次输入的密码不一致",
|
|
5011
4674
|
verificationCode: "验证码",
|
|
5012
4675
|
verifySend: "发送验证码",
|
|
5013
4676
|
verifyResend: "重新发送",
|
|
@@ -5016,7 +4679,7 @@ const zhCN = {
|
|
|
5016
4679
|
password: "密码",
|
|
5017
4680
|
username: "用户名",
|
|
5018
4681
|
nextStep: "下一步",
|
|
5019
|
-
|
|
4682
|
+
skipVerify: "跳过验证",
|
|
5020
4683
|
logoutConfirm: "确定要退出登录吗?",
|
|
5021
4684
|
accountMergeNotice: "您的电子邮件下有多个不同 ID 的账户。",
|
|
5022
4685
|
accountMergeSelectOne: "请选择将所有数据合并到其中的一个。",
|
|
@@ -5062,8 +4725,7 @@ function findLocaleSet(lang) {
|
|
|
5062
4725
|
let LocaleConf = "en";
|
|
5063
4726
|
let LocaleDict = findLocaleSet(LocaleConf);
|
|
5064
4727
|
function setLocale(locale) {
|
|
5065
|
-
if (locale === LocaleConf)
|
|
5066
|
-
return;
|
|
4728
|
+
if (locale === LocaleConf) return;
|
|
5067
4729
|
LocaleConf = locale;
|
|
5068
4730
|
LocaleDict = typeof locale === "string" ? findLocaleSet(locale) : locale;
|
|
5069
4731
|
}
|
|
@@ -5089,8 +4751,7 @@ class EventManager {
|
|
|
5089
4751
|
* Remove an event listener for a specific event name and handler
|
|
5090
4752
|
*/
|
|
5091
4753
|
off(name, handler) {
|
|
5092
|
-
if (!handler)
|
|
5093
|
-
return;
|
|
4754
|
+
if (!handler) return;
|
|
5094
4755
|
this.events = this.events.filter((evt) => !(evt.name === name && evt.handler === handler));
|
|
5095
4756
|
}
|
|
5096
4757
|
/**
|
|
@@ -5098,8 +4759,7 @@ class EventManager {
|
|
|
5098
4759
|
*/
|
|
5099
4760
|
trigger(name, payload) {
|
|
5100
4761
|
this.events.slice(0).filter((evt) => evt.name === name && typeof evt.handler === "function").forEach((evt) => {
|
|
5101
|
-
if (evt.once)
|
|
5102
|
-
this.off(name, evt.handler);
|
|
4762
|
+
if (evt.once) this.off(name, evt.handler);
|
|
5103
4763
|
evt.handler(payload);
|
|
5104
4764
|
});
|
|
5105
4765
|
}
|
|
@@ -5152,26 +4812,19 @@ function handelCustomConf(customConf, full = false) {
|
|
|
5152
4812
|
if (conf.el && typeof conf.el === "string") {
|
|
5153
4813
|
try {
|
|
5154
4814
|
const findEl = document.querySelector(conf.el);
|
|
5155
|
-
if (!findEl)
|
|
5156
|
-
throw Error(`Target element "${conf.el}" was not found.`);
|
|
4815
|
+
if (!findEl) throw Error(`Target element "${conf.el}" was not found.`);
|
|
5157
4816
|
conf.el = findEl;
|
|
5158
4817
|
} catch (e) {
|
|
5159
4818
|
console.error(e);
|
|
5160
4819
|
throw new Error("Please check your Artalk `el` config.");
|
|
5161
4820
|
}
|
|
5162
4821
|
}
|
|
5163
|
-
if (conf.pageKey === "")
|
|
5164
|
-
|
|
5165
|
-
if (conf.
|
|
5166
|
-
|
|
5167
|
-
if (conf.
|
|
5168
|
-
|
|
5169
|
-
if (conf.locale === "auto")
|
|
5170
|
-
conf.locale = navigator.language;
|
|
5171
|
-
if (conf.flatMode === "auto")
|
|
5172
|
-
conf.flatMode = window.matchMedia("(max-width: 768px)").matches;
|
|
5173
|
-
if (typeof conf.nestMax === "number" && Number(conf.nestMax) <= 1)
|
|
5174
|
-
conf.flatMode = true;
|
|
4822
|
+
if (conf.pageKey === "") conf.pageKey = `${window.location.pathname}`;
|
|
4823
|
+
if (conf.pageTitle === "") conf.pageTitle = `${document.title}`;
|
|
4824
|
+
if (conf.server) conf.server = conf.server.replace(/\/$/, "").replace(/\/api\/?$/, "");
|
|
4825
|
+
if (conf.locale === "auto") conf.locale = navigator.language;
|
|
4826
|
+
if (conf.flatMode === "auto") conf.flatMode = window.matchMedia("(max-width: 768px)").matches;
|
|
4827
|
+
if (typeof conf.nestMax === "number" && Number(conf.nestMax) <= 1) conf.flatMode = true;
|
|
5175
4828
|
return conf;
|
|
5176
4829
|
}
|
|
5177
4830
|
function handleConfFormServer(conf) {
|
|
@@ -5186,10 +4839,8 @@ function handleConfFormServer(conf) {
|
|
|
5186
4839
|
"statPageKeyAttr"
|
|
5187
4840
|
];
|
|
5188
4841
|
Object.keys(conf).forEach((k) => {
|
|
5189
|
-
if (ExcludedKeys.includes(k))
|
|
5190
|
-
|
|
5191
|
-
if (k === "darkMode" && conf[k] !== "auto")
|
|
5192
|
-
delete conf[k];
|
|
4842
|
+
if (ExcludedKeys.includes(k)) delete conf[k];
|
|
4843
|
+
if (k === "darkMode" && conf[k] !== "auto") delete conf[k];
|
|
5193
4844
|
});
|
|
5194
4845
|
if (conf.emoticons && typeof conf.emoticons === "string") {
|
|
5195
4846
|
conf.emoticons = conf.emoticons.trim();
|
|
@@ -5210,7 +4861,7 @@ function convertApiOptions(conf, ctx) {
|
|
|
5210
4861
|
timeout: conf.reqTimeout,
|
|
5211
4862
|
getApiToken: () => ctx == null ? void 0 : ctx.get("user").getData().token,
|
|
5212
4863
|
userInfo: (ctx == null ? void 0 : ctx.get("user").checkHasBasicUserInfo()) ? {
|
|
5213
|
-
name: ctx == null ? void 0 : ctx.get("user").getData().
|
|
4864
|
+
name: ctx == null ? void 0 : ctx.get("user").getData().name,
|
|
5214
4865
|
email: ctx == null ? void 0 : ctx.get("user").getData().email
|
|
5215
4866
|
} : void 0,
|
|
5216
4867
|
handlers: ctx == null ? void 0 : ctx.getApiHandlers()
|
|
@@ -5260,6 +4911,7 @@ class Context {
|
|
|
5260
4911
|
this.$root = conf.el;
|
|
5261
4912
|
this.$root.classList.add("artalk");
|
|
5262
4913
|
this.$root.innerHTML = "";
|
|
4914
|
+
conf.darkMode && this.$root.classList.add("atk-dark-mode");
|
|
5263
4915
|
this.data = new DataManager(this.events);
|
|
5264
4916
|
this.on("mounted", () => {
|
|
5265
4917
|
this.mounted = true;
|
|
@@ -5275,8 +4927,7 @@ class Context {
|
|
|
5275
4927
|
return new Api2(convertApiOptions(this.conf, this));
|
|
5276
4928
|
}
|
|
5277
4929
|
getApiHandlers() {
|
|
5278
|
-
if (!this.apiHandlers)
|
|
5279
|
-
this.apiHandlers = createNewApiHandlers(this);
|
|
4930
|
+
if (!this.apiHandlers) this.apiHandlers = createNewApiHandlers(this);
|
|
5280
4931
|
return this.apiHandlers;
|
|
5281
4932
|
}
|
|
5282
4933
|
getData() {
|
|
@@ -5375,8 +5026,7 @@ function showLoading(parentElem, conf) {
|
|
|
5375
5026
|
</div>
|
|
5376
5027
|
</div>`
|
|
5377
5028
|
);
|
|
5378
|
-
if (conf == null ? void 0 : conf.transparentBg)
|
|
5379
|
-
$loading.style.background = "transparent";
|
|
5029
|
+
if (conf == null ? void 0 : conf.transparentBg) $loading.style.background = "transparent";
|
|
5380
5030
|
parentElem.appendChild($loading);
|
|
5381
5031
|
}
|
|
5382
5032
|
$loading.style.display = "";
|
|
@@ -5384,21 +5034,17 @@ function showLoading(parentElem, conf) {
|
|
|
5384
5034
|
if ($spinner) {
|
|
5385
5035
|
$spinner.style.display = "none";
|
|
5386
5036
|
window.setTimeout(() => {
|
|
5387
|
-
if ($spinner.isConnected)
|
|
5388
|
-
$spinner.style.display = "";
|
|
5037
|
+
if ($spinner.isConnected) $spinner.style.display = "";
|
|
5389
5038
|
}, 500);
|
|
5390
5039
|
}
|
|
5391
5040
|
}
|
|
5392
5041
|
function hideLoading(parentElem) {
|
|
5393
5042
|
const $loading = parentElem.querySelector(":scope > .atk-loading");
|
|
5394
|
-
if ($loading)
|
|
5395
|
-
$loading.style.display = "none";
|
|
5043
|
+
if ($loading) $loading.style.display = "none";
|
|
5396
5044
|
}
|
|
5397
5045
|
function setLoading(val, parentElem) {
|
|
5398
|
-
if (val)
|
|
5399
|
-
|
|
5400
|
-
else
|
|
5401
|
-
hideLoading(parentElem);
|
|
5046
|
+
if (val) showLoading(parentElem);
|
|
5047
|
+
else hideLoading(parentElem);
|
|
5402
5048
|
}
|
|
5403
5049
|
function scrollIntoView(elem, enableAnim = true, relativeTo) {
|
|
5404
5050
|
let top;
|
|
@@ -5417,10 +5063,8 @@ function scrollIntoView(elem, enableAnim = true, relativeTo) {
|
|
|
5417
5063
|
// behavior: enableAnim ? 'smooth' : 'instant',
|
|
5418
5064
|
behavior: "instant"
|
|
5419
5065
|
};
|
|
5420
|
-
if (relativeTo)
|
|
5421
|
-
|
|
5422
|
-
else
|
|
5423
|
-
window.scroll(scrollOptions);
|
|
5066
|
+
if (relativeTo) relativeTo.scroll(scrollOptions);
|
|
5067
|
+
else window.scroll(scrollOptions);
|
|
5424
5068
|
}
|
|
5425
5069
|
function showNotify(wrapElem, msg, type) {
|
|
5426
5070
|
const colors = { s: "#57d59f", e: "#ff6f6c", w: "#ffc721", i: "#2ebcfc" };
|
|
@@ -5462,8 +5106,7 @@ function playFadeInAnim(elem, after) {
|
|
|
5462
5106
|
function setError(parentElem, html2, title = '<span class="atk-error-title">Artalk Error</span>') {
|
|
5463
5107
|
let elem = parentElem.querySelector(".atk-error-layer");
|
|
5464
5108
|
if (html2 === null) {
|
|
5465
|
-
if (elem !== null)
|
|
5466
|
-
elem.remove();
|
|
5109
|
+
if (elem !== null) elem.remove();
|
|
5467
5110
|
return;
|
|
5468
5111
|
}
|
|
5469
5112
|
if (!elem) {
|
|
@@ -5474,8 +5117,7 @@ function setError(parentElem, html2, title = '<span class="atk-error-title">Arta
|
|
|
5474
5117
|
}
|
|
5475
5118
|
const errorTextEl = elem.querySelector(".atk-error-text");
|
|
5476
5119
|
errorTextEl.innerHTML = "";
|
|
5477
|
-
if (html2 === null)
|
|
5478
|
-
return;
|
|
5120
|
+
if (html2 === null) return;
|
|
5479
5121
|
if (html2 instanceof HTMLElement) {
|
|
5480
5122
|
errorTextEl.appendChild(html2);
|
|
5481
5123
|
} else {
|
|
@@ -5499,8 +5141,7 @@ function getScrollBarWidth() {
|
|
|
5499
5141
|
const w1 = inner.offsetWidth;
|
|
5500
5142
|
outer.style.overflow = "scroll";
|
|
5501
5143
|
let w2 = inner.offsetWidth;
|
|
5502
|
-
if (w1 === w2)
|
|
5503
|
-
w2 = outer.clientWidth;
|
|
5144
|
+
if (w1 === w2) w2 = outer.clientWidth;
|
|
5504
5145
|
document.body.removeChild(outer);
|
|
5505
5146
|
return w1 - w2;
|
|
5506
5147
|
}
|
|
@@ -5545,8 +5186,7 @@ function iframeBody(checker) {
|
|
|
5545
5186
|
(function queryStatus() {
|
|
5546
5187
|
return __async(this, null, function* () {
|
|
5547
5188
|
yield sleep(1e3);
|
|
5548
|
-
if (stop)
|
|
5549
|
-
return;
|
|
5189
|
+
if (stop) return;
|
|
5550
5190
|
let isPass = false;
|
|
5551
5191
|
try {
|
|
5552
5192
|
const resp = yield checker.getApi().captcha.getCaptchaStatus();
|
|
@@ -5574,8 +5214,7 @@ const CaptchaChecker = {
|
|
|
5574
5214
|
});
|
|
5575
5215
|
},
|
|
5576
5216
|
body(checker) {
|
|
5577
|
-
if (checker.get("iframe"))
|
|
5578
|
-
return iframeBody(checker);
|
|
5217
|
+
if (checker.get("iframe")) return iframeBody(checker);
|
|
5579
5218
|
return imgBody(checker);
|
|
5580
5219
|
},
|
|
5581
5220
|
onSuccess(checker, data, inputVal, formEl) {
|
|
@@ -5591,7 +5230,7 @@ const AdminChecker = {
|
|
|
5591
5230
|
request(checker, inputVal) {
|
|
5592
5231
|
return __async(this, null, function* () {
|
|
5593
5232
|
return (yield checker.getApi().user.login({
|
|
5594
|
-
name: checker.getUser().getData().
|
|
5233
|
+
name: checker.getUser().getData().name,
|
|
5595
5234
|
email: checker.getUser().getData().email,
|
|
5596
5235
|
password: inputVal
|
|
5597
5236
|
})).data;
|
|
@@ -5602,7 +5241,7 @@ const AdminChecker = {
|
|
|
5602
5241
|
},
|
|
5603
5242
|
onSuccess(checker, res, inputVal, formEl) {
|
|
5604
5243
|
checker.getUser().update({
|
|
5605
|
-
|
|
5244
|
+
is_admin: true,
|
|
5606
5245
|
token: res.token
|
|
5607
5246
|
});
|
|
5608
5247
|
checker.getOpts().onReload();
|
|
@@ -5703,19 +5342,15 @@ class CheckerLauncher {
|
|
|
5703
5342
|
},
|
|
5704
5343
|
triggerSuccess: () => {
|
|
5705
5344
|
close();
|
|
5706
|
-
if (checker.onSuccess)
|
|
5707
|
-
|
|
5708
|
-
if (payload.onSuccess)
|
|
5709
|
-
payload.onSuccess();
|
|
5345
|
+
if (checker.onSuccess) checker.onSuccess(checkerCtx, "", "", formEl);
|
|
5346
|
+
if (payload.onSuccess) payload.onSuccess();
|
|
5710
5347
|
},
|
|
5711
5348
|
cancel: () => {
|
|
5712
5349
|
close();
|
|
5713
|
-
if (payload.onCancel)
|
|
5714
|
-
payload.onCancel();
|
|
5350
|
+
if (payload.onCancel) payload.onCancel();
|
|
5715
5351
|
}
|
|
5716
5352
|
};
|
|
5717
|
-
if (postFire)
|
|
5718
|
-
postFire(checkerCtx);
|
|
5353
|
+
if (postFire) postFire(checkerCtx);
|
|
5719
5354
|
const formEl = createElement();
|
|
5720
5355
|
formEl.appendChild(checker.body(checkerCtx));
|
|
5721
5356
|
const $input = createElement(
|
|
@@ -5733,8 +5368,7 @@ class CheckerLauncher {
|
|
|
5733
5368
|
const dialog = new Dialog(formEl);
|
|
5734
5369
|
dialog.setYes((btnEl) => {
|
|
5735
5370
|
const inputVal = $input.value.trim();
|
|
5736
|
-
if (!btnTextOrg)
|
|
5737
|
-
btnTextOrg = btnEl.innerText;
|
|
5371
|
+
if (!btnTextOrg) btnTextOrg = btnEl.innerText;
|
|
5738
5372
|
const btnTextSet = (btnText) => {
|
|
5739
5373
|
btnEl.innerText = btnText;
|
|
5740
5374
|
btnEl.classList.add("error");
|
|
@@ -5746,14 +5380,11 @@ class CheckerLauncher {
|
|
|
5746
5380
|
btnEl.innerText = `${t("loading")}...`;
|
|
5747
5381
|
checker.request(checkerCtx, inputVal).then((data) => {
|
|
5748
5382
|
close();
|
|
5749
|
-
if (checker.onSuccess)
|
|
5750
|
-
|
|
5751
|
-
if (payload.onSuccess)
|
|
5752
|
-
payload.onSuccess();
|
|
5383
|
+
if (checker.onSuccess) checker.onSuccess(checkerCtx, data, inputVal, formEl);
|
|
5384
|
+
if (payload.onSuccess) payload.onSuccess();
|
|
5753
5385
|
}).catch((err) => {
|
|
5754
5386
|
btnTextSet(String(err.message || String(err)));
|
|
5755
|
-
if (checker.onError)
|
|
5756
|
-
checker.onError(checkerCtx, err, inputVal, formEl);
|
|
5387
|
+
if (checker.onError) checker.onError(checkerCtx, err, inputVal, formEl);
|
|
5757
5388
|
const tf = setTimeout(() => btnTextRestore(), 3e3);
|
|
5758
5389
|
$input.onfocus = () => {
|
|
5759
5390
|
btnTextRestore();
|
|
@@ -5764,8 +5395,7 @@ class CheckerLauncher {
|
|
|
5764
5395
|
});
|
|
5765
5396
|
dialog.setNo(() => {
|
|
5766
5397
|
close();
|
|
5767
|
-
if (payload.onCancel)
|
|
5768
|
-
payload.onCancel();
|
|
5398
|
+
if (payload.onCancel) payload.onCancel();
|
|
5769
5399
|
return false;
|
|
5770
5400
|
});
|
|
5771
5401
|
if (hideInteractInput) {
|
|
@@ -5773,8 +5403,7 @@ class CheckerLauncher {
|
|
|
5773
5403
|
dialog.$el.querySelector(".atk-layer-dialog-actions").style.display = "none";
|
|
5774
5404
|
}
|
|
5775
5405
|
layer.getEl().append(dialog.$el);
|
|
5776
|
-
if (payload.onMount)
|
|
5777
|
-
payload.onMount(dialog.$el);
|
|
5406
|
+
if (payload.onMount) payload.onMount(dialog.$el);
|
|
5778
5407
|
}
|
|
5779
5408
|
}
|
|
5780
5409
|
class Component {
|
|
@@ -5789,10 +5418,10 @@ class Component {
|
|
|
5789
5418
|
return this.$el;
|
|
5790
5419
|
}
|
|
5791
5420
|
}
|
|
5792
|
-
const EditorHTML = '<div class="atk-main-editor">\n <div class="atk-header">\n <input name="
|
|
5421
|
+
const EditorHTML = '<div class="atk-main-editor">\n <div class="atk-header">\n <input name="name" class="atk-name" type="text" required="required" />\n <input name="email" class="atk-email" type="email" required="required" />\n <input name="link" class="atk-link" type="url" />\n </div>\n <div class="atk-textarea-wrap">\n <textarea class="atk-textarea"></textarea>\n </div>\n <div class="atk-plug-panel-wrap" style="display: none"></div>\n <div class="atk-bottom">\n <div class="atk-item atk-bottom-left">\n <span class="atk-state-wrap"></span>\n <span class="atk-plug-btn-wrap"></span>\n </div>\n <div class="atk-item">\n <button type="button" class="atk-send-btn"></button>\n </div>\n </div>\n <div class="atk-notify-wrap"></div>\n</div>\n';
|
|
5793
5422
|
const Sel = {
|
|
5794
5423
|
$header: ".atk-header",
|
|
5795
|
-
$
|
|
5424
|
+
$name: '.atk-header [name="name"]',
|
|
5796
5425
|
$email: '.atk-header [name="email"]',
|
|
5797
5426
|
$link: '.atk-header [name="link"]',
|
|
5798
5427
|
$textareaWrap: ".atk-textarea-wrap",
|
|
@@ -5815,6 +5444,9 @@ function render() {
|
|
|
5815
5444
|
}
|
|
5816
5445
|
class EditorPlug {
|
|
5817
5446
|
constructor(kit) {
|
|
5447
|
+
__publicField(this, "$btn");
|
|
5448
|
+
__publicField(this, "$panel");
|
|
5449
|
+
__publicField(this, "editorStateEffectWhen");
|
|
5818
5450
|
this.kit = kit;
|
|
5819
5451
|
}
|
|
5820
5452
|
/** Use plug btn will add a btn on the bottom of editor */
|
|
@@ -5834,15 +5466,13 @@ class EditorPlug {
|
|
|
5834
5466
|
/** Listen the event of panel show */
|
|
5835
5467
|
usePanelShow(func) {
|
|
5836
5468
|
this.kit.useEvents().on("panel-show", (aPlug) => {
|
|
5837
|
-
if (aPlug === this)
|
|
5838
|
-
func();
|
|
5469
|
+
if (aPlug === this) func();
|
|
5839
5470
|
});
|
|
5840
5471
|
}
|
|
5841
5472
|
/** Listen the event of panel hide */
|
|
5842
5473
|
usePanelHide(func) {
|
|
5843
5474
|
this.kit.useEvents().on("panel-hide", (aPlug) => {
|
|
5844
|
-
if (aPlug === this)
|
|
5845
|
-
func();
|
|
5475
|
+
if (aPlug === this) func();
|
|
5846
5476
|
});
|
|
5847
5477
|
}
|
|
5848
5478
|
/** Use editor state modifier */
|
|
@@ -5857,8 +5487,7 @@ class Mover extends EditorPlug {
|
|
|
5857
5487
|
__publicField(this, "isMoved", false);
|
|
5858
5488
|
}
|
|
5859
5489
|
move(afterEl) {
|
|
5860
|
-
if (this.isMoved)
|
|
5861
|
-
return;
|
|
5490
|
+
if (this.isMoved) return;
|
|
5862
5491
|
this.isMoved = true;
|
|
5863
5492
|
const editorEl = this.kit.useUI().$el;
|
|
5864
5493
|
editorEl.after(createElement('<div class="atk-editor-travel-placeholder"></div>'));
|
|
@@ -5870,8 +5499,7 @@ class Mover extends EditorPlug {
|
|
|
5870
5499
|
}
|
|
5871
5500
|
back() {
|
|
5872
5501
|
var _a;
|
|
5873
|
-
if (!this.isMoved)
|
|
5874
|
-
return;
|
|
5502
|
+
if (!this.isMoved) return;
|
|
5875
5503
|
this.isMoved = false;
|
|
5876
5504
|
(_a = this.kit.useGlobalCtx().$root.querySelector(".atk-editor-travel-placeholder")) == null ? void 0 : _a.replaceWith(this.kit.useUI().$el);
|
|
5877
5505
|
this.kit.useUI().$el.classList.remove("editor-traveling");
|
|
@@ -5934,13 +5562,12 @@ class Editor extends Component {
|
|
|
5934
5562
|
return this.state.get();
|
|
5935
5563
|
}
|
|
5936
5564
|
getHeaderInputEls() {
|
|
5937
|
-
return {
|
|
5565
|
+
return { name: this.ui.$name, email: this.ui.$email, link: this.ui.$link };
|
|
5938
5566
|
}
|
|
5939
5567
|
getContentFinal() {
|
|
5940
5568
|
let content = this.getContentRaw();
|
|
5941
5569
|
const plugs = this.getPlugs();
|
|
5942
|
-
if (plugs)
|
|
5943
|
-
content = plugs.getTransformedContent(content);
|
|
5570
|
+
if (plugs) content = plugs.getTransformedContent(content);
|
|
5944
5571
|
return content;
|
|
5945
5572
|
}
|
|
5946
5573
|
getContentRaw() {
|
|
@@ -6018,8 +5645,8 @@ class SidebarLayer extends Component {
|
|
|
6018
5645
|
__publicField(this, "$closeBtn");
|
|
6019
5646
|
__publicField(this, "$iframeWrap");
|
|
6020
5647
|
__publicField(this, "$iframe");
|
|
6021
|
-
/** Refresh iFrame
|
|
6022
|
-
__publicField(this, "
|
|
5648
|
+
/** Refresh iFrame when show */
|
|
5649
|
+
__publicField(this, "refreshWhenShow", true);
|
|
6023
5650
|
/** Animation timer */
|
|
6024
5651
|
__publicField(this, "animTimer");
|
|
6025
5652
|
this.$el = createElement(SidebarHTML);
|
|
@@ -6030,7 +5657,7 @@ class SidebarLayer extends Component {
|
|
|
6030
5657
|
this.hide();
|
|
6031
5658
|
};
|
|
6032
5659
|
this.ctx.on("user-changed", () => {
|
|
6033
|
-
this.
|
|
5660
|
+
this.refreshWhenShow = true;
|
|
6034
5661
|
});
|
|
6035
5662
|
}
|
|
6036
5663
|
/** 显示 */
|
|
@@ -6039,8 +5666,8 @@ class SidebarLayer extends Component {
|
|
|
6039
5666
|
this.$el.style.transform = "";
|
|
6040
5667
|
this.initLayer();
|
|
6041
5668
|
this.layer.show();
|
|
6042
|
-
if (this.
|
|
6043
|
-
this.
|
|
5669
|
+
if (this.refreshWhenShow) {
|
|
5670
|
+
this.refreshWhenShow = false;
|
|
6044
5671
|
this.$iframeWrap.innerHTML = "";
|
|
6045
5672
|
this.$iframe = this.createIframe(conf.view);
|
|
6046
5673
|
this.$iframeWrap.append(this.$iframe);
|
|
@@ -6050,7 +5677,7 @@ class SidebarLayer extends Component {
|
|
|
6050
5677
|
if (this.getDarkMode() !== iFrameSrc.includes("&darkMode=1")) {
|
|
6051
5678
|
this.iframeLoad(
|
|
6052
5679
|
$iframe,
|
|
6053
|
-
|
|
5680
|
+
iFrameSrc.replace(/&darkMode=\d/, `&darkMode=${Number(this.getDarkMode())}`)
|
|
6054
5681
|
);
|
|
6055
5682
|
}
|
|
6056
5683
|
}
|
|
@@ -6078,7 +5705,7 @@ class SidebarLayer extends Component {
|
|
|
6078
5705
|
return __async(this, null, function* () {
|
|
6079
5706
|
const data = (yield this.ctx.getApi().user.getUserStatus(__spreadValues({}, this.ctx.getApi().getUserFields()))).data;
|
|
6080
5707
|
if (data.is_admin && !data.is_login) {
|
|
6081
|
-
this.
|
|
5708
|
+
this.refreshWhenShow = true;
|
|
6082
5709
|
this.ctx.checkAdmin({
|
|
6083
5710
|
onSuccess: () => {
|
|
6084
5711
|
setTimeout(() => {
|
|
@@ -6094,8 +5721,7 @@ class SidebarLayer extends Component {
|
|
|
6094
5721
|
});
|
|
6095
5722
|
}
|
|
6096
5723
|
initLayer() {
|
|
6097
|
-
if (this.layer)
|
|
6098
|
-
return;
|
|
5724
|
+
if (this.layer) return;
|
|
6099
5725
|
this.layer = this.ctx.get("layerManager").create("sidebar", this.$el);
|
|
6100
5726
|
this.layer.setOnAfterHide(() => {
|
|
6101
5727
|
this.ctx.editorResetState();
|
|
@@ -6118,10 +5744,8 @@ class SidebarLayer extends Component {
|
|
|
6118
5744
|
user: JSON.stringify(this.ctx.get("user").getData()),
|
|
6119
5745
|
time: +/* @__PURE__ */ new Date()
|
|
6120
5746
|
};
|
|
6121
|
-
if (view)
|
|
6122
|
-
|
|
6123
|
-
if (this.getDarkMode())
|
|
6124
|
-
query.darkMode = "1";
|
|
5747
|
+
if (view) query.view = view;
|
|
5748
|
+
query.darkMode = this.getDarkMode() ? "1" : "0";
|
|
6125
5749
|
const urlParams = new URLSearchParams(query);
|
|
6126
5750
|
this.iframeLoad($iframe, `${baseURL}?${urlParams.toString()}`);
|
|
6127
5751
|
return $iframe;
|
|
@@ -6152,10 +5776,8 @@ function makeNestCommentNodeList(srcData, sortBy = "DATE_DESC", nestMax = 2) {
|
|
|
6152
5776
|
nodeList.push(rootNode);
|
|
6153
5777
|
(function loadChildren(parentNode) {
|
|
6154
5778
|
const children = srcData.filter((o) => o.rid === parentNode.id);
|
|
6155
|
-
if (children.length === 0)
|
|
6156
|
-
|
|
6157
|
-
if (parentNode.level >= nestMax)
|
|
6158
|
-
parentNode = parentNode.parent;
|
|
5779
|
+
if (children.length === 0) return;
|
|
5780
|
+
if (parentNode.level >= nestMax) parentNode = parentNode.parent;
|
|
6159
5781
|
children.forEach((child) => {
|
|
6160
5782
|
const childNode = {
|
|
6161
5783
|
id: child.id,
|
|
@@ -6171,14 +5793,10 @@ function makeNestCommentNodeList(srcData, sortBy = "DATE_DESC", nestMax = 2) {
|
|
|
6171
5793
|
});
|
|
6172
5794
|
const sortFunc = (a, b) => {
|
|
6173
5795
|
let v = a.id - b.id;
|
|
6174
|
-
if (sortBy === "DATE_ASC")
|
|
6175
|
-
|
|
6176
|
-
else if (sortBy === "
|
|
6177
|
-
|
|
6178
|
-
else if (sortBy === "SRC_INDEX")
|
|
6179
|
-
v = srcData.indexOf(a.comment) - srcData.indexOf(b.comment);
|
|
6180
|
-
else if (sortBy === "VOTE_UP_DESC")
|
|
6181
|
-
v = b.comment.vote_up - a.comment.vote_up;
|
|
5796
|
+
if (sortBy === "DATE_ASC") v = +new Date(a.comment.date) - +new Date(b.comment.date);
|
|
5797
|
+
else if (sortBy === "DATE_DESC") v = +new Date(b.comment.date) - +new Date(a.comment.date);
|
|
5798
|
+
else if (sortBy === "SRC_INDEX") v = srcData.indexOf(a.comment) - srcData.indexOf(b.comment);
|
|
5799
|
+
else if (sortBy === "VOTE_UP_DESC") v = b.comment.vote_up - a.comment.vote_up;
|
|
6182
5800
|
return v;
|
|
6183
5801
|
};
|
|
6184
5802
|
(function sortLevels(nodes) {
|
|
@@ -6242,16 +5860,13 @@ const createFlatStrategy = (opts) => ({
|
|
|
6242
5860
|
}
|
|
6243
5861
|
});
|
|
6244
5862
|
function insertComment(opts, insertMode, comment, replyComment) {
|
|
6245
|
-
if (comment.is_collapsed)
|
|
6246
|
-
comment.is_allow_reply = false;
|
|
5863
|
+
if (comment.is_collapsed) comment.is_allow_reply = false;
|
|
6247
5864
|
const node = opts.createCommentNode(comment, replyComment);
|
|
6248
5865
|
if (comment.visible) {
|
|
6249
5866
|
const $comment = node.getEl();
|
|
6250
5867
|
const $listCommentsWrap = opts.$commentsWrap;
|
|
6251
|
-
if (insertMode === "append")
|
|
6252
|
-
|
|
6253
|
-
if (insertMode === "prepend")
|
|
6254
|
-
$listCommentsWrap == null ? void 0 : $listCommentsWrap.prepend($comment);
|
|
5868
|
+
if (insertMode === "append") $listCommentsWrap == null ? void 0 : $listCommentsWrap.append($comment);
|
|
5869
|
+
if (insertMode === "prepend") $listCommentsWrap == null ? void 0 : $listCommentsWrap.prepend($comment);
|
|
6255
5870
|
node.getRender().playFadeAnim();
|
|
6256
5871
|
}
|
|
6257
5872
|
node.getRender().checkHeightLimit();
|
|
@@ -6356,8 +5971,7 @@ function Detect(userAgent) {
|
|
|
6356
5971
|
dest.language = (() => {
|
|
6357
5972
|
const g = nav.browserLanguage || nav.language;
|
|
6358
5973
|
const arr = g.split("-");
|
|
6359
|
-
if (arr[1])
|
|
6360
|
-
arr[1] = arr[1].toUpperCase();
|
|
5974
|
+
if (arr[1]) arr[1] = arr[1].toUpperCase();
|
|
6361
5975
|
return arr.join("_");
|
|
6362
5976
|
})();
|
|
6363
5977
|
const hash = {
|
|
@@ -6368,8 +5982,7 @@ function Detect(userAgent) {
|
|
|
6368
5982
|
};
|
|
6369
5983
|
Object.entries(hash).forEach(([type, match]) => {
|
|
6370
5984
|
Object.entries(match).forEach(([name, result]) => {
|
|
6371
|
-
if (result === true)
|
|
6372
|
-
dest[type] = name;
|
|
5985
|
+
if (result === true) dest[type] = name;
|
|
6373
5986
|
});
|
|
6374
5987
|
});
|
|
6375
5988
|
const osVersion = {
|
|
@@ -6464,16 +6077,12 @@ function Detect(userAgent) {
|
|
|
6464
6077
|
}
|
|
6465
6078
|
function check(conf, rules) {
|
|
6466
6079
|
rules.forEach(({ el, max, imgCheck }) => {
|
|
6467
|
-
if (!el)
|
|
6468
|
-
|
|
6469
|
-
if (imgCheck)
|
|
6470
|
-
el.style.maxHeight = `${max + 1}px`;
|
|
6080
|
+
if (!el) return;
|
|
6081
|
+
if (imgCheck) el.style.maxHeight = `${max + 1}px`;
|
|
6471
6082
|
let lock = false;
|
|
6472
6083
|
const _check = () => {
|
|
6473
|
-
if (lock)
|
|
6474
|
-
|
|
6475
|
-
if (getHeight(el) <= max)
|
|
6476
|
-
return;
|
|
6084
|
+
if (lock) return;
|
|
6085
|
+
if (getHeight(el) <= max) return;
|
|
6477
6086
|
const afterExpandBtnClick = () => {
|
|
6478
6087
|
var _a;
|
|
6479
6088
|
lock = true;
|
|
@@ -6484,8 +6093,7 @@ function check(conf, rules) {
|
|
|
6484
6093
|
_check();
|
|
6485
6094
|
if (imgCheck) {
|
|
6486
6095
|
const imgs = el.querySelectorAll(".atk-content img");
|
|
6487
|
-
if (imgs.length === 0)
|
|
6488
|
-
el.style.maxHeight = "";
|
|
6096
|
+
if (imgs.length === 0) el.style.maxHeight = "";
|
|
6489
6097
|
imgs.forEach((img) => {
|
|
6490
6098
|
img.onload = () => _check();
|
|
6491
6099
|
});
|
|
@@ -6494,12 +6102,9 @@ function check(conf, rules) {
|
|
|
6494
6102
|
}
|
|
6495
6103
|
const HEIGHT_LIMIT_CSS = "atk-height-limit";
|
|
6496
6104
|
function applyHeightLimit(obj) {
|
|
6497
|
-
if (!obj.el)
|
|
6498
|
-
|
|
6499
|
-
if (
|
|
6500
|
-
return;
|
|
6501
|
-
if (obj.el.classList.contains(HEIGHT_LIMIT_CSS))
|
|
6502
|
-
return;
|
|
6105
|
+
if (!obj.el) return;
|
|
6106
|
+
if (!obj.max) return;
|
|
6107
|
+
if (obj.el.classList.contains(HEIGHT_LIMIT_CSS)) return;
|
|
6503
6108
|
obj.el.classList.add(HEIGHT_LIMIT_CSS);
|
|
6504
6109
|
obj.el.style.height = `${obj.max}px`;
|
|
6505
6110
|
obj.el.style.overflow = "hidden";
|
|
@@ -6509,20 +6114,16 @@ function applyHeightLimit(obj) {
|
|
|
6509
6114
|
$expandBtn.onclick = (e) => {
|
|
6510
6115
|
e.stopPropagation();
|
|
6511
6116
|
disposeHeightLimit(obj.el);
|
|
6512
|
-
if (obj.afterExpandBtnClick)
|
|
6513
|
-
obj.afterExpandBtnClick(e);
|
|
6117
|
+
if (obj.afterExpandBtnClick) obj.afterExpandBtnClick(e);
|
|
6514
6118
|
};
|
|
6515
6119
|
obj.el.append($expandBtn);
|
|
6516
6120
|
}
|
|
6517
6121
|
function disposeHeightLimit($el) {
|
|
6518
|
-
if (!$el)
|
|
6519
|
-
|
|
6520
|
-
if (!$el.classList.contains(HEIGHT_LIMIT_CSS))
|
|
6521
|
-
return;
|
|
6122
|
+
if (!$el) return;
|
|
6123
|
+
if (!$el.classList.contains(HEIGHT_LIMIT_CSS)) return;
|
|
6522
6124
|
$el.classList.remove(HEIGHT_LIMIT_CSS);
|
|
6523
6125
|
Array.from($el.children).forEach((e) => {
|
|
6524
|
-
if (e.classList.contains("atk-height-limit-btn"))
|
|
6525
|
-
e.remove();
|
|
6126
|
+
if (e.classList.contains("atk-height-limit-btn")) e.remove();
|
|
6526
6127
|
});
|
|
6527
6128
|
$el.style.height = "";
|
|
6528
6129
|
$el.style.maxHeight = "";
|
|
@@ -6530,10 +6131,8 @@ function disposeHeightLimit($el) {
|
|
|
6530
6131
|
}
|
|
6531
6132
|
const HEIGHT_LIMIT_SCROLL_CSS = "atk-height-limit-scroll";
|
|
6532
6133
|
function applyScrollableHeightLimit(opt) {
|
|
6533
|
-
if (!opt.el)
|
|
6534
|
-
|
|
6535
|
-
if (opt.el.classList.contains(HEIGHT_LIMIT_SCROLL_CSS))
|
|
6536
|
-
return;
|
|
6134
|
+
if (!opt.el) return;
|
|
6135
|
+
if (opt.el.classList.contains(HEIGHT_LIMIT_SCROLL_CSS)) return;
|
|
6537
6136
|
opt.el.classList.add(HEIGHT_LIMIT_SCROLL_CSS);
|
|
6538
6137
|
opt.el.style.height = `${opt.max}px`;
|
|
6539
6138
|
}
|
|
@@ -6604,8 +6203,7 @@ function renderDate(ctx) {
|
|
|
6604
6203
|
$date.setAttribute("data-atk-comment-date", String(+new Date(ctx.data.date)));
|
|
6605
6204
|
}
|
|
6606
6205
|
function renderUABadge(ctx) {
|
|
6607
|
-
if (!ctx.opts.uaBadge && !ctx.data.ip_region)
|
|
6608
|
-
return;
|
|
6206
|
+
if (!ctx.opts.uaBadge && !ctx.data.ip_region) return;
|
|
6609
6207
|
let $uaWrap = ctx.$header.querySelector("atk-ua-wrap");
|
|
6610
6208
|
if (!$uaWrap) {
|
|
6611
6209
|
$uaWrap = createElement(`<span class="atk-ua-wrap"></span>`);
|
|
@@ -6660,10 +6258,8 @@ function renderContent(r) {
|
|
|
6660
6258
|
});
|
|
6661
6259
|
}
|
|
6662
6260
|
function renderReplyAt(r) {
|
|
6663
|
-
if (r.opts.flatMode || r.data.rid === 0)
|
|
6664
|
-
|
|
6665
|
-
if (!r.opts.replyTo)
|
|
6666
|
-
return;
|
|
6261
|
+
if (r.opts.flatMode || r.data.rid === 0) return;
|
|
6262
|
+
if (!r.opts.replyTo) return;
|
|
6667
6263
|
r.$replyAt = createElement(
|
|
6668
6264
|
`<span class="atk-item atk-reply-at"><span class="atk-arrow"></span><span class="atk-nick"></span></span>`
|
|
6669
6265
|
);
|
|
@@ -6674,10 +6270,8 @@ function renderReplyAt(r) {
|
|
|
6674
6270
|
r.$headerBadgeWrap.insertAdjacentElement("afterend", r.$replyAt);
|
|
6675
6271
|
}
|
|
6676
6272
|
function renderReplyTo(r) {
|
|
6677
|
-
if (!r.opts.flatMode)
|
|
6678
|
-
|
|
6679
|
-
if (!r.opts.replyTo)
|
|
6680
|
-
return;
|
|
6273
|
+
if (!r.opts.flatMode) return;
|
|
6274
|
+
if (!r.opts.replyTo) return;
|
|
6681
6275
|
r.$replyTo = createElement(`
|
|
6682
6276
|
<div class="atk-reply-to">
|
|
6683
6277
|
<div class="atk-meta">${t("reply")} <span class="atk-nick"></span>:</div>
|
|
@@ -6689,14 +6283,12 @@ function renderReplyTo(r) {
|
|
|
6689
6283
|
r.comment.getActions().goToReplyComment();
|
|
6690
6284
|
};
|
|
6691
6285
|
let replyContent = marked(r.opts.replyTo.content);
|
|
6692
|
-
if (r.opts.replyTo.is_collapsed)
|
|
6693
|
-
replyContent = `[${t("collapsed")}]`;
|
|
6286
|
+
if (r.opts.replyTo.is_collapsed) replyContent = `[${t("collapsed")}]`;
|
|
6694
6287
|
r.$replyTo.querySelector(".atk-content").innerHTML = replyContent;
|
|
6695
6288
|
r.$body.prepend(r.$replyTo);
|
|
6696
6289
|
}
|
|
6697
6290
|
function renderPending(r) {
|
|
6698
|
-
if (!r.data.is_pending)
|
|
6699
|
-
return;
|
|
6291
|
+
if (!r.data.is_pending) return;
|
|
6700
6292
|
const pendingEl = createElement(`<div class="atk-pending">${t("pendingMsg")}</div>`);
|
|
6701
6293
|
r.$body.prepend(pendingEl);
|
|
6702
6294
|
}
|
|
@@ -6718,8 +6310,7 @@ class ActionBtn {
|
|
|
6718
6310
|
this.$el = createElement(`<span class="atk-common-action-btn"></span>`);
|
|
6719
6311
|
this.opts = typeof opts !== "object" ? { text: opts } : opts;
|
|
6720
6312
|
this.$el.innerText = this.getText();
|
|
6721
|
-
if (this.opts.adminOnly)
|
|
6722
|
-
this.$el.setAttribute("atk-only-admin-show", "");
|
|
6313
|
+
if (this.opts.adminOnly) this.$el.setAttribute("atk-only-admin-show", "");
|
|
6723
6314
|
}
|
|
6724
6315
|
// 消息显示复原操作
|
|
6725
6316
|
get isMessaging() {
|
|
@@ -6754,8 +6345,7 @@ class ActionBtn {
|
|
|
6754
6345
|
this.confirmRecTimer = window.setTimeout(() => confirmRestore(), 5e3);
|
|
6755
6346
|
return;
|
|
6756
6347
|
}
|
|
6757
|
-
if (this.confirmRecTimer)
|
|
6758
|
-
window.clearTimeout(this.confirmRecTimer);
|
|
6348
|
+
if (this.confirmRecTimer) window.clearTimeout(this.confirmRecTimer);
|
|
6759
6349
|
confirmRestore();
|
|
6760
6350
|
}
|
|
6761
6351
|
if (this.msgRecTimer) {
|
|
@@ -6768,15 +6358,13 @@ class ActionBtn {
|
|
|
6768
6358
|
}
|
|
6769
6359
|
/** 文字刷新(动态/静态) */
|
|
6770
6360
|
updateText(text) {
|
|
6771
|
-
if (text)
|
|
6772
|
-
this.opts.text = text;
|
|
6361
|
+
if (text) this.opts.text = text;
|
|
6773
6362
|
this.setLoading(false);
|
|
6774
6363
|
this.$el.innerText = this.getText();
|
|
6775
6364
|
}
|
|
6776
6365
|
/** 设置加载状态 */
|
|
6777
6366
|
setLoading(value, loadingText) {
|
|
6778
|
-
if (this.isLoading === value)
|
|
6779
|
-
return;
|
|
6367
|
+
if (this.isLoading === value) return;
|
|
6780
6368
|
this.isLoading = value;
|
|
6781
6369
|
if (value) {
|
|
6782
6370
|
this.$el.classList.add("atk-btn-loading");
|
|
@@ -6801,15 +6389,12 @@ class ActionBtn {
|
|
|
6801
6389
|
/** 设置消息 */
|
|
6802
6390
|
setMsg(text, className, duringTime, after) {
|
|
6803
6391
|
this.setLoading(false);
|
|
6804
|
-
if (className)
|
|
6805
|
-
this.$el.classList.add(className);
|
|
6392
|
+
if (className) this.$el.classList.add(className);
|
|
6806
6393
|
this.$el.innerText = text;
|
|
6807
6394
|
this.setMsgRecTimer(() => {
|
|
6808
6395
|
this.$el.innerText = this.getText();
|
|
6809
|
-
if (className)
|
|
6810
|
-
|
|
6811
|
-
if (after)
|
|
6812
|
-
after();
|
|
6396
|
+
if (className) this.$el.classList.remove(className);
|
|
6397
|
+
if (after) after();
|
|
6813
6398
|
}, duringTime || 2500);
|
|
6814
6399
|
}
|
|
6815
6400
|
/** 设置消息复原操作定时器 */
|
|
@@ -6824,13 +6409,11 @@ class ActionBtn {
|
|
|
6824
6409
|
}
|
|
6825
6410
|
/** 立刻触发器复原定时器 */
|
|
6826
6411
|
fireMsgRecTimer() {
|
|
6827
|
-
if (this.msgRecTimerFunc)
|
|
6828
|
-
this.msgRecTimerFunc();
|
|
6412
|
+
if (this.msgRecTimerFunc) this.msgRecTimerFunc();
|
|
6829
6413
|
}
|
|
6830
6414
|
/** 仅清除 timer */
|
|
6831
6415
|
clearMsgRecTimer() {
|
|
6832
|
-
if (this.msgRecTimer)
|
|
6833
|
-
window.clearTimeout(this.msgRecTimer);
|
|
6416
|
+
if (this.msgRecTimer) window.clearTimeout(this.msgRecTimer);
|
|
6834
6417
|
this.msgRecTimer = void 0;
|
|
6835
6418
|
this.msgRecTimerFunc = void 0;
|
|
6836
6419
|
}
|
|
@@ -6850,8 +6433,7 @@ function renderActions(r) {
|
|
|
6850
6433
|
});
|
|
6851
6434
|
}
|
|
6852
6435
|
function renderVote(r) {
|
|
6853
|
-
if (!r.opts.vote)
|
|
6854
|
-
return;
|
|
6436
|
+
if (!r.opts.vote) return;
|
|
6855
6437
|
r.voteBtnUp = new ActionBtn(() => `${t("voteUp")} (${r.data.vote_up || 0})`).appendTo(r.$actions);
|
|
6856
6438
|
r.voteBtnUp.setClick(() => {
|
|
6857
6439
|
r.comment.getActions().vote("up");
|
|
@@ -6866,8 +6448,7 @@ function renderVote(r) {
|
|
|
6866
6448
|
}
|
|
6867
6449
|
}
|
|
6868
6450
|
function renderReply(r) {
|
|
6869
|
-
if (!r.data.is_allow_reply)
|
|
6870
|
-
return;
|
|
6451
|
+
if (!r.data.is_allow_reply) return;
|
|
6871
6452
|
const replyBtn = createElement(`<span>${t("reply")}</span>`);
|
|
6872
6453
|
r.$actions.append(replyBtn);
|
|
6873
6454
|
replyBtn.addEventListener("click", (e) => {
|
|
@@ -6993,8 +6574,7 @@ class Render {
|
|
|
6993
6574
|
/** 内容限高检测 */
|
|
6994
6575
|
checkHeightLimit() {
|
|
6995
6576
|
const conf = this.opts.heightLimit;
|
|
6996
|
-
if (!conf || !conf.content || !conf.children)
|
|
6997
|
-
return;
|
|
6577
|
+
if (!conf || !conf.content || !conf.children) return;
|
|
6998
6578
|
const contentMaxH = conf.content;
|
|
6999
6579
|
const childrenMaxH = conf.children;
|
|
7000
6580
|
check(
|
|
@@ -7017,8 +6597,7 @@ class Render {
|
|
|
7017
6597
|
}
|
|
7018
6598
|
/** 子评论区域移除限高 */
|
|
7019
6599
|
heightLimitRemoveForChildren() {
|
|
7020
|
-
if (!this.$childrenWrap)
|
|
7021
|
-
return;
|
|
6600
|
+
if (!this.$childrenWrap) return;
|
|
7022
6601
|
disposeHeightLimit(this.$childrenWrap);
|
|
7023
6602
|
}
|
|
7024
6603
|
/** 渐出动画 */
|
|
@@ -7046,17 +6625,13 @@ class Render {
|
|
|
7046
6625
|
}
|
|
7047
6626
|
/** 设置已读 */
|
|
7048
6627
|
setUnread(val) {
|
|
7049
|
-
if (val)
|
|
7050
|
-
|
|
7051
|
-
else
|
|
7052
|
-
this.$el.classList.remove("atk-unread");
|
|
6628
|
+
if (val) this.$el.classList.add("atk-unread");
|
|
6629
|
+
else this.$el.classList.remove("atk-unread");
|
|
7053
6630
|
}
|
|
7054
6631
|
/** 设置为可点击的评论 */
|
|
7055
6632
|
setOpenable(val) {
|
|
7056
|
-
if (val)
|
|
7057
|
-
|
|
7058
|
-
else
|
|
7059
|
-
this.$el.classList.remove("atk-openable");
|
|
6633
|
+
if (val) this.$el.classList.add("atk-openable");
|
|
6634
|
+
else this.$el.classList.remove("atk-openable");
|
|
7060
6635
|
}
|
|
7061
6636
|
/** 设置点击评论打开置顶 URL */
|
|
7062
6637
|
setOpenURL(url) {
|
|
@@ -7105,8 +6680,7 @@ class CommentActions {
|
|
|
7105
6680
|
}
|
|
7106
6681
|
/** 管理员 - 评论状态修改 */
|
|
7107
6682
|
adminEdit(type, btnElem) {
|
|
7108
|
-
if (btnElem.isLoading)
|
|
7109
|
-
return;
|
|
6683
|
+
if (btnElem.isLoading) return;
|
|
7110
6684
|
btnElem.setLoading(true, `${t("editing")}...`);
|
|
7111
6685
|
const modify = __spreadValues({}, this.data);
|
|
7112
6686
|
if (type === "collapsed") {
|
|
@@ -7126,13 +6700,11 @@ class CommentActions {
|
|
|
7126
6700
|
}
|
|
7127
6701
|
/** 管理员 - 评论删除 */
|
|
7128
6702
|
adminDelete(btnElem) {
|
|
7129
|
-
if (btnElem.isLoading)
|
|
7130
|
-
return;
|
|
6703
|
+
if (btnElem.isLoading) return;
|
|
7131
6704
|
btnElem.setLoading(true, `${t("deleting")}...`);
|
|
7132
6705
|
this.getApi().comments.deleteComment(this.data.id).then(() => {
|
|
7133
6706
|
btnElem.setLoading(false);
|
|
7134
|
-
if (this.opts.onDelete)
|
|
7135
|
-
this.opts.onDelete(this.comment);
|
|
6707
|
+
if (this.opts.onDelete) this.opts.onDelete(this.comment);
|
|
7136
6708
|
}).catch((e) => {
|
|
7137
6709
|
console.error(e);
|
|
7138
6710
|
btnElem.setError(t("deleteFail"));
|
|
@@ -7143,8 +6715,7 @@ class CommentActions {
|
|
|
7143
6715
|
const origHash = window.location.hash;
|
|
7144
6716
|
const modifyHash = `#atk-comment-${this.data.rid}`;
|
|
7145
6717
|
window.location.hash = modifyHash;
|
|
7146
|
-
if (modifyHash === origHash)
|
|
7147
|
-
window.dispatchEvent(new Event("hashchange"));
|
|
6718
|
+
if (modifyHash === origHash) window.dispatchEvent(new Event("hashchange"));
|
|
7148
6719
|
}
|
|
7149
6720
|
}
|
|
7150
6721
|
class CommentNode {
|
|
@@ -7169,11 +6740,9 @@ class CommentNode {
|
|
|
7169
6740
|
/** 渲染 UI */
|
|
7170
6741
|
render() {
|
|
7171
6742
|
const newEl = this.renderInstance.render();
|
|
7172
|
-
if (this.$el)
|
|
7173
|
-
this.$el.replaceWith(newEl);
|
|
6743
|
+
if (this.$el) this.$el.replaceWith(newEl);
|
|
7174
6744
|
this.$el = newEl;
|
|
7175
|
-
if (this.opts.onAfterRender)
|
|
7176
|
-
this.opts.onAfterRender();
|
|
6745
|
+
if (this.opts.onAfterRender) this.opts.onAfterRender();
|
|
7177
6746
|
}
|
|
7178
6747
|
/** 获取评论操作实例对象 */
|
|
7179
6748
|
getActions() {
|
|
@@ -7220,10 +6789,8 @@ class CommentNode {
|
|
|
7220
6789
|
this.children.push(childNode);
|
|
7221
6790
|
const $childrenWrap = this.getChildrenWrapEl();
|
|
7222
6791
|
const $childComment = childNode.getEl();
|
|
7223
|
-
if (insertMode === "append")
|
|
7224
|
-
|
|
7225
|
-
else if (insertMode === "prepend")
|
|
7226
|
-
$childrenWrap.prepend($childComment);
|
|
6792
|
+
if (insertMode === "append") $childrenWrap.append($childComment);
|
|
6793
|
+
else if (insertMode === "prepend") $childrenWrap.prepend($childComment);
|
|
7227
6794
|
childNode.getRender().playFadeAnim();
|
|
7228
6795
|
childNode.getRender().checkHeightLimit();
|
|
7229
6796
|
}
|
|
@@ -7251,8 +6818,7 @@ class CommentNode {
|
|
|
7251
6818
|
* Please be aware of the memory leak if you use the $el reference directly.
|
|
7252
6819
|
*/
|
|
7253
6820
|
getEl() {
|
|
7254
|
-
if (!this.$el)
|
|
7255
|
-
throw new Error("comment element not initialized before `getEl()`");
|
|
6821
|
+
if (!this.$el) throw new Error("comment element not initialized before `getEl()`");
|
|
7256
6822
|
return this.$el;
|
|
7257
6823
|
}
|
|
7258
6824
|
/**
|
|
@@ -7261,8 +6827,7 @@ class CommentNode {
|
|
|
7261
6827
|
* Scroll to the comment and perform flash animation
|
|
7262
6828
|
*/
|
|
7263
6829
|
focus() {
|
|
7264
|
-
if (!this.$el)
|
|
7265
|
-
throw new Error("comment element not initialized before `focus()`");
|
|
6830
|
+
if (!this.$el) throw new Error("comment element not initialized before `focus()`");
|
|
7266
6831
|
this.getParents().forEach((p) => {
|
|
7267
6832
|
p.getRender().heightLimitRemoveForChildren();
|
|
7268
6833
|
});
|
|
@@ -7293,7 +6858,9 @@ class CommentNode {
|
|
|
7293
6858
|
}
|
|
7294
6859
|
/** 获取格式化后的日期 */
|
|
7295
6860
|
getDateFormatted() {
|
|
7296
|
-
|
|
6861
|
+
var _a, _b;
|
|
6862
|
+
const date = new Date(this.data.date);
|
|
6863
|
+
return ((_b = (_a = this.opts).dateFormatter) == null ? void 0 : _b.call(_a, date)) || timeAgo(date, t);
|
|
7297
6864
|
}
|
|
7298
6865
|
/** 获取用户 UserAgent 信息 */
|
|
7299
6866
|
getUserUA() {
|
|
@@ -7327,6 +6894,7 @@ function createCommentNode(ctx, comment, replyComment, opts) {
|
|
|
7327
6894
|
vote: ctx.conf.vote,
|
|
7328
6895
|
voteDown: ctx.conf.voteDown,
|
|
7329
6896
|
uaBadge: ctx.conf.uaBadge,
|
|
6897
|
+
dateFormatter: ctx.conf.dateFormatter,
|
|
7330
6898
|
// TODO: move to plugin folder and remove from core
|
|
7331
6899
|
getApi: () => ctx.getApi(),
|
|
7332
6900
|
replyComment: (c, $el) => ctx.replyComment(c, $el),
|
|
@@ -7365,8 +6933,7 @@ class ReadMoreBtn {
|
|
|
7365
6933
|
return this.total > this.offset + this.opts.pageSize;
|
|
7366
6934
|
}
|
|
7367
6935
|
click() {
|
|
7368
|
-
if (this.hasMore)
|
|
7369
|
-
this.opts.onClick(this.offset + this.opts.pageSize);
|
|
6936
|
+
if (this.hasMore) this.opts.onClick(this.offset + this.opts.pageSize);
|
|
7370
6937
|
this.checkDisabled();
|
|
7371
6938
|
}
|
|
7372
6939
|
/** 显示 */
|
|
@@ -7399,10 +6966,8 @@ class ReadMoreBtn {
|
|
|
7399
6966
|
this.checkDisabled();
|
|
7400
6967
|
}
|
|
7401
6968
|
checkDisabled() {
|
|
7402
|
-
if (this.hasMore)
|
|
7403
|
-
|
|
7404
|
-
else
|
|
7405
|
-
this.hide();
|
|
6969
|
+
if (this.hasMore) this.show();
|
|
6970
|
+
else this.hide();
|
|
7406
6971
|
}
|
|
7407
6972
|
}
|
|
7408
6973
|
class ReadMorePaginator {
|
|
@@ -7424,8 +6989,7 @@ class ReadMorePaginator {
|
|
|
7424
6989
|
});
|
|
7425
6990
|
if (opt.readMoreAutoLoad) {
|
|
7426
6991
|
this.onReachedBottom = () => {
|
|
7427
|
-
if (!this.instance.hasMore || this.opt.ctx.getData().getLoading())
|
|
7428
|
-
return;
|
|
6992
|
+
if (!this.instance.hasMore || this.opt.ctx.getData().getLoading()) return;
|
|
7429
6993
|
this.instance.click();
|
|
7430
6994
|
};
|
|
7431
6995
|
this.opt.ctx.on("list-reach-bottom", this.onReachedBottom);
|
|
@@ -7531,10 +7095,8 @@ class Pagination {
|
|
|
7531
7095
|
}
|
|
7532
7096
|
this.change(page);
|
|
7533
7097
|
};
|
|
7534
|
-
if (!now)
|
|
7535
|
-
|
|
7536
|
-
else
|
|
7537
|
-
modify();
|
|
7098
|
+
if (!now) this.inputTimer = window.setTimeout(() => modify(), 800);
|
|
7099
|
+
else modify();
|
|
7538
7100
|
}
|
|
7539
7101
|
prev() {
|
|
7540
7102
|
const page = this.page - 1;
|
|
@@ -7593,10 +7155,8 @@ class Pagination {
|
|
|
7593
7155
|
}
|
|
7594
7156
|
/** 加载 */
|
|
7595
7157
|
setLoading(isLoading) {
|
|
7596
|
-
if (isLoading)
|
|
7597
|
-
|
|
7598
|
-
else
|
|
7599
|
-
hideLoading(this.$el);
|
|
7158
|
+
if (isLoading) showLoading(this.$el);
|
|
7159
|
+
else hideLoading(this.$el);
|
|
7600
7160
|
}
|
|
7601
7161
|
}
|
|
7602
7162
|
class UpDownPaginator {
|
|
@@ -7638,26 +7198,22 @@ class UpDownPaginator {
|
|
|
7638
7198
|
}
|
|
7639
7199
|
}
|
|
7640
7200
|
function createPaginatorByConf(conf) {
|
|
7641
|
-
if (conf.pagination.readMore)
|
|
7642
|
-
return new ReadMorePaginator();
|
|
7201
|
+
if (conf.pagination.readMore) return new ReadMorePaginator();
|
|
7643
7202
|
return new UpDownPaginator();
|
|
7644
7203
|
}
|
|
7645
7204
|
function getPageDataByLastData(ctx) {
|
|
7646
7205
|
const last = ctx.getData().getListLastFetch();
|
|
7647
7206
|
const r = { offset: 0, total: 0 };
|
|
7648
|
-
if (!last)
|
|
7649
|
-
return r;
|
|
7207
|
+
if (!last) return r;
|
|
7650
7208
|
r.offset = last.params.offset;
|
|
7651
|
-
if (last.data)
|
|
7652
|
-
r.total = last.params.flatMode ? last.data.count : last.data.roots_count;
|
|
7209
|
+
if (last.data) r.total = last.params.flatMode ? last.data.count : last.data.roots_count;
|
|
7653
7210
|
return r;
|
|
7654
7211
|
}
|
|
7655
7212
|
const initListPaginatorFunc = (ctx) => {
|
|
7656
7213
|
let paginator = null;
|
|
7657
7214
|
ctx.watchConf(["pagination", "locale"], (conf) => {
|
|
7658
7215
|
const list2 = ctx.get("list");
|
|
7659
|
-
if (paginator)
|
|
7660
|
-
paginator.dispose();
|
|
7216
|
+
if (paginator) paginator.dispose();
|
|
7661
7217
|
paginator = createPaginatorByConf(conf);
|
|
7662
7218
|
const { offset, total } = getPageDataByLastData(ctx);
|
|
7663
7219
|
const $paginator = paginator.create({
|
|
@@ -7797,18 +7353,14 @@ class Layer {
|
|
|
7797
7353
|
this.$el.style.display = "";
|
|
7798
7354
|
}
|
|
7799
7355
|
hide() {
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
this.onAfterHide && this.onAfterHide();
|
|
7804
|
-
});
|
|
7356
|
+
this.opts.onHide();
|
|
7357
|
+
this.$el.style.display = "none";
|
|
7358
|
+
this.onAfterHide && this.onAfterHide();
|
|
7805
7359
|
}
|
|
7806
7360
|
destroy() {
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
this.onAfterHide && this.onAfterHide();
|
|
7811
|
-
});
|
|
7361
|
+
this.opts.onHide();
|
|
7362
|
+
this.$el.remove();
|
|
7363
|
+
this.onAfterHide && this.onAfterHide();
|
|
7812
7364
|
}
|
|
7813
7365
|
}
|
|
7814
7366
|
class LayerWrap {
|
|
@@ -7886,11 +7438,12 @@ class User {
|
|
|
7886
7438
|
this.opts = opts;
|
|
7887
7439
|
const localUser = JSON.parse(window.localStorage.getItem(LOCAL_USER_KEY) || "{}");
|
|
7888
7440
|
this.data = {
|
|
7889
|
-
|
|
7441
|
+
name: localUser.name || localUser.nick || "",
|
|
7442
|
+
// nick is deprecated (for historical compatibility)
|
|
7890
7443
|
email: localUser.email || "",
|
|
7891
7444
|
link: localUser.link || "",
|
|
7892
7445
|
token: localUser.token || "",
|
|
7893
|
-
|
|
7446
|
+
is_admin: localUser.is_admin || localUser.isAdmin || false
|
|
7894
7447
|
};
|
|
7895
7448
|
}
|
|
7896
7449
|
getData() {
|
|
@@ -7907,17 +7460,17 @@ class User {
|
|
|
7907
7460
|
/**
|
|
7908
7461
|
* Logout
|
|
7909
7462
|
*
|
|
7910
|
-
* @description Logout will clear login status, but not clear user data (
|
|
7463
|
+
* @description Logout will clear login status, but not clear user data (name, email, link)
|
|
7911
7464
|
*/
|
|
7912
7465
|
logout() {
|
|
7913
7466
|
this.update({
|
|
7914
7467
|
token: "",
|
|
7915
|
-
|
|
7468
|
+
is_admin: false
|
|
7916
7469
|
});
|
|
7917
7470
|
}
|
|
7918
7471
|
/** Check if user has filled basic data */
|
|
7919
7472
|
checkHasBasicUserInfo() {
|
|
7920
|
-
return !!this.data.
|
|
7473
|
+
return !!this.data.name && !!this.data.email;
|
|
7921
7474
|
}
|
|
7922
7475
|
}
|
|
7923
7476
|
const services = {
|
|
@@ -8001,8 +7554,7 @@ function initCountWidget(opt) {
|
|
|
8001
7554
|
}
|
|
8002
7555
|
function incrementPvCount(opt) {
|
|
8003
7556
|
return __async(this, null, function* () {
|
|
8004
|
-
if (!opt.pvAdd || !opt.pageKey)
|
|
8005
|
-
return void 0;
|
|
7557
|
+
if (!opt.pvAdd || !opt.pageKey) return void 0;
|
|
8006
7558
|
const pvCount = (yield opt.getApi().pages.logPv({
|
|
8007
7559
|
page_key: opt.pageKey,
|
|
8008
7560
|
page_title: opt.pageTitle,
|
|
@@ -8020,7 +7572,7 @@ function loadCommentCount(opt) {
|
|
|
8020
7572
|
}
|
|
8021
7573
|
function loadPvCount(opt, cache) {
|
|
8022
7574
|
return __async(this, null, function* () {
|
|
8023
|
-
yield loadStatCount({ opt, query: "page_pv", containers: [opt.pvEl, "#
|
|
7575
|
+
yield loadStatCount({ opt, query: "page_pv", containers: [opt.pvEl, "#ArtalkPV"], cache });
|
|
8024
7576
|
});
|
|
8025
7577
|
}
|
|
8026
7578
|
function loadStatCount(args) {
|
|
@@ -8157,11 +7709,11 @@ class SubmitAddPreset {
|
|
|
8157
7709
|
}
|
|
8158
7710
|
getSubmitAddParams() {
|
|
8159
7711
|
return __async(this, null, function* () {
|
|
8160
|
-
const {
|
|
7712
|
+
const { name, email, link: link2 } = this.kit.useUser().getData();
|
|
8161
7713
|
const conf = this.kit.useConf();
|
|
8162
7714
|
return {
|
|
8163
7715
|
content: this.kit.useEditor().getContentFinal(),
|
|
8164
|
-
name
|
|
7716
|
+
name,
|
|
8165
7717
|
email,
|
|
8166
7718
|
link: link2,
|
|
8167
7719
|
rid: 0,
|
|
@@ -8203,17 +7755,12 @@ class Submit extends EditorPlug {
|
|
|
8203
7755
|
const custom = this.customs.find((o) => o.activeCond());
|
|
8204
7756
|
this.kit.useEditor().showLoading();
|
|
8205
7757
|
try {
|
|
8206
|
-
if (custom == null ? void 0 : custom.pre)
|
|
8207
|
-
custom.pre();
|
|
7758
|
+
if (custom == null ? void 0 : custom.pre) custom.pre();
|
|
8208
7759
|
let nComment;
|
|
8209
|
-
if (custom == null ? void 0 : custom.req)
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
if (custom == null ? void 0 : custom.post)
|
|
8214
|
-
custom.post(nComment);
|
|
8215
|
-
else
|
|
8216
|
-
this.defaultPreset.postSubmitAdd(nComment);
|
|
7760
|
+
if (custom == null ? void 0 : custom.req) nComment = yield custom.req();
|
|
7761
|
+
else nComment = yield this.defaultPreset.reqAdd();
|
|
7762
|
+
if (custom == null ? void 0 : custom.post) custom.post(nComment);
|
|
7763
|
+
else this.defaultPreset.postSubmitAdd(nComment);
|
|
8217
7764
|
} catch (err) {
|
|
8218
7765
|
console.error(err);
|
|
8219
7766
|
this.kit.useEditor().showNotify(`${t("commentFail")}: ${err.message || String(err)}`, "e");
|
|
@@ -8238,15 +7785,13 @@ class StateReply extends EditorPlug {
|
|
|
8238
7785
|
});
|
|
8239
7786
|
this.kit.useEvents().on("mounted", () => {
|
|
8240
7787
|
const submitPlug = this.kit.useDeps(Submit);
|
|
8241
|
-
if (!submitPlug)
|
|
8242
|
-
throw Error("SubmitPlug not initialized");
|
|
7788
|
+
if (!submitPlug) throw Error("SubmitPlug not initialized");
|
|
8243
7789
|
const defaultPreset = new SubmitAddPreset(this.kit);
|
|
8244
7790
|
submitPlug.registerCustom({
|
|
8245
7791
|
activeCond: () => !!this.comment,
|
|
8246
7792
|
// active this custom submit when reply mode
|
|
8247
7793
|
req: () => __async(this, null, function* () {
|
|
8248
|
-
if (!this.comment)
|
|
8249
|
-
throw new Error("reply comment cannot be empty");
|
|
7794
|
+
if (!this.comment) throw new Error("reply comment cannot be empty");
|
|
8250
7795
|
const nComment = (yield this.kit.useApi().comments.createComment(__spreadProps(__spreadValues({}, yield defaultPreset.getSubmitAddParams()), {
|
|
8251
7796
|
rid: this.comment.id,
|
|
8252
7797
|
page_key: this.comment.page_key,
|
|
@@ -8282,8 +7827,7 @@ class StateReply extends EditorPlug {
|
|
|
8282
7827
|
ui.$textarea.focus();
|
|
8283
7828
|
}
|
|
8284
7829
|
cancelReply() {
|
|
8285
|
-
if (!this.comment)
|
|
8286
|
-
return;
|
|
7830
|
+
if (!this.comment) return;
|
|
8287
7831
|
const ui = this.kit.useUI();
|
|
8288
7832
|
if (ui.$sendReplyBtn) {
|
|
8289
7833
|
ui.$sendReplyBtn.remove();
|
|
@@ -8308,15 +7852,14 @@ class StateEdit extends EditorPlug {
|
|
|
8308
7852
|
});
|
|
8309
7853
|
this.kit.useMounted(() => {
|
|
8310
7854
|
const submitPlug = this.kit.useDeps(Submit);
|
|
8311
|
-
if (!submitPlug)
|
|
8312
|
-
throw Error("SubmitPlug not initialized");
|
|
7855
|
+
if (!submitPlug) throw Error("SubmitPlug not initialized");
|
|
8313
7856
|
submitPlug.registerCustom({
|
|
8314
7857
|
activeCond: () => !!this.comment,
|
|
8315
7858
|
// active this custom submit when edit mode
|
|
8316
7859
|
req: () => __async(this, null, function* () {
|
|
8317
7860
|
const saveData = {
|
|
8318
7861
|
content: this.kit.useEditor().getContentFinal(),
|
|
8319
|
-
nick: this.kit.useUI().$
|
|
7862
|
+
nick: this.kit.useUI().$name.value,
|
|
8320
7863
|
email: this.kit.useUI().$email.value,
|
|
8321
7864
|
link: this.kit.useUI().$link.value
|
|
8322
7865
|
};
|
|
@@ -8344,7 +7887,7 @@ class StateEdit extends EditorPlug {
|
|
|
8344
7887
|
}
|
|
8345
7888
|
this.comment = comment;
|
|
8346
7889
|
ui.$header.style.display = "none";
|
|
8347
|
-
ui.$
|
|
7890
|
+
ui.$name.value = comment.nick || "";
|
|
8348
7891
|
ui.$email.value = comment.email || "";
|
|
8349
7892
|
ui.$link.value = comment.link || "";
|
|
8350
7893
|
this.kit.useEditor().setContent(comment.content);
|
|
@@ -8352,16 +7895,15 @@ class StateEdit extends EditorPlug {
|
|
|
8352
7895
|
this.updateSubmitBtnText(t("save"));
|
|
8353
7896
|
}
|
|
8354
7897
|
cancelEdit() {
|
|
8355
|
-
if (!this.comment)
|
|
8356
|
-
return;
|
|
7898
|
+
if (!this.comment) return;
|
|
8357
7899
|
const ui = this.kit.useUI();
|
|
8358
7900
|
if (ui.$editCancelBtn) {
|
|
8359
7901
|
ui.$editCancelBtn.remove();
|
|
8360
7902
|
ui.$editCancelBtn = void 0;
|
|
8361
7903
|
}
|
|
8362
7904
|
this.comment = void 0;
|
|
8363
|
-
const {
|
|
8364
|
-
ui.$
|
|
7905
|
+
const { name, email, link: link2 } = this.kit.useUser().getData();
|
|
7906
|
+
ui.$name.value = name;
|
|
8365
7907
|
ui.$email.value = email;
|
|
8366
7908
|
ui.$link.value = link2;
|
|
8367
7909
|
this.kit.useEditor().setContent("");
|
|
@@ -8401,7 +7943,7 @@ class Closable extends EditorPlug {
|
|
|
8401
7943
|
this.kit.useUI().$textareaWrap.prepend(
|
|
8402
7944
|
createElement(`<div class="atk-comment-closed">${t("onlyAdminCanReply")}</div>`)
|
|
8403
7945
|
);
|
|
8404
|
-
if (!this.kit.useUser().getData().
|
|
7946
|
+
if (!this.kit.useUser().getData().is_admin) {
|
|
8405
7947
|
this.kit.useUI().$textarea.style.display = "none";
|
|
8406
7948
|
this.kit.useEvents().trigger("panel-close");
|
|
8407
7949
|
this.kit.useUI().$bottom.style.display = "none";
|
|
@@ -8450,15 +7992,18 @@ class HeaderUser extends EditorPlug {
|
|
|
8450
7992
|
abortFn: null
|
|
8451
7993
|
});
|
|
8452
7994
|
const onInput = ({ $input, field }) => {
|
|
8453
|
-
if (this.kit.useEditor().getState() === "edit")
|
|
8454
|
-
return;
|
|
7995
|
+
if (this.kit.useEditor().getState() === "edit") return;
|
|
8455
7996
|
this.kit.useUser().update({ [field]: $input.value.trim() });
|
|
8456
|
-
if (field === "
|
|
8457
|
-
|
|
7997
|
+
if (field === "name" || field === "email") this.fetchUserInfo();
|
|
7998
|
+
};
|
|
7999
|
+
const placeholders = {
|
|
8000
|
+
name: t("nick"),
|
|
8001
|
+
email: t("email"),
|
|
8002
|
+
link: t("link")
|
|
8458
8003
|
};
|
|
8459
8004
|
this.kit.useMounted(() => {
|
|
8460
8005
|
Object.entries(this.kit.useEditor().getHeaderInputEls()).forEach(([key, $input]) => {
|
|
8461
|
-
$input.placeholder =
|
|
8006
|
+
$input.placeholder = placeholders[key];
|
|
8462
8007
|
$input.value = this.kit.useUser().getData()[key] || "";
|
|
8463
8008
|
});
|
|
8464
8009
|
this.kit.useEvents().on("header-input", onInput);
|
|
@@ -8472,10 +8017,8 @@ class HeaderUser extends EditorPlug {
|
|
|
8472
8017
|
*/
|
|
8473
8018
|
fetchUserInfo() {
|
|
8474
8019
|
this.kit.useUser().logout();
|
|
8475
|
-
if (this.query.timer)
|
|
8476
|
-
|
|
8477
|
-
if (this.query.abortFn)
|
|
8478
|
-
this.query.abortFn();
|
|
8020
|
+
if (this.query.timer) window.clearTimeout(this.query.timer);
|
|
8021
|
+
if (this.query.abortFn) this.query.abortFn();
|
|
8479
8022
|
this.query.timer = window.setTimeout(() => {
|
|
8480
8023
|
this.query.timer = null;
|
|
8481
8024
|
const api = this.kit.useApi();
|
|
@@ -8499,8 +8042,7 @@ class HeaderUser extends EditorPlug {
|
|
|
8499
8042
|
*/
|
|
8500
8043
|
onUserInfoFetched(data) {
|
|
8501
8044
|
var _a;
|
|
8502
|
-
if (!data.is_login)
|
|
8503
|
-
this.kit.useUser().logout();
|
|
8045
|
+
if (!data.is_login) this.kit.useUser().logout();
|
|
8504
8046
|
this.kit.useGlobalCtx().getData().updateNotifies(data.notifies);
|
|
8505
8047
|
if (this.kit.useUser().checkHasBasicUserInfo() && !data.is_login && ((_a = data.user) == null ? void 0 : _a.is_admin)) {
|
|
8506
8048
|
this.kit.useGlobalCtx().checkAdmin({
|
|
@@ -8518,8 +8060,7 @@ class HeaderLink extends EditorPlug {
|
|
|
8518
8060
|
constructor(kit) {
|
|
8519
8061
|
super(kit);
|
|
8520
8062
|
const onLinkChange = ({ field }) => {
|
|
8521
|
-
if (field === "link")
|
|
8522
|
-
this.onLinkInputChange();
|
|
8063
|
+
if (field === "link") this.onLinkInputChange();
|
|
8523
8064
|
};
|
|
8524
8065
|
this.kit.useMounted(() => {
|
|
8525
8066
|
this.kit.useEvents().on("header-change", onLinkChange);
|
|
@@ -8575,8 +8116,7 @@ class Emoticons extends EditorPlug {
|
|
|
8575
8116
|
}
|
|
8576
8117
|
loadEmoticonsData() {
|
|
8577
8118
|
return __async(this, null, function* () {
|
|
8578
|
-
if (this.isListLoaded)
|
|
8579
|
-
return;
|
|
8119
|
+
if (this.isListLoaded) return;
|
|
8580
8120
|
if (this.loadingTask !== null) {
|
|
8581
8121
|
yield this.loadingTask;
|
|
8582
8122
|
return;
|
|
@@ -8602,10 +8142,8 @@ class Emoticons extends EditorPlug {
|
|
|
8602
8142
|
return [];
|
|
8603
8143
|
}
|
|
8604
8144
|
const pushGrp = (grp) => {
|
|
8605
|
-
if (typeof grp !== "object")
|
|
8606
|
-
|
|
8607
|
-
if (grp.name && data.find((o) => o.name === grp.name))
|
|
8608
|
-
return;
|
|
8145
|
+
if (typeof grp !== "object") return;
|
|
8146
|
+
if (grp.name && data.find((o) => o.name === grp.name)) return;
|
|
8609
8147
|
data.push(grp);
|
|
8610
8148
|
};
|
|
8611
8149
|
const remoteLoad = (d) => __async(this, null, function* () {
|
|
@@ -8617,10 +8155,8 @@ class Emoticons extends EditorPlug {
|
|
|
8617
8155
|
yield remoteLoad(grp);
|
|
8618
8156
|
} else if (typeof grp === "string") {
|
|
8619
8157
|
const grpData = yield this.remoteLoad(grp);
|
|
8620
|
-
if (Array.isArray(grpData))
|
|
8621
|
-
|
|
8622
|
-
else if (typeof grpData === "object")
|
|
8623
|
-
pushGrp(grpData);
|
|
8158
|
+
if (Array.isArray(grpData)) yield remoteLoad(grpData);
|
|
8159
|
+
else if (typeof grpData === "object") pushGrp(grpData);
|
|
8624
8160
|
}
|
|
8625
8161
|
}))
|
|
8626
8162
|
);
|
|
@@ -8649,8 +8185,7 @@ class Emoticons extends EditorPlug {
|
|
|
8649
8185
|
/** 远程加载 */
|
|
8650
8186
|
remoteLoad(url) {
|
|
8651
8187
|
return __async(this, null, function* () {
|
|
8652
|
-
if (!url)
|
|
8653
|
-
return [];
|
|
8188
|
+
if (!url) return [];
|
|
8654
8189
|
try {
|
|
8655
8190
|
const resp = yield fetch(url);
|
|
8656
8191
|
const json = yield resp.json();
|
|
@@ -8667,8 +8202,7 @@ class Emoticons extends EditorPlug {
|
|
|
8667
8202
|
solveNullKey(data) {
|
|
8668
8203
|
data.forEach((grp) => {
|
|
8669
8204
|
grp.items.forEach((item, index) => {
|
|
8670
|
-
if (!item.key)
|
|
8671
|
-
item.key = `${grp.name} ${index + 1}`;
|
|
8205
|
+
if (!item.key) item.key = `${grp.name} ${index + 1}`;
|
|
8672
8206
|
});
|
|
8673
8207
|
});
|
|
8674
8208
|
}
|
|
@@ -8677,14 +8211,10 @@ class Emoticons extends EditorPlug {
|
|
|
8677
8211
|
const tmp = {};
|
|
8678
8212
|
data.forEach((grp) => {
|
|
8679
8213
|
grp.items.forEach((item) => {
|
|
8680
|
-
if (!item.key || String(item.key).trim() === "")
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8684
|
-
else
|
|
8685
|
-
tmp[item.key]++;
|
|
8686
|
-
if (tmp[item.key] > 1)
|
|
8687
|
-
item.key = `${item.key} ${tmp[item.key]}`;
|
|
8214
|
+
if (!item.key || String(item.key).trim() === "") return;
|
|
8215
|
+
if (!tmp[item.key]) tmp[item.key] = 1;
|
|
8216
|
+
else tmp[item.key]++;
|
|
8217
|
+
if (tmp[item.key] > 1) item.key = `${item.key} ${tmp[item.key]}`;
|
|
8688
8218
|
});
|
|
8689
8219
|
});
|
|
8690
8220
|
}
|
|
@@ -8705,8 +8235,7 @@ class Emoticons extends EditorPlug {
|
|
|
8705
8235
|
const iconStr = item.icon;
|
|
8706
8236
|
if (/<(img|IMG)/.test(iconStr)) {
|
|
8707
8237
|
const find = /src=["'](.*?)["']/.exec(iconStr);
|
|
8708
|
-
if (find && find.length > 1)
|
|
8709
|
-
item.icon = find[1];
|
|
8238
|
+
if (find && find.length > 1) item.icon = find[1];
|
|
8710
8239
|
}
|
|
8711
8240
|
nGrp.items.push({
|
|
8712
8241
|
key: item.text || `${grpName} ${index + 1}`,
|
|
@@ -8760,8 +8289,7 @@ class Emoticons extends EditorPlug {
|
|
|
8760
8289
|
this.$grpSwitcher.append($item);
|
|
8761
8290
|
});
|
|
8762
8291
|
}
|
|
8763
|
-
if (this.emoticons.length > 0)
|
|
8764
|
-
this.openGrp(0);
|
|
8292
|
+
if (this.emoticons.length > 0) this.openGrp(0);
|
|
8765
8293
|
}
|
|
8766
8294
|
/** 打开一个表情组 */
|
|
8767
8295
|
openGrp(index) {
|
|
@@ -8782,11 +8310,9 @@ class Emoticons extends EditorPlug {
|
|
|
8782
8310
|
}
|
|
8783
8311
|
/** 处理评论 content 中的表情内容 */
|
|
8784
8312
|
transEmoticonImageText(text) {
|
|
8785
|
-
if (!this.emoticons || !Array.isArray(this.emoticons))
|
|
8786
|
-
return text;
|
|
8313
|
+
if (!this.emoticons || !Array.isArray(this.emoticons)) return text;
|
|
8787
8314
|
this.emoticons.forEach((grp) => {
|
|
8788
|
-
if (grp.type !== "image")
|
|
8789
|
-
return;
|
|
8315
|
+
if (grp.type !== "image") return;
|
|
8790
8316
|
Object.entries(grp.items).forEach(([index, item]) => {
|
|
8791
8317
|
text = text.split(`:[${item.key}]`).join(`<img src="${item.val}" atk-emoticon="${item.key}">`);
|
|
8792
8318
|
});
|
|
@@ -8815,8 +8341,7 @@ class Upload extends EditorPlug {
|
|
|
8815
8341
|
const $input = this.$imgUploadInput;
|
|
8816
8342
|
$input.onchange = () => {
|
|
8817
8343
|
(() => __async(this, null, function* () {
|
|
8818
|
-
if (!$input.files || $input.files.length === 0)
|
|
8819
|
-
return;
|
|
8344
|
+
if (!$input.files || $input.files.length === 0) return;
|
|
8820
8345
|
const file = $input.files[0];
|
|
8821
8346
|
this.uploadImg(file);
|
|
8822
8347
|
}))();
|
|
@@ -8829,8 +8354,7 @@ class Upload extends EditorPlug {
|
|
|
8829
8354
|
}
|
|
8830
8355
|
initDragImg() {
|
|
8831
8356
|
const uploadFromFileList = (files) => {
|
|
8832
|
-
if (!files)
|
|
8833
|
-
return;
|
|
8357
|
+
if (!files) return;
|
|
8834
8358
|
for (let i = 0; i < files.length; i++) {
|
|
8835
8359
|
const file = files[i];
|
|
8836
8360
|
this.uploadImg(file);
|
|
@@ -8870,15 +8394,13 @@ class Upload extends EditorPlug {
|
|
|
8870
8394
|
uploadImg(file) {
|
|
8871
8395
|
return __async(this, null, function* () {
|
|
8872
8396
|
const fileExt = /[^.]+$/.exec(file.name);
|
|
8873
|
-
if (!fileExt || !AllowImgExts.includes(String(fileExt[0]).toLowerCase()))
|
|
8874
|
-
return;
|
|
8397
|
+
if (!fileExt || !AllowImgExts.includes(String(fileExt[0]).toLowerCase())) return;
|
|
8875
8398
|
if (!this.kit.useUser().checkHasBasicUserInfo()) {
|
|
8876
8399
|
this.kit.useEditor().showNotify(t("uploadLoginMsg"), "w");
|
|
8877
8400
|
return;
|
|
8878
8401
|
}
|
|
8879
8402
|
let insertPrefix = "\n";
|
|
8880
|
-
if (this.kit.useUI().$textarea.value.trim() === "")
|
|
8881
|
-
insertPrefix = "";
|
|
8403
|
+
if (this.kit.useUI().$textarea.value.trim() === "") insertPrefix = "";
|
|
8882
8404
|
const uploadPlaceholderTxt = `${insertPrefix}`;
|
|
8883
8405
|
this.kit.useEditor().insertContent(uploadPlaceholderTxt);
|
|
8884
8406
|
let resp;
|
|
@@ -9048,8 +8570,7 @@ class PlugManager {
|
|
|
9048
8570
|
clear() {
|
|
9049
8571
|
this.plugs = [];
|
|
9050
8572
|
this.events = new EventManager();
|
|
9051
|
-
if (this.openedPlug)
|
|
9052
|
-
this.closePlugPanel();
|
|
8573
|
+
if (this.openedPlug) this.closePlugPanel();
|
|
9053
8574
|
}
|
|
9054
8575
|
loadPluginUI() {
|
|
9055
8576
|
this.editor.getUI().$plugPanelWrap.innerHTML = "";
|
|
@@ -9060,8 +8581,7 @@ class PlugManager {
|
|
|
9060
8581
|
/** Load the plug btn and plug panel on editor ui */
|
|
9061
8582
|
loadPluginItem(plug) {
|
|
9062
8583
|
const $btn = plug.$btn;
|
|
9063
|
-
if (!$btn)
|
|
9064
|
-
return;
|
|
8584
|
+
if (!$btn) return;
|
|
9065
8585
|
this.editor.getUI().$plugBtnWrap.appendChild($btn);
|
|
9066
8586
|
!$btn.onclick && ($btn.onclick = () => {
|
|
9067
8587
|
this.editor.getUI().$plugBtnWrap.querySelectorAll(".active").forEach((item) => item.classList.remove("active"));
|
|
@@ -9085,8 +8605,7 @@ class PlugManager {
|
|
|
9085
8605
|
openPlugPanel(plug) {
|
|
9086
8606
|
this.plugs.forEach((aPlug) => {
|
|
9087
8607
|
const plugPanel = aPlug.$panel;
|
|
9088
|
-
if (!plugPanel)
|
|
9089
|
-
return;
|
|
8608
|
+
if (!plugPanel) return;
|
|
9090
8609
|
if (aPlug === plug) {
|
|
9091
8610
|
plugPanel.style.display = "";
|
|
9092
8611
|
this.events.trigger("panel-show", plug);
|
|
@@ -9100,8 +8619,7 @@ class PlugManager {
|
|
|
9100
8619
|
}
|
|
9101
8620
|
/** Close the editor plug panel */
|
|
9102
8621
|
closePlugPanel() {
|
|
9103
|
-
if (!this.openedPlug)
|
|
9104
|
-
return;
|
|
8622
|
+
if (!this.openedPlug) return;
|
|
9105
8623
|
this.editor.getUI().$plugPanelWrap.style.display = "none";
|
|
9106
8624
|
this.events.trigger("panel-hide", this.openedPlug);
|
|
9107
8625
|
this.openedPlug = null;
|
|
@@ -9110,8 +8628,7 @@ class PlugManager {
|
|
|
9110
8628
|
getTransformedContent(rawContent) {
|
|
9111
8629
|
let result = rawContent;
|
|
9112
8630
|
this.plugs.forEach((aPlug) => {
|
|
9113
|
-
if (!aPlug.contentTransformer)
|
|
9114
|
-
return;
|
|
8631
|
+
if (!aPlug.contentTransformer) return;
|
|
9115
8632
|
result = aPlug.contentTransformer(result);
|
|
9116
8633
|
});
|
|
9117
8634
|
return result;
|
|
@@ -9124,8 +8641,7 @@ const WithEditor = (ctx) => {
|
|
|
9124
8641
|
$closeCommentBtn = list2.$el.querySelector('[data-action="admin-close-comment"]');
|
|
9125
8642
|
$closeCommentBtn.addEventListener("click", () => {
|
|
9126
8643
|
const page = ctx.getData().getPage();
|
|
9127
|
-
if (!page)
|
|
9128
|
-
throw new Error("Page data not found");
|
|
8644
|
+
if (!page) throw new Error("Page data not found");
|
|
9129
8645
|
page.admin_only = !page.admin_only;
|
|
9130
8646
|
adminPageEditSave(ctx, page);
|
|
9131
8647
|
});
|
|
@@ -9187,8 +8703,7 @@ const Count = (ctx) => {
|
|
|
9187
8703
|
var _a, _b;
|
|
9188
8704
|
const list2 = ctx.get("list");
|
|
9189
8705
|
const $count = list2.$el.querySelector(".atk-comment-count .atk-text");
|
|
9190
|
-
if (!$count)
|
|
9191
|
-
return;
|
|
8706
|
+
if (!$count) return;
|
|
9192
8707
|
const text = htmlEncode(
|
|
9193
8708
|
t("counter", {
|
|
9194
8709
|
count: `${Number((_b = (_a = ctx.getData().getListLastFetch()) == null ? void 0 : _a.data) == null ? void 0 : _b.count) || 0}`
|
|
@@ -9201,26 +8716,22 @@ const Count = (ctx) => {
|
|
|
9201
8716
|
});
|
|
9202
8717
|
ctx.on("comment-inserted", () => {
|
|
9203
8718
|
const last = ctx.getData().getListLastFetch();
|
|
9204
|
-
if (last == null ? void 0 : last.data)
|
|
9205
|
-
last.data.count += 1;
|
|
8719
|
+
if (last == null ? void 0 : last.data) last.data.count += 1;
|
|
9206
8720
|
});
|
|
9207
8721
|
ctx.on("comment-deleted", () => {
|
|
9208
8722
|
const last = ctx.getData().getListLastFetch();
|
|
9209
|
-
if (last == null ? void 0 : last.data)
|
|
9210
|
-
last.data.count -= 1;
|
|
8723
|
+
if (last == null ? void 0 : last.data) last.data.count -= 1;
|
|
9211
8724
|
});
|
|
9212
8725
|
};
|
|
9213
8726
|
const SidebarBtn = (ctx) => {
|
|
9214
8727
|
let $openSidebarBtn = null;
|
|
9215
8728
|
const syncByUser = () => {
|
|
9216
|
-
if (!$openSidebarBtn)
|
|
9217
|
-
return;
|
|
8729
|
+
if (!$openSidebarBtn) return;
|
|
9218
8730
|
const user = ctx.get("user").getData();
|
|
9219
|
-
if (!!user.
|
|
8731
|
+
if (!!user.name && !!user.email) {
|
|
9220
8732
|
$openSidebarBtn.classList.remove("atk-hide");
|
|
9221
8733
|
const $btnText = $openSidebarBtn.querySelector(".atk-text");
|
|
9222
|
-
if ($btnText)
|
|
9223
|
-
$btnText.innerText = !user.isAdmin ? t("msgCenter") : t("ctrlCenter");
|
|
8734
|
+
if ($btnText) $btnText.innerText = !user.is_admin ? t("msgCenter") : t("ctrlCenter");
|
|
9224
8735
|
} else {
|
|
9225
8736
|
$openSidebarBtn.classList.add("atk-hide");
|
|
9226
8737
|
}
|
|
@@ -9228,8 +8739,7 @@ const SidebarBtn = (ctx) => {
|
|
|
9228
8739
|
ctx.watchConf(["locale"], (conf) => {
|
|
9229
8740
|
const list2 = ctx.get("list");
|
|
9230
8741
|
$openSidebarBtn = list2.$el.querySelector('[data-action="open-sidebar"]');
|
|
9231
|
-
if (!$openSidebarBtn)
|
|
9232
|
-
return;
|
|
8742
|
+
if (!$openSidebarBtn) return;
|
|
9233
8743
|
$openSidebarBtn.onclick = () => {
|
|
9234
8744
|
ctx.showSidebar();
|
|
9235
8745
|
};
|
|
@@ -9242,8 +8752,7 @@ const SidebarBtn = (ctx) => {
|
|
|
9242
8752
|
const UnreadBadge = (ctx) => {
|
|
9243
8753
|
let $unreadBadge = null;
|
|
9244
8754
|
const showUnreadBadge = (count) => {
|
|
9245
|
-
if (!$unreadBadge)
|
|
9246
|
-
return;
|
|
8755
|
+
if (!$unreadBadge) return;
|
|
9247
8756
|
if (count > 0) {
|
|
9248
8757
|
$unreadBadge.innerText = `${Number(count || 0)}`;
|
|
9249
8758
|
$unreadBadge.style.display = "block";
|
|
@@ -9263,10 +8772,8 @@ const GotoDispatcher = (ctx) => {
|
|
|
9263
8772
|
let lastID = 0;
|
|
9264
8773
|
const check2 = ({ locker }) => {
|
|
9265
8774
|
const commentID = extractCommentID();
|
|
9266
|
-
if (!commentID)
|
|
9267
|
-
|
|
9268
|
-
if (locker && lastID === commentID)
|
|
9269
|
-
return;
|
|
8775
|
+
if (!commentID) return;
|
|
8776
|
+
if (locker && lastID === commentID) return;
|
|
9270
8777
|
lastID = commentID;
|
|
9271
8778
|
ctx.trigger("list-goto", commentID);
|
|
9272
8779
|
};
|
|
@@ -9297,18 +8804,16 @@ const GotoFocus = (ctx) => {
|
|
|
9297
8804
|
ctx.get("list").getListLayout({ forceFlatMode: true }).insert(data.comment, data.reply_comment);
|
|
9298
8805
|
comment = ctx.getCommentNodes().find((c) => c.getID() === commentID);
|
|
9299
8806
|
}
|
|
9300
|
-
if (!comment)
|
|
9301
|
-
return;
|
|
8807
|
+
if (!comment) return;
|
|
9302
8808
|
comment.focus();
|
|
9303
8809
|
}));
|
|
9304
8810
|
};
|
|
9305
|
-
const version = "2.
|
|
8811
|
+
const version = "2.9.0";
|
|
9306
8812
|
const Copyright = (ctx) => {
|
|
9307
8813
|
ctx.on("mounted", () => {
|
|
9308
8814
|
const list2 = ctx.get("list");
|
|
9309
8815
|
const $copyright = list2.$el.querySelector(".atk-copyright");
|
|
9310
|
-
if (!$copyright)
|
|
9311
|
-
return;
|
|
8816
|
+
if (!$copyright) return;
|
|
9312
8817
|
$copyright.innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${version}">Artalk</a>`;
|
|
9313
8818
|
});
|
|
9314
8819
|
};
|
|
@@ -9375,8 +8880,7 @@ const Dropdown = (ctx) => {
|
|
|
9375
8880
|
ctx.watchConf(["listSort", "locale"], (conf) => {
|
|
9376
8881
|
const list2 = ctx.get("list");
|
|
9377
8882
|
const $count = list2.$el.querySelector(".atk-comment-count");
|
|
9378
|
-
if (!$count)
|
|
9379
|
-
return;
|
|
8883
|
+
if (!$count) return;
|
|
9380
8884
|
if (conf.listSort) {
|
|
9381
8885
|
initDropdown($count);
|
|
9382
8886
|
} else {
|
|
@@ -9388,8 +8892,7 @@ const Dropdown = (ctx) => {
|
|
|
9388
8892
|
};
|
|
9389
8893
|
function renderDropdown(conf) {
|
|
9390
8894
|
const { $dropdownWrap, dropdownList } = conf;
|
|
9391
|
-
if ($dropdownWrap.querySelector(".atk-dropdown"))
|
|
9392
|
-
return;
|
|
8895
|
+
if ($dropdownWrap.querySelector(".atk-dropdown")) return;
|
|
9393
8896
|
$dropdownWrap.classList.add("atk-dropdown-wrap");
|
|
9394
8897
|
$dropdownWrap.append(createElement(`<span class="atk-arrow-down-icon"></span>`));
|
|
9395
8898
|
let curtActive = 0;
|
|
@@ -9415,8 +8918,7 @@ function renderDropdown(conf) {
|
|
|
9415
8918
|
onItemClick(i, $item, name, action);
|
|
9416
8919
|
};
|
|
9417
8920
|
$dropdown.append($item);
|
|
9418
|
-
if (i === curtActive)
|
|
9419
|
-
$item.classList.add("active");
|
|
8921
|
+
if (i === curtActive) $item.classList.add("active");
|
|
9420
8922
|
});
|
|
9421
8923
|
$dropdownWrap.append($dropdown);
|
|
9422
8924
|
}
|
|
@@ -9433,8 +8935,9 @@ const TimeTicking = (ctx) => {
|
|
|
9433
8935
|
timer = window.setInterval(() => {
|
|
9434
8936
|
const list2 = ctx.get("list");
|
|
9435
8937
|
list2.$el.querySelectorAll("[data-atk-comment-date]").forEach((el) => {
|
|
9436
|
-
|
|
9437
|
-
|
|
8938
|
+
var _a, _b;
|
|
8939
|
+
const date = new Date(Number(el.getAttribute("data-atk-comment-date")));
|
|
8940
|
+
el.innerText = ((_b = (_a = ctx.getConf()).dateFormatter) == null ? void 0 : _b.call(_a, date)) || timeAgo(date, ctx.$t);
|
|
9438
8941
|
});
|
|
9439
8942
|
}, 30 * 1e3);
|
|
9440
8943
|
});
|
|
@@ -9487,8 +8990,7 @@ const Loading = (ctx) => {
|
|
|
9487
8990
|
};
|
|
9488
8991
|
const Fetch = (ctx) => {
|
|
9489
8992
|
ctx.on("list-fetch", (_params) => {
|
|
9490
|
-
if (ctx.getData().getLoading())
|
|
9491
|
-
return;
|
|
8993
|
+
if (ctx.getData().getLoading()) return;
|
|
9492
8994
|
ctx.getData().setLoading(true);
|
|
9493
8995
|
const params = __spreadValues({
|
|
9494
8996
|
// default params
|
|
@@ -9508,8 +9010,7 @@ const Fetch = (ctx) => {
|
|
|
9508
9010
|
page_key: ctx.getConf().pageKey,
|
|
9509
9011
|
site_name: ctx.getConf().site
|
|
9510
9012
|
};
|
|
9511
|
-
if (params.paramsModifier)
|
|
9512
|
-
params.paramsModifier(reqParams);
|
|
9013
|
+
if (params.paramsModifier) params.paramsModifier(reqParams);
|
|
9513
9014
|
ctx.getApi().comments.getComments(__spreadValues(__spreadValues({}, reqParams), ctx.getApi().getUserFields())).then(({ data }) => {
|
|
9514
9015
|
ctx.getData().setListLastFetch({ params, data });
|
|
9515
9016
|
ctx.getData().loadComments(data.comments);
|
|
@@ -9560,8 +9061,7 @@ const ReachBottom = (ctx) => {
|
|
|
9560
9061
|
const list2 = ctx.get("list");
|
|
9561
9062
|
const children = list2.getCommentsWrapEl().childNodes;
|
|
9562
9063
|
const $target = children.length > 2 ? children[children.length - 2] : null;
|
|
9563
|
-
if (!$target)
|
|
9564
|
-
return;
|
|
9064
|
+
if (!$target) return;
|
|
9565
9065
|
if (!("IntersectionObserver" in window)) {
|
|
9566
9066
|
console.warn("IntersectionObserver api not supported");
|
|
9567
9067
|
return;
|
|
@@ -9608,11 +9108,9 @@ const ListPlugins = [
|
|
|
9608
9108
|
];
|
|
9609
9109
|
const Notifies = (ctx) => {
|
|
9610
9110
|
ctx.on("list-fetch", (params) => {
|
|
9611
|
-
if (params.offset !== 0)
|
|
9612
|
-
return;
|
|
9111
|
+
if (params.offset !== 0) return;
|
|
9613
9112
|
const user = ctx.getApi().getUserFields();
|
|
9614
|
-
if (!user)
|
|
9615
|
-
return;
|
|
9113
|
+
if (!user) return;
|
|
9616
9114
|
ctx.getApi().notifies.getNotifies(user).then((res) => {
|
|
9617
9115
|
ctx.getData().updateNotifies(res.data.notifies);
|
|
9618
9116
|
});
|
|
@@ -9629,8 +9127,7 @@ const VersionCheck = (ctx) => {
|
|
|
9629
9127
|
function versionCheck(list2, feVer, beVer) {
|
|
9630
9128
|
const comp = versionCompare(feVer, beVer);
|
|
9631
9129
|
const sameVer = comp === 0;
|
|
9632
|
-
if (sameVer)
|
|
9633
|
-
return;
|
|
9130
|
+
if (sameVer) return;
|
|
9634
9131
|
const errEl = createElement(
|
|
9635
9132
|
`<div class="atk-version-check-notice">${t("updateMsg", {
|
|
9636
9133
|
name: comp < 0 ? t("frontend") : t("backend")
|
|
@@ -9647,7 +9144,7 @@ function versionCheck(list2, feVer, beVer) {
|
|
|
9647
9144
|
const AdminOnlyElem = (ctx) => {
|
|
9648
9145
|
const scanApply = () => {
|
|
9649
9146
|
applyAdminOnlyEls(
|
|
9650
|
-
ctx.get("user").getData().
|
|
9147
|
+
ctx.get("user").getData().is_admin,
|
|
9651
9148
|
getAdminOnlyEls({
|
|
9652
9149
|
$root: ctx.$root
|
|
9653
9150
|
})
|
|
@@ -9670,20 +9167,16 @@ function getAdminOnlyEls(opts) {
|
|
|
9670
9167
|
}
|
|
9671
9168
|
function applyAdminOnlyEls(isAdmin, els) {
|
|
9672
9169
|
els.forEach(($item) => {
|
|
9673
|
-
if (isAdmin)
|
|
9674
|
-
|
|
9675
|
-
else
|
|
9676
|
-
$item.classList.add("atk-hide");
|
|
9170
|
+
if (isAdmin) $item.classList.remove("atk-hide");
|
|
9171
|
+
else $item.classList.add("atk-hide");
|
|
9677
9172
|
});
|
|
9678
9173
|
}
|
|
9679
9174
|
let darkModeMedia;
|
|
9680
9175
|
function updateClassnames($els, darkMode) {
|
|
9681
9176
|
const DarkModeClassName = "atk-dark-mode";
|
|
9682
9177
|
$els.forEach(($el) => {
|
|
9683
|
-
if (darkMode)
|
|
9684
|
-
|
|
9685
|
-
else
|
|
9686
|
-
$el.classList.remove(DarkModeClassName);
|
|
9178
|
+
if (darkMode) $el.classList.add(DarkModeClassName);
|
|
9179
|
+
else $el.classList.remove(DarkModeClassName);
|
|
9687
9180
|
});
|
|
9688
9181
|
}
|
|
9689
9182
|
const DarkMode = (ctx) => {
|
|
@@ -9725,6 +9218,7 @@ const DefaultPlugins = [
|
|
|
9725
9218
|
DarkMode
|
|
9726
9219
|
];
|
|
9727
9220
|
const GlobalPlugins = /* @__PURE__ */ new Set([...DefaultPlugins]);
|
|
9221
|
+
const PluginOptions = /* @__PURE__ */ new WeakMap();
|
|
9728
9222
|
function load(ctx) {
|
|
9729
9223
|
return __async(this, null, function* () {
|
|
9730
9224
|
var _a;
|
|
@@ -9732,7 +9226,7 @@ function load(ctx) {
|
|
|
9732
9226
|
const loadPlugins = (plugins) => {
|
|
9733
9227
|
plugins.forEach((plugin) => {
|
|
9734
9228
|
if (typeof plugin === "function" && !loadedPlugins.has(plugin)) {
|
|
9735
|
-
plugin(ctx);
|
|
9229
|
+
plugin(ctx, PluginOptions.get(plugin));
|
|
9736
9230
|
loadedPlugins.add(plugin);
|
|
9737
9231
|
}
|
|
9738
9232
|
});
|
|
@@ -9770,8 +9264,7 @@ function load(ctx) {
|
|
|
9770
9264
|
function loadNetworkPlugins(scripts, apiBase) {
|
|
9771
9265
|
return __async(this, null, function* () {
|
|
9772
9266
|
const networkPlugins = /* @__PURE__ */ new Set();
|
|
9773
|
-
if (!scripts || !Array.isArray(scripts))
|
|
9774
|
-
return networkPlugins;
|
|
9267
|
+
if (!scripts || !Array.isArray(scripts)) return networkPlugins;
|
|
9775
9268
|
const tasks = [];
|
|
9776
9269
|
scripts.forEach((url) => {
|
|
9777
9270
|
if (!/^(http|https):\/\//.test(url))
|
|
@@ -9792,8 +9285,7 @@ function loadNetworkPlugins(scripts, apiBase) {
|
|
|
9792
9285
|
});
|
|
9793
9286
|
yield Promise.all(tasks);
|
|
9794
9287
|
Object.values(window.ArtalkPlugins || {}).forEach((plugin) => {
|
|
9795
|
-
if (typeof plugin === "function")
|
|
9796
|
-
networkPlugins.add(plugin);
|
|
9288
|
+
if (typeof plugin === "function") networkPlugins.add(plugin);
|
|
9797
9289
|
});
|
|
9798
9290
|
return networkPlugins;
|
|
9799
9291
|
});
|
|
@@ -9813,7 +9305,7 @@ function onLoadErr(ctx, err) {
|
|
|
9813
9305
|
errMsg: err.msg || String(err),
|
|
9814
9306
|
errData: err.data,
|
|
9815
9307
|
retryFn: () => load(ctx),
|
|
9816
|
-
onOpenSidebar: ctx.get("user").getData().
|
|
9308
|
+
onOpenSidebar: ctx.get("user").getData().is_admin ? () => ctx.showSidebar({
|
|
9817
9309
|
view: sidebarOpenView
|
|
9818
9310
|
}) : void 0
|
|
9819
9311
|
// only show open sidebar button when user is admin
|
|
@@ -9880,8 +9372,9 @@ class Artalk {
|
|
|
9880
9372
|
return new Artalk(conf);
|
|
9881
9373
|
}
|
|
9882
9374
|
/** Use plugin, the plugin will be used when Artalk.init */
|
|
9883
|
-
static use(plugin) {
|
|
9375
|
+
static use(plugin, options) {
|
|
9884
9376
|
GlobalPlugins.add(plugin);
|
|
9377
|
+
PluginOptions.set(plugin, options);
|
|
9885
9378
|
}
|
|
9886
9379
|
/** Load count widget */
|
|
9887
9380
|
static loadCountWidget(c) {
|