artalk 2.2.9 → 2.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Artalk.es.js CHANGED
@@ -1,4 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
2
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
4
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -14,6 +16,7 @@ var __spreadValues = (a, b) => {
14
16
  }
15
17
  return a;
16
18
  };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
17
20
  var __publicField = (obj, key, value) => {
18
21
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
19
22
  return value;
@@ -95,16 +98,17 @@ const defaults$3 = {
95
98
  placeholder: "\u952E\u5165\u5185\u5BB9...",
96
99
  noComment: "\u300C\u6B64\u65F6\u65E0\u58F0\u80DC\u6709\u58F0\u300D",
97
100
  sendBtn: "\u53D1\u9001\u8BC4\u8BBA",
98
- darkMode: false,
101
+ darkMode: "auto",
99
102
  editorTravel: true,
103
+ flatMode: "auto",
104
+ nestMax: 2,
105
+ nestSort: "DATE_ASC",
100
106
  emoticons: "https://cdn.jsdelivr.net/gh/ArtalkJS/Emoticons/grps/default.json",
101
107
  vote: true,
102
108
  voteDown: false,
103
109
  uaBadge: true,
104
110
  listSort: true,
105
111
  pvEl: "#ArtalkPV",
106
- flatMode: "auto",
107
- nestMax: 3,
108
112
  gravatar: {
109
113
  default: "mp",
110
114
  mirror: "https://sdn.geekzu.org/avatar/"
@@ -3119,63 +3123,54 @@ class Dialog {
3119
3123
  }
3120
3124
  function Fetch(ctx, input, init, timeout) {
3121
3125
  return __async(this, null, function* () {
3126
+ var _a, _b;
3122
3127
  if (ctx.user.data.token) {
3123
- const requestHeaders = new Headers();
3124
- requestHeaders.set("Authorization", `Bearer ${ctx.user.data.token}`);
3125
- init.headers = requestHeaders;
3126
- }
3127
- try {
3128
- let resp;
3129
- if (typeof timeout !== "number" && ctx.conf.reqTimeout === 0 || timeout === 0) {
3130
- resp = yield fetch(input, init);
3131
- } else {
3132
- resp = yield timeoutPromise(timeout || ctx.conf.reqTimeout || 15e3, fetch(input, init));
3133
- }
3134
- const noAccessCodes = [401, 400];
3135
- if (!resp.ok && !noAccessCodes.includes(resp.status))
3136
- throw new Error(`\u8BF7\u6C42\u54CD\u5E94 ${resp.status}`);
3137
- let json = yield resp.json();
3138
- const recall = (resolve, reject) => {
3139
- Fetch(ctx, input, init).then((d) => {
3140
- resolve(d);
3141
- }).catch((err) => {
3142
- reject(err);
3143
- });
3144
- };
3145
- if (json.data && json.data.need_captcha) {
3146
- json = yield new Promise((resolve, reject) => {
3147
- ctx.trigger("checker-captcha", {
3148
- imgData: json.data.img_data,
3149
- iframe: json.data.iframe,
3150
- onSuccess: () => {
3151
- recall(resolve, reject);
3152
- },
3153
- onCancel: () => {
3154
- reject(json);
3155
- }
3156
- });
3128
+ const headers = new Headers(init.headers);
3129
+ headers.set("Authorization", `Bearer ${ctx.user.data.token}`);
3130
+ init.headers = headers;
3131
+ }
3132
+ const resp = yield timeoutFetch(input, timeout || ctx.conf.reqTimeout || 15e3, init);
3133
+ const respHttpCode = resp.status;
3134
+ const noAccessCodes = [401, 400];
3135
+ const isNoAccess = noAccessCodes.includes(respHttpCode);
3136
+ if (!resp.ok && !isNoAccess)
3137
+ throw new Error(`\u8BF7\u6C42\u54CD\u5E94 ${respHttpCode}`);
3138
+ let json = yield resp.json();
3139
+ const recall = (resolve, reject) => {
3140
+ Fetch(ctx, input, init).then((d) => {
3141
+ resolve(d);
3142
+ }).catch((e) => {
3143
+ reject(e);
3144
+ });
3145
+ };
3146
+ if ((_a = json.data) == null ? void 0 : _a.need_captcha) {
3147
+ json = yield new Promise((resolve, reject) => {
3148
+ ctx.trigger("checker-captcha", {
3149
+ imgData: json.data.img_data,
3150
+ iframe: json.data.iframe,
3151
+ onSuccess: () => {
3152
+ recall(resolve, reject);
3153
+ },
3154
+ onCancel: () => {
3155
+ reject(json);
3156
+ }
3157
3157
  });
3158
- } else if (json.data && json.data.need_login || noAccessCodes.includes(resp.status)) {
3159
- json = yield new Promise((resolve, reject) => {
3160
- ctx.trigger("checker-admin", {
3161
- onSuccess: () => {
3162
- recall(resolve, reject);
3163
- },
3164
- onCancel: () => {
3165
- reject(json);
3166
- }
3167
- });
3158
+ });
3159
+ } else if (((_b = json.data) == null ? void 0 : _b.need_login) || isNoAccess) {
3160
+ json = yield new Promise((resolve, reject) => {
3161
+ ctx.trigger("checker-admin", {
3162
+ onSuccess: () => {
3163
+ recall(resolve, reject);
3164
+ },
3165
+ onCancel: () => {
3166
+ reject(json);
3167
+ }
3168
3168
  });
3169
- }
3170
- if (!json.success)
3171
- throw json;
3172
- return json;
3173
- } catch (err) {
3174
- console.error(err);
3175
- if (err instanceof TypeError)
3176
- throw new Error(`\u7F51\u7EDC\u9519\u8BEF`);
3177
- throw err;
3169
+ });
3178
3170
  }
3171
+ if (!json.success)
3172
+ throw json;
3173
+ return json;
3179
3174
  });
3180
3175
  }
3181
3176
  function POST(ctx, url, data) {
@@ -3194,20 +3189,390 @@ function ToFormData(object) {
3194
3189
  Object.keys(object).forEach((key) => formData.append(key, String(object[key])));
3195
3190
  return formData;
3196
3191
  }
3197
- function timeoutPromise(ms, promise) {
3198
- return new Promise((resolve, reject) => {
3199
- const timeoutId = setTimeout(() => {
3200
- reject(new Error("\u8BF7\u6C42\u8D85\u65F6"));
3201
- }, ms);
3202
- promise.then((res) => {
3203
- clearTimeout(timeoutId);
3204
- resolve(res);
3205
- }, (err) => {
3206
- clearTimeout(timeoutId);
3207
- reject(err);
3192
+ function timeoutFetch(url, ms, opts) {
3193
+ var _a;
3194
+ const controller = new AbortController();
3195
+ (_a = opts.signal) == null ? void 0 : _a.addEventListener("abort", () => controller.abort());
3196
+ let promise = fetch(url, __spreadProps(__spreadValues({}, opts), { signal: controller.signal }));
3197
+ if (ms > 0) {
3198
+ const timer = setTimeout(() => controller.abort(), ms);
3199
+ promise.finally(() => {
3200
+ clearTimeout(timer);
3208
3201
  });
3202
+ }
3203
+ promise = promise.catch((err) => {
3204
+ throw (err || {}).name === "AbortError" ? new Error("\u8BF7\u6C42\u8D85\u65F6\u6216\u610F\u5916\u7EC8\u6B62") : err;
3209
3205
  });
3206
+ return promise;
3210
3207
  }
3208
+ (function(factory) {
3209
+ factory();
3210
+ })(function() {
3211
+ function _classCallCheck(instance, Constructor) {
3212
+ if (!(instance instanceof Constructor)) {
3213
+ throw new TypeError("Cannot call a class as a function");
3214
+ }
3215
+ }
3216
+ function _defineProperties(target, props) {
3217
+ for (var i = 0; i < props.length; i++) {
3218
+ var descriptor = props[i];
3219
+ descriptor.enumerable = descriptor.enumerable || false;
3220
+ descriptor.configurable = true;
3221
+ if ("value" in descriptor)
3222
+ descriptor.writable = true;
3223
+ Object.defineProperty(target, descriptor.key, descriptor);
3224
+ }
3225
+ }
3226
+ function _createClass(Constructor, protoProps, staticProps) {
3227
+ if (protoProps)
3228
+ _defineProperties(Constructor.prototype, protoProps);
3229
+ if (staticProps)
3230
+ _defineProperties(Constructor, staticProps);
3231
+ return Constructor;
3232
+ }
3233
+ function _inherits(subClass, superClass) {
3234
+ if (typeof superClass !== "function" && superClass !== null) {
3235
+ throw new TypeError("Super expression must either be null or a function");
3236
+ }
3237
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
3238
+ constructor: {
3239
+ value: subClass,
3240
+ writable: true,
3241
+ configurable: true
3242
+ }
3243
+ });
3244
+ if (superClass)
3245
+ _setPrototypeOf(subClass, superClass);
3246
+ }
3247
+ function _getPrototypeOf(o) {
3248
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
3249
+ return o2.__proto__ || Object.getPrototypeOf(o2);
3250
+ };
3251
+ return _getPrototypeOf(o);
3252
+ }
3253
+ function _setPrototypeOf(o, p) {
3254
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
3255
+ o2.__proto__ = p2;
3256
+ return o2;
3257
+ };
3258
+ return _setPrototypeOf(o, p);
3259
+ }
3260
+ function _isNativeReflectConstruct() {
3261
+ if (typeof Reflect === "undefined" || !Reflect.construct)
3262
+ return false;
3263
+ if (Reflect.construct.sham)
3264
+ return false;
3265
+ if (typeof Proxy === "function")
3266
+ return true;
3267
+ try {
3268
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
3269
+ }));
3270
+ return true;
3271
+ } catch (e) {
3272
+ return false;
3273
+ }
3274
+ }
3275
+ function _assertThisInitialized(self2) {
3276
+ if (self2 === void 0) {
3277
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
3278
+ }
3279
+ return self2;
3280
+ }
3281
+ function _possibleConstructorReturn(self2, call) {
3282
+ if (call && (typeof call === "object" || typeof call === "function")) {
3283
+ return call;
3284
+ }
3285
+ return _assertThisInitialized(self2);
3286
+ }
3287
+ function _createSuper(Derived) {
3288
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
3289
+ return function _createSuperInternal() {
3290
+ var Super = _getPrototypeOf(Derived), result;
3291
+ if (hasNativeReflectConstruct) {
3292
+ var NewTarget = _getPrototypeOf(this).constructor;
3293
+ result = Reflect.construct(Super, arguments, NewTarget);
3294
+ } else {
3295
+ result = Super.apply(this, arguments);
3296
+ }
3297
+ return _possibleConstructorReturn(this, result);
3298
+ };
3299
+ }
3300
+ function _superPropBase(object, property) {
3301
+ while (!Object.prototype.hasOwnProperty.call(object, property)) {
3302
+ object = _getPrototypeOf(object);
3303
+ if (object === null)
3304
+ break;
3305
+ }
3306
+ return object;
3307
+ }
3308
+ function _get(target, property, receiver) {
3309
+ if (typeof Reflect !== "undefined" && Reflect.get) {
3310
+ _get = Reflect.get;
3311
+ } else {
3312
+ _get = function _get2(target2, property2, receiver2) {
3313
+ var base = _superPropBase(target2, property2);
3314
+ if (!base)
3315
+ return;
3316
+ var desc = Object.getOwnPropertyDescriptor(base, property2);
3317
+ if (desc.get) {
3318
+ return desc.get.call(receiver2);
3319
+ }
3320
+ return desc.value;
3321
+ };
3322
+ }
3323
+ return _get(target, property, receiver || target);
3324
+ }
3325
+ var Emitter = /* @__PURE__ */ function() {
3326
+ function Emitter2() {
3327
+ _classCallCheck(this, Emitter2);
3328
+ Object.defineProperty(this, "listeners", {
3329
+ value: {},
3330
+ writable: true,
3331
+ configurable: true
3332
+ });
3333
+ }
3334
+ _createClass(Emitter2, [{
3335
+ key: "addEventListener",
3336
+ value: function addEventListener(type, callback, options) {
3337
+ if (!(type in this.listeners)) {
3338
+ this.listeners[type] = [];
3339
+ }
3340
+ this.listeners[type].push({
3341
+ callback,
3342
+ options
3343
+ });
3344
+ }
3345
+ }, {
3346
+ key: "removeEventListener",
3347
+ value: function removeEventListener(type, callback) {
3348
+ if (!(type in this.listeners)) {
3349
+ return;
3350
+ }
3351
+ var stack = this.listeners[type];
3352
+ for (var i = 0, l = stack.length; i < l; i++) {
3353
+ if (stack[i].callback === callback) {
3354
+ stack.splice(i, 1);
3355
+ return;
3356
+ }
3357
+ }
3358
+ }
3359
+ }, {
3360
+ key: "dispatchEvent",
3361
+ value: function dispatchEvent(event) {
3362
+ if (!(event.type in this.listeners)) {
3363
+ return;
3364
+ }
3365
+ var stack = this.listeners[event.type];
3366
+ var stackToCall = stack.slice();
3367
+ for (var i = 0, l = stackToCall.length; i < l; i++) {
3368
+ var listener = stackToCall[i];
3369
+ try {
3370
+ listener.callback.call(this, event);
3371
+ } catch (e) {
3372
+ Promise.resolve().then(function() {
3373
+ throw e;
3374
+ });
3375
+ }
3376
+ if (listener.options && listener.options.once) {
3377
+ this.removeEventListener(event.type, listener.callback);
3378
+ }
3379
+ }
3380
+ return !event.defaultPrevented;
3381
+ }
3382
+ }]);
3383
+ return Emitter2;
3384
+ }();
3385
+ var AbortSignal = /* @__PURE__ */ function(_Emitter) {
3386
+ _inherits(AbortSignal2, _Emitter);
3387
+ var _super = _createSuper(AbortSignal2);
3388
+ function AbortSignal2() {
3389
+ var _this;
3390
+ _classCallCheck(this, AbortSignal2);
3391
+ _this = _super.call(this);
3392
+ if (!_this.listeners) {
3393
+ Emitter.call(_assertThisInitialized(_this));
3394
+ }
3395
+ Object.defineProperty(_assertThisInitialized(_this), "aborted", {
3396
+ value: false,
3397
+ writable: true,
3398
+ configurable: true
3399
+ });
3400
+ Object.defineProperty(_assertThisInitialized(_this), "onabort", {
3401
+ value: null,
3402
+ writable: true,
3403
+ configurable: true
3404
+ });
3405
+ return _this;
3406
+ }
3407
+ _createClass(AbortSignal2, [{
3408
+ key: "toString",
3409
+ value: function toString() {
3410
+ return "[object AbortSignal]";
3411
+ }
3412
+ }, {
3413
+ key: "dispatchEvent",
3414
+ value: function dispatchEvent(event) {
3415
+ if (event.type === "abort") {
3416
+ this.aborted = true;
3417
+ if (typeof this.onabort === "function") {
3418
+ this.onabort.call(this, event);
3419
+ }
3420
+ }
3421
+ _get(_getPrototypeOf(AbortSignal2.prototype), "dispatchEvent", this).call(this, event);
3422
+ }
3423
+ }]);
3424
+ return AbortSignal2;
3425
+ }(Emitter);
3426
+ var AbortController2 = /* @__PURE__ */ function() {
3427
+ function AbortController3() {
3428
+ _classCallCheck(this, AbortController3);
3429
+ Object.defineProperty(this, "signal", {
3430
+ value: new AbortSignal(),
3431
+ writable: true,
3432
+ configurable: true
3433
+ });
3434
+ }
3435
+ _createClass(AbortController3, [{
3436
+ key: "abort",
3437
+ value: function abort() {
3438
+ var event;
3439
+ try {
3440
+ event = new Event("abort");
3441
+ } catch (e) {
3442
+ if (typeof document !== "undefined") {
3443
+ if (!document.createEvent) {
3444
+ event = document.createEventObject();
3445
+ event.type = "abort";
3446
+ } else {
3447
+ event = document.createEvent("Event");
3448
+ event.initEvent("abort", false, false);
3449
+ }
3450
+ } else {
3451
+ event = {
3452
+ type: "abort",
3453
+ bubbles: false,
3454
+ cancelable: false
3455
+ };
3456
+ }
3457
+ }
3458
+ this.signal.dispatchEvent(event);
3459
+ }
3460
+ }, {
3461
+ key: "toString",
3462
+ value: function toString() {
3463
+ return "[object AbortController]";
3464
+ }
3465
+ }]);
3466
+ return AbortController3;
3467
+ }();
3468
+ if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
3469
+ AbortController2.prototype[Symbol.toStringTag] = "AbortController";
3470
+ AbortSignal.prototype[Symbol.toStringTag] = "AbortSignal";
3471
+ }
3472
+ function polyfillNeeded(self2) {
3473
+ if (self2.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {
3474
+ console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill");
3475
+ return true;
3476
+ }
3477
+ return typeof self2.Request === "function" && !self2.Request.prototype.hasOwnProperty("signal") || !self2.AbortController;
3478
+ }
3479
+ function abortableFetchDecorator(patchTargets) {
3480
+ if (typeof patchTargets === "function") {
3481
+ patchTargets = {
3482
+ fetch: patchTargets
3483
+ };
3484
+ }
3485
+ 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;
3486
+ if (!polyfillNeeded({
3487
+ fetch: fetch2,
3488
+ Request: NativeRequest,
3489
+ AbortController: NativeAbortController,
3490
+ __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL
3491
+ })) {
3492
+ return {
3493
+ fetch: fetch2,
3494
+ Request
3495
+ };
3496
+ }
3497
+ var Request = NativeRequest;
3498
+ if (Request && !Request.prototype.hasOwnProperty("signal") || __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {
3499
+ Request = function Request2(input, init) {
3500
+ var signal;
3501
+ if (init && init.signal) {
3502
+ signal = init.signal;
3503
+ delete init.signal;
3504
+ }
3505
+ var request = new NativeRequest(input, init);
3506
+ if (signal) {
3507
+ Object.defineProperty(request, "signal", {
3508
+ writable: false,
3509
+ enumerable: false,
3510
+ configurable: true,
3511
+ value: signal
3512
+ });
3513
+ }
3514
+ return request;
3515
+ };
3516
+ Request.prototype = NativeRequest.prototype;
3517
+ }
3518
+ var realFetch = fetch2;
3519
+ var abortableFetch = function abortableFetch2(input, init) {
3520
+ var signal = Request && Request.prototype.isPrototypeOf(input) ? input.signal : init ? init.signal : void 0;
3521
+ if (signal) {
3522
+ var abortError;
3523
+ try {
3524
+ abortError = new DOMException("Aborted", "AbortError");
3525
+ } catch (err) {
3526
+ abortError = new Error("Aborted");
3527
+ abortError.name = "AbortError";
3528
+ }
3529
+ if (signal.aborted) {
3530
+ return Promise.reject(abortError);
3531
+ }
3532
+ var cancellation = new Promise(function(_, reject) {
3533
+ signal.addEventListener("abort", function() {
3534
+ return reject(abortError);
3535
+ }, {
3536
+ once: true
3537
+ });
3538
+ });
3539
+ if (init && init.signal) {
3540
+ delete init.signal;
3541
+ }
3542
+ return Promise.race([cancellation, realFetch(input, init)]);
3543
+ }
3544
+ return realFetch(input, init);
3545
+ };
3546
+ return {
3547
+ fetch: abortableFetch,
3548
+ Request
3549
+ };
3550
+ }
3551
+ (function(self2) {
3552
+ if (!polyfillNeeded(self2)) {
3553
+ return;
3554
+ }
3555
+ if (!self2.fetch) {
3556
+ console.warn("fetch() is not available, cannot install abortcontroller-polyfill");
3557
+ return;
3558
+ }
3559
+ var _abortableFetch = abortableFetchDecorator(self2), fetch2 = _abortableFetch.fetch, Request = _abortableFetch.Request;
3560
+ self2.fetch = fetch2;
3561
+ self2.Request = Request;
3562
+ Object.defineProperty(self2, "AbortController", {
3563
+ writable: true,
3564
+ enumerable: false,
3565
+ configurable: true,
3566
+ value: AbortController2
3567
+ });
3568
+ Object.defineProperty(self2, "AbortSignal", {
3569
+ writable: true,
3570
+ enumerable: false,
3571
+ configurable: true,
3572
+ value: AbortSignal
3573
+ });
3574
+ })(typeof self !== "undefined" ? self : commonjsGlobal);
3575
+ });
3211
3576
  class Api {
3212
3577
  constructor(ctx) {
3213
3578
  __publicField(this, "ctx");
@@ -3280,7 +3645,6 @@ class Api {
3280
3645
  }
3281
3646
  userGet(name, email) {
3282
3647
  const ctrl = new AbortController();
3283
- const { signal } = ctrl;
3284
3648
  const params = {
3285
3649
  name,
3286
3650
  email,
@@ -3289,7 +3653,7 @@ class Api {
3289
3653
  const req = Fetch(this.ctx, `${this.baseURL}/user-get`, {
3290
3654
  method: "POST",
3291
3655
  body: ToFormData(params),
3292
- signal
3656
+ signal: ctrl.signal
3293
3657
  }).then((json) => ({
3294
3658
  user: json.data.user,
3295
3659
  is_login: json.data.is_login,
@@ -3461,6 +3825,8 @@ class Api {
3461
3825
  conf.emoticons = conf.emoticons.trim();
3462
3826
  if (conf.emoticons.startsWith("[") || conf.emoticons.startsWith("{")) {
3463
3827
  conf.emoticons = JSON.parse(conf.emoticons);
3828
+ } else if (conf.emoticons === "false") {
3829
+ conf.emoticons = false;
3464
3830
  }
3465
3831
  }
3466
3832
  return conf;
@@ -4090,6 +4456,7 @@ class Editor extends Component {
4090
4456
  this.user.data.link = data.user.link;
4091
4457
  this.getInputEl("link").value = data.user.link;
4092
4458
  }
4459
+ }).catch(() => {
4093
4460
  }).finally(() => {
4094
4461
  this.queryUserInfo.abortFunc = null;
4095
4462
  });
@@ -4135,15 +4502,10 @@ class Editor extends Component {
4135
4502
  this.openedPlugName = null;
4136
4503
  this.$plugBtnWrap.innerHTML = "";
4137
4504
  this.LOADABLE_PLUG_LIST.forEach((PlugObj) => {
4505
+ if (PlugObj.Name === "emoticons" && !this.conf.emoticons)
4506
+ return;
4138
4507
  const btnElem = createElement(`<span class="atk-plug-btn" data-plug-name="${PlugObj.Name}">${PlugObj.BtnHTML}</span>`);
4139
4508
  this.$plugBtnWrap.appendChild(btnElem);
4140
- if (PlugObj.Name === "emoticons") {
4141
- const emoPlug = new PlugObj(this);
4142
- this.plugList[PlugObj.Name] = emoPlug;
4143
- window.setTimeout(() => {
4144
- emoPlug.loadEmoticonsData();
4145
- }, 1e3);
4146
- }
4147
4509
  btnElem.addEventListener("click", () => {
4148
4510
  let plug = this.plugList[PlugObj.Name];
4149
4511
  if (!plug) {
@@ -4178,6 +4540,13 @@ class Editor extends Component {
4178
4540
  btnElem.classList.add("active");
4179
4541
  });
4180
4542
  });
4543
+ if (this.conf.emoticons) {
4544
+ const emoPlug = new EmoticonsPlug(this);
4545
+ this.plugList[EmoticonsPlug.Name] = emoPlug;
4546
+ window.setTimeout(() => {
4547
+ emoPlug.loadEmoticonsData();
4548
+ }, 1e3);
4549
+ }
4181
4550
  this.initImgUpload();
4182
4551
  }
4183
4552
  closePlug() {
@@ -4759,6 +5128,7 @@ class Comment extends Component {
4759
5128
  __publicField(this, "$main");
4760
5129
  __publicField(this, "$header");
4761
5130
  __publicField(this, "$headerNick");
5131
+ __publicField(this, "$headerBadge");
4762
5132
  __publicField(this, "$body");
4763
5133
  __publicField(this, "$content");
4764
5134
  __publicField(this, "$children");
@@ -4852,13 +5222,14 @@ class Comment extends Component {
4852
5222
  } else {
4853
5223
  this.$headerNick.innerText = this.data.nick;
4854
5224
  }
4855
- const $badge = this.$el.querySelector(".atk-badge");
5225
+ this.$headerBadge = this.$el.querySelector(".atk-badge");
4856
5226
  if (this.data.badge_name) {
4857
- $badge.innerText = this.data.badge_name;
5227
+ this.$headerBadge.innerText = this.data.badge_name;
4858
5228
  if (this.data.badge_color)
4859
- $badge.style.backgroundColor = this.data.badge_color;
5229
+ this.$headerBadge.style.backgroundColor = this.data.badge_color;
4860
5230
  } else {
4861
- $badge.remove();
5231
+ this.$headerBadge.remove();
5232
+ this.$headerBadge = void 0;
4862
5233
  }
4863
5234
  if (this.data.is_pinned) {
4864
5235
  const $pinnedBadge = createElement(`<span class="atk-item atk-pinned-badge">\u7F6E\u9876</span>`);
@@ -4917,7 +5288,8 @@ class Comment extends Component {
4917
5288
  this.$replyAt.onclick = () => {
4918
5289
  this.goToReplyComment();
4919
5290
  };
4920
- this.$headerNick.insertAdjacentElement("afterend", this.$replyAt);
5291
+ const $after = this.$headerBadge || this.$headerNick;
5292
+ $after.insertAdjacentElement("afterend", this.$replyAt);
4921
5293
  }
4922
5294
  renderReplyTo() {
4923
5295
  if (!this.flatMode)
@@ -5486,7 +5858,7 @@ function makeNestCommentNodeList(srcData, sortBy = "DATE_DESC", nestMax = 2) {
5486
5858
  })(nodeList);
5487
5859
  return nodeList;
5488
5860
  }
5489
- const backendMinVersion = "2.1.4";
5861
+ const backendMinVersion = "2.1.6";
5490
5862
  class ListLite extends Component {
5491
5863
  constructor(ctx) {
5492
5864
  super(ctx);
@@ -5496,7 +5868,7 @@ class ListLite extends Component {
5496
5868
  __publicField(this, "isLoading", false);
5497
5869
  __publicField(this, "noCommentText", "\u65E0\u5185\u5BB9");
5498
5870
  __publicField(this, "flatMode", false);
5499
- __publicField(this, "nestSortBy", "DATE_DESC");
5871
+ __publicField(this, "nestSortBy");
5500
5872
  __publicField(this, "pageMode", "pagination");
5501
5873
  __publicField(this, "pageSize", 20);
5502
5874
  __publicField(this, "scrollListenerAt");
@@ -5515,6 +5887,7 @@ class ListLite extends Component {
5515
5887
  this.$commentsWrap = this.$el.querySelector(".atk-list-comments-wrap");
5516
5888
  if (ctx.conf.noComment)
5517
5889
  this.noCommentText = ctx.conf.noComment;
5890
+ this.nestSortBy = this.ctx.conf.nestSort || "DATE_ASC";
5518
5891
  window.setInterval(() => {
5519
5892
  this.$el.querySelectorAll("[data-atk-comment-date]").forEach((el) => {
5520
5893
  const date = el.getAttribute("data-atk-comment-date");
@@ -5580,7 +5953,7 @@ class ListLite extends Component {
5580
5953
  }
5581
5954
  this.data = data;
5582
5955
  const feMinVersion = ((_a = data.api_version) == null ? void 0 : _a.fe_min_version) || "0.0.0";
5583
- if (this.ctx.conf.versionCheck && this.versionCheck("\u524D\u7AEF", feMinVersion, "2.2.9"))
5956
+ if (this.ctx.conf.versionCheck && this.versionCheck("\u524D\u7AEF", feMinVersion, "2.2.12"))
5584
5957
  return;
5585
5958
  if (this.ctx.conf.versionCheck && this.versionCheck("\u540E\u7AEF", backendMinVersion, (_b = data.api_version) == null ? void 0 : _b.version))
5586
5959
  return;
@@ -5718,6 +6091,8 @@ class ListLite extends Component {
5718
6091
  this.refreshUI();
5719
6092
  };
5720
6093
  comment2.replyTo = cData.rid ? ctxData.find((c) => c.id === cData.rid) : void 0;
6094
+ comment2.render();
6095
+ this.commentList.push(comment2);
5721
6096
  return comment2;
5722
6097
  }
5723
6098
  importComments(srcData) {
@@ -5733,18 +6108,14 @@ class ListLite extends Component {
5733
6108
  const rootNodes = makeNestCommentNodeList(srcData, this.nestSortBy, this.conf.nestMax);
5734
6109
  rootNodes.forEach((rootNode) => {
5735
6110
  const rootC = this.createComment(rootNode.comment, srcData);
5736
- rootC.render();
5737
6111
  this.$commentsWrap.appendChild(rootC.getEl());
5738
6112
  rootC.playFadeInAnim();
5739
- this.commentList.push(rootC);
5740
6113
  const that = this;
5741
6114
  (function loadChildren(parentC, parentNode) {
5742
6115
  parentNode.children.forEach((node) => {
5743
6116
  const childD = node.comment;
5744
6117
  const childC = that.createComment(childD, srcData);
5745
- childC.render();
5746
6118
  parentC.putChild(childC);
5747
- that.commentList.push(childC);
5748
6119
  loadChildren(childC, node);
5749
6120
  });
5750
6121
  })(rootC, rootNode);
@@ -5755,8 +6126,6 @@ class ListLite extends Component {
5755
6126
  if (cData.is_collapsed)
5756
6127
  cData.is_allow_reply = false;
5757
6128
  const comment2 = this.createComment(cData, ctxData);
5758
- comment2.render();
5759
- this.commentList.push(comment2);
5760
6129
  if (cData.visible) {
5761
6130
  if (insertMode === "append")
5762
6131
  this.$commentsWrap.append(comment2.getEl());
@@ -5771,13 +6140,10 @@ class ListLite extends Component {
5771
6140
  if (!this.flatMode) {
5772
6141
  const comment2 = this.createComment(commentData);
5773
6142
  if (commentData.rid === 0) {
5774
- comment2.render();
5775
6143
  this.$commentsWrap.prepend(comment2.getEl());
5776
- this.commentList.push(comment2);
5777
6144
  } else {
5778
6145
  const parent = this.findComment(commentData.rid);
5779
6146
  if (parent) {
5780
- comment2.render();
5781
6147
  parent.putChild(comment2, this.nestSortBy === "DATE_ASC" ? "append" : "prepend");
5782
6148
  comment2.getParents().forEach((p) => {
5783
6149
  if (p.$children)
@@ -5887,7 +6253,7 @@ class List extends ListLite {
5887
6253
  if (this.ctx.conf.listSort) {
5888
6254
  this.initDropdown();
5889
6255
  }
5890
- this.$el.querySelector(".atk-copyright").innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${"2.2.9"}">Artalk</a>`;
6256
+ this.$el.querySelector(".atk-copyright").innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${"2.2.12"}">Artalk</a>`;
5891
6257
  this.ctx.on("list-reload", () => this.fetchComments(0));
5892
6258
  this.ctx.on("list-refresh-ui", () => this.refreshUI());
5893
6259
  this.ctx.on("list-import", (data) => this.importComments(data));
@@ -6212,6 +6578,9 @@ const _Artalk = class {
6212
6578
  if (!this.conf.pageTitle) {
6213
6579
  this.conf.pageTitle = `${document.title}`;
6214
6580
  }
6581
+ if (this.conf.nestMax && this.conf.nestMax <= 1) {
6582
+ this.conf.flatMode = true;
6583
+ }
6215
6584
  if (!!this.conf.el && this.conf.el instanceof HTMLElement) {
6216
6585
  this.$root = this.conf.el;
6217
6586
  } else {
@@ -6304,7 +6673,20 @@ const _Artalk = class {
6304
6673
  Layer.BodyOrgPaddingRight = document.body.style.paddingRight;
6305
6674
  }
6306
6675
  initDarkMode() {
6676
+ if (this.conf.darkMode === "auto") {
6677
+ const darkModeMedia = window.matchMedia("(prefers-color-scheme: dark)");
6678
+ darkModeMedia.addEventListener("change", (e) => {
6679
+ this.setDarkMode(e.matches);
6680
+ });
6681
+ this.setDarkMode(darkModeMedia.matches);
6682
+ } else {
6683
+ this.setDarkMode(this.conf.darkMode || false);
6684
+ }
6685
+ }
6686
+ setDarkMode(darkMode) {
6307
6687
  const darkModeClassName = "atk-dark-mode";
6688
+ this.ctx.conf.darkMode = darkMode;
6689
+ this.ctx.trigger("conf-updated");
6308
6690
  if (this.conf.darkMode) {
6309
6691
  this.$root.classList.add(darkModeClassName);
6310
6692
  } else {
@@ -6319,11 +6701,6 @@ const _Artalk = class {
6319
6701
  }
6320
6702
  }
6321
6703
  }
6322
- setDarkMode(darkMode) {
6323
- this.ctx.conf.darkMode = darkMode;
6324
- this.ctx.trigger("conf-updated");
6325
- this.initDarkMode();
6326
- }
6327
6704
  initPV() {
6328
6705
  return __async(this, null, function* () {
6329
6706
  const pvNum = yield new Api(this.ctx).pv();