artalk 2.2.11 → 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,7 +98,7 @@ 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,
100
103
  flatMode: "auto",
101
104
  nestMax: 2,
@@ -3120,63 +3123,54 @@ class Dialog {
3120
3123
  }
3121
3124
  function Fetch(ctx, input, init, timeout) {
3122
3125
  return __async(this, null, function* () {
3126
+ var _a, _b;
3123
3127
  if (ctx.user.data.token) {
3124
- const requestHeaders = new Headers();
3125
- requestHeaders.set("Authorization", `Bearer ${ctx.user.data.token}`);
3126
- init.headers = requestHeaders;
3127
- }
3128
- try {
3129
- let resp;
3130
- if (typeof timeout !== "number" && ctx.conf.reqTimeout === 0 || timeout === 0) {
3131
- resp = yield fetch(input, init);
3132
- } else {
3133
- resp = yield timeoutPromise(timeout || ctx.conf.reqTimeout || 15e3, fetch(input, init));
3134
- }
3135
- const noAccessCodes = [401, 400];
3136
- if (!resp.ok && !noAccessCodes.includes(resp.status))
3137
- throw new Error(`\u8BF7\u6C42\u54CD\u5E94 ${resp.status}`);
3138
- let json = yield resp.json();
3139
- const recall = (resolve, reject) => {
3140
- Fetch(ctx, input, init).then((d) => {
3141
- resolve(d);
3142
- }).catch((err) => {
3143
- reject(err);
3144
- });
3145
- };
3146
- if (json.data && json.data.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
- });
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
+ }
3158
3157
  });
3159
- } else if (json.data && json.data.need_login || noAccessCodes.includes(resp.status)) {
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
- });
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
+ }
3169
3168
  });
3170
- }
3171
- if (!json.success)
3172
- throw json;
3173
- return json;
3174
- } catch (err) {
3175
- console.error(err);
3176
- if (err instanceof TypeError)
3177
- throw new Error(`\u7F51\u7EDC\u9519\u8BEF`);
3178
- throw err;
3169
+ });
3179
3170
  }
3171
+ if (!json.success)
3172
+ throw json;
3173
+ return json;
3180
3174
  });
3181
3175
  }
3182
3176
  function POST(ctx, url, data) {
@@ -3195,20 +3189,390 @@ function ToFormData(object) {
3195
3189
  Object.keys(object).forEach((key) => formData.append(key, String(object[key])));
3196
3190
  return formData;
3197
3191
  }
3198
- function timeoutPromise(ms, promise) {
3199
- return new Promise((resolve, reject) => {
3200
- const timeoutId = setTimeout(() => {
3201
- reject(new Error("\u8BF7\u6C42\u8D85\u65F6"));
3202
- }, ms);
3203
- promise.then((res) => {
3204
- clearTimeout(timeoutId);
3205
- resolve(res);
3206
- }, (err) => {
3207
- clearTimeout(timeoutId);
3208
- 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);
3209
3201
  });
3202
+ }
3203
+ promise = promise.catch((err) => {
3204
+ throw (err || {}).name === "AbortError" ? new Error("\u8BF7\u6C42\u8D85\u65F6\u6216\u610F\u5916\u7EC8\u6B62") : err;
3210
3205
  });
3206
+ return promise;
3211
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
+ });
3212
3576
  class Api {
3213
3577
  constructor(ctx) {
3214
3578
  __publicField(this, "ctx");
@@ -3281,7 +3645,6 @@ class Api {
3281
3645
  }
3282
3646
  userGet(name, email) {
3283
3647
  const ctrl = new AbortController();
3284
- const { signal } = ctrl;
3285
3648
  const params = {
3286
3649
  name,
3287
3650
  email,
@@ -3290,7 +3653,7 @@ class Api {
3290
3653
  const req = Fetch(this.ctx, `${this.baseURL}/user-get`, {
3291
3654
  method: "POST",
3292
3655
  body: ToFormData(params),
3293
- signal
3656
+ signal: ctrl.signal
3294
3657
  }).then((json) => ({
3295
3658
  user: json.data.user,
3296
3659
  is_login: json.data.is_login,
@@ -3462,6 +3825,8 @@ class Api {
3462
3825
  conf.emoticons = conf.emoticons.trim();
3463
3826
  if (conf.emoticons.startsWith("[") || conf.emoticons.startsWith("{")) {
3464
3827
  conf.emoticons = JSON.parse(conf.emoticons);
3828
+ } else if (conf.emoticons === "false") {
3829
+ conf.emoticons = false;
3465
3830
  }
3466
3831
  }
3467
3832
  return conf;
@@ -4091,6 +4456,7 @@ class Editor extends Component {
4091
4456
  this.user.data.link = data.user.link;
4092
4457
  this.getInputEl("link").value = data.user.link;
4093
4458
  }
4459
+ }).catch(() => {
4094
4460
  }).finally(() => {
4095
4461
  this.queryUserInfo.abortFunc = null;
4096
4462
  });
@@ -4136,15 +4502,10 @@ class Editor extends Component {
4136
4502
  this.openedPlugName = null;
4137
4503
  this.$plugBtnWrap.innerHTML = "";
4138
4504
  this.LOADABLE_PLUG_LIST.forEach((PlugObj) => {
4505
+ if (PlugObj.Name === "emoticons" && !this.conf.emoticons)
4506
+ return;
4139
4507
  const btnElem = createElement(`<span class="atk-plug-btn" data-plug-name="${PlugObj.Name}">${PlugObj.BtnHTML}</span>`);
4140
4508
  this.$plugBtnWrap.appendChild(btnElem);
4141
- if (PlugObj.Name === "emoticons") {
4142
- const emoPlug = new PlugObj(this);
4143
- this.plugList[PlugObj.Name] = emoPlug;
4144
- window.setTimeout(() => {
4145
- emoPlug.loadEmoticonsData();
4146
- }, 1e3);
4147
- }
4148
4509
  btnElem.addEventListener("click", () => {
4149
4510
  let plug = this.plugList[PlugObj.Name];
4150
4511
  if (!plug) {
@@ -4179,6 +4540,13 @@ class Editor extends Component {
4179
4540
  btnElem.classList.add("active");
4180
4541
  });
4181
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
+ }
4182
4550
  this.initImgUpload();
4183
4551
  }
4184
4552
  closePlug() {
@@ -5490,7 +5858,7 @@ function makeNestCommentNodeList(srcData, sortBy = "DATE_DESC", nestMax = 2) {
5490
5858
  })(nodeList);
5491
5859
  return nodeList;
5492
5860
  }
5493
- const backendMinVersion = "2.1.4";
5861
+ const backendMinVersion = "2.1.6";
5494
5862
  class ListLite extends Component {
5495
5863
  constructor(ctx) {
5496
5864
  super(ctx);
@@ -5585,7 +5953,7 @@ class ListLite extends Component {
5585
5953
  }
5586
5954
  this.data = data;
5587
5955
  const feMinVersion = ((_a = data.api_version) == null ? void 0 : _a.fe_min_version) || "0.0.0";
5588
- if (this.ctx.conf.versionCheck && this.versionCheck("\u524D\u7AEF", feMinVersion, "2.2.11"))
5956
+ if (this.ctx.conf.versionCheck && this.versionCheck("\u524D\u7AEF", feMinVersion, "2.2.12"))
5589
5957
  return;
5590
5958
  if (this.ctx.conf.versionCheck && this.versionCheck("\u540E\u7AEF", backendMinVersion, (_b = data.api_version) == null ? void 0 : _b.version))
5591
5959
  return;
@@ -5723,6 +6091,8 @@ class ListLite extends Component {
5723
6091
  this.refreshUI();
5724
6092
  };
5725
6093
  comment2.replyTo = cData.rid ? ctxData.find((c) => c.id === cData.rid) : void 0;
6094
+ comment2.render();
6095
+ this.commentList.push(comment2);
5726
6096
  return comment2;
5727
6097
  }
5728
6098
  importComments(srcData) {
@@ -5738,18 +6108,14 @@ class ListLite extends Component {
5738
6108
  const rootNodes = makeNestCommentNodeList(srcData, this.nestSortBy, this.conf.nestMax);
5739
6109
  rootNodes.forEach((rootNode) => {
5740
6110
  const rootC = this.createComment(rootNode.comment, srcData);
5741
- rootC.render();
5742
6111
  this.$commentsWrap.appendChild(rootC.getEl());
5743
6112
  rootC.playFadeInAnim();
5744
- this.commentList.push(rootC);
5745
6113
  const that = this;
5746
6114
  (function loadChildren(parentC, parentNode) {
5747
6115
  parentNode.children.forEach((node) => {
5748
6116
  const childD = node.comment;
5749
6117
  const childC = that.createComment(childD, srcData);
5750
- childC.render();
5751
6118
  parentC.putChild(childC);
5752
- that.commentList.push(childC);
5753
6119
  loadChildren(childC, node);
5754
6120
  });
5755
6121
  })(rootC, rootNode);
@@ -5760,8 +6126,6 @@ class ListLite extends Component {
5760
6126
  if (cData.is_collapsed)
5761
6127
  cData.is_allow_reply = false;
5762
6128
  const comment2 = this.createComment(cData, ctxData);
5763
- comment2.render();
5764
- this.commentList.push(comment2);
5765
6129
  if (cData.visible) {
5766
6130
  if (insertMode === "append")
5767
6131
  this.$commentsWrap.append(comment2.getEl());
@@ -5776,13 +6140,10 @@ class ListLite extends Component {
5776
6140
  if (!this.flatMode) {
5777
6141
  const comment2 = this.createComment(commentData);
5778
6142
  if (commentData.rid === 0) {
5779
- comment2.render();
5780
6143
  this.$commentsWrap.prepend(comment2.getEl());
5781
- this.commentList.push(comment2);
5782
6144
  } else {
5783
6145
  const parent = this.findComment(commentData.rid);
5784
6146
  if (parent) {
5785
- comment2.render();
5786
6147
  parent.putChild(comment2, this.nestSortBy === "DATE_ASC" ? "append" : "prepend");
5787
6148
  comment2.getParents().forEach((p) => {
5788
6149
  if (p.$children)
@@ -5892,7 +6253,7 @@ class List extends ListLite {
5892
6253
  if (this.ctx.conf.listSort) {
5893
6254
  this.initDropdown();
5894
6255
  }
5895
- this.$el.querySelector(".atk-copyright").innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${"2.2.11"}">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>`;
5896
6257
  this.ctx.on("list-reload", () => this.fetchComments(0));
5897
6258
  this.ctx.on("list-refresh-ui", () => this.refreshUI());
5898
6259
  this.ctx.on("list-import", (data) => this.importComments(data));
@@ -6312,7 +6673,20 @@ const _Artalk = class {
6312
6673
  Layer.BodyOrgPaddingRight = document.body.style.paddingRight;
6313
6674
  }
6314
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) {
6315
6687
  const darkModeClassName = "atk-dark-mode";
6688
+ this.ctx.conf.darkMode = darkMode;
6689
+ this.ctx.trigger("conf-updated");
6316
6690
  if (this.conf.darkMode) {
6317
6691
  this.$root.classList.add(darkModeClassName);
6318
6692
  } else {
@@ -6327,11 +6701,6 @@ const _Artalk = class {
6327
6701
  }
6328
6702
  }
6329
6703
  }
6330
- setDarkMode(darkMode) {
6331
- this.ctx.conf.darkMode = darkMode;
6332
- this.ctx.trigger("conf-updated");
6333
- this.initDarkMode();
6334
- }
6335
6704
  initPV() {
6336
6705
  return __async(this, null, function* () {
6337
6706
  const pvNum = yield new Api(this.ctx).pv();