artalk 2.8.6 → 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 +953 -1421
- 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 +641 -1148
- 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 +157 -94
- package/dist/main.d.ts +157 -94
- package/package.json +56 -24
- /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);
|
|
@@ -4685,218 +4347,14 @@ class DataManager {
|
|
|
4685
4347
|
this.events.trigger("page-loaded", pageData);
|
|
4686
4348
|
}
|
|
4687
4349
|
}
|
|
4688
|
-
const en = {
|
|
4689
|
-
/* Editor */
|
|
4690
|
-
placeholder: "Leave a comment",
|
|
4691
|
-
noComment: "No Comment",
|
|
4692
|
-
send: "Send",
|
|
4693
|
-
signIn: "Sign in",
|
|
4694
|
-
signUp: "Sign up",
|
|
4695
|
-
save: "Save",
|
|
4696
|
-
nick: "Nickname",
|
|
4697
|
-
email: "Email",
|
|
4698
|
-
link: "Website",
|
|
4699
|
-
emoticon: "Emoji",
|
|
4700
|
-
preview: "Preview",
|
|
4701
|
-
uploadImage: "Upload Image",
|
|
4702
|
-
uploadFail: "Upload Failed",
|
|
4703
|
-
commentFail: "Failed to comment",
|
|
4704
|
-
restoredMsg: "Content has been restored",
|
|
4705
|
-
onlyAdminCanReply: "Only admin can reply",
|
|
4706
|
-
uploadLoginMsg: "Please fill in your name and email to upload",
|
|
4707
|
-
/* List */
|
|
4708
|
-
counter: "{count} Comments",
|
|
4709
|
-
sortLatest: "Latest",
|
|
4710
|
-
sortOldest: "Oldest",
|
|
4711
|
-
sortBest: "Best",
|
|
4712
|
-
sortAuthor: "Author",
|
|
4713
|
-
openComment: "Open Comment",
|
|
4714
|
-
closeComment: "Close Comment",
|
|
4715
|
-
listLoadFailMsg: "Failed to load comments",
|
|
4716
|
-
listRetry: "Retry",
|
|
4717
|
-
loadMore: "Load More",
|
|
4718
|
-
/* Comment */
|
|
4719
|
-
admin: "Admin",
|
|
4720
|
-
reply: "Reply",
|
|
4721
|
-
voteUp: "Up",
|
|
4722
|
-
voteDown: "Down",
|
|
4723
|
-
voteFail: "Vote Failed",
|
|
4724
|
-
readMore: "Read More",
|
|
4725
|
-
actionConfirm: "Confirm",
|
|
4726
|
-
collapse: "Collapse",
|
|
4727
|
-
collapsed: "Collapsed",
|
|
4728
|
-
collapsedMsg: "This comment has been collapsed",
|
|
4729
|
-
expand: "Expand",
|
|
4730
|
-
approved: "Approved",
|
|
4731
|
-
pending: "Pending",
|
|
4732
|
-
pendingMsg: "Pending, visible only to commenter.",
|
|
4733
|
-
edit: "Edit",
|
|
4734
|
-
editCancel: "Cancel Edit",
|
|
4735
|
-
delete: "Delete",
|
|
4736
|
-
deleteConfirm: "Confirm",
|
|
4737
|
-
pin: "Pin",
|
|
4738
|
-
unpin: "Unpin",
|
|
4739
|
-
/* Time */
|
|
4740
|
-
seconds: "seconds ago",
|
|
4741
|
-
minutes: "minutes ago",
|
|
4742
|
-
hours: "hours ago",
|
|
4743
|
-
days: "days ago",
|
|
4744
|
-
now: "just now",
|
|
4745
|
-
/* Checker */
|
|
4746
|
-
adminCheck: "Enter admin password:",
|
|
4747
|
-
captchaCheck: "Enter the CAPTCHA to continue:",
|
|
4748
|
-
confirm: "Confirm",
|
|
4749
|
-
cancel: "Cancel",
|
|
4750
|
-
/* Sidebar */
|
|
4751
|
-
msgCenter: "Messages",
|
|
4752
|
-
ctrlCenter: "Admin",
|
|
4753
|
-
/* Auth */
|
|
4754
|
-
noAccountPrompt: "Don't have an account?",
|
|
4755
|
-
haveAccountPrompt: "Already have an account?",
|
|
4756
|
-
forgetPassword: "Forget Password",
|
|
4757
|
-
resetPassword: "Reset Password",
|
|
4758
|
-
verificationCode: "Verification Code",
|
|
4759
|
-
verifySend: "Verify",
|
|
4760
|
-
verifyResend: "Resend",
|
|
4761
|
-
waitSeconds: "Wait {seconds}s",
|
|
4762
|
-
emailVerified: "Email has been verified",
|
|
4763
|
-
password: "Password",
|
|
4764
|
-
username: "Username",
|
|
4765
|
-
nextStep: "Next Step",
|
|
4766
|
-
skipNotVerify: "Skip, do not verify",
|
|
4767
|
-
logoutConfirm: "Are you sure to logout?",
|
|
4768
|
-
accountMergeNotice: "Your email has multiple accounts with different id.",
|
|
4769
|
-
accountMergeSelectOne: "Please select one you want to merge all the data into it.",
|
|
4770
|
-
accountMergeConfirm: "All data will be merged into one account, the id is {id}.",
|
|
4771
|
-
dismiss: "Dismiss",
|
|
4772
|
-
merge: "Merge",
|
|
4773
|
-
/* General */
|
|
4774
|
-
frontend: "Frontend",
|
|
4775
|
-
backend: "Backend",
|
|
4776
|
-
loading: "Loading",
|
|
4777
|
-
loadFail: "Load Failed",
|
|
4778
|
-
editing: "Editing",
|
|
4779
|
-
editFail: "Edit Failed",
|
|
4780
|
-
deleting: "Deleting",
|
|
4781
|
-
deleteFail: "Delete Failed",
|
|
4782
|
-
reqGot: "Request got",
|
|
4783
|
-
reqAborted: "Request timed out or terminated unexpectedly",
|
|
4784
|
-
updateMsg: "Please update Artalk {name} to get the best experience!",
|
|
4785
|
-
currentVersion: "Current Version",
|
|
4786
|
-
ignore: "Ignore",
|
|
4787
|
-
open: "Open",
|
|
4788
|
-
openName: "Open {name}"
|
|
4789
|
-
};
|
|
4790
|
-
const zhCN = {
|
|
4791
|
-
/* Editor */
|
|
4792
|
-
placeholder: "键入内容...",
|
|
4793
|
-
noComment: "「此时无声胜有声」",
|
|
4794
|
-
send: "发送",
|
|
4795
|
-
signIn: "登录",
|
|
4796
|
-
signUp: "注册",
|
|
4797
|
-
save: "保存",
|
|
4798
|
-
nick: "昵称",
|
|
4799
|
-
email: "邮箱",
|
|
4800
|
-
link: "网址",
|
|
4801
|
-
emoticon: "表情",
|
|
4802
|
-
preview: "预览",
|
|
4803
|
-
uploadImage: "上传图片",
|
|
4804
|
-
uploadFail: "上传失败",
|
|
4805
|
-
commentFail: "评论失败",
|
|
4806
|
-
restoredMsg: "内容已自动恢复",
|
|
4807
|
-
onlyAdminCanReply: "仅管理员可评论",
|
|
4808
|
-
uploadLoginMsg: "填入你的名字邮箱才能上传哦",
|
|
4809
|
-
/* List */
|
|
4810
|
-
counter: "{count} 条评论",
|
|
4811
|
-
sortLatest: "最新",
|
|
4812
|
-
sortOldest: "最早",
|
|
4813
|
-
sortBest: "最热",
|
|
4814
|
-
sortAuthor: "作者",
|
|
4815
|
-
openComment: "打开评论",
|
|
4816
|
-
closeComment: "关闭评论",
|
|
4817
|
-
listLoadFailMsg: "无法获取评论列表数据",
|
|
4818
|
-
listRetry: "点击重新获取",
|
|
4819
|
-
loadMore: "加载更多",
|
|
4820
|
-
/* Comment */
|
|
4821
|
-
admin: "管理员",
|
|
4822
|
-
reply: "回复",
|
|
4823
|
-
voteUp: "赞同",
|
|
4824
|
-
voteDown: "反对",
|
|
4825
|
-
voteFail: "投票失败",
|
|
4826
|
-
readMore: "阅读更多",
|
|
4827
|
-
actionConfirm: "确认操作",
|
|
4828
|
-
collapse: "折叠",
|
|
4829
|
-
collapsed: "已折叠",
|
|
4830
|
-
collapsedMsg: "该评论已被系统或管理员折叠",
|
|
4831
|
-
expand: "展开",
|
|
4832
|
-
approved: "已审",
|
|
4833
|
-
pending: "待审",
|
|
4834
|
-
pendingMsg: "审核中,仅本人可见。",
|
|
4835
|
-
edit: "编辑",
|
|
4836
|
-
editCancel: "取消编辑",
|
|
4837
|
-
delete: "删除",
|
|
4838
|
-
deleteConfirm: "确认删除",
|
|
4839
|
-
pin: "置顶",
|
|
4840
|
-
unpin: "取消置顶",
|
|
4841
|
-
/* Time */
|
|
4842
|
-
seconds: "秒前",
|
|
4843
|
-
minutes: "分钟前",
|
|
4844
|
-
hours: "小时前",
|
|
4845
|
-
days: "天前",
|
|
4846
|
-
now: "刚刚",
|
|
4847
|
-
/* Checker */
|
|
4848
|
-
adminCheck: "键入密码来验证管理员身份:",
|
|
4849
|
-
captchaCheck: "键入验证码继续:",
|
|
4850
|
-
confirm: "确认",
|
|
4851
|
-
cancel: "取消",
|
|
4852
|
-
/* Sidebar */
|
|
4853
|
-
msgCenter: "通知中心",
|
|
4854
|
-
ctrlCenter: "控制中心",
|
|
4855
|
-
/* Auth */
|
|
4856
|
-
noAccountPrompt: "没有账号?",
|
|
4857
|
-
haveAccountPrompt: "已有账号?",
|
|
4858
|
-
forgetPassword: "忘记密码",
|
|
4859
|
-
resetPassword: "重置密码",
|
|
4860
|
-
verificationCode: "验证码",
|
|
4861
|
-
verifySend: "发送验证码",
|
|
4862
|
-
verifyResend: "重新发送",
|
|
4863
|
-
waitSeconds: "等待 {seconds}秒",
|
|
4864
|
-
emailVerified: "邮箱已验证",
|
|
4865
|
-
password: "密码",
|
|
4866
|
-
username: "用户名",
|
|
4867
|
-
nextStep: "下一步",
|
|
4868
|
-
skipNotVerify: "跳过,不验证",
|
|
4869
|
-
logoutConfirm: "确定要退出登录吗?",
|
|
4870
|
-
accountMergeNotice: "您的电子邮件下有多个不同 ID 的账户。",
|
|
4871
|
-
accountMergeSelectOne: "请选择将所有数据合并到其中的一个。",
|
|
4872
|
-
accountMergeConfirm: "所有数据将合并到 ID 为 {id} 的账户中。",
|
|
4873
|
-
dismiss: "忽略",
|
|
4874
|
-
merge: "合并",
|
|
4875
|
-
/* General */
|
|
4876
|
-
frontend: "前端",
|
|
4877
|
-
backend: "后端",
|
|
4878
|
-
loading: "加载中",
|
|
4879
|
-
loadFail: "加载失败",
|
|
4880
|
-
editing: "修改中",
|
|
4881
|
-
editFail: "修改失败",
|
|
4882
|
-
deleting: "删除中",
|
|
4883
|
-
deleteFail: "删除失败",
|
|
4884
|
-
reqGot: "请求响应",
|
|
4885
|
-
reqAborted: "请求超时或意外终止",
|
|
4886
|
-
updateMsg: "请更新 Artalk {name} 以获得更好的体验!",
|
|
4887
|
-
currentVersion: "当前版本",
|
|
4888
|
-
ignore: "忽略",
|
|
4889
|
-
open: "打开",
|
|
4890
|
-
openName: "打开{name}"
|
|
4891
|
-
};
|
|
4892
|
-
const GLOBAL_LOCALES_KEY = "ArtalkI18n";
|
|
4893
4350
|
function createElement(htmlStr = "") {
|
|
4894
4351
|
const div = document.createElement("div");
|
|
4895
4352
|
div.innerHTML = htmlStr.trim();
|
|
4896
4353
|
return div.firstElementChild || div;
|
|
4897
4354
|
}
|
|
4898
4355
|
function getHeight(el) {
|
|
4899
|
-
|
|
4356
|
+
const num = parseFloat(getComputedStyle(el, null).height.replace("px", ""));
|
|
4357
|
+
return num || 0;
|
|
4900
4358
|
}
|
|
4901
4359
|
function htmlEncode(str) {
|
|
4902
4360
|
const temp = document.createElement("div");
|
|
@@ -4919,8 +4377,7 @@ function getOffset(el, relativeTo) {
|
|
|
4919
4377
|
};
|
|
4920
4378
|
};
|
|
4921
4379
|
const elOffset = getOffsetRecursive(el);
|
|
4922
|
-
if (!relativeTo)
|
|
4923
|
-
return elOffset;
|
|
4380
|
+
if (!relativeTo) return elOffset;
|
|
4924
4381
|
const relativeToOffset = getOffsetRecursive(relativeTo);
|
|
4925
4382
|
return {
|
|
4926
4383
|
top: elOffset.top - relativeToOffset.top,
|
|
@@ -4955,16 +4412,14 @@ function timeAgo(date, $t = (n) => n) {
|
|
|
4955
4412
|
if (minutes === 0) {
|
|
4956
4413
|
const leave3 = leave2 % (60 * 1e3);
|
|
4957
4414
|
const seconds = Math.round(leave3 / 1e3);
|
|
4958
|
-
if (seconds < 10)
|
|
4959
|
-
return $t("now");
|
|
4415
|
+
if (seconds < 10) return $t("now");
|
|
4960
4416
|
return `${seconds} ${$t("seconds")}`;
|
|
4961
4417
|
}
|
|
4962
4418
|
return `${minutes} ${$t("minutes")}`;
|
|
4963
4419
|
}
|
|
4964
4420
|
return `${hours} ${$t("hours")}`;
|
|
4965
4421
|
}
|
|
4966
|
-
if (days < 0)
|
|
4967
|
-
return $t("now");
|
|
4422
|
+
if (days < 0) return $t("now");
|
|
4968
4423
|
if (days < 8) {
|
|
4969
4424
|
return `${days} ${$t("days")}`;
|
|
4970
4425
|
}
|
|
@@ -4975,7 +4430,7 @@ function timeAgo(date, $t = (n) => n) {
|
|
|
4975
4430
|
}
|
|
4976
4431
|
}
|
|
4977
4432
|
function getGravatarURL(opts) {
|
|
4978
|
-
return `${opts.mirror.replace(/\/$/, "")}/${opts.
|
|
4433
|
+
return `${opts.mirror.replace(/\/$/, "")}/${opts.emailHash}?${opts.params.replace(/^\?/, "")}`;
|
|
4979
4434
|
}
|
|
4980
4435
|
function versionCompare(a, b) {
|
|
4981
4436
|
const pa = a.split(".");
|
|
@@ -4983,14 +4438,10 @@ function versionCompare(a, b) {
|
|
|
4983
4438
|
for (let i = 0; i < 3; i++) {
|
|
4984
4439
|
const na = Number(pa[i]);
|
|
4985
4440
|
const nb = Number(pb[i]);
|
|
4986
|
-
if (na > nb)
|
|
4987
|
-
|
|
4988
|
-
if (nb
|
|
4989
|
-
|
|
4990
|
-
if (!Number.isNaN(na) && Number.isNaN(nb))
|
|
4991
|
-
return 1;
|
|
4992
|
-
if (Number.isNaN(na) && !Number.isNaN(nb))
|
|
4993
|
-
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;
|
|
4994
4445
|
}
|
|
4995
4446
|
return 0;
|
|
4996
4447
|
}
|
|
@@ -5040,6 +4491,219 @@ function getURLBasedOnApi(opts) {
|
|
|
5040
4491
|
function getURLBasedOn(baseURL, path) {
|
|
5041
4492
|
return `${baseURL.replace(/\/$/, "")}/${path.replace(/^\//, "")}`;
|
|
5042
4493
|
}
|
|
4494
|
+
const en = {
|
|
4495
|
+
/* Editor */
|
|
4496
|
+
placeholder: "Leave a comment",
|
|
4497
|
+
noComment: "No Comment",
|
|
4498
|
+
send: "Send",
|
|
4499
|
+
signIn: "Sign in",
|
|
4500
|
+
signUp: "Sign up",
|
|
4501
|
+
save: "Save",
|
|
4502
|
+
nick: "Nickname",
|
|
4503
|
+
email: "Email",
|
|
4504
|
+
link: "Website",
|
|
4505
|
+
emoticon: "Emoji",
|
|
4506
|
+
preview: "Preview",
|
|
4507
|
+
uploadImage: "Upload Image",
|
|
4508
|
+
uploadFail: "Upload Failed",
|
|
4509
|
+
commentFail: "Failed to comment",
|
|
4510
|
+
restoredMsg: "Content has been restored",
|
|
4511
|
+
onlyAdminCanReply: "Only admin can reply",
|
|
4512
|
+
uploadLoginMsg: "Please fill in your name and email to upload",
|
|
4513
|
+
/* List */
|
|
4514
|
+
counter: "{count} Comments",
|
|
4515
|
+
sortLatest: "Latest",
|
|
4516
|
+
sortOldest: "Oldest",
|
|
4517
|
+
sortBest: "Best",
|
|
4518
|
+
sortAuthor: "Author",
|
|
4519
|
+
openComment: "Open Comment",
|
|
4520
|
+
closeComment: "Close Comment",
|
|
4521
|
+
listLoadFailMsg: "Failed to load comments",
|
|
4522
|
+
listRetry: "Retry",
|
|
4523
|
+
loadMore: "Load More",
|
|
4524
|
+
/* Comment */
|
|
4525
|
+
admin: "Admin",
|
|
4526
|
+
reply: "Reply",
|
|
4527
|
+
voteUp: "Up",
|
|
4528
|
+
voteDown: "Down",
|
|
4529
|
+
voteFail: "Vote Failed",
|
|
4530
|
+
readMore: "Read More",
|
|
4531
|
+
actionConfirm: "Confirm",
|
|
4532
|
+
collapse: "Collapse",
|
|
4533
|
+
collapsed: "Collapsed",
|
|
4534
|
+
collapsedMsg: "This comment has been collapsed",
|
|
4535
|
+
expand: "Expand",
|
|
4536
|
+
approved: "Approved",
|
|
4537
|
+
pending: "Pending",
|
|
4538
|
+
pendingMsg: "Pending, visible only to commenter.",
|
|
4539
|
+
edit: "Edit",
|
|
4540
|
+
editCancel: "Cancel Edit",
|
|
4541
|
+
delete: "Delete",
|
|
4542
|
+
deleteConfirm: "Confirm",
|
|
4543
|
+
pin: "Pin",
|
|
4544
|
+
unpin: "Unpin",
|
|
4545
|
+
/* Time */
|
|
4546
|
+
seconds: "seconds ago",
|
|
4547
|
+
minutes: "minutes ago",
|
|
4548
|
+
hours: "hours ago",
|
|
4549
|
+
days: "days ago",
|
|
4550
|
+
now: "just now",
|
|
4551
|
+
/* Checker */
|
|
4552
|
+
adminCheck: "Enter admin password:",
|
|
4553
|
+
captchaCheck: "Enter the CAPTCHA to continue:",
|
|
4554
|
+
confirm: "Confirm",
|
|
4555
|
+
cancel: "Cancel",
|
|
4556
|
+
/* Sidebar */
|
|
4557
|
+
msgCenter: "Messages",
|
|
4558
|
+
ctrlCenter: "Dashboard",
|
|
4559
|
+
/* Auth */
|
|
4560
|
+
userProfile: "Profile",
|
|
4561
|
+
noAccountPrompt: "Don't have an account?",
|
|
4562
|
+
haveAccountPrompt: "Already have an account?",
|
|
4563
|
+
forgetPassword: "Forget Password",
|
|
4564
|
+
resetPassword: "Reset Password",
|
|
4565
|
+
changePassword: "Change Password",
|
|
4566
|
+
confirmPassword: "Confirm Password",
|
|
4567
|
+
passwordMismatch: "Passwords do not match",
|
|
4568
|
+
verificationCode: "Verification Code",
|
|
4569
|
+
verifySend: "Send Code",
|
|
4570
|
+
verifyResend: "Resend",
|
|
4571
|
+
waitSeconds: "Wait {seconds}s",
|
|
4572
|
+
emailVerified: "Email has been verified",
|
|
4573
|
+
password: "Password",
|
|
4574
|
+
username: "Username",
|
|
4575
|
+
nextStep: "Next Step",
|
|
4576
|
+
skipVerify: "Skip verification",
|
|
4577
|
+
logoutConfirm: "Are you sure to logout?",
|
|
4578
|
+
accountMergeNotice: "Your email has multiple accounts with different id.",
|
|
4579
|
+
accountMergeSelectOne: "Please select one you want to merge all the data into it.",
|
|
4580
|
+
accountMergeConfirm: "All data will be merged into one account, the id is {id}.",
|
|
4581
|
+
dismiss: "Dismiss",
|
|
4582
|
+
merge: "Merge",
|
|
4583
|
+
/* General */
|
|
4584
|
+
frontend: "Frontend",
|
|
4585
|
+
backend: "Backend",
|
|
4586
|
+
loading: "Loading",
|
|
4587
|
+
loadFail: "Load Failed",
|
|
4588
|
+
editing: "Editing",
|
|
4589
|
+
editFail: "Edit Failed",
|
|
4590
|
+
deleting: "Deleting",
|
|
4591
|
+
deleteFail: "Delete Failed",
|
|
4592
|
+
reqGot: "Request got",
|
|
4593
|
+
reqAborted: "Request timed out or terminated unexpectedly",
|
|
4594
|
+
updateMsg: "Please update Artalk {name} to get the best experience!",
|
|
4595
|
+
currentVersion: "Current Version",
|
|
4596
|
+
ignore: "Ignore",
|
|
4597
|
+
open: "Open",
|
|
4598
|
+
openName: "Open {name}"
|
|
4599
|
+
};
|
|
4600
|
+
const zhCN = {
|
|
4601
|
+
/* Editor */
|
|
4602
|
+
placeholder: "键入内容...",
|
|
4603
|
+
noComment: "「此时无声胜有声」",
|
|
4604
|
+
send: "发送",
|
|
4605
|
+
signIn: "登录",
|
|
4606
|
+
signUp: "注册",
|
|
4607
|
+
save: "保存",
|
|
4608
|
+
nick: "昵称",
|
|
4609
|
+
email: "邮箱",
|
|
4610
|
+
link: "网址",
|
|
4611
|
+
emoticon: "表情",
|
|
4612
|
+
preview: "预览",
|
|
4613
|
+
uploadImage: "上传图片",
|
|
4614
|
+
uploadFail: "上传失败",
|
|
4615
|
+
commentFail: "评论失败",
|
|
4616
|
+
restoredMsg: "内容已自动恢复",
|
|
4617
|
+
onlyAdminCanReply: "仅管理员可评论",
|
|
4618
|
+
uploadLoginMsg: "填入你的名字邮箱才能上传哦",
|
|
4619
|
+
/* List */
|
|
4620
|
+
counter: "{count} 条评论",
|
|
4621
|
+
sortLatest: "最新",
|
|
4622
|
+
sortOldest: "最早",
|
|
4623
|
+
sortBest: "最热",
|
|
4624
|
+
sortAuthor: "作者",
|
|
4625
|
+
openComment: "打开评论",
|
|
4626
|
+
closeComment: "关闭评论",
|
|
4627
|
+
listLoadFailMsg: "无法获取评论列表数据",
|
|
4628
|
+
listRetry: "点击重新获取",
|
|
4629
|
+
loadMore: "加载更多",
|
|
4630
|
+
/* Comment */
|
|
4631
|
+
admin: "管理员",
|
|
4632
|
+
reply: "回复",
|
|
4633
|
+
voteUp: "赞同",
|
|
4634
|
+
voteDown: "反对",
|
|
4635
|
+
voteFail: "投票失败",
|
|
4636
|
+
readMore: "阅读更多",
|
|
4637
|
+
actionConfirm: "确认操作",
|
|
4638
|
+
collapse: "折叠",
|
|
4639
|
+
collapsed: "已折叠",
|
|
4640
|
+
collapsedMsg: "该评论已被系统或管理员折叠",
|
|
4641
|
+
expand: "展开",
|
|
4642
|
+
approved: "已审",
|
|
4643
|
+
pending: "待审",
|
|
4644
|
+
pendingMsg: "审核中,仅本人可见。",
|
|
4645
|
+
edit: "编辑",
|
|
4646
|
+
editCancel: "取消编辑",
|
|
4647
|
+
delete: "删除",
|
|
4648
|
+
deleteConfirm: "确认删除",
|
|
4649
|
+
pin: "置顶",
|
|
4650
|
+
unpin: "取消置顶",
|
|
4651
|
+
/* Time */
|
|
4652
|
+
seconds: "秒前",
|
|
4653
|
+
minutes: "分钟前",
|
|
4654
|
+
hours: "小时前",
|
|
4655
|
+
days: "天前",
|
|
4656
|
+
now: "刚刚",
|
|
4657
|
+
/* Checker */
|
|
4658
|
+
adminCheck: "键入密码来验证管理员身份:",
|
|
4659
|
+
captchaCheck: "键入验证码继续:",
|
|
4660
|
+
confirm: "确认",
|
|
4661
|
+
cancel: "取消",
|
|
4662
|
+
/* Sidebar */
|
|
4663
|
+
msgCenter: "通知中心",
|
|
4664
|
+
ctrlCenter: "控制中心",
|
|
4665
|
+
/* Auth */
|
|
4666
|
+
userProfile: "个人资料",
|
|
4667
|
+
noAccountPrompt: "没有账号?",
|
|
4668
|
+
haveAccountPrompt: "已有账号?",
|
|
4669
|
+
forgetPassword: "忘记密码",
|
|
4670
|
+
resetPassword: "重置密码",
|
|
4671
|
+
changePassword: "修改密码",
|
|
4672
|
+
confirmPassword: "确认密码",
|
|
4673
|
+
passwordMismatch: "两次输入的密码不一致",
|
|
4674
|
+
verificationCode: "验证码",
|
|
4675
|
+
verifySend: "发送验证码",
|
|
4676
|
+
verifyResend: "重新发送",
|
|
4677
|
+
waitSeconds: "等待 {seconds}秒",
|
|
4678
|
+
emailVerified: "邮箱已验证",
|
|
4679
|
+
password: "密码",
|
|
4680
|
+
username: "用户名",
|
|
4681
|
+
nextStep: "下一步",
|
|
4682
|
+
skipVerify: "跳过验证",
|
|
4683
|
+
logoutConfirm: "确定要退出登录吗?",
|
|
4684
|
+
accountMergeNotice: "您的电子邮件下有多个不同 ID 的账户。",
|
|
4685
|
+
accountMergeSelectOne: "请选择将所有数据合并到其中的一个。",
|
|
4686
|
+
accountMergeConfirm: "所有数据将合并到 ID 为 {id} 的账户中。",
|
|
4687
|
+
dismiss: "忽略",
|
|
4688
|
+
merge: "合并",
|
|
4689
|
+
/* General */
|
|
4690
|
+
frontend: "前端",
|
|
4691
|
+
backend: "后端",
|
|
4692
|
+
loading: "加载中",
|
|
4693
|
+
loadFail: "加载失败",
|
|
4694
|
+
editing: "修改中",
|
|
4695
|
+
editFail: "修改失败",
|
|
4696
|
+
deleting: "删除中",
|
|
4697
|
+
deleteFail: "删除失败",
|
|
4698
|
+
reqGot: "请求响应",
|
|
4699
|
+
reqAborted: "请求超时或意外终止",
|
|
4700
|
+
updateMsg: "请更新 Artalk {name} 以获得更好的体验!",
|
|
4701
|
+
currentVersion: "当前版本",
|
|
4702
|
+
ignore: "忽略",
|
|
4703
|
+
open: "打开",
|
|
4704
|
+
openName: "打开{name}"
|
|
4705
|
+
};
|
|
4706
|
+
const GLOBAL_LOCALES_KEY = "ArtalkI18n";
|
|
5043
4707
|
const internal = {
|
|
5044
4708
|
en,
|
|
5045
4709
|
"en-US": en,
|
|
@@ -5061,8 +4725,7 @@ function findLocaleSet(lang) {
|
|
|
5061
4725
|
let LocaleConf = "en";
|
|
5062
4726
|
let LocaleDict = findLocaleSet(LocaleConf);
|
|
5063
4727
|
function setLocale(locale) {
|
|
5064
|
-
if (locale === LocaleConf)
|
|
5065
|
-
return;
|
|
4728
|
+
if (locale === LocaleConf) return;
|
|
5066
4729
|
LocaleConf = locale;
|
|
5067
4730
|
LocaleDict = typeof locale === "string" ? findLocaleSet(locale) : locale;
|
|
5068
4731
|
}
|
|
@@ -5088,8 +4751,7 @@ class EventManager {
|
|
|
5088
4751
|
* Remove an event listener for a specific event name and handler
|
|
5089
4752
|
*/
|
|
5090
4753
|
off(name, handler) {
|
|
5091
|
-
if (!handler)
|
|
5092
|
-
return;
|
|
4754
|
+
if (!handler) return;
|
|
5093
4755
|
this.events = this.events.filter((evt) => !(evt.name === name && evt.handler === handler));
|
|
5094
4756
|
}
|
|
5095
4757
|
/**
|
|
@@ -5097,8 +4759,7 @@ class EventManager {
|
|
|
5097
4759
|
*/
|
|
5098
4760
|
trigger(name, payload) {
|
|
5099
4761
|
this.events.slice(0).filter((evt) => evt.name === name && typeof evt.handler === "function").forEach((evt) => {
|
|
5100
|
-
if (evt.once)
|
|
5101
|
-
this.off(name, evt.handler);
|
|
4762
|
+
if (evt.once) this.off(name, evt.handler);
|
|
5102
4763
|
evt.handler(payload);
|
|
5103
4764
|
});
|
|
5104
4765
|
}
|
|
@@ -5123,11 +4784,12 @@ const defaults = {
|
|
|
5123
4784
|
uaBadge: true,
|
|
5124
4785
|
listSort: true,
|
|
5125
4786
|
preview: true,
|
|
5126
|
-
countEl: "
|
|
5127
|
-
pvEl: "
|
|
4787
|
+
countEl: ".artalk-comment-count",
|
|
4788
|
+
pvEl: ".artalk-pv-count",
|
|
4789
|
+
statPageKeyAttr: "data-page-key",
|
|
5128
4790
|
gravatar: {
|
|
5129
|
-
mirror: "https://
|
|
5130
|
-
params: "d=mp&s=240"
|
|
4791
|
+
mirror: "https://www.gravatar.com/avatar/",
|
|
4792
|
+
params: "sha256=1&d=mp&s=240"
|
|
5131
4793
|
},
|
|
5132
4794
|
pagination: {
|
|
5133
4795
|
pageSize: 20,
|
|
@@ -5150,35 +4812,35 @@ function handelCustomConf(customConf, full = false) {
|
|
|
5150
4812
|
if (conf.el && typeof conf.el === "string") {
|
|
5151
4813
|
try {
|
|
5152
4814
|
const findEl = document.querySelector(conf.el);
|
|
5153
|
-
if (!findEl)
|
|
5154
|
-
throw Error(`Target element "${conf.el}" was not found.`);
|
|
4815
|
+
if (!findEl) throw Error(`Target element "${conf.el}" was not found.`);
|
|
5155
4816
|
conf.el = findEl;
|
|
5156
4817
|
} catch (e) {
|
|
5157
4818
|
console.error(e);
|
|
5158
4819
|
throw new Error("Please check your Artalk `el` config.");
|
|
5159
4820
|
}
|
|
5160
4821
|
}
|
|
5161
|
-
if (conf.pageKey === "")
|
|
5162
|
-
|
|
5163
|
-
if (conf.
|
|
5164
|
-
|
|
5165
|
-
if (conf.
|
|
5166
|
-
|
|
5167
|
-
if (conf.locale === "auto")
|
|
5168
|
-
conf.locale = navigator.language;
|
|
5169
|
-
if (conf.flatMode === "auto")
|
|
5170
|
-
conf.flatMode = window.matchMedia("(max-width: 768px)").matches;
|
|
5171
|
-
if (typeof conf.nestMax === "number" && Number(conf.nestMax) <= 1)
|
|
5172
|
-
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;
|
|
5173
4828
|
return conf;
|
|
5174
4829
|
}
|
|
5175
4830
|
function handleConfFormServer(conf) {
|
|
5176
|
-
const
|
|
4831
|
+
const ExcludedKeys = [
|
|
4832
|
+
"el",
|
|
4833
|
+
"pageKey",
|
|
4834
|
+
"pageTitle",
|
|
4835
|
+
"server",
|
|
4836
|
+
"site",
|
|
4837
|
+
"pvEl",
|
|
4838
|
+
"countEl",
|
|
4839
|
+
"statPageKeyAttr"
|
|
4840
|
+
];
|
|
5177
4841
|
Object.keys(conf).forEach((k) => {
|
|
5178
|
-
if (
|
|
5179
|
-
|
|
5180
|
-
if (k === "darkMode" && conf[k] !== "auto")
|
|
5181
|
-
delete conf[k];
|
|
4842
|
+
if (ExcludedKeys.includes(k)) delete conf[k];
|
|
4843
|
+
if (k === "darkMode" && conf[k] !== "auto") delete conf[k];
|
|
5182
4844
|
});
|
|
5183
4845
|
if (conf.emoticons && typeof conf.emoticons === "string") {
|
|
5184
4846
|
conf.emoticons = conf.emoticons.trim();
|
|
@@ -5199,7 +4861,7 @@ function convertApiOptions(conf, ctx) {
|
|
|
5199
4861
|
timeout: conf.reqTimeout,
|
|
5200
4862
|
getApiToken: () => ctx == null ? void 0 : ctx.get("user").getData().token,
|
|
5201
4863
|
userInfo: (ctx == null ? void 0 : ctx.get("user").checkHasBasicUserInfo()) ? {
|
|
5202
|
-
name: ctx == null ? void 0 : ctx.get("user").getData().
|
|
4864
|
+
name: ctx == null ? void 0 : ctx.get("user").getData().name,
|
|
5203
4865
|
email: ctx == null ? void 0 : ctx.get("user").getData().email
|
|
5204
4866
|
} : void 0,
|
|
5205
4867
|
handlers: ctx == null ? void 0 : ctx.getApiHandlers()
|
|
@@ -5249,6 +4911,7 @@ class Context {
|
|
|
5249
4911
|
this.$root = conf.el;
|
|
5250
4912
|
this.$root.classList.add("artalk");
|
|
5251
4913
|
this.$root.innerHTML = "";
|
|
4914
|
+
conf.darkMode && this.$root.classList.add("atk-dark-mode");
|
|
5252
4915
|
this.data = new DataManager(this.events);
|
|
5253
4916
|
this.on("mounted", () => {
|
|
5254
4917
|
this.mounted = true;
|
|
@@ -5264,8 +4927,7 @@ class Context {
|
|
|
5264
4927
|
return new Api2(convertApiOptions(this.conf, this));
|
|
5265
4928
|
}
|
|
5266
4929
|
getApiHandlers() {
|
|
5267
|
-
if (!this.apiHandlers)
|
|
5268
|
-
this.apiHandlers = createNewApiHandlers(this);
|
|
4930
|
+
if (!this.apiHandlers) this.apiHandlers = createNewApiHandlers(this);
|
|
5269
4931
|
return this.apiHandlers;
|
|
5270
4932
|
}
|
|
5271
4933
|
getData() {
|
|
@@ -5354,50 +5016,6 @@ class Context {
|
|
|
5354
5016
|
watchConf(this, keys, effect);
|
|
5355
5017
|
}
|
|
5356
5018
|
}
|
|
5357
|
-
class Dialog {
|
|
5358
|
-
constructor(contentEl) {
|
|
5359
|
-
__publicField(this, "$el");
|
|
5360
|
-
__publicField(this, "$content");
|
|
5361
|
-
__publicField(this, "$actions");
|
|
5362
|
-
this.$el = createElement(
|
|
5363
|
-
`<div class="atk-layer-dialog-wrap">
|
|
5364
|
-
<div class="atk-layer-dialog">
|
|
5365
|
-
<div class="atk-layer-dialog-content"></div>
|
|
5366
|
-
<div class="atk-layer-dialog-actions"></div>
|
|
5367
|
-
</div>
|
|
5368
|
-
</div>`
|
|
5369
|
-
);
|
|
5370
|
-
this.$actions = this.$el.querySelector(".atk-layer-dialog-actions");
|
|
5371
|
-
this.$content = this.$el.querySelector(".atk-layer-dialog-content");
|
|
5372
|
-
this.$content.appendChild(contentEl);
|
|
5373
|
-
}
|
|
5374
|
-
/** 按钮 · 确定 */
|
|
5375
|
-
setYes(handler) {
|
|
5376
|
-
const btn = createElement(
|
|
5377
|
-
`<button data-action="confirm">${t("confirm")}</button>`
|
|
5378
|
-
);
|
|
5379
|
-
btn.onclick = this.onBtnClick(handler);
|
|
5380
|
-
this.$actions.appendChild(btn);
|
|
5381
|
-
return this;
|
|
5382
|
-
}
|
|
5383
|
-
/** 按钮 · 取消 */
|
|
5384
|
-
setNo(handler) {
|
|
5385
|
-
const btn = createElement(
|
|
5386
|
-
`<button data-action="cancel">${t("cancel")}</button>`
|
|
5387
|
-
);
|
|
5388
|
-
btn.onclick = this.onBtnClick(handler);
|
|
5389
|
-
this.$actions.appendChild(btn);
|
|
5390
|
-
return this;
|
|
5391
|
-
}
|
|
5392
|
-
onBtnClick(handler) {
|
|
5393
|
-
return (evt) => {
|
|
5394
|
-
const re = handler(evt.currentTarget, this);
|
|
5395
|
-
if (re === void 0 || re === true) {
|
|
5396
|
-
this.$el.remove();
|
|
5397
|
-
}
|
|
5398
|
-
};
|
|
5399
|
-
}
|
|
5400
|
-
}
|
|
5401
5019
|
function showLoading(parentElem, conf) {
|
|
5402
5020
|
let $loading = parentElem.querySelector(":scope > .atk-loading");
|
|
5403
5021
|
if (!$loading) {
|
|
@@ -5408,8 +5026,7 @@ function showLoading(parentElem, conf) {
|
|
|
5408
5026
|
</div>
|
|
5409
5027
|
</div>`
|
|
5410
5028
|
);
|
|
5411
|
-
if (conf == null ? void 0 : conf.transparentBg)
|
|
5412
|
-
$loading.style.background = "transparent";
|
|
5029
|
+
if (conf == null ? void 0 : conf.transparentBg) $loading.style.background = "transparent";
|
|
5413
5030
|
parentElem.appendChild($loading);
|
|
5414
5031
|
}
|
|
5415
5032
|
$loading.style.display = "";
|
|
@@ -5417,21 +5034,17 @@ function showLoading(parentElem, conf) {
|
|
|
5417
5034
|
if ($spinner) {
|
|
5418
5035
|
$spinner.style.display = "none";
|
|
5419
5036
|
window.setTimeout(() => {
|
|
5420
|
-
if ($spinner.isConnected)
|
|
5421
|
-
$spinner.style.display = "";
|
|
5037
|
+
if ($spinner.isConnected) $spinner.style.display = "";
|
|
5422
5038
|
}, 500);
|
|
5423
5039
|
}
|
|
5424
5040
|
}
|
|
5425
5041
|
function hideLoading(parentElem) {
|
|
5426
5042
|
const $loading = parentElem.querySelector(":scope > .atk-loading");
|
|
5427
|
-
if ($loading)
|
|
5428
|
-
$loading.style.display = "none";
|
|
5043
|
+
if ($loading) $loading.style.display = "none";
|
|
5429
5044
|
}
|
|
5430
5045
|
function setLoading(val, parentElem) {
|
|
5431
|
-
if (val)
|
|
5432
|
-
|
|
5433
|
-
else
|
|
5434
|
-
hideLoading(parentElem);
|
|
5046
|
+
if (val) showLoading(parentElem);
|
|
5047
|
+
else hideLoading(parentElem);
|
|
5435
5048
|
}
|
|
5436
5049
|
function scrollIntoView(elem, enableAnim = true, relativeTo) {
|
|
5437
5050
|
let top;
|
|
@@ -5450,10 +5063,8 @@ function scrollIntoView(elem, enableAnim = true, relativeTo) {
|
|
|
5450
5063
|
// behavior: enableAnim ? 'smooth' : 'instant',
|
|
5451
5064
|
behavior: "instant"
|
|
5452
5065
|
};
|
|
5453
|
-
if (relativeTo)
|
|
5454
|
-
|
|
5455
|
-
else
|
|
5456
|
-
window.scroll(scrollOptions);
|
|
5066
|
+
if (relativeTo) relativeTo.scroll(scrollOptions);
|
|
5067
|
+
else window.scroll(scrollOptions);
|
|
5457
5068
|
}
|
|
5458
5069
|
function showNotify(wrapElem, msg, type) {
|
|
5459
5070
|
const colors = { s: "#57d59f", e: "#ff6f6c", w: "#ffc721", i: "#2ebcfc" };
|
|
@@ -5495,8 +5106,7 @@ function playFadeInAnim(elem, after) {
|
|
|
5495
5106
|
function setError(parentElem, html2, title = '<span class="atk-error-title">Artalk Error</span>') {
|
|
5496
5107
|
let elem = parentElem.querySelector(".atk-error-layer");
|
|
5497
5108
|
if (html2 === null) {
|
|
5498
|
-
if (elem !== null)
|
|
5499
|
-
elem.remove();
|
|
5109
|
+
if (elem !== null) elem.remove();
|
|
5500
5110
|
return;
|
|
5501
5111
|
}
|
|
5502
5112
|
if (!elem) {
|
|
@@ -5507,8 +5117,7 @@ function setError(parentElem, html2, title = '<span class="atk-error-title">Arta
|
|
|
5507
5117
|
}
|
|
5508
5118
|
const errorTextEl = elem.querySelector(".atk-error-text");
|
|
5509
5119
|
errorTextEl.innerHTML = "";
|
|
5510
|
-
if (html2 === null)
|
|
5511
|
-
return;
|
|
5120
|
+
if (html2 === null) return;
|
|
5512
5121
|
if (html2 instanceof HTMLElement) {
|
|
5513
5122
|
errorTextEl.appendChild(html2);
|
|
5514
5123
|
} else {
|
|
@@ -5532,8 +5141,7 @@ function getScrollBarWidth() {
|
|
|
5532
5141
|
const w1 = inner.offsetWidth;
|
|
5533
5142
|
outer.style.overflow = "scroll";
|
|
5534
5143
|
let w2 = inner.offsetWidth;
|
|
5535
|
-
if (w1 === w2)
|
|
5536
|
-
w2 = outer.clientWidth;
|
|
5144
|
+
if (w1 === w2) w2 = outer.clientWidth;
|
|
5537
5145
|
document.body.removeChild(outer);
|
|
5538
5146
|
return w1 - w2;
|
|
5539
5147
|
}
|
|
@@ -5578,8 +5186,7 @@ function iframeBody(checker) {
|
|
|
5578
5186
|
(function queryStatus() {
|
|
5579
5187
|
return __async(this, null, function* () {
|
|
5580
5188
|
yield sleep(1e3);
|
|
5581
|
-
if (stop)
|
|
5582
|
-
return;
|
|
5189
|
+
if (stop) return;
|
|
5583
5190
|
let isPass = false;
|
|
5584
5191
|
try {
|
|
5585
5192
|
const resp = yield checker.getApi().captcha.getCaptchaStatus();
|
|
@@ -5607,8 +5214,7 @@ const CaptchaChecker = {
|
|
|
5607
5214
|
});
|
|
5608
5215
|
},
|
|
5609
5216
|
body(checker) {
|
|
5610
|
-
if (checker.get("iframe"))
|
|
5611
|
-
return iframeBody(checker);
|
|
5217
|
+
if (checker.get("iframe")) return iframeBody(checker);
|
|
5612
5218
|
return imgBody(checker);
|
|
5613
5219
|
},
|
|
5614
5220
|
onSuccess(checker, data, inputVal, formEl) {
|
|
@@ -5624,7 +5230,7 @@ const AdminChecker = {
|
|
|
5624
5230
|
request(checker, inputVal) {
|
|
5625
5231
|
return __async(this, null, function* () {
|
|
5626
5232
|
return (yield checker.getApi().user.login({
|
|
5627
|
-
name: checker.getUser().getData().
|
|
5233
|
+
name: checker.getUser().getData().name,
|
|
5628
5234
|
email: checker.getUser().getData().email,
|
|
5629
5235
|
password: inputVal
|
|
5630
5236
|
})).data;
|
|
@@ -5635,7 +5241,7 @@ const AdminChecker = {
|
|
|
5635
5241
|
},
|
|
5636
5242
|
onSuccess(checker, res, inputVal, formEl) {
|
|
5637
5243
|
checker.getUser().update({
|
|
5638
|
-
|
|
5244
|
+
is_admin: true,
|
|
5639
5245
|
token: res.token
|
|
5640
5246
|
});
|
|
5641
5247
|
checker.getOpts().onReload();
|
|
@@ -5643,6 +5249,50 @@ const AdminChecker = {
|
|
|
5643
5249
|
onError(checker, err, inputVal, formEl) {
|
|
5644
5250
|
}
|
|
5645
5251
|
};
|
|
5252
|
+
class Dialog {
|
|
5253
|
+
constructor(contentEl) {
|
|
5254
|
+
__publicField(this, "$el");
|
|
5255
|
+
__publicField(this, "$content");
|
|
5256
|
+
__publicField(this, "$actions");
|
|
5257
|
+
this.$el = createElement(
|
|
5258
|
+
`<div class="atk-layer-dialog-wrap">
|
|
5259
|
+
<div class="atk-layer-dialog">
|
|
5260
|
+
<div class="atk-layer-dialog-content"></div>
|
|
5261
|
+
<div class="atk-layer-dialog-actions"></div>
|
|
5262
|
+
</div>
|
|
5263
|
+
</div>`
|
|
5264
|
+
);
|
|
5265
|
+
this.$actions = this.$el.querySelector(".atk-layer-dialog-actions");
|
|
5266
|
+
this.$content = this.$el.querySelector(".atk-layer-dialog-content");
|
|
5267
|
+
this.$content.appendChild(contentEl);
|
|
5268
|
+
}
|
|
5269
|
+
/** 按钮 · 确定 */
|
|
5270
|
+
setYes(handler) {
|
|
5271
|
+
const btn = createElement(
|
|
5272
|
+
`<button data-action="confirm">${t("confirm")}</button>`
|
|
5273
|
+
);
|
|
5274
|
+
btn.onclick = this.onBtnClick(handler);
|
|
5275
|
+
this.$actions.appendChild(btn);
|
|
5276
|
+
return this;
|
|
5277
|
+
}
|
|
5278
|
+
/** 按钮 · 取消 */
|
|
5279
|
+
setNo(handler) {
|
|
5280
|
+
const btn = createElement(
|
|
5281
|
+
`<button data-action="cancel">${t("cancel")}</button>`
|
|
5282
|
+
);
|
|
5283
|
+
btn.onclick = this.onBtnClick(handler);
|
|
5284
|
+
this.$actions.appendChild(btn);
|
|
5285
|
+
return this;
|
|
5286
|
+
}
|
|
5287
|
+
onBtnClick(handler) {
|
|
5288
|
+
return (evt) => {
|
|
5289
|
+
const re = handler(evt.currentTarget, this);
|
|
5290
|
+
if (re === void 0 || re === true) {
|
|
5291
|
+
this.$el.remove();
|
|
5292
|
+
}
|
|
5293
|
+
};
|
|
5294
|
+
}
|
|
5295
|
+
}
|
|
5646
5296
|
function wrapPromise(fn) {
|
|
5647
5297
|
return (payload) => new Promise((resolve, reject) => {
|
|
5648
5298
|
const cancelFn = payload.onCancel;
|
|
@@ -5692,19 +5342,15 @@ class CheckerLauncher {
|
|
|
5692
5342
|
},
|
|
5693
5343
|
triggerSuccess: () => {
|
|
5694
5344
|
close();
|
|
5695
|
-
if (checker.onSuccess)
|
|
5696
|
-
|
|
5697
|
-
if (payload.onSuccess)
|
|
5698
|
-
payload.onSuccess();
|
|
5345
|
+
if (checker.onSuccess) checker.onSuccess(checkerCtx, "", "", formEl);
|
|
5346
|
+
if (payload.onSuccess) payload.onSuccess();
|
|
5699
5347
|
},
|
|
5700
5348
|
cancel: () => {
|
|
5701
5349
|
close();
|
|
5702
|
-
if (payload.onCancel)
|
|
5703
|
-
payload.onCancel();
|
|
5350
|
+
if (payload.onCancel) payload.onCancel();
|
|
5704
5351
|
}
|
|
5705
5352
|
};
|
|
5706
|
-
if (postFire)
|
|
5707
|
-
postFire(checkerCtx);
|
|
5353
|
+
if (postFire) postFire(checkerCtx);
|
|
5708
5354
|
const formEl = createElement();
|
|
5709
5355
|
formEl.appendChild(checker.body(checkerCtx));
|
|
5710
5356
|
const $input = createElement(
|
|
@@ -5722,8 +5368,7 @@ class CheckerLauncher {
|
|
|
5722
5368
|
const dialog = new Dialog(formEl);
|
|
5723
5369
|
dialog.setYes((btnEl) => {
|
|
5724
5370
|
const inputVal = $input.value.trim();
|
|
5725
|
-
if (!btnTextOrg)
|
|
5726
|
-
btnTextOrg = btnEl.innerText;
|
|
5371
|
+
if (!btnTextOrg) btnTextOrg = btnEl.innerText;
|
|
5727
5372
|
const btnTextSet = (btnText) => {
|
|
5728
5373
|
btnEl.innerText = btnText;
|
|
5729
5374
|
btnEl.classList.add("error");
|
|
@@ -5735,14 +5380,11 @@ class CheckerLauncher {
|
|
|
5735
5380
|
btnEl.innerText = `${t("loading")}...`;
|
|
5736
5381
|
checker.request(checkerCtx, inputVal).then((data) => {
|
|
5737
5382
|
close();
|
|
5738
|
-
if (checker.onSuccess)
|
|
5739
|
-
|
|
5740
|
-
if (payload.onSuccess)
|
|
5741
|
-
payload.onSuccess();
|
|
5383
|
+
if (checker.onSuccess) checker.onSuccess(checkerCtx, data, inputVal, formEl);
|
|
5384
|
+
if (payload.onSuccess) payload.onSuccess();
|
|
5742
5385
|
}).catch((err) => {
|
|
5743
5386
|
btnTextSet(String(err.message || String(err)));
|
|
5744
|
-
if (checker.onError)
|
|
5745
|
-
checker.onError(checkerCtx, err, inputVal, formEl);
|
|
5387
|
+
if (checker.onError) checker.onError(checkerCtx, err, inputVal, formEl);
|
|
5746
5388
|
const tf = setTimeout(() => btnTextRestore(), 3e3);
|
|
5747
5389
|
$input.onfocus = () => {
|
|
5748
5390
|
btnTextRestore();
|
|
@@ -5753,8 +5395,7 @@ class CheckerLauncher {
|
|
|
5753
5395
|
});
|
|
5754
5396
|
dialog.setNo(() => {
|
|
5755
5397
|
close();
|
|
5756
|
-
if (payload.onCancel)
|
|
5757
|
-
payload.onCancel();
|
|
5398
|
+
if (payload.onCancel) payload.onCancel();
|
|
5758
5399
|
return false;
|
|
5759
5400
|
});
|
|
5760
5401
|
if (hideInteractInput) {
|
|
@@ -5762,8 +5403,7 @@ class CheckerLauncher {
|
|
|
5762
5403
|
dialog.$el.querySelector(".atk-layer-dialog-actions").style.display = "none";
|
|
5763
5404
|
}
|
|
5764
5405
|
layer.getEl().append(dialog.$el);
|
|
5765
|
-
if (payload.onMount)
|
|
5766
|
-
payload.onMount(dialog.$el);
|
|
5406
|
+
if (payload.onMount) payload.onMount(dialog.$el);
|
|
5767
5407
|
}
|
|
5768
5408
|
}
|
|
5769
5409
|
class Component {
|
|
@@ -5778,10 +5418,10 @@ class Component {
|
|
|
5778
5418
|
return this.$el;
|
|
5779
5419
|
}
|
|
5780
5420
|
}
|
|
5781
|
-
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';
|
|
5782
5422
|
const Sel = {
|
|
5783
5423
|
$header: ".atk-header",
|
|
5784
|
-
$
|
|
5424
|
+
$name: '.atk-header [name="name"]',
|
|
5785
5425
|
$email: '.atk-header [name="email"]',
|
|
5786
5426
|
$link: '.atk-header [name="link"]',
|
|
5787
5427
|
$textareaWrap: ".atk-textarea-wrap",
|
|
@@ -5804,6 +5444,9 @@ function render() {
|
|
|
5804
5444
|
}
|
|
5805
5445
|
class EditorPlug {
|
|
5806
5446
|
constructor(kit) {
|
|
5447
|
+
__publicField(this, "$btn");
|
|
5448
|
+
__publicField(this, "$panel");
|
|
5449
|
+
__publicField(this, "editorStateEffectWhen");
|
|
5807
5450
|
this.kit = kit;
|
|
5808
5451
|
}
|
|
5809
5452
|
/** Use plug btn will add a btn on the bottom of editor */
|
|
@@ -5823,15 +5466,13 @@ class EditorPlug {
|
|
|
5823
5466
|
/** Listen the event of panel show */
|
|
5824
5467
|
usePanelShow(func) {
|
|
5825
5468
|
this.kit.useEvents().on("panel-show", (aPlug) => {
|
|
5826
|
-
if (aPlug === this)
|
|
5827
|
-
func();
|
|
5469
|
+
if (aPlug === this) func();
|
|
5828
5470
|
});
|
|
5829
5471
|
}
|
|
5830
5472
|
/** Listen the event of panel hide */
|
|
5831
5473
|
usePanelHide(func) {
|
|
5832
5474
|
this.kit.useEvents().on("panel-hide", (aPlug) => {
|
|
5833
|
-
if (aPlug === this)
|
|
5834
|
-
func();
|
|
5475
|
+
if (aPlug === this) func();
|
|
5835
5476
|
});
|
|
5836
5477
|
}
|
|
5837
5478
|
/** Use editor state modifier */
|
|
@@ -5846,8 +5487,7 @@ class Mover extends EditorPlug {
|
|
|
5846
5487
|
__publicField(this, "isMoved", false);
|
|
5847
5488
|
}
|
|
5848
5489
|
move(afterEl) {
|
|
5849
|
-
if (this.isMoved)
|
|
5850
|
-
return;
|
|
5490
|
+
if (this.isMoved) return;
|
|
5851
5491
|
this.isMoved = true;
|
|
5852
5492
|
const editorEl = this.kit.useUI().$el;
|
|
5853
5493
|
editorEl.after(createElement('<div class="atk-editor-travel-placeholder"></div>'));
|
|
@@ -5859,8 +5499,7 @@ class Mover extends EditorPlug {
|
|
|
5859
5499
|
}
|
|
5860
5500
|
back() {
|
|
5861
5501
|
var _a;
|
|
5862
|
-
if (!this.isMoved)
|
|
5863
|
-
return;
|
|
5502
|
+
if (!this.isMoved) return;
|
|
5864
5503
|
this.isMoved = false;
|
|
5865
5504
|
(_a = this.kit.useGlobalCtx().$root.querySelector(".atk-editor-travel-placeholder")) == null ? void 0 : _a.replaceWith(this.kit.useUI().$el);
|
|
5866
5505
|
this.kit.useUI().$el.classList.remove("editor-traveling");
|
|
@@ -5923,13 +5562,12 @@ class Editor extends Component {
|
|
|
5923
5562
|
return this.state.get();
|
|
5924
5563
|
}
|
|
5925
5564
|
getHeaderInputEls() {
|
|
5926
|
-
return {
|
|
5565
|
+
return { name: this.ui.$name, email: this.ui.$email, link: this.ui.$link };
|
|
5927
5566
|
}
|
|
5928
5567
|
getContentFinal() {
|
|
5929
5568
|
let content = this.getContentRaw();
|
|
5930
5569
|
const plugs = this.getPlugs();
|
|
5931
|
-
if (plugs)
|
|
5932
|
-
content = plugs.getTransformedContent(content);
|
|
5570
|
+
if (plugs) content = plugs.getTransformedContent(content);
|
|
5933
5571
|
return content;
|
|
5934
5572
|
}
|
|
5935
5573
|
getContentRaw() {
|
|
@@ -6007,8 +5645,8 @@ class SidebarLayer extends Component {
|
|
|
6007
5645
|
__publicField(this, "$closeBtn");
|
|
6008
5646
|
__publicField(this, "$iframeWrap");
|
|
6009
5647
|
__publicField(this, "$iframe");
|
|
6010
|
-
/** Refresh iFrame
|
|
6011
|
-
__publicField(this, "
|
|
5648
|
+
/** Refresh iFrame when show */
|
|
5649
|
+
__publicField(this, "refreshWhenShow", true);
|
|
6012
5650
|
/** Animation timer */
|
|
6013
5651
|
__publicField(this, "animTimer");
|
|
6014
5652
|
this.$el = createElement(SidebarHTML);
|
|
@@ -6019,7 +5657,7 @@ class SidebarLayer extends Component {
|
|
|
6019
5657
|
this.hide();
|
|
6020
5658
|
};
|
|
6021
5659
|
this.ctx.on("user-changed", () => {
|
|
6022
|
-
this.
|
|
5660
|
+
this.refreshWhenShow = true;
|
|
6023
5661
|
});
|
|
6024
5662
|
}
|
|
6025
5663
|
/** 显示 */
|
|
@@ -6028,8 +5666,8 @@ class SidebarLayer extends Component {
|
|
|
6028
5666
|
this.$el.style.transform = "";
|
|
6029
5667
|
this.initLayer();
|
|
6030
5668
|
this.layer.show();
|
|
6031
|
-
if (this.
|
|
6032
|
-
this.
|
|
5669
|
+
if (this.refreshWhenShow) {
|
|
5670
|
+
this.refreshWhenShow = false;
|
|
6033
5671
|
this.$iframeWrap.innerHTML = "";
|
|
6034
5672
|
this.$iframe = this.createIframe(conf.view);
|
|
6035
5673
|
this.$iframeWrap.append(this.$iframe);
|
|
@@ -6039,7 +5677,7 @@ class SidebarLayer extends Component {
|
|
|
6039
5677
|
if (this.getDarkMode() !== iFrameSrc.includes("&darkMode=1")) {
|
|
6040
5678
|
this.iframeLoad(
|
|
6041
5679
|
$iframe,
|
|
6042
|
-
|
|
5680
|
+
iFrameSrc.replace(/&darkMode=\d/, `&darkMode=${Number(this.getDarkMode())}`)
|
|
6043
5681
|
);
|
|
6044
5682
|
}
|
|
6045
5683
|
}
|
|
@@ -6067,7 +5705,7 @@ class SidebarLayer extends Component {
|
|
|
6067
5705
|
return __async(this, null, function* () {
|
|
6068
5706
|
const data = (yield this.ctx.getApi().user.getUserStatus(__spreadValues({}, this.ctx.getApi().getUserFields()))).data;
|
|
6069
5707
|
if (data.is_admin && !data.is_login) {
|
|
6070
|
-
this.
|
|
5708
|
+
this.refreshWhenShow = true;
|
|
6071
5709
|
this.ctx.checkAdmin({
|
|
6072
5710
|
onSuccess: () => {
|
|
6073
5711
|
setTimeout(() => {
|
|
@@ -6083,8 +5721,7 @@ class SidebarLayer extends Component {
|
|
|
6083
5721
|
});
|
|
6084
5722
|
}
|
|
6085
5723
|
initLayer() {
|
|
6086
|
-
if (this.layer)
|
|
6087
|
-
return;
|
|
5724
|
+
if (this.layer) return;
|
|
6088
5725
|
this.layer = this.ctx.get("layerManager").create("sidebar", this.$el);
|
|
6089
5726
|
this.layer.setOnAfterHide(() => {
|
|
6090
5727
|
this.ctx.editorResetState();
|
|
@@ -6107,10 +5744,8 @@ class SidebarLayer extends Component {
|
|
|
6107
5744
|
user: JSON.stringify(this.ctx.get("user").getData()),
|
|
6108
5745
|
time: +/* @__PURE__ */ new Date()
|
|
6109
5746
|
};
|
|
6110
|
-
if (view)
|
|
6111
|
-
|
|
6112
|
-
if (this.getDarkMode())
|
|
6113
|
-
query.darkMode = "1";
|
|
5747
|
+
if (view) query.view = view;
|
|
5748
|
+
query.darkMode = this.getDarkMode() ? "1" : "0";
|
|
6114
5749
|
const urlParams = new URLSearchParams(query);
|
|
6115
5750
|
this.iframeLoad($iframe, `${baseURL}?${urlParams.toString()}`);
|
|
6116
5751
|
return $iframe;
|
|
@@ -6141,10 +5776,8 @@ function makeNestCommentNodeList(srcData, sortBy = "DATE_DESC", nestMax = 2) {
|
|
|
6141
5776
|
nodeList.push(rootNode);
|
|
6142
5777
|
(function loadChildren(parentNode) {
|
|
6143
5778
|
const children = srcData.filter((o) => o.rid === parentNode.id);
|
|
6144
|
-
if (children.length === 0)
|
|
6145
|
-
|
|
6146
|
-
if (parentNode.level >= nestMax)
|
|
6147
|
-
parentNode = parentNode.parent;
|
|
5779
|
+
if (children.length === 0) return;
|
|
5780
|
+
if (parentNode.level >= nestMax) parentNode = parentNode.parent;
|
|
6148
5781
|
children.forEach((child) => {
|
|
6149
5782
|
const childNode = {
|
|
6150
5783
|
id: child.id,
|
|
@@ -6160,14 +5793,10 @@ function makeNestCommentNodeList(srcData, sortBy = "DATE_DESC", nestMax = 2) {
|
|
|
6160
5793
|
});
|
|
6161
5794
|
const sortFunc = (a, b) => {
|
|
6162
5795
|
let v = a.id - b.id;
|
|
6163
|
-
if (sortBy === "DATE_ASC")
|
|
6164
|
-
|
|
6165
|
-
else if (sortBy === "
|
|
6166
|
-
|
|
6167
|
-
else if (sortBy === "SRC_INDEX")
|
|
6168
|
-
v = srcData.indexOf(a.comment) - srcData.indexOf(b.comment);
|
|
6169
|
-
else if (sortBy === "VOTE_UP_DESC")
|
|
6170
|
-
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;
|
|
6171
5800
|
return v;
|
|
6172
5801
|
};
|
|
6173
5802
|
(function sortLevels(nodes) {
|
|
@@ -6231,16 +5860,13 @@ const createFlatStrategy = (opts) => ({
|
|
|
6231
5860
|
}
|
|
6232
5861
|
});
|
|
6233
5862
|
function insertComment(opts, insertMode, comment, replyComment) {
|
|
6234
|
-
if (comment.is_collapsed)
|
|
6235
|
-
comment.is_allow_reply = false;
|
|
5863
|
+
if (comment.is_collapsed) comment.is_allow_reply = false;
|
|
6236
5864
|
const node = opts.createCommentNode(comment, replyComment);
|
|
6237
5865
|
if (comment.visible) {
|
|
6238
5866
|
const $comment = node.getEl();
|
|
6239
5867
|
const $listCommentsWrap = opts.$commentsWrap;
|
|
6240
|
-
if (insertMode === "append")
|
|
6241
|
-
|
|
6242
|
-
if (insertMode === "prepend")
|
|
6243
|
-
$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);
|
|
6244
5870
|
node.getRender().playFadeAnim();
|
|
6245
5871
|
}
|
|
6246
5872
|
node.getRender().checkHeightLimit();
|
|
@@ -6345,8 +5971,7 @@ function Detect(userAgent) {
|
|
|
6345
5971
|
dest.language = (() => {
|
|
6346
5972
|
const g = nav.browserLanguage || nav.language;
|
|
6347
5973
|
const arr = g.split("-");
|
|
6348
|
-
if (arr[1])
|
|
6349
|
-
arr[1] = arr[1].toUpperCase();
|
|
5974
|
+
if (arr[1]) arr[1] = arr[1].toUpperCase();
|
|
6350
5975
|
return arr.join("_");
|
|
6351
5976
|
})();
|
|
6352
5977
|
const hash = {
|
|
@@ -6357,8 +5982,7 @@ function Detect(userAgent) {
|
|
|
6357
5982
|
};
|
|
6358
5983
|
Object.entries(hash).forEach(([type, match]) => {
|
|
6359
5984
|
Object.entries(match).forEach(([name, result]) => {
|
|
6360
|
-
if (result === true)
|
|
6361
|
-
dest[type] = name;
|
|
5985
|
+
if (result === true) dest[type] = name;
|
|
6362
5986
|
});
|
|
6363
5987
|
});
|
|
6364
5988
|
const osVersion = {
|
|
@@ -6453,16 +6077,12 @@ function Detect(userAgent) {
|
|
|
6453
6077
|
}
|
|
6454
6078
|
function check(conf, rules) {
|
|
6455
6079
|
rules.forEach(({ el, max, imgCheck }) => {
|
|
6456
|
-
if (!el)
|
|
6457
|
-
|
|
6458
|
-
if (imgCheck)
|
|
6459
|
-
el.style.maxHeight = `${max + 1}px`;
|
|
6080
|
+
if (!el) return;
|
|
6081
|
+
if (imgCheck) el.style.maxHeight = `${max + 1}px`;
|
|
6460
6082
|
let lock = false;
|
|
6461
6083
|
const _check = () => {
|
|
6462
|
-
if (lock)
|
|
6463
|
-
|
|
6464
|
-
if (getHeight(el) <= max)
|
|
6465
|
-
return;
|
|
6084
|
+
if (lock) return;
|
|
6085
|
+
if (getHeight(el) <= max) return;
|
|
6466
6086
|
const afterExpandBtnClick = () => {
|
|
6467
6087
|
var _a;
|
|
6468
6088
|
lock = true;
|
|
@@ -6472,7 +6092,9 @@ function check(conf, rules) {
|
|
|
6472
6092
|
};
|
|
6473
6093
|
_check();
|
|
6474
6094
|
if (imgCheck) {
|
|
6475
|
-
el.querySelectorAll(".atk-content img")
|
|
6095
|
+
const imgs = el.querySelectorAll(".atk-content img");
|
|
6096
|
+
if (imgs.length === 0) el.style.maxHeight = "";
|
|
6097
|
+
imgs.forEach((img) => {
|
|
6476
6098
|
img.onload = () => _check();
|
|
6477
6099
|
});
|
|
6478
6100
|
}
|
|
@@ -6480,12 +6102,9 @@ function check(conf, rules) {
|
|
|
6480
6102
|
}
|
|
6481
6103
|
const HEIGHT_LIMIT_CSS = "atk-height-limit";
|
|
6482
6104
|
function applyHeightLimit(obj) {
|
|
6483
|
-
if (!obj.el)
|
|
6484
|
-
|
|
6485
|
-
if (
|
|
6486
|
-
return;
|
|
6487
|
-
if (obj.el.classList.contains(HEIGHT_LIMIT_CSS))
|
|
6488
|
-
return;
|
|
6105
|
+
if (!obj.el) return;
|
|
6106
|
+
if (!obj.max) return;
|
|
6107
|
+
if (obj.el.classList.contains(HEIGHT_LIMIT_CSS)) return;
|
|
6489
6108
|
obj.el.classList.add(HEIGHT_LIMIT_CSS);
|
|
6490
6109
|
obj.el.style.height = `${obj.max}px`;
|
|
6491
6110
|
obj.el.style.overflow = "hidden";
|
|
@@ -6495,20 +6114,16 @@ function applyHeightLimit(obj) {
|
|
|
6495
6114
|
$expandBtn.onclick = (e) => {
|
|
6496
6115
|
e.stopPropagation();
|
|
6497
6116
|
disposeHeightLimit(obj.el);
|
|
6498
|
-
if (obj.afterExpandBtnClick)
|
|
6499
|
-
obj.afterExpandBtnClick(e);
|
|
6117
|
+
if (obj.afterExpandBtnClick) obj.afterExpandBtnClick(e);
|
|
6500
6118
|
};
|
|
6501
6119
|
obj.el.append($expandBtn);
|
|
6502
6120
|
}
|
|
6503
6121
|
function disposeHeightLimit($el) {
|
|
6504
|
-
if (!$el)
|
|
6505
|
-
|
|
6506
|
-
if (!$el.classList.contains(HEIGHT_LIMIT_CSS))
|
|
6507
|
-
return;
|
|
6122
|
+
if (!$el) return;
|
|
6123
|
+
if (!$el.classList.contains(HEIGHT_LIMIT_CSS)) return;
|
|
6508
6124
|
$el.classList.remove(HEIGHT_LIMIT_CSS);
|
|
6509
6125
|
Array.from($el.children).forEach((e) => {
|
|
6510
|
-
if (e.classList.contains("atk-height-limit-btn"))
|
|
6511
|
-
e.remove();
|
|
6126
|
+
if (e.classList.contains("atk-height-limit-btn")) e.remove();
|
|
6512
6127
|
});
|
|
6513
6128
|
$el.style.height = "";
|
|
6514
6129
|
$el.style.maxHeight = "";
|
|
@@ -6516,10 +6131,8 @@ function disposeHeightLimit($el) {
|
|
|
6516
6131
|
}
|
|
6517
6132
|
const HEIGHT_LIMIT_SCROLL_CSS = "atk-height-limit-scroll";
|
|
6518
6133
|
function applyScrollableHeightLimit(opt) {
|
|
6519
|
-
if (!opt.el)
|
|
6520
|
-
|
|
6521
|
-
if (opt.el.classList.contains(HEIGHT_LIMIT_SCROLL_CSS))
|
|
6522
|
-
return;
|
|
6134
|
+
if (!opt.el) return;
|
|
6135
|
+
if (opt.el.classList.contains(HEIGHT_LIMIT_SCROLL_CSS)) return;
|
|
6523
6136
|
opt.el.classList.add(HEIGHT_LIMIT_SCROLL_CSS);
|
|
6524
6137
|
opt.el.style.height = `${opt.max}px`;
|
|
6525
6138
|
}
|
|
@@ -6590,8 +6203,7 @@ function renderDate(ctx) {
|
|
|
6590
6203
|
$date.setAttribute("data-atk-comment-date", String(+new Date(ctx.data.date)));
|
|
6591
6204
|
}
|
|
6592
6205
|
function renderUABadge(ctx) {
|
|
6593
|
-
if (!ctx.opts.uaBadge && !ctx.data.ip_region)
|
|
6594
|
-
return;
|
|
6206
|
+
if (!ctx.opts.uaBadge && !ctx.data.ip_region) return;
|
|
6595
6207
|
let $uaWrap = ctx.$header.querySelector("atk-ua-wrap");
|
|
6596
6208
|
if (!$uaWrap) {
|
|
6597
6209
|
$uaWrap = createElement(`<span class="atk-ua-wrap"></span>`);
|
|
@@ -6646,10 +6258,8 @@ function renderContent(r) {
|
|
|
6646
6258
|
});
|
|
6647
6259
|
}
|
|
6648
6260
|
function renderReplyAt(r) {
|
|
6649
|
-
if (r.opts.flatMode || r.data.rid === 0)
|
|
6650
|
-
|
|
6651
|
-
if (!r.opts.replyTo)
|
|
6652
|
-
return;
|
|
6261
|
+
if (r.opts.flatMode || r.data.rid === 0) return;
|
|
6262
|
+
if (!r.opts.replyTo) return;
|
|
6653
6263
|
r.$replyAt = createElement(
|
|
6654
6264
|
`<span class="atk-item atk-reply-at"><span class="atk-arrow"></span><span class="atk-nick"></span></span>`
|
|
6655
6265
|
);
|
|
@@ -6660,10 +6270,8 @@ function renderReplyAt(r) {
|
|
|
6660
6270
|
r.$headerBadgeWrap.insertAdjacentElement("afterend", r.$replyAt);
|
|
6661
6271
|
}
|
|
6662
6272
|
function renderReplyTo(r) {
|
|
6663
|
-
if (!r.opts.flatMode)
|
|
6664
|
-
|
|
6665
|
-
if (!r.opts.replyTo)
|
|
6666
|
-
return;
|
|
6273
|
+
if (!r.opts.flatMode) return;
|
|
6274
|
+
if (!r.opts.replyTo) return;
|
|
6667
6275
|
r.$replyTo = createElement(`
|
|
6668
6276
|
<div class="atk-reply-to">
|
|
6669
6277
|
<div class="atk-meta">${t("reply")} <span class="atk-nick"></span>:</div>
|
|
@@ -6675,14 +6283,12 @@ function renderReplyTo(r) {
|
|
|
6675
6283
|
r.comment.getActions().goToReplyComment();
|
|
6676
6284
|
};
|
|
6677
6285
|
let replyContent = marked(r.opts.replyTo.content);
|
|
6678
|
-
if (r.opts.replyTo.is_collapsed)
|
|
6679
|
-
replyContent = `[${t("collapsed")}]`;
|
|
6286
|
+
if (r.opts.replyTo.is_collapsed) replyContent = `[${t("collapsed")}]`;
|
|
6680
6287
|
r.$replyTo.querySelector(".atk-content").innerHTML = replyContent;
|
|
6681
6288
|
r.$body.prepend(r.$replyTo);
|
|
6682
6289
|
}
|
|
6683
6290
|
function renderPending(r) {
|
|
6684
|
-
if (!r.data.is_pending)
|
|
6685
|
-
return;
|
|
6291
|
+
if (!r.data.is_pending) return;
|
|
6686
6292
|
const pendingEl = createElement(`<div class="atk-pending">${t("pendingMsg")}</div>`);
|
|
6687
6293
|
r.$body.prepend(pendingEl);
|
|
6688
6294
|
}
|
|
@@ -6704,8 +6310,7 @@ class ActionBtn {
|
|
|
6704
6310
|
this.$el = createElement(`<span class="atk-common-action-btn"></span>`);
|
|
6705
6311
|
this.opts = typeof opts !== "object" ? { text: opts } : opts;
|
|
6706
6312
|
this.$el.innerText = this.getText();
|
|
6707
|
-
if (this.opts.adminOnly)
|
|
6708
|
-
this.$el.setAttribute("atk-only-admin-show", "");
|
|
6313
|
+
if (this.opts.adminOnly) this.$el.setAttribute("atk-only-admin-show", "");
|
|
6709
6314
|
}
|
|
6710
6315
|
// 消息显示复原操作
|
|
6711
6316
|
get isMessaging() {
|
|
@@ -6740,8 +6345,7 @@ class ActionBtn {
|
|
|
6740
6345
|
this.confirmRecTimer = window.setTimeout(() => confirmRestore(), 5e3);
|
|
6741
6346
|
return;
|
|
6742
6347
|
}
|
|
6743
|
-
if (this.confirmRecTimer)
|
|
6744
|
-
window.clearTimeout(this.confirmRecTimer);
|
|
6348
|
+
if (this.confirmRecTimer) window.clearTimeout(this.confirmRecTimer);
|
|
6745
6349
|
confirmRestore();
|
|
6746
6350
|
}
|
|
6747
6351
|
if (this.msgRecTimer) {
|
|
@@ -6754,15 +6358,13 @@ class ActionBtn {
|
|
|
6754
6358
|
}
|
|
6755
6359
|
/** 文字刷新(动态/静态) */
|
|
6756
6360
|
updateText(text) {
|
|
6757
|
-
if (text)
|
|
6758
|
-
this.opts.text = text;
|
|
6361
|
+
if (text) this.opts.text = text;
|
|
6759
6362
|
this.setLoading(false);
|
|
6760
6363
|
this.$el.innerText = this.getText();
|
|
6761
6364
|
}
|
|
6762
6365
|
/** 设置加载状态 */
|
|
6763
6366
|
setLoading(value, loadingText) {
|
|
6764
|
-
if (this.isLoading === value)
|
|
6765
|
-
return;
|
|
6367
|
+
if (this.isLoading === value) return;
|
|
6766
6368
|
this.isLoading = value;
|
|
6767
6369
|
if (value) {
|
|
6768
6370
|
this.$el.classList.add("atk-btn-loading");
|
|
@@ -6787,15 +6389,12 @@ class ActionBtn {
|
|
|
6787
6389
|
/** 设置消息 */
|
|
6788
6390
|
setMsg(text, className, duringTime, after) {
|
|
6789
6391
|
this.setLoading(false);
|
|
6790
|
-
if (className)
|
|
6791
|
-
this.$el.classList.add(className);
|
|
6392
|
+
if (className) this.$el.classList.add(className);
|
|
6792
6393
|
this.$el.innerText = text;
|
|
6793
6394
|
this.setMsgRecTimer(() => {
|
|
6794
6395
|
this.$el.innerText = this.getText();
|
|
6795
|
-
if (className)
|
|
6796
|
-
|
|
6797
|
-
if (after)
|
|
6798
|
-
after();
|
|
6396
|
+
if (className) this.$el.classList.remove(className);
|
|
6397
|
+
if (after) after();
|
|
6799
6398
|
}, duringTime || 2500);
|
|
6800
6399
|
}
|
|
6801
6400
|
/** 设置消息复原操作定时器 */
|
|
@@ -6810,13 +6409,11 @@ class ActionBtn {
|
|
|
6810
6409
|
}
|
|
6811
6410
|
/** 立刻触发器复原定时器 */
|
|
6812
6411
|
fireMsgRecTimer() {
|
|
6813
|
-
if (this.msgRecTimerFunc)
|
|
6814
|
-
this.msgRecTimerFunc();
|
|
6412
|
+
if (this.msgRecTimerFunc) this.msgRecTimerFunc();
|
|
6815
6413
|
}
|
|
6816
6414
|
/** 仅清除 timer */
|
|
6817
6415
|
clearMsgRecTimer() {
|
|
6818
|
-
if (this.msgRecTimer)
|
|
6819
|
-
window.clearTimeout(this.msgRecTimer);
|
|
6416
|
+
if (this.msgRecTimer) window.clearTimeout(this.msgRecTimer);
|
|
6820
6417
|
this.msgRecTimer = void 0;
|
|
6821
6418
|
this.msgRecTimerFunc = void 0;
|
|
6822
6419
|
}
|
|
@@ -6836,8 +6433,7 @@ function renderActions(r) {
|
|
|
6836
6433
|
});
|
|
6837
6434
|
}
|
|
6838
6435
|
function renderVote(r) {
|
|
6839
|
-
if (!r.opts.vote)
|
|
6840
|
-
return;
|
|
6436
|
+
if (!r.opts.vote) return;
|
|
6841
6437
|
r.voteBtnUp = new ActionBtn(() => `${t("voteUp")} (${r.data.vote_up || 0})`).appendTo(r.$actions);
|
|
6842
6438
|
r.voteBtnUp.setClick(() => {
|
|
6843
6439
|
r.comment.getActions().vote("up");
|
|
@@ -6852,8 +6448,7 @@ function renderVote(r) {
|
|
|
6852
6448
|
}
|
|
6853
6449
|
}
|
|
6854
6450
|
function renderReply(r) {
|
|
6855
|
-
if (!r.data.is_allow_reply)
|
|
6856
|
-
return;
|
|
6451
|
+
if (!r.data.is_allow_reply) return;
|
|
6857
6452
|
const replyBtn = createElement(`<span>${t("reply")}</span>`);
|
|
6858
6453
|
r.$actions.append(replyBtn);
|
|
6859
6454
|
replyBtn.addEventListener("click", (e) => {
|
|
@@ -6979,8 +6574,7 @@ class Render {
|
|
|
6979
6574
|
/** 内容限高检测 */
|
|
6980
6575
|
checkHeightLimit() {
|
|
6981
6576
|
const conf = this.opts.heightLimit;
|
|
6982
|
-
if (!conf || !conf.content || !conf.children)
|
|
6983
|
-
return;
|
|
6577
|
+
if (!conf || !conf.content || !conf.children) return;
|
|
6984
6578
|
const contentMaxH = conf.content;
|
|
6985
6579
|
const childrenMaxH = conf.children;
|
|
6986
6580
|
check(
|
|
@@ -7003,8 +6597,7 @@ class Render {
|
|
|
7003
6597
|
}
|
|
7004
6598
|
/** 子评论区域移除限高 */
|
|
7005
6599
|
heightLimitRemoveForChildren() {
|
|
7006
|
-
if (!this.$childrenWrap)
|
|
7007
|
-
return;
|
|
6600
|
+
if (!this.$childrenWrap) return;
|
|
7008
6601
|
disposeHeightLimit(this.$childrenWrap);
|
|
7009
6602
|
}
|
|
7010
6603
|
/** 渐出动画 */
|
|
@@ -7032,17 +6625,13 @@ class Render {
|
|
|
7032
6625
|
}
|
|
7033
6626
|
/** 设置已读 */
|
|
7034
6627
|
setUnread(val) {
|
|
7035
|
-
if (val)
|
|
7036
|
-
|
|
7037
|
-
else
|
|
7038
|
-
this.$el.classList.remove("atk-unread");
|
|
6628
|
+
if (val) this.$el.classList.add("atk-unread");
|
|
6629
|
+
else this.$el.classList.remove("atk-unread");
|
|
7039
6630
|
}
|
|
7040
6631
|
/** 设置为可点击的评论 */
|
|
7041
6632
|
setOpenable(val) {
|
|
7042
|
-
if (val)
|
|
7043
|
-
|
|
7044
|
-
else
|
|
7045
|
-
this.$el.classList.remove("atk-openable");
|
|
6633
|
+
if (val) this.$el.classList.add("atk-openable");
|
|
6634
|
+
else this.$el.classList.remove("atk-openable");
|
|
7046
6635
|
}
|
|
7047
6636
|
/** 设置点击评论打开置顶 URL */
|
|
7048
6637
|
setOpenURL(url) {
|
|
@@ -7091,8 +6680,7 @@ class CommentActions {
|
|
|
7091
6680
|
}
|
|
7092
6681
|
/** 管理员 - 评论状态修改 */
|
|
7093
6682
|
adminEdit(type, btnElem) {
|
|
7094
|
-
if (btnElem.isLoading)
|
|
7095
|
-
return;
|
|
6683
|
+
if (btnElem.isLoading) return;
|
|
7096
6684
|
btnElem.setLoading(true, `${t("editing")}...`);
|
|
7097
6685
|
const modify = __spreadValues({}, this.data);
|
|
7098
6686
|
if (type === "collapsed") {
|
|
@@ -7112,13 +6700,11 @@ class CommentActions {
|
|
|
7112
6700
|
}
|
|
7113
6701
|
/** 管理员 - 评论删除 */
|
|
7114
6702
|
adminDelete(btnElem) {
|
|
7115
|
-
if (btnElem.isLoading)
|
|
7116
|
-
return;
|
|
6703
|
+
if (btnElem.isLoading) return;
|
|
7117
6704
|
btnElem.setLoading(true, `${t("deleting")}...`);
|
|
7118
6705
|
this.getApi().comments.deleteComment(this.data.id).then(() => {
|
|
7119
6706
|
btnElem.setLoading(false);
|
|
7120
|
-
if (this.opts.onDelete)
|
|
7121
|
-
this.opts.onDelete(this.comment);
|
|
6707
|
+
if (this.opts.onDelete) this.opts.onDelete(this.comment);
|
|
7122
6708
|
}).catch((e) => {
|
|
7123
6709
|
console.error(e);
|
|
7124
6710
|
btnElem.setError(t("deleteFail"));
|
|
@@ -7129,8 +6715,7 @@ class CommentActions {
|
|
|
7129
6715
|
const origHash = window.location.hash;
|
|
7130
6716
|
const modifyHash = `#atk-comment-${this.data.rid}`;
|
|
7131
6717
|
window.location.hash = modifyHash;
|
|
7132
|
-
if (modifyHash === origHash)
|
|
7133
|
-
window.dispatchEvent(new Event("hashchange"));
|
|
6718
|
+
if (modifyHash === origHash) window.dispatchEvent(new Event("hashchange"));
|
|
7134
6719
|
}
|
|
7135
6720
|
}
|
|
7136
6721
|
class CommentNode {
|
|
@@ -7155,11 +6740,9 @@ class CommentNode {
|
|
|
7155
6740
|
/** 渲染 UI */
|
|
7156
6741
|
render() {
|
|
7157
6742
|
const newEl = this.renderInstance.render();
|
|
7158
|
-
if (this.$el)
|
|
7159
|
-
this.$el.replaceWith(newEl);
|
|
6743
|
+
if (this.$el) this.$el.replaceWith(newEl);
|
|
7160
6744
|
this.$el = newEl;
|
|
7161
|
-
if (this.opts.onAfterRender)
|
|
7162
|
-
this.opts.onAfterRender();
|
|
6745
|
+
if (this.opts.onAfterRender) this.opts.onAfterRender();
|
|
7163
6746
|
}
|
|
7164
6747
|
/** 获取评论操作实例对象 */
|
|
7165
6748
|
getActions() {
|
|
@@ -7206,10 +6789,8 @@ class CommentNode {
|
|
|
7206
6789
|
this.children.push(childNode);
|
|
7207
6790
|
const $childrenWrap = this.getChildrenWrapEl();
|
|
7208
6791
|
const $childComment = childNode.getEl();
|
|
7209
|
-
if (insertMode === "append")
|
|
7210
|
-
|
|
7211
|
-
else if (insertMode === "prepend")
|
|
7212
|
-
$childrenWrap.prepend($childComment);
|
|
6792
|
+
if (insertMode === "append") $childrenWrap.append($childComment);
|
|
6793
|
+
else if (insertMode === "prepend") $childrenWrap.prepend($childComment);
|
|
7213
6794
|
childNode.getRender().playFadeAnim();
|
|
7214
6795
|
childNode.getRender().checkHeightLimit();
|
|
7215
6796
|
}
|
|
@@ -7237,8 +6818,7 @@ class CommentNode {
|
|
|
7237
6818
|
* Please be aware of the memory leak if you use the $el reference directly.
|
|
7238
6819
|
*/
|
|
7239
6820
|
getEl() {
|
|
7240
|
-
if (!this.$el)
|
|
7241
|
-
throw new Error("comment element not initialized before `getEl()`");
|
|
6821
|
+
if (!this.$el) throw new Error("comment element not initialized before `getEl()`");
|
|
7242
6822
|
return this.$el;
|
|
7243
6823
|
}
|
|
7244
6824
|
/**
|
|
@@ -7247,8 +6827,7 @@ class CommentNode {
|
|
|
7247
6827
|
* Scroll to the comment and perform flash animation
|
|
7248
6828
|
*/
|
|
7249
6829
|
focus() {
|
|
7250
|
-
if (!this.$el)
|
|
7251
|
-
throw new Error("comment element not initialized before `focus()`");
|
|
6830
|
+
if (!this.$el) throw new Error("comment element not initialized before `focus()`");
|
|
7252
6831
|
this.getParents().forEach((p) => {
|
|
7253
6832
|
p.getRender().heightLimitRemoveForChildren();
|
|
7254
6833
|
});
|
|
@@ -7270,7 +6849,7 @@ class CommentNode {
|
|
|
7270
6849
|
return getGravatarURL({
|
|
7271
6850
|
mirror: this.opts.gravatar.mirror,
|
|
7272
6851
|
params: this.opts.gravatar.params,
|
|
7273
|
-
|
|
6852
|
+
emailHash: this.data.email_encrypted
|
|
7274
6853
|
});
|
|
7275
6854
|
}
|
|
7276
6855
|
/** 获取评论 markdown 解析后的内容 */
|
|
@@ -7279,7 +6858,9 @@ class CommentNode {
|
|
|
7279
6858
|
}
|
|
7280
6859
|
/** 获取格式化后的日期 */
|
|
7281
6860
|
getDateFormatted() {
|
|
7282
|
-
|
|
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);
|
|
7283
6864
|
}
|
|
7284
6865
|
/** 获取用户 UserAgent 信息 */
|
|
7285
6866
|
getUserUA() {
|
|
@@ -7313,6 +6894,7 @@ function createCommentNode(ctx, comment, replyComment, opts) {
|
|
|
7313
6894
|
vote: ctx.conf.vote,
|
|
7314
6895
|
voteDown: ctx.conf.voteDown,
|
|
7315
6896
|
uaBadge: ctx.conf.uaBadge,
|
|
6897
|
+
dateFormatter: ctx.conf.dateFormatter,
|
|
7316
6898
|
// TODO: move to plugin folder and remove from core
|
|
7317
6899
|
getApi: () => ctx.getApi(),
|
|
7318
6900
|
replyComment: (c, $el) => ctx.replyComment(c, $el),
|
|
@@ -7351,8 +6933,7 @@ class ReadMoreBtn {
|
|
|
7351
6933
|
return this.total > this.offset + this.opts.pageSize;
|
|
7352
6934
|
}
|
|
7353
6935
|
click() {
|
|
7354
|
-
if (this.hasMore)
|
|
7355
|
-
this.opts.onClick(this.offset + this.opts.pageSize);
|
|
6936
|
+
if (this.hasMore) this.opts.onClick(this.offset + this.opts.pageSize);
|
|
7356
6937
|
this.checkDisabled();
|
|
7357
6938
|
}
|
|
7358
6939
|
/** 显示 */
|
|
@@ -7385,10 +6966,8 @@ class ReadMoreBtn {
|
|
|
7385
6966
|
this.checkDisabled();
|
|
7386
6967
|
}
|
|
7387
6968
|
checkDisabled() {
|
|
7388
|
-
if (this.hasMore)
|
|
7389
|
-
|
|
7390
|
-
else
|
|
7391
|
-
this.hide();
|
|
6969
|
+
if (this.hasMore) this.show();
|
|
6970
|
+
else this.hide();
|
|
7392
6971
|
}
|
|
7393
6972
|
}
|
|
7394
6973
|
class ReadMorePaginator {
|
|
@@ -7410,8 +6989,7 @@ class ReadMorePaginator {
|
|
|
7410
6989
|
});
|
|
7411
6990
|
if (opt.readMoreAutoLoad) {
|
|
7412
6991
|
this.onReachedBottom = () => {
|
|
7413
|
-
if (!this.instance.hasMore || this.opt.ctx.getData().getLoading())
|
|
7414
|
-
return;
|
|
6992
|
+
if (!this.instance.hasMore || this.opt.ctx.getData().getLoading()) return;
|
|
7415
6993
|
this.instance.click();
|
|
7416
6994
|
};
|
|
7417
6995
|
this.opt.ctx.on("list-reach-bottom", this.onReachedBottom);
|
|
@@ -7517,10 +7095,8 @@ class Pagination {
|
|
|
7517
7095
|
}
|
|
7518
7096
|
this.change(page);
|
|
7519
7097
|
};
|
|
7520
|
-
if (!now)
|
|
7521
|
-
|
|
7522
|
-
else
|
|
7523
|
-
modify();
|
|
7098
|
+
if (!now) this.inputTimer = window.setTimeout(() => modify(), 800);
|
|
7099
|
+
else modify();
|
|
7524
7100
|
}
|
|
7525
7101
|
prev() {
|
|
7526
7102
|
const page = this.page - 1;
|
|
@@ -7579,10 +7155,8 @@ class Pagination {
|
|
|
7579
7155
|
}
|
|
7580
7156
|
/** 加载 */
|
|
7581
7157
|
setLoading(isLoading) {
|
|
7582
|
-
if (isLoading)
|
|
7583
|
-
|
|
7584
|
-
else
|
|
7585
|
-
hideLoading(this.$el);
|
|
7158
|
+
if (isLoading) showLoading(this.$el);
|
|
7159
|
+
else hideLoading(this.$el);
|
|
7586
7160
|
}
|
|
7587
7161
|
}
|
|
7588
7162
|
class UpDownPaginator {
|
|
@@ -7624,26 +7198,22 @@ class UpDownPaginator {
|
|
|
7624
7198
|
}
|
|
7625
7199
|
}
|
|
7626
7200
|
function createPaginatorByConf(conf) {
|
|
7627
|
-
if (conf.pagination.readMore)
|
|
7628
|
-
return new ReadMorePaginator();
|
|
7201
|
+
if (conf.pagination.readMore) return new ReadMorePaginator();
|
|
7629
7202
|
return new UpDownPaginator();
|
|
7630
7203
|
}
|
|
7631
7204
|
function getPageDataByLastData(ctx) {
|
|
7632
7205
|
const last = ctx.getData().getListLastFetch();
|
|
7633
7206
|
const r = { offset: 0, total: 0 };
|
|
7634
|
-
if (!last)
|
|
7635
|
-
return r;
|
|
7207
|
+
if (!last) return r;
|
|
7636
7208
|
r.offset = last.params.offset;
|
|
7637
|
-
if (last.data)
|
|
7638
|
-
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;
|
|
7639
7210
|
return r;
|
|
7640
7211
|
}
|
|
7641
7212
|
const initListPaginatorFunc = (ctx) => {
|
|
7642
7213
|
let paginator = null;
|
|
7643
7214
|
ctx.watchConf(["pagination", "locale"], (conf) => {
|
|
7644
7215
|
const list2 = ctx.get("list");
|
|
7645
|
-
if (paginator)
|
|
7646
|
-
paginator.dispose();
|
|
7216
|
+
if (paginator) paginator.dispose();
|
|
7647
7217
|
paginator = createPaginatorByConf(conf);
|
|
7648
7218
|
const { offset, total } = getPageDataByLastData(ctx);
|
|
7649
7219
|
const $paginator = paginator.create({
|
|
@@ -7783,18 +7353,14 @@ class Layer {
|
|
|
7783
7353
|
this.$el.style.display = "";
|
|
7784
7354
|
}
|
|
7785
7355
|
hide() {
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
this.onAfterHide && this.onAfterHide();
|
|
7790
|
-
});
|
|
7356
|
+
this.opts.onHide();
|
|
7357
|
+
this.$el.style.display = "none";
|
|
7358
|
+
this.onAfterHide && this.onAfterHide();
|
|
7791
7359
|
}
|
|
7792
7360
|
destroy() {
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
this.onAfterHide && this.onAfterHide();
|
|
7797
|
-
});
|
|
7361
|
+
this.opts.onHide();
|
|
7362
|
+
this.$el.remove();
|
|
7363
|
+
this.onAfterHide && this.onAfterHide();
|
|
7798
7364
|
}
|
|
7799
7365
|
}
|
|
7800
7366
|
class LayerWrap {
|
|
@@ -7872,11 +7438,12 @@ class User {
|
|
|
7872
7438
|
this.opts = opts;
|
|
7873
7439
|
const localUser = JSON.parse(window.localStorage.getItem(LOCAL_USER_KEY) || "{}");
|
|
7874
7440
|
this.data = {
|
|
7875
|
-
|
|
7441
|
+
name: localUser.name || localUser.nick || "",
|
|
7442
|
+
// nick is deprecated (for historical compatibility)
|
|
7876
7443
|
email: localUser.email || "",
|
|
7877
7444
|
link: localUser.link || "",
|
|
7878
7445
|
token: localUser.token || "",
|
|
7879
|
-
|
|
7446
|
+
is_admin: localUser.is_admin || localUser.isAdmin || false
|
|
7880
7447
|
};
|
|
7881
7448
|
}
|
|
7882
7449
|
getData() {
|
|
@@ -7893,17 +7460,17 @@ class User {
|
|
|
7893
7460
|
/**
|
|
7894
7461
|
* Logout
|
|
7895
7462
|
*
|
|
7896
|
-
* @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)
|
|
7897
7464
|
*/
|
|
7898
7465
|
logout() {
|
|
7899
7466
|
this.update({
|
|
7900
7467
|
token: "",
|
|
7901
|
-
|
|
7468
|
+
is_admin: false
|
|
7902
7469
|
});
|
|
7903
7470
|
}
|
|
7904
7471
|
/** Check if user has filled basic data */
|
|
7905
7472
|
checkHasBasicUserInfo() {
|
|
7906
|
-
return !!this.data.
|
|
7473
|
+
return !!this.data.name && !!this.data.email;
|
|
7907
7474
|
}
|
|
7908
7475
|
}
|
|
7909
7476
|
const services = {
|
|
@@ -7965,7 +7532,7 @@ const services = {
|
|
|
7965
7532
|
}
|
|
7966
7533
|
};
|
|
7967
7534
|
const PvCountWidget = (ctx) => {
|
|
7968
|
-
ctx.watchConf(["site", "pageKey", "pageTitle", "countEl", "pvEl"], (conf) => {
|
|
7535
|
+
ctx.watchConf(["site", "pageKey", "pageTitle", "countEl", "pvEl", "statPageKeyAttr"], (conf) => {
|
|
7969
7536
|
initCountWidget({
|
|
7970
7537
|
getApi: () => ctx.getApi(),
|
|
7971
7538
|
siteName: conf.site,
|
|
@@ -7973,81 +7540,84 @@ const PvCountWidget = (ctx) => {
|
|
|
7973
7540
|
pageTitle: conf.pageTitle,
|
|
7974
7541
|
countEl: conf.countEl,
|
|
7975
7542
|
pvEl: conf.pvEl,
|
|
7543
|
+
pageKeyAttr: conf.statPageKeyAttr,
|
|
7976
7544
|
pvAdd: typeof ctx.conf.pvAdd === "boolean" ? ctx.conf.pvAdd : true
|
|
7977
7545
|
});
|
|
7978
7546
|
});
|
|
7979
7547
|
};
|
|
7980
7548
|
function initCountWidget(opt) {
|
|
7981
7549
|
return __async(this, null, function* () {
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
7550
|
+
yield loadCommentCount(opt);
|
|
7551
|
+
const cacheData = yield incrementPvCount(opt);
|
|
7552
|
+
yield loadPvCount(opt, cacheData);
|
|
7553
|
+
});
|
|
7554
|
+
}
|
|
7555
|
+
function incrementPvCount(opt) {
|
|
7556
|
+
return __async(this, null, function* () {
|
|
7557
|
+
if (!opt.pvAdd || !opt.pageKey) return void 0;
|
|
7558
|
+
const pvCount = (yield opt.getApi().pages.logPv({
|
|
7559
|
+
page_key: opt.pageKey,
|
|
7560
|
+
page_title: opt.pageTitle,
|
|
7561
|
+
site_name: opt.siteName
|
|
7562
|
+
})).data.pv;
|
|
7563
|
+
return {
|
|
7564
|
+
[opt.pageKey]: pvCount
|
|
7565
|
+
};
|
|
7566
|
+
});
|
|
7567
|
+
}
|
|
7568
|
+
function loadCommentCount(opt) {
|
|
7569
|
+
return __async(this, null, function* () {
|
|
7570
|
+
yield loadStatCount({ opt, query: "page_comment", containers: [opt.countEl, "#ArtalkCount"] });
|
|
7571
|
+
});
|
|
7572
|
+
}
|
|
7573
|
+
function loadPvCount(opt, cache) {
|
|
7574
|
+
return __async(this, null, function* () {
|
|
7575
|
+
yield loadStatCount({ opt, query: "page_pv", containers: [opt.pvEl, "#ArtalkPV"], cache });
|
|
8000
7576
|
});
|
|
8001
7577
|
}
|
|
8002
|
-
function
|
|
7578
|
+
function loadStatCount(args) {
|
|
8003
7579
|
return __async(this, null, function* () {
|
|
8004
|
-
|
|
8005
|
-
let
|
|
8006
|
-
|
|
8007
|
-
|
|
7580
|
+
const { opt } = args;
|
|
7581
|
+
let cache = args.cache || {};
|
|
7582
|
+
const els = retrieveElements(args.containers);
|
|
7583
|
+
const pageKeys = getPageKeys(els, opt.pageKeyAttr, opt.pageKey, cache);
|
|
7584
|
+
if (pageKeys.length > 0) {
|
|
8008
7585
|
const res = (yield opt.getApi().stats.getStats(args.query, {
|
|
8009
|
-
page_keys:
|
|
7586
|
+
page_keys: pageKeys.join(","),
|
|
8010
7587
|
site_name: opt.siteName
|
|
8011
7588
|
})).data.data;
|
|
8012
|
-
|
|
7589
|
+
cache = __spreadValues(__spreadValues({}, cache), res);
|
|
8013
7590
|
}
|
|
8014
|
-
|
|
8015
|
-
applyCountData(args.numEl, data, defaultCount);
|
|
7591
|
+
updateElementsText(els, cache, opt.pageKey);
|
|
8016
7592
|
});
|
|
8017
7593
|
}
|
|
8018
|
-
function
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
el.innerHTML = `${count}`;
|
|
7594
|
+
function retrieveElements(containers) {
|
|
7595
|
+
const els = /* @__PURE__ */ new Set();
|
|
7596
|
+
new Set(containers).forEach((selector) => {
|
|
7597
|
+
document.querySelectorAll(selector).forEach((el) => els.add(el));
|
|
8023
7598
|
});
|
|
7599
|
+
return els;
|
|
8024
7600
|
}
|
|
8025
|
-
function
|
|
8026
|
-
const
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
const $openSidebar = createElement(
|
|
8036
|
-
`<span atk-only-admin-show> | <span style="cursor:pointer;">${t("openName", { name: t("ctrlCenter") })}</span></span>`
|
|
8037
|
-
);
|
|
8038
|
-
errEl.appendChild($openSidebar);
|
|
8039
|
-
$openSidebar.onclick = () => opts.onOpenSidebar && opts.onOpenSidebar();
|
|
8040
|
-
}
|
|
8041
|
-
setError(opts.$err, errEl);
|
|
7601
|
+
function getPageKeys(els, pageKeyAttr, pageKey, cache) {
|
|
7602
|
+
const pageKeys = Array.from(els).map((el) => el.getAttribute(pageKeyAttr) || pageKey).filter((key) => key && typeof cache[key] !== "number");
|
|
7603
|
+
return [...new Set(pageKeys)];
|
|
7604
|
+
}
|
|
7605
|
+
function updateElementsText(els, data, defaultPageKey) {
|
|
7606
|
+
els.forEach((el) => {
|
|
7607
|
+
const pageKey = el.getAttribute("data-page-key");
|
|
7608
|
+
const count = pageKey && data[pageKey] || defaultPageKey && data[defaultPageKey] || 0;
|
|
7609
|
+
el.innerText = `${Number(count)}`;
|
|
7610
|
+
});
|
|
8042
7611
|
}
|
|
8043
7612
|
const Markdown = (ctx) => {
|
|
8044
|
-
ctx.watchConf(["
|
|
7613
|
+
ctx.watchConf(["imgLazyLoad", "markedOptions"], (conf) => {
|
|
8045
7614
|
initMarked({
|
|
8046
7615
|
markedOptions: ctx.getConf().markedOptions,
|
|
8047
7616
|
imgLazyLoad: ctx.getConf().imgLazyLoad
|
|
8048
7617
|
});
|
|
8049
|
-
|
|
8050
|
-
|
|
7618
|
+
});
|
|
7619
|
+
ctx.watchConf(["markedReplacers"], (conf) => {
|
|
7620
|
+
conf.markedReplacers && setReplacers(conf.markedReplacers);
|
|
8051
7621
|
});
|
|
8052
7622
|
};
|
|
8053
7623
|
const LocalStorageKey = "ArtalkContent";
|
|
@@ -8139,11 +7709,11 @@ class SubmitAddPreset {
|
|
|
8139
7709
|
}
|
|
8140
7710
|
getSubmitAddParams() {
|
|
8141
7711
|
return __async(this, null, function* () {
|
|
8142
|
-
const {
|
|
7712
|
+
const { name, email, link: link2 } = this.kit.useUser().getData();
|
|
8143
7713
|
const conf = this.kit.useConf();
|
|
8144
7714
|
return {
|
|
8145
7715
|
content: this.kit.useEditor().getContentFinal(),
|
|
8146
|
-
name
|
|
7716
|
+
name,
|
|
8147
7717
|
email,
|
|
8148
7718
|
link: link2,
|
|
8149
7719
|
rid: 0,
|
|
@@ -8185,17 +7755,12 @@ class Submit extends EditorPlug {
|
|
|
8185
7755
|
const custom = this.customs.find((o) => o.activeCond());
|
|
8186
7756
|
this.kit.useEditor().showLoading();
|
|
8187
7757
|
try {
|
|
8188
|
-
if (custom == null ? void 0 : custom.pre)
|
|
8189
|
-
custom.pre();
|
|
7758
|
+
if (custom == null ? void 0 : custom.pre) custom.pre();
|
|
8190
7759
|
let nComment;
|
|
8191
|
-
if (custom == null ? void 0 : custom.req)
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
if (custom == null ? void 0 : custom.post)
|
|
8196
|
-
custom.post(nComment);
|
|
8197
|
-
else
|
|
8198
|
-
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);
|
|
8199
7764
|
} catch (err) {
|
|
8200
7765
|
console.error(err);
|
|
8201
7766
|
this.kit.useEditor().showNotify(`${t("commentFail")}: ${err.message || String(err)}`, "e");
|
|
@@ -8220,15 +7785,13 @@ class StateReply extends EditorPlug {
|
|
|
8220
7785
|
});
|
|
8221
7786
|
this.kit.useEvents().on("mounted", () => {
|
|
8222
7787
|
const submitPlug = this.kit.useDeps(Submit);
|
|
8223
|
-
if (!submitPlug)
|
|
8224
|
-
throw Error("SubmitPlug not initialized");
|
|
7788
|
+
if (!submitPlug) throw Error("SubmitPlug not initialized");
|
|
8225
7789
|
const defaultPreset = new SubmitAddPreset(this.kit);
|
|
8226
7790
|
submitPlug.registerCustom({
|
|
8227
7791
|
activeCond: () => !!this.comment,
|
|
8228
7792
|
// active this custom submit when reply mode
|
|
8229
7793
|
req: () => __async(this, null, function* () {
|
|
8230
|
-
if (!this.comment)
|
|
8231
|
-
throw new Error("reply comment cannot be empty");
|
|
7794
|
+
if (!this.comment) throw new Error("reply comment cannot be empty");
|
|
8232
7795
|
const nComment = (yield this.kit.useApi().comments.createComment(__spreadProps(__spreadValues({}, yield defaultPreset.getSubmitAddParams()), {
|
|
8233
7796
|
rid: this.comment.id,
|
|
8234
7797
|
page_key: this.comment.page_key,
|
|
@@ -8264,8 +7827,7 @@ class StateReply extends EditorPlug {
|
|
|
8264
7827
|
ui.$textarea.focus();
|
|
8265
7828
|
}
|
|
8266
7829
|
cancelReply() {
|
|
8267
|
-
if (!this.comment)
|
|
8268
|
-
return;
|
|
7830
|
+
if (!this.comment) return;
|
|
8269
7831
|
const ui = this.kit.useUI();
|
|
8270
7832
|
if (ui.$sendReplyBtn) {
|
|
8271
7833
|
ui.$sendReplyBtn.remove();
|
|
@@ -8290,15 +7852,14 @@ class StateEdit extends EditorPlug {
|
|
|
8290
7852
|
});
|
|
8291
7853
|
this.kit.useMounted(() => {
|
|
8292
7854
|
const submitPlug = this.kit.useDeps(Submit);
|
|
8293
|
-
if (!submitPlug)
|
|
8294
|
-
throw Error("SubmitPlug not initialized");
|
|
7855
|
+
if (!submitPlug) throw Error("SubmitPlug not initialized");
|
|
8295
7856
|
submitPlug.registerCustom({
|
|
8296
7857
|
activeCond: () => !!this.comment,
|
|
8297
7858
|
// active this custom submit when edit mode
|
|
8298
7859
|
req: () => __async(this, null, function* () {
|
|
8299
7860
|
const saveData = {
|
|
8300
7861
|
content: this.kit.useEditor().getContentFinal(),
|
|
8301
|
-
nick: this.kit.useUI().$
|
|
7862
|
+
nick: this.kit.useUI().$name.value,
|
|
8302
7863
|
email: this.kit.useUI().$email.value,
|
|
8303
7864
|
link: this.kit.useUI().$link.value
|
|
8304
7865
|
};
|
|
@@ -8326,7 +7887,7 @@ class StateEdit extends EditorPlug {
|
|
|
8326
7887
|
}
|
|
8327
7888
|
this.comment = comment;
|
|
8328
7889
|
ui.$header.style.display = "none";
|
|
8329
|
-
ui.$
|
|
7890
|
+
ui.$name.value = comment.nick || "";
|
|
8330
7891
|
ui.$email.value = comment.email || "";
|
|
8331
7892
|
ui.$link.value = comment.link || "";
|
|
8332
7893
|
this.kit.useEditor().setContent(comment.content);
|
|
@@ -8334,16 +7895,15 @@ class StateEdit extends EditorPlug {
|
|
|
8334
7895
|
this.updateSubmitBtnText(t("save"));
|
|
8335
7896
|
}
|
|
8336
7897
|
cancelEdit() {
|
|
8337
|
-
if (!this.comment)
|
|
8338
|
-
return;
|
|
7898
|
+
if (!this.comment) return;
|
|
8339
7899
|
const ui = this.kit.useUI();
|
|
8340
7900
|
if (ui.$editCancelBtn) {
|
|
8341
7901
|
ui.$editCancelBtn.remove();
|
|
8342
7902
|
ui.$editCancelBtn = void 0;
|
|
8343
7903
|
}
|
|
8344
7904
|
this.comment = void 0;
|
|
8345
|
-
const {
|
|
8346
|
-
ui.$
|
|
7905
|
+
const { name, email, link: link2 } = this.kit.useUser().getData();
|
|
7906
|
+
ui.$name.value = name;
|
|
8347
7907
|
ui.$email.value = email;
|
|
8348
7908
|
ui.$link.value = link2;
|
|
8349
7909
|
this.kit.useEditor().setContent("");
|
|
@@ -8383,7 +7943,7 @@ class Closable extends EditorPlug {
|
|
|
8383
7943
|
this.kit.useUI().$textareaWrap.prepend(
|
|
8384
7944
|
createElement(`<div class="atk-comment-closed">${t("onlyAdminCanReply")}</div>`)
|
|
8385
7945
|
);
|
|
8386
|
-
if (!this.kit.useUser().getData().
|
|
7946
|
+
if (!this.kit.useUser().getData().is_admin) {
|
|
8387
7947
|
this.kit.useUI().$textarea.style.display = "none";
|
|
8388
7948
|
this.kit.useEvents().trigger("panel-close");
|
|
8389
7949
|
this.kit.useUI().$bottom.style.display = "none";
|
|
@@ -8432,15 +7992,18 @@ class HeaderUser extends EditorPlug {
|
|
|
8432
7992
|
abortFn: null
|
|
8433
7993
|
});
|
|
8434
7994
|
const onInput = ({ $input, field }) => {
|
|
8435
|
-
if (this.kit.useEditor().getState() === "edit")
|
|
8436
|
-
return;
|
|
7995
|
+
if (this.kit.useEditor().getState() === "edit") return;
|
|
8437
7996
|
this.kit.useUser().update({ [field]: $input.value.trim() });
|
|
8438
|
-
if (field === "
|
|
8439
|
-
|
|
7997
|
+
if (field === "name" || field === "email") this.fetchUserInfo();
|
|
7998
|
+
};
|
|
7999
|
+
const placeholders = {
|
|
8000
|
+
name: t("nick"),
|
|
8001
|
+
email: t("email"),
|
|
8002
|
+
link: t("link")
|
|
8440
8003
|
};
|
|
8441
8004
|
this.kit.useMounted(() => {
|
|
8442
8005
|
Object.entries(this.kit.useEditor().getHeaderInputEls()).forEach(([key, $input]) => {
|
|
8443
|
-
$input.placeholder =
|
|
8006
|
+
$input.placeholder = placeholders[key];
|
|
8444
8007
|
$input.value = this.kit.useUser().getData()[key] || "";
|
|
8445
8008
|
});
|
|
8446
8009
|
this.kit.useEvents().on("header-input", onInput);
|
|
@@ -8454,10 +8017,8 @@ class HeaderUser extends EditorPlug {
|
|
|
8454
8017
|
*/
|
|
8455
8018
|
fetchUserInfo() {
|
|
8456
8019
|
this.kit.useUser().logout();
|
|
8457
|
-
if (this.query.timer)
|
|
8458
|
-
|
|
8459
|
-
if (this.query.abortFn)
|
|
8460
|
-
this.query.abortFn();
|
|
8020
|
+
if (this.query.timer) window.clearTimeout(this.query.timer);
|
|
8021
|
+
if (this.query.abortFn) this.query.abortFn();
|
|
8461
8022
|
this.query.timer = window.setTimeout(() => {
|
|
8462
8023
|
this.query.timer = null;
|
|
8463
8024
|
const api = this.kit.useApi();
|
|
@@ -8481,8 +8042,7 @@ class HeaderUser extends EditorPlug {
|
|
|
8481
8042
|
*/
|
|
8482
8043
|
onUserInfoFetched(data) {
|
|
8483
8044
|
var _a;
|
|
8484
|
-
if (!data.is_login)
|
|
8485
|
-
this.kit.useUser().logout();
|
|
8045
|
+
if (!data.is_login) this.kit.useUser().logout();
|
|
8486
8046
|
this.kit.useGlobalCtx().getData().updateNotifies(data.notifies);
|
|
8487
8047
|
if (this.kit.useUser().checkHasBasicUserInfo() && !data.is_login && ((_a = data.user) == null ? void 0 : _a.is_admin)) {
|
|
8488
8048
|
this.kit.useGlobalCtx().checkAdmin({
|
|
@@ -8500,8 +8060,7 @@ class HeaderLink extends EditorPlug {
|
|
|
8500
8060
|
constructor(kit) {
|
|
8501
8061
|
super(kit);
|
|
8502
8062
|
const onLinkChange = ({ field }) => {
|
|
8503
|
-
if (field === "link")
|
|
8504
|
-
this.onLinkInputChange();
|
|
8063
|
+
if (field === "link") this.onLinkInputChange();
|
|
8505
8064
|
};
|
|
8506
8065
|
this.kit.useMounted(() => {
|
|
8507
8066
|
this.kit.useEvents().on("header-change", onLinkChange);
|
|
@@ -8557,8 +8116,7 @@ class Emoticons extends EditorPlug {
|
|
|
8557
8116
|
}
|
|
8558
8117
|
loadEmoticonsData() {
|
|
8559
8118
|
return __async(this, null, function* () {
|
|
8560
|
-
if (this.isListLoaded)
|
|
8561
|
-
return;
|
|
8119
|
+
if (this.isListLoaded) return;
|
|
8562
8120
|
if (this.loadingTask !== null) {
|
|
8563
8121
|
yield this.loadingTask;
|
|
8564
8122
|
return;
|
|
@@ -8584,10 +8142,8 @@ class Emoticons extends EditorPlug {
|
|
|
8584
8142
|
return [];
|
|
8585
8143
|
}
|
|
8586
8144
|
const pushGrp = (grp) => {
|
|
8587
|
-
if (typeof grp !== "object")
|
|
8588
|
-
|
|
8589
|
-
if (grp.name && data.find((o) => o.name === grp.name))
|
|
8590
|
-
return;
|
|
8145
|
+
if (typeof grp !== "object") return;
|
|
8146
|
+
if (grp.name && data.find((o) => o.name === grp.name)) return;
|
|
8591
8147
|
data.push(grp);
|
|
8592
8148
|
};
|
|
8593
8149
|
const remoteLoad = (d) => __async(this, null, function* () {
|
|
@@ -8599,10 +8155,8 @@ class Emoticons extends EditorPlug {
|
|
|
8599
8155
|
yield remoteLoad(grp);
|
|
8600
8156
|
} else if (typeof grp === "string") {
|
|
8601
8157
|
const grpData = yield this.remoteLoad(grp);
|
|
8602
|
-
if (Array.isArray(grpData))
|
|
8603
|
-
|
|
8604
|
-
else if (typeof grpData === "object")
|
|
8605
|
-
pushGrp(grpData);
|
|
8158
|
+
if (Array.isArray(grpData)) yield remoteLoad(grpData);
|
|
8159
|
+
else if (typeof grpData === "object") pushGrp(grpData);
|
|
8606
8160
|
}
|
|
8607
8161
|
}))
|
|
8608
8162
|
);
|
|
@@ -8631,8 +8185,7 @@ class Emoticons extends EditorPlug {
|
|
|
8631
8185
|
/** 远程加载 */
|
|
8632
8186
|
remoteLoad(url) {
|
|
8633
8187
|
return __async(this, null, function* () {
|
|
8634
|
-
if (!url)
|
|
8635
|
-
return [];
|
|
8188
|
+
if (!url) return [];
|
|
8636
8189
|
try {
|
|
8637
8190
|
const resp = yield fetch(url);
|
|
8638
8191
|
const json = yield resp.json();
|
|
@@ -8649,8 +8202,7 @@ class Emoticons extends EditorPlug {
|
|
|
8649
8202
|
solveNullKey(data) {
|
|
8650
8203
|
data.forEach((grp) => {
|
|
8651
8204
|
grp.items.forEach((item, index) => {
|
|
8652
|
-
if (!item.key)
|
|
8653
|
-
item.key = `${grp.name} ${index + 1}`;
|
|
8205
|
+
if (!item.key) item.key = `${grp.name} ${index + 1}`;
|
|
8654
8206
|
});
|
|
8655
8207
|
});
|
|
8656
8208
|
}
|
|
@@ -8659,14 +8211,10 @@ class Emoticons extends EditorPlug {
|
|
|
8659
8211
|
const tmp = {};
|
|
8660
8212
|
data.forEach((grp) => {
|
|
8661
8213
|
grp.items.forEach((item) => {
|
|
8662
|
-
if (!item.key || String(item.key).trim() === "")
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
else
|
|
8667
|
-
tmp[item.key]++;
|
|
8668
|
-
if (tmp[item.key] > 1)
|
|
8669
|
-
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]}`;
|
|
8670
8218
|
});
|
|
8671
8219
|
});
|
|
8672
8220
|
}
|
|
@@ -8687,8 +8235,7 @@ class Emoticons extends EditorPlug {
|
|
|
8687
8235
|
const iconStr = item.icon;
|
|
8688
8236
|
if (/<(img|IMG)/.test(iconStr)) {
|
|
8689
8237
|
const find = /src=["'](.*?)["']/.exec(iconStr);
|
|
8690
|
-
if (find && find.length > 1)
|
|
8691
|
-
item.icon = find[1];
|
|
8238
|
+
if (find && find.length > 1) item.icon = find[1];
|
|
8692
8239
|
}
|
|
8693
8240
|
nGrp.items.push({
|
|
8694
8241
|
key: item.text || `${grpName} ${index + 1}`,
|
|
@@ -8742,8 +8289,7 @@ class Emoticons extends EditorPlug {
|
|
|
8742
8289
|
this.$grpSwitcher.append($item);
|
|
8743
8290
|
});
|
|
8744
8291
|
}
|
|
8745
|
-
if (this.emoticons.length > 0)
|
|
8746
|
-
this.openGrp(0);
|
|
8292
|
+
if (this.emoticons.length > 0) this.openGrp(0);
|
|
8747
8293
|
}
|
|
8748
8294
|
/** 打开一个表情组 */
|
|
8749
8295
|
openGrp(index) {
|
|
@@ -8764,11 +8310,9 @@ class Emoticons extends EditorPlug {
|
|
|
8764
8310
|
}
|
|
8765
8311
|
/** 处理评论 content 中的表情内容 */
|
|
8766
8312
|
transEmoticonImageText(text) {
|
|
8767
|
-
if (!this.emoticons || !Array.isArray(this.emoticons))
|
|
8768
|
-
return text;
|
|
8313
|
+
if (!this.emoticons || !Array.isArray(this.emoticons)) return text;
|
|
8769
8314
|
this.emoticons.forEach((grp) => {
|
|
8770
|
-
if (grp.type !== "image")
|
|
8771
|
-
return;
|
|
8315
|
+
if (grp.type !== "image") return;
|
|
8772
8316
|
Object.entries(grp.items).forEach(([index, item]) => {
|
|
8773
8317
|
text = text.split(`:[${item.key}]`).join(`<img src="${item.val}" atk-emoticon="${item.key}">`);
|
|
8774
8318
|
});
|
|
@@ -8797,8 +8341,7 @@ class Upload extends EditorPlug {
|
|
|
8797
8341
|
const $input = this.$imgUploadInput;
|
|
8798
8342
|
$input.onchange = () => {
|
|
8799
8343
|
(() => __async(this, null, function* () {
|
|
8800
|
-
if (!$input.files || $input.files.length === 0)
|
|
8801
|
-
return;
|
|
8344
|
+
if (!$input.files || $input.files.length === 0) return;
|
|
8802
8345
|
const file = $input.files[0];
|
|
8803
8346
|
this.uploadImg(file);
|
|
8804
8347
|
}))();
|
|
@@ -8811,8 +8354,7 @@ class Upload extends EditorPlug {
|
|
|
8811
8354
|
}
|
|
8812
8355
|
initDragImg() {
|
|
8813
8356
|
const uploadFromFileList = (files) => {
|
|
8814
|
-
if (!files)
|
|
8815
|
-
return;
|
|
8357
|
+
if (!files) return;
|
|
8816
8358
|
for (let i = 0; i < files.length; i++) {
|
|
8817
8359
|
const file = files[i];
|
|
8818
8360
|
this.uploadImg(file);
|
|
@@ -8852,15 +8394,13 @@ class Upload extends EditorPlug {
|
|
|
8852
8394
|
uploadImg(file) {
|
|
8853
8395
|
return __async(this, null, function* () {
|
|
8854
8396
|
const fileExt = /[^.]+$/.exec(file.name);
|
|
8855
|
-
if (!fileExt || !AllowImgExts.includes(String(fileExt[0]).toLowerCase()))
|
|
8856
|
-
return;
|
|
8397
|
+
if (!fileExt || !AllowImgExts.includes(String(fileExt[0]).toLowerCase())) return;
|
|
8857
8398
|
if (!this.kit.useUser().checkHasBasicUserInfo()) {
|
|
8858
8399
|
this.kit.useEditor().showNotify(t("uploadLoginMsg"), "w");
|
|
8859
8400
|
return;
|
|
8860
8401
|
}
|
|
8861
8402
|
let insertPrefix = "\n";
|
|
8862
|
-
if (this.kit.useUI().$textarea.value.trim() === "")
|
|
8863
|
-
insertPrefix = "";
|
|
8403
|
+
if (this.kit.useUI().$textarea.value.trim() === "") insertPrefix = "";
|
|
8864
8404
|
const uploadPlaceholderTxt = `${insertPrefix}`;
|
|
8865
8405
|
this.kit.useEditor().insertContent(uploadPlaceholderTxt);
|
|
8866
8406
|
let resp;
|
|
@@ -9030,8 +8570,7 @@ class PlugManager {
|
|
|
9030
8570
|
clear() {
|
|
9031
8571
|
this.plugs = [];
|
|
9032
8572
|
this.events = new EventManager();
|
|
9033
|
-
if (this.openedPlug)
|
|
9034
|
-
this.closePlugPanel();
|
|
8573
|
+
if (this.openedPlug) this.closePlugPanel();
|
|
9035
8574
|
}
|
|
9036
8575
|
loadPluginUI() {
|
|
9037
8576
|
this.editor.getUI().$plugPanelWrap.innerHTML = "";
|
|
@@ -9042,8 +8581,7 @@ class PlugManager {
|
|
|
9042
8581
|
/** Load the plug btn and plug panel on editor ui */
|
|
9043
8582
|
loadPluginItem(plug) {
|
|
9044
8583
|
const $btn = plug.$btn;
|
|
9045
|
-
if (!$btn)
|
|
9046
|
-
return;
|
|
8584
|
+
if (!$btn) return;
|
|
9047
8585
|
this.editor.getUI().$plugBtnWrap.appendChild($btn);
|
|
9048
8586
|
!$btn.onclick && ($btn.onclick = () => {
|
|
9049
8587
|
this.editor.getUI().$plugBtnWrap.querySelectorAll(".active").forEach((item) => item.classList.remove("active"));
|
|
@@ -9067,8 +8605,7 @@ class PlugManager {
|
|
|
9067
8605
|
openPlugPanel(plug) {
|
|
9068
8606
|
this.plugs.forEach((aPlug) => {
|
|
9069
8607
|
const plugPanel = aPlug.$panel;
|
|
9070
|
-
if (!plugPanel)
|
|
9071
|
-
return;
|
|
8608
|
+
if (!plugPanel) return;
|
|
9072
8609
|
if (aPlug === plug) {
|
|
9073
8610
|
plugPanel.style.display = "";
|
|
9074
8611
|
this.events.trigger("panel-show", plug);
|
|
@@ -9082,8 +8619,7 @@ class PlugManager {
|
|
|
9082
8619
|
}
|
|
9083
8620
|
/** Close the editor plug panel */
|
|
9084
8621
|
closePlugPanel() {
|
|
9085
|
-
if (!this.openedPlug)
|
|
9086
|
-
return;
|
|
8622
|
+
if (!this.openedPlug) return;
|
|
9087
8623
|
this.editor.getUI().$plugPanelWrap.style.display = "none";
|
|
9088
8624
|
this.events.trigger("panel-hide", this.openedPlug);
|
|
9089
8625
|
this.openedPlug = null;
|
|
@@ -9092,8 +8628,7 @@ class PlugManager {
|
|
|
9092
8628
|
getTransformedContent(rawContent) {
|
|
9093
8629
|
let result = rawContent;
|
|
9094
8630
|
this.plugs.forEach((aPlug) => {
|
|
9095
|
-
if (!aPlug.contentTransformer)
|
|
9096
|
-
return;
|
|
8631
|
+
if (!aPlug.contentTransformer) return;
|
|
9097
8632
|
result = aPlug.contentTransformer(result);
|
|
9098
8633
|
});
|
|
9099
8634
|
return result;
|
|
@@ -9106,8 +8641,7 @@ const WithEditor = (ctx) => {
|
|
|
9106
8641
|
$closeCommentBtn = list2.$el.querySelector('[data-action="admin-close-comment"]');
|
|
9107
8642
|
$closeCommentBtn.addEventListener("click", () => {
|
|
9108
8643
|
const page = ctx.getData().getPage();
|
|
9109
|
-
if (!page)
|
|
9110
|
-
throw new Error("Page data not found");
|
|
8644
|
+
if (!page) throw new Error("Page data not found");
|
|
9111
8645
|
page.admin_only = !page.admin_only;
|
|
9112
8646
|
adminPageEditSave(ctx, page);
|
|
9113
8647
|
});
|
|
@@ -9169,8 +8703,7 @@ const Count = (ctx) => {
|
|
|
9169
8703
|
var _a, _b;
|
|
9170
8704
|
const list2 = ctx.get("list");
|
|
9171
8705
|
const $count = list2.$el.querySelector(".atk-comment-count .atk-text");
|
|
9172
|
-
if (!$count)
|
|
9173
|
-
return;
|
|
8706
|
+
if (!$count) return;
|
|
9174
8707
|
const text = htmlEncode(
|
|
9175
8708
|
t("counter", {
|
|
9176
8709
|
count: `${Number((_b = (_a = ctx.getData().getListLastFetch()) == null ? void 0 : _a.data) == null ? void 0 : _b.count) || 0}`
|
|
@@ -9183,26 +8716,22 @@ const Count = (ctx) => {
|
|
|
9183
8716
|
});
|
|
9184
8717
|
ctx.on("comment-inserted", () => {
|
|
9185
8718
|
const last = ctx.getData().getListLastFetch();
|
|
9186
|
-
if (last == null ? void 0 : last.data)
|
|
9187
|
-
last.data.count += 1;
|
|
8719
|
+
if (last == null ? void 0 : last.data) last.data.count += 1;
|
|
9188
8720
|
});
|
|
9189
8721
|
ctx.on("comment-deleted", () => {
|
|
9190
8722
|
const last = ctx.getData().getListLastFetch();
|
|
9191
|
-
if (last == null ? void 0 : last.data)
|
|
9192
|
-
last.data.count -= 1;
|
|
8723
|
+
if (last == null ? void 0 : last.data) last.data.count -= 1;
|
|
9193
8724
|
});
|
|
9194
8725
|
};
|
|
9195
8726
|
const SidebarBtn = (ctx) => {
|
|
9196
8727
|
let $openSidebarBtn = null;
|
|
9197
8728
|
const syncByUser = () => {
|
|
9198
|
-
if (!$openSidebarBtn)
|
|
9199
|
-
return;
|
|
8729
|
+
if (!$openSidebarBtn) return;
|
|
9200
8730
|
const user = ctx.get("user").getData();
|
|
9201
|
-
if (!!user.
|
|
8731
|
+
if (!!user.name && !!user.email) {
|
|
9202
8732
|
$openSidebarBtn.classList.remove("atk-hide");
|
|
9203
8733
|
const $btnText = $openSidebarBtn.querySelector(".atk-text");
|
|
9204
|
-
if ($btnText)
|
|
9205
|
-
$btnText.innerText = !user.isAdmin ? t("msgCenter") : t("ctrlCenter");
|
|
8734
|
+
if ($btnText) $btnText.innerText = !user.is_admin ? t("msgCenter") : t("ctrlCenter");
|
|
9206
8735
|
} else {
|
|
9207
8736
|
$openSidebarBtn.classList.add("atk-hide");
|
|
9208
8737
|
}
|
|
@@ -9210,8 +8739,7 @@ const SidebarBtn = (ctx) => {
|
|
|
9210
8739
|
ctx.watchConf(["locale"], (conf) => {
|
|
9211
8740
|
const list2 = ctx.get("list");
|
|
9212
8741
|
$openSidebarBtn = list2.$el.querySelector('[data-action="open-sidebar"]');
|
|
9213
|
-
if (!$openSidebarBtn)
|
|
9214
|
-
return;
|
|
8742
|
+
if (!$openSidebarBtn) return;
|
|
9215
8743
|
$openSidebarBtn.onclick = () => {
|
|
9216
8744
|
ctx.showSidebar();
|
|
9217
8745
|
};
|
|
@@ -9224,8 +8752,7 @@ const SidebarBtn = (ctx) => {
|
|
|
9224
8752
|
const UnreadBadge = (ctx) => {
|
|
9225
8753
|
let $unreadBadge = null;
|
|
9226
8754
|
const showUnreadBadge = (count) => {
|
|
9227
|
-
if (!$unreadBadge)
|
|
9228
|
-
return;
|
|
8755
|
+
if (!$unreadBadge) return;
|
|
9229
8756
|
if (count > 0) {
|
|
9230
8757
|
$unreadBadge.innerText = `${Number(count || 0)}`;
|
|
9231
8758
|
$unreadBadge.style.display = "block";
|
|
@@ -9245,10 +8772,8 @@ const GotoDispatcher = (ctx) => {
|
|
|
9245
8772
|
let lastID = 0;
|
|
9246
8773
|
const check2 = ({ locker }) => {
|
|
9247
8774
|
const commentID = extractCommentID();
|
|
9248
|
-
if (!commentID)
|
|
9249
|
-
|
|
9250
|
-
if (locker && lastID === commentID)
|
|
9251
|
-
return;
|
|
8775
|
+
if (!commentID) return;
|
|
8776
|
+
if (locker && lastID === commentID) return;
|
|
9252
8777
|
lastID = commentID;
|
|
9253
8778
|
ctx.trigger("list-goto", commentID);
|
|
9254
8779
|
};
|
|
@@ -9279,18 +8804,16 @@ const GotoFocus = (ctx) => {
|
|
|
9279
8804
|
ctx.get("list").getListLayout({ forceFlatMode: true }).insert(data.comment, data.reply_comment);
|
|
9280
8805
|
comment = ctx.getCommentNodes().find((c) => c.getID() === commentID);
|
|
9281
8806
|
}
|
|
9282
|
-
if (!comment)
|
|
9283
|
-
return;
|
|
8807
|
+
if (!comment) return;
|
|
9284
8808
|
comment.focus();
|
|
9285
8809
|
}));
|
|
9286
8810
|
};
|
|
9287
|
-
const version = "2.
|
|
8811
|
+
const version = "2.9.0";
|
|
9288
8812
|
const Copyright = (ctx) => {
|
|
9289
8813
|
ctx.on("mounted", () => {
|
|
9290
8814
|
const list2 = ctx.get("list");
|
|
9291
8815
|
const $copyright = list2.$el.querySelector(".atk-copyright");
|
|
9292
|
-
if (!$copyright)
|
|
9293
|
-
return;
|
|
8816
|
+
if (!$copyright) return;
|
|
9294
8817
|
$copyright.innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${version}">Artalk</a>`;
|
|
9295
8818
|
});
|
|
9296
8819
|
};
|
|
@@ -9357,8 +8880,7 @@ const Dropdown = (ctx) => {
|
|
|
9357
8880
|
ctx.watchConf(["listSort", "locale"], (conf) => {
|
|
9358
8881
|
const list2 = ctx.get("list");
|
|
9359
8882
|
const $count = list2.$el.querySelector(".atk-comment-count");
|
|
9360
|
-
if (!$count)
|
|
9361
|
-
return;
|
|
8883
|
+
if (!$count) return;
|
|
9362
8884
|
if (conf.listSort) {
|
|
9363
8885
|
initDropdown($count);
|
|
9364
8886
|
} else {
|
|
@@ -9370,8 +8892,7 @@ const Dropdown = (ctx) => {
|
|
|
9370
8892
|
};
|
|
9371
8893
|
function renderDropdown(conf) {
|
|
9372
8894
|
const { $dropdownWrap, dropdownList } = conf;
|
|
9373
|
-
if ($dropdownWrap.querySelector(".atk-dropdown"))
|
|
9374
|
-
return;
|
|
8895
|
+
if ($dropdownWrap.querySelector(".atk-dropdown")) return;
|
|
9375
8896
|
$dropdownWrap.classList.add("atk-dropdown-wrap");
|
|
9376
8897
|
$dropdownWrap.append(createElement(`<span class="atk-arrow-down-icon"></span>`));
|
|
9377
8898
|
let curtActive = 0;
|
|
@@ -9389,8 +8910,7 @@ function renderDropdown(conf) {
|
|
|
9389
8910
|
};
|
|
9390
8911
|
const $dropdown = createElement(`<ul class="atk-dropdown atk-fade-in"></ul>`);
|
|
9391
8912
|
dropdownList.forEach((item, i) => {
|
|
9392
|
-
const name = item
|
|
9393
|
-
const action = item[1];
|
|
8913
|
+
const [name, action] = item;
|
|
9394
8914
|
const $item = createElement(`<li class="atk-dropdown-item"><span></span></li>`);
|
|
9395
8915
|
const $link = $item.querySelector("span");
|
|
9396
8916
|
$link.innerText = name;
|
|
@@ -9398,8 +8918,7 @@ function renderDropdown(conf) {
|
|
|
9398
8918
|
onItemClick(i, $item, name, action);
|
|
9399
8919
|
};
|
|
9400
8920
|
$dropdown.append($item);
|
|
9401
|
-
if (i === curtActive)
|
|
9402
|
-
$item.classList.add("active");
|
|
8921
|
+
if (i === curtActive) $item.classList.add("active");
|
|
9403
8922
|
});
|
|
9404
8923
|
$dropdownWrap.append($dropdown);
|
|
9405
8924
|
}
|
|
@@ -9416,8 +8935,9 @@ const TimeTicking = (ctx) => {
|
|
|
9416
8935
|
timer = window.setInterval(() => {
|
|
9417
8936
|
const list2 = ctx.get("list");
|
|
9418
8937
|
list2.$el.querySelectorAll("[data-atk-comment-date]").forEach((el) => {
|
|
9419
|
-
|
|
9420
|
-
|
|
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);
|
|
9421
8941
|
});
|
|
9422
8942
|
}, 30 * 1e3);
|
|
9423
8943
|
});
|
|
@@ -9425,6 +8945,24 @@ const TimeTicking = (ctx) => {
|
|
|
9425
8945
|
timer && window.clearInterval(timer);
|
|
9426
8946
|
});
|
|
9427
8947
|
};
|
|
8948
|
+
function showErrorDialog(opts) {
|
|
8949
|
+
const errEl = createElement(`<span><span class="error-message"></span><br/><br/></span>`);
|
|
8950
|
+
errEl.querySelector(".error-message").innerText = `${t("listLoadFailMsg")}
|
|
8951
|
+
${opts.errMsg}`;
|
|
8952
|
+
if (opts.retryFn) {
|
|
8953
|
+
const $retryBtn = createElement(`<span style="cursor:pointer;">${t("listRetry")}</span>`);
|
|
8954
|
+
$retryBtn.onclick = () => opts.retryFn && opts.retryFn();
|
|
8955
|
+
errEl.appendChild($retryBtn);
|
|
8956
|
+
}
|
|
8957
|
+
if (opts.onOpenSidebar) {
|
|
8958
|
+
const $openSidebar = createElement(
|
|
8959
|
+
`<span atk-only-admin-show> | <span style="cursor:pointer;">${t("openName", { name: t("ctrlCenter") })}</span></span>`
|
|
8960
|
+
);
|
|
8961
|
+
errEl.appendChild($openSidebar);
|
|
8962
|
+
$openSidebar.onclick = () => opts.onOpenSidebar && opts.onOpenSidebar();
|
|
8963
|
+
}
|
|
8964
|
+
setError(opts.$err, errEl);
|
|
8965
|
+
}
|
|
9428
8966
|
const ErrorDialog = (ctx) => {
|
|
9429
8967
|
ctx.on("list-fetch", () => {
|
|
9430
8968
|
const list2 = ctx.get("list");
|
|
@@ -9452,8 +8990,7 @@ const Loading = (ctx) => {
|
|
|
9452
8990
|
};
|
|
9453
8991
|
const Fetch = (ctx) => {
|
|
9454
8992
|
ctx.on("list-fetch", (_params) => {
|
|
9455
|
-
if (ctx.getData().getLoading())
|
|
9456
|
-
return;
|
|
8993
|
+
if (ctx.getData().getLoading()) return;
|
|
9457
8994
|
ctx.getData().setLoading(true);
|
|
9458
8995
|
const params = __spreadValues({
|
|
9459
8996
|
// default params
|
|
@@ -9473,8 +9010,7 @@ const Fetch = (ctx) => {
|
|
|
9473
9010
|
page_key: ctx.getConf().pageKey,
|
|
9474
9011
|
site_name: ctx.getConf().site
|
|
9475
9012
|
};
|
|
9476
|
-
if (params.paramsModifier)
|
|
9477
|
-
params.paramsModifier(reqParams);
|
|
9013
|
+
if (params.paramsModifier) params.paramsModifier(reqParams);
|
|
9478
9014
|
ctx.getApi().comments.getComments(__spreadValues(__spreadValues({}, reqParams), ctx.getApi().getUserFields())).then(({ data }) => {
|
|
9479
9015
|
ctx.getData().setListLastFetch({ params, data });
|
|
9480
9016
|
ctx.getData().loadComments(data.comments);
|
|
@@ -9525,8 +9061,7 @@ const ReachBottom = (ctx) => {
|
|
|
9525
9061
|
const list2 = ctx.get("list");
|
|
9526
9062
|
const children = list2.getCommentsWrapEl().childNodes;
|
|
9527
9063
|
const $target = children.length > 2 ? children[children.length - 2] : null;
|
|
9528
|
-
if (!$target)
|
|
9529
|
-
return;
|
|
9064
|
+
if (!$target) return;
|
|
9530
9065
|
if (!("IntersectionObserver" in window)) {
|
|
9531
9066
|
console.warn("IntersectionObserver api not supported");
|
|
9532
9067
|
return;
|
|
@@ -9573,11 +9108,9 @@ const ListPlugins = [
|
|
|
9573
9108
|
];
|
|
9574
9109
|
const Notifies = (ctx) => {
|
|
9575
9110
|
ctx.on("list-fetch", (params) => {
|
|
9576
|
-
if (params.offset !== 0)
|
|
9577
|
-
return;
|
|
9111
|
+
if (params.offset !== 0) return;
|
|
9578
9112
|
const user = ctx.getApi().getUserFields();
|
|
9579
|
-
if (!user)
|
|
9580
|
-
return;
|
|
9113
|
+
if (!user) return;
|
|
9581
9114
|
ctx.getApi().notifies.getNotifies(user).then((res) => {
|
|
9582
9115
|
ctx.getData().updateNotifies(res.data.notifies);
|
|
9583
9116
|
});
|
|
@@ -9594,8 +9127,7 @@ const VersionCheck = (ctx) => {
|
|
|
9594
9127
|
function versionCheck(list2, feVer, beVer) {
|
|
9595
9128
|
const comp = versionCompare(feVer, beVer);
|
|
9596
9129
|
const sameVer = comp === 0;
|
|
9597
|
-
if (sameVer)
|
|
9598
|
-
return;
|
|
9130
|
+
if (sameVer) return;
|
|
9599
9131
|
const errEl = createElement(
|
|
9600
9132
|
`<div class="atk-version-check-notice">${t("updateMsg", {
|
|
9601
9133
|
name: comp < 0 ? t("frontend") : t("backend")
|
|
@@ -9612,7 +9144,7 @@ function versionCheck(list2, feVer, beVer) {
|
|
|
9612
9144
|
const AdminOnlyElem = (ctx) => {
|
|
9613
9145
|
const scanApply = () => {
|
|
9614
9146
|
applyAdminOnlyEls(
|
|
9615
|
-
ctx.get("user").getData().
|
|
9147
|
+
ctx.get("user").getData().is_admin,
|
|
9616
9148
|
getAdminOnlyEls({
|
|
9617
9149
|
$root: ctx.$root
|
|
9618
9150
|
})
|
|
@@ -9635,20 +9167,16 @@ function getAdminOnlyEls(opts) {
|
|
|
9635
9167
|
}
|
|
9636
9168
|
function applyAdminOnlyEls(isAdmin, els) {
|
|
9637
9169
|
els.forEach(($item) => {
|
|
9638
|
-
if (isAdmin)
|
|
9639
|
-
|
|
9640
|
-
else
|
|
9641
|
-
$item.classList.add("atk-hide");
|
|
9170
|
+
if (isAdmin) $item.classList.remove("atk-hide");
|
|
9171
|
+
else $item.classList.add("atk-hide");
|
|
9642
9172
|
});
|
|
9643
9173
|
}
|
|
9644
9174
|
let darkModeMedia;
|
|
9645
9175
|
function updateClassnames($els, darkMode) {
|
|
9646
9176
|
const DarkModeClassName = "atk-dark-mode";
|
|
9647
9177
|
$els.forEach(($el) => {
|
|
9648
|
-
if (darkMode)
|
|
9649
|
-
|
|
9650
|
-
else
|
|
9651
|
-
$el.classList.remove(DarkModeClassName);
|
|
9178
|
+
if (darkMode) $el.classList.add(DarkModeClassName);
|
|
9179
|
+
else $el.classList.remove(DarkModeClassName);
|
|
9652
9180
|
});
|
|
9653
9181
|
}
|
|
9654
9182
|
const DarkMode = (ctx) => {
|
|
@@ -9689,16 +9217,17 @@ const DefaultPlugins = [
|
|
|
9689
9217
|
VersionCheck,
|
|
9690
9218
|
DarkMode
|
|
9691
9219
|
];
|
|
9692
|
-
const GlobalPlugins = [...DefaultPlugins];
|
|
9220
|
+
const GlobalPlugins = /* @__PURE__ */ new Set([...DefaultPlugins]);
|
|
9221
|
+
const PluginOptions = /* @__PURE__ */ new WeakMap();
|
|
9693
9222
|
function load(ctx) {
|
|
9694
9223
|
return __async(this, null, function* () {
|
|
9695
9224
|
var _a;
|
|
9696
|
-
const loadedPlugins =
|
|
9225
|
+
const loadedPlugins = /* @__PURE__ */ new Set();
|
|
9697
9226
|
const loadPlugins = (plugins) => {
|
|
9698
9227
|
plugins.forEach((plugin) => {
|
|
9699
|
-
if (typeof plugin === "function" && !loadedPlugins.
|
|
9700
|
-
plugin(ctx);
|
|
9701
|
-
loadedPlugins.
|
|
9228
|
+
if (typeof plugin === "function" && !loadedPlugins.has(plugin)) {
|
|
9229
|
+
plugin(ctx, PluginOptions.get(plugin));
|
|
9230
|
+
loadedPlugins.add(plugin);
|
|
9702
9231
|
}
|
|
9703
9232
|
});
|
|
9704
9233
|
};
|
|
@@ -9734,8 +9263,8 @@ function load(ctx) {
|
|
|
9734
9263
|
}
|
|
9735
9264
|
function loadNetworkPlugins(scripts, apiBase) {
|
|
9736
9265
|
return __async(this, null, function* () {
|
|
9737
|
-
|
|
9738
|
-
|
|
9266
|
+
const networkPlugins = /* @__PURE__ */ new Set();
|
|
9267
|
+
if (!scripts || !Array.isArray(scripts)) return networkPlugins;
|
|
9739
9268
|
const tasks = [];
|
|
9740
9269
|
scripts.forEach((url) => {
|
|
9741
9270
|
if (!/^(http|https):\/\//.test(url))
|
|
@@ -9755,7 +9284,10 @@ function loadNetworkPlugins(scripts, apiBase) {
|
|
|
9755
9284
|
);
|
|
9756
9285
|
});
|
|
9757
9286
|
yield Promise.all(tasks);
|
|
9758
|
-
|
|
9287
|
+
Object.values(window.ArtalkPlugins || {}).forEach((plugin) => {
|
|
9288
|
+
if (typeof plugin === "function") networkPlugins.add(plugin);
|
|
9289
|
+
});
|
|
9290
|
+
return networkPlugins;
|
|
9759
9291
|
});
|
|
9760
9292
|
}
|
|
9761
9293
|
function onLoadErr(ctx, err) {
|
|
@@ -9773,7 +9305,7 @@ function onLoadErr(ctx, err) {
|
|
|
9773
9305
|
errMsg: err.msg || String(err),
|
|
9774
9306
|
errData: err.data,
|
|
9775
9307
|
retryFn: () => load(ctx),
|
|
9776
|
-
onOpenSidebar: ctx.get("user").getData().
|
|
9308
|
+
onOpenSidebar: ctx.get("user").getData().is_admin ? () => ctx.showSidebar({
|
|
9777
9309
|
view: sidebarOpenView
|
|
9778
9310
|
}) : void 0
|
|
9779
9311
|
// only show open sidebar button when user is admin
|
|
@@ -9840,10 +9372,9 @@ class Artalk {
|
|
|
9840
9372
|
return new Artalk(conf);
|
|
9841
9373
|
}
|
|
9842
9374
|
/** Use plugin, the plugin will be used when Artalk.init */
|
|
9843
|
-
static use(plugin) {
|
|
9844
|
-
|
|
9845
|
-
|
|
9846
|
-
GlobalPlugins.push(plugin);
|
|
9375
|
+
static use(plugin, options) {
|
|
9376
|
+
GlobalPlugins.add(plugin);
|
|
9377
|
+
PluginOptions.set(plugin, options);
|
|
9847
9378
|
}
|
|
9848
9379
|
/** Load count widget */
|
|
9849
9380
|
static loadCountWidget(c) {
|
|
@@ -9853,6 +9384,7 @@ class Artalk {
|
|
|
9853
9384
|
siteName: conf.site,
|
|
9854
9385
|
countEl: conf.countEl,
|
|
9855
9386
|
pvEl: conf.pvEl,
|
|
9387
|
+
pageKeyAttr: conf.statPageKeyAttr,
|
|
9856
9388
|
pvAdd: false
|
|
9857
9389
|
});
|
|
9858
9390
|
}
|