artalk 2.8.7 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +630 -1130
- 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 +325 -868
- package/dist/ArtalkLite.mjs.map +1 -1
- package/dist/i18n/fr.cjs +1 -0
- package/dist/i18n/fr.js +1 -0
- package/dist/i18n/fr.mjs +123 -0
- package/dist/i18n/{jp.cjs → ja.cjs} +1 -1
- package/dist/i18n/ja.d.cts +3 -0
- package/dist/i18n/ja.d.ts +3 -0
- package/dist/i18n/{jp.js → ja.js} +1 -1
- package/dist/i18n/{jp.mjs → ja.mjs} +12 -9
- package/dist/i18n/ko.cjs +1 -0
- package/dist/i18n/ko.d.cts +3 -0
- package/dist/i18n/ko.d.ts +3 -0
- package/dist/i18n/ko.js +1 -0
- package/dist/i18n/ko.mjs +123 -0
- package/dist/i18n/ru.cjs +1 -0
- package/dist/i18n/ru.d.cts +3 -0
- package/dist/i18n/ru.d.ts +3 -0
- package/dist/i18n/ru.js +1 -0
- package/dist/i18n/ru.mjs +123 -0
- package/dist/i18n/zh-TW.cjs +1 -1
- package/dist/i18n/zh-TW.js +1 -1
- package/dist/i18n/zh-TW.mjs +6 -3
- package/dist/main.d.cts +146 -85
- package/dist/main.d.ts +146 -85
- package/package.json +49 -15
- /package/dist/i18n/{jp.d.cts → fr.d.cts} +0 -0
- /package/dist/i18n/{jp.d.ts → fr.d.ts} +0 -0
package/dist/Artalk.mjs
CHANGED
|
@@ -29,23 +29,7 @@ var __objRest = (source, exclude) => {
|
|
|
29
29
|
}
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
|
-
var __publicField = (obj, key, value) =>
|
|
33
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
|
-
return value;
|
|
35
|
-
};
|
|
36
|
-
var __accessCheck = (obj, member, msg) => {
|
|
37
|
-
if (!member.has(obj))
|
|
38
|
-
throw TypeError("Cannot " + msg);
|
|
39
|
-
};
|
|
40
|
-
var __privateAdd = (obj, member, value) => {
|
|
41
|
-
if (member.has(obj))
|
|
42
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
43
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
44
|
-
};
|
|
45
|
-
var __privateMethod = (obj, member, method) => {
|
|
46
|
-
__accessCheck(obj, member, "access private method");
|
|
47
|
-
return method;
|
|
48
|
-
};
|
|
32
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
49
33
|
var __async = (__this, __arguments, generator) => {
|
|
50
34
|
return new Promise((resolve, reject) => {
|
|
51
35
|
var fulfilled = (value) => {
|
|
@@ -66,7 +50,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
66
50
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
67
51
|
});
|
|
68
52
|
};
|
|
69
|
-
var _parseMarkdown, parseMarkdown_fn, _onError, onError_fn;
|
|
70
53
|
class HttpClient {
|
|
71
54
|
constructor(apiConfig = {}) {
|
|
72
55
|
__publicField(this, "baseUrl", "/api/v2");
|
|
@@ -163,7 +146,7 @@ class HttpClient {
|
|
|
163
146
|
body: typeof body === "undefined" || body === null ? null : payloadFormatter(body)
|
|
164
147
|
})
|
|
165
148
|
).then((response) => __async(this, null, function* () {
|
|
166
|
-
const r = response;
|
|
149
|
+
const r = response.clone();
|
|
167
150
|
r.data = null;
|
|
168
151
|
r.error = null;
|
|
169
152
|
const data = !responseFormat ? r : yield response[responseFormat]().then((data2) => {
|
|
@@ -180,8 +163,7 @@ class HttpClient {
|
|
|
180
163
|
if (cancelToken) {
|
|
181
164
|
this.abortControllers.delete(cancelToken);
|
|
182
165
|
}
|
|
183
|
-
if (!response.ok)
|
|
184
|
-
throw data;
|
|
166
|
+
if (!response.ok) throw data;
|
|
185
167
|
return data;
|
|
186
168
|
}));
|
|
187
169
|
}));
|
|
@@ -253,7 +235,7 @@ let Api$1 = class Api extends HttpClient {
|
|
|
253
235
|
format: "json"
|
|
254
236
|
}, params)),
|
|
255
237
|
/**
|
|
256
|
-
* @description Register by email and verify code (if user exists, will update user, like forget password. Need send email verify code first)
|
|
238
|
+
* @description Register by email and verify code (if user exists, will update user, like forget or change password. Need send email verify code first)
|
|
257
239
|
*
|
|
258
240
|
* @tags Auth
|
|
259
241
|
* @name RegisterByEmail
|
|
@@ -1232,6 +1214,32 @@ let Api$1 = class Api extends HttpClient {
|
|
|
1232
1214
|
secure: true,
|
|
1233
1215
|
format: "json"
|
|
1234
1216
|
}, params)),
|
|
1217
|
+
/**
|
|
1218
|
+
* @description Update user profile when user is logged in
|
|
1219
|
+
*
|
|
1220
|
+
* @tags Auth
|
|
1221
|
+
* @name UpdateProfile
|
|
1222
|
+
* @summary Update user profile
|
|
1223
|
+
* @request POST:/user
|
|
1224
|
+
* @secure
|
|
1225
|
+
* @response `200` `HandlerResponseUserInfoUpdate` OK
|
|
1226
|
+
* @response `400` `(HandlerMap & {
|
|
1227
|
+
msg?: string,
|
|
1228
|
+
|
|
1229
|
+
})` Bad Request
|
|
1230
|
+
* @response `500` `(HandlerMap & {
|
|
1231
|
+
msg?: string,
|
|
1232
|
+
|
|
1233
|
+
})` Internal Server Error
|
|
1234
|
+
*/
|
|
1235
|
+
updateProfile: (data, params = {}) => this.request(__spreadValues({
|
|
1236
|
+
path: `/user`,
|
|
1237
|
+
method: "POST",
|
|
1238
|
+
body: data,
|
|
1239
|
+
secure: true,
|
|
1240
|
+
type: "application/json",
|
|
1241
|
+
format: "json"
|
|
1242
|
+
}, params)),
|
|
1235
1243
|
/**
|
|
1236
1244
|
* @description Login user by name or email
|
|
1237
1245
|
*
|
|
@@ -1466,411 +1474,12 @@ let Api$1 = class Api extends HttpClient {
|
|
|
1466
1474
|
});
|
|
1467
1475
|
}
|
|
1468
1476
|
};
|
|
1469
|
-
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
1470
|
-
function getDefaultExportFromCjs(x) {
|
|
1471
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
1472
|
-
}
|
|
1473
|
-
(function(factory) {
|
|
1474
|
-
factory();
|
|
1475
|
-
})(function() {
|
|
1476
|
-
function _classCallCheck(instance2, Constructor) {
|
|
1477
|
-
if (!(instance2 instanceof Constructor)) {
|
|
1478
|
-
throw new TypeError("Cannot call a class as a function");
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
function _defineProperties(target, props) {
|
|
1482
|
-
for (var i = 0; i < props.length; i++) {
|
|
1483
|
-
var descriptor = props[i];
|
|
1484
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
1485
|
-
descriptor.configurable = true;
|
|
1486
|
-
if ("value" in descriptor)
|
|
1487
|
-
descriptor.writable = true;
|
|
1488
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1489
|
-
}
|
|
1490
|
-
}
|
|
1491
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
1492
|
-
if (protoProps)
|
|
1493
|
-
_defineProperties(Constructor.prototype, protoProps);
|
|
1494
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
1495
|
-
writable: false
|
|
1496
|
-
});
|
|
1497
|
-
return Constructor;
|
|
1498
|
-
}
|
|
1499
|
-
function _inherits(subClass, superClass) {
|
|
1500
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
1501
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
1502
|
-
}
|
|
1503
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
1504
|
-
constructor: {
|
|
1505
|
-
value: subClass,
|
|
1506
|
-
writable: true,
|
|
1507
|
-
configurable: true
|
|
1508
|
-
}
|
|
1509
|
-
});
|
|
1510
|
-
Object.defineProperty(subClass, "prototype", {
|
|
1511
|
-
writable: false
|
|
1512
|
-
});
|
|
1513
|
-
if (superClass)
|
|
1514
|
-
_setPrototypeOf(subClass, superClass);
|
|
1515
|
-
}
|
|
1516
|
-
function _getPrototypeOf(o) {
|
|
1517
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
|
|
1518
|
-
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
1519
|
-
};
|
|
1520
|
-
return _getPrototypeOf(o);
|
|
1521
|
-
}
|
|
1522
|
-
function _setPrototypeOf(o, p) {
|
|
1523
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
|
|
1524
|
-
o2.__proto__ = p2;
|
|
1525
|
-
return o2;
|
|
1526
|
-
};
|
|
1527
|
-
return _setPrototypeOf(o, p);
|
|
1528
|
-
}
|
|
1529
|
-
function _isNativeReflectConstruct() {
|
|
1530
|
-
if (typeof Reflect === "undefined" || !Reflect.construct)
|
|
1531
|
-
return false;
|
|
1532
|
-
if (Reflect.construct.sham)
|
|
1533
|
-
return false;
|
|
1534
|
-
if (typeof Proxy === "function")
|
|
1535
|
-
return true;
|
|
1536
|
-
try {
|
|
1537
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
1538
|
-
}));
|
|
1539
|
-
return true;
|
|
1540
|
-
} catch (e) {
|
|
1541
|
-
return false;
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
function _assertThisInitialized(self2) {
|
|
1545
|
-
if (self2 === void 0) {
|
|
1546
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
1547
|
-
}
|
|
1548
|
-
return self2;
|
|
1549
|
-
}
|
|
1550
|
-
function _possibleConstructorReturn(self2, call) {
|
|
1551
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
1552
|
-
return call;
|
|
1553
|
-
} else if (call !== void 0) {
|
|
1554
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
1555
|
-
}
|
|
1556
|
-
return _assertThisInitialized(self2);
|
|
1557
|
-
}
|
|
1558
|
-
function _createSuper(Derived) {
|
|
1559
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
1560
|
-
return function _createSuperInternal() {
|
|
1561
|
-
var Super = _getPrototypeOf(Derived), result;
|
|
1562
|
-
if (hasNativeReflectConstruct) {
|
|
1563
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
1564
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
1565
|
-
} else {
|
|
1566
|
-
result = Super.apply(this, arguments);
|
|
1567
|
-
}
|
|
1568
|
-
return _possibleConstructorReturn(this, result);
|
|
1569
|
-
};
|
|
1570
|
-
}
|
|
1571
|
-
function _superPropBase(object, property) {
|
|
1572
|
-
while (!Object.prototype.hasOwnProperty.call(object, property)) {
|
|
1573
|
-
object = _getPrototypeOf(object);
|
|
1574
|
-
if (object === null)
|
|
1575
|
-
break;
|
|
1576
|
-
}
|
|
1577
|
-
return object;
|
|
1578
|
-
}
|
|
1579
|
-
function _get() {
|
|
1580
|
-
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
1581
|
-
_get = Reflect.get.bind();
|
|
1582
|
-
} else {
|
|
1583
|
-
_get = function _get2(target, property, receiver) {
|
|
1584
|
-
var base = _superPropBase(target, property);
|
|
1585
|
-
if (!base)
|
|
1586
|
-
return;
|
|
1587
|
-
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
1588
|
-
if (desc.get) {
|
|
1589
|
-
return desc.get.call(arguments.length < 3 ? target : receiver);
|
|
1590
|
-
}
|
|
1591
|
-
return desc.value;
|
|
1592
|
-
};
|
|
1593
|
-
}
|
|
1594
|
-
return _get.apply(this, arguments);
|
|
1595
|
-
}
|
|
1596
|
-
var Emitter = /* @__PURE__ */ function() {
|
|
1597
|
-
function Emitter2() {
|
|
1598
|
-
_classCallCheck(this, Emitter2);
|
|
1599
|
-
Object.defineProperty(this, "listeners", {
|
|
1600
|
-
value: {},
|
|
1601
|
-
writable: true,
|
|
1602
|
-
configurable: true
|
|
1603
|
-
});
|
|
1604
|
-
}
|
|
1605
|
-
_createClass(Emitter2, [{
|
|
1606
|
-
key: "addEventListener",
|
|
1607
|
-
value: function addEventListener(type, callback, options) {
|
|
1608
|
-
if (!(type in this.listeners)) {
|
|
1609
|
-
this.listeners[type] = [];
|
|
1610
|
-
}
|
|
1611
|
-
this.listeners[type].push({
|
|
1612
|
-
callback,
|
|
1613
|
-
options
|
|
1614
|
-
});
|
|
1615
|
-
}
|
|
1616
|
-
}, {
|
|
1617
|
-
key: "removeEventListener",
|
|
1618
|
-
value: function removeEventListener(type, callback) {
|
|
1619
|
-
if (!(type in this.listeners)) {
|
|
1620
|
-
return;
|
|
1621
|
-
}
|
|
1622
|
-
var stack = this.listeners[type];
|
|
1623
|
-
for (var i = 0, l = stack.length; i < l; i++) {
|
|
1624
|
-
if (stack[i].callback === callback) {
|
|
1625
|
-
stack.splice(i, 1);
|
|
1626
|
-
return;
|
|
1627
|
-
}
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
}, {
|
|
1631
|
-
key: "dispatchEvent",
|
|
1632
|
-
value: function dispatchEvent(event) {
|
|
1633
|
-
if (!(event.type in this.listeners)) {
|
|
1634
|
-
return;
|
|
1635
|
-
}
|
|
1636
|
-
var stack = this.listeners[event.type];
|
|
1637
|
-
var stackToCall = stack.slice();
|
|
1638
|
-
for (var i = 0, l = stackToCall.length; i < l; i++) {
|
|
1639
|
-
var listener = stackToCall[i];
|
|
1640
|
-
try {
|
|
1641
|
-
listener.callback.call(this, event);
|
|
1642
|
-
} catch (e) {
|
|
1643
|
-
Promise.resolve().then(function() {
|
|
1644
|
-
throw e;
|
|
1645
|
-
});
|
|
1646
|
-
}
|
|
1647
|
-
if (listener.options && listener.options.once) {
|
|
1648
|
-
this.removeEventListener(event.type, listener.callback);
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
return !event.defaultPrevented;
|
|
1652
|
-
}
|
|
1653
|
-
}]);
|
|
1654
|
-
return Emitter2;
|
|
1655
|
-
}();
|
|
1656
|
-
var AbortSignal = /* @__PURE__ */ function(_Emitter) {
|
|
1657
|
-
_inherits(AbortSignal2, _Emitter);
|
|
1658
|
-
var _super = _createSuper(AbortSignal2);
|
|
1659
|
-
function AbortSignal2() {
|
|
1660
|
-
var _this;
|
|
1661
|
-
_classCallCheck(this, AbortSignal2);
|
|
1662
|
-
_this = _super.call(this);
|
|
1663
|
-
if (!_this.listeners) {
|
|
1664
|
-
Emitter.call(_assertThisInitialized(_this));
|
|
1665
|
-
}
|
|
1666
|
-
Object.defineProperty(_assertThisInitialized(_this), "aborted", {
|
|
1667
|
-
value: false,
|
|
1668
|
-
writable: true,
|
|
1669
|
-
configurable: true
|
|
1670
|
-
});
|
|
1671
|
-
Object.defineProperty(_assertThisInitialized(_this), "onabort", {
|
|
1672
|
-
value: null,
|
|
1673
|
-
writable: true,
|
|
1674
|
-
configurable: true
|
|
1675
|
-
});
|
|
1676
|
-
Object.defineProperty(_assertThisInitialized(_this), "reason", {
|
|
1677
|
-
value: void 0,
|
|
1678
|
-
writable: true,
|
|
1679
|
-
configurable: true
|
|
1680
|
-
});
|
|
1681
|
-
return _this;
|
|
1682
|
-
}
|
|
1683
|
-
_createClass(AbortSignal2, [{
|
|
1684
|
-
key: "toString",
|
|
1685
|
-
value: function toString() {
|
|
1686
|
-
return "[object AbortSignal]";
|
|
1687
|
-
}
|
|
1688
|
-
}, {
|
|
1689
|
-
key: "dispatchEvent",
|
|
1690
|
-
value: function dispatchEvent(event) {
|
|
1691
|
-
if (event.type === "abort") {
|
|
1692
|
-
this.aborted = true;
|
|
1693
|
-
if (typeof this.onabort === "function") {
|
|
1694
|
-
this.onabort.call(this, event);
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
_get(_getPrototypeOf(AbortSignal2.prototype), "dispatchEvent", this).call(this, event);
|
|
1698
|
-
}
|
|
1699
|
-
}]);
|
|
1700
|
-
return AbortSignal2;
|
|
1701
|
-
}(Emitter);
|
|
1702
|
-
var AbortController2 = /* @__PURE__ */ function() {
|
|
1703
|
-
function AbortController3() {
|
|
1704
|
-
_classCallCheck(this, AbortController3);
|
|
1705
|
-
Object.defineProperty(this, "signal", {
|
|
1706
|
-
value: new AbortSignal(),
|
|
1707
|
-
writable: true,
|
|
1708
|
-
configurable: true
|
|
1709
|
-
});
|
|
1710
|
-
}
|
|
1711
|
-
_createClass(AbortController3, [{
|
|
1712
|
-
key: "abort",
|
|
1713
|
-
value: function abort(reason) {
|
|
1714
|
-
var event;
|
|
1715
|
-
try {
|
|
1716
|
-
event = new Event("abort");
|
|
1717
|
-
} catch (e) {
|
|
1718
|
-
if (typeof document !== "undefined") {
|
|
1719
|
-
if (!document.createEvent) {
|
|
1720
|
-
event = document.createEventObject();
|
|
1721
|
-
event.type = "abort";
|
|
1722
|
-
} else {
|
|
1723
|
-
event = document.createEvent("Event");
|
|
1724
|
-
event.initEvent("abort", false, false);
|
|
1725
|
-
}
|
|
1726
|
-
} else {
|
|
1727
|
-
event = {
|
|
1728
|
-
type: "abort",
|
|
1729
|
-
bubbles: false,
|
|
1730
|
-
cancelable: false
|
|
1731
|
-
};
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
var signalReason = reason;
|
|
1735
|
-
if (signalReason === void 0) {
|
|
1736
|
-
if (typeof document === "undefined") {
|
|
1737
|
-
signalReason = new Error("This operation was aborted");
|
|
1738
|
-
signalReason.name = "AbortError";
|
|
1739
|
-
} else {
|
|
1740
|
-
try {
|
|
1741
|
-
signalReason = new DOMException("signal is aborted without reason");
|
|
1742
|
-
} catch (err) {
|
|
1743
|
-
signalReason = new Error("This operation was aborted");
|
|
1744
|
-
signalReason.name = "AbortError";
|
|
1745
|
-
}
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
this.signal.reason = signalReason;
|
|
1749
|
-
this.signal.dispatchEvent(event);
|
|
1750
|
-
}
|
|
1751
|
-
}, {
|
|
1752
|
-
key: "toString",
|
|
1753
|
-
value: function toString() {
|
|
1754
|
-
return "[object AbortController]";
|
|
1755
|
-
}
|
|
1756
|
-
}]);
|
|
1757
|
-
return AbortController3;
|
|
1758
|
-
}();
|
|
1759
|
-
if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
|
|
1760
|
-
AbortController2.prototype[Symbol.toStringTag] = "AbortController";
|
|
1761
|
-
AbortSignal.prototype[Symbol.toStringTag] = "AbortSignal";
|
|
1762
|
-
}
|
|
1763
|
-
function polyfillNeeded(self2) {
|
|
1764
|
-
if (self2.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {
|
|
1765
|
-
console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill");
|
|
1766
|
-
return true;
|
|
1767
|
-
}
|
|
1768
|
-
return typeof self2.Request === "function" && !self2.Request.prototype.hasOwnProperty("signal") || !self2.AbortController;
|
|
1769
|
-
}
|
|
1770
|
-
function abortableFetchDecorator(patchTargets) {
|
|
1771
|
-
if ("function" === typeof patchTargets) {
|
|
1772
|
-
patchTargets = {
|
|
1773
|
-
fetch: patchTargets
|
|
1774
|
-
};
|
|
1775
|
-
}
|
|
1776
|
-
var _patchTargets = patchTargets, fetch2 = _patchTargets.fetch, _patchTargets$Request = _patchTargets.Request, NativeRequest = _patchTargets$Request === void 0 ? fetch2.Request : _patchTargets$Request, NativeAbortController = _patchTargets.AbortController, _patchTargets$__FORCE = _patchTargets.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL, __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL = _patchTargets$__FORCE === void 0 ? false : _patchTargets$__FORCE;
|
|
1777
|
-
if (!polyfillNeeded({
|
|
1778
|
-
fetch: fetch2,
|
|
1779
|
-
Request: NativeRequest,
|
|
1780
|
-
AbortController: NativeAbortController,
|
|
1781
|
-
__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL
|
|
1782
|
-
})) {
|
|
1783
|
-
return {
|
|
1784
|
-
fetch: fetch2,
|
|
1785
|
-
Request
|
|
1786
|
-
};
|
|
1787
|
-
}
|
|
1788
|
-
var Request = NativeRequest;
|
|
1789
|
-
if (Request && !Request.prototype.hasOwnProperty("signal") || __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {
|
|
1790
|
-
Request = function Request2(input, init2) {
|
|
1791
|
-
var signal;
|
|
1792
|
-
if (init2 && init2.signal) {
|
|
1793
|
-
signal = init2.signal;
|
|
1794
|
-
delete init2.signal;
|
|
1795
|
-
}
|
|
1796
|
-
var request = new NativeRequest(input, init2);
|
|
1797
|
-
if (signal) {
|
|
1798
|
-
Object.defineProperty(request, "signal", {
|
|
1799
|
-
writable: false,
|
|
1800
|
-
enumerable: false,
|
|
1801
|
-
configurable: true,
|
|
1802
|
-
value: signal
|
|
1803
|
-
});
|
|
1804
|
-
}
|
|
1805
|
-
return request;
|
|
1806
|
-
};
|
|
1807
|
-
Request.prototype = NativeRequest.prototype;
|
|
1808
|
-
}
|
|
1809
|
-
var realFetch = fetch2;
|
|
1810
|
-
var abortableFetch = function abortableFetch2(input, init2) {
|
|
1811
|
-
var signal = Request && Request.prototype.isPrototypeOf(input) ? input.signal : init2 ? init2.signal : void 0;
|
|
1812
|
-
if (signal) {
|
|
1813
|
-
var abortError;
|
|
1814
|
-
try {
|
|
1815
|
-
abortError = new DOMException("Aborted", "AbortError");
|
|
1816
|
-
} catch (err) {
|
|
1817
|
-
abortError = new Error("Aborted");
|
|
1818
|
-
abortError.name = "AbortError";
|
|
1819
|
-
}
|
|
1820
|
-
if (signal.aborted) {
|
|
1821
|
-
return Promise.reject(abortError);
|
|
1822
|
-
}
|
|
1823
|
-
var cancellation = new Promise(function(_, reject) {
|
|
1824
|
-
signal.addEventListener("abort", function() {
|
|
1825
|
-
return reject(abortError);
|
|
1826
|
-
}, {
|
|
1827
|
-
once: true
|
|
1828
|
-
});
|
|
1829
|
-
});
|
|
1830
|
-
if (init2 && init2.signal) {
|
|
1831
|
-
delete init2.signal;
|
|
1832
|
-
}
|
|
1833
|
-
return Promise.race([cancellation, realFetch(input, init2)]);
|
|
1834
|
-
}
|
|
1835
|
-
return realFetch(input, init2);
|
|
1836
|
-
};
|
|
1837
|
-
return {
|
|
1838
|
-
fetch: abortableFetch,
|
|
1839
|
-
Request
|
|
1840
|
-
};
|
|
1841
|
-
}
|
|
1842
|
-
(function(self2) {
|
|
1843
|
-
if (!polyfillNeeded(self2)) {
|
|
1844
|
-
return;
|
|
1845
|
-
}
|
|
1846
|
-
if (!self2.fetch) {
|
|
1847
|
-
console.warn("fetch() is not available, cannot install abortcontroller-polyfill");
|
|
1848
|
-
return;
|
|
1849
|
-
}
|
|
1850
|
-
var _abortableFetch = abortableFetchDecorator(self2), fetch2 = _abortableFetch.fetch, Request = _abortableFetch.Request;
|
|
1851
|
-
self2.fetch = fetch2;
|
|
1852
|
-
self2.Request = Request;
|
|
1853
|
-
Object.defineProperty(self2, "AbortController", {
|
|
1854
|
-
writable: true,
|
|
1855
|
-
enumerable: false,
|
|
1856
|
-
configurable: true,
|
|
1857
|
-
value: AbortController2
|
|
1858
|
-
});
|
|
1859
|
-
Object.defineProperty(self2, "AbortSignal", {
|
|
1860
|
-
writable: true,
|
|
1861
|
-
enumerable: false,
|
|
1862
|
-
configurable: true,
|
|
1863
|
-
value: AbortSignal
|
|
1864
|
-
});
|
|
1865
|
-
})(typeof self !== "undefined" ? self : commonjsGlobal);
|
|
1866
|
-
});
|
|
1867
1477
|
const Fetch$1 = (opts, input, init2) => __async(void 0, null, function* () {
|
|
1868
1478
|
const apiToken = opts.getApiToken && opts.getApiToken();
|
|
1869
1479
|
const headers = new Headers(__spreadValues({
|
|
1870
1480
|
Authorization: apiToken ? `Bearer ${apiToken}` : ""
|
|
1871
1481
|
}, init2 == null ? void 0 : init2.headers));
|
|
1872
|
-
if (!headers.get("Authorization"))
|
|
1873
|
-
headers.delete("Authorization");
|
|
1482
|
+
if (!headers.get("Authorization")) headers.delete("Authorization");
|
|
1874
1483
|
const resp = yield fetch(input, __spreadProps(__spreadValues({}, init2), {
|
|
1875
1484
|
headers
|
|
1876
1485
|
}));
|
|
@@ -1885,8 +1494,7 @@ const Fetch$1 = (opts, input, init2) => __async(void 0, null, function* () {
|
|
|
1885
1494
|
retry = true;
|
|
1886
1495
|
}
|
|
1887
1496
|
}), Promise.resolve()));
|
|
1888
|
-
if (retry)
|
|
1889
|
-
return Fetch$1(opts, input, init2);
|
|
1497
|
+
if (retry) return Fetch$1(opts, input, init2);
|
|
1890
1498
|
throw createError(resp.status, json);
|
|
1891
1499
|
}
|
|
1892
1500
|
return resp;
|
|
@@ -1913,6 +1521,10 @@ function createApiHandlers() {
|
|
|
1913
1521
|
add: (action, handler) => {
|
|
1914
1522
|
handlers.push({ action, handler });
|
|
1915
1523
|
},
|
|
1524
|
+
remove: (action) => {
|
|
1525
|
+
const index = handlers.findIndex((h) => h.action === action);
|
|
1526
|
+
if (index !== -1) handlers.splice(index, 1);
|
|
1527
|
+
},
|
|
1916
1528
|
get: () => handlers
|
|
1917
1529
|
};
|
|
1918
1530
|
}
|
|
@@ -1932,8 +1544,7 @@ class Api2 extends Api$1 {
|
|
|
1932
1544
|
*/
|
|
1933
1545
|
getUserFields() {
|
|
1934
1546
|
const user = this._opts.userInfo;
|
|
1935
|
-
if (!(user == null ? void 0 : user.name) || !(user == null ? void 0 : user.email))
|
|
1936
|
-
return void 0;
|
|
1547
|
+
if (!(user == null ? void 0 : user.name) || !(user == null ? void 0 : user.email)) return void 0;
|
|
1937
1548
|
return { name: user.name, email: user.email };
|
|
1938
1549
|
}
|
|
1939
1550
|
}
|
|
@@ -1979,18 +1590,6 @@ function escape$1(html2, encode) {
|
|
|
1979
1590
|
}
|
|
1980
1591
|
return html2;
|
|
1981
1592
|
}
|
|
1982
|
-
const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
1983
|
-
function unescape(html2) {
|
|
1984
|
-
return html2.replace(unescapeTest, (_, n) => {
|
|
1985
|
-
n = n.toLowerCase();
|
|
1986
|
-
if (n === "colon")
|
|
1987
|
-
return ":";
|
|
1988
|
-
if (n.charAt(0) === "#") {
|
|
1989
|
-
return n.charAt(1) === "x" ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
|
|
1990
|
-
}
|
|
1991
|
-
return "";
|
|
1992
|
-
});
|
|
1993
|
-
}
|
|
1994
1593
|
const caret = /(^|[^\[])\^/g;
|
|
1995
1594
|
function edit(regex, opt) {
|
|
1996
1595
|
let source = typeof regex === "string" ? regex : regex.source;
|
|
@@ -2150,7 +1749,7 @@ class _Tokenizer {
|
|
|
2150
1749
|
code(src) {
|
|
2151
1750
|
const cap = this.rules.block.code.exec(src);
|
|
2152
1751
|
if (cap) {
|
|
2153
|
-
const text = cap[0].replace(/^ {1,4}/gm, "");
|
|
1752
|
+
const text = cap[0].replace(/^(?: {1,4}| {0,3}\t)/gm, "");
|
|
2154
1753
|
return {
|
|
2155
1754
|
type: "code",
|
|
2156
1755
|
raw: cap[0],
|
|
@@ -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 && /^[ \t]*$/.test(nextLine)) {
|
|
2267
1916
|
raw += nextLine + "\n";
|
|
2268
1917
|
src = src.substring(nextLine.length + 1);
|
|
2269
1918
|
endEarly = true;
|
|
@@ -2273,11 +1922,16 @@ class _Tokenizer {
|
|
|
2273
1922
|
const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
|
|
2274
1923
|
const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
|
|
2275
1924
|
const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
|
|
1925
|
+
const htmlBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}<[a-z].*>`, "i");
|
|
2276
1926
|
while (src) {
|
|
2277
1927
|
const rawLine = src.split("\n", 1)[0];
|
|
1928
|
+
let nextLineWithoutTabs;
|
|
2278
1929
|
nextLine = rawLine;
|
|
2279
1930
|
if (this.options.pedantic) {
|
|
2280
1931
|
nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ");
|
|
1932
|
+
nextLineWithoutTabs = nextLine;
|
|
1933
|
+
} else {
|
|
1934
|
+
nextLineWithoutTabs = nextLine.replace(/\t/g, " ");
|
|
2281
1935
|
}
|
|
2282
1936
|
if (fencesBeginRegex.test(nextLine)) {
|
|
2283
1937
|
break;
|
|
@@ -2285,19 +1939,22 @@ class _Tokenizer {
|
|
|
2285
1939
|
if (headingBeginRegex.test(nextLine)) {
|
|
2286
1940
|
break;
|
|
2287
1941
|
}
|
|
1942
|
+
if (htmlBeginRegex.test(nextLine)) {
|
|
1943
|
+
break;
|
|
1944
|
+
}
|
|
2288
1945
|
if (nextBulletRegex.test(nextLine)) {
|
|
2289
1946
|
break;
|
|
2290
1947
|
}
|
|
2291
|
-
if (hrRegex.test(
|
|
1948
|
+
if (hrRegex.test(nextLine)) {
|
|
2292
1949
|
break;
|
|
2293
1950
|
}
|
|
2294
|
-
if (
|
|
2295
|
-
itemContents += "\n" +
|
|
1951
|
+
if (nextLineWithoutTabs.search(/[^ ]/) >= indent || !nextLine.trim()) {
|
|
1952
|
+
itemContents += "\n" + nextLineWithoutTabs.slice(indent);
|
|
2296
1953
|
} else {
|
|
2297
1954
|
if (blankLine) {
|
|
2298
1955
|
break;
|
|
2299
1956
|
}
|
|
2300
|
-
if (line.search(/[^ ]/) >= 4) {
|
|
1957
|
+
if (line.replace(/\t/g, " ").search(/[^ ]/) >= 4) {
|
|
2301
1958
|
break;
|
|
2302
1959
|
}
|
|
2303
1960
|
if (fencesBeginRegex.test(line)) {
|
|
@@ -2316,13 +1973,13 @@ class _Tokenizer {
|
|
|
2316
1973
|
}
|
|
2317
1974
|
raw += rawLine + "\n";
|
|
2318
1975
|
src = src.substring(rawLine.length + 1);
|
|
2319
|
-
line =
|
|
1976
|
+
line = nextLineWithoutTabs.slice(indent);
|
|
2320
1977
|
}
|
|
2321
1978
|
}
|
|
2322
1979
|
if (!list2.loose) {
|
|
2323
1980
|
if (endsWithBlankLine) {
|
|
2324
1981
|
list2.loose = true;
|
|
2325
|
-
} else if (/\n *\n *$/.test(raw)) {
|
|
1982
|
+
} else if (/\n[ \t]*\n[ \t]*$/.test(raw)) {
|
|
2326
1983
|
endsWithBlankLine = true;
|
|
2327
1984
|
}
|
|
2328
1985
|
}
|
|
@@ -2346,8 +2003,8 @@ class _Tokenizer {
|
|
|
2346
2003
|
});
|
|
2347
2004
|
list2.raw += raw;
|
|
2348
2005
|
}
|
|
2349
|
-
list2.items[list2.items.length - 1].raw = raw.trimEnd();
|
|
2350
|
-
list2.items[list2.items.length - 1].text =
|
|
2006
|
+
list2.items[list2.items.length - 1].raw = list2.items[list2.items.length - 1].raw.trimEnd();
|
|
2007
|
+
list2.items[list2.items.length - 1].text = list2.items[list2.items.length - 1].text.trimEnd();
|
|
2351
2008
|
list2.raw = list2.raw.trimEnd();
|
|
2352
2009
|
for (let i = 0; i < list2.items.length; i++) {
|
|
2353
2010
|
this.lexer.state.top = false;
|
|
@@ -2426,17 +2083,21 @@ class _Tokenizer {
|
|
|
2426
2083
|
item.align.push(null);
|
|
2427
2084
|
}
|
|
2428
2085
|
}
|
|
2429
|
-
for (
|
|
2086
|
+
for (let i = 0; i < headers.length; i++) {
|
|
2430
2087
|
item.header.push({
|
|
2431
|
-
text:
|
|
2432
|
-
tokens: this.lexer.inline(
|
|
2088
|
+
text: headers[i],
|
|
2089
|
+
tokens: this.lexer.inline(headers[i]),
|
|
2090
|
+
header: true,
|
|
2091
|
+
align: item.align[i]
|
|
2433
2092
|
});
|
|
2434
2093
|
}
|
|
2435
2094
|
for (const row of rows) {
|
|
2436
|
-
item.rows.push(splitCells(row, item.header.length).map((cell) => {
|
|
2095
|
+
item.rows.push(splitCells(row, item.header.length).map((cell, i) => {
|
|
2437
2096
|
return {
|
|
2438
2097
|
text: cell,
|
|
2439
|
-
tokens: this.lexer.inline(cell)
|
|
2098
|
+
tokens: this.lexer.inline(cell),
|
|
2099
|
+
header: false,
|
|
2100
|
+
align: item.align[i]
|
|
2440
2101
|
};
|
|
2441
2102
|
}));
|
|
2442
2103
|
}
|
|
@@ -2741,21 +2402,21 @@ class _Tokenizer {
|
|
|
2741
2402
|
}
|
|
2742
2403
|
}
|
|
2743
2404
|
}
|
|
2744
|
-
const newline = /^(?: *(?:\n|$))+/;
|
|
2745
|
-
const blockCode = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/;
|
|
2405
|
+
const newline = /^(?:[ \t]*(?:\n|$))+/;
|
|
2406
|
+
const blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
2746
2407
|
const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
|
|
2747
2408
|
const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
2748
2409
|
const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
2749
2410
|
const bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
2750
|
-
const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet).replace(/blockCode/g, / {4}/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).getRegex();
|
|
2411
|
+
const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).getRegex();
|
|
2751
2412
|
const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
|
|
2752
2413
|
const blockText = /^[^\n]+/;
|
|
2753
2414
|
const _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
|
|
2754
|
-
const def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
|
|
2415
|
+
const def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
|
|
2755
2416
|
const list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
|
|
2756
2417
|
const _tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
|
|
2757
2418
|
const _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
2758
|
-
const html = edit("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n
|
|
2419
|
+
const html = edit("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
2759
2420
|
const paragraph = edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
|
|
2760
2421
|
const blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
|
|
2761
2422
|
const blockNormal = {
|
|
@@ -2773,7 +2434,7 @@ const blockNormal = {
|
|
|
2773
2434
|
table: noopTest,
|
|
2774
2435
|
text: blockText
|
|
2775
2436
|
};
|
|
2776
|
-
const gfmTable = edit("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
|
|
2437
|
+
const gfmTable = edit("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
|
|
2777
2438
|
const blockGfm = __spreadProps(__spreadValues({}, blockNormal), {
|
|
2778
2439
|
table: gfmTable,
|
|
2779
2440
|
paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", gfmTable).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex()
|
|
@@ -2927,18 +2588,13 @@ class _Lexer {
|
|
|
2927
2588
|
this.inlineQueue = [];
|
|
2928
2589
|
return this.tokens;
|
|
2929
2590
|
}
|
|
2930
|
-
blockTokens(src, tokens = []) {
|
|
2591
|
+
blockTokens(src, tokens = [], lastParagraphClipped = false) {
|
|
2931
2592
|
if (this.options.pedantic) {
|
|
2932
2593
|
src = src.replace(/\t/g, " ").replace(/^ +$/gm, "");
|
|
2933
|
-
} else {
|
|
2934
|
-
src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
|
|
2935
|
-
return leading + " ".repeat(tabs.length);
|
|
2936
|
-
});
|
|
2937
2594
|
}
|
|
2938
2595
|
let token;
|
|
2939
2596
|
let lastToken;
|
|
2940
2597
|
let cutSrc;
|
|
2941
|
-
let lastParagraphClipped;
|
|
2942
2598
|
while (src) {
|
|
2943
2599
|
if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((extTokenizer) => {
|
|
2944
2600
|
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
|
|
@@ -3043,7 +2699,7 @@ class _Lexer {
|
|
|
3043
2699
|
}
|
|
3044
2700
|
if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
|
|
3045
2701
|
lastToken = tokens[tokens.length - 1];
|
|
3046
|
-
if (lastParagraphClipped && lastToken.type === "paragraph") {
|
|
2702
|
+
if (lastParagraphClipped && (lastToken == null ? void 0 : lastToken.type) === "paragraph") {
|
|
3047
2703
|
lastToken.raw += "\n" + token.raw;
|
|
3048
2704
|
lastToken.text += "\n" + token.text;
|
|
3049
2705
|
this.inlineQueue.pop();
|
|
@@ -3230,85 +2886,136 @@ class _Lexer {
|
|
|
3230
2886
|
}
|
|
3231
2887
|
}
|
|
3232
2888
|
class _Renderer {
|
|
2889
|
+
// set by the parser
|
|
3233
2890
|
constructor(options) {
|
|
3234
2891
|
__publicField(this, "options");
|
|
2892
|
+
__publicField(this, "parser");
|
|
3235
2893
|
this.options = options || _defaults;
|
|
3236
2894
|
}
|
|
3237
|
-
|
|
2895
|
+
space(token) {
|
|
2896
|
+
return "";
|
|
2897
|
+
}
|
|
2898
|
+
code({ text, lang, escaped }) {
|
|
3238
2899
|
var _a;
|
|
3239
|
-
const
|
|
3240
|
-
code =
|
|
3241
|
-
if (!
|
|
2900
|
+
const langString = (_a = (lang || "").match(/^\S*/)) == null ? void 0 : _a[0];
|
|
2901
|
+
const code = text.replace(/\n$/, "") + "\n";
|
|
2902
|
+
if (!langString) {
|
|
3242
2903
|
return "<pre><code>" + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
|
|
3243
2904
|
}
|
|
3244
|
-
return '<pre><code class="language-' + escape$1(
|
|
2905
|
+
return '<pre><code class="language-' + escape$1(langString) + '">' + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
|
|
3245
2906
|
}
|
|
3246
|
-
blockquote(
|
|
2907
|
+
blockquote({ tokens }) {
|
|
2908
|
+
const body = this.parser.parse(tokens);
|
|
3247
2909
|
return `<blockquote>
|
|
3248
|
-
${
|
|
2910
|
+
${body}</blockquote>
|
|
3249
2911
|
`;
|
|
3250
2912
|
}
|
|
3251
|
-
html(
|
|
3252
|
-
return
|
|
2913
|
+
html({ text }) {
|
|
2914
|
+
return text;
|
|
3253
2915
|
}
|
|
3254
|
-
heading(
|
|
3255
|
-
return `<h${
|
|
2916
|
+
heading({ tokens, depth }) {
|
|
2917
|
+
return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>
|
|
3256
2918
|
`;
|
|
3257
2919
|
}
|
|
3258
|
-
hr() {
|
|
2920
|
+
hr(token) {
|
|
3259
2921
|
return "<hr>\n";
|
|
3260
2922
|
}
|
|
3261
|
-
list(
|
|
2923
|
+
list(token) {
|
|
2924
|
+
const ordered = token.ordered;
|
|
2925
|
+
const start = token.start;
|
|
2926
|
+
let body = "";
|
|
2927
|
+
for (let j = 0; j < token.items.length; j++) {
|
|
2928
|
+
const item = token.items[j];
|
|
2929
|
+
body += this.listitem(item);
|
|
2930
|
+
}
|
|
3262
2931
|
const type = ordered ? "ol" : "ul";
|
|
3263
|
-
const
|
|
3264
|
-
return "<" + type +
|
|
3265
|
-
}
|
|
3266
|
-
listitem(
|
|
3267
|
-
|
|
2932
|
+
const startAttr = ordered && start !== 1 ? ' start="' + start + '"' : "";
|
|
2933
|
+
return "<" + type + startAttr + ">\n" + body + "</" + type + ">\n";
|
|
2934
|
+
}
|
|
2935
|
+
listitem(item) {
|
|
2936
|
+
let itemBody = "";
|
|
2937
|
+
if (item.task) {
|
|
2938
|
+
const checkbox = this.checkbox({ checked: !!item.checked });
|
|
2939
|
+
if (item.loose) {
|
|
2940
|
+
if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
|
|
2941
|
+
item.tokens[0].text = checkbox + " " + item.tokens[0].text;
|
|
2942
|
+
if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
|
|
2943
|
+
item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
|
|
2944
|
+
}
|
|
2945
|
+
} else {
|
|
2946
|
+
item.tokens.unshift({
|
|
2947
|
+
type: "text",
|
|
2948
|
+
raw: checkbox + " ",
|
|
2949
|
+
text: checkbox + " "
|
|
2950
|
+
});
|
|
2951
|
+
}
|
|
2952
|
+
} else {
|
|
2953
|
+
itemBody += checkbox + " ";
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
itemBody += this.parser.parse(item.tokens, !!item.loose);
|
|
2957
|
+
return `<li>${itemBody}</li>
|
|
3268
2958
|
`;
|
|
3269
2959
|
}
|
|
3270
|
-
checkbox(checked) {
|
|
2960
|
+
checkbox({ checked }) {
|
|
3271
2961
|
return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
|
|
3272
2962
|
}
|
|
3273
|
-
paragraph(
|
|
3274
|
-
return `<p>${
|
|
2963
|
+
paragraph({ tokens }) {
|
|
2964
|
+
return `<p>${this.parser.parseInline(tokens)}</p>
|
|
3275
2965
|
`;
|
|
3276
2966
|
}
|
|
3277
|
-
table(
|
|
2967
|
+
table(token) {
|
|
2968
|
+
let header = "";
|
|
2969
|
+
let cell = "";
|
|
2970
|
+
for (let j = 0; j < token.header.length; j++) {
|
|
2971
|
+
cell += this.tablecell(token.header[j]);
|
|
2972
|
+
}
|
|
2973
|
+
header += this.tablerow({ text: cell });
|
|
2974
|
+
let body = "";
|
|
2975
|
+
for (let j = 0; j < token.rows.length; j++) {
|
|
2976
|
+
const row = token.rows[j];
|
|
2977
|
+
cell = "";
|
|
2978
|
+
for (let k = 0; k < row.length; k++) {
|
|
2979
|
+
cell += this.tablecell(row[k]);
|
|
2980
|
+
}
|
|
2981
|
+
body += this.tablerow({ text: cell });
|
|
2982
|
+
}
|
|
3278
2983
|
if (body)
|
|
3279
2984
|
body = `<tbody>${body}</tbody>`;
|
|
3280
2985
|
return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
|
|
3281
2986
|
}
|
|
3282
|
-
tablerow(
|
|
2987
|
+
tablerow({ text }) {
|
|
3283
2988
|
return `<tr>
|
|
3284
|
-
${
|
|
2989
|
+
${text}</tr>
|
|
3285
2990
|
`;
|
|
3286
2991
|
}
|
|
3287
|
-
tablecell(
|
|
3288
|
-
const
|
|
3289
|
-
const
|
|
2992
|
+
tablecell(token) {
|
|
2993
|
+
const content = this.parser.parseInline(token.tokens);
|
|
2994
|
+
const type = token.header ? "th" : "td";
|
|
2995
|
+
const tag2 = token.align ? `<${type} align="${token.align}">` : `<${type}>`;
|
|
3290
2996
|
return tag2 + content + `</${type}>
|
|
3291
2997
|
`;
|
|
3292
2998
|
}
|
|
3293
2999
|
/**
|
|
3294
3000
|
* span level renderer
|
|
3295
3001
|
*/
|
|
3296
|
-
strong(
|
|
3297
|
-
return `<strong>${
|
|
3002
|
+
strong({ tokens }) {
|
|
3003
|
+
return `<strong>${this.parser.parseInline(tokens)}</strong>`;
|
|
3298
3004
|
}
|
|
3299
|
-
em(
|
|
3300
|
-
return `<em>${
|
|
3005
|
+
em({ tokens }) {
|
|
3006
|
+
return `<em>${this.parser.parseInline(tokens)}</em>`;
|
|
3301
3007
|
}
|
|
3302
|
-
codespan(text) {
|
|
3008
|
+
codespan({ text }) {
|
|
3303
3009
|
return `<code>${text}</code>`;
|
|
3304
3010
|
}
|
|
3305
|
-
br() {
|
|
3011
|
+
br(token) {
|
|
3306
3012
|
return "<br>";
|
|
3307
3013
|
}
|
|
3308
|
-
del(
|
|
3309
|
-
return `<del>${
|
|
3014
|
+
del({ tokens }) {
|
|
3015
|
+
return `<del>${this.parser.parseInline(tokens)}</del>`;
|
|
3310
3016
|
}
|
|
3311
|
-
link(href, title,
|
|
3017
|
+
link({ href, title, tokens }) {
|
|
3018
|
+
const text = this.parser.parseInline(tokens);
|
|
3312
3019
|
const cleanHref = cleanUrl(href);
|
|
3313
3020
|
if (cleanHref === null) {
|
|
3314
3021
|
return text;
|
|
@@ -3321,7 +3028,7 @@ ${content}</tr>
|
|
|
3321
3028
|
out += ">" + text + "</a>";
|
|
3322
3029
|
return out;
|
|
3323
3030
|
}
|
|
3324
|
-
image(href, title, text) {
|
|
3031
|
+
image({ href, title, text }) {
|
|
3325
3032
|
const cleanHref = cleanUrl(href);
|
|
3326
3033
|
if (cleanHref === null) {
|
|
3327
3034
|
return text;
|
|
@@ -3334,34 +3041,34 @@ ${content}</tr>
|
|
|
3334
3041
|
out += ">";
|
|
3335
3042
|
return out;
|
|
3336
3043
|
}
|
|
3337
|
-
text(
|
|
3338
|
-
return text;
|
|
3044
|
+
text(token) {
|
|
3045
|
+
return "tokens" in token && token.tokens ? this.parser.parseInline(token.tokens) : token.text;
|
|
3339
3046
|
}
|
|
3340
3047
|
}
|
|
3341
3048
|
class _TextRenderer {
|
|
3342
3049
|
// no need for block level renderers
|
|
3343
|
-
strong(text) {
|
|
3050
|
+
strong({ text }) {
|
|
3344
3051
|
return text;
|
|
3345
3052
|
}
|
|
3346
|
-
em(text) {
|
|
3053
|
+
em({ text }) {
|
|
3347
3054
|
return text;
|
|
3348
3055
|
}
|
|
3349
|
-
codespan(text) {
|
|
3056
|
+
codespan({ text }) {
|
|
3350
3057
|
return text;
|
|
3351
3058
|
}
|
|
3352
|
-
del(text) {
|
|
3059
|
+
del({ text }) {
|
|
3353
3060
|
return text;
|
|
3354
3061
|
}
|
|
3355
|
-
html(text) {
|
|
3062
|
+
html({ text }) {
|
|
3356
3063
|
return text;
|
|
3357
3064
|
}
|
|
3358
|
-
text(text) {
|
|
3065
|
+
text({ text }) {
|
|
3359
3066
|
return text;
|
|
3360
3067
|
}
|
|
3361
|
-
link(
|
|
3068
|
+
link({ text }) {
|
|
3362
3069
|
return "" + text;
|
|
3363
3070
|
}
|
|
3364
|
-
image(
|
|
3071
|
+
image({ text }) {
|
|
3365
3072
|
return "" + text;
|
|
3366
3073
|
}
|
|
3367
3074
|
br() {
|
|
@@ -3377,6 +3084,7 @@ class _Parser {
|
|
|
3377
3084
|
this.options.renderer = this.options.renderer || new _Renderer();
|
|
3378
3085
|
this.renderer = this.options.renderer;
|
|
3379
3086
|
this.renderer.options = this.options;
|
|
3087
|
+
this.renderer.parser = this;
|
|
3380
3088
|
this.textRenderer = new _TextRenderer();
|
|
3381
3089
|
}
|
|
3382
3090
|
/**
|
|
@@ -3399,112 +3107,70 @@ class _Parser {
|
|
|
3399
3107
|
parse(tokens, top = true) {
|
|
3400
3108
|
let out = "";
|
|
3401
3109
|
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 =
|
|
3110
|
+
const anyToken = tokens[i];
|
|
3111
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[anyToken.type]) {
|
|
3112
|
+
const genericToken = anyToken;
|
|
3405
3113
|
const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
|
|
3406
3114
|
if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
|
|
3407
3115
|
out += ret || "";
|
|
3408
3116
|
continue;
|
|
3409
3117
|
}
|
|
3410
3118
|
}
|
|
3119
|
+
const token = anyToken;
|
|
3411
3120
|
switch (token.type) {
|
|
3412
3121
|
case "space": {
|
|
3122
|
+
out += this.renderer.space(token);
|
|
3413
3123
|
continue;
|
|
3414
3124
|
}
|
|
3415
3125
|
case "hr": {
|
|
3416
|
-
out += this.renderer.hr();
|
|
3126
|
+
out += this.renderer.hr(token);
|
|
3417
3127
|
continue;
|
|
3418
3128
|
}
|
|
3419
3129
|
case "heading": {
|
|
3420
|
-
|
|
3421
|
-
out += this.renderer.heading(this.parseInline(headingToken.tokens), headingToken.depth, unescape(this.parseInline(headingToken.tokens, this.textRenderer)));
|
|
3130
|
+
out += this.renderer.heading(token);
|
|
3422
3131
|
continue;
|
|
3423
3132
|
}
|
|
3424
3133
|
case "code": {
|
|
3425
|
-
|
|
3426
|
-
out += this.renderer.code(codeToken.text, codeToken.lang, !!codeToken.escaped);
|
|
3134
|
+
out += this.renderer.code(token);
|
|
3427
3135
|
continue;
|
|
3428
3136
|
}
|
|
3429
3137
|
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);
|
|
3138
|
+
out += this.renderer.table(token);
|
|
3447
3139
|
continue;
|
|
3448
3140
|
}
|
|
3449
3141
|
case "blockquote": {
|
|
3450
|
-
|
|
3451
|
-
const body = this.parse(blockquoteToken.tokens);
|
|
3452
|
-
out += this.renderer.blockquote(body);
|
|
3142
|
+
out += this.renderer.blockquote(token);
|
|
3453
3143
|
continue;
|
|
3454
3144
|
}
|
|
3455
3145
|
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);
|
|
3146
|
+
out += this.renderer.list(token);
|
|
3488
3147
|
continue;
|
|
3489
3148
|
}
|
|
3490
3149
|
case "html": {
|
|
3491
|
-
|
|
3492
|
-
out += this.renderer.html(htmlToken.text, htmlToken.block);
|
|
3150
|
+
out += this.renderer.html(token);
|
|
3493
3151
|
continue;
|
|
3494
3152
|
}
|
|
3495
3153
|
case "paragraph": {
|
|
3496
|
-
|
|
3497
|
-
out += this.renderer.paragraph(this.parseInline(paragraphToken.tokens));
|
|
3154
|
+
out += this.renderer.paragraph(token);
|
|
3498
3155
|
continue;
|
|
3499
3156
|
}
|
|
3500
3157
|
case "text": {
|
|
3501
3158
|
let textToken = token;
|
|
3502
|
-
let body =
|
|
3159
|
+
let body = this.renderer.text(textToken);
|
|
3503
3160
|
while (i + 1 < tokens.length && tokens[i + 1].type === "text") {
|
|
3504
3161
|
textToken = tokens[++i];
|
|
3505
|
-
body += "\n" +
|
|
3162
|
+
body += "\n" + this.renderer.text(textToken);
|
|
3163
|
+
}
|
|
3164
|
+
if (top) {
|
|
3165
|
+
out += this.renderer.paragraph({
|
|
3166
|
+
type: "paragraph",
|
|
3167
|
+
raw: body,
|
|
3168
|
+
text: body,
|
|
3169
|
+
tokens: [{ type: "text", raw: body, text: body }]
|
|
3170
|
+
});
|
|
3171
|
+
} else {
|
|
3172
|
+
out += body;
|
|
3506
3173
|
}
|
|
3507
|
-
out += top ? this.renderer.paragraph(body) : body;
|
|
3508
3174
|
continue;
|
|
3509
3175
|
}
|
|
3510
3176
|
default: {
|
|
@@ -3527,62 +3193,54 @@ class _Parser {
|
|
|
3527
3193
|
renderer = renderer || this.renderer;
|
|
3528
3194
|
let out = "";
|
|
3529
3195
|
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(
|
|
3196
|
+
const anyToken = tokens[i];
|
|
3197
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[anyToken.type]) {
|
|
3198
|
+
const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);
|
|
3199
|
+
if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(anyToken.type)) {
|
|
3534
3200
|
out += ret || "";
|
|
3535
3201
|
continue;
|
|
3536
3202
|
}
|
|
3537
3203
|
}
|
|
3204
|
+
const token = anyToken;
|
|
3538
3205
|
switch (token.type) {
|
|
3539
3206
|
case "escape": {
|
|
3540
|
-
|
|
3541
|
-
out += renderer.text(escapeToken.text);
|
|
3207
|
+
out += renderer.text(token);
|
|
3542
3208
|
break;
|
|
3543
3209
|
}
|
|
3544
3210
|
case "html": {
|
|
3545
|
-
|
|
3546
|
-
out += renderer.html(tagToken.text);
|
|
3211
|
+
out += renderer.html(token);
|
|
3547
3212
|
break;
|
|
3548
3213
|
}
|
|
3549
3214
|
case "link": {
|
|
3550
|
-
|
|
3551
|
-
out += renderer.link(linkToken.href, linkToken.title, this.parseInline(linkToken.tokens, renderer));
|
|
3215
|
+
out += renderer.link(token);
|
|
3552
3216
|
break;
|
|
3553
3217
|
}
|
|
3554
3218
|
case "image": {
|
|
3555
|
-
|
|
3556
|
-
out += renderer.image(imageToken.href, imageToken.title, imageToken.text);
|
|
3219
|
+
out += renderer.image(token);
|
|
3557
3220
|
break;
|
|
3558
3221
|
}
|
|
3559
3222
|
case "strong": {
|
|
3560
|
-
|
|
3561
|
-
out += renderer.strong(this.parseInline(strongToken.tokens, renderer));
|
|
3223
|
+
out += renderer.strong(token);
|
|
3562
3224
|
break;
|
|
3563
3225
|
}
|
|
3564
3226
|
case "em": {
|
|
3565
|
-
|
|
3566
|
-
out += renderer.em(this.parseInline(emToken.tokens, renderer));
|
|
3227
|
+
out += renderer.em(token);
|
|
3567
3228
|
break;
|
|
3568
3229
|
}
|
|
3569
3230
|
case "codespan": {
|
|
3570
|
-
|
|
3571
|
-
out += renderer.codespan(codespanToken.text);
|
|
3231
|
+
out += renderer.codespan(token);
|
|
3572
3232
|
break;
|
|
3573
3233
|
}
|
|
3574
3234
|
case "br": {
|
|
3575
|
-
out += renderer.br();
|
|
3235
|
+
out += renderer.br(token);
|
|
3576
3236
|
break;
|
|
3577
3237
|
}
|
|
3578
3238
|
case "del": {
|
|
3579
|
-
|
|
3580
|
-
out += renderer.del(this.parseInline(delToken.tokens, renderer));
|
|
3239
|
+
out += renderer.del(token);
|
|
3581
3240
|
break;
|
|
3582
3241
|
}
|
|
3583
3242
|
case "text": {
|
|
3584
|
-
|
|
3585
|
-
out += renderer.text(textToken.text);
|
|
3243
|
+
out += renderer.text(token);
|
|
3586
3244
|
break;
|
|
3587
3245
|
}
|
|
3588
3246
|
default: {
|
|
@@ -3602,6 +3260,7 @@ class _Parser {
|
|
|
3602
3260
|
class _Hooks {
|
|
3603
3261
|
constructor(options) {
|
|
3604
3262
|
__publicField(this, "options");
|
|
3263
|
+
__publicField(this, "block");
|
|
3605
3264
|
this.options = options || _defaults;
|
|
3606
3265
|
}
|
|
3607
3266
|
/**
|
|
@@ -3622,6 +3281,18 @@ class _Hooks {
|
|
|
3622
3281
|
processAllTokens(tokens) {
|
|
3623
3282
|
return tokens;
|
|
3624
3283
|
}
|
|
3284
|
+
/**
|
|
3285
|
+
* Provide function to tokenize markdown
|
|
3286
|
+
*/
|
|
3287
|
+
provideLexer() {
|
|
3288
|
+
return this.block ? _Lexer.lex : _Lexer.lexInline;
|
|
3289
|
+
}
|
|
3290
|
+
/**
|
|
3291
|
+
* Provide function to parse tokens
|
|
3292
|
+
*/
|
|
3293
|
+
provideParser() {
|
|
3294
|
+
return this.block ? _Parser.parse : _Parser.parseInline;
|
|
3295
|
+
}
|
|
3625
3296
|
}
|
|
3626
3297
|
__publicField(_Hooks, "passThroughHooks", /* @__PURE__ */ new Set([
|
|
3627
3298
|
"preprocess",
|
|
@@ -3630,12 +3301,10 @@ __publicField(_Hooks, "passThroughHooks", /* @__PURE__ */ new Set([
|
|
|
3630
3301
|
]));
|
|
3631
3302
|
class Marked {
|
|
3632
3303
|
constructor(...args) {
|
|
3633
|
-
__privateAdd(this, _parseMarkdown);
|
|
3634
|
-
__privateAdd(this, _onError);
|
|
3635
3304
|
__publicField(this, "defaults", _getDefaults());
|
|
3636
3305
|
__publicField(this, "options", this.setOptions);
|
|
3637
|
-
__publicField(this, "parse",
|
|
3638
|
-
__publicField(this, "parseInline",
|
|
3306
|
+
__publicField(this, "parse", this.parseMarkdown(true));
|
|
3307
|
+
__publicField(this, "parseInline", this.parseMarkdown(false));
|
|
3639
3308
|
__publicField(this, "Parser", _Parser);
|
|
3640
3309
|
__publicField(this, "Renderer", _Renderer);
|
|
3641
3310
|
__publicField(this, "TextRenderer", _TextRenderer);
|
|
@@ -3747,7 +3416,7 @@ class Marked {
|
|
|
3747
3416
|
if (!(prop in renderer)) {
|
|
3748
3417
|
throw new Error(`renderer '${prop}' does not exist`);
|
|
3749
3418
|
}
|
|
3750
|
-
if (
|
|
3419
|
+
if (["options", "parser"].includes(prop)) {
|
|
3751
3420
|
continue;
|
|
3752
3421
|
}
|
|
3753
3422
|
const rendererProp = prop;
|
|
@@ -3791,7 +3460,7 @@ class Marked {
|
|
|
3791
3460
|
if (!(prop in hooks)) {
|
|
3792
3461
|
throw new Error(`hook '${prop}' does not exist`);
|
|
3793
3462
|
}
|
|
3794
|
-
if (
|
|
3463
|
+
if (["options", "block"].includes(prop)) {
|
|
3795
3464
|
continue;
|
|
3796
3465
|
}
|
|
3797
3466
|
const hooksProp = prop;
|
|
@@ -3845,69 +3514,68 @@ class Marked {
|
|
|
3845
3514
|
parser(tokens, options) {
|
|
3846
3515
|
return _Parser.parse(tokens, options != null ? options : this.defaults);
|
|
3847
3516
|
}
|
|
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.");
|
|
3517
|
+
parseMarkdown(blockType) {
|
|
3518
|
+
const parse = (src, options) => {
|
|
3519
|
+
const origOpt = __spreadValues({}, options);
|
|
3520
|
+
const opt = __spreadValues(__spreadValues({}, this.defaults), origOpt);
|
|
3521
|
+
const throwError = this.onError(!!opt.silent, !!opt.async);
|
|
3522
|
+
if (this.defaults.async === true && origOpt.async === false) {
|
|
3523
|
+
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
3524
|
}
|
|
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);
|
|
3525
|
+
if (typeof src === "undefined" || src === null) {
|
|
3526
|
+
return throwError(new Error("marked(): input parameter is undefined or null"));
|
|
3527
|
+
}
|
|
3528
|
+
if (typeof src !== "string") {
|
|
3529
|
+
return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
|
|
3876
3530
|
}
|
|
3877
|
-
let tokens = lexer(src, opt);
|
|
3878
3531
|
if (opt.hooks) {
|
|
3879
|
-
|
|
3532
|
+
opt.hooks.options = opt;
|
|
3533
|
+
opt.hooks.block = blockType;
|
|
3880
3534
|
}
|
|
3881
|
-
|
|
3882
|
-
|
|
3535
|
+
const lexer = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
|
|
3536
|
+
const parser2 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
|
|
3537
|
+
if (opt.async) {
|
|
3538
|
+
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
3539
|
}
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3540
|
+
try {
|
|
3541
|
+
if (opt.hooks) {
|
|
3542
|
+
src = opt.hooks.preprocess(src);
|
|
3543
|
+
}
|
|
3544
|
+
let tokens = lexer(src, opt);
|
|
3545
|
+
if (opt.hooks) {
|
|
3546
|
+
tokens = opt.hooks.processAllTokens(tokens);
|
|
3547
|
+
}
|
|
3548
|
+
if (opt.walkTokens) {
|
|
3549
|
+
this.walkTokens(tokens, opt.walkTokens);
|
|
3550
|
+
}
|
|
3551
|
+
let html2 = parser2(tokens, opt);
|
|
3552
|
+
if (opt.hooks) {
|
|
3553
|
+
html2 = opt.hooks.postprocess(html2);
|
|
3554
|
+
}
|
|
3555
|
+
return html2;
|
|
3556
|
+
} catch (e) {
|
|
3557
|
+
return throwError(e);
|
|
3558
|
+
}
|
|
3559
|
+
};
|
|
3560
|
+
return parse;
|
|
3561
|
+
}
|
|
3562
|
+
onError(silent, async) {
|
|
3563
|
+
return (e) => {
|
|
3564
|
+
e.message += "\nPlease report this to https://github.com/markedjs/marked.";
|
|
3565
|
+
if (silent) {
|
|
3566
|
+
const msg = "<p>An error occurred:</p><pre>" + escape$1(e.message + "", true) + "</pre>";
|
|
3567
|
+
if (async) {
|
|
3568
|
+
return Promise.resolve(msg);
|
|
3569
|
+
}
|
|
3570
|
+
return msg;
|
|
3887
3571
|
}
|
|
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
3572
|
if (async) {
|
|
3901
|
-
return Promise.
|
|
3573
|
+
return Promise.reject(e);
|
|
3902
3574
|
}
|
|
3903
|
-
|
|
3904
|
-
}
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
}
|
|
3908
|
-
throw e;
|
|
3909
|
-
};
|
|
3910
|
-
};
|
|
3575
|
+
throw e;
|
|
3576
|
+
};
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3911
3579
|
const markedInstance = new Marked();
|
|
3912
3580
|
function marked$1(src, opt) {
|
|
3913
3581
|
return markedInstance.parse(src, opt);
|
|
@@ -3946,6 +3614,10 @@ marked$1.walkTokens;
|
|
|
3946
3614
|
marked$1.parseInline;
|
|
3947
3615
|
_Parser.parse;
|
|
3948
3616
|
_Lexer.lex;
|
|
3617
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
3618
|
+
function getDefaultExportFromCjs(x) {
|
|
3619
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
3620
|
+
}
|
|
3949
3621
|
var escapes = {
|
|
3950
3622
|
"&": "&",
|
|
3951
3623
|
"<": "<",
|
|
@@ -4444,11 +4116,9 @@ var hanabi$1 = { exports: {} };
|
|
|
4444
4116
|
});
|
|
4445
4117
|
var defaultColors = ["23AC69", "91C132", "F19726", "E8552D", "1AAB8E", "E1147F", "2980C1", "1BA1E6", "9FA0A0", "F19726", "E30B20", "E30B20", "A3338B"];
|
|
4446
4118
|
var index = function(input, ref) {
|
|
4447
|
-
if (ref === void 0)
|
|
4448
|
-
ref = {};
|
|
4119
|
+
if (ref === void 0) ref = {};
|
|
4449
4120
|
var colors = ref.colors;
|
|
4450
|
-
if (colors === void 0)
|
|
4451
|
-
colors = defaultColors;
|
|
4121
|
+
if (colors === void 0) colors = defaultColors;
|
|
4452
4122
|
var index2 = 0;
|
|
4453
4123
|
var cache = {};
|
|
4454
4124
|
var wordRe = /[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/;
|
|
@@ -4491,7 +4161,7 @@ function getRenderer(options) {
|
|
|
4491
4161
|
renderer.image = markedImageRenderer(renderer, renderer.image, options);
|
|
4492
4162
|
return renderer;
|
|
4493
4163
|
}
|
|
4494
|
-
const markedLinkRenderer = (renderer, orgLinkRenderer) => (
|
|
4164
|
+
const markedLinkRenderer = (renderer, orgLinkRenderer) => (args) => {
|
|
4495
4165
|
const getLinkOrigin = (link2) => {
|
|
4496
4166
|
try {
|
|
4497
4167
|
return new URL(link2).origin;
|
|
@@ -4499,31 +4169,30 @@ const markedLinkRenderer = (renderer, orgLinkRenderer) => (href, title, text) =>
|
|
|
4499
4169
|
return "";
|
|
4500
4170
|
}
|
|
4501
4171
|
};
|
|
4502
|
-
const isSameOriginLink = getLinkOrigin(href) === window.location.origin;
|
|
4503
|
-
const html2 = orgLinkRenderer.call(renderer,
|
|
4172
|
+
const isSameOriginLink = getLinkOrigin(args.href) === window.location.origin;
|
|
4173
|
+
const html2 = orgLinkRenderer.call(renderer, args);
|
|
4504
4174
|
return html2.replace(
|
|
4505
4175
|
/^<a /,
|
|
4506
4176
|
`<a target="_blank" ${!isSameOriginLink ? `rel="noreferrer noopener nofollow"` : ""} `
|
|
4507
4177
|
);
|
|
4508
4178
|
};
|
|
4509
|
-
const markedCodeRenderer = () => (
|
|
4179
|
+
const markedCodeRenderer = () => ({ lang, text }) => {
|
|
4510
4180
|
const realLang = !lang ? "plaintext" : lang;
|
|
4511
|
-
let colorized =
|
|
4181
|
+
let colorized = text;
|
|
4512
4182
|
if (window.hljs) {
|
|
4513
4183
|
if (realLang && window.hljs.getLanguage(realLang)) {
|
|
4514
|
-
colorized = window.hljs.highlight(realLang,
|
|
4184
|
+
colorized = window.hljs.highlight(realLang, text).value;
|
|
4515
4185
|
}
|
|
4516
4186
|
} else {
|
|
4517
|
-
colorized = renderCode(
|
|
4187
|
+
colorized = renderCode(text);
|
|
4518
4188
|
}
|
|
4519
4189
|
return `<pre rel="${realLang}">
|
|
4520
4190
|
<code class="hljs language-${realLang}">${colorized.replace(/&/g, "&")}</code>
|
|
4521
4191
|
</pre>`;
|
|
4522
4192
|
};
|
|
4523
|
-
const markedImageRenderer = (renderer, orgImageRenderer, { imgLazyLoad }) => (
|
|
4524
|
-
const html2 = orgImageRenderer.call(renderer,
|
|
4525
|
-
if (!imgLazyLoad)
|
|
4526
|
-
return html2;
|
|
4193
|
+
const markedImageRenderer = (renderer, orgImageRenderer, { imgLazyLoad }) => (args) => {
|
|
4194
|
+
const html2 = orgImageRenderer.call(renderer, args);
|
|
4195
|
+
if (!imgLazyLoad) return html2;
|
|
4527
4196
|
if (imgLazyLoad === "native" || imgLazyLoad === true)
|
|
4528
4197
|
return html2.replace(/^<img /, '<img class="lazyload" loading="lazy" ');
|
|
4529
4198
|
if (imgLazyLoad === "data-src")
|
|
@@ -4545,17 +4214,17 @@ function setReplacers(arr) {
|
|
|
4545
4214
|
}
|
|
4546
4215
|
function initMarked(options) {
|
|
4547
4216
|
try {
|
|
4548
|
-
if (!
|
|
4549
|
-
return;
|
|
4217
|
+
if (!Marked.name) return;
|
|
4550
4218
|
} catch (e) {
|
|
4551
4219
|
return;
|
|
4552
4220
|
}
|
|
4553
|
-
|
|
4221
|
+
const marked2 = new Marked();
|
|
4222
|
+
marked2.setOptions(__spreadValues(__spreadValues({
|
|
4554
4223
|
renderer: getRenderer({
|
|
4555
4224
|
imgLazyLoad: options.imgLazyLoad
|
|
4556
4225
|
})
|
|
4557
4226
|
}, markedOptions), options.markedOptions));
|
|
4558
|
-
instance =
|
|
4227
|
+
instance = marked2;
|
|
4559
4228
|
}
|
|
4560
4229
|
function marked(src) {
|
|
4561
4230
|
var _a;
|
|
@@ -4565,8 +4234,7 @@ function marked(src) {
|
|
|
4565
4234
|
}
|
|
4566
4235
|
let dest = sanitize(markedContent);
|
|
4567
4236
|
replacers.forEach((replacer) => {
|
|
4568
|
-
if (typeof replacer === "function")
|
|
4569
|
-
dest = replacer(dest);
|
|
4237
|
+
if (typeof replacer === "function") dest = replacer(dest);
|
|
4570
4238
|
});
|
|
4571
4239
|
return dest;
|
|
4572
4240
|
}
|
|
@@ -4649,8 +4317,7 @@ class DataManager {
|
|
|
4649
4317
|
}
|
|
4650
4318
|
updateComment(comment) {
|
|
4651
4319
|
this.comments = this.comments.map((c) => {
|
|
4652
|
-
if (c.id === comment.id)
|
|
4653
|
-
return comment;
|
|
4320
|
+
if (c.id === comment.id) return comment;
|
|
4654
4321
|
return c;
|
|
4655
4322
|
});
|
|
4656
4323
|
this.events.trigger("comment-updated", comment);
|
|
@@ -4658,8 +4325,7 @@ class DataManager {
|
|
|
4658
4325
|
}
|
|
4659
4326
|
deleteComment(id) {
|
|
4660
4327
|
const comment = this.comments.find((c) => c.id === id);
|
|
4661
|
-
if (!comment)
|
|
4662
|
-
throw new Error(`Comment ${id} not found`);
|
|
4328
|
+
if (!comment) throw new Error(`Comment ${id} not found`);
|
|
4663
4329
|
this.comments = this.comments.filter((c) => c.id !== id);
|
|
4664
4330
|
this.events.trigger("comment-deleted", comment);
|
|
4665
4331
|
this.events.trigger("list-loaded", this.comments);
|
|
@@ -4715,8 +4381,7 @@ function getOffset(el, relativeTo) {
|
|
|
4715
4381
|
};
|
|
4716
4382
|
};
|
|
4717
4383
|
const elOffset = getOffsetRecursive(el);
|
|
4718
|
-
if (!relativeTo)
|
|
4719
|
-
return elOffset;
|
|
4384
|
+
if (!relativeTo) return elOffset;
|
|
4720
4385
|
const relativeToOffset = getOffsetRecursive(relativeTo);
|
|
4721
4386
|
return {
|
|
4722
4387
|
top: elOffset.top - relativeToOffset.top,
|
|
@@ -4751,16 +4416,14 @@ function timeAgo(date, $t = (n) => n) {
|
|
|
4751
4416
|
if (minutes === 0) {
|
|
4752
4417
|
const leave3 = leave2 % (60 * 1e3);
|
|
4753
4418
|
const seconds = Math.round(leave3 / 1e3);
|
|
4754
|
-
if (seconds < 10)
|
|
4755
|
-
return $t("now");
|
|
4419
|
+
if (seconds < 10) return $t("now");
|
|
4756
4420
|
return `${seconds} ${$t("seconds")}`;
|
|
4757
4421
|
}
|
|
4758
4422
|
return `${minutes} ${$t("minutes")}`;
|
|
4759
4423
|
}
|
|
4760
4424
|
return `${hours} ${$t("hours")}`;
|
|
4761
4425
|
}
|
|
4762
|
-
if (days < 0)
|
|
4763
|
-
return $t("now");
|
|
4426
|
+
if (days < 0) return $t("now");
|
|
4764
4427
|
if (days < 8) {
|
|
4765
4428
|
return `${days} ${$t("days")}`;
|
|
4766
4429
|
}
|
|
@@ -4779,14 +4442,10 @@ function versionCompare(a, b) {
|
|
|
4779
4442
|
for (let i = 0; i < 3; i++) {
|
|
4780
4443
|
const na = Number(pa[i]);
|
|
4781
4444
|
const nb = Number(pb[i]);
|
|
4782
|
-
if (na > nb)
|
|
4783
|
-
|
|
4784
|
-
if (nb
|
|
4785
|
-
|
|
4786
|
-
if (!Number.isNaN(na) && Number.isNaN(nb))
|
|
4787
|
-
return 1;
|
|
4788
|
-
if (Number.isNaN(na) && !Number.isNaN(nb))
|
|
4789
|
-
return -1;
|
|
4445
|
+
if (na > nb) return 1;
|
|
4446
|
+
if (nb > na) return -1;
|
|
4447
|
+
if (!Number.isNaN(na) && Number.isNaN(nb)) return 1;
|
|
4448
|
+
if (Number.isNaN(na) && !Number.isNaN(nb)) return -1;
|
|
4790
4449
|
}
|
|
4791
4450
|
return 0;
|
|
4792
4451
|
}
|
|
@@ -4900,21 +4559,25 @@ const en = {
|
|
|
4900
4559
|
cancel: "Cancel",
|
|
4901
4560
|
/* Sidebar */
|
|
4902
4561
|
msgCenter: "Messages",
|
|
4903
|
-
ctrlCenter: "
|
|
4562
|
+
ctrlCenter: "Dashboard",
|
|
4904
4563
|
/* Auth */
|
|
4564
|
+
userProfile: "Profile",
|
|
4905
4565
|
noAccountPrompt: "Don't have an account?",
|
|
4906
4566
|
haveAccountPrompt: "Already have an account?",
|
|
4907
4567
|
forgetPassword: "Forget Password",
|
|
4908
4568
|
resetPassword: "Reset Password",
|
|
4569
|
+
changePassword: "Change Password",
|
|
4570
|
+
confirmPassword: "Confirm Password",
|
|
4571
|
+
passwordMismatch: "Passwords do not match",
|
|
4909
4572
|
verificationCode: "Verification Code",
|
|
4910
|
-
verifySend: "
|
|
4573
|
+
verifySend: "Send Code",
|
|
4911
4574
|
verifyResend: "Resend",
|
|
4912
4575
|
waitSeconds: "Wait {seconds}s",
|
|
4913
4576
|
emailVerified: "Email has been verified",
|
|
4914
4577
|
password: "Password",
|
|
4915
4578
|
username: "Username",
|
|
4916
4579
|
nextStep: "Next Step",
|
|
4917
|
-
|
|
4580
|
+
skipVerify: "Skip verification",
|
|
4918
4581
|
logoutConfirm: "Are you sure to logout?",
|
|
4919
4582
|
accountMergeNotice: "Your email has multiple accounts with different id.",
|
|
4920
4583
|
accountMergeSelectOne: "Please select one you want to merge all the data into it.",
|
|
@@ -5004,10 +4667,14 @@ const zhCN = {
|
|
|
5004
4667
|
msgCenter: "通知中心",
|
|
5005
4668
|
ctrlCenter: "控制中心",
|
|
5006
4669
|
/* Auth */
|
|
4670
|
+
userProfile: "个人资料",
|
|
5007
4671
|
noAccountPrompt: "没有账号?",
|
|
5008
4672
|
haveAccountPrompt: "已有账号?",
|
|
5009
4673
|
forgetPassword: "忘记密码",
|
|
5010
4674
|
resetPassword: "重置密码",
|
|
4675
|
+
changePassword: "修改密码",
|
|
4676
|
+
confirmPassword: "确认密码",
|
|
4677
|
+
passwordMismatch: "两次输入的密码不一致",
|
|
5011
4678
|
verificationCode: "验证码",
|
|
5012
4679
|
verifySend: "发送验证码",
|
|
5013
4680
|
verifyResend: "重新发送",
|
|
@@ -5016,7 +4683,7 @@ const zhCN = {
|
|
|
5016
4683
|
password: "密码",
|
|
5017
4684
|
username: "用户名",
|
|
5018
4685
|
nextStep: "下一步",
|
|
5019
|
-
|
|
4686
|
+
skipVerify: "跳过验证",
|
|
5020
4687
|
logoutConfirm: "确定要退出登录吗?",
|
|
5021
4688
|
accountMergeNotice: "您的电子邮件下有多个不同 ID 的账户。",
|
|
5022
4689
|
accountMergeSelectOne: "请选择将所有数据合并到其中的一个。",
|
|
@@ -5062,8 +4729,7 @@ function findLocaleSet(lang) {
|
|
|
5062
4729
|
let LocaleConf = "en";
|
|
5063
4730
|
let LocaleDict = findLocaleSet(LocaleConf);
|
|
5064
4731
|
function setLocale(locale) {
|
|
5065
|
-
if (locale === LocaleConf)
|
|
5066
|
-
return;
|
|
4732
|
+
if (locale === LocaleConf) return;
|
|
5067
4733
|
LocaleConf = locale;
|
|
5068
4734
|
LocaleDict = typeof locale === "string" ? findLocaleSet(locale) : locale;
|
|
5069
4735
|
}
|
|
@@ -5089,8 +4755,7 @@ class EventManager {
|
|
|
5089
4755
|
* Remove an event listener for a specific event name and handler
|
|
5090
4756
|
*/
|
|
5091
4757
|
off(name, handler) {
|
|
5092
|
-
if (!handler)
|
|
5093
|
-
return;
|
|
4758
|
+
if (!handler) return;
|
|
5094
4759
|
this.events = this.events.filter((evt) => !(evt.name === name && evt.handler === handler));
|
|
5095
4760
|
}
|
|
5096
4761
|
/**
|
|
@@ -5098,8 +4763,7 @@ class EventManager {
|
|
|
5098
4763
|
*/
|
|
5099
4764
|
trigger(name, payload) {
|
|
5100
4765
|
this.events.slice(0).filter((evt) => evt.name === name && typeof evt.handler === "function").forEach((evt) => {
|
|
5101
|
-
if (evt.once)
|
|
5102
|
-
this.off(name, evt.handler);
|
|
4766
|
+
if (evt.once) this.off(name, evt.handler);
|
|
5103
4767
|
evt.handler(payload);
|
|
5104
4768
|
});
|
|
5105
4769
|
}
|
|
@@ -5152,26 +4816,19 @@ function handelCustomConf(customConf, full = false) {
|
|
|
5152
4816
|
if (conf.el && typeof conf.el === "string") {
|
|
5153
4817
|
try {
|
|
5154
4818
|
const findEl = document.querySelector(conf.el);
|
|
5155
|
-
if (!findEl)
|
|
5156
|
-
throw Error(`Target element "${conf.el}" was not found.`);
|
|
4819
|
+
if (!findEl) throw Error(`Target element "${conf.el}" was not found.`);
|
|
5157
4820
|
conf.el = findEl;
|
|
5158
4821
|
} catch (e) {
|
|
5159
4822
|
console.error(e);
|
|
5160
4823
|
throw new Error("Please check your Artalk `el` config.");
|
|
5161
4824
|
}
|
|
5162
4825
|
}
|
|
5163
|
-
if (conf.pageKey === "")
|
|
5164
|
-
|
|
5165
|
-
if (conf.
|
|
5166
|
-
|
|
5167
|
-
if (conf.
|
|
5168
|
-
|
|
5169
|
-
if (conf.locale === "auto")
|
|
5170
|
-
conf.locale = navigator.language;
|
|
5171
|
-
if (conf.flatMode === "auto")
|
|
5172
|
-
conf.flatMode = window.matchMedia("(max-width: 768px)").matches;
|
|
5173
|
-
if (typeof conf.nestMax === "number" && Number(conf.nestMax) <= 1)
|
|
5174
|
-
conf.flatMode = true;
|
|
4826
|
+
if (conf.pageKey === "") conf.pageKey = `${window.location.pathname}`;
|
|
4827
|
+
if (conf.pageTitle === "") conf.pageTitle = `${document.title}`;
|
|
4828
|
+
if (conf.server) conf.server = conf.server.replace(/\/$/, "").replace(/\/api\/?$/, "");
|
|
4829
|
+
if (conf.locale === "auto") conf.locale = navigator.language;
|
|
4830
|
+
if (conf.flatMode === "auto") conf.flatMode = window.matchMedia("(max-width: 768px)").matches;
|
|
4831
|
+
if (typeof conf.nestMax === "number" && Number(conf.nestMax) <= 1) conf.flatMode = true;
|
|
5175
4832
|
return conf;
|
|
5176
4833
|
}
|
|
5177
4834
|
function handleConfFormServer(conf) {
|
|
@@ -5186,10 +4843,8 @@ function handleConfFormServer(conf) {
|
|
|
5186
4843
|
"statPageKeyAttr"
|
|
5187
4844
|
];
|
|
5188
4845
|
Object.keys(conf).forEach((k) => {
|
|
5189
|
-
if (ExcludedKeys.includes(k))
|
|
5190
|
-
|
|
5191
|
-
if (k === "darkMode" && conf[k] !== "auto")
|
|
5192
|
-
delete conf[k];
|
|
4846
|
+
if (ExcludedKeys.includes(k)) delete conf[k];
|
|
4847
|
+
if (k === "darkMode" && conf[k] !== "auto") delete conf[k];
|
|
5193
4848
|
});
|
|
5194
4849
|
if (conf.emoticons && typeof conf.emoticons === "string") {
|
|
5195
4850
|
conf.emoticons = conf.emoticons.trim();
|
|
@@ -5210,7 +4865,7 @@ function convertApiOptions(conf, ctx) {
|
|
|
5210
4865
|
timeout: conf.reqTimeout,
|
|
5211
4866
|
getApiToken: () => ctx == null ? void 0 : ctx.get("user").getData().token,
|
|
5212
4867
|
userInfo: (ctx == null ? void 0 : ctx.get("user").checkHasBasicUserInfo()) ? {
|
|
5213
|
-
name: ctx == null ? void 0 : ctx.get("user").getData().
|
|
4868
|
+
name: ctx == null ? void 0 : ctx.get("user").getData().name,
|
|
5214
4869
|
email: ctx == null ? void 0 : ctx.get("user").getData().email
|
|
5215
4870
|
} : void 0,
|
|
5216
4871
|
handlers: ctx == null ? void 0 : ctx.getApiHandlers()
|
|
@@ -5260,6 +4915,7 @@ class Context {
|
|
|
5260
4915
|
this.$root = conf.el;
|
|
5261
4916
|
this.$root.classList.add("artalk");
|
|
5262
4917
|
this.$root.innerHTML = "";
|
|
4918
|
+
conf.darkMode && this.$root.classList.add("atk-dark-mode");
|
|
5263
4919
|
this.data = new DataManager(this.events);
|
|
5264
4920
|
this.on("mounted", () => {
|
|
5265
4921
|
this.mounted = true;
|
|
@@ -5275,8 +4931,7 @@ class Context {
|
|
|
5275
4931
|
return new Api2(convertApiOptions(this.conf, this));
|
|
5276
4932
|
}
|
|
5277
4933
|
getApiHandlers() {
|
|
5278
|
-
if (!this.apiHandlers)
|
|
5279
|
-
this.apiHandlers = createNewApiHandlers(this);
|
|
4934
|
+
if (!this.apiHandlers) this.apiHandlers = createNewApiHandlers(this);
|
|
5280
4935
|
return this.apiHandlers;
|
|
5281
4936
|
}
|
|
5282
4937
|
getData() {
|
|
@@ -5375,8 +5030,7 @@ function showLoading(parentElem, conf) {
|
|
|
5375
5030
|
</div>
|
|
5376
5031
|
</div>`
|
|
5377
5032
|
);
|
|
5378
|
-
if (conf == null ? void 0 : conf.transparentBg)
|
|
5379
|
-
$loading.style.background = "transparent";
|
|
5033
|
+
if (conf == null ? void 0 : conf.transparentBg) $loading.style.background = "transparent";
|
|
5380
5034
|
parentElem.appendChild($loading);
|
|
5381
5035
|
}
|
|
5382
5036
|
$loading.style.display = "";
|
|
@@ -5384,21 +5038,17 @@ function showLoading(parentElem, conf) {
|
|
|
5384
5038
|
if ($spinner) {
|
|
5385
5039
|
$spinner.style.display = "none";
|
|
5386
5040
|
window.setTimeout(() => {
|
|
5387
|
-
if ($spinner.isConnected)
|
|
5388
|
-
$spinner.style.display = "";
|
|
5041
|
+
if ($spinner.isConnected) $spinner.style.display = "";
|
|
5389
5042
|
}, 500);
|
|
5390
5043
|
}
|
|
5391
5044
|
}
|
|
5392
5045
|
function hideLoading(parentElem) {
|
|
5393
5046
|
const $loading = parentElem.querySelector(":scope > .atk-loading");
|
|
5394
|
-
if ($loading)
|
|
5395
|
-
$loading.style.display = "none";
|
|
5047
|
+
if ($loading) $loading.style.display = "none";
|
|
5396
5048
|
}
|
|
5397
5049
|
function setLoading(val, parentElem) {
|
|
5398
|
-
if (val)
|
|
5399
|
-
|
|
5400
|
-
else
|
|
5401
|
-
hideLoading(parentElem);
|
|
5050
|
+
if (val) showLoading(parentElem);
|
|
5051
|
+
else hideLoading(parentElem);
|
|
5402
5052
|
}
|
|
5403
5053
|
function scrollIntoView(elem, enableAnim = true, relativeTo) {
|
|
5404
5054
|
let top;
|
|
@@ -5417,10 +5067,8 @@ function scrollIntoView(elem, enableAnim = true, relativeTo) {
|
|
|
5417
5067
|
// behavior: enableAnim ? 'smooth' : 'instant',
|
|
5418
5068
|
behavior: "instant"
|
|
5419
5069
|
};
|
|
5420
|
-
if (relativeTo)
|
|
5421
|
-
|
|
5422
|
-
else
|
|
5423
|
-
window.scroll(scrollOptions);
|
|
5070
|
+
if (relativeTo) relativeTo.scroll(scrollOptions);
|
|
5071
|
+
else window.scroll(scrollOptions);
|
|
5424
5072
|
}
|
|
5425
5073
|
function showNotify(wrapElem, msg, type) {
|
|
5426
5074
|
const colors = { s: "#57d59f", e: "#ff6f6c", w: "#ffc721", i: "#2ebcfc" };
|
|
@@ -5462,8 +5110,7 @@ function playFadeInAnim(elem, after) {
|
|
|
5462
5110
|
function setError(parentElem, html2, title = '<span class="atk-error-title">Artalk Error</span>') {
|
|
5463
5111
|
let elem = parentElem.querySelector(".atk-error-layer");
|
|
5464
5112
|
if (html2 === null) {
|
|
5465
|
-
if (elem !== null)
|
|
5466
|
-
elem.remove();
|
|
5113
|
+
if (elem !== null) elem.remove();
|
|
5467
5114
|
return;
|
|
5468
5115
|
}
|
|
5469
5116
|
if (!elem) {
|
|
@@ -5474,8 +5121,7 @@ function setError(parentElem, html2, title = '<span class="atk-error-title">Arta
|
|
|
5474
5121
|
}
|
|
5475
5122
|
const errorTextEl = elem.querySelector(".atk-error-text");
|
|
5476
5123
|
errorTextEl.innerHTML = "";
|
|
5477
|
-
if (html2 === null)
|
|
5478
|
-
return;
|
|
5124
|
+
if (html2 === null) return;
|
|
5479
5125
|
if (html2 instanceof HTMLElement) {
|
|
5480
5126
|
errorTextEl.appendChild(html2);
|
|
5481
5127
|
} else {
|
|
@@ -5499,8 +5145,7 @@ function getScrollBarWidth() {
|
|
|
5499
5145
|
const w1 = inner.offsetWidth;
|
|
5500
5146
|
outer.style.overflow = "scroll";
|
|
5501
5147
|
let w2 = inner.offsetWidth;
|
|
5502
|
-
if (w1 === w2)
|
|
5503
|
-
w2 = outer.clientWidth;
|
|
5148
|
+
if (w1 === w2) w2 = outer.clientWidth;
|
|
5504
5149
|
document.body.removeChild(outer);
|
|
5505
5150
|
return w1 - w2;
|
|
5506
5151
|
}
|
|
@@ -5545,8 +5190,7 @@ function iframeBody(checker) {
|
|
|
5545
5190
|
(function queryStatus() {
|
|
5546
5191
|
return __async(this, null, function* () {
|
|
5547
5192
|
yield sleep(1e3);
|
|
5548
|
-
if (stop)
|
|
5549
|
-
return;
|
|
5193
|
+
if (stop) return;
|
|
5550
5194
|
let isPass = false;
|
|
5551
5195
|
try {
|
|
5552
5196
|
const resp = yield checker.getApi().captcha.getCaptchaStatus();
|
|
@@ -5574,8 +5218,7 @@ const CaptchaChecker = {
|
|
|
5574
5218
|
});
|
|
5575
5219
|
},
|
|
5576
5220
|
body(checker) {
|
|
5577
|
-
if (checker.get("iframe"))
|
|
5578
|
-
return iframeBody(checker);
|
|
5221
|
+
if (checker.get("iframe")) return iframeBody(checker);
|
|
5579
5222
|
return imgBody(checker);
|
|
5580
5223
|
},
|
|
5581
5224
|
onSuccess(checker, data, inputVal, formEl) {
|
|
@@ -5591,7 +5234,7 @@ const AdminChecker = {
|
|
|
5591
5234
|
request(checker, inputVal) {
|
|
5592
5235
|
return __async(this, null, function* () {
|
|
5593
5236
|
return (yield checker.getApi().user.login({
|
|
5594
|
-
name: checker.getUser().getData().
|
|
5237
|
+
name: checker.getUser().getData().name,
|
|
5595
5238
|
email: checker.getUser().getData().email,
|
|
5596
5239
|
password: inputVal
|
|
5597
5240
|
})).data;
|
|
@@ -5602,7 +5245,7 @@ const AdminChecker = {
|
|
|
5602
5245
|
},
|
|
5603
5246
|
onSuccess(checker, res, inputVal, formEl) {
|
|
5604
5247
|
checker.getUser().update({
|
|
5605
|
-
|
|
5248
|
+
is_admin: true,
|
|
5606
5249
|
token: res.token
|
|
5607
5250
|
});
|
|
5608
5251
|
checker.getOpts().onReload();
|
|
@@ -5703,19 +5346,15 @@ class CheckerLauncher {
|
|
|
5703
5346
|
},
|
|
5704
5347
|
triggerSuccess: () => {
|
|
5705
5348
|
close();
|
|
5706
|
-
if (checker.onSuccess)
|
|
5707
|
-
|
|
5708
|
-
if (payload.onSuccess)
|
|
5709
|
-
payload.onSuccess();
|
|
5349
|
+
if (checker.onSuccess) checker.onSuccess(checkerCtx, "", "", formEl);
|
|
5350
|
+
if (payload.onSuccess) payload.onSuccess();
|
|
5710
5351
|
},
|
|
5711
5352
|
cancel: () => {
|
|
5712
5353
|
close();
|
|
5713
|
-
if (payload.onCancel)
|
|
5714
|
-
payload.onCancel();
|
|
5354
|
+
if (payload.onCancel) payload.onCancel();
|
|
5715
5355
|
}
|
|
5716
5356
|
};
|
|
5717
|
-
if (postFire)
|
|
5718
|
-
postFire(checkerCtx);
|
|
5357
|
+
if (postFire) postFire(checkerCtx);
|
|
5719
5358
|
const formEl = createElement();
|
|
5720
5359
|
formEl.appendChild(checker.body(checkerCtx));
|
|
5721
5360
|
const $input = createElement(
|
|
@@ -5733,8 +5372,7 @@ class CheckerLauncher {
|
|
|
5733
5372
|
const dialog = new Dialog(formEl);
|
|
5734
5373
|
dialog.setYes((btnEl) => {
|
|
5735
5374
|
const inputVal = $input.value.trim();
|
|
5736
|
-
if (!btnTextOrg)
|
|
5737
|
-
btnTextOrg = btnEl.innerText;
|
|
5375
|
+
if (!btnTextOrg) btnTextOrg = btnEl.innerText;
|
|
5738
5376
|
const btnTextSet = (btnText) => {
|
|
5739
5377
|
btnEl.innerText = btnText;
|
|
5740
5378
|
btnEl.classList.add("error");
|
|
@@ -5746,14 +5384,11 @@ class CheckerLauncher {
|
|
|
5746
5384
|
btnEl.innerText = `${t("loading")}...`;
|
|
5747
5385
|
checker.request(checkerCtx, inputVal).then((data) => {
|
|
5748
5386
|
close();
|
|
5749
|
-
if (checker.onSuccess)
|
|
5750
|
-
|
|
5751
|
-
if (payload.onSuccess)
|
|
5752
|
-
payload.onSuccess();
|
|
5387
|
+
if (checker.onSuccess) checker.onSuccess(checkerCtx, data, inputVal, formEl);
|
|
5388
|
+
if (payload.onSuccess) payload.onSuccess();
|
|
5753
5389
|
}).catch((err) => {
|
|
5754
5390
|
btnTextSet(String(err.message || String(err)));
|
|
5755
|
-
if (checker.onError)
|
|
5756
|
-
checker.onError(checkerCtx, err, inputVal, formEl);
|
|
5391
|
+
if (checker.onError) checker.onError(checkerCtx, err, inputVal, formEl);
|
|
5757
5392
|
const tf = setTimeout(() => btnTextRestore(), 3e3);
|
|
5758
5393
|
$input.onfocus = () => {
|
|
5759
5394
|
btnTextRestore();
|
|
@@ -5764,8 +5399,7 @@ class CheckerLauncher {
|
|
|
5764
5399
|
});
|
|
5765
5400
|
dialog.setNo(() => {
|
|
5766
5401
|
close();
|
|
5767
|
-
if (payload.onCancel)
|
|
5768
|
-
payload.onCancel();
|
|
5402
|
+
if (payload.onCancel) payload.onCancel();
|
|
5769
5403
|
return false;
|
|
5770
5404
|
});
|
|
5771
5405
|
if (hideInteractInput) {
|
|
@@ -5773,8 +5407,7 @@ class CheckerLauncher {
|
|
|
5773
5407
|
dialog.$el.querySelector(".atk-layer-dialog-actions").style.display = "none";
|
|
5774
5408
|
}
|
|
5775
5409
|
layer.getEl().append(dialog.$el);
|
|
5776
|
-
if (payload.onMount)
|
|
5777
|
-
payload.onMount(dialog.$el);
|
|
5410
|
+
if (payload.onMount) payload.onMount(dialog.$el);
|
|
5778
5411
|
}
|
|
5779
5412
|
}
|
|
5780
5413
|
class Component {
|
|
@@ -5789,10 +5422,10 @@ class Component {
|
|
|
5789
5422
|
return this.$el;
|
|
5790
5423
|
}
|
|
5791
5424
|
}
|
|
5792
|
-
const EditorHTML = '<div class="atk-main-editor">\n <div class="atk-header">\n <input name="
|
|
5425
|
+
const EditorHTML = '<div class="atk-main-editor">\n <div class="atk-header">\n <input name="name" class="atk-name" type="text" required="required" />\n <input name="email" class="atk-email" type="email" required="required" />\n <input name="link" class="atk-link" type="url" />\n </div>\n <div class="atk-textarea-wrap">\n <textarea class="atk-textarea"></textarea>\n </div>\n <div class="atk-plug-panel-wrap" style="display: none"></div>\n <div class="atk-bottom">\n <div class="atk-item atk-bottom-left">\n <span class="atk-state-wrap"></span>\n <span class="atk-plug-btn-wrap"></span>\n </div>\n <div class="atk-item">\n <button type="button" class="atk-send-btn"></button>\n </div>\n </div>\n <div class="atk-notify-wrap"></div>\n</div>\n';
|
|
5793
5426
|
const Sel = {
|
|
5794
5427
|
$header: ".atk-header",
|
|
5795
|
-
$
|
|
5428
|
+
$name: '.atk-header [name="name"]',
|
|
5796
5429
|
$email: '.atk-header [name="email"]',
|
|
5797
5430
|
$link: '.atk-header [name="link"]',
|
|
5798
5431
|
$textareaWrap: ".atk-textarea-wrap",
|
|
@@ -5815,6 +5448,9 @@ function render() {
|
|
|
5815
5448
|
}
|
|
5816
5449
|
class EditorPlug {
|
|
5817
5450
|
constructor(kit) {
|
|
5451
|
+
__publicField(this, "$btn");
|
|
5452
|
+
__publicField(this, "$panel");
|
|
5453
|
+
__publicField(this, "editorStateEffectWhen");
|
|
5818
5454
|
this.kit = kit;
|
|
5819
5455
|
}
|
|
5820
5456
|
/** Use plug btn will add a btn on the bottom of editor */
|
|
@@ -5834,15 +5470,13 @@ class EditorPlug {
|
|
|
5834
5470
|
/** Listen the event of panel show */
|
|
5835
5471
|
usePanelShow(func) {
|
|
5836
5472
|
this.kit.useEvents().on("panel-show", (aPlug) => {
|
|
5837
|
-
if (aPlug === this)
|
|
5838
|
-
func();
|
|
5473
|
+
if (aPlug === this) func();
|
|
5839
5474
|
});
|
|
5840
5475
|
}
|
|
5841
5476
|
/** Listen the event of panel hide */
|
|
5842
5477
|
usePanelHide(func) {
|
|
5843
5478
|
this.kit.useEvents().on("panel-hide", (aPlug) => {
|
|
5844
|
-
if (aPlug === this)
|
|
5845
|
-
func();
|
|
5479
|
+
if (aPlug === this) func();
|
|
5846
5480
|
});
|
|
5847
5481
|
}
|
|
5848
5482
|
/** Use editor state modifier */
|
|
@@ -5857,8 +5491,7 @@ class Mover extends EditorPlug {
|
|
|
5857
5491
|
__publicField(this, "isMoved", false);
|
|
5858
5492
|
}
|
|
5859
5493
|
move(afterEl) {
|
|
5860
|
-
if (this.isMoved)
|
|
5861
|
-
return;
|
|
5494
|
+
if (this.isMoved) return;
|
|
5862
5495
|
this.isMoved = true;
|
|
5863
5496
|
const editorEl = this.kit.useUI().$el;
|
|
5864
5497
|
editorEl.after(createElement('<div class="atk-editor-travel-placeholder"></div>'));
|
|
@@ -5870,8 +5503,7 @@ class Mover extends EditorPlug {
|
|
|
5870
5503
|
}
|
|
5871
5504
|
back() {
|
|
5872
5505
|
var _a;
|
|
5873
|
-
if (!this.isMoved)
|
|
5874
|
-
return;
|
|
5506
|
+
if (!this.isMoved) return;
|
|
5875
5507
|
this.isMoved = false;
|
|
5876
5508
|
(_a = this.kit.useGlobalCtx().$root.querySelector(".atk-editor-travel-placeholder")) == null ? void 0 : _a.replaceWith(this.kit.useUI().$el);
|
|
5877
5509
|
this.kit.useUI().$el.classList.remove("editor-traveling");
|
|
@@ -5934,13 +5566,12 @@ class Editor extends Component {
|
|
|
5934
5566
|
return this.state.get();
|
|
5935
5567
|
}
|
|
5936
5568
|
getHeaderInputEls() {
|
|
5937
|
-
return {
|
|
5569
|
+
return { name: this.ui.$name, email: this.ui.$email, link: this.ui.$link };
|
|
5938
5570
|
}
|
|
5939
5571
|
getContentFinal() {
|
|
5940
5572
|
let content = this.getContentRaw();
|
|
5941
5573
|
const plugs = this.getPlugs();
|
|
5942
|
-
if (plugs)
|
|
5943
|
-
content = plugs.getTransformedContent(content);
|
|
5574
|
+
if (plugs) content = plugs.getTransformedContent(content);
|
|
5944
5575
|
return content;
|
|
5945
5576
|
}
|
|
5946
5577
|
getContentRaw() {
|
|
@@ -6018,8 +5649,8 @@ class SidebarLayer extends Component {
|
|
|
6018
5649
|
__publicField(this, "$closeBtn");
|
|
6019
5650
|
__publicField(this, "$iframeWrap");
|
|
6020
5651
|
__publicField(this, "$iframe");
|
|
6021
|
-
/** Refresh iFrame
|
|
6022
|
-
__publicField(this, "
|
|
5652
|
+
/** Refresh iFrame when show */
|
|
5653
|
+
__publicField(this, "refreshWhenShow", true);
|
|
6023
5654
|
/** Animation timer */
|
|
6024
5655
|
__publicField(this, "animTimer");
|
|
6025
5656
|
this.$el = createElement(SidebarHTML);
|
|
@@ -6030,7 +5661,7 @@ class SidebarLayer extends Component {
|
|
|
6030
5661
|
this.hide();
|
|
6031
5662
|
};
|
|
6032
5663
|
this.ctx.on("user-changed", () => {
|
|
6033
|
-
this.
|
|
5664
|
+
this.refreshWhenShow = true;
|
|
6034
5665
|
});
|
|
6035
5666
|
}
|
|
6036
5667
|
/** 显示 */
|
|
@@ -6039,8 +5670,8 @@ class SidebarLayer extends Component {
|
|
|
6039
5670
|
this.$el.style.transform = "";
|
|
6040
5671
|
this.initLayer();
|
|
6041
5672
|
this.layer.show();
|
|
6042
|
-
if (this.
|
|
6043
|
-
this.
|
|
5673
|
+
if (this.refreshWhenShow) {
|
|
5674
|
+
this.refreshWhenShow = false;
|
|
6044
5675
|
this.$iframeWrap.innerHTML = "";
|
|
6045
5676
|
this.$iframe = this.createIframe(conf.view);
|
|
6046
5677
|
this.$iframeWrap.append(this.$iframe);
|
|
@@ -6050,7 +5681,7 @@ class SidebarLayer extends Component {
|
|
|
6050
5681
|
if (this.getDarkMode() !== iFrameSrc.includes("&darkMode=1")) {
|
|
6051
5682
|
this.iframeLoad(
|
|
6052
5683
|
$iframe,
|
|
6053
|
-
|
|
5684
|
+
iFrameSrc.replace(/&darkMode=\d/, `&darkMode=${Number(this.getDarkMode())}`)
|
|
6054
5685
|
);
|
|
6055
5686
|
}
|
|
6056
5687
|
}
|
|
@@ -6078,7 +5709,7 @@ class SidebarLayer extends Component {
|
|
|
6078
5709
|
return __async(this, null, function* () {
|
|
6079
5710
|
const data = (yield this.ctx.getApi().user.getUserStatus(__spreadValues({}, this.ctx.getApi().getUserFields()))).data;
|
|
6080
5711
|
if (data.is_admin && !data.is_login) {
|
|
6081
|
-
this.
|
|
5712
|
+
this.refreshWhenShow = true;
|
|
6082
5713
|
this.ctx.checkAdmin({
|
|
6083
5714
|
onSuccess: () => {
|
|
6084
5715
|
setTimeout(() => {
|
|
@@ -6094,8 +5725,7 @@ class SidebarLayer extends Component {
|
|
|
6094
5725
|
});
|
|
6095
5726
|
}
|
|
6096
5727
|
initLayer() {
|
|
6097
|
-
if (this.layer)
|
|
6098
|
-
return;
|
|
5728
|
+
if (this.layer) return;
|
|
6099
5729
|
this.layer = this.ctx.get("layerManager").create("sidebar", this.$el);
|
|
6100
5730
|
this.layer.setOnAfterHide(() => {
|
|
6101
5731
|
this.ctx.editorResetState();
|
|
@@ -6118,10 +5748,8 @@ class SidebarLayer extends Component {
|
|
|
6118
5748
|
user: JSON.stringify(this.ctx.get("user").getData()),
|
|
6119
5749
|
time: +/* @__PURE__ */ new Date()
|
|
6120
5750
|
};
|
|
6121
|
-
if (view)
|
|
6122
|
-
|
|
6123
|
-
if (this.getDarkMode())
|
|
6124
|
-
query.darkMode = "1";
|
|
5751
|
+
if (view) query.view = view;
|
|
5752
|
+
query.darkMode = this.getDarkMode() ? "1" : "0";
|
|
6125
5753
|
const urlParams = new URLSearchParams(query);
|
|
6126
5754
|
this.iframeLoad($iframe, `${baseURL}?${urlParams.toString()}`);
|
|
6127
5755
|
return $iframe;
|
|
@@ -6152,10 +5780,8 @@ function makeNestCommentNodeList(srcData, sortBy = "DATE_DESC", nestMax = 2) {
|
|
|
6152
5780
|
nodeList.push(rootNode);
|
|
6153
5781
|
(function loadChildren(parentNode) {
|
|
6154
5782
|
const children = srcData.filter((o) => o.rid === parentNode.id);
|
|
6155
|
-
if (children.length === 0)
|
|
6156
|
-
|
|
6157
|
-
if (parentNode.level >= nestMax)
|
|
6158
|
-
parentNode = parentNode.parent;
|
|
5783
|
+
if (children.length === 0) return;
|
|
5784
|
+
if (parentNode.level >= nestMax) parentNode = parentNode.parent;
|
|
6159
5785
|
children.forEach((child) => {
|
|
6160
5786
|
const childNode = {
|
|
6161
5787
|
id: child.id,
|
|
@@ -6171,14 +5797,10 @@ function makeNestCommentNodeList(srcData, sortBy = "DATE_DESC", nestMax = 2) {
|
|
|
6171
5797
|
});
|
|
6172
5798
|
const sortFunc = (a, b) => {
|
|
6173
5799
|
let v = a.id - b.id;
|
|
6174
|
-
if (sortBy === "DATE_ASC")
|
|
6175
|
-
|
|
6176
|
-
else if (sortBy === "
|
|
6177
|
-
|
|
6178
|
-
else if (sortBy === "SRC_INDEX")
|
|
6179
|
-
v = srcData.indexOf(a.comment) - srcData.indexOf(b.comment);
|
|
6180
|
-
else if (sortBy === "VOTE_UP_DESC")
|
|
6181
|
-
v = b.comment.vote_up - a.comment.vote_up;
|
|
5800
|
+
if (sortBy === "DATE_ASC") v = +new Date(a.comment.date) - +new Date(b.comment.date);
|
|
5801
|
+
else if (sortBy === "DATE_DESC") v = +new Date(b.comment.date) - +new Date(a.comment.date);
|
|
5802
|
+
else if (sortBy === "SRC_INDEX") v = srcData.indexOf(a.comment) - srcData.indexOf(b.comment);
|
|
5803
|
+
else if (sortBy === "VOTE_UP_DESC") v = b.comment.vote_up - a.comment.vote_up;
|
|
6182
5804
|
return v;
|
|
6183
5805
|
};
|
|
6184
5806
|
(function sortLevels(nodes) {
|
|
@@ -6242,16 +5864,13 @@ const createFlatStrategy = (opts) => ({
|
|
|
6242
5864
|
}
|
|
6243
5865
|
});
|
|
6244
5866
|
function insertComment(opts, insertMode, comment, replyComment) {
|
|
6245
|
-
if (comment.is_collapsed)
|
|
6246
|
-
comment.is_allow_reply = false;
|
|
5867
|
+
if (comment.is_collapsed) comment.is_allow_reply = false;
|
|
6247
5868
|
const node = opts.createCommentNode(comment, replyComment);
|
|
6248
5869
|
if (comment.visible) {
|
|
6249
5870
|
const $comment = node.getEl();
|
|
6250
5871
|
const $listCommentsWrap = opts.$commentsWrap;
|
|
6251
|
-
if (insertMode === "append")
|
|
6252
|
-
|
|
6253
|
-
if (insertMode === "prepend")
|
|
6254
|
-
$listCommentsWrap == null ? void 0 : $listCommentsWrap.prepend($comment);
|
|
5872
|
+
if (insertMode === "append") $listCommentsWrap == null ? void 0 : $listCommentsWrap.append($comment);
|
|
5873
|
+
if (insertMode === "prepend") $listCommentsWrap == null ? void 0 : $listCommentsWrap.prepend($comment);
|
|
6255
5874
|
node.getRender().playFadeAnim();
|
|
6256
5875
|
}
|
|
6257
5876
|
node.getRender().checkHeightLimit();
|
|
@@ -6356,8 +5975,7 @@ function Detect(userAgent) {
|
|
|
6356
5975
|
dest.language = (() => {
|
|
6357
5976
|
const g = nav.browserLanguage || nav.language;
|
|
6358
5977
|
const arr = g.split("-");
|
|
6359
|
-
if (arr[1])
|
|
6360
|
-
arr[1] = arr[1].toUpperCase();
|
|
5978
|
+
if (arr[1]) arr[1] = arr[1].toUpperCase();
|
|
6361
5979
|
return arr.join("_");
|
|
6362
5980
|
})();
|
|
6363
5981
|
const hash = {
|
|
@@ -6368,8 +5986,7 @@ function Detect(userAgent) {
|
|
|
6368
5986
|
};
|
|
6369
5987
|
Object.entries(hash).forEach(([type, match]) => {
|
|
6370
5988
|
Object.entries(match).forEach(([name, result]) => {
|
|
6371
|
-
if (result === true)
|
|
6372
|
-
dest[type] = name;
|
|
5989
|
+
if (result === true) dest[type] = name;
|
|
6373
5990
|
});
|
|
6374
5991
|
});
|
|
6375
5992
|
const osVersion = {
|
|
@@ -6464,16 +6081,12 @@ function Detect(userAgent) {
|
|
|
6464
6081
|
}
|
|
6465
6082
|
function check(conf, rules) {
|
|
6466
6083
|
rules.forEach(({ el, max, imgCheck }) => {
|
|
6467
|
-
if (!el)
|
|
6468
|
-
|
|
6469
|
-
if (imgCheck)
|
|
6470
|
-
el.style.maxHeight = `${max + 1}px`;
|
|
6084
|
+
if (!el) return;
|
|
6085
|
+
if (imgCheck) el.style.maxHeight = `${max + 1}px`;
|
|
6471
6086
|
let lock = false;
|
|
6472
6087
|
const _check = () => {
|
|
6473
|
-
if (lock)
|
|
6474
|
-
|
|
6475
|
-
if (getHeight(el) <= max)
|
|
6476
|
-
return;
|
|
6088
|
+
if (lock) return;
|
|
6089
|
+
if (getHeight(el) <= max) return;
|
|
6477
6090
|
const afterExpandBtnClick = () => {
|
|
6478
6091
|
var _a;
|
|
6479
6092
|
lock = true;
|
|
@@ -6484,8 +6097,7 @@ function check(conf, rules) {
|
|
|
6484
6097
|
_check();
|
|
6485
6098
|
if (imgCheck) {
|
|
6486
6099
|
const imgs = el.querySelectorAll(".atk-content img");
|
|
6487
|
-
if (imgs.length === 0)
|
|
6488
|
-
el.style.maxHeight = "";
|
|
6100
|
+
if (imgs.length === 0) el.style.maxHeight = "";
|
|
6489
6101
|
imgs.forEach((img) => {
|
|
6490
6102
|
img.onload = () => _check();
|
|
6491
6103
|
});
|
|
@@ -6494,12 +6106,9 @@ function check(conf, rules) {
|
|
|
6494
6106
|
}
|
|
6495
6107
|
const HEIGHT_LIMIT_CSS = "atk-height-limit";
|
|
6496
6108
|
function applyHeightLimit(obj) {
|
|
6497
|
-
if (!obj.el)
|
|
6498
|
-
|
|
6499
|
-
if (
|
|
6500
|
-
return;
|
|
6501
|
-
if (obj.el.classList.contains(HEIGHT_LIMIT_CSS))
|
|
6502
|
-
return;
|
|
6109
|
+
if (!obj.el) return;
|
|
6110
|
+
if (!obj.max) return;
|
|
6111
|
+
if (obj.el.classList.contains(HEIGHT_LIMIT_CSS)) return;
|
|
6503
6112
|
obj.el.classList.add(HEIGHT_LIMIT_CSS);
|
|
6504
6113
|
obj.el.style.height = `${obj.max}px`;
|
|
6505
6114
|
obj.el.style.overflow = "hidden";
|
|
@@ -6509,20 +6118,16 @@ function applyHeightLimit(obj) {
|
|
|
6509
6118
|
$expandBtn.onclick = (e) => {
|
|
6510
6119
|
e.stopPropagation();
|
|
6511
6120
|
disposeHeightLimit(obj.el);
|
|
6512
|
-
if (obj.afterExpandBtnClick)
|
|
6513
|
-
obj.afterExpandBtnClick(e);
|
|
6121
|
+
if (obj.afterExpandBtnClick) obj.afterExpandBtnClick(e);
|
|
6514
6122
|
};
|
|
6515
6123
|
obj.el.append($expandBtn);
|
|
6516
6124
|
}
|
|
6517
6125
|
function disposeHeightLimit($el) {
|
|
6518
|
-
if (!$el)
|
|
6519
|
-
|
|
6520
|
-
if (!$el.classList.contains(HEIGHT_LIMIT_CSS))
|
|
6521
|
-
return;
|
|
6126
|
+
if (!$el) return;
|
|
6127
|
+
if (!$el.classList.contains(HEIGHT_LIMIT_CSS)) return;
|
|
6522
6128
|
$el.classList.remove(HEIGHT_LIMIT_CSS);
|
|
6523
6129
|
Array.from($el.children).forEach((e) => {
|
|
6524
|
-
if (e.classList.contains("atk-height-limit-btn"))
|
|
6525
|
-
e.remove();
|
|
6130
|
+
if (e.classList.contains("atk-height-limit-btn")) e.remove();
|
|
6526
6131
|
});
|
|
6527
6132
|
$el.style.height = "";
|
|
6528
6133
|
$el.style.maxHeight = "";
|
|
@@ -6530,10 +6135,8 @@ function disposeHeightLimit($el) {
|
|
|
6530
6135
|
}
|
|
6531
6136
|
const HEIGHT_LIMIT_SCROLL_CSS = "atk-height-limit-scroll";
|
|
6532
6137
|
function applyScrollableHeightLimit(opt) {
|
|
6533
|
-
if (!opt.el)
|
|
6534
|
-
|
|
6535
|
-
if (opt.el.classList.contains(HEIGHT_LIMIT_SCROLL_CSS))
|
|
6536
|
-
return;
|
|
6138
|
+
if (!opt.el) return;
|
|
6139
|
+
if (opt.el.classList.contains(HEIGHT_LIMIT_SCROLL_CSS)) return;
|
|
6537
6140
|
opt.el.classList.add(HEIGHT_LIMIT_SCROLL_CSS);
|
|
6538
6141
|
opt.el.style.height = `${opt.max}px`;
|
|
6539
6142
|
}
|
|
@@ -6604,8 +6207,7 @@ function renderDate(ctx) {
|
|
|
6604
6207
|
$date.setAttribute("data-atk-comment-date", String(+new Date(ctx.data.date)));
|
|
6605
6208
|
}
|
|
6606
6209
|
function renderUABadge(ctx) {
|
|
6607
|
-
if (!ctx.opts.uaBadge && !ctx.data.ip_region)
|
|
6608
|
-
return;
|
|
6210
|
+
if (!ctx.opts.uaBadge && !ctx.data.ip_region) return;
|
|
6609
6211
|
let $uaWrap = ctx.$header.querySelector("atk-ua-wrap");
|
|
6610
6212
|
if (!$uaWrap) {
|
|
6611
6213
|
$uaWrap = createElement(`<span class="atk-ua-wrap"></span>`);
|
|
@@ -6660,10 +6262,8 @@ function renderContent(r) {
|
|
|
6660
6262
|
});
|
|
6661
6263
|
}
|
|
6662
6264
|
function renderReplyAt(r) {
|
|
6663
|
-
if (r.opts.flatMode || r.data.rid === 0)
|
|
6664
|
-
|
|
6665
|
-
if (!r.opts.replyTo)
|
|
6666
|
-
return;
|
|
6265
|
+
if (r.opts.flatMode || r.data.rid === 0) return;
|
|
6266
|
+
if (!r.opts.replyTo) return;
|
|
6667
6267
|
r.$replyAt = createElement(
|
|
6668
6268
|
`<span class="atk-item atk-reply-at"><span class="atk-arrow"></span><span class="atk-nick"></span></span>`
|
|
6669
6269
|
);
|
|
@@ -6674,10 +6274,8 @@ function renderReplyAt(r) {
|
|
|
6674
6274
|
r.$headerBadgeWrap.insertAdjacentElement("afterend", r.$replyAt);
|
|
6675
6275
|
}
|
|
6676
6276
|
function renderReplyTo(r) {
|
|
6677
|
-
if (!r.opts.flatMode)
|
|
6678
|
-
|
|
6679
|
-
if (!r.opts.replyTo)
|
|
6680
|
-
return;
|
|
6277
|
+
if (!r.opts.flatMode) return;
|
|
6278
|
+
if (!r.opts.replyTo) return;
|
|
6681
6279
|
r.$replyTo = createElement(`
|
|
6682
6280
|
<div class="atk-reply-to">
|
|
6683
6281
|
<div class="atk-meta">${t("reply")} <span class="atk-nick"></span>:</div>
|
|
@@ -6689,14 +6287,12 @@ function renderReplyTo(r) {
|
|
|
6689
6287
|
r.comment.getActions().goToReplyComment();
|
|
6690
6288
|
};
|
|
6691
6289
|
let replyContent = marked(r.opts.replyTo.content);
|
|
6692
|
-
if (r.opts.replyTo.is_collapsed)
|
|
6693
|
-
replyContent = `[${t("collapsed")}]`;
|
|
6290
|
+
if (r.opts.replyTo.is_collapsed) replyContent = `[${t("collapsed")}]`;
|
|
6694
6291
|
r.$replyTo.querySelector(".atk-content").innerHTML = replyContent;
|
|
6695
6292
|
r.$body.prepend(r.$replyTo);
|
|
6696
6293
|
}
|
|
6697
6294
|
function renderPending(r) {
|
|
6698
|
-
if (!r.data.is_pending)
|
|
6699
|
-
return;
|
|
6295
|
+
if (!r.data.is_pending) return;
|
|
6700
6296
|
const pendingEl = createElement(`<div class="atk-pending">${t("pendingMsg")}</div>`);
|
|
6701
6297
|
r.$body.prepend(pendingEl);
|
|
6702
6298
|
}
|
|
@@ -6718,8 +6314,7 @@ class ActionBtn {
|
|
|
6718
6314
|
this.$el = createElement(`<span class="atk-common-action-btn"></span>`);
|
|
6719
6315
|
this.opts = typeof opts !== "object" ? { text: opts } : opts;
|
|
6720
6316
|
this.$el.innerText = this.getText();
|
|
6721
|
-
if (this.opts.adminOnly)
|
|
6722
|
-
this.$el.setAttribute("atk-only-admin-show", "");
|
|
6317
|
+
if (this.opts.adminOnly) this.$el.setAttribute("atk-only-admin-show", "");
|
|
6723
6318
|
}
|
|
6724
6319
|
// 消息显示复原操作
|
|
6725
6320
|
get isMessaging() {
|
|
@@ -6754,8 +6349,7 @@ class ActionBtn {
|
|
|
6754
6349
|
this.confirmRecTimer = window.setTimeout(() => confirmRestore(), 5e3);
|
|
6755
6350
|
return;
|
|
6756
6351
|
}
|
|
6757
|
-
if (this.confirmRecTimer)
|
|
6758
|
-
window.clearTimeout(this.confirmRecTimer);
|
|
6352
|
+
if (this.confirmRecTimer) window.clearTimeout(this.confirmRecTimer);
|
|
6759
6353
|
confirmRestore();
|
|
6760
6354
|
}
|
|
6761
6355
|
if (this.msgRecTimer) {
|
|
@@ -6768,15 +6362,13 @@ class ActionBtn {
|
|
|
6768
6362
|
}
|
|
6769
6363
|
/** 文字刷新(动态/静态) */
|
|
6770
6364
|
updateText(text) {
|
|
6771
|
-
if (text)
|
|
6772
|
-
this.opts.text = text;
|
|
6365
|
+
if (text) this.opts.text = text;
|
|
6773
6366
|
this.setLoading(false);
|
|
6774
6367
|
this.$el.innerText = this.getText();
|
|
6775
6368
|
}
|
|
6776
6369
|
/** 设置加载状态 */
|
|
6777
6370
|
setLoading(value, loadingText) {
|
|
6778
|
-
if (this.isLoading === value)
|
|
6779
|
-
return;
|
|
6371
|
+
if (this.isLoading === value) return;
|
|
6780
6372
|
this.isLoading = value;
|
|
6781
6373
|
if (value) {
|
|
6782
6374
|
this.$el.classList.add("atk-btn-loading");
|
|
@@ -6801,15 +6393,12 @@ class ActionBtn {
|
|
|
6801
6393
|
/** 设置消息 */
|
|
6802
6394
|
setMsg(text, className, duringTime, after) {
|
|
6803
6395
|
this.setLoading(false);
|
|
6804
|
-
if (className)
|
|
6805
|
-
this.$el.classList.add(className);
|
|
6396
|
+
if (className) this.$el.classList.add(className);
|
|
6806
6397
|
this.$el.innerText = text;
|
|
6807
6398
|
this.setMsgRecTimer(() => {
|
|
6808
6399
|
this.$el.innerText = this.getText();
|
|
6809
|
-
if (className)
|
|
6810
|
-
|
|
6811
|
-
if (after)
|
|
6812
|
-
after();
|
|
6400
|
+
if (className) this.$el.classList.remove(className);
|
|
6401
|
+
if (after) after();
|
|
6813
6402
|
}, duringTime || 2500);
|
|
6814
6403
|
}
|
|
6815
6404
|
/** 设置消息复原操作定时器 */
|
|
@@ -6824,13 +6413,11 @@ class ActionBtn {
|
|
|
6824
6413
|
}
|
|
6825
6414
|
/** 立刻触发器复原定时器 */
|
|
6826
6415
|
fireMsgRecTimer() {
|
|
6827
|
-
if (this.msgRecTimerFunc)
|
|
6828
|
-
this.msgRecTimerFunc();
|
|
6416
|
+
if (this.msgRecTimerFunc) this.msgRecTimerFunc();
|
|
6829
6417
|
}
|
|
6830
6418
|
/** 仅清除 timer */
|
|
6831
6419
|
clearMsgRecTimer() {
|
|
6832
|
-
if (this.msgRecTimer)
|
|
6833
|
-
window.clearTimeout(this.msgRecTimer);
|
|
6420
|
+
if (this.msgRecTimer) window.clearTimeout(this.msgRecTimer);
|
|
6834
6421
|
this.msgRecTimer = void 0;
|
|
6835
6422
|
this.msgRecTimerFunc = void 0;
|
|
6836
6423
|
}
|
|
@@ -6850,8 +6437,7 @@ function renderActions(r) {
|
|
|
6850
6437
|
});
|
|
6851
6438
|
}
|
|
6852
6439
|
function renderVote(r) {
|
|
6853
|
-
if (!r.opts.vote)
|
|
6854
|
-
return;
|
|
6440
|
+
if (!r.opts.vote) return;
|
|
6855
6441
|
r.voteBtnUp = new ActionBtn(() => `${t("voteUp")} (${r.data.vote_up || 0})`).appendTo(r.$actions);
|
|
6856
6442
|
r.voteBtnUp.setClick(() => {
|
|
6857
6443
|
r.comment.getActions().vote("up");
|
|
@@ -6866,8 +6452,7 @@ function renderVote(r) {
|
|
|
6866
6452
|
}
|
|
6867
6453
|
}
|
|
6868
6454
|
function renderReply(r) {
|
|
6869
|
-
if (!r.data.is_allow_reply)
|
|
6870
|
-
return;
|
|
6455
|
+
if (!r.data.is_allow_reply) return;
|
|
6871
6456
|
const replyBtn = createElement(`<span>${t("reply")}</span>`);
|
|
6872
6457
|
r.$actions.append(replyBtn);
|
|
6873
6458
|
replyBtn.addEventListener("click", (e) => {
|
|
@@ -6993,8 +6578,7 @@ class Render {
|
|
|
6993
6578
|
/** 内容限高检测 */
|
|
6994
6579
|
checkHeightLimit() {
|
|
6995
6580
|
const conf = this.opts.heightLimit;
|
|
6996
|
-
if (!conf || !conf.content || !conf.children)
|
|
6997
|
-
return;
|
|
6581
|
+
if (!conf || !conf.content || !conf.children) return;
|
|
6998
6582
|
const contentMaxH = conf.content;
|
|
6999
6583
|
const childrenMaxH = conf.children;
|
|
7000
6584
|
check(
|
|
@@ -7017,8 +6601,7 @@ class Render {
|
|
|
7017
6601
|
}
|
|
7018
6602
|
/** 子评论区域移除限高 */
|
|
7019
6603
|
heightLimitRemoveForChildren() {
|
|
7020
|
-
if (!this.$childrenWrap)
|
|
7021
|
-
return;
|
|
6604
|
+
if (!this.$childrenWrap) return;
|
|
7022
6605
|
disposeHeightLimit(this.$childrenWrap);
|
|
7023
6606
|
}
|
|
7024
6607
|
/** 渐出动画 */
|
|
@@ -7046,17 +6629,13 @@ class Render {
|
|
|
7046
6629
|
}
|
|
7047
6630
|
/** 设置已读 */
|
|
7048
6631
|
setUnread(val) {
|
|
7049
|
-
if (val)
|
|
7050
|
-
|
|
7051
|
-
else
|
|
7052
|
-
this.$el.classList.remove("atk-unread");
|
|
6632
|
+
if (val) this.$el.classList.add("atk-unread");
|
|
6633
|
+
else this.$el.classList.remove("atk-unread");
|
|
7053
6634
|
}
|
|
7054
6635
|
/** 设置为可点击的评论 */
|
|
7055
6636
|
setOpenable(val) {
|
|
7056
|
-
if (val)
|
|
7057
|
-
|
|
7058
|
-
else
|
|
7059
|
-
this.$el.classList.remove("atk-openable");
|
|
6637
|
+
if (val) this.$el.classList.add("atk-openable");
|
|
6638
|
+
else this.$el.classList.remove("atk-openable");
|
|
7060
6639
|
}
|
|
7061
6640
|
/** 设置点击评论打开置顶 URL */
|
|
7062
6641
|
setOpenURL(url) {
|
|
@@ -7105,8 +6684,7 @@ class CommentActions {
|
|
|
7105
6684
|
}
|
|
7106
6685
|
/** 管理员 - 评论状态修改 */
|
|
7107
6686
|
adminEdit(type, btnElem) {
|
|
7108
|
-
if (btnElem.isLoading)
|
|
7109
|
-
return;
|
|
6687
|
+
if (btnElem.isLoading) return;
|
|
7110
6688
|
btnElem.setLoading(true, `${t("editing")}...`);
|
|
7111
6689
|
const modify = __spreadValues({}, this.data);
|
|
7112
6690
|
if (type === "collapsed") {
|
|
@@ -7126,13 +6704,11 @@ class CommentActions {
|
|
|
7126
6704
|
}
|
|
7127
6705
|
/** 管理员 - 评论删除 */
|
|
7128
6706
|
adminDelete(btnElem) {
|
|
7129
|
-
if (btnElem.isLoading)
|
|
7130
|
-
return;
|
|
6707
|
+
if (btnElem.isLoading) return;
|
|
7131
6708
|
btnElem.setLoading(true, `${t("deleting")}...`);
|
|
7132
6709
|
this.getApi().comments.deleteComment(this.data.id).then(() => {
|
|
7133
6710
|
btnElem.setLoading(false);
|
|
7134
|
-
if (this.opts.onDelete)
|
|
7135
|
-
this.opts.onDelete(this.comment);
|
|
6711
|
+
if (this.opts.onDelete) this.opts.onDelete(this.comment);
|
|
7136
6712
|
}).catch((e) => {
|
|
7137
6713
|
console.error(e);
|
|
7138
6714
|
btnElem.setError(t("deleteFail"));
|
|
@@ -7143,8 +6719,7 @@ class CommentActions {
|
|
|
7143
6719
|
const origHash = window.location.hash;
|
|
7144
6720
|
const modifyHash = `#atk-comment-${this.data.rid}`;
|
|
7145
6721
|
window.location.hash = modifyHash;
|
|
7146
|
-
if (modifyHash === origHash)
|
|
7147
|
-
window.dispatchEvent(new Event("hashchange"));
|
|
6722
|
+
if (modifyHash === origHash) window.dispatchEvent(new Event("hashchange"));
|
|
7148
6723
|
}
|
|
7149
6724
|
}
|
|
7150
6725
|
class CommentNode {
|
|
@@ -7169,11 +6744,9 @@ class CommentNode {
|
|
|
7169
6744
|
/** 渲染 UI */
|
|
7170
6745
|
render() {
|
|
7171
6746
|
const newEl = this.renderInstance.render();
|
|
7172
|
-
if (this.$el)
|
|
7173
|
-
this.$el.replaceWith(newEl);
|
|
6747
|
+
if (this.$el) this.$el.replaceWith(newEl);
|
|
7174
6748
|
this.$el = newEl;
|
|
7175
|
-
if (this.opts.onAfterRender)
|
|
7176
|
-
this.opts.onAfterRender();
|
|
6749
|
+
if (this.opts.onAfterRender) this.opts.onAfterRender();
|
|
7177
6750
|
}
|
|
7178
6751
|
/** 获取评论操作实例对象 */
|
|
7179
6752
|
getActions() {
|
|
@@ -7220,10 +6793,8 @@ class CommentNode {
|
|
|
7220
6793
|
this.children.push(childNode);
|
|
7221
6794
|
const $childrenWrap = this.getChildrenWrapEl();
|
|
7222
6795
|
const $childComment = childNode.getEl();
|
|
7223
|
-
if (insertMode === "append")
|
|
7224
|
-
|
|
7225
|
-
else if (insertMode === "prepend")
|
|
7226
|
-
$childrenWrap.prepend($childComment);
|
|
6796
|
+
if (insertMode === "append") $childrenWrap.append($childComment);
|
|
6797
|
+
else if (insertMode === "prepend") $childrenWrap.prepend($childComment);
|
|
7227
6798
|
childNode.getRender().playFadeAnim();
|
|
7228
6799
|
childNode.getRender().checkHeightLimit();
|
|
7229
6800
|
}
|
|
@@ -7251,8 +6822,7 @@ class CommentNode {
|
|
|
7251
6822
|
* Please be aware of the memory leak if you use the $el reference directly.
|
|
7252
6823
|
*/
|
|
7253
6824
|
getEl() {
|
|
7254
|
-
if (!this.$el)
|
|
7255
|
-
throw new Error("comment element not initialized before `getEl()`");
|
|
6825
|
+
if (!this.$el) throw new Error("comment element not initialized before `getEl()`");
|
|
7256
6826
|
return this.$el;
|
|
7257
6827
|
}
|
|
7258
6828
|
/**
|
|
@@ -7261,8 +6831,7 @@ class CommentNode {
|
|
|
7261
6831
|
* Scroll to the comment and perform flash animation
|
|
7262
6832
|
*/
|
|
7263
6833
|
focus() {
|
|
7264
|
-
if (!this.$el)
|
|
7265
|
-
throw new Error("comment element not initialized before `focus()`");
|
|
6834
|
+
if (!this.$el) throw new Error("comment element not initialized before `focus()`");
|
|
7266
6835
|
this.getParents().forEach((p) => {
|
|
7267
6836
|
p.getRender().heightLimitRemoveForChildren();
|
|
7268
6837
|
});
|
|
@@ -7293,7 +6862,9 @@ class CommentNode {
|
|
|
7293
6862
|
}
|
|
7294
6863
|
/** 获取格式化后的日期 */
|
|
7295
6864
|
getDateFormatted() {
|
|
7296
|
-
|
|
6865
|
+
var _a, _b;
|
|
6866
|
+
const date = new Date(this.data.date);
|
|
6867
|
+
return ((_b = (_a = this.opts).dateFormatter) == null ? void 0 : _b.call(_a, date)) || timeAgo(date, t);
|
|
7297
6868
|
}
|
|
7298
6869
|
/** 获取用户 UserAgent 信息 */
|
|
7299
6870
|
getUserUA() {
|
|
@@ -7327,6 +6898,7 @@ function createCommentNode(ctx, comment, replyComment, opts) {
|
|
|
7327
6898
|
vote: ctx.conf.vote,
|
|
7328
6899
|
voteDown: ctx.conf.voteDown,
|
|
7329
6900
|
uaBadge: ctx.conf.uaBadge,
|
|
6901
|
+
dateFormatter: ctx.conf.dateFormatter,
|
|
7330
6902
|
// TODO: move to plugin folder and remove from core
|
|
7331
6903
|
getApi: () => ctx.getApi(),
|
|
7332
6904
|
replyComment: (c, $el) => ctx.replyComment(c, $el),
|
|
@@ -7365,8 +6937,7 @@ class ReadMoreBtn {
|
|
|
7365
6937
|
return this.total > this.offset + this.opts.pageSize;
|
|
7366
6938
|
}
|
|
7367
6939
|
click() {
|
|
7368
|
-
if (this.hasMore)
|
|
7369
|
-
this.opts.onClick(this.offset + this.opts.pageSize);
|
|
6940
|
+
if (this.hasMore) this.opts.onClick(this.offset + this.opts.pageSize);
|
|
7370
6941
|
this.checkDisabled();
|
|
7371
6942
|
}
|
|
7372
6943
|
/** 显示 */
|
|
@@ -7399,10 +6970,8 @@ class ReadMoreBtn {
|
|
|
7399
6970
|
this.checkDisabled();
|
|
7400
6971
|
}
|
|
7401
6972
|
checkDisabled() {
|
|
7402
|
-
if (this.hasMore)
|
|
7403
|
-
|
|
7404
|
-
else
|
|
7405
|
-
this.hide();
|
|
6973
|
+
if (this.hasMore) this.show();
|
|
6974
|
+
else this.hide();
|
|
7406
6975
|
}
|
|
7407
6976
|
}
|
|
7408
6977
|
class ReadMorePaginator {
|
|
@@ -7424,8 +6993,7 @@ class ReadMorePaginator {
|
|
|
7424
6993
|
});
|
|
7425
6994
|
if (opt.readMoreAutoLoad) {
|
|
7426
6995
|
this.onReachedBottom = () => {
|
|
7427
|
-
if (!this.instance.hasMore || this.opt.ctx.getData().getLoading())
|
|
7428
|
-
return;
|
|
6996
|
+
if (!this.instance.hasMore || this.opt.ctx.getData().getLoading()) return;
|
|
7429
6997
|
this.instance.click();
|
|
7430
6998
|
};
|
|
7431
6999
|
this.opt.ctx.on("list-reach-bottom", this.onReachedBottom);
|
|
@@ -7531,10 +7099,8 @@ class Pagination {
|
|
|
7531
7099
|
}
|
|
7532
7100
|
this.change(page);
|
|
7533
7101
|
};
|
|
7534
|
-
if (!now)
|
|
7535
|
-
|
|
7536
|
-
else
|
|
7537
|
-
modify();
|
|
7102
|
+
if (!now) this.inputTimer = window.setTimeout(() => modify(), 800);
|
|
7103
|
+
else modify();
|
|
7538
7104
|
}
|
|
7539
7105
|
prev() {
|
|
7540
7106
|
const page = this.page - 1;
|
|
@@ -7593,10 +7159,8 @@ class Pagination {
|
|
|
7593
7159
|
}
|
|
7594
7160
|
/** 加载 */
|
|
7595
7161
|
setLoading(isLoading) {
|
|
7596
|
-
if (isLoading)
|
|
7597
|
-
|
|
7598
|
-
else
|
|
7599
|
-
hideLoading(this.$el);
|
|
7162
|
+
if (isLoading) showLoading(this.$el);
|
|
7163
|
+
else hideLoading(this.$el);
|
|
7600
7164
|
}
|
|
7601
7165
|
}
|
|
7602
7166
|
class UpDownPaginator {
|
|
@@ -7638,26 +7202,22 @@ class UpDownPaginator {
|
|
|
7638
7202
|
}
|
|
7639
7203
|
}
|
|
7640
7204
|
function createPaginatorByConf(conf) {
|
|
7641
|
-
if (conf.pagination.readMore)
|
|
7642
|
-
return new ReadMorePaginator();
|
|
7205
|
+
if (conf.pagination.readMore) return new ReadMorePaginator();
|
|
7643
7206
|
return new UpDownPaginator();
|
|
7644
7207
|
}
|
|
7645
7208
|
function getPageDataByLastData(ctx) {
|
|
7646
7209
|
const last = ctx.getData().getListLastFetch();
|
|
7647
7210
|
const r = { offset: 0, total: 0 };
|
|
7648
|
-
if (!last)
|
|
7649
|
-
return r;
|
|
7211
|
+
if (!last) return r;
|
|
7650
7212
|
r.offset = last.params.offset;
|
|
7651
|
-
if (last.data)
|
|
7652
|
-
r.total = last.params.flatMode ? last.data.count : last.data.roots_count;
|
|
7213
|
+
if (last.data) r.total = last.params.flatMode ? last.data.count : last.data.roots_count;
|
|
7653
7214
|
return r;
|
|
7654
7215
|
}
|
|
7655
7216
|
const initListPaginatorFunc = (ctx) => {
|
|
7656
7217
|
let paginator = null;
|
|
7657
7218
|
ctx.watchConf(["pagination", "locale"], (conf) => {
|
|
7658
7219
|
const list2 = ctx.get("list");
|
|
7659
|
-
if (paginator)
|
|
7660
|
-
paginator.dispose();
|
|
7220
|
+
if (paginator) paginator.dispose();
|
|
7661
7221
|
paginator = createPaginatorByConf(conf);
|
|
7662
7222
|
const { offset, total } = getPageDataByLastData(ctx);
|
|
7663
7223
|
const $paginator = paginator.create({
|
|
@@ -7797,18 +7357,14 @@ class Layer {
|
|
|
7797
7357
|
this.$el.style.display = "";
|
|
7798
7358
|
}
|
|
7799
7359
|
hide() {
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
this.onAfterHide && this.onAfterHide();
|
|
7804
|
-
});
|
|
7360
|
+
this.opts.onHide();
|
|
7361
|
+
this.$el.style.display = "none";
|
|
7362
|
+
this.onAfterHide && this.onAfterHide();
|
|
7805
7363
|
}
|
|
7806
7364
|
destroy() {
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
this.onAfterHide && this.onAfterHide();
|
|
7811
|
-
});
|
|
7365
|
+
this.opts.onHide();
|
|
7366
|
+
this.$el.remove();
|
|
7367
|
+
this.onAfterHide && this.onAfterHide();
|
|
7812
7368
|
}
|
|
7813
7369
|
}
|
|
7814
7370
|
class LayerWrap {
|
|
@@ -7886,11 +7442,12 @@ class User {
|
|
|
7886
7442
|
this.opts = opts;
|
|
7887
7443
|
const localUser = JSON.parse(window.localStorage.getItem(LOCAL_USER_KEY) || "{}");
|
|
7888
7444
|
this.data = {
|
|
7889
|
-
|
|
7445
|
+
name: localUser.name || localUser.nick || "",
|
|
7446
|
+
// nick is deprecated (for historical compatibility)
|
|
7890
7447
|
email: localUser.email || "",
|
|
7891
7448
|
link: localUser.link || "",
|
|
7892
7449
|
token: localUser.token || "",
|
|
7893
|
-
|
|
7450
|
+
is_admin: localUser.is_admin || localUser.isAdmin || false
|
|
7894
7451
|
};
|
|
7895
7452
|
}
|
|
7896
7453
|
getData() {
|
|
@@ -7907,17 +7464,17 @@ class User {
|
|
|
7907
7464
|
/**
|
|
7908
7465
|
* Logout
|
|
7909
7466
|
*
|
|
7910
|
-
* @description Logout will clear login status, but not clear user data (
|
|
7467
|
+
* @description Logout will clear login status, but not clear user data (name, email, link)
|
|
7911
7468
|
*/
|
|
7912
7469
|
logout() {
|
|
7913
7470
|
this.update({
|
|
7914
7471
|
token: "",
|
|
7915
|
-
|
|
7472
|
+
is_admin: false
|
|
7916
7473
|
});
|
|
7917
7474
|
}
|
|
7918
7475
|
/** Check if user has filled basic data */
|
|
7919
7476
|
checkHasBasicUserInfo() {
|
|
7920
|
-
return !!this.data.
|
|
7477
|
+
return !!this.data.name && !!this.data.email;
|
|
7921
7478
|
}
|
|
7922
7479
|
}
|
|
7923
7480
|
const services = {
|
|
@@ -8001,8 +7558,7 @@ function initCountWidget(opt) {
|
|
|
8001
7558
|
}
|
|
8002
7559
|
function incrementPvCount(opt) {
|
|
8003
7560
|
return __async(this, null, function* () {
|
|
8004
|
-
if (!opt.pvAdd || !opt.pageKey)
|
|
8005
|
-
return void 0;
|
|
7561
|
+
if (!opt.pvAdd || !opt.pageKey) return void 0;
|
|
8006
7562
|
const pvCount = (yield opt.getApi().pages.logPv({
|
|
8007
7563
|
page_key: opt.pageKey,
|
|
8008
7564
|
page_title: opt.pageTitle,
|
|
@@ -8020,7 +7576,7 @@ function loadCommentCount(opt) {
|
|
|
8020
7576
|
}
|
|
8021
7577
|
function loadPvCount(opt, cache) {
|
|
8022
7578
|
return __async(this, null, function* () {
|
|
8023
|
-
yield loadStatCount({ opt, query: "page_pv", containers: [opt.pvEl, "#
|
|
7579
|
+
yield loadStatCount({ opt, query: "page_pv", containers: [opt.pvEl, "#ArtalkPV"], cache });
|
|
8024
7580
|
});
|
|
8025
7581
|
}
|
|
8026
7582
|
function loadStatCount(args) {
|
|
@@ -8157,11 +7713,11 @@ class SubmitAddPreset {
|
|
|
8157
7713
|
}
|
|
8158
7714
|
getSubmitAddParams() {
|
|
8159
7715
|
return __async(this, null, function* () {
|
|
8160
|
-
const {
|
|
7716
|
+
const { name, email, link: link2 } = this.kit.useUser().getData();
|
|
8161
7717
|
const conf = this.kit.useConf();
|
|
8162
7718
|
return {
|
|
8163
7719
|
content: this.kit.useEditor().getContentFinal(),
|
|
8164
|
-
name
|
|
7720
|
+
name,
|
|
8165
7721
|
email,
|
|
8166
7722
|
link: link2,
|
|
8167
7723
|
rid: 0,
|
|
@@ -8203,17 +7759,12 @@ class Submit extends EditorPlug {
|
|
|
8203
7759
|
const custom = this.customs.find((o) => o.activeCond());
|
|
8204
7760
|
this.kit.useEditor().showLoading();
|
|
8205
7761
|
try {
|
|
8206
|
-
if (custom == null ? void 0 : custom.pre)
|
|
8207
|
-
custom.pre();
|
|
7762
|
+
if (custom == null ? void 0 : custom.pre) custom.pre();
|
|
8208
7763
|
let nComment;
|
|
8209
|
-
if (custom == null ? void 0 : custom.req)
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
if (custom == null ? void 0 : custom.post)
|
|
8214
|
-
custom.post(nComment);
|
|
8215
|
-
else
|
|
8216
|
-
this.defaultPreset.postSubmitAdd(nComment);
|
|
7764
|
+
if (custom == null ? void 0 : custom.req) nComment = yield custom.req();
|
|
7765
|
+
else nComment = yield this.defaultPreset.reqAdd();
|
|
7766
|
+
if (custom == null ? void 0 : custom.post) custom.post(nComment);
|
|
7767
|
+
else this.defaultPreset.postSubmitAdd(nComment);
|
|
8217
7768
|
} catch (err) {
|
|
8218
7769
|
console.error(err);
|
|
8219
7770
|
this.kit.useEditor().showNotify(`${t("commentFail")}: ${err.message || String(err)}`, "e");
|
|
@@ -8238,15 +7789,13 @@ class StateReply extends EditorPlug {
|
|
|
8238
7789
|
});
|
|
8239
7790
|
this.kit.useEvents().on("mounted", () => {
|
|
8240
7791
|
const submitPlug = this.kit.useDeps(Submit);
|
|
8241
|
-
if (!submitPlug)
|
|
8242
|
-
throw Error("SubmitPlug not initialized");
|
|
7792
|
+
if (!submitPlug) throw Error("SubmitPlug not initialized");
|
|
8243
7793
|
const defaultPreset = new SubmitAddPreset(this.kit);
|
|
8244
7794
|
submitPlug.registerCustom({
|
|
8245
7795
|
activeCond: () => !!this.comment,
|
|
8246
7796
|
// active this custom submit when reply mode
|
|
8247
7797
|
req: () => __async(this, null, function* () {
|
|
8248
|
-
if (!this.comment)
|
|
8249
|
-
throw new Error("reply comment cannot be empty");
|
|
7798
|
+
if (!this.comment) throw new Error("reply comment cannot be empty");
|
|
8250
7799
|
const nComment = (yield this.kit.useApi().comments.createComment(__spreadProps(__spreadValues({}, yield defaultPreset.getSubmitAddParams()), {
|
|
8251
7800
|
rid: this.comment.id,
|
|
8252
7801
|
page_key: this.comment.page_key,
|
|
@@ -8282,8 +7831,7 @@ class StateReply extends EditorPlug {
|
|
|
8282
7831
|
ui.$textarea.focus();
|
|
8283
7832
|
}
|
|
8284
7833
|
cancelReply() {
|
|
8285
|
-
if (!this.comment)
|
|
8286
|
-
return;
|
|
7834
|
+
if (!this.comment) return;
|
|
8287
7835
|
const ui = this.kit.useUI();
|
|
8288
7836
|
if (ui.$sendReplyBtn) {
|
|
8289
7837
|
ui.$sendReplyBtn.remove();
|
|
@@ -8308,15 +7856,14 @@ class StateEdit extends EditorPlug {
|
|
|
8308
7856
|
});
|
|
8309
7857
|
this.kit.useMounted(() => {
|
|
8310
7858
|
const submitPlug = this.kit.useDeps(Submit);
|
|
8311
|
-
if (!submitPlug)
|
|
8312
|
-
throw Error("SubmitPlug not initialized");
|
|
7859
|
+
if (!submitPlug) throw Error("SubmitPlug not initialized");
|
|
8313
7860
|
submitPlug.registerCustom({
|
|
8314
7861
|
activeCond: () => !!this.comment,
|
|
8315
7862
|
// active this custom submit when edit mode
|
|
8316
7863
|
req: () => __async(this, null, function* () {
|
|
8317
7864
|
const saveData = {
|
|
8318
7865
|
content: this.kit.useEditor().getContentFinal(),
|
|
8319
|
-
nick: this.kit.useUI().$
|
|
7866
|
+
nick: this.kit.useUI().$name.value,
|
|
8320
7867
|
email: this.kit.useUI().$email.value,
|
|
8321
7868
|
link: this.kit.useUI().$link.value
|
|
8322
7869
|
};
|
|
@@ -8344,7 +7891,7 @@ class StateEdit extends EditorPlug {
|
|
|
8344
7891
|
}
|
|
8345
7892
|
this.comment = comment;
|
|
8346
7893
|
ui.$header.style.display = "none";
|
|
8347
|
-
ui.$
|
|
7894
|
+
ui.$name.value = comment.nick || "";
|
|
8348
7895
|
ui.$email.value = comment.email || "";
|
|
8349
7896
|
ui.$link.value = comment.link || "";
|
|
8350
7897
|
this.kit.useEditor().setContent(comment.content);
|
|
@@ -8352,16 +7899,15 @@ class StateEdit extends EditorPlug {
|
|
|
8352
7899
|
this.updateSubmitBtnText(t("save"));
|
|
8353
7900
|
}
|
|
8354
7901
|
cancelEdit() {
|
|
8355
|
-
if (!this.comment)
|
|
8356
|
-
return;
|
|
7902
|
+
if (!this.comment) return;
|
|
8357
7903
|
const ui = this.kit.useUI();
|
|
8358
7904
|
if (ui.$editCancelBtn) {
|
|
8359
7905
|
ui.$editCancelBtn.remove();
|
|
8360
7906
|
ui.$editCancelBtn = void 0;
|
|
8361
7907
|
}
|
|
8362
7908
|
this.comment = void 0;
|
|
8363
|
-
const {
|
|
8364
|
-
ui.$
|
|
7909
|
+
const { name, email, link: link2 } = this.kit.useUser().getData();
|
|
7910
|
+
ui.$name.value = name;
|
|
8365
7911
|
ui.$email.value = email;
|
|
8366
7912
|
ui.$link.value = link2;
|
|
8367
7913
|
this.kit.useEditor().setContent("");
|
|
@@ -8401,7 +7947,7 @@ class Closable extends EditorPlug {
|
|
|
8401
7947
|
this.kit.useUI().$textareaWrap.prepend(
|
|
8402
7948
|
createElement(`<div class="atk-comment-closed">${t("onlyAdminCanReply")}</div>`)
|
|
8403
7949
|
);
|
|
8404
|
-
if (!this.kit.useUser().getData().
|
|
7950
|
+
if (!this.kit.useUser().getData().is_admin) {
|
|
8405
7951
|
this.kit.useUI().$textarea.style.display = "none";
|
|
8406
7952
|
this.kit.useEvents().trigger("panel-close");
|
|
8407
7953
|
this.kit.useUI().$bottom.style.display = "none";
|
|
@@ -8450,15 +7996,18 @@ class HeaderUser extends EditorPlug {
|
|
|
8450
7996
|
abortFn: null
|
|
8451
7997
|
});
|
|
8452
7998
|
const onInput = ({ $input, field }) => {
|
|
8453
|
-
if (this.kit.useEditor().getState() === "edit")
|
|
8454
|
-
return;
|
|
7999
|
+
if (this.kit.useEditor().getState() === "edit") return;
|
|
8455
8000
|
this.kit.useUser().update({ [field]: $input.value.trim() });
|
|
8456
|
-
if (field === "
|
|
8457
|
-
|
|
8001
|
+
if (field === "name" || field === "email") this.fetchUserInfo();
|
|
8002
|
+
};
|
|
8003
|
+
const placeholders = {
|
|
8004
|
+
name: t("nick"),
|
|
8005
|
+
email: t("email"),
|
|
8006
|
+
link: t("link")
|
|
8458
8007
|
};
|
|
8459
8008
|
this.kit.useMounted(() => {
|
|
8460
8009
|
Object.entries(this.kit.useEditor().getHeaderInputEls()).forEach(([key, $input]) => {
|
|
8461
|
-
$input.placeholder =
|
|
8010
|
+
$input.placeholder = placeholders[key];
|
|
8462
8011
|
$input.value = this.kit.useUser().getData()[key] || "";
|
|
8463
8012
|
});
|
|
8464
8013
|
this.kit.useEvents().on("header-input", onInput);
|
|
@@ -8472,10 +8021,8 @@ class HeaderUser extends EditorPlug {
|
|
|
8472
8021
|
*/
|
|
8473
8022
|
fetchUserInfo() {
|
|
8474
8023
|
this.kit.useUser().logout();
|
|
8475
|
-
if (this.query.timer)
|
|
8476
|
-
|
|
8477
|
-
if (this.query.abortFn)
|
|
8478
|
-
this.query.abortFn();
|
|
8024
|
+
if (this.query.timer) window.clearTimeout(this.query.timer);
|
|
8025
|
+
if (this.query.abortFn) this.query.abortFn();
|
|
8479
8026
|
this.query.timer = window.setTimeout(() => {
|
|
8480
8027
|
this.query.timer = null;
|
|
8481
8028
|
const api = this.kit.useApi();
|
|
@@ -8499,8 +8046,7 @@ class HeaderUser extends EditorPlug {
|
|
|
8499
8046
|
*/
|
|
8500
8047
|
onUserInfoFetched(data) {
|
|
8501
8048
|
var _a;
|
|
8502
|
-
if (!data.is_login)
|
|
8503
|
-
this.kit.useUser().logout();
|
|
8049
|
+
if (!data.is_login) this.kit.useUser().logout();
|
|
8504
8050
|
this.kit.useGlobalCtx().getData().updateNotifies(data.notifies);
|
|
8505
8051
|
if (this.kit.useUser().checkHasBasicUserInfo() && !data.is_login && ((_a = data.user) == null ? void 0 : _a.is_admin)) {
|
|
8506
8052
|
this.kit.useGlobalCtx().checkAdmin({
|
|
@@ -8518,8 +8064,7 @@ class HeaderLink extends EditorPlug {
|
|
|
8518
8064
|
constructor(kit) {
|
|
8519
8065
|
super(kit);
|
|
8520
8066
|
const onLinkChange = ({ field }) => {
|
|
8521
|
-
if (field === "link")
|
|
8522
|
-
this.onLinkInputChange();
|
|
8067
|
+
if (field === "link") this.onLinkInputChange();
|
|
8523
8068
|
};
|
|
8524
8069
|
this.kit.useMounted(() => {
|
|
8525
8070
|
this.kit.useEvents().on("header-change", onLinkChange);
|
|
@@ -8575,8 +8120,7 @@ class Emoticons extends EditorPlug {
|
|
|
8575
8120
|
}
|
|
8576
8121
|
loadEmoticonsData() {
|
|
8577
8122
|
return __async(this, null, function* () {
|
|
8578
|
-
if (this.isListLoaded)
|
|
8579
|
-
return;
|
|
8123
|
+
if (this.isListLoaded) return;
|
|
8580
8124
|
if (this.loadingTask !== null) {
|
|
8581
8125
|
yield this.loadingTask;
|
|
8582
8126
|
return;
|
|
@@ -8602,10 +8146,8 @@ class Emoticons extends EditorPlug {
|
|
|
8602
8146
|
return [];
|
|
8603
8147
|
}
|
|
8604
8148
|
const pushGrp = (grp) => {
|
|
8605
|
-
if (typeof grp !== "object")
|
|
8606
|
-
|
|
8607
|
-
if (grp.name && data.find((o) => o.name === grp.name))
|
|
8608
|
-
return;
|
|
8149
|
+
if (typeof grp !== "object") return;
|
|
8150
|
+
if (grp.name && data.find((o) => o.name === grp.name)) return;
|
|
8609
8151
|
data.push(grp);
|
|
8610
8152
|
};
|
|
8611
8153
|
const remoteLoad = (d) => __async(this, null, function* () {
|
|
@@ -8617,10 +8159,8 @@ class Emoticons extends EditorPlug {
|
|
|
8617
8159
|
yield remoteLoad(grp);
|
|
8618
8160
|
} else if (typeof grp === "string") {
|
|
8619
8161
|
const grpData = yield this.remoteLoad(grp);
|
|
8620
|
-
if (Array.isArray(grpData))
|
|
8621
|
-
|
|
8622
|
-
else if (typeof grpData === "object")
|
|
8623
|
-
pushGrp(grpData);
|
|
8162
|
+
if (Array.isArray(grpData)) yield remoteLoad(grpData);
|
|
8163
|
+
else if (typeof grpData === "object") pushGrp(grpData);
|
|
8624
8164
|
}
|
|
8625
8165
|
}))
|
|
8626
8166
|
);
|
|
@@ -8649,8 +8189,7 @@ class Emoticons extends EditorPlug {
|
|
|
8649
8189
|
/** 远程加载 */
|
|
8650
8190
|
remoteLoad(url) {
|
|
8651
8191
|
return __async(this, null, function* () {
|
|
8652
|
-
if (!url)
|
|
8653
|
-
return [];
|
|
8192
|
+
if (!url) return [];
|
|
8654
8193
|
try {
|
|
8655
8194
|
const resp = yield fetch(url);
|
|
8656
8195
|
const json = yield resp.json();
|
|
@@ -8667,8 +8206,7 @@ class Emoticons extends EditorPlug {
|
|
|
8667
8206
|
solveNullKey(data) {
|
|
8668
8207
|
data.forEach((grp) => {
|
|
8669
8208
|
grp.items.forEach((item, index) => {
|
|
8670
|
-
if (!item.key)
|
|
8671
|
-
item.key = `${grp.name} ${index + 1}`;
|
|
8209
|
+
if (!item.key) item.key = `${grp.name} ${index + 1}`;
|
|
8672
8210
|
});
|
|
8673
8211
|
});
|
|
8674
8212
|
}
|
|
@@ -8677,14 +8215,10 @@ class Emoticons extends EditorPlug {
|
|
|
8677
8215
|
const tmp = {};
|
|
8678
8216
|
data.forEach((grp) => {
|
|
8679
8217
|
grp.items.forEach((item) => {
|
|
8680
|
-
if (!item.key || String(item.key).trim() === "")
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8684
|
-
else
|
|
8685
|
-
tmp[item.key]++;
|
|
8686
|
-
if (tmp[item.key] > 1)
|
|
8687
|
-
item.key = `${item.key} ${tmp[item.key]}`;
|
|
8218
|
+
if (!item.key || String(item.key).trim() === "") return;
|
|
8219
|
+
if (!tmp[item.key]) tmp[item.key] = 1;
|
|
8220
|
+
else tmp[item.key]++;
|
|
8221
|
+
if (tmp[item.key] > 1) item.key = `${item.key} ${tmp[item.key]}`;
|
|
8688
8222
|
});
|
|
8689
8223
|
});
|
|
8690
8224
|
}
|
|
@@ -8705,8 +8239,7 @@ class Emoticons extends EditorPlug {
|
|
|
8705
8239
|
const iconStr = item.icon;
|
|
8706
8240
|
if (/<(img|IMG)/.test(iconStr)) {
|
|
8707
8241
|
const find = /src=["'](.*?)["']/.exec(iconStr);
|
|
8708
|
-
if (find && find.length > 1)
|
|
8709
|
-
item.icon = find[1];
|
|
8242
|
+
if (find && find.length > 1) item.icon = find[1];
|
|
8710
8243
|
}
|
|
8711
8244
|
nGrp.items.push({
|
|
8712
8245
|
key: item.text || `${grpName} ${index + 1}`,
|
|
@@ -8760,8 +8293,7 @@ class Emoticons extends EditorPlug {
|
|
|
8760
8293
|
this.$grpSwitcher.append($item);
|
|
8761
8294
|
});
|
|
8762
8295
|
}
|
|
8763
|
-
if (this.emoticons.length > 0)
|
|
8764
|
-
this.openGrp(0);
|
|
8296
|
+
if (this.emoticons.length > 0) this.openGrp(0);
|
|
8765
8297
|
}
|
|
8766
8298
|
/** 打开一个表情组 */
|
|
8767
8299
|
openGrp(index) {
|
|
@@ -8782,11 +8314,9 @@ class Emoticons extends EditorPlug {
|
|
|
8782
8314
|
}
|
|
8783
8315
|
/** 处理评论 content 中的表情内容 */
|
|
8784
8316
|
transEmoticonImageText(text) {
|
|
8785
|
-
if (!this.emoticons || !Array.isArray(this.emoticons))
|
|
8786
|
-
return text;
|
|
8317
|
+
if (!this.emoticons || !Array.isArray(this.emoticons)) return text;
|
|
8787
8318
|
this.emoticons.forEach((grp) => {
|
|
8788
|
-
if (grp.type !== "image")
|
|
8789
|
-
return;
|
|
8319
|
+
if (grp.type !== "image") return;
|
|
8790
8320
|
Object.entries(grp.items).forEach(([index, item]) => {
|
|
8791
8321
|
text = text.split(`:[${item.key}]`).join(`<img src="${item.val}" atk-emoticon="${item.key}">`);
|
|
8792
8322
|
});
|
|
@@ -8815,8 +8345,7 @@ class Upload extends EditorPlug {
|
|
|
8815
8345
|
const $input = this.$imgUploadInput;
|
|
8816
8346
|
$input.onchange = () => {
|
|
8817
8347
|
(() => __async(this, null, function* () {
|
|
8818
|
-
if (!$input.files || $input.files.length === 0)
|
|
8819
|
-
return;
|
|
8348
|
+
if (!$input.files || $input.files.length === 0) return;
|
|
8820
8349
|
const file = $input.files[0];
|
|
8821
8350
|
this.uploadImg(file);
|
|
8822
8351
|
}))();
|
|
@@ -8829,8 +8358,7 @@ class Upload extends EditorPlug {
|
|
|
8829
8358
|
}
|
|
8830
8359
|
initDragImg() {
|
|
8831
8360
|
const uploadFromFileList = (files) => {
|
|
8832
|
-
if (!files)
|
|
8833
|
-
return;
|
|
8361
|
+
if (!files) return;
|
|
8834
8362
|
for (let i = 0; i < files.length; i++) {
|
|
8835
8363
|
const file = files[i];
|
|
8836
8364
|
this.uploadImg(file);
|
|
@@ -8870,15 +8398,13 @@ class Upload extends EditorPlug {
|
|
|
8870
8398
|
uploadImg(file) {
|
|
8871
8399
|
return __async(this, null, function* () {
|
|
8872
8400
|
const fileExt = /[^.]+$/.exec(file.name);
|
|
8873
|
-
if (!fileExt || !AllowImgExts.includes(String(fileExt[0]).toLowerCase()))
|
|
8874
|
-
return;
|
|
8401
|
+
if (!fileExt || !AllowImgExts.includes(String(fileExt[0]).toLowerCase())) return;
|
|
8875
8402
|
if (!this.kit.useUser().checkHasBasicUserInfo()) {
|
|
8876
8403
|
this.kit.useEditor().showNotify(t("uploadLoginMsg"), "w");
|
|
8877
8404
|
return;
|
|
8878
8405
|
}
|
|
8879
8406
|
let insertPrefix = "\n";
|
|
8880
|
-
if (this.kit.useUI().$textarea.value.trim() === "")
|
|
8881
|
-
insertPrefix = "";
|
|
8407
|
+
if (this.kit.useUI().$textarea.value.trim() === "") insertPrefix = "";
|
|
8882
8408
|
const uploadPlaceholderTxt = `${insertPrefix}`;
|
|
8883
8409
|
this.kit.useEditor().insertContent(uploadPlaceholderTxt);
|
|
8884
8410
|
let resp;
|
|
@@ -9048,8 +8574,7 @@ class PlugManager {
|
|
|
9048
8574
|
clear() {
|
|
9049
8575
|
this.plugs = [];
|
|
9050
8576
|
this.events = new EventManager();
|
|
9051
|
-
if (this.openedPlug)
|
|
9052
|
-
this.closePlugPanel();
|
|
8577
|
+
if (this.openedPlug) this.closePlugPanel();
|
|
9053
8578
|
}
|
|
9054
8579
|
loadPluginUI() {
|
|
9055
8580
|
this.editor.getUI().$plugPanelWrap.innerHTML = "";
|
|
@@ -9060,8 +8585,7 @@ class PlugManager {
|
|
|
9060
8585
|
/** Load the plug btn and plug panel on editor ui */
|
|
9061
8586
|
loadPluginItem(plug) {
|
|
9062
8587
|
const $btn = plug.$btn;
|
|
9063
|
-
if (!$btn)
|
|
9064
|
-
return;
|
|
8588
|
+
if (!$btn) return;
|
|
9065
8589
|
this.editor.getUI().$plugBtnWrap.appendChild($btn);
|
|
9066
8590
|
!$btn.onclick && ($btn.onclick = () => {
|
|
9067
8591
|
this.editor.getUI().$plugBtnWrap.querySelectorAll(".active").forEach((item) => item.classList.remove("active"));
|
|
@@ -9085,8 +8609,7 @@ class PlugManager {
|
|
|
9085
8609
|
openPlugPanel(plug) {
|
|
9086
8610
|
this.plugs.forEach((aPlug) => {
|
|
9087
8611
|
const plugPanel = aPlug.$panel;
|
|
9088
|
-
if (!plugPanel)
|
|
9089
|
-
return;
|
|
8612
|
+
if (!plugPanel) return;
|
|
9090
8613
|
if (aPlug === plug) {
|
|
9091
8614
|
plugPanel.style.display = "";
|
|
9092
8615
|
this.events.trigger("panel-show", plug);
|
|
@@ -9100,8 +8623,7 @@ class PlugManager {
|
|
|
9100
8623
|
}
|
|
9101
8624
|
/** Close the editor plug panel */
|
|
9102
8625
|
closePlugPanel() {
|
|
9103
|
-
if (!this.openedPlug)
|
|
9104
|
-
return;
|
|
8626
|
+
if (!this.openedPlug) return;
|
|
9105
8627
|
this.editor.getUI().$plugPanelWrap.style.display = "none";
|
|
9106
8628
|
this.events.trigger("panel-hide", this.openedPlug);
|
|
9107
8629
|
this.openedPlug = null;
|
|
@@ -9110,8 +8632,7 @@ class PlugManager {
|
|
|
9110
8632
|
getTransformedContent(rawContent) {
|
|
9111
8633
|
let result = rawContent;
|
|
9112
8634
|
this.plugs.forEach((aPlug) => {
|
|
9113
|
-
if (!aPlug.contentTransformer)
|
|
9114
|
-
return;
|
|
8635
|
+
if (!aPlug.contentTransformer) return;
|
|
9115
8636
|
result = aPlug.contentTransformer(result);
|
|
9116
8637
|
});
|
|
9117
8638
|
return result;
|
|
@@ -9124,8 +8645,7 @@ const WithEditor = (ctx) => {
|
|
|
9124
8645
|
$closeCommentBtn = list2.$el.querySelector('[data-action="admin-close-comment"]');
|
|
9125
8646
|
$closeCommentBtn.addEventListener("click", () => {
|
|
9126
8647
|
const page = ctx.getData().getPage();
|
|
9127
|
-
if (!page)
|
|
9128
|
-
throw new Error("Page data not found");
|
|
8648
|
+
if (!page) throw new Error("Page data not found");
|
|
9129
8649
|
page.admin_only = !page.admin_only;
|
|
9130
8650
|
adminPageEditSave(ctx, page);
|
|
9131
8651
|
});
|
|
@@ -9187,8 +8707,7 @@ const Count = (ctx) => {
|
|
|
9187
8707
|
var _a, _b;
|
|
9188
8708
|
const list2 = ctx.get("list");
|
|
9189
8709
|
const $count = list2.$el.querySelector(".atk-comment-count .atk-text");
|
|
9190
|
-
if (!$count)
|
|
9191
|
-
return;
|
|
8710
|
+
if (!$count) return;
|
|
9192
8711
|
const text = htmlEncode(
|
|
9193
8712
|
t("counter", {
|
|
9194
8713
|
count: `${Number((_b = (_a = ctx.getData().getListLastFetch()) == null ? void 0 : _a.data) == null ? void 0 : _b.count) || 0}`
|
|
@@ -9201,26 +8720,22 @@ const Count = (ctx) => {
|
|
|
9201
8720
|
});
|
|
9202
8721
|
ctx.on("comment-inserted", () => {
|
|
9203
8722
|
const last = ctx.getData().getListLastFetch();
|
|
9204
|
-
if (last == null ? void 0 : last.data)
|
|
9205
|
-
last.data.count += 1;
|
|
8723
|
+
if (last == null ? void 0 : last.data) last.data.count += 1;
|
|
9206
8724
|
});
|
|
9207
8725
|
ctx.on("comment-deleted", () => {
|
|
9208
8726
|
const last = ctx.getData().getListLastFetch();
|
|
9209
|
-
if (last == null ? void 0 : last.data)
|
|
9210
|
-
last.data.count -= 1;
|
|
8727
|
+
if (last == null ? void 0 : last.data) last.data.count -= 1;
|
|
9211
8728
|
});
|
|
9212
8729
|
};
|
|
9213
8730
|
const SidebarBtn = (ctx) => {
|
|
9214
8731
|
let $openSidebarBtn = null;
|
|
9215
8732
|
const syncByUser = () => {
|
|
9216
|
-
if (!$openSidebarBtn)
|
|
9217
|
-
return;
|
|
8733
|
+
if (!$openSidebarBtn) return;
|
|
9218
8734
|
const user = ctx.get("user").getData();
|
|
9219
|
-
if (!!user.
|
|
8735
|
+
if (!!user.name && !!user.email) {
|
|
9220
8736
|
$openSidebarBtn.classList.remove("atk-hide");
|
|
9221
8737
|
const $btnText = $openSidebarBtn.querySelector(".atk-text");
|
|
9222
|
-
if ($btnText)
|
|
9223
|
-
$btnText.innerText = !user.isAdmin ? t("msgCenter") : t("ctrlCenter");
|
|
8738
|
+
if ($btnText) $btnText.innerText = !user.is_admin ? t("msgCenter") : t("ctrlCenter");
|
|
9224
8739
|
} else {
|
|
9225
8740
|
$openSidebarBtn.classList.add("atk-hide");
|
|
9226
8741
|
}
|
|
@@ -9228,8 +8743,7 @@ const SidebarBtn = (ctx) => {
|
|
|
9228
8743
|
ctx.watchConf(["locale"], (conf) => {
|
|
9229
8744
|
const list2 = ctx.get("list");
|
|
9230
8745
|
$openSidebarBtn = list2.$el.querySelector('[data-action="open-sidebar"]');
|
|
9231
|
-
if (!$openSidebarBtn)
|
|
9232
|
-
return;
|
|
8746
|
+
if (!$openSidebarBtn) return;
|
|
9233
8747
|
$openSidebarBtn.onclick = () => {
|
|
9234
8748
|
ctx.showSidebar();
|
|
9235
8749
|
};
|
|
@@ -9242,8 +8756,7 @@ const SidebarBtn = (ctx) => {
|
|
|
9242
8756
|
const UnreadBadge = (ctx) => {
|
|
9243
8757
|
let $unreadBadge = null;
|
|
9244
8758
|
const showUnreadBadge = (count) => {
|
|
9245
|
-
if (!$unreadBadge)
|
|
9246
|
-
return;
|
|
8759
|
+
if (!$unreadBadge) return;
|
|
9247
8760
|
if (count > 0) {
|
|
9248
8761
|
$unreadBadge.innerText = `${Number(count || 0)}`;
|
|
9249
8762
|
$unreadBadge.style.display = "block";
|
|
@@ -9263,10 +8776,8 @@ const GotoDispatcher = (ctx) => {
|
|
|
9263
8776
|
let lastID = 0;
|
|
9264
8777
|
const check2 = ({ locker }) => {
|
|
9265
8778
|
const commentID = extractCommentID();
|
|
9266
|
-
if (!commentID)
|
|
9267
|
-
|
|
9268
|
-
if (locker && lastID === commentID)
|
|
9269
|
-
return;
|
|
8779
|
+
if (!commentID) return;
|
|
8780
|
+
if (locker && lastID === commentID) return;
|
|
9270
8781
|
lastID = commentID;
|
|
9271
8782
|
ctx.trigger("list-goto", commentID);
|
|
9272
8783
|
};
|
|
@@ -9297,18 +8808,16 @@ const GotoFocus = (ctx) => {
|
|
|
9297
8808
|
ctx.get("list").getListLayout({ forceFlatMode: true }).insert(data.comment, data.reply_comment);
|
|
9298
8809
|
comment = ctx.getCommentNodes().find((c) => c.getID() === commentID);
|
|
9299
8810
|
}
|
|
9300
|
-
if (!comment)
|
|
9301
|
-
return;
|
|
8811
|
+
if (!comment) return;
|
|
9302
8812
|
comment.focus();
|
|
9303
8813
|
}));
|
|
9304
8814
|
};
|
|
9305
|
-
const version = "2.
|
|
8815
|
+
const version = "2.9.1";
|
|
9306
8816
|
const Copyright = (ctx) => {
|
|
9307
8817
|
ctx.on("mounted", () => {
|
|
9308
8818
|
const list2 = ctx.get("list");
|
|
9309
8819
|
const $copyright = list2.$el.querySelector(".atk-copyright");
|
|
9310
|
-
if (!$copyright)
|
|
9311
|
-
return;
|
|
8820
|
+
if (!$copyright) return;
|
|
9312
8821
|
$copyright.innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${version}">Artalk</a>`;
|
|
9313
8822
|
});
|
|
9314
8823
|
};
|
|
@@ -9375,8 +8884,7 @@ const Dropdown = (ctx) => {
|
|
|
9375
8884
|
ctx.watchConf(["listSort", "locale"], (conf) => {
|
|
9376
8885
|
const list2 = ctx.get("list");
|
|
9377
8886
|
const $count = list2.$el.querySelector(".atk-comment-count");
|
|
9378
|
-
if (!$count)
|
|
9379
|
-
return;
|
|
8887
|
+
if (!$count) return;
|
|
9380
8888
|
if (conf.listSort) {
|
|
9381
8889
|
initDropdown($count);
|
|
9382
8890
|
} else {
|
|
@@ -9388,8 +8896,7 @@ const Dropdown = (ctx) => {
|
|
|
9388
8896
|
};
|
|
9389
8897
|
function renderDropdown(conf) {
|
|
9390
8898
|
const { $dropdownWrap, dropdownList } = conf;
|
|
9391
|
-
if ($dropdownWrap.querySelector(".atk-dropdown"))
|
|
9392
|
-
return;
|
|
8899
|
+
if ($dropdownWrap.querySelector(".atk-dropdown")) return;
|
|
9393
8900
|
$dropdownWrap.classList.add("atk-dropdown-wrap");
|
|
9394
8901
|
$dropdownWrap.append(createElement(`<span class="atk-arrow-down-icon"></span>`));
|
|
9395
8902
|
let curtActive = 0;
|
|
@@ -9415,8 +8922,7 @@ function renderDropdown(conf) {
|
|
|
9415
8922
|
onItemClick(i, $item, name, action);
|
|
9416
8923
|
};
|
|
9417
8924
|
$dropdown.append($item);
|
|
9418
|
-
if (i === curtActive)
|
|
9419
|
-
$item.classList.add("active");
|
|
8925
|
+
if (i === curtActive) $item.classList.add("active");
|
|
9420
8926
|
});
|
|
9421
8927
|
$dropdownWrap.append($dropdown);
|
|
9422
8928
|
}
|
|
@@ -9433,8 +8939,9 @@ const TimeTicking = (ctx) => {
|
|
|
9433
8939
|
timer = window.setInterval(() => {
|
|
9434
8940
|
const list2 = ctx.get("list");
|
|
9435
8941
|
list2.$el.querySelectorAll("[data-atk-comment-date]").forEach((el) => {
|
|
9436
|
-
|
|
9437
|
-
|
|
8942
|
+
var _a, _b;
|
|
8943
|
+
const date = new Date(Number(el.getAttribute("data-atk-comment-date")));
|
|
8944
|
+
el.innerText = ((_b = (_a = ctx.getConf()).dateFormatter) == null ? void 0 : _b.call(_a, date)) || timeAgo(date, ctx.$t);
|
|
9438
8945
|
});
|
|
9439
8946
|
}, 30 * 1e3);
|
|
9440
8947
|
});
|
|
@@ -9487,8 +8994,7 @@ const Loading = (ctx) => {
|
|
|
9487
8994
|
};
|
|
9488
8995
|
const Fetch = (ctx) => {
|
|
9489
8996
|
ctx.on("list-fetch", (_params) => {
|
|
9490
|
-
if (ctx.getData().getLoading())
|
|
9491
|
-
return;
|
|
8997
|
+
if (ctx.getData().getLoading()) return;
|
|
9492
8998
|
ctx.getData().setLoading(true);
|
|
9493
8999
|
const params = __spreadValues({
|
|
9494
9000
|
// default params
|
|
@@ -9508,8 +9014,7 @@ const Fetch = (ctx) => {
|
|
|
9508
9014
|
page_key: ctx.getConf().pageKey,
|
|
9509
9015
|
site_name: ctx.getConf().site
|
|
9510
9016
|
};
|
|
9511
|
-
if (params.paramsModifier)
|
|
9512
|
-
params.paramsModifier(reqParams);
|
|
9017
|
+
if (params.paramsModifier) params.paramsModifier(reqParams);
|
|
9513
9018
|
ctx.getApi().comments.getComments(__spreadValues(__spreadValues({}, reqParams), ctx.getApi().getUserFields())).then(({ data }) => {
|
|
9514
9019
|
ctx.getData().setListLastFetch({ params, data });
|
|
9515
9020
|
ctx.getData().loadComments(data.comments);
|
|
@@ -9560,8 +9065,7 @@ const ReachBottom = (ctx) => {
|
|
|
9560
9065
|
const list2 = ctx.get("list");
|
|
9561
9066
|
const children = list2.getCommentsWrapEl().childNodes;
|
|
9562
9067
|
const $target = children.length > 2 ? children[children.length - 2] : null;
|
|
9563
|
-
if (!$target)
|
|
9564
|
-
return;
|
|
9068
|
+
if (!$target) return;
|
|
9565
9069
|
if (!("IntersectionObserver" in window)) {
|
|
9566
9070
|
console.warn("IntersectionObserver api not supported");
|
|
9567
9071
|
return;
|
|
@@ -9608,11 +9112,9 @@ const ListPlugins = [
|
|
|
9608
9112
|
];
|
|
9609
9113
|
const Notifies = (ctx) => {
|
|
9610
9114
|
ctx.on("list-fetch", (params) => {
|
|
9611
|
-
if (params.offset !== 0)
|
|
9612
|
-
return;
|
|
9115
|
+
if (params.offset !== 0) return;
|
|
9613
9116
|
const user = ctx.getApi().getUserFields();
|
|
9614
|
-
if (!user)
|
|
9615
|
-
return;
|
|
9117
|
+
if (!user) return;
|
|
9616
9118
|
ctx.getApi().notifies.getNotifies(user).then((res) => {
|
|
9617
9119
|
ctx.getData().updateNotifies(res.data.notifies);
|
|
9618
9120
|
});
|
|
@@ -9629,8 +9131,7 @@ const VersionCheck = (ctx) => {
|
|
|
9629
9131
|
function versionCheck(list2, feVer, beVer) {
|
|
9630
9132
|
const comp = versionCompare(feVer, beVer);
|
|
9631
9133
|
const sameVer = comp === 0;
|
|
9632
|
-
if (sameVer)
|
|
9633
|
-
return;
|
|
9134
|
+
if (sameVer) return;
|
|
9634
9135
|
const errEl = createElement(
|
|
9635
9136
|
`<div class="atk-version-check-notice">${t("updateMsg", {
|
|
9636
9137
|
name: comp < 0 ? t("frontend") : t("backend")
|
|
@@ -9647,7 +9148,7 @@ function versionCheck(list2, feVer, beVer) {
|
|
|
9647
9148
|
const AdminOnlyElem = (ctx) => {
|
|
9648
9149
|
const scanApply = () => {
|
|
9649
9150
|
applyAdminOnlyEls(
|
|
9650
|
-
ctx.get("user").getData().
|
|
9151
|
+
ctx.get("user").getData().is_admin,
|
|
9651
9152
|
getAdminOnlyEls({
|
|
9652
9153
|
$root: ctx.$root
|
|
9653
9154
|
})
|
|
@@ -9670,20 +9171,16 @@ function getAdminOnlyEls(opts) {
|
|
|
9670
9171
|
}
|
|
9671
9172
|
function applyAdminOnlyEls(isAdmin, els) {
|
|
9672
9173
|
els.forEach(($item) => {
|
|
9673
|
-
if (isAdmin)
|
|
9674
|
-
|
|
9675
|
-
else
|
|
9676
|
-
$item.classList.add("atk-hide");
|
|
9174
|
+
if (isAdmin) $item.classList.remove("atk-hide");
|
|
9175
|
+
else $item.classList.add("atk-hide");
|
|
9677
9176
|
});
|
|
9678
9177
|
}
|
|
9679
9178
|
let darkModeMedia;
|
|
9680
9179
|
function updateClassnames($els, darkMode) {
|
|
9681
9180
|
const DarkModeClassName = "atk-dark-mode";
|
|
9682
9181
|
$els.forEach(($el) => {
|
|
9683
|
-
if (darkMode)
|
|
9684
|
-
|
|
9685
|
-
else
|
|
9686
|
-
$el.classList.remove(DarkModeClassName);
|
|
9182
|
+
if (darkMode) $el.classList.add(DarkModeClassName);
|
|
9183
|
+
else $el.classList.remove(DarkModeClassName);
|
|
9687
9184
|
});
|
|
9688
9185
|
}
|
|
9689
9186
|
const DarkMode = (ctx) => {
|
|
@@ -9725,6 +9222,7 @@ const DefaultPlugins = [
|
|
|
9725
9222
|
DarkMode
|
|
9726
9223
|
];
|
|
9727
9224
|
const GlobalPlugins = /* @__PURE__ */ new Set([...DefaultPlugins]);
|
|
9225
|
+
const PluginOptions = /* @__PURE__ */ new WeakMap();
|
|
9728
9226
|
function load(ctx) {
|
|
9729
9227
|
return __async(this, null, function* () {
|
|
9730
9228
|
var _a;
|
|
@@ -9732,7 +9230,7 @@ function load(ctx) {
|
|
|
9732
9230
|
const loadPlugins = (plugins) => {
|
|
9733
9231
|
plugins.forEach((plugin) => {
|
|
9734
9232
|
if (typeof plugin === "function" && !loadedPlugins.has(plugin)) {
|
|
9735
|
-
plugin(ctx);
|
|
9233
|
+
plugin(ctx, PluginOptions.get(plugin));
|
|
9736
9234
|
loadedPlugins.add(plugin);
|
|
9737
9235
|
}
|
|
9738
9236
|
});
|
|
@@ -9770,14 +9268,13 @@ function load(ctx) {
|
|
|
9770
9268
|
function loadNetworkPlugins(scripts, apiBase) {
|
|
9771
9269
|
return __async(this, null, function* () {
|
|
9772
9270
|
const networkPlugins = /* @__PURE__ */ new Set();
|
|
9773
|
-
if (!scripts || !Array.isArray(scripts))
|
|
9774
|
-
return networkPlugins;
|
|
9271
|
+
if (!scripts || !Array.isArray(scripts)) return networkPlugins;
|
|
9775
9272
|
const tasks = [];
|
|
9776
9273
|
scripts.forEach((url) => {
|
|
9777
9274
|
if (!/^(http|https):\/\//.test(url))
|
|
9778
9275
|
url = `${apiBase.replace(/\/$/, "")}/${url.replace(/^\//, "")}`;
|
|
9779
9276
|
tasks.push(
|
|
9780
|
-
new Promise((resolve
|
|
9277
|
+
new Promise((resolve) => {
|
|
9781
9278
|
if (document.querySelector(`script[src="${url}"]`)) {
|
|
9782
9279
|
resolve();
|
|
9783
9280
|
return;
|
|
@@ -9786,14 +9283,16 @@ function loadNetworkPlugins(scripts, apiBase) {
|
|
|
9786
9283
|
script.src = url;
|
|
9787
9284
|
document.head.appendChild(script);
|
|
9788
9285
|
script.onload = () => resolve();
|
|
9789
|
-
script.onerror = (err) =>
|
|
9286
|
+
script.onerror = (err) => {
|
|
9287
|
+
console.error("[artalk] Failed to load plugin", err);
|
|
9288
|
+
resolve();
|
|
9289
|
+
};
|
|
9790
9290
|
})
|
|
9791
9291
|
);
|
|
9792
9292
|
});
|
|
9793
9293
|
yield Promise.all(tasks);
|
|
9794
9294
|
Object.values(window.ArtalkPlugins || {}).forEach((plugin) => {
|
|
9795
|
-
if (typeof plugin === "function")
|
|
9796
|
-
networkPlugins.add(plugin);
|
|
9295
|
+
if (typeof plugin === "function") networkPlugins.add(plugin);
|
|
9797
9296
|
});
|
|
9798
9297
|
return networkPlugins;
|
|
9799
9298
|
});
|
|
@@ -9813,7 +9312,7 @@ function onLoadErr(ctx, err) {
|
|
|
9813
9312
|
errMsg: err.msg || String(err),
|
|
9814
9313
|
errData: err.data,
|
|
9815
9314
|
retryFn: () => load(ctx),
|
|
9816
|
-
onOpenSidebar: ctx.get("user").getData().
|
|
9315
|
+
onOpenSidebar: ctx.get("user").getData().is_admin ? () => ctx.showSidebar({
|
|
9817
9316
|
view: sidebarOpenView
|
|
9818
9317
|
}) : void 0
|
|
9819
9318
|
// only show open sidebar button when user is admin
|
|
@@ -9880,8 +9379,9 @@ class Artalk {
|
|
|
9880
9379
|
return new Artalk(conf);
|
|
9881
9380
|
}
|
|
9882
9381
|
/** Use plugin, the plugin will be used when Artalk.init */
|
|
9883
|
-
static use(plugin) {
|
|
9382
|
+
static use(plugin, options) {
|
|
9884
9383
|
GlobalPlugins.add(plugin);
|
|
9384
|
+
PluginOptions.set(plugin, options);
|
|
9885
9385
|
}
|
|
9886
9386
|
/** Load count widget */
|
|
9887
9387
|
static loadCountWidget(c) {
|