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.
Files changed (44) hide show
  1. package/dist/Artalk.cjs +2 -2
  2. package/dist/Artalk.cjs.map +1 -1
  3. package/dist/Artalk.css +1 -1
  4. package/dist/Artalk.iife.js +2 -2
  5. package/dist/Artalk.iife.js.map +1 -1
  6. package/dist/Artalk.js +2 -2
  7. package/dist/Artalk.js.map +1 -1
  8. package/dist/Artalk.mjs +630 -1130
  9. package/dist/Artalk.mjs.map +1 -1
  10. package/dist/ArtalkLite.cjs +2 -2
  11. package/dist/ArtalkLite.cjs.map +1 -1
  12. package/dist/ArtalkLite.css +1 -1
  13. package/dist/ArtalkLite.iife.js +2 -2
  14. package/dist/ArtalkLite.iife.js.map +1 -1
  15. package/dist/ArtalkLite.js +2 -2
  16. package/dist/ArtalkLite.js.map +1 -1
  17. package/dist/ArtalkLite.mjs +325 -868
  18. package/dist/ArtalkLite.mjs.map +1 -1
  19. package/dist/i18n/fr.cjs +1 -0
  20. package/dist/i18n/fr.js +1 -0
  21. package/dist/i18n/fr.mjs +123 -0
  22. package/dist/i18n/{jp.cjs → ja.cjs} +1 -1
  23. package/dist/i18n/ja.d.cts +3 -0
  24. package/dist/i18n/ja.d.ts +3 -0
  25. package/dist/i18n/{jp.js → ja.js} +1 -1
  26. package/dist/i18n/{jp.mjs → ja.mjs} +12 -9
  27. package/dist/i18n/ko.cjs +1 -0
  28. package/dist/i18n/ko.d.cts +3 -0
  29. package/dist/i18n/ko.d.ts +3 -0
  30. package/dist/i18n/ko.js +1 -0
  31. package/dist/i18n/ko.mjs +123 -0
  32. package/dist/i18n/ru.cjs +1 -0
  33. package/dist/i18n/ru.d.cts +3 -0
  34. package/dist/i18n/ru.d.ts +3 -0
  35. package/dist/i18n/ru.js +1 -0
  36. package/dist/i18n/ru.mjs +123 -0
  37. package/dist/i18n/zh-TW.cjs +1 -1
  38. package/dist/i18n/zh-TW.js +1 -1
  39. package/dist/i18n/zh-TW.mjs +6 -3
  40. package/dist/main.d.cts +146 -85
  41. package/dist/main.d.ts +146 -85
  42. package/package.json +49 -15
  43. /package/dist/i18n/{jp.d.cts → fr.d.cts} +0 -0
  44. /package/dist/i18n/{jp.d.ts → fr.d.ts} +0 -0
@@ -29,10 +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
- };
32
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
36
33
  var __async = (__this, __arguments, generator) => {
37
34
  return new Promise((resolve, reject) => {
38
35
  var fulfilled = (value) => {
@@ -53,7 +50,7 @@ var __async = (__this, __arguments, generator) => {
53
50
  step((generator = generator.apply(__this, __arguments)).next());
54
51
  });
55
52
  };
56
- import { marked as marked$1 } from "marked";
53
+ import { marked as marked$1, Marked } from "marked";
57
54
  class HttpClient {
58
55
  constructor(apiConfig = {}) {
59
56
  __publicField(this, "baseUrl", "/api/v2");
@@ -150,7 +147,7 @@ class HttpClient {
150
147
  body: typeof body === "undefined" || body === null ? null : payloadFormatter(body)
151
148
  })
152
149
  ).then((response) => __async(this, null, function* () {
153
- const r = response;
150
+ const r = response.clone();
154
151
  r.data = null;
155
152
  r.error = null;
156
153
  const data = !responseFormat ? r : yield response[responseFormat]().then((data2) => {
@@ -167,8 +164,7 @@ class HttpClient {
167
164
  if (cancelToken) {
168
165
  this.abortControllers.delete(cancelToken);
169
166
  }
170
- if (!response.ok)
171
- throw data;
167
+ if (!response.ok) throw data;
172
168
  return data;
173
169
  }));
174
170
  }));
@@ -240,7 +236,7 @@ let Api$1 = class Api extends HttpClient {
240
236
  format: "json"
241
237
  }, params)),
242
238
  /**
243
- * @description Register by email and verify code (if user exists, will update user, like forget password. Need send email verify code first)
239
+ * @description Register by email and verify code (if user exists, will update user, like forget or change password. Need send email verify code first)
244
240
  *
245
241
  * @tags Auth
246
242
  * @name RegisterByEmail
@@ -1219,6 +1215,32 @@ let Api$1 = class Api extends HttpClient {
1219
1215
  secure: true,
1220
1216
  format: "json"
1221
1217
  }, params)),
1218
+ /**
1219
+ * @description Update user profile when user is logged in
1220
+ *
1221
+ * @tags Auth
1222
+ * @name UpdateProfile
1223
+ * @summary Update user profile
1224
+ * @request POST:/user
1225
+ * @secure
1226
+ * @response `200` `HandlerResponseUserInfoUpdate` OK
1227
+ * @response `400` `(HandlerMap & {
1228
+ msg?: string,
1229
+
1230
+ })` Bad Request
1231
+ * @response `500` `(HandlerMap & {
1232
+ msg?: string,
1233
+
1234
+ })` Internal Server Error
1235
+ */
1236
+ updateProfile: (data, params = {}) => this.request(__spreadValues({
1237
+ path: `/user`,
1238
+ method: "POST",
1239
+ body: data,
1240
+ secure: true,
1241
+ type: "application/json",
1242
+ format: "json"
1243
+ }, params)),
1222
1244
  /**
1223
1245
  * @description Login user by name or email
1224
1246
  *
@@ -1453,411 +1475,12 @@ let Api$1 = class Api extends HttpClient {
1453
1475
  });
1454
1476
  }
1455
1477
  };
1456
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1457
- function getDefaultExportFromCjs(x) {
1458
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1459
- }
1460
- (function(factory) {
1461
- factory();
1462
- })(function() {
1463
- function _classCallCheck(instance2, Constructor) {
1464
- if (!(instance2 instanceof Constructor)) {
1465
- throw new TypeError("Cannot call a class as a function");
1466
- }
1467
- }
1468
- function _defineProperties(target, props) {
1469
- for (var i = 0; i < props.length; i++) {
1470
- var descriptor = props[i];
1471
- descriptor.enumerable = descriptor.enumerable || false;
1472
- descriptor.configurable = true;
1473
- if ("value" in descriptor)
1474
- descriptor.writable = true;
1475
- Object.defineProperty(target, descriptor.key, descriptor);
1476
- }
1477
- }
1478
- function _createClass(Constructor, protoProps, staticProps) {
1479
- if (protoProps)
1480
- _defineProperties(Constructor.prototype, protoProps);
1481
- Object.defineProperty(Constructor, "prototype", {
1482
- writable: false
1483
- });
1484
- return Constructor;
1485
- }
1486
- function _inherits(subClass, superClass) {
1487
- if (typeof superClass !== "function" && superClass !== null) {
1488
- throw new TypeError("Super expression must either be null or a function");
1489
- }
1490
- subClass.prototype = Object.create(superClass && superClass.prototype, {
1491
- constructor: {
1492
- value: subClass,
1493
- writable: true,
1494
- configurable: true
1495
- }
1496
- });
1497
- Object.defineProperty(subClass, "prototype", {
1498
- writable: false
1499
- });
1500
- if (superClass)
1501
- _setPrototypeOf(subClass, superClass);
1502
- }
1503
- function _getPrototypeOf(o) {
1504
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
1505
- return o2.__proto__ || Object.getPrototypeOf(o2);
1506
- };
1507
- return _getPrototypeOf(o);
1508
- }
1509
- function _setPrototypeOf(o, p) {
1510
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
1511
- o2.__proto__ = p2;
1512
- return o2;
1513
- };
1514
- return _setPrototypeOf(o, p);
1515
- }
1516
- function _isNativeReflectConstruct() {
1517
- if (typeof Reflect === "undefined" || !Reflect.construct)
1518
- return false;
1519
- if (Reflect.construct.sham)
1520
- return false;
1521
- if (typeof Proxy === "function")
1522
- return true;
1523
- try {
1524
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
1525
- }));
1526
- return true;
1527
- } catch (e) {
1528
- return false;
1529
- }
1530
- }
1531
- function _assertThisInitialized(self2) {
1532
- if (self2 === void 0) {
1533
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1534
- }
1535
- return self2;
1536
- }
1537
- function _possibleConstructorReturn(self2, call) {
1538
- if (call && (typeof call === "object" || typeof call === "function")) {
1539
- return call;
1540
- } else if (call !== void 0) {
1541
- throw new TypeError("Derived constructors may only return object or undefined");
1542
- }
1543
- return _assertThisInitialized(self2);
1544
- }
1545
- function _createSuper(Derived) {
1546
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
1547
- return function _createSuperInternal() {
1548
- var Super = _getPrototypeOf(Derived), result;
1549
- if (hasNativeReflectConstruct) {
1550
- var NewTarget = _getPrototypeOf(this).constructor;
1551
- result = Reflect.construct(Super, arguments, NewTarget);
1552
- } else {
1553
- result = Super.apply(this, arguments);
1554
- }
1555
- return _possibleConstructorReturn(this, result);
1556
- };
1557
- }
1558
- function _superPropBase(object, property) {
1559
- while (!Object.prototype.hasOwnProperty.call(object, property)) {
1560
- object = _getPrototypeOf(object);
1561
- if (object === null)
1562
- break;
1563
- }
1564
- return object;
1565
- }
1566
- function _get() {
1567
- if (typeof Reflect !== "undefined" && Reflect.get) {
1568
- _get = Reflect.get.bind();
1569
- } else {
1570
- _get = function _get2(target, property, receiver) {
1571
- var base = _superPropBase(target, property);
1572
- if (!base)
1573
- return;
1574
- var desc = Object.getOwnPropertyDescriptor(base, property);
1575
- if (desc.get) {
1576
- return desc.get.call(arguments.length < 3 ? target : receiver);
1577
- }
1578
- return desc.value;
1579
- };
1580
- }
1581
- return _get.apply(this, arguments);
1582
- }
1583
- var Emitter = /* @__PURE__ */ function() {
1584
- function Emitter2() {
1585
- _classCallCheck(this, Emitter2);
1586
- Object.defineProperty(this, "listeners", {
1587
- value: {},
1588
- writable: true,
1589
- configurable: true
1590
- });
1591
- }
1592
- _createClass(Emitter2, [{
1593
- key: "addEventListener",
1594
- value: function addEventListener(type, callback, options) {
1595
- if (!(type in this.listeners)) {
1596
- this.listeners[type] = [];
1597
- }
1598
- this.listeners[type].push({
1599
- callback,
1600
- options
1601
- });
1602
- }
1603
- }, {
1604
- key: "removeEventListener",
1605
- value: function removeEventListener(type, callback) {
1606
- if (!(type in this.listeners)) {
1607
- return;
1608
- }
1609
- var stack = this.listeners[type];
1610
- for (var i = 0, l = stack.length; i < l; i++) {
1611
- if (stack[i].callback === callback) {
1612
- stack.splice(i, 1);
1613
- return;
1614
- }
1615
- }
1616
- }
1617
- }, {
1618
- key: "dispatchEvent",
1619
- value: function dispatchEvent(event) {
1620
- if (!(event.type in this.listeners)) {
1621
- return;
1622
- }
1623
- var stack = this.listeners[event.type];
1624
- var stackToCall = stack.slice();
1625
- for (var i = 0, l = stackToCall.length; i < l; i++) {
1626
- var listener = stackToCall[i];
1627
- try {
1628
- listener.callback.call(this, event);
1629
- } catch (e) {
1630
- Promise.resolve().then(function() {
1631
- throw e;
1632
- });
1633
- }
1634
- if (listener.options && listener.options.once) {
1635
- this.removeEventListener(event.type, listener.callback);
1636
- }
1637
- }
1638
- return !event.defaultPrevented;
1639
- }
1640
- }]);
1641
- return Emitter2;
1642
- }();
1643
- var AbortSignal = /* @__PURE__ */ function(_Emitter) {
1644
- _inherits(AbortSignal2, _Emitter);
1645
- var _super = _createSuper(AbortSignal2);
1646
- function AbortSignal2() {
1647
- var _this;
1648
- _classCallCheck(this, AbortSignal2);
1649
- _this = _super.call(this);
1650
- if (!_this.listeners) {
1651
- Emitter.call(_assertThisInitialized(_this));
1652
- }
1653
- Object.defineProperty(_assertThisInitialized(_this), "aborted", {
1654
- value: false,
1655
- writable: true,
1656
- configurable: true
1657
- });
1658
- Object.defineProperty(_assertThisInitialized(_this), "onabort", {
1659
- value: null,
1660
- writable: true,
1661
- configurable: true
1662
- });
1663
- Object.defineProperty(_assertThisInitialized(_this), "reason", {
1664
- value: void 0,
1665
- writable: true,
1666
- configurable: true
1667
- });
1668
- return _this;
1669
- }
1670
- _createClass(AbortSignal2, [{
1671
- key: "toString",
1672
- value: function toString() {
1673
- return "[object AbortSignal]";
1674
- }
1675
- }, {
1676
- key: "dispatchEvent",
1677
- value: function dispatchEvent(event) {
1678
- if (event.type === "abort") {
1679
- this.aborted = true;
1680
- if (typeof this.onabort === "function") {
1681
- this.onabort.call(this, event);
1682
- }
1683
- }
1684
- _get(_getPrototypeOf(AbortSignal2.prototype), "dispatchEvent", this).call(this, event);
1685
- }
1686
- }]);
1687
- return AbortSignal2;
1688
- }(Emitter);
1689
- var AbortController2 = /* @__PURE__ */ function() {
1690
- function AbortController3() {
1691
- _classCallCheck(this, AbortController3);
1692
- Object.defineProperty(this, "signal", {
1693
- value: new AbortSignal(),
1694
- writable: true,
1695
- configurable: true
1696
- });
1697
- }
1698
- _createClass(AbortController3, [{
1699
- key: "abort",
1700
- value: function abort(reason) {
1701
- var event;
1702
- try {
1703
- event = new Event("abort");
1704
- } catch (e) {
1705
- if (typeof document !== "undefined") {
1706
- if (!document.createEvent) {
1707
- event = document.createEventObject();
1708
- event.type = "abort";
1709
- } else {
1710
- event = document.createEvent("Event");
1711
- event.initEvent("abort", false, false);
1712
- }
1713
- } else {
1714
- event = {
1715
- type: "abort",
1716
- bubbles: false,
1717
- cancelable: false
1718
- };
1719
- }
1720
- }
1721
- var signalReason = reason;
1722
- if (signalReason === void 0) {
1723
- if (typeof document === "undefined") {
1724
- signalReason = new Error("This operation was aborted");
1725
- signalReason.name = "AbortError";
1726
- } else {
1727
- try {
1728
- signalReason = new DOMException("signal is aborted without reason");
1729
- } catch (err) {
1730
- signalReason = new Error("This operation was aborted");
1731
- signalReason.name = "AbortError";
1732
- }
1733
- }
1734
- }
1735
- this.signal.reason = signalReason;
1736
- this.signal.dispatchEvent(event);
1737
- }
1738
- }, {
1739
- key: "toString",
1740
- value: function toString() {
1741
- return "[object AbortController]";
1742
- }
1743
- }]);
1744
- return AbortController3;
1745
- }();
1746
- if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
1747
- AbortController2.prototype[Symbol.toStringTag] = "AbortController";
1748
- AbortSignal.prototype[Symbol.toStringTag] = "AbortSignal";
1749
- }
1750
- function polyfillNeeded(self2) {
1751
- if (self2.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {
1752
- console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill");
1753
- return true;
1754
- }
1755
- return typeof self2.Request === "function" && !self2.Request.prototype.hasOwnProperty("signal") || !self2.AbortController;
1756
- }
1757
- function abortableFetchDecorator(patchTargets) {
1758
- if ("function" === typeof patchTargets) {
1759
- patchTargets = {
1760
- fetch: patchTargets
1761
- };
1762
- }
1763
- 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;
1764
- if (!polyfillNeeded({
1765
- fetch: fetch2,
1766
- Request: NativeRequest,
1767
- AbortController: NativeAbortController,
1768
- __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL
1769
- })) {
1770
- return {
1771
- fetch: fetch2,
1772
- Request
1773
- };
1774
- }
1775
- var Request = NativeRequest;
1776
- if (Request && !Request.prototype.hasOwnProperty("signal") || __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {
1777
- Request = function Request2(input, init2) {
1778
- var signal;
1779
- if (init2 && init2.signal) {
1780
- signal = init2.signal;
1781
- delete init2.signal;
1782
- }
1783
- var request = new NativeRequest(input, init2);
1784
- if (signal) {
1785
- Object.defineProperty(request, "signal", {
1786
- writable: false,
1787
- enumerable: false,
1788
- configurable: true,
1789
- value: signal
1790
- });
1791
- }
1792
- return request;
1793
- };
1794
- Request.prototype = NativeRequest.prototype;
1795
- }
1796
- var realFetch = fetch2;
1797
- var abortableFetch = function abortableFetch2(input, init2) {
1798
- var signal = Request && Request.prototype.isPrototypeOf(input) ? input.signal : init2 ? init2.signal : void 0;
1799
- if (signal) {
1800
- var abortError;
1801
- try {
1802
- abortError = new DOMException("Aborted", "AbortError");
1803
- } catch (err) {
1804
- abortError = new Error("Aborted");
1805
- abortError.name = "AbortError";
1806
- }
1807
- if (signal.aborted) {
1808
- return Promise.reject(abortError);
1809
- }
1810
- var cancellation = new Promise(function(_, reject) {
1811
- signal.addEventListener("abort", function() {
1812
- return reject(abortError);
1813
- }, {
1814
- once: true
1815
- });
1816
- });
1817
- if (init2 && init2.signal) {
1818
- delete init2.signal;
1819
- }
1820
- return Promise.race([cancellation, realFetch(input, init2)]);
1821
- }
1822
- return realFetch(input, init2);
1823
- };
1824
- return {
1825
- fetch: abortableFetch,
1826
- Request
1827
- };
1828
- }
1829
- (function(self2) {
1830
- if (!polyfillNeeded(self2)) {
1831
- return;
1832
- }
1833
- if (!self2.fetch) {
1834
- console.warn("fetch() is not available, cannot install abortcontroller-polyfill");
1835
- return;
1836
- }
1837
- var _abortableFetch = abortableFetchDecorator(self2), fetch2 = _abortableFetch.fetch, Request = _abortableFetch.Request;
1838
- self2.fetch = fetch2;
1839
- self2.Request = Request;
1840
- Object.defineProperty(self2, "AbortController", {
1841
- writable: true,
1842
- enumerable: false,
1843
- configurable: true,
1844
- value: AbortController2
1845
- });
1846
- Object.defineProperty(self2, "AbortSignal", {
1847
- writable: true,
1848
- enumerable: false,
1849
- configurable: true,
1850
- value: AbortSignal
1851
- });
1852
- })(typeof self !== "undefined" ? self : commonjsGlobal);
1853
- });
1854
1478
  const Fetch$1 = (opts, input, init2) => __async(void 0, null, function* () {
1855
1479
  const apiToken = opts.getApiToken && opts.getApiToken();
1856
1480
  const headers = new Headers(__spreadValues({
1857
1481
  Authorization: apiToken ? `Bearer ${apiToken}` : ""
1858
1482
  }, init2 == null ? void 0 : init2.headers));
1859
- if (!headers.get("Authorization"))
1860
- headers.delete("Authorization");
1483
+ if (!headers.get("Authorization")) headers.delete("Authorization");
1861
1484
  const resp = yield fetch(input, __spreadProps(__spreadValues({}, init2), {
1862
1485
  headers
1863
1486
  }));
@@ -1872,8 +1495,7 @@ const Fetch$1 = (opts, input, init2) => __async(void 0, null, function* () {
1872
1495
  retry = true;
1873
1496
  }
1874
1497
  }), Promise.resolve()));
1875
- if (retry)
1876
- return Fetch$1(opts, input, init2);
1498
+ if (retry) return Fetch$1(opts, input, init2);
1877
1499
  throw createError(resp.status, json);
1878
1500
  }
1879
1501
  return resp;
@@ -1900,6 +1522,10 @@ function createApiHandlers() {
1900
1522
  add: (action, handler) => {
1901
1523
  handlers.push({ action, handler });
1902
1524
  },
1525
+ remove: (action) => {
1526
+ const index = handlers.findIndex((h) => h.action === action);
1527
+ if (index !== -1) handlers.splice(index, 1);
1528
+ },
1903
1529
  get: () => handlers
1904
1530
  };
1905
1531
  }
@@ -1919,11 +1545,14 @@ class Api2 extends Api$1 {
1919
1545
  */
1920
1546
  getUserFields() {
1921
1547
  const user = this._opts.userInfo;
1922
- if (!(user == null ? void 0 : user.name) || !(user == null ? void 0 : user.email))
1923
- return void 0;
1548
+ if (!(user == null ? void 0 : user.name) || !(user == null ? void 0 : user.email)) return void 0;
1924
1549
  return { name: user.name, email: user.email };
1925
1550
  }
1926
1551
  }
1552
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1553
+ function getDefaultExportFromCjs(x) {
1554
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1555
+ }
1927
1556
  var escapes = {
1928
1557
  "&": "&amp;",
1929
1558
  "<": "&lt;",
@@ -2422,11 +2051,9 @@ var hanabi$1 = { exports: {} };
2422
2051
  });
2423
2052
  var defaultColors = ["23AC69", "91C132", "F19726", "E8552D", "1AAB8E", "E1147F", "2980C1", "1BA1E6", "9FA0A0", "F19726", "E30B20", "E30B20", "A3338B"];
2424
2053
  var index = function(input, ref) {
2425
- if (ref === void 0)
2426
- ref = {};
2054
+ if (ref === void 0) ref = {};
2427
2055
  var colors = ref.colors;
2428
- if (colors === void 0)
2429
- colors = defaultColors;
2056
+ if (colors === void 0) colors = defaultColors;
2430
2057
  var index2 = 0;
2431
2058
  var cache = {};
2432
2059
  var wordRe = /[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/;
@@ -2469,7 +2096,7 @@ function getRenderer(options) {
2469
2096
  renderer.image = markedImageRenderer(renderer, renderer.image, options);
2470
2097
  return renderer;
2471
2098
  }
2472
- const markedLinkRenderer = (renderer, orgLinkRenderer) => (href, title, text) => {
2099
+ const markedLinkRenderer = (renderer, orgLinkRenderer) => (args) => {
2473
2100
  const getLinkOrigin = (link) => {
2474
2101
  try {
2475
2102
  return new URL(link).origin;
@@ -2477,31 +2104,30 @@ const markedLinkRenderer = (renderer, orgLinkRenderer) => (href, title, text) =>
2477
2104
  return "";
2478
2105
  }
2479
2106
  };
2480
- const isSameOriginLink = getLinkOrigin(href) === window.location.origin;
2481
- const html = orgLinkRenderer.call(renderer, href, title, text);
2107
+ const isSameOriginLink = getLinkOrigin(args.href) === window.location.origin;
2108
+ const html = orgLinkRenderer.call(renderer, args);
2482
2109
  return html.replace(
2483
2110
  /^<a /,
2484
2111
  `<a target="_blank" ${!isSameOriginLink ? `rel="noreferrer noopener nofollow"` : ""} `
2485
2112
  );
2486
2113
  };
2487
- const markedCodeRenderer = () => (block, lang) => {
2114
+ const markedCodeRenderer = () => ({ lang, text }) => {
2488
2115
  const realLang = !lang ? "plaintext" : lang;
2489
- let colorized = block;
2116
+ let colorized = text;
2490
2117
  if (window.hljs) {
2491
2118
  if (realLang && window.hljs.getLanguage(realLang)) {
2492
- colorized = window.hljs.highlight(realLang, block).value;
2119
+ colorized = window.hljs.highlight(realLang, text).value;
2493
2120
  }
2494
2121
  } else {
2495
- colorized = renderCode(block);
2122
+ colorized = renderCode(text);
2496
2123
  }
2497
2124
  return `<pre rel="${realLang}">
2498
2125
  <code class="hljs language-${realLang}">${colorized.replace(/&amp;/g, "&")}</code>
2499
2126
  </pre>`;
2500
2127
  };
2501
- const markedImageRenderer = (renderer, orgImageRenderer, { imgLazyLoad }) => (href, title, text) => {
2502
- const html = orgImageRenderer.call(renderer, href, title, text);
2503
- if (!imgLazyLoad)
2504
- return html;
2128
+ const markedImageRenderer = (renderer, orgImageRenderer, { imgLazyLoad }) => (args) => {
2129
+ const html = orgImageRenderer.call(renderer, args);
2130
+ if (!imgLazyLoad) return html;
2505
2131
  if (imgLazyLoad === "native" || imgLazyLoad === true)
2506
2132
  return html.replace(/^<img /, '<img class="lazyload" loading="lazy" ');
2507
2133
  if (imgLazyLoad === "data-src")
@@ -2523,17 +2149,17 @@ function setReplacers(arr) {
2523
2149
  }
2524
2150
  function initMarked(options) {
2525
2151
  try {
2526
- if (!marked$1.name)
2527
- return;
2152
+ if (!Marked.name) return;
2528
2153
  } catch (e) {
2529
2154
  return;
2530
2155
  }
2531
- marked$1.setOptions(__spreadValues(__spreadValues({
2156
+ const marked2 = new Marked();
2157
+ marked2.setOptions(__spreadValues(__spreadValues({
2532
2158
  renderer: getRenderer({
2533
2159
  imgLazyLoad: options.imgLazyLoad
2534
2160
  })
2535
2161
  }, markedOptions), options.markedOptions));
2536
- instance = marked$1;
2162
+ instance = marked2;
2537
2163
  }
2538
2164
  function marked(src) {
2539
2165
  var _a;
@@ -2543,8 +2169,7 @@ function marked(src) {
2543
2169
  }
2544
2170
  let dest = sanitize(markedContent);
2545
2171
  replacers.forEach((replacer) => {
2546
- if (typeof replacer === "function")
2547
- dest = replacer(dest);
2172
+ if (typeof replacer === "function") dest = replacer(dest);
2548
2173
  });
2549
2174
  return dest;
2550
2175
  }
@@ -2627,8 +2252,7 @@ class DataManager {
2627
2252
  }
2628
2253
  updateComment(comment) {
2629
2254
  this.comments = this.comments.map((c) => {
2630
- if (c.id === comment.id)
2631
- return comment;
2255
+ if (c.id === comment.id) return comment;
2632
2256
  return c;
2633
2257
  });
2634
2258
  this.events.trigger("comment-updated", comment);
@@ -2636,8 +2260,7 @@ class DataManager {
2636
2260
  }
2637
2261
  deleteComment(id) {
2638
2262
  const comment = this.comments.find((c) => c.id === id);
2639
- if (!comment)
2640
- throw new Error(`Comment ${id} not found`);
2263
+ if (!comment) throw new Error(`Comment ${id} not found`);
2641
2264
  this.comments = this.comments.filter((c) => c.id !== id);
2642
2265
  this.events.trigger("comment-deleted", comment);
2643
2266
  this.events.trigger("list-loaded", this.comments);
@@ -2693,8 +2316,7 @@ function getOffset(el, relativeTo) {
2693
2316
  };
2694
2317
  };
2695
2318
  const elOffset = getOffsetRecursive(el);
2696
- if (!relativeTo)
2697
- return elOffset;
2319
+ if (!relativeTo) return elOffset;
2698
2320
  const relativeToOffset = getOffsetRecursive(relativeTo);
2699
2321
  return {
2700
2322
  top: elOffset.top - relativeToOffset.top,
@@ -2729,16 +2351,14 @@ function timeAgo(date, $t = (n) => n) {
2729
2351
  if (minutes === 0) {
2730
2352
  const leave3 = leave2 % (60 * 1e3);
2731
2353
  const seconds = Math.round(leave3 / 1e3);
2732
- if (seconds < 10)
2733
- return $t("now");
2354
+ if (seconds < 10) return $t("now");
2734
2355
  return `${seconds} ${$t("seconds")}`;
2735
2356
  }
2736
2357
  return `${minutes} ${$t("minutes")}`;
2737
2358
  }
2738
2359
  return `${hours} ${$t("hours")}`;
2739
2360
  }
2740
- if (days < 0)
2741
- return $t("now");
2361
+ if (days < 0) return $t("now");
2742
2362
  if (days < 8) {
2743
2363
  return `${days} ${$t("days")}`;
2744
2364
  }
@@ -2757,14 +2377,10 @@ function versionCompare(a, b) {
2757
2377
  for (let i = 0; i < 3; i++) {
2758
2378
  const na = Number(pa[i]);
2759
2379
  const nb = Number(pb[i]);
2760
- if (na > nb)
2761
- return 1;
2762
- if (nb > na)
2763
- return -1;
2764
- if (!Number.isNaN(na) && Number.isNaN(nb))
2765
- return 1;
2766
- if (Number.isNaN(na) && !Number.isNaN(nb))
2767
- return -1;
2380
+ if (na > nb) return 1;
2381
+ if (nb > na) return -1;
2382
+ if (!Number.isNaN(na) && Number.isNaN(nb)) return 1;
2383
+ if (Number.isNaN(na) && !Number.isNaN(nb)) return -1;
2768
2384
  }
2769
2385
  return 0;
2770
2386
  }
@@ -2878,21 +2494,25 @@ const en = {
2878
2494
  cancel: "Cancel",
2879
2495
  /* Sidebar */
2880
2496
  msgCenter: "Messages",
2881
- ctrlCenter: "Admin",
2497
+ ctrlCenter: "Dashboard",
2882
2498
  /* Auth */
2499
+ userProfile: "Profile",
2883
2500
  noAccountPrompt: "Don't have an account?",
2884
2501
  haveAccountPrompt: "Already have an account?",
2885
2502
  forgetPassword: "Forget Password",
2886
2503
  resetPassword: "Reset Password",
2504
+ changePassword: "Change Password",
2505
+ confirmPassword: "Confirm Password",
2506
+ passwordMismatch: "Passwords do not match",
2887
2507
  verificationCode: "Verification Code",
2888
- verifySend: "Verify",
2508
+ verifySend: "Send Code",
2889
2509
  verifyResend: "Resend",
2890
2510
  waitSeconds: "Wait {seconds}s",
2891
2511
  emailVerified: "Email has been verified",
2892
2512
  password: "Password",
2893
2513
  username: "Username",
2894
2514
  nextStep: "Next Step",
2895
- skipNotVerify: "Skip, do not verify",
2515
+ skipVerify: "Skip verification",
2896
2516
  logoutConfirm: "Are you sure to logout?",
2897
2517
  accountMergeNotice: "Your email has multiple accounts with different id.",
2898
2518
  accountMergeSelectOne: "Please select one you want to merge all the data into it.",
@@ -2982,10 +2602,14 @@ const zhCN = {
2982
2602
  msgCenter: "通知中心",
2983
2603
  ctrlCenter: "控制中心",
2984
2604
  /* Auth */
2605
+ userProfile: "个人资料",
2985
2606
  noAccountPrompt: "没有账号?",
2986
2607
  haveAccountPrompt: "已有账号?",
2987
2608
  forgetPassword: "忘记密码",
2988
2609
  resetPassword: "重置密码",
2610
+ changePassword: "修改密码",
2611
+ confirmPassword: "确认密码",
2612
+ passwordMismatch: "两次输入的密码不一致",
2989
2613
  verificationCode: "验证码",
2990
2614
  verifySend: "发送验证码",
2991
2615
  verifyResend: "重新发送",
@@ -2994,7 +2618,7 @@ const zhCN = {
2994
2618
  password: "密码",
2995
2619
  username: "用户名",
2996
2620
  nextStep: "下一步",
2997
- skipNotVerify: "跳过,不验证",
2621
+ skipVerify: "跳过验证",
2998
2622
  logoutConfirm: "确定要退出登录吗?",
2999
2623
  accountMergeNotice: "您的电子邮件下有多个不同 ID 的账户。",
3000
2624
  accountMergeSelectOne: "请选择将所有数据合并到其中的一个。",
@@ -3040,8 +2664,7 @@ function findLocaleSet(lang) {
3040
2664
  let LocaleConf = "en";
3041
2665
  let LocaleDict = findLocaleSet(LocaleConf);
3042
2666
  function setLocale(locale) {
3043
- if (locale === LocaleConf)
3044
- return;
2667
+ if (locale === LocaleConf) return;
3045
2668
  LocaleConf = locale;
3046
2669
  LocaleDict = typeof locale === "string" ? findLocaleSet(locale) : locale;
3047
2670
  }
@@ -3067,8 +2690,7 @@ class EventManager {
3067
2690
  * Remove an event listener for a specific event name and handler
3068
2691
  */
3069
2692
  off(name, handler) {
3070
- if (!handler)
3071
- return;
2693
+ if (!handler) return;
3072
2694
  this.events = this.events.filter((evt) => !(evt.name === name && evt.handler === handler));
3073
2695
  }
3074
2696
  /**
@@ -3076,8 +2698,7 @@ class EventManager {
3076
2698
  */
3077
2699
  trigger(name, payload) {
3078
2700
  this.events.slice(0).filter((evt) => evt.name === name && typeof evt.handler === "function").forEach((evt) => {
3079
- if (evt.once)
3080
- this.off(name, evt.handler);
2701
+ if (evt.once) this.off(name, evt.handler);
3081
2702
  evt.handler(payload);
3082
2703
  });
3083
2704
  }
@@ -3130,26 +2751,19 @@ function handelCustomConf(customConf, full = false) {
3130
2751
  if (conf.el && typeof conf.el === "string") {
3131
2752
  try {
3132
2753
  const findEl = document.querySelector(conf.el);
3133
- if (!findEl)
3134
- throw Error(`Target element "${conf.el}" was not found.`);
2754
+ if (!findEl) throw Error(`Target element "${conf.el}" was not found.`);
3135
2755
  conf.el = findEl;
3136
2756
  } catch (e) {
3137
2757
  console.error(e);
3138
2758
  throw new Error("Please check your Artalk `el` config.");
3139
2759
  }
3140
2760
  }
3141
- if (conf.pageKey === "")
3142
- conf.pageKey = `${window.location.pathname}`;
3143
- if (conf.pageTitle === "")
3144
- conf.pageTitle = `${document.title}`;
3145
- if (conf.server)
3146
- conf.server = conf.server.replace(/\/$/, "").replace(/\/api\/?$/, "");
3147
- if (conf.locale === "auto")
3148
- conf.locale = navigator.language;
3149
- if (conf.flatMode === "auto")
3150
- conf.flatMode = window.matchMedia("(max-width: 768px)").matches;
3151
- if (typeof conf.nestMax === "number" && Number(conf.nestMax) <= 1)
3152
- conf.flatMode = true;
2761
+ if (conf.pageKey === "") conf.pageKey = `${window.location.pathname}`;
2762
+ if (conf.pageTitle === "") conf.pageTitle = `${document.title}`;
2763
+ if (conf.server) conf.server = conf.server.replace(/\/$/, "").replace(/\/api\/?$/, "");
2764
+ if (conf.locale === "auto") conf.locale = navigator.language;
2765
+ if (conf.flatMode === "auto") conf.flatMode = window.matchMedia("(max-width: 768px)").matches;
2766
+ if (typeof conf.nestMax === "number" && Number(conf.nestMax) <= 1) conf.flatMode = true;
3153
2767
  return conf;
3154
2768
  }
3155
2769
  function handleConfFormServer(conf) {
@@ -3164,10 +2778,8 @@ function handleConfFormServer(conf) {
3164
2778
  "statPageKeyAttr"
3165
2779
  ];
3166
2780
  Object.keys(conf).forEach((k) => {
3167
- if (ExcludedKeys.includes(k))
3168
- delete conf[k];
3169
- if (k === "darkMode" && conf[k] !== "auto")
3170
- delete conf[k];
2781
+ if (ExcludedKeys.includes(k)) delete conf[k];
2782
+ if (k === "darkMode" && conf[k] !== "auto") delete conf[k];
3171
2783
  });
3172
2784
  if (conf.emoticons && typeof conf.emoticons === "string") {
3173
2785
  conf.emoticons = conf.emoticons.trim();
@@ -3188,7 +2800,7 @@ function convertApiOptions(conf, ctx) {
3188
2800
  timeout: conf.reqTimeout,
3189
2801
  getApiToken: () => ctx == null ? void 0 : ctx.get("user").getData().token,
3190
2802
  userInfo: (ctx == null ? void 0 : ctx.get("user").checkHasBasicUserInfo()) ? {
3191
- name: ctx == null ? void 0 : ctx.get("user").getData().nick,
2803
+ name: ctx == null ? void 0 : ctx.get("user").getData().name,
3192
2804
  email: ctx == null ? void 0 : ctx.get("user").getData().email
3193
2805
  } : void 0,
3194
2806
  handlers: ctx == null ? void 0 : ctx.getApiHandlers()
@@ -3238,6 +2850,7 @@ class Context {
3238
2850
  this.$root = conf.el;
3239
2851
  this.$root.classList.add("artalk");
3240
2852
  this.$root.innerHTML = "";
2853
+ conf.darkMode && this.$root.classList.add("atk-dark-mode");
3241
2854
  this.data = new DataManager(this.events);
3242
2855
  this.on("mounted", () => {
3243
2856
  this.mounted = true;
@@ -3253,8 +2866,7 @@ class Context {
3253
2866
  return new Api2(convertApiOptions(this.conf, this));
3254
2867
  }
3255
2868
  getApiHandlers() {
3256
- if (!this.apiHandlers)
3257
- this.apiHandlers = createNewApiHandlers(this);
2869
+ if (!this.apiHandlers) this.apiHandlers = createNewApiHandlers(this);
3258
2870
  return this.apiHandlers;
3259
2871
  }
3260
2872
  getData() {
@@ -3353,8 +2965,7 @@ function showLoading(parentElem, conf) {
3353
2965
  </div>
3354
2966
  </div>`
3355
2967
  );
3356
- if (conf == null ? void 0 : conf.transparentBg)
3357
- $loading.style.background = "transparent";
2968
+ if (conf == null ? void 0 : conf.transparentBg) $loading.style.background = "transparent";
3358
2969
  parentElem.appendChild($loading);
3359
2970
  }
3360
2971
  $loading.style.display = "";
@@ -3362,21 +2973,17 @@ function showLoading(parentElem, conf) {
3362
2973
  if ($spinner) {
3363
2974
  $spinner.style.display = "none";
3364
2975
  window.setTimeout(() => {
3365
- if ($spinner.isConnected)
3366
- $spinner.style.display = "";
2976
+ if ($spinner.isConnected) $spinner.style.display = "";
3367
2977
  }, 500);
3368
2978
  }
3369
2979
  }
3370
2980
  function hideLoading(parentElem) {
3371
2981
  const $loading = parentElem.querySelector(":scope > .atk-loading");
3372
- if ($loading)
3373
- $loading.style.display = "none";
2982
+ if ($loading) $loading.style.display = "none";
3374
2983
  }
3375
2984
  function setLoading(val, parentElem) {
3376
- if (val)
3377
- showLoading(parentElem);
3378
- else
3379
- hideLoading(parentElem);
2985
+ if (val) showLoading(parentElem);
2986
+ else hideLoading(parentElem);
3380
2987
  }
3381
2988
  function scrollIntoView(elem, enableAnim = true, relativeTo) {
3382
2989
  let top;
@@ -3395,10 +3002,8 @@ function scrollIntoView(elem, enableAnim = true, relativeTo) {
3395
3002
  // behavior: enableAnim ? 'smooth' : 'instant',
3396
3003
  behavior: "instant"
3397
3004
  };
3398
- if (relativeTo)
3399
- relativeTo.scroll(scrollOptions);
3400
- else
3401
- window.scroll(scrollOptions);
3005
+ if (relativeTo) relativeTo.scroll(scrollOptions);
3006
+ else window.scroll(scrollOptions);
3402
3007
  }
3403
3008
  function showNotify(wrapElem, msg, type) {
3404
3009
  const colors = { s: "#57d59f", e: "#ff6f6c", w: "#ffc721", i: "#2ebcfc" };
@@ -3440,8 +3045,7 @@ function playFadeInAnim(elem, after) {
3440
3045
  function setError(parentElem, html, title = '<span class="atk-error-title">Artalk Error</span>') {
3441
3046
  let elem = parentElem.querySelector(".atk-error-layer");
3442
3047
  if (html === null) {
3443
- if (elem !== null)
3444
- elem.remove();
3048
+ if (elem !== null) elem.remove();
3445
3049
  return;
3446
3050
  }
3447
3051
  if (!elem) {
@@ -3452,8 +3056,7 @@ function setError(parentElem, html, title = '<span class="atk-error-title">Artal
3452
3056
  }
3453
3057
  const errorTextEl = elem.querySelector(".atk-error-text");
3454
3058
  errorTextEl.innerHTML = "";
3455
- if (html === null)
3456
- return;
3059
+ if (html === null) return;
3457
3060
  if (html instanceof HTMLElement) {
3458
3061
  errorTextEl.appendChild(html);
3459
3062
  } else {
@@ -3477,8 +3080,7 @@ function getScrollBarWidth() {
3477
3080
  const w1 = inner.offsetWidth;
3478
3081
  outer.style.overflow = "scroll";
3479
3082
  let w2 = inner.offsetWidth;
3480
- if (w1 === w2)
3481
- w2 = outer.clientWidth;
3083
+ if (w1 === w2) w2 = outer.clientWidth;
3482
3084
  document.body.removeChild(outer);
3483
3085
  return w1 - w2;
3484
3086
  }
@@ -3523,8 +3125,7 @@ function iframeBody(checker) {
3523
3125
  (function queryStatus() {
3524
3126
  return __async(this, null, function* () {
3525
3127
  yield sleep(1e3);
3526
- if (stop)
3527
- return;
3128
+ if (stop) return;
3528
3129
  let isPass = false;
3529
3130
  try {
3530
3131
  const resp = yield checker.getApi().captcha.getCaptchaStatus();
@@ -3552,8 +3153,7 @@ const CaptchaChecker = {
3552
3153
  });
3553
3154
  },
3554
3155
  body(checker) {
3555
- if (checker.get("iframe"))
3556
- return iframeBody(checker);
3156
+ if (checker.get("iframe")) return iframeBody(checker);
3557
3157
  return imgBody(checker);
3558
3158
  },
3559
3159
  onSuccess(checker, data, inputVal, formEl) {
@@ -3569,7 +3169,7 @@ const AdminChecker = {
3569
3169
  request(checker, inputVal) {
3570
3170
  return __async(this, null, function* () {
3571
3171
  return (yield checker.getApi().user.login({
3572
- name: checker.getUser().getData().nick,
3172
+ name: checker.getUser().getData().name,
3573
3173
  email: checker.getUser().getData().email,
3574
3174
  password: inputVal
3575
3175
  })).data;
@@ -3580,7 +3180,7 @@ const AdminChecker = {
3580
3180
  },
3581
3181
  onSuccess(checker, res, inputVal, formEl) {
3582
3182
  checker.getUser().update({
3583
- isAdmin: true,
3183
+ is_admin: true,
3584
3184
  token: res.token
3585
3185
  });
3586
3186
  checker.getOpts().onReload();
@@ -3681,19 +3281,15 @@ class CheckerLauncher {
3681
3281
  },
3682
3282
  triggerSuccess: () => {
3683
3283
  close();
3684
- if (checker.onSuccess)
3685
- checker.onSuccess(checkerCtx, "", "", formEl);
3686
- if (payload.onSuccess)
3687
- payload.onSuccess();
3284
+ if (checker.onSuccess) checker.onSuccess(checkerCtx, "", "", formEl);
3285
+ if (payload.onSuccess) payload.onSuccess();
3688
3286
  },
3689
3287
  cancel: () => {
3690
3288
  close();
3691
- if (payload.onCancel)
3692
- payload.onCancel();
3289
+ if (payload.onCancel) payload.onCancel();
3693
3290
  }
3694
3291
  };
3695
- if (postFire)
3696
- postFire(checkerCtx);
3292
+ if (postFire) postFire(checkerCtx);
3697
3293
  const formEl = createElement();
3698
3294
  formEl.appendChild(checker.body(checkerCtx));
3699
3295
  const $input = createElement(
@@ -3711,8 +3307,7 @@ class CheckerLauncher {
3711
3307
  const dialog = new Dialog(formEl);
3712
3308
  dialog.setYes((btnEl) => {
3713
3309
  const inputVal = $input.value.trim();
3714
- if (!btnTextOrg)
3715
- btnTextOrg = btnEl.innerText;
3310
+ if (!btnTextOrg) btnTextOrg = btnEl.innerText;
3716
3311
  const btnTextSet = (btnText) => {
3717
3312
  btnEl.innerText = btnText;
3718
3313
  btnEl.classList.add("error");
@@ -3724,14 +3319,11 @@ class CheckerLauncher {
3724
3319
  btnEl.innerText = `${t("loading")}...`;
3725
3320
  checker.request(checkerCtx, inputVal).then((data) => {
3726
3321
  close();
3727
- if (checker.onSuccess)
3728
- checker.onSuccess(checkerCtx, data, inputVal, formEl);
3729
- if (payload.onSuccess)
3730
- payload.onSuccess();
3322
+ if (checker.onSuccess) checker.onSuccess(checkerCtx, data, inputVal, formEl);
3323
+ if (payload.onSuccess) payload.onSuccess();
3731
3324
  }).catch((err) => {
3732
3325
  btnTextSet(String(err.message || String(err)));
3733
- if (checker.onError)
3734
- checker.onError(checkerCtx, err, inputVal, formEl);
3326
+ if (checker.onError) checker.onError(checkerCtx, err, inputVal, formEl);
3735
3327
  const tf = setTimeout(() => btnTextRestore(), 3e3);
3736
3328
  $input.onfocus = () => {
3737
3329
  btnTextRestore();
@@ -3742,8 +3334,7 @@ class CheckerLauncher {
3742
3334
  });
3743
3335
  dialog.setNo(() => {
3744
3336
  close();
3745
- if (payload.onCancel)
3746
- payload.onCancel();
3337
+ if (payload.onCancel) payload.onCancel();
3747
3338
  return false;
3748
3339
  });
3749
3340
  if (hideInteractInput) {
@@ -3751,8 +3342,7 @@ class CheckerLauncher {
3751
3342
  dialog.$el.querySelector(".atk-layer-dialog-actions").style.display = "none";
3752
3343
  }
3753
3344
  layer.getEl().append(dialog.$el);
3754
- if (payload.onMount)
3755
- payload.onMount(dialog.$el);
3345
+ if (payload.onMount) payload.onMount(dialog.$el);
3756
3346
  }
3757
3347
  }
3758
3348
  class Component {
@@ -3767,10 +3357,10 @@ class Component {
3767
3357
  return this.$el;
3768
3358
  }
3769
3359
  }
3770
- const EditorHTML = '<div class="atk-main-editor">\n <div class="atk-header">\n <input name="nick" class="atk-nick" 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';
3360
+ 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';
3771
3361
  const Sel = {
3772
3362
  $header: ".atk-header",
3773
- $nick: '.atk-header [name="nick"]',
3363
+ $name: '.atk-header [name="name"]',
3774
3364
  $email: '.atk-header [name="email"]',
3775
3365
  $link: '.atk-header [name="link"]',
3776
3366
  $textareaWrap: ".atk-textarea-wrap",
@@ -3793,6 +3383,9 @@ function render() {
3793
3383
  }
3794
3384
  class EditorPlug {
3795
3385
  constructor(kit) {
3386
+ __publicField(this, "$btn");
3387
+ __publicField(this, "$panel");
3388
+ __publicField(this, "editorStateEffectWhen");
3796
3389
  this.kit = kit;
3797
3390
  }
3798
3391
  /** Use plug btn will add a btn on the bottom of editor */
@@ -3812,15 +3405,13 @@ class EditorPlug {
3812
3405
  /** Listen the event of panel show */
3813
3406
  usePanelShow(func) {
3814
3407
  this.kit.useEvents().on("panel-show", (aPlug) => {
3815
- if (aPlug === this)
3816
- func();
3408
+ if (aPlug === this) func();
3817
3409
  });
3818
3410
  }
3819
3411
  /** Listen the event of panel hide */
3820
3412
  usePanelHide(func) {
3821
3413
  this.kit.useEvents().on("panel-hide", (aPlug) => {
3822
- if (aPlug === this)
3823
- func();
3414
+ if (aPlug === this) func();
3824
3415
  });
3825
3416
  }
3826
3417
  /** Use editor state modifier */
@@ -3835,8 +3426,7 @@ class Mover extends EditorPlug {
3835
3426
  __publicField(this, "isMoved", false);
3836
3427
  }
3837
3428
  move(afterEl) {
3838
- if (this.isMoved)
3839
- return;
3429
+ if (this.isMoved) return;
3840
3430
  this.isMoved = true;
3841
3431
  const editorEl = this.kit.useUI().$el;
3842
3432
  editorEl.after(createElement('<div class="atk-editor-travel-placeholder"></div>'));
@@ -3848,8 +3438,7 @@ class Mover extends EditorPlug {
3848
3438
  }
3849
3439
  back() {
3850
3440
  var _a;
3851
- if (!this.isMoved)
3852
- return;
3441
+ if (!this.isMoved) return;
3853
3442
  this.isMoved = false;
3854
3443
  (_a = this.kit.useGlobalCtx().$root.querySelector(".atk-editor-travel-placeholder")) == null ? void 0 : _a.replaceWith(this.kit.useUI().$el);
3855
3444
  this.kit.useUI().$el.classList.remove("editor-traveling");
@@ -3912,13 +3501,12 @@ class Editor extends Component {
3912
3501
  return this.state.get();
3913
3502
  }
3914
3503
  getHeaderInputEls() {
3915
- return { nick: this.ui.$nick, email: this.ui.$email, link: this.ui.$link };
3504
+ return { name: this.ui.$name, email: this.ui.$email, link: this.ui.$link };
3916
3505
  }
3917
3506
  getContentFinal() {
3918
3507
  let content = this.getContentRaw();
3919
3508
  const plugs = this.getPlugs();
3920
- if (plugs)
3921
- content = plugs.getTransformedContent(content);
3509
+ if (plugs) content = plugs.getTransformedContent(content);
3922
3510
  return content;
3923
3511
  }
3924
3512
  getContentRaw() {
@@ -3996,8 +3584,8 @@ class SidebarLayer extends Component {
3996
3584
  __publicField(this, "$closeBtn");
3997
3585
  __publicField(this, "$iframeWrap");
3998
3586
  __publicField(this, "$iframe");
3999
- /** Refresh iFrame on show */
4000
- __publicField(this, "refreshOnShow", true);
3587
+ /** Refresh iFrame when show */
3588
+ __publicField(this, "refreshWhenShow", true);
4001
3589
  /** Animation timer */
4002
3590
  __publicField(this, "animTimer");
4003
3591
  this.$el = createElement(SidebarHTML);
@@ -4008,7 +3596,7 @@ class SidebarLayer extends Component {
4008
3596
  this.hide();
4009
3597
  };
4010
3598
  this.ctx.on("user-changed", () => {
4011
- this.refreshOnShow = true;
3599
+ this.refreshWhenShow = true;
4012
3600
  });
4013
3601
  }
4014
3602
  /** 显示 */
@@ -4017,8 +3605,8 @@ class SidebarLayer extends Component {
4017
3605
  this.$el.style.transform = "";
4018
3606
  this.initLayer();
4019
3607
  this.layer.show();
4020
- if (this.refreshOnShow) {
4021
- this.refreshOnShow = false;
3608
+ if (this.refreshWhenShow) {
3609
+ this.refreshWhenShow = false;
4022
3610
  this.$iframeWrap.innerHTML = "";
4023
3611
  this.$iframe = this.createIframe(conf.view);
4024
3612
  this.$iframeWrap.append(this.$iframe);
@@ -4028,7 +3616,7 @@ class SidebarLayer extends Component {
4028
3616
  if (this.getDarkMode() !== iFrameSrc.includes("&darkMode=1")) {
4029
3617
  this.iframeLoad(
4030
3618
  $iframe,
4031
- this.getDarkMode() ? iFrameSrc.concat("&darkMode=1") : iFrameSrc.replace("&darkMode=1", "")
3619
+ iFrameSrc.replace(/&darkMode=\d/, `&darkMode=${Number(this.getDarkMode())}`)
4032
3620
  );
4033
3621
  }
4034
3622
  }
@@ -4056,7 +3644,7 @@ class SidebarLayer extends Component {
4056
3644
  return __async(this, null, function* () {
4057
3645
  const data = (yield this.ctx.getApi().user.getUserStatus(__spreadValues({}, this.ctx.getApi().getUserFields()))).data;
4058
3646
  if (data.is_admin && !data.is_login) {
4059
- this.refreshOnShow = true;
3647
+ this.refreshWhenShow = true;
4060
3648
  this.ctx.checkAdmin({
4061
3649
  onSuccess: () => {
4062
3650
  setTimeout(() => {
@@ -4072,8 +3660,7 @@ class SidebarLayer extends Component {
4072
3660
  });
4073
3661
  }
4074
3662
  initLayer() {
4075
- if (this.layer)
4076
- return;
3663
+ if (this.layer) return;
4077
3664
  this.layer = this.ctx.get("layerManager").create("sidebar", this.$el);
4078
3665
  this.layer.setOnAfterHide(() => {
4079
3666
  this.ctx.editorResetState();
@@ -4096,10 +3683,8 @@ class SidebarLayer extends Component {
4096
3683
  user: JSON.stringify(this.ctx.get("user").getData()),
4097
3684
  time: +/* @__PURE__ */ new Date()
4098
3685
  };
4099
- if (view)
4100
- query.view = view;
4101
- if (this.getDarkMode())
4102
- query.darkMode = "1";
3686
+ if (view) query.view = view;
3687
+ query.darkMode = this.getDarkMode() ? "1" : "0";
4103
3688
  const urlParams = new URLSearchParams(query);
4104
3689
  this.iframeLoad($iframe, `${baseURL}?${urlParams.toString()}`);
4105
3690
  return $iframe;
@@ -4130,10 +3715,8 @@ function makeNestCommentNodeList(srcData, sortBy = "DATE_DESC", nestMax = 2) {
4130
3715
  nodeList.push(rootNode);
4131
3716
  (function loadChildren(parentNode) {
4132
3717
  const children = srcData.filter((o) => o.rid === parentNode.id);
4133
- if (children.length === 0)
4134
- return;
4135
- if (parentNode.level >= nestMax)
4136
- parentNode = parentNode.parent;
3718
+ if (children.length === 0) return;
3719
+ if (parentNode.level >= nestMax) parentNode = parentNode.parent;
4137
3720
  children.forEach((child) => {
4138
3721
  const childNode = {
4139
3722
  id: child.id,
@@ -4149,14 +3732,10 @@ function makeNestCommentNodeList(srcData, sortBy = "DATE_DESC", nestMax = 2) {
4149
3732
  });
4150
3733
  const sortFunc = (a, b) => {
4151
3734
  let v = a.id - b.id;
4152
- if (sortBy === "DATE_ASC")
4153
- v = +new Date(a.comment.date) - +new Date(b.comment.date);
4154
- else if (sortBy === "DATE_DESC")
4155
- v = +new Date(b.comment.date) - +new Date(a.comment.date);
4156
- else if (sortBy === "SRC_INDEX")
4157
- v = srcData.indexOf(a.comment) - srcData.indexOf(b.comment);
4158
- else if (sortBy === "VOTE_UP_DESC")
4159
- v = b.comment.vote_up - a.comment.vote_up;
3735
+ if (sortBy === "DATE_ASC") v = +new Date(a.comment.date) - +new Date(b.comment.date);
3736
+ else if (sortBy === "DATE_DESC") v = +new Date(b.comment.date) - +new Date(a.comment.date);
3737
+ else if (sortBy === "SRC_INDEX") v = srcData.indexOf(a.comment) - srcData.indexOf(b.comment);
3738
+ else if (sortBy === "VOTE_UP_DESC") v = b.comment.vote_up - a.comment.vote_up;
4160
3739
  return v;
4161
3740
  };
4162
3741
  (function sortLevels(nodes) {
@@ -4220,16 +3799,13 @@ const createFlatStrategy = (opts) => ({
4220
3799
  }
4221
3800
  });
4222
3801
  function insertComment(opts, insertMode, comment, replyComment) {
4223
- if (comment.is_collapsed)
4224
- comment.is_allow_reply = false;
3802
+ if (comment.is_collapsed) comment.is_allow_reply = false;
4225
3803
  const node = opts.createCommentNode(comment, replyComment);
4226
3804
  if (comment.visible) {
4227
3805
  const $comment = node.getEl();
4228
3806
  const $listCommentsWrap = opts.$commentsWrap;
4229
- if (insertMode === "append")
4230
- $listCommentsWrap == null ? void 0 : $listCommentsWrap.append($comment);
4231
- if (insertMode === "prepend")
4232
- $listCommentsWrap == null ? void 0 : $listCommentsWrap.prepend($comment);
3807
+ if (insertMode === "append") $listCommentsWrap == null ? void 0 : $listCommentsWrap.append($comment);
3808
+ if (insertMode === "prepend") $listCommentsWrap == null ? void 0 : $listCommentsWrap.prepend($comment);
4233
3809
  node.getRender().playFadeAnim();
4234
3810
  }
4235
3811
  node.getRender().checkHeightLimit();
@@ -4334,8 +3910,7 @@ function Detect(userAgent) {
4334
3910
  dest.language = (() => {
4335
3911
  const g = nav.browserLanguage || nav.language;
4336
3912
  const arr = g.split("-");
4337
- if (arr[1])
4338
- arr[1] = arr[1].toUpperCase();
3913
+ if (arr[1]) arr[1] = arr[1].toUpperCase();
4339
3914
  return arr.join("_");
4340
3915
  })();
4341
3916
  const hash = {
@@ -4346,8 +3921,7 @@ function Detect(userAgent) {
4346
3921
  };
4347
3922
  Object.entries(hash).forEach(([type, match]) => {
4348
3923
  Object.entries(match).forEach(([name, result]) => {
4349
- if (result === true)
4350
- dest[type] = name;
3924
+ if (result === true) dest[type] = name;
4351
3925
  });
4352
3926
  });
4353
3927
  const osVersion = {
@@ -4442,16 +4016,12 @@ function Detect(userAgent) {
4442
4016
  }
4443
4017
  function check(conf, rules) {
4444
4018
  rules.forEach(({ el, max, imgCheck }) => {
4445
- if (!el)
4446
- return;
4447
- if (imgCheck)
4448
- el.style.maxHeight = `${max + 1}px`;
4019
+ if (!el) return;
4020
+ if (imgCheck) el.style.maxHeight = `${max + 1}px`;
4449
4021
  let lock = false;
4450
4022
  const _check = () => {
4451
- if (lock)
4452
- return;
4453
- if (getHeight(el) <= max)
4454
- return;
4023
+ if (lock) return;
4024
+ if (getHeight(el) <= max) return;
4455
4025
  const afterExpandBtnClick = () => {
4456
4026
  var _a;
4457
4027
  lock = true;
@@ -4462,8 +4032,7 @@ function check(conf, rules) {
4462
4032
  _check();
4463
4033
  if (imgCheck) {
4464
4034
  const imgs = el.querySelectorAll(".atk-content img");
4465
- if (imgs.length === 0)
4466
- el.style.maxHeight = "";
4035
+ if (imgs.length === 0) el.style.maxHeight = "";
4467
4036
  imgs.forEach((img) => {
4468
4037
  img.onload = () => _check();
4469
4038
  });
@@ -4472,12 +4041,9 @@ function check(conf, rules) {
4472
4041
  }
4473
4042
  const HEIGHT_LIMIT_CSS = "atk-height-limit";
4474
4043
  function applyHeightLimit(obj) {
4475
- if (!obj.el)
4476
- return;
4477
- if (!obj.max)
4478
- return;
4479
- if (obj.el.classList.contains(HEIGHT_LIMIT_CSS))
4480
- return;
4044
+ if (!obj.el) return;
4045
+ if (!obj.max) return;
4046
+ if (obj.el.classList.contains(HEIGHT_LIMIT_CSS)) return;
4481
4047
  obj.el.classList.add(HEIGHT_LIMIT_CSS);
4482
4048
  obj.el.style.height = `${obj.max}px`;
4483
4049
  obj.el.style.overflow = "hidden";
@@ -4487,20 +4053,16 @@ function applyHeightLimit(obj) {
4487
4053
  $expandBtn.onclick = (e) => {
4488
4054
  e.stopPropagation();
4489
4055
  disposeHeightLimit(obj.el);
4490
- if (obj.afterExpandBtnClick)
4491
- obj.afterExpandBtnClick(e);
4056
+ if (obj.afterExpandBtnClick) obj.afterExpandBtnClick(e);
4492
4057
  };
4493
4058
  obj.el.append($expandBtn);
4494
4059
  }
4495
4060
  function disposeHeightLimit($el) {
4496
- if (!$el)
4497
- return;
4498
- if (!$el.classList.contains(HEIGHT_LIMIT_CSS))
4499
- return;
4061
+ if (!$el) return;
4062
+ if (!$el.classList.contains(HEIGHT_LIMIT_CSS)) return;
4500
4063
  $el.classList.remove(HEIGHT_LIMIT_CSS);
4501
4064
  Array.from($el.children).forEach((e) => {
4502
- if (e.classList.contains("atk-height-limit-btn"))
4503
- e.remove();
4065
+ if (e.classList.contains("atk-height-limit-btn")) e.remove();
4504
4066
  });
4505
4067
  $el.style.height = "";
4506
4068
  $el.style.maxHeight = "";
@@ -4508,10 +4070,8 @@ function disposeHeightLimit($el) {
4508
4070
  }
4509
4071
  const HEIGHT_LIMIT_SCROLL_CSS = "atk-height-limit-scroll";
4510
4072
  function applyScrollableHeightLimit(opt) {
4511
- if (!opt.el)
4512
- return;
4513
- if (opt.el.classList.contains(HEIGHT_LIMIT_SCROLL_CSS))
4514
- return;
4073
+ if (!opt.el) return;
4074
+ if (opt.el.classList.contains(HEIGHT_LIMIT_SCROLL_CSS)) return;
4515
4075
  opt.el.classList.add(HEIGHT_LIMIT_SCROLL_CSS);
4516
4076
  opt.el.style.height = `${opt.max}px`;
4517
4077
  }
@@ -4582,8 +4142,7 @@ function renderDate(ctx) {
4582
4142
  $date.setAttribute("data-atk-comment-date", String(+new Date(ctx.data.date)));
4583
4143
  }
4584
4144
  function renderUABadge(ctx) {
4585
- if (!ctx.opts.uaBadge && !ctx.data.ip_region)
4586
- return;
4145
+ if (!ctx.opts.uaBadge && !ctx.data.ip_region) return;
4587
4146
  let $uaWrap = ctx.$header.querySelector("atk-ua-wrap");
4588
4147
  if (!$uaWrap) {
4589
4148
  $uaWrap = createElement(`<span class="atk-ua-wrap"></span>`);
@@ -4638,10 +4197,8 @@ function renderContent(r) {
4638
4197
  });
4639
4198
  }
4640
4199
  function renderReplyAt(r) {
4641
- if (r.opts.flatMode || r.data.rid === 0)
4642
- return;
4643
- if (!r.opts.replyTo)
4644
- return;
4200
+ if (r.opts.flatMode || r.data.rid === 0) return;
4201
+ if (!r.opts.replyTo) return;
4645
4202
  r.$replyAt = createElement(
4646
4203
  `<span class="atk-item atk-reply-at"><span class="atk-arrow"></span><span class="atk-nick"></span></span>`
4647
4204
  );
@@ -4652,10 +4209,8 @@ function renderReplyAt(r) {
4652
4209
  r.$headerBadgeWrap.insertAdjacentElement("afterend", r.$replyAt);
4653
4210
  }
4654
4211
  function renderReplyTo(r) {
4655
- if (!r.opts.flatMode)
4656
- return;
4657
- if (!r.opts.replyTo)
4658
- return;
4212
+ if (!r.opts.flatMode) return;
4213
+ if (!r.opts.replyTo) return;
4659
4214
  r.$replyTo = createElement(`
4660
4215
  <div class="atk-reply-to">
4661
4216
  <div class="atk-meta">${t("reply")} <span class="atk-nick"></span>:</div>
@@ -4667,14 +4222,12 @@ function renderReplyTo(r) {
4667
4222
  r.comment.getActions().goToReplyComment();
4668
4223
  };
4669
4224
  let replyContent = marked(r.opts.replyTo.content);
4670
- if (r.opts.replyTo.is_collapsed)
4671
- replyContent = `[${t("collapsed")}]`;
4225
+ if (r.opts.replyTo.is_collapsed) replyContent = `[${t("collapsed")}]`;
4672
4226
  r.$replyTo.querySelector(".atk-content").innerHTML = replyContent;
4673
4227
  r.$body.prepend(r.$replyTo);
4674
4228
  }
4675
4229
  function renderPending(r) {
4676
- if (!r.data.is_pending)
4677
- return;
4230
+ if (!r.data.is_pending) return;
4678
4231
  const pendingEl = createElement(`<div class="atk-pending">${t("pendingMsg")}</div>`);
4679
4232
  r.$body.prepend(pendingEl);
4680
4233
  }
@@ -4696,8 +4249,7 @@ class ActionBtn {
4696
4249
  this.$el = createElement(`<span class="atk-common-action-btn"></span>`);
4697
4250
  this.opts = typeof opts !== "object" ? { text: opts } : opts;
4698
4251
  this.$el.innerText = this.getText();
4699
- if (this.opts.adminOnly)
4700
- this.$el.setAttribute("atk-only-admin-show", "");
4252
+ if (this.opts.adminOnly) this.$el.setAttribute("atk-only-admin-show", "");
4701
4253
  }
4702
4254
  // 消息显示复原操作
4703
4255
  get isMessaging() {
@@ -4732,8 +4284,7 @@ class ActionBtn {
4732
4284
  this.confirmRecTimer = window.setTimeout(() => confirmRestore(), 5e3);
4733
4285
  return;
4734
4286
  }
4735
- if (this.confirmRecTimer)
4736
- window.clearTimeout(this.confirmRecTimer);
4287
+ if (this.confirmRecTimer) window.clearTimeout(this.confirmRecTimer);
4737
4288
  confirmRestore();
4738
4289
  }
4739
4290
  if (this.msgRecTimer) {
@@ -4746,15 +4297,13 @@ class ActionBtn {
4746
4297
  }
4747
4298
  /** 文字刷新(动态/静态) */
4748
4299
  updateText(text) {
4749
- if (text)
4750
- this.opts.text = text;
4300
+ if (text) this.opts.text = text;
4751
4301
  this.setLoading(false);
4752
4302
  this.$el.innerText = this.getText();
4753
4303
  }
4754
4304
  /** 设置加载状态 */
4755
4305
  setLoading(value, loadingText) {
4756
- if (this.isLoading === value)
4757
- return;
4306
+ if (this.isLoading === value) return;
4758
4307
  this.isLoading = value;
4759
4308
  if (value) {
4760
4309
  this.$el.classList.add("atk-btn-loading");
@@ -4779,15 +4328,12 @@ class ActionBtn {
4779
4328
  /** 设置消息 */
4780
4329
  setMsg(text, className, duringTime, after) {
4781
4330
  this.setLoading(false);
4782
- if (className)
4783
- this.$el.classList.add(className);
4331
+ if (className) this.$el.classList.add(className);
4784
4332
  this.$el.innerText = text;
4785
4333
  this.setMsgRecTimer(() => {
4786
4334
  this.$el.innerText = this.getText();
4787
- if (className)
4788
- this.$el.classList.remove(className);
4789
- if (after)
4790
- after();
4335
+ if (className) this.$el.classList.remove(className);
4336
+ if (after) after();
4791
4337
  }, duringTime || 2500);
4792
4338
  }
4793
4339
  /** 设置消息复原操作定时器 */
@@ -4802,13 +4348,11 @@ class ActionBtn {
4802
4348
  }
4803
4349
  /** 立刻触发器复原定时器 */
4804
4350
  fireMsgRecTimer() {
4805
- if (this.msgRecTimerFunc)
4806
- this.msgRecTimerFunc();
4351
+ if (this.msgRecTimerFunc) this.msgRecTimerFunc();
4807
4352
  }
4808
4353
  /** 仅清除 timer */
4809
4354
  clearMsgRecTimer() {
4810
- if (this.msgRecTimer)
4811
- window.clearTimeout(this.msgRecTimer);
4355
+ if (this.msgRecTimer) window.clearTimeout(this.msgRecTimer);
4812
4356
  this.msgRecTimer = void 0;
4813
4357
  this.msgRecTimerFunc = void 0;
4814
4358
  }
@@ -4828,8 +4372,7 @@ function renderActions(r) {
4828
4372
  });
4829
4373
  }
4830
4374
  function renderVote(r) {
4831
- if (!r.opts.vote)
4832
- return;
4375
+ if (!r.opts.vote) return;
4833
4376
  r.voteBtnUp = new ActionBtn(() => `${t("voteUp")} (${r.data.vote_up || 0})`).appendTo(r.$actions);
4834
4377
  r.voteBtnUp.setClick(() => {
4835
4378
  r.comment.getActions().vote("up");
@@ -4844,8 +4387,7 @@ function renderVote(r) {
4844
4387
  }
4845
4388
  }
4846
4389
  function renderReply(r) {
4847
- if (!r.data.is_allow_reply)
4848
- return;
4390
+ if (!r.data.is_allow_reply) return;
4849
4391
  const replyBtn = createElement(`<span>${t("reply")}</span>`);
4850
4392
  r.$actions.append(replyBtn);
4851
4393
  replyBtn.addEventListener("click", (e) => {
@@ -4971,8 +4513,7 @@ class Render {
4971
4513
  /** 内容限高检测 */
4972
4514
  checkHeightLimit() {
4973
4515
  const conf = this.opts.heightLimit;
4974
- if (!conf || !conf.content || !conf.children)
4975
- return;
4516
+ if (!conf || !conf.content || !conf.children) return;
4976
4517
  const contentMaxH = conf.content;
4977
4518
  const childrenMaxH = conf.children;
4978
4519
  check(
@@ -4995,8 +4536,7 @@ class Render {
4995
4536
  }
4996
4537
  /** 子评论区域移除限高 */
4997
4538
  heightLimitRemoveForChildren() {
4998
- if (!this.$childrenWrap)
4999
- return;
4539
+ if (!this.$childrenWrap) return;
5000
4540
  disposeHeightLimit(this.$childrenWrap);
5001
4541
  }
5002
4542
  /** 渐出动画 */
@@ -5024,17 +4564,13 @@ class Render {
5024
4564
  }
5025
4565
  /** 设置已读 */
5026
4566
  setUnread(val) {
5027
- if (val)
5028
- this.$el.classList.add("atk-unread");
5029
- else
5030
- this.$el.classList.remove("atk-unread");
4567
+ if (val) this.$el.classList.add("atk-unread");
4568
+ else this.$el.classList.remove("atk-unread");
5031
4569
  }
5032
4570
  /** 设置为可点击的评论 */
5033
4571
  setOpenable(val) {
5034
- if (val)
5035
- this.$el.classList.add("atk-openable");
5036
- else
5037
- this.$el.classList.remove("atk-openable");
4572
+ if (val) this.$el.classList.add("atk-openable");
4573
+ else this.$el.classList.remove("atk-openable");
5038
4574
  }
5039
4575
  /** 设置点击评论打开置顶 URL */
5040
4576
  setOpenURL(url) {
@@ -5083,8 +4619,7 @@ class CommentActions {
5083
4619
  }
5084
4620
  /** 管理员 - 评论状态修改 */
5085
4621
  adminEdit(type, btnElem) {
5086
- if (btnElem.isLoading)
5087
- return;
4622
+ if (btnElem.isLoading) return;
5088
4623
  btnElem.setLoading(true, `${t("editing")}...`);
5089
4624
  const modify = __spreadValues({}, this.data);
5090
4625
  if (type === "collapsed") {
@@ -5104,13 +4639,11 @@ class CommentActions {
5104
4639
  }
5105
4640
  /** 管理员 - 评论删除 */
5106
4641
  adminDelete(btnElem) {
5107
- if (btnElem.isLoading)
5108
- return;
4642
+ if (btnElem.isLoading) return;
5109
4643
  btnElem.setLoading(true, `${t("deleting")}...`);
5110
4644
  this.getApi().comments.deleteComment(this.data.id).then(() => {
5111
4645
  btnElem.setLoading(false);
5112
- if (this.opts.onDelete)
5113
- this.opts.onDelete(this.comment);
4646
+ if (this.opts.onDelete) this.opts.onDelete(this.comment);
5114
4647
  }).catch((e) => {
5115
4648
  console.error(e);
5116
4649
  btnElem.setError(t("deleteFail"));
@@ -5121,8 +4654,7 @@ class CommentActions {
5121
4654
  const origHash = window.location.hash;
5122
4655
  const modifyHash = `#atk-comment-${this.data.rid}`;
5123
4656
  window.location.hash = modifyHash;
5124
- if (modifyHash === origHash)
5125
- window.dispatchEvent(new Event("hashchange"));
4657
+ if (modifyHash === origHash) window.dispatchEvent(new Event("hashchange"));
5126
4658
  }
5127
4659
  }
5128
4660
  class CommentNode {
@@ -5147,11 +4679,9 @@ class CommentNode {
5147
4679
  /** 渲染 UI */
5148
4680
  render() {
5149
4681
  const newEl = this.renderInstance.render();
5150
- if (this.$el)
5151
- this.$el.replaceWith(newEl);
4682
+ if (this.$el) this.$el.replaceWith(newEl);
5152
4683
  this.$el = newEl;
5153
- if (this.opts.onAfterRender)
5154
- this.opts.onAfterRender();
4684
+ if (this.opts.onAfterRender) this.opts.onAfterRender();
5155
4685
  }
5156
4686
  /** 获取评论操作实例对象 */
5157
4687
  getActions() {
@@ -5198,10 +4728,8 @@ class CommentNode {
5198
4728
  this.children.push(childNode);
5199
4729
  const $childrenWrap = this.getChildrenWrapEl();
5200
4730
  const $childComment = childNode.getEl();
5201
- if (insertMode === "append")
5202
- $childrenWrap.append($childComment);
5203
- else if (insertMode === "prepend")
5204
- $childrenWrap.prepend($childComment);
4731
+ if (insertMode === "append") $childrenWrap.append($childComment);
4732
+ else if (insertMode === "prepend") $childrenWrap.prepend($childComment);
5205
4733
  childNode.getRender().playFadeAnim();
5206
4734
  childNode.getRender().checkHeightLimit();
5207
4735
  }
@@ -5229,8 +4757,7 @@ class CommentNode {
5229
4757
  * Please be aware of the memory leak if you use the $el reference directly.
5230
4758
  */
5231
4759
  getEl() {
5232
- if (!this.$el)
5233
- throw new Error("comment element not initialized before `getEl()`");
4760
+ if (!this.$el) throw new Error("comment element not initialized before `getEl()`");
5234
4761
  return this.$el;
5235
4762
  }
5236
4763
  /**
@@ -5239,8 +4766,7 @@ class CommentNode {
5239
4766
  * Scroll to the comment and perform flash animation
5240
4767
  */
5241
4768
  focus() {
5242
- if (!this.$el)
5243
- throw new Error("comment element not initialized before `focus()`");
4769
+ if (!this.$el) throw new Error("comment element not initialized before `focus()`");
5244
4770
  this.getParents().forEach((p) => {
5245
4771
  p.getRender().heightLimitRemoveForChildren();
5246
4772
  });
@@ -5271,7 +4797,9 @@ class CommentNode {
5271
4797
  }
5272
4798
  /** 获取格式化后的日期 */
5273
4799
  getDateFormatted() {
5274
- return timeAgo(new Date(this.data.date), t);
4800
+ var _a, _b;
4801
+ const date = new Date(this.data.date);
4802
+ return ((_b = (_a = this.opts).dateFormatter) == null ? void 0 : _b.call(_a, date)) || timeAgo(date, t);
5275
4803
  }
5276
4804
  /** 获取用户 UserAgent 信息 */
5277
4805
  getUserUA() {
@@ -5305,6 +4833,7 @@ function createCommentNode(ctx, comment, replyComment, opts) {
5305
4833
  vote: ctx.conf.vote,
5306
4834
  voteDown: ctx.conf.voteDown,
5307
4835
  uaBadge: ctx.conf.uaBadge,
4836
+ dateFormatter: ctx.conf.dateFormatter,
5308
4837
  // TODO: move to plugin folder and remove from core
5309
4838
  getApi: () => ctx.getApi(),
5310
4839
  replyComment: (c, $el) => ctx.replyComment(c, $el),
@@ -5343,8 +4872,7 @@ class ReadMoreBtn {
5343
4872
  return this.total > this.offset + this.opts.pageSize;
5344
4873
  }
5345
4874
  click() {
5346
- if (this.hasMore)
5347
- this.opts.onClick(this.offset + this.opts.pageSize);
4875
+ if (this.hasMore) this.opts.onClick(this.offset + this.opts.pageSize);
5348
4876
  this.checkDisabled();
5349
4877
  }
5350
4878
  /** 显示 */
@@ -5377,10 +4905,8 @@ class ReadMoreBtn {
5377
4905
  this.checkDisabled();
5378
4906
  }
5379
4907
  checkDisabled() {
5380
- if (this.hasMore)
5381
- this.show();
5382
- else
5383
- this.hide();
4908
+ if (this.hasMore) this.show();
4909
+ else this.hide();
5384
4910
  }
5385
4911
  }
5386
4912
  class ReadMorePaginator {
@@ -5402,8 +4928,7 @@ class ReadMorePaginator {
5402
4928
  });
5403
4929
  if (opt.readMoreAutoLoad) {
5404
4930
  this.onReachedBottom = () => {
5405
- if (!this.instance.hasMore || this.opt.ctx.getData().getLoading())
5406
- return;
4931
+ if (!this.instance.hasMore || this.opt.ctx.getData().getLoading()) return;
5407
4932
  this.instance.click();
5408
4933
  };
5409
4934
  this.opt.ctx.on("list-reach-bottom", this.onReachedBottom);
@@ -5509,10 +5034,8 @@ class Pagination {
5509
5034
  }
5510
5035
  this.change(page);
5511
5036
  };
5512
- if (!now)
5513
- this.inputTimer = window.setTimeout(() => modify(), 800);
5514
- else
5515
- modify();
5037
+ if (!now) this.inputTimer = window.setTimeout(() => modify(), 800);
5038
+ else modify();
5516
5039
  }
5517
5040
  prev() {
5518
5041
  const page = this.page - 1;
@@ -5571,10 +5094,8 @@ class Pagination {
5571
5094
  }
5572
5095
  /** 加载 */
5573
5096
  setLoading(isLoading) {
5574
- if (isLoading)
5575
- showLoading(this.$el);
5576
- else
5577
- hideLoading(this.$el);
5097
+ if (isLoading) showLoading(this.$el);
5098
+ else hideLoading(this.$el);
5578
5099
  }
5579
5100
  }
5580
5101
  class UpDownPaginator {
@@ -5616,26 +5137,22 @@ class UpDownPaginator {
5616
5137
  }
5617
5138
  }
5618
5139
  function createPaginatorByConf(conf) {
5619
- if (conf.pagination.readMore)
5620
- return new ReadMorePaginator();
5140
+ if (conf.pagination.readMore) return new ReadMorePaginator();
5621
5141
  return new UpDownPaginator();
5622
5142
  }
5623
5143
  function getPageDataByLastData(ctx) {
5624
5144
  const last = ctx.getData().getListLastFetch();
5625
5145
  const r = { offset: 0, total: 0 };
5626
- if (!last)
5627
- return r;
5146
+ if (!last) return r;
5628
5147
  r.offset = last.params.offset;
5629
- if (last.data)
5630
- r.total = last.params.flatMode ? last.data.count : last.data.roots_count;
5148
+ if (last.data) r.total = last.params.flatMode ? last.data.count : last.data.roots_count;
5631
5149
  return r;
5632
5150
  }
5633
5151
  const initListPaginatorFunc = (ctx) => {
5634
5152
  let paginator = null;
5635
5153
  ctx.watchConf(["pagination", "locale"], (conf) => {
5636
5154
  const list = ctx.get("list");
5637
- if (paginator)
5638
- paginator.dispose();
5155
+ if (paginator) paginator.dispose();
5639
5156
  paginator = createPaginatorByConf(conf);
5640
5157
  const { offset, total } = getPageDataByLastData(ctx);
5641
5158
  const $paginator = paginator.create({
@@ -5775,18 +5292,14 @@ class Layer {
5775
5292
  this.$el.style.display = "";
5776
5293
  }
5777
5294
  hide() {
5778
- return __async(this, null, function* () {
5779
- this.opts.onHide();
5780
- this.$el.style.display = "none";
5781
- this.onAfterHide && this.onAfterHide();
5782
- });
5295
+ this.opts.onHide();
5296
+ this.$el.style.display = "none";
5297
+ this.onAfterHide && this.onAfterHide();
5783
5298
  }
5784
5299
  destroy() {
5785
- return __async(this, null, function* () {
5786
- this.opts.onHide();
5787
- this.$el.remove();
5788
- this.onAfterHide && this.onAfterHide();
5789
- });
5300
+ this.opts.onHide();
5301
+ this.$el.remove();
5302
+ this.onAfterHide && this.onAfterHide();
5790
5303
  }
5791
5304
  }
5792
5305
  class LayerWrap {
@@ -5864,11 +5377,12 @@ class User {
5864
5377
  this.opts = opts;
5865
5378
  const localUser = JSON.parse(window.localStorage.getItem(LOCAL_USER_KEY) || "{}");
5866
5379
  this.data = {
5867
- nick: localUser.nick || "",
5380
+ name: localUser.name || localUser.nick || "",
5381
+ // nick is deprecated (for historical compatibility)
5868
5382
  email: localUser.email || "",
5869
5383
  link: localUser.link || "",
5870
5384
  token: localUser.token || "",
5871
- isAdmin: localUser.isAdmin || false
5385
+ is_admin: localUser.is_admin || localUser.isAdmin || false
5872
5386
  };
5873
5387
  }
5874
5388
  getData() {
@@ -5885,17 +5399,17 @@ class User {
5885
5399
  /**
5886
5400
  * Logout
5887
5401
  *
5888
- * @description Logout will clear login status, but not clear user data (nick, email, link)
5402
+ * @description Logout will clear login status, but not clear user data (name, email, link)
5889
5403
  */
5890
5404
  logout() {
5891
5405
  this.update({
5892
5406
  token: "",
5893
- isAdmin: false
5407
+ is_admin: false
5894
5408
  });
5895
5409
  }
5896
5410
  /** Check if user has filled basic data */
5897
5411
  checkHasBasicUserInfo() {
5898
- return !!this.data.nick && !!this.data.email;
5412
+ return !!this.data.name && !!this.data.email;
5899
5413
  }
5900
5414
  }
5901
5415
  const services = {
@@ -5979,8 +5493,7 @@ function initCountWidget(opt) {
5979
5493
  }
5980
5494
  function incrementPvCount(opt) {
5981
5495
  return __async(this, null, function* () {
5982
- if (!opt.pvAdd || !opt.pageKey)
5983
- return void 0;
5496
+ if (!opt.pvAdd || !opt.pageKey) return void 0;
5984
5497
  const pvCount = (yield opt.getApi().pages.logPv({
5985
5498
  page_key: opt.pageKey,
5986
5499
  page_title: opt.pageTitle,
@@ -5998,7 +5511,7 @@ function loadCommentCount(opt) {
5998
5511
  }
5999
5512
  function loadPvCount(opt, cache) {
6000
5513
  return __async(this, null, function* () {
6001
- yield loadStatCount({ opt, query: "page_pv", containers: [opt.pvEl, "#ArtalkPv"], cache });
5514
+ yield loadStatCount({ opt, query: "page_pv", containers: [opt.pvEl, "#ArtalkPV"], cache });
6002
5515
  });
6003
5516
  }
6004
5517
  function loadStatCount(args) {
@@ -6135,11 +5648,11 @@ class SubmitAddPreset {
6135
5648
  }
6136
5649
  getSubmitAddParams() {
6137
5650
  return __async(this, null, function* () {
6138
- const { nick, email, link } = this.kit.useUser().getData();
5651
+ const { name, email, link } = this.kit.useUser().getData();
6139
5652
  const conf = this.kit.useConf();
6140
5653
  return {
6141
5654
  content: this.kit.useEditor().getContentFinal(),
6142
- name: nick,
5655
+ name,
6143
5656
  email,
6144
5657
  link,
6145
5658
  rid: 0,
@@ -6181,17 +5694,12 @@ class Submit extends EditorPlug {
6181
5694
  const custom = this.customs.find((o) => o.activeCond());
6182
5695
  this.kit.useEditor().showLoading();
6183
5696
  try {
6184
- if (custom == null ? void 0 : custom.pre)
6185
- custom.pre();
5697
+ if (custom == null ? void 0 : custom.pre) custom.pre();
6186
5698
  let nComment;
6187
- if (custom == null ? void 0 : custom.req)
6188
- nComment = yield custom.req();
6189
- else
6190
- nComment = yield this.defaultPreset.reqAdd();
6191
- if (custom == null ? void 0 : custom.post)
6192
- custom.post(nComment);
6193
- else
6194
- this.defaultPreset.postSubmitAdd(nComment);
5699
+ if (custom == null ? void 0 : custom.req) nComment = yield custom.req();
5700
+ else nComment = yield this.defaultPreset.reqAdd();
5701
+ if (custom == null ? void 0 : custom.post) custom.post(nComment);
5702
+ else this.defaultPreset.postSubmitAdd(nComment);
6195
5703
  } catch (err) {
6196
5704
  console.error(err);
6197
5705
  this.kit.useEditor().showNotify(`${t("commentFail")}: ${err.message || String(err)}`, "e");
@@ -6216,15 +5724,13 @@ class StateReply extends EditorPlug {
6216
5724
  });
6217
5725
  this.kit.useEvents().on("mounted", () => {
6218
5726
  const submitPlug = this.kit.useDeps(Submit);
6219
- if (!submitPlug)
6220
- throw Error("SubmitPlug not initialized");
5727
+ if (!submitPlug) throw Error("SubmitPlug not initialized");
6221
5728
  const defaultPreset = new SubmitAddPreset(this.kit);
6222
5729
  submitPlug.registerCustom({
6223
5730
  activeCond: () => !!this.comment,
6224
5731
  // active this custom submit when reply mode
6225
5732
  req: () => __async(this, null, function* () {
6226
- if (!this.comment)
6227
- throw new Error("reply comment cannot be empty");
5733
+ if (!this.comment) throw new Error("reply comment cannot be empty");
6228
5734
  const nComment = (yield this.kit.useApi().comments.createComment(__spreadProps(__spreadValues({}, yield defaultPreset.getSubmitAddParams()), {
6229
5735
  rid: this.comment.id,
6230
5736
  page_key: this.comment.page_key,
@@ -6260,8 +5766,7 @@ class StateReply extends EditorPlug {
6260
5766
  ui.$textarea.focus();
6261
5767
  }
6262
5768
  cancelReply() {
6263
- if (!this.comment)
6264
- return;
5769
+ if (!this.comment) return;
6265
5770
  const ui = this.kit.useUI();
6266
5771
  if (ui.$sendReplyBtn) {
6267
5772
  ui.$sendReplyBtn.remove();
@@ -6286,15 +5791,14 @@ class StateEdit extends EditorPlug {
6286
5791
  });
6287
5792
  this.kit.useMounted(() => {
6288
5793
  const submitPlug = this.kit.useDeps(Submit);
6289
- if (!submitPlug)
6290
- throw Error("SubmitPlug not initialized");
5794
+ if (!submitPlug) throw Error("SubmitPlug not initialized");
6291
5795
  submitPlug.registerCustom({
6292
5796
  activeCond: () => !!this.comment,
6293
5797
  // active this custom submit when edit mode
6294
5798
  req: () => __async(this, null, function* () {
6295
5799
  const saveData = {
6296
5800
  content: this.kit.useEditor().getContentFinal(),
6297
- nick: this.kit.useUI().$nick.value,
5801
+ nick: this.kit.useUI().$name.value,
6298
5802
  email: this.kit.useUI().$email.value,
6299
5803
  link: this.kit.useUI().$link.value
6300
5804
  };
@@ -6322,7 +5826,7 @@ class StateEdit extends EditorPlug {
6322
5826
  }
6323
5827
  this.comment = comment;
6324
5828
  ui.$header.style.display = "none";
6325
- ui.$nick.value = comment.nick || "";
5829
+ ui.$name.value = comment.nick || "";
6326
5830
  ui.$email.value = comment.email || "";
6327
5831
  ui.$link.value = comment.link || "";
6328
5832
  this.kit.useEditor().setContent(comment.content);
@@ -6330,16 +5834,15 @@ class StateEdit extends EditorPlug {
6330
5834
  this.updateSubmitBtnText(t("save"));
6331
5835
  }
6332
5836
  cancelEdit() {
6333
- if (!this.comment)
6334
- return;
5837
+ if (!this.comment) return;
6335
5838
  const ui = this.kit.useUI();
6336
5839
  if (ui.$editCancelBtn) {
6337
5840
  ui.$editCancelBtn.remove();
6338
5841
  ui.$editCancelBtn = void 0;
6339
5842
  }
6340
5843
  this.comment = void 0;
6341
- const { nick, email, link } = this.kit.useUser().getData();
6342
- ui.$nick.value = nick;
5844
+ const { name, email, link } = this.kit.useUser().getData();
5845
+ ui.$name.value = name;
6343
5846
  ui.$email.value = email;
6344
5847
  ui.$link.value = link;
6345
5848
  this.kit.useEditor().setContent("");
@@ -6379,7 +5882,7 @@ class Closable extends EditorPlug {
6379
5882
  this.kit.useUI().$textareaWrap.prepend(
6380
5883
  createElement(`<div class="atk-comment-closed">${t("onlyAdminCanReply")}</div>`)
6381
5884
  );
6382
- if (!this.kit.useUser().getData().isAdmin) {
5885
+ if (!this.kit.useUser().getData().is_admin) {
6383
5886
  this.kit.useUI().$textarea.style.display = "none";
6384
5887
  this.kit.useEvents().trigger("panel-close");
6385
5888
  this.kit.useUI().$bottom.style.display = "none";
@@ -6428,15 +5931,18 @@ class HeaderUser extends EditorPlug {
6428
5931
  abortFn: null
6429
5932
  });
6430
5933
  const onInput = ({ $input, field }) => {
6431
- if (this.kit.useEditor().getState() === "edit")
6432
- return;
5934
+ if (this.kit.useEditor().getState() === "edit") return;
6433
5935
  this.kit.useUser().update({ [field]: $input.value.trim() });
6434
- if (field === "nick" || field === "email")
6435
- this.fetchUserInfo();
5936
+ if (field === "name" || field === "email") this.fetchUserInfo();
5937
+ };
5938
+ const placeholders = {
5939
+ name: t("nick"),
5940
+ email: t("email"),
5941
+ link: t("link")
6436
5942
  };
6437
5943
  this.kit.useMounted(() => {
6438
5944
  Object.entries(this.kit.useEditor().getHeaderInputEls()).forEach(([key, $input]) => {
6439
- $input.placeholder = `${t(key)}`;
5945
+ $input.placeholder = placeholders[key];
6440
5946
  $input.value = this.kit.useUser().getData()[key] || "";
6441
5947
  });
6442
5948
  this.kit.useEvents().on("header-input", onInput);
@@ -6450,10 +5956,8 @@ class HeaderUser extends EditorPlug {
6450
5956
  */
6451
5957
  fetchUserInfo() {
6452
5958
  this.kit.useUser().logout();
6453
- if (this.query.timer)
6454
- window.clearTimeout(this.query.timer);
6455
- if (this.query.abortFn)
6456
- this.query.abortFn();
5959
+ if (this.query.timer) window.clearTimeout(this.query.timer);
5960
+ if (this.query.abortFn) this.query.abortFn();
6457
5961
  this.query.timer = window.setTimeout(() => {
6458
5962
  this.query.timer = null;
6459
5963
  const api = this.kit.useApi();
@@ -6477,8 +5981,7 @@ class HeaderUser extends EditorPlug {
6477
5981
  */
6478
5982
  onUserInfoFetched(data) {
6479
5983
  var _a;
6480
- if (!data.is_login)
6481
- this.kit.useUser().logout();
5984
+ if (!data.is_login) this.kit.useUser().logout();
6482
5985
  this.kit.useGlobalCtx().getData().updateNotifies(data.notifies);
6483
5986
  if (this.kit.useUser().checkHasBasicUserInfo() && !data.is_login && ((_a = data.user) == null ? void 0 : _a.is_admin)) {
6484
5987
  this.kit.useGlobalCtx().checkAdmin({
@@ -6496,8 +5999,7 @@ class HeaderLink extends EditorPlug {
6496
5999
  constructor(kit) {
6497
6000
  super(kit);
6498
6001
  const onLinkChange = ({ field }) => {
6499
- if (field === "link")
6500
- this.onLinkInputChange();
6002
+ if (field === "link") this.onLinkInputChange();
6501
6003
  };
6502
6004
  this.kit.useMounted(() => {
6503
6005
  this.kit.useEvents().on("header-change", onLinkChange);
@@ -6553,8 +6055,7 @@ class Emoticons extends EditorPlug {
6553
6055
  }
6554
6056
  loadEmoticonsData() {
6555
6057
  return __async(this, null, function* () {
6556
- if (this.isListLoaded)
6557
- return;
6058
+ if (this.isListLoaded) return;
6558
6059
  if (this.loadingTask !== null) {
6559
6060
  yield this.loadingTask;
6560
6061
  return;
@@ -6580,10 +6081,8 @@ class Emoticons extends EditorPlug {
6580
6081
  return [];
6581
6082
  }
6582
6083
  const pushGrp = (grp) => {
6583
- if (typeof grp !== "object")
6584
- return;
6585
- if (grp.name && data.find((o) => o.name === grp.name))
6586
- return;
6084
+ if (typeof grp !== "object") return;
6085
+ if (grp.name && data.find((o) => o.name === grp.name)) return;
6587
6086
  data.push(grp);
6588
6087
  };
6589
6088
  const remoteLoad = (d) => __async(this, null, function* () {
@@ -6595,10 +6094,8 @@ class Emoticons extends EditorPlug {
6595
6094
  yield remoteLoad(grp);
6596
6095
  } else if (typeof grp === "string") {
6597
6096
  const grpData = yield this.remoteLoad(grp);
6598
- if (Array.isArray(grpData))
6599
- yield remoteLoad(grpData);
6600
- else if (typeof grpData === "object")
6601
- pushGrp(grpData);
6097
+ if (Array.isArray(grpData)) yield remoteLoad(grpData);
6098
+ else if (typeof grpData === "object") pushGrp(grpData);
6602
6099
  }
6603
6100
  }))
6604
6101
  );
@@ -6627,8 +6124,7 @@ class Emoticons extends EditorPlug {
6627
6124
  /** 远程加载 */
6628
6125
  remoteLoad(url) {
6629
6126
  return __async(this, null, function* () {
6630
- if (!url)
6631
- return [];
6127
+ if (!url) return [];
6632
6128
  try {
6633
6129
  const resp = yield fetch(url);
6634
6130
  const json = yield resp.json();
@@ -6645,8 +6141,7 @@ class Emoticons extends EditorPlug {
6645
6141
  solveNullKey(data) {
6646
6142
  data.forEach((grp) => {
6647
6143
  grp.items.forEach((item, index) => {
6648
- if (!item.key)
6649
- item.key = `${grp.name} ${index + 1}`;
6144
+ if (!item.key) item.key = `${grp.name} ${index + 1}`;
6650
6145
  });
6651
6146
  });
6652
6147
  }
@@ -6655,14 +6150,10 @@ class Emoticons extends EditorPlug {
6655
6150
  const tmp = {};
6656
6151
  data.forEach((grp) => {
6657
6152
  grp.items.forEach((item) => {
6658
- if (!item.key || String(item.key).trim() === "")
6659
- return;
6660
- if (!tmp[item.key])
6661
- tmp[item.key] = 1;
6662
- else
6663
- tmp[item.key]++;
6664
- if (tmp[item.key] > 1)
6665
- item.key = `${item.key} ${tmp[item.key]}`;
6153
+ if (!item.key || String(item.key).trim() === "") return;
6154
+ if (!tmp[item.key]) tmp[item.key] = 1;
6155
+ else tmp[item.key]++;
6156
+ if (tmp[item.key] > 1) item.key = `${item.key} ${tmp[item.key]}`;
6666
6157
  });
6667
6158
  });
6668
6159
  }
@@ -6683,8 +6174,7 @@ class Emoticons extends EditorPlug {
6683
6174
  const iconStr = item.icon;
6684
6175
  if (/<(img|IMG)/.test(iconStr)) {
6685
6176
  const find = /src=["'](.*?)["']/.exec(iconStr);
6686
- if (find && find.length > 1)
6687
- item.icon = find[1];
6177
+ if (find && find.length > 1) item.icon = find[1];
6688
6178
  }
6689
6179
  nGrp.items.push({
6690
6180
  key: item.text || `${grpName} ${index + 1}`,
@@ -6738,8 +6228,7 @@ class Emoticons extends EditorPlug {
6738
6228
  this.$grpSwitcher.append($item);
6739
6229
  });
6740
6230
  }
6741
- if (this.emoticons.length > 0)
6742
- this.openGrp(0);
6231
+ if (this.emoticons.length > 0) this.openGrp(0);
6743
6232
  }
6744
6233
  /** 打开一个表情组 */
6745
6234
  openGrp(index) {
@@ -6760,11 +6249,9 @@ class Emoticons extends EditorPlug {
6760
6249
  }
6761
6250
  /** 处理评论 content 中的表情内容 */
6762
6251
  transEmoticonImageText(text) {
6763
- if (!this.emoticons || !Array.isArray(this.emoticons))
6764
- return text;
6252
+ if (!this.emoticons || !Array.isArray(this.emoticons)) return text;
6765
6253
  this.emoticons.forEach((grp) => {
6766
- if (grp.type !== "image")
6767
- return;
6254
+ if (grp.type !== "image") return;
6768
6255
  Object.entries(grp.items).forEach(([index, item]) => {
6769
6256
  text = text.split(`:[${item.key}]`).join(`<img src="${item.val}" atk-emoticon="${item.key}">`);
6770
6257
  });
@@ -6793,8 +6280,7 @@ class Upload extends EditorPlug {
6793
6280
  const $input = this.$imgUploadInput;
6794
6281
  $input.onchange = () => {
6795
6282
  (() => __async(this, null, function* () {
6796
- if (!$input.files || $input.files.length === 0)
6797
- return;
6283
+ if (!$input.files || $input.files.length === 0) return;
6798
6284
  const file = $input.files[0];
6799
6285
  this.uploadImg(file);
6800
6286
  }))();
@@ -6807,8 +6293,7 @@ class Upload extends EditorPlug {
6807
6293
  }
6808
6294
  initDragImg() {
6809
6295
  const uploadFromFileList = (files) => {
6810
- if (!files)
6811
- return;
6296
+ if (!files) return;
6812
6297
  for (let i = 0; i < files.length; i++) {
6813
6298
  const file = files[i];
6814
6299
  this.uploadImg(file);
@@ -6848,15 +6333,13 @@ class Upload extends EditorPlug {
6848
6333
  uploadImg(file) {
6849
6334
  return __async(this, null, function* () {
6850
6335
  const fileExt = /[^.]+$/.exec(file.name);
6851
- if (!fileExt || !AllowImgExts.includes(String(fileExt[0]).toLowerCase()))
6852
- return;
6336
+ if (!fileExt || !AllowImgExts.includes(String(fileExt[0]).toLowerCase())) return;
6853
6337
  if (!this.kit.useUser().checkHasBasicUserInfo()) {
6854
6338
  this.kit.useEditor().showNotify(t("uploadLoginMsg"), "w");
6855
6339
  return;
6856
6340
  }
6857
6341
  let insertPrefix = "\n";
6858
- if (this.kit.useUI().$textarea.value.trim() === "")
6859
- insertPrefix = "";
6342
+ if (this.kit.useUI().$textarea.value.trim() === "") insertPrefix = "";
6860
6343
  const uploadPlaceholderTxt = `${insertPrefix}![](Uploading ${file.name}...)`;
6861
6344
  this.kit.useEditor().insertContent(uploadPlaceholderTxt);
6862
6345
  let resp;
@@ -7026,8 +6509,7 @@ class PlugManager {
7026
6509
  clear() {
7027
6510
  this.plugs = [];
7028
6511
  this.events = new EventManager();
7029
- if (this.openedPlug)
7030
- this.closePlugPanel();
6512
+ if (this.openedPlug) this.closePlugPanel();
7031
6513
  }
7032
6514
  loadPluginUI() {
7033
6515
  this.editor.getUI().$plugPanelWrap.innerHTML = "";
@@ -7038,8 +6520,7 @@ class PlugManager {
7038
6520
  /** Load the plug btn and plug panel on editor ui */
7039
6521
  loadPluginItem(plug) {
7040
6522
  const $btn = plug.$btn;
7041
- if (!$btn)
7042
- return;
6523
+ if (!$btn) return;
7043
6524
  this.editor.getUI().$plugBtnWrap.appendChild($btn);
7044
6525
  !$btn.onclick && ($btn.onclick = () => {
7045
6526
  this.editor.getUI().$plugBtnWrap.querySelectorAll(".active").forEach((item) => item.classList.remove("active"));
@@ -7063,8 +6544,7 @@ class PlugManager {
7063
6544
  openPlugPanel(plug) {
7064
6545
  this.plugs.forEach((aPlug) => {
7065
6546
  const plugPanel = aPlug.$panel;
7066
- if (!plugPanel)
7067
- return;
6547
+ if (!plugPanel) return;
7068
6548
  if (aPlug === plug) {
7069
6549
  plugPanel.style.display = "";
7070
6550
  this.events.trigger("panel-show", plug);
@@ -7078,8 +6558,7 @@ class PlugManager {
7078
6558
  }
7079
6559
  /** Close the editor plug panel */
7080
6560
  closePlugPanel() {
7081
- if (!this.openedPlug)
7082
- return;
6561
+ if (!this.openedPlug) return;
7083
6562
  this.editor.getUI().$plugPanelWrap.style.display = "none";
7084
6563
  this.events.trigger("panel-hide", this.openedPlug);
7085
6564
  this.openedPlug = null;
@@ -7088,8 +6567,7 @@ class PlugManager {
7088
6567
  getTransformedContent(rawContent) {
7089
6568
  let result = rawContent;
7090
6569
  this.plugs.forEach((aPlug) => {
7091
- if (!aPlug.contentTransformer)
7092
- return;
6570
+ if (!aPlug.contentTransformer) return;
7093
6571
  result = aPlug.contentTransformer(result);
7094
6572
  });
7095
6573
  return result;
@@ -7102,8 +6580,7 @@ const WithEditor = (ctx) => {
7102
6580
  $closeCommentBtn = list.$el.querySelector('[data-action="admin-close-comment"]');
7103
6581
  $closeCommentBtn.addEventListener("click", () => {
7104
6582
  const page = ctx.getData().getPage();
7105
- if (!page)
7106
- throw new Error("Page data not found");
6583
+ if (!page) throw new Error("Page data not found");
7107
6584
  page.admin_only = !page.admin_only;
7108
6585
  adminPageEditSave(ctx, page);
7109
6586
  });
@@ -7165,8 +6642,7 @@ const Count = (ctx) => {
7165
6642
  var _a, _b;
7166
6643
  const list = ctx.get("list");
7167
6644
  const $count = list.$el.querySelector(".atk-comment-count .atk-text");
7168
- if (!$count)
7169
- return;
6645
+ if (!$count) return;
7170
6646
  const text = htmlEncode(
7171
6647
  t("counter", {
7172
6648
  count: `${Number((_b = (_a = ctx.getData().getListLastFetch()) == null ? void 0 : _a.data) == null ? void 0 : _b.count) || 0}`
@@ -7179,26 +6655,22 @@ const Count = (ctx) => {
7179
6655
  });
7180
6656
  ctx.on("comment-inserted", () => {
7181
6657
  const last = ctx.getData().getListLastFetch();
7182
- if (last == null ? void 0 : last.data)
7183
- last.data.count += 1;
6658
+ if (last == null ? void 0 : last.data) last.data.count += 1;
7184
6659
  });
7185
6660
  ctx.on("comment-deleted", () => {
7186
6661
  const last = ctx.getData().getListLastFetch();
7187
- if (last == null ? void 0 : last.data)
7188
- last.data.count -= 1;
6662
+ if (last == null ? void 0 : last.data) last.data.count -= 1;
7189
6663
  });
7190
6664
  };
7191
6665
  const SidebarBtn = (ctx) => {
7192
6666
  let $openSidebarBtn = null;
7193
6667
  const syncByUser = () => {
7194
- if (!$openSidebarBtn)
7195
- return;
6668
+ if (!$openSidebarBtn) return;
7196
6669
  const user = ctx.get("user").getData();
7197
- if (!!user.nick && !!user.email) {
6670
+ if (!!user.name && !!user.email) {
7198
6671
  $openSidebarBtn.classList.remove("atk-hide");
7199
6672
  const $btnText = $openSidebarBtn.querySelector(".atk-text");
7200
- if ($btnText)
7201
- $btnText.innerText = !user.isAdmin ? t("msgCenter") : t("ctrlCenter");
6673
+ if ($btnText) $btnText.innerText = !user.is_admin ? t("msgCenter") : t("ctrlCenter");
7202
6674
  } else {
7203
6675
  $openSidebarBtn.classList.add("atk-hide");
7204
6676
  }
@@ -7206,8 +6678,7 @@ const SidebarBtn = (ctx) => {
7206
6678
  ctx.watchConf(["locale"], (conf) => {
7207
6679
  const list = ctx.get("list");
7208
6680
  $openSidebarBtn = list.$el.querySelector('[data-action="open-sidebar"]');
7209
- if (!$openSidebarBtn)
7210
- return;
6681
+ if (!$openSidebarBtn) return;
7211
6682
  $openSidebarBtn.onclick = () => {
7212
6683
  ctx.showSidebar();
7213
6684
  };
@@ -7220,8 +6691,7 @@ const SidebarBtn = (ctx) => {
7220
6691
  const UnreadBadge = (ctx) => {
7221
6692
  let $unreadBadge = null;
7222
6693
  const showUnreadBadge = (count) => {
7223
- if (!$unreadBadge)
7224
- return;
6694
+ if (!$unreadBadge) return;
7225
6695
  if (count > 0) {
7226
6696
  $unreadBadge.innerText = `${Number(count || 0)}`;
7227
6697
  $unreadBadge.style.display = "block";
@@ -7241,10 +6711,8 @@ const GotoDispatcher = (ctx) => {
7241
6711
  let lastID = 0;
7242
6712
  const check2 = ({ locker }) => {
7243
6713
  const commentID = extractCommentID();
7244
- if (!commentID)
7245
- return;
7246
- if (locker && lastID === commentID)
7247
- return;
6714
+ if (!commentID) return;
6715
+ if (locker && lastID === commentID) return;
7248
6716
  lastID = commentID;
7249
6717
  ctx.trigger("list-goto", commentID);
7250
6718
  };
@@ -7275,18 +6743,16 @@ const GotoFocus = (ctx) => {
7275
6743
  ctx.get("list").getListLayout({ forceFlatMode: true }).insert(data.comment, data.reply_comment);
7276
6744
  comment = ctx.getCommentNodes().find((c) => c.getID() === commentID);
7277
6745
  }
7278
- if (!comment)
7279
- return;
6746
+ if (!comment) return;
7280
6747
  comment.focus();
7281
6748
  }));
7282
6749
  };
7283
- const version = "2.8.7";
6750
+ const version = "2.9.1";
7284
6751
  const Copyright = (ctx) => {
7285
6752
  ctx.on("mounted", () => {
7286
6753
  const list = ctx.get("list");
7287
6754
  const $copyright = list.$el.querySelector(".atk-copyright");
7288
- if (!$copyright)
7289
- return;
6755
+ if (!$copyright) return;
7290
6756
  $copyright.innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${version}">Artalk</a>`;
7291
6757
  });
7292
6758
  };
@@ -7353,8 +6819,7 @@ const Dropdown = (ctx) => {
7353
6819
  ctx.watchConf(["listSort", "locale"], (conf) => {
7354
6820
  const list = ctx.get("list");
7355
6821
  const $count = list.$el.querySelector(".atk-comment-count");
7356
- if (!$count)
7357
- return;
6822
+ if (!$count) return;
7358
6823
  if (conf.listSort) {
7359
6824
  initDropdown($count);
7360
6825
  } else {
@@ -7366,8 +6831,7 @@ const Dropdown = (ctx) => {
7366
6831
  };
7367
6832
  function renderDropdown(conf) {
7368
6833
  const { $dropdownWrap, dropdownList } = conf;
7369
- if ($dropdownWrap.querySelector(".atk-dropdown"))
7370
- return;
6834
+ if ($dropdownWrap.querySelector(".atk-dropdown")) return;
7371
6835
  $dropdownWrap.classList.add("atk-dropdown-wrap");
7372
6836
  $dropdownWrap.append(createElement(`<span class="atk-arrow-down-icon"></span>`));
7373
6837
  let curtActive = 0;
@@ -7393,8 +6857,7 @@ function renderDropdown(conf) {
7393
6857
  onItemClick(i, $item, name, action);
7394
6858
  };
7395
6859
  $dropdown.append($item);
7396
- if (i === curtActive)
7397
- $item.classList.add("active");
6860
+ if (i === curtActive) $item.classList.add("active");
7398
6861
  });
7399
6862
  $dropdownWrap.append($dropdown);
7400
6863
  }
@@ -7411,8 +6874,9 @@ const TimeTicking = (ctx) => {
7411
6874
  timer = window.setInterval(() => {
7412
6875
  const list = ctx.get("list");
7413
6876
  list.$el.querySelectorAll("[data-atk-comment-date]").forEach((el) => {
7414
- const date = el.getAttribute("data-atk-comment-date");
7415
- el.innerText = timeAgo(new Date(Number(date)), ctx.$t);
6877
+ var _a, _b;
6878
+ const date = new Date(Number(el.getAttribute("data-atk-comment-date")));
6879
+ el.innerText = ((_b = (_a = ctx.getConf()).dateFormatter) == null ? void 0 : _b.call(_a, date)) || timeAgo(date, ctx.$t);
7416
6880
  });
7417
6881
  }, 30 * 1e3);
7418
6882
  });
@@ -7465,8 +6929,7 @@ const Loading = (ctx) => {
7465
6929
  };
7466
6930
  const Fetch = (ctx) => {
7467
6931
  ctx.on("list-fetch", (_params) => {
7468
- if (ctx.getData().getLoading())
7469
- return;
6932
+ if (ctx.getData().getLoading()) return;
7470
6933
  ctx.getData().setLoading(true);
7471
6934
  const params = __spreadValues({
7472
6935
  // default params
@@ -7486,8 +6949,7 @@ const Fetch = (ctx) => {
7486
6949
  page_key: ctx.getConf().pageKey,
7487
6950
  site_name: ctx.getConf().site
7488
6951
  };
7489
- if (params.paramsModifier)
7490
- params.paramsModifier(reqParams);
6952
+ if (params.paramsModifier) params.paramsModifier(reqParams);
7491
6953
  ctx.getApi().comments.getComments(__spreadValues(__spreadValues({}, reqParams), ctx.getApi().getUserFields())).then(({ data }) => {
7492
6954
  ctx.getData().setListLastFetch({ params, data });
7493
6955
  ctx.getData().loadComments(data.comments);
@@ -7538,8 +7000,7 @@ const ReachBottom = (ctx) => {
7538
7000
  const list = ctx.get("list");
7539
7001
  const children = list.getCommentsWrapEl().childNodes;
7540
7002
  const $target = children.length > 2 ? children[children.length - 2] : null;
7541
- if (!$target)
7542
- return;
7003
+ if (!$target) return;
7543
7004
  if (!("IntersectionObserver" in window)) {
7544
7005
  console.warn("IntersectionObserver api not supported");
7545
7006
  return;
@@ -7586,11 +7047,9 @@ const ListPlugins = [
7586
7047
  ];
7587
7048
  const Notifies = (ctx) => {
7588
7049
  ctx.on("list-fetch", (params) => {
7589
- if (params.offset !== 0)
7590
- return;
7050
+ if (params.offset !== 0) return;
7591
7051
  const user = ctx.getApi().getUserFields();
7592
- if (!user)
7593
- return;
7052
+ if (!user) return;
7594
7053
  ctx.getApi().notifies.getNotifies(user).then((res) => {
7595
7054
  ctx.getData().updateNotifies(res.data.notifies);
7596
7055
  });
@@ -7607,8 +7066,7 @@ const VersionCheck = (ctx) => {
7607
7066
  function versionCheck(list, feVer, beVer) {
7608
7067
  const comp = versionCompare(feVer, beVer);
7609
7068
  const sameVer = comp === 0;
7610
- if (sameVer)
7611
- return;
7069
+ if (sameVer) return;
7612
7070
  const errEl = createElement(
7613
7071
  `<div class="atk-version-check-notice">${t("updateMsg", {
7614
7072
  name: comp < 0 ? t("frontend") : t("backend")
@@ -7625,7 +7083,7 @@ function versionCheck(list, feVer, beVer) {
7625
7083
  const AdminOnlyElem = (ctx) => {
7626
7084
  const scanApply = () => {
7627
7085
  applyAdminOnlyEls(
7628
- ctx.get("user").getData().isAdmin,
7086
+ ctx.get("user").getData().is_admin,
7629
7087
  getAdminOnlyEls({
7630
7088
  $root: ctx.$root
7631
7089
  })
@@ -7648,20 +7106,16 @@ function getAdminOnlyEls(opts) {
7648
7106
  }
7649
7107
  function applyAdminOnlyEls(isAdmin, els) {
7650
7108
  els.forEach(($item) => {
7651
- if (isAdmin)
7652
- $item.classList.remove("atk-hide");
7653
- else
7654
- $item.classList.add("atk-hide");
7109
+ if (isAdmin) $item.classList.remove("atk-hide");
7110
+ else $item.classList.add("atk-hide");
7655
7111
  });
7656
7112
  }
7657
7113
  let darkModeMedia;
7658
7114
  function updateClassnames($els, darkMode) {
7659
7115
  const DarkModeClassName = "atk-dark-mode";
7660
7116
  $els.forEach(($el) => {
7661
- if (darkMode)
7662
- $el.classList.add(DarkModeClassName);
7663
- else
7664
- $el.classList.remove(DarkModeClassName);
7117
+ if (darkMode) $el.classList.add(DarkModeClassName);
7118
+ else $el.classList.remove(DarkModeClassName);
7665
7119
  });
7666
7120
  }
7667
7121
  const DarkMode = (ctx) => {
@@ -7703,6 +7157,7 @@ const DefaultPlugins = [
7703
7157
  DarkMode
7704
7158
  ];
7705
7159
  const GlobalPlugins = /* @__PURE__ */ new Set([...DefaultPlugins]);
7160
+ const PluginOptions = /* @__PURE__ */ new WeakMap();
7706
7161
  function load(ctx) {
7707
7162
  return __async(this, null, function* () {
7708
7163
  var _a;
@@ -7710,7 +7165,7 @@ function load(ctx) {
7710
7165
  const loadPlugins = (plugins) => {
7711
7166
  plugins.forEach((plugin) => {
7712
7167
  if (typeof plugin === "function" && !loadedPlugins.has(plugin)) {
7713
- plugin(ctx);
7168
+ plugin(ctx, PluginOptions.get(plugin));
7714
7169
  loadedPlugins.add(plugin);
7715
7170
  }
7716
7171
  });
@@ -7748,14 +7203,13 @@ function load(ctx) {
7748
7203
  function loadNetworkPlugins(scripts, apiBase) {
7749
7204
  return __async(this, null, function* () {
7750
7205
  const networkPlugins = /* @__PURE__ */ new Set();
7751
- if (!scripts || !Array.isArray(scripts))
7752
- return networkPlugins;
7206
+ if (!scripts || !Array.isArray(scripts)) return networkPlugins;
7753
7207
  const tasks = [];
7754
7208
  scripts.forEach((url) => {
7755
7209
  if (!/^(http|https):\/\//.test(url))
7756
7210
  url = `${apiBase.replace(/\/$/, "")}/${url.replace(/^\//, "")}`;
7757
7211
  tasks.push(
7758
- new Promise((resolve, reject) => {
7212
+ new Promise((resolve) => {
7759
7213
  if (document.querySelector(`script[src="${url}"]`)) {
7760
7214
  resolve();
7761
7215
  return;
@@ -7764,14 +7218,16 @@ function loadNetworkPlugins(scripts, apiBase) {
7764
7218
  script.src = url;
7765
7219
  document.head.appendChild(script);
7766
7220
  script.onload = () => resolve();
7767
- script.onerror = (err) => reject(err);
7221
+ script.onerror = (err) => {
7222
+ console.error("[artalk] Failed to load plugin", err);
7223
+ resolve();
7224
+ };
7768
7225
  })
7769
7226
  );
7770
7227
  });
7771
7228
  yield Promise.all(tasks);
7772
7229
  Object.values(window.ArtalkPlugins || {}).forEach((plugin) => {
7773
- if (typeof plugin === "function")
7774
- networkPlugins.add(plugin);
7230
+ if (typeof plugin === "function") networkPlugins.add(plugin);
7775
7231
  });
7776
7232
  return networkPlugins;
7777
7233
  });
@@ -7791,7 +7247,7 @@ function onLoadErr(ctx, err) {
7791
7247
  errMsg: err.msg || String(err),
7792
7248
  errData: err.data,
7793
7249
  retryFn: () => load(ctx),
7794
- onOpenSidebar: ctx.get("user").getData().isAdmin ? () => ctx.showSidebar({
7250
+ onOpenSidebar: ctx.get("user").getData().is_admin ? () => ctx.showSidebar({
7795
7251
  view: sidebarOpenView
7796
7252
  }) : void 0
7797
7253
  // only show open sidebar button when user is admin
@@ -7858,8 +7314,9 @@ class Artalk {
7858
7314
  return new Artalk(conf);
7859
7315
  }
7860
7316
  /** Use plugin, the plugin will be used when Artalk.init */
7861
- static use(plugin) {
7317
+ static use(plugin, options) {
7862
7318
  GlobalPlugins.add(plugin);
7319
+ PluginOptions.set(plugin, options);
7863
7320
  }
7864
7321
  /** Load count widget */
7865
7322
  static loadCountWidget(c) {