artalk 2.7.2 → 2.7.3

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 (157) hide show
  1. package/LICENSE +21 -0
  2. package/dist/Artalk.cjs +2 -0
  3. package/dist/Artalk.cjs.map +1 -0
  4. package/dist/Artalk.iife.js +1 -1
  5. package/dist/Artalk.iife.js.map +1 -1
  6. package/dist/Artalk.js +1 -1
  7. package/dist/Artalk.js.map +1 -1
  8. package/dist/{Artalk.es.js → Artalk.mjs} +96 -76
  9. package/dist/Artalk.mjs.map +1 -0
  10. package/dist/ArtalkLite.cjs +2 -0
  11. package/dist/ArtalkLite.cjs.map +1 -0
  12. package/dist/ArtalkLite.iife.js +1 -1
  13. package/dist/ArtalkLite.iife.js.map +1 -1
  14. package/dist/ArtalkLite.js +1 -1
  15. package/dist/ArtalkLite.js.map +1 -1
  16. package/dist/{ArtalkLite.es.js → ArtalkLite.mjs} +96 -81
  17. package/dist/ArtalkLite.mjs.map +1 -0
  18. package/dist/i18n/jp.cjs +1 -0
  19. package/dist/i18n/jp.d.cts +3 -0
  20. package/dist/i18n/jp.d.ts +3 -0
  21. package/dist/i18n/jp.mjs +93 -0
  22. package/dist/i18n/zh-TW.cjs +1 -0
  23. package/dist/i18n/zh-TW.d.cts +3 -0
  24. package/dist/i18n/zh-TW.d.ts +3 -0
  25. package/dist/i18n/zh-TW.mjs +93 -0
  26. package/dist/main.d.cts +1476 -0
  27. package/dist/main.d.ts +1476 -0
  28. package/package.json +60 -28
  29. package/dist/Artalk.es.js.map +0 -1
  30. package/dist/ArtalkLite.es.js.map +0 -1
  31. package/dist/src/api/_base.d.ts +0 -17
  32. package/dist/src/api/_options.d.ts +0 -24
  33. package/dist/src/api/_request.d.ts +0 -12
  34. package/dist/src/api/admin.d.ts +0 -10
  35. package/dist/src/api/captcha.d.ts +0 -14
  36. package/dist/src/api/comment.d.ts +0 -29
  37. package/dist/src/api/index.d.ts +0 -29
  38. package/dist/src/api/page.d.ts +0 -22
  39. package/dist/src/api/site.d.ts +0 -17
  40. package/dist/src/api/system.d.ts +0 -33
  41. package/dist/src/api/upload.d.ts +0 -11
  42. package/dist/src/api/user.d.ts +0 -42
  43. package/dist/src/artalk.d.ts +0 -35
  44. package/dist/src/comment/actions.d.ts +0 -17
  45. package/dist/src/comment/comment.d.ts +0 -66
  46. package/dist/src/comment/height-limit.d.ts +0 -30
  47. package/dist/src/comment/index.d.ts +0 -2
  48. package/dist/src/comment/render.d.ts +0 -46
  49. package/dist/src/comment/renders/actions.d.ts +0 -5
  50. package/dist/src/comment/renders/avatar.d.ts +0 -5
  51. package/dist/src/comment/renders/content.d.ts +0 -5
  52. package/dist/src/comment/renders/header.d.ts +0 -5
  53. package/dist/src/comment/renders/index.d.ts +0 -2
  54. package/dist/src/comment/renders/pending.d.ts +0 -5
  55. package/dist/src/comment/renders/reply-at.d.ts +0 -5
  56. package/dist/src/comment/renders/reply-to.d.ts +0 -5
  57. package/dist/src/components/action-btn.d.ts +0 -50
  58. package/dist/src/components/checker/admin.d.ts +0 -3
  59. package/dist/src/components/checker/captcha-renders.d.ts +0 -5
  60. package/dist/src/components/checker/captcha.d.ts +0 -3
  61. package/dist/src/components/checker/index.d.ts +0 -53
  62. package/dist/src/components/dialog.d.ts +0 -16
  63. package/dist/src/components/error-dialog.d.ts +0 -8
  64. package/dist/src/components/pagination.d.ts +0 -31
  65. package/dist/src/components/read-more-btn.d.ts +0 -33
  66. package/dist/src/config.d.ts +0 -24
  67. package/dist/src/context.d.ts +0 -45
  68. package/dist/src/data.d.ts +0 -27
  69. package/dist/src/defaults.d.ts +0 -3
  70. package/dist/src/editor/editor.d.ts +0 -31
  71. package/dist/src/editor/state.d.ts +0 -20
  72. package/dist/src/editor/ui.d.ts +0 -25
  73. package/dist/src/i18n/en.d.ts +0 -73
  74. package/dist/src/i18n/external.d.ts +0 -74
  75. package/dist/src/i18n/index.d.ts +0 -236
  76. package/dist/src/i18n/jp.d.ts +0 -73
  77. package/dist/src/i18n/zh-CN.d.ts +0 -3
  78. package/dist/src/i18n/zh-TW.d.ts +0 -73
  79. package/dist/src/layer/index.d.ts +0 -4
  80. package/dist/src/layer/layer-manager.d.ts +0 -9
  81. package/dist/src/layer/layer.d.ts +0 -12
  82. package/dist/src/layer/scrollbar-helper.d.ts +0 -5
  83. package/dist/src/layer/sidebar-layer.d.ts +0 -20
  84. package/dist/src/layer/wrap.d.ts +0 -13
  85. package/dist/src/lib/component.d.ts +0 -7
  86. package/dist/src/lib/detect.d.ts +0 -10
  87. package/dist/src/lib/event-manager.d.ts +0 -28
  88. package/dist/src/lib/highlight.d.ts +0 -1
  89. package/dist/src/lib/marked-renderer.d.ts +0 -4
  90. package/dist/src/lib/marked.d.ts +0 -11
  91. package/dist/src/lib/sanitizer.d.ts +0 -1
  92. package/dist/src/lib/ui.d.ts +0 -24
  93. package/dist/src/lib/user.d.ts +0 -21
  94. package/dist/src/lib/utils.d.ts +0 -41
  95. package/dist/src/list/comment.d.ts +0 -3
  96. package/dist/src/list/layout.d.ts +0 -23
  97. package/dist/src/list/list.d.ts +0 -14
  98. package/dist/src/list/nest.d.ts +0 -10
  99. package/dist/src/list/page.d.ts +0 -2
  100. package/dist/src/list/paginator/index.d.ts +0 -25
  101. package/dist/src/list/paginator/read-more.d.ts +0 -18
  102. package/dist/src/list/paginator/up-down.d.ts +0 -14
  103. package/dist/src/main.d.ts +0 -7
  104. package/dist/src/plugins/admin-only-elem.d.ts +0 -2
  105. package/dist/src/plugins/conf-remoter.d.ts +0 -2
  106. package/dist/src/plugins/dark-mode.d.ts +0 -2
  107. package/dist/src/plugins/editor/_kit.d.ts +0 -33
  108. package/dist/src/plugins/editor/_plug.d.ts +0 -29
  109. package/dist/src/plugins/editor/_sample.d.ts +0 -5
  110. package/dist/src/plugins/editor/closable.d.ts +0 -7
  111. package/dist/src/plugins/editor/emoticons.d.ts +0 -30
  112. package/dist/src/plugins/editor/header-event.d.ts +0 -6
  113. package/dist/src/plugins/editor/header-link.d.ts +0 -6
  114. package/dist/src/plugins/editor/header-user.d.ts +0 -16
  115. package/dist/src/plugins/editor/index.d.ts +0 -6
  116. package/dist/src/plugins/editor/local-storage.d.ts +0 -6
  117. package/dist/src/plugins/editor/mover.d.ts +0 -6
  118. package/dist/src/plugins/editor/preview.d.ts +0 -7
  119. package/dist/src/plugins/editor/state-edit.d.ts +0 -11
  120. package/dist/src/plugins/editor/state-reply.d.ts +0 -8
  121. package/dist/src/plugins/editor/submit-add.d.ts +0 -18
  122. package/dist/src/plugins/editor/submit-btn.d.ts +0 -5
  123. package/dist/src/plugins/editor/submit.d.ts +0 -17
  124. package/dist/src/plugins/editor/textarea.d.ts +0 -8
  125. package/dist/src/plugins/editor/upload.d.ts +0 -9
  126. package/dist/src/plugins/editor-kit.d.ts +0 -42
  127. package/dist/src/plugins/index.d.ts +0 -2
  128. package/dist/src/plugins/list/copyright.d.ts +0 -2
  129. package/dist/src/plugins/list/count.d.ts +0 -2
  130. package/dist/src/plugins/list/dropdown.d.ts +0 -2
  131. package/dist/src/plugins/list/error-dialog.d.ts +0 -2
  132. package/dist/src/plugins/list/fetch.d.ts +0 -2
  133. package/dist/src/plugins/list/goto-first.d.ts +0 -3
  134. package/dist/src/plugins/list/goto.d.ts +0 -2
  135. package/dist/src/plugins/list/index.d.ts +0 -3
  136. package/dist/src/plugins/list/loading.d.ts +0 -2
  137. package/dist/src/plugins/list/no-comment.d.ts +0 -2
  138. package/dist/src/plugins/list/reach-bottom.d.ts +0 -2
  139. package/dist/src/plugins/list/sidebar-btn.d.ts +0 -2
  140. package/dist/src/plugins/list/time-ticking.d.ts +0 -3
  141. package/dist/src/plugins/list/unread-badge.d.ts +0 -2
  142. package/dist/src/plugins/list/unread.d.ts +0 -2
  143. package/dist/src/plugins/list/with-editor.d.ts +0 -2
  144. package/dist/src/plugins/markdown.d.ts +0 -2
  145. package/dist/src/plugins/stat.d.ts +0 -13
  146. package/dist/src/plugins/version-check.d.ts +0 -2
  147. package/dist/src/service.d.ts +0 -36
  148. package/dist/tests/e2e/comment-add.spec.d.ts +0 -1
  149. package/dist/types/config.d.ts +0 -110
  150. package/dist/types/context.d.ts +0 -62
  151. package/dist/types/data.d.ts +0 -194
  152. package/dist/types/editor.d.ts +0 -76
  153. package/dist/types/event.d.ts +0 -39
  154. package/dist/types/global.d.ts +0 -1
  155. package/dist/types/index.d.ts +0 -7
  156. package/dist/types/plugin.d.ts +0 -2
  157. package/dist/types/sidebar.d.ts +0 -3
@@ -223,24 +223,6 @@ function getURLBasedOnApi(opts) {
223
223
  function getURLBasedOn(baseURL, path) {
224
224
  return `${baseURL.replace(/\/$/, "")}/${path.replace(/^\//, "")}`;
225
225
  }
226
- function mergeDeep(target, source) {
227
- const isObject = (obj) => obj && typeof obj === "object";
228
- if (!isObject(target) || !isObject(source)) {
229
- return source;
230
- }
231
- Object.keys(source).forEach((key) => {
232
- const targetValue = target[key];
233
- const sourceValue = source[key];
234
- if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
235
- target[key] = targetValue.concat(sourceValue);
236
- } else if (isObject(targetValue) && isObject(sourceValue)) {
237
- target[key] = mergeDeep(__spreadValues({}, targetValue), sourceValue);
238
- } else {
239
- target[key] = sourceValue;
240
- }
241
- });
242
- return target;
243
- }
244
226
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
245
227
  function getDefaultExportFromCjs(x) {
246
228
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -3695,12 +3677,12 @@ function parser$1(html, handler) {
3695
3677
  }
3696
3678
  }
3697
3679
  function parseComment() {
3698
- var index2 = html.indexOf("-->");
3699
- if (index2 >= 0) {
3680
+ var index = html.indexOf("-->");
3681
+ if (index >= 0) {
3700
3682
  if (handler.comment) {
3701
- handler.comment(html.substring(4, index2));
3683
+ handler.comment(html.substring(4, index));
3702
3684
  }
3703
- html = html.substring(index2 + 3);
3685
+ html = html.substring(index + 3);
3704
3686
  chars = false;
3705
3687
  }
3706
3688
  }
@@ -3709,10 +3691,10 @@ function parser$1(html, handler) {
3709
3691
  return;
3710
3692
  }
3711
3693
  var text;
3712
- var index2 = html.indexOf("<");
3713
- if (index2 >= 0) {
3714
- text = html.substring(0, index2);
3715
- html = html.substring(index2);
3694
+ var index = html.indexOf("<");
3695
+ if (index >= 0) {
3696
+ text = html.substring(0, index);
3697
+ html = html.substring(index);
3716
3698
  } else {
3717
3699
  text = html;
3718
3700
  html = "";
@@ -4063,13 +4045,13 @@ var hanabi$1 = { exports: {} };
4063
4045
  };
4064
4046
  });
4065
4047
  var defaultColors = ["23AC69", "91C132", "F19726", "E8552D", "1AAB8E", "E1147F", "2980C1", "1BA1E6", "9FA0A0", "F19726", "E30B20", "E30B20", "A3338B"];
4066
- var index2 = function(input, ref) {
4048
+ var index = function(input, ref) {
4067
4049
  if (ref === void 0)
4068
4050
  ref = {};
4069
4051
  var colors = ref.colors;
4070
4052
  if (colors === void 0)
4071
4053
  colors = defaultColors;
4072
- var index3 = 0;
4054
+ var index2 = 0;
4073
4055
  var cache = {};
4074
4056
  var wordRe = /[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/;
4075
4057
  var leftAngleRe = /</;
@@ -4085,18 +4067,18 @@ var hanabi$1 = { exports: {} };
4085
4067
  if (cache[word]) {
4086
4068
  color = cache[word];
4087
4069
  } else {
4088
- color = colors[index3];
4070
+ color = colors[index2];
4089
4071
  cache[word] = color;
4090
4072
  }
4091
4073
  var out = '<span style="color: #' + color + '">' + word + "</span>";
4092
- index3 = ++index3 % colors.length;
4074
+ index2 = ++index2 % colors.length;
4093
4075
  return out;
4094
4076
  });
4095
4077
  };
4096
4078
  function toComment(cm) {
4097
4079
  return '<span style="color: slategray">' + cm + "</span>";
4098
4080
  }
4099
- return index2;
4081
+ return index;
4100
4082
  });
4101
4083
  })(hanabi$1);
4102
4084
  var hanabiExports = hanabi$1.exports;
@@ -4175,6 +4157,26 @@ function marked(src) {
4175
4157
  function simpleMarked(src) {
4176
4158
  return src.replace(/```\s*([^]+?.*?[^]+?[^]+?)```/g, (_, code) => `<pre><code>${renderCode(code)}</code></pre>`).replace(/!\[(.*?)\]\((.*?)\)/g, (_, alt, imgSrc) => `<img src="${imgSrc}" alt="${alt}" />`).replace(/\[(.*?)\]\((.*?)\)/g, (_, text, link) => `<a href="${link}" target="_blank">${text}</a>`).replace(/\n/g, "<br>");
4177
4159
  }
4160
+ function mergeDeep(...objects) {
4161
+ const isObject = (obj) => obj && typeof obj === "object" && obj.constructor === Object;
4162
+ return objects.reduce((prev, obj) => {
4163
+ Object.keys(obj != null ? obj : {}).forEach((key) => {
4164
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
4165
+ return;
4166
+ }
4167
+ const pVal = prev[key];
4168
+ const oVal = obj[key];
4169
+ if (Array.isArray(pVal) && Array.isArray(oVal)) {
4170
+ prev[key] = pVal.concat(...oVal);
4171
+ } else if (isObject(pVal) && isObject(oVal)) {
4172
+ prev[key] = mergeDeep(pVal, oVal);
4173
+ } else {
4174
+ prev[key] = oVal;
4175
+ }
4176
+ });
4177
+ return prev;
4178
+ }, {});
4179
+ }
4178
4180
  class DataManager {
4179
4181
  constructor(events) {
4180
4182
  __publicField(this, "loading", false);
@@ -4332,11 +4334,9 @@ const defaults = {
4332
4334
  useBackendConf: true,
4333
4335
  locale: "zh-CN"
4334
4336
  };
4335
- function handelCustomConf(customConf) {
4336
- const conf = mergeDeep(defaults, customConf);
4337
- if (customConf.el)
4338
- conf.el = customConf.el;
4339
- if (typeof conf.el === "string" && !!conf.el) {
4337
+ function handelCustomConf(customConf, full = false) {
4338
+ const conf = full ? mergeDeep(defaults, customConf) : customConf;
4339
+ if (conf.el && typeof conf.el === "string") {
4340
4340
  try {
4341
4341
  const findEl = document.querySelector(conf.el);
4342
4342
  if (!findEl)
@@ -4347,20 +4347,18 @@ function handelCustomConf(customConf) {
4347
4347
  throw new Error("Please check your Artalk `el` config.");
4348
4348
  }
4349
4349
  }
4350
- conf.server = conf.server.replace(/\/$/, "").replace(/\/api\/?$/, "");
4351
- if (!conf.pageKey) {
4350
+ if (conf.pageKey === "")
4352
4351
  conf.pageKey = `${window.location.pathname}`;
4353
- }
4354
- if (!conf.pageTitle) {
4352
+ if (conf.pageTitle === "")
4355
4353
  conf.pageTitle = `${document.title}`;
4356
- }
4357
- if (conf.locale === "auto") {
4354
+ if (conf.server)
4355
+ conf.server = conf.server.replace(/\/$/, "").replace(/\/api\/?$/, "");
4356
+ if (conf.locale === "auto")
4358
4357
  conf.locale = navigator.language;
4359
- }
4360
- if (conf.flatMode === true || Number(conf.nestMax) <= 1)
4361
- conf.flatMode = true;
4362
4358
  if (conf.flatMode === "auto")
4363
4359
  conf.flatMode = window.matchMedia("(max-width: 768px)").matches;
4360
+ if (typeof conf.nestMax === "number" && Number(conf.nestMax) <= 1)
4361
+ conf.flatMode = true;
4364
4362
  return conf;
4365
4363
  }
4366
4364
  function handleConfFormServer(conf) {
@@ -4423,7 +4421,7 @@ function convertApiOptions(conf, ctx) {
4423
4421
  };
4424
4422
  }
4425
4423
  class Context {
4426
- constructor(conf, $root) {
4424
+ constructor(conf) {
4427
4425
  /* 运行参数 */
4428
4426
  __publicField(this, "conf");
4429
4427
  __publicField(this, "data");
@@ -4431,7 +4429,7 @@ class Context {
4431
4429
  /* Event Manager */
4432
4430
  __publicField(this, "events", new EventManager());
4433
4431
  this.conf = conf;
4434
- this.$root = $root || document.createElement("div");
4432
+ this.$root = conf.el;
4435
4433
  this.$root.classList.add("artalk");
4436
4434
  this.$root.innerHTML = "";
4437
4435
  this.data = new DataManager(this.events);
@@ -4509,9 +4507,15 @@ class Context {
4509
4507
  this.events.trigger("dark-mode-changed", darkMode);
4510
4508
  }
4511
4509
  updateConf(nConf) {
4512
- this.conf = mergeDeep(this.conf, handelCustomConf(nConf));
4510
+ this.conf = mergeDeep(this.conf, handelCustomConf(nConf, false));
4513
4511
  this.events.trigger("conf-loaded", this.conf);
4514
4512
  }
4513
+ getConf() {
4514
+ return this.conf;
4515
+ }
4516
+ getEl() {
4517
+ return this.$root;
4518
+ }
4515
4519
  getMarked() {
4516
4520
  return getInstance();
4517
4521
  }
@@ -7042,6 +7046,11 @@ function showErrorDialog(opts) {
7042
7046
  }
7043
7047
  const ConfRemoter = (ctx) => {
7044
7048
  ctx.on("inited", () => {
7049
+ if (ctx.conf.immediateFetch === false)
7050
+ return;
7051
+ ctx.trigger("conf-fetch");
7052
+ });
7053
+ ctx.on("conf-fetch", () => {
7045
7054
  loadConf(ctx);
7046
7055
  });
7047
7056
  };
@@ -7613,7 +7622,7 @@ class Emoticons extends EditorPlug {
7613
7622
  data.push(grp);
7614
7623
  };
7615
7624
  const remoteLoad = (d) => __async(this, null, function* () {
7616
- yield Promise.all(d.map((grp, index2) => __async(this, null, function* () {
7625
+ yield Promise.all(d.map((grp, index) => __async(this, null, function* () {
7617
7626
  if (typeof grp === "object" && !Array.isArray(grp)) {
7618
7627
  pushGrp(grp);
7619
7628
  } else if (Array.isArray(grp)) {
@@ -7666,9 +7675,9 @@ class Emoticons extends EditorPlug {
7666
7675
  /** 避免表情 item.key 为 null 的情况 */
7667
7676
  solveNullKey(data) {
7668
7677
  data.forEach((grp) => {
7669
- grp.items.forEach((item, index2) => {
7678
+ grp.items.forEach((item, index) => {
7670
7679
  if (!item.key)
7671
- item.key = `${grp.name} ${index2 + 1}`;
7680
+ item.key = `${grp.name} ${index + 1}`;
7672
7681
  });
7673
7682
  });
7674
7683
  }
@@ -7701,14 +7710,14 @@ class Emoticons extends EditorPlug {
7701
7710
  const dest = [];
7702
7711
  Object.entries(owoData).forEach(([grpName, grp]) => {
7703
7712
  const nGrp = { name: grpName, type: grp.type, items: [] };
7704
- grp.container.forEach((item, index2) => {
7713
+ grp.container.forEach((item, index) => {
7705
7714
  const iconStr = item.icon;
7706
7715
  if (/<(img|IMG)/.test(iconStr)) {
7707
7716
  const find = /src=["'](.*?)["']/.exec(iconStr);
7708
7717
  if (find && find.length > 1)
7709
7718
  item.icon = find[1];
7710
7719
  }
7711
- nGrp.items.push({ key: item.text || `${grpName} ${index2 + 1}`, val: item.icon });
7720
+ nGrp.items.push({ key: item.text || `${grpName} ${index + 1}`, val: item.icon });
7712
7721
  });
7713
7722
  dest.push(nGrp);
7714
7723
  });
@@ -7718,10 +7727,10 @@ class Emoticons extends EditorPlug {
7718
7727
  initEmoticonsList() {
7719
7728
  this.$grpWrap = createElement(`<div class="atk-grp-wrap"></div>`);
7720
7729
  this.$panel.append(this.$grpWrap);
7721
- this.emoticons.forEach((grp, index2) => {
7730
+ this.emoticons.forEach((grp, index) => {
7722
7731
  const $grp = createElement(`<div class="atk-grp" style="display: none;"></div>`);
7723
7732
  this.$grpWrap.append($grp);
7724
- $grp.setAttribute("data-index", String(index2));
7733
+ $grp.setAttribute("data-index", String(index));
7725
7734
  $grp.setAttribute("data-grp-name", grp.name);
7726
7735
  $grp.setAttribute("data-type", grp.type);
7727
7736
  grp.items.forEach((item) => {
@@ -7749,11 +7758,11 @@ class Emoticons extends EditorPlug {
7749
7758
  if (this.emoticons.length > 1) {
7750
7759
  this.$grpSwitcher = createElement(`<div class="atk-grp-switcher"></div>`);
7751
7760
  this.$panel.append(this.$grpSwitcher);
7752
- this.emoticons.forEach((grp, index2) => {
7761
+ this.emoticons.forEach((grp, index) => {
7753
7762
  const $item = createElement("<span />");
7754
7763
  $item.innerText = grp.name;
7755
- $item.setAttribute("data-index", String(index2));
7756
- $item.onclick = () => this.openGrp(index2);
7764
+ $item.setAttribute("data-index", String(index));
7765
+ $item.onclick = () => this.openGrp(index);
7757
7766
  this.$grpSwitcher.append($item);
7758
7767
  });
7759
7768
  }
@@ -7761,18 +7770,18 @@ class Emoticons extends EditorPlug {
7761
7770
  this.openGrp(0);
7762
7771
  }
7763
7772
  /** 打开一个表情组 */
7764
- openGrp(index2) {
7773
+ openGrp(index) {
7765
7774
  var _a, _b, _c;
7766
7775
  Array.from(this.$grpWrap.children).forEach((item) => {
7767
7776
  const el = item;
7768
- if (el.getAttribute("data-index") !== String(index2)) {
7777
+ if (el.getAttribute("data-index") !== String(index)) {
7769
7778
  el.style.display = "none";
7770
7779
  } else {
7771
7780
  el.style.display = "";
7772
7781
  }
7773
7782
  });
7774
7783
  (_a = this.$grpSwitcher) == null ? void 0 : _a.querySelectorAll("span.active").forEach((item) => item.classList.remove("active"));
7775
- (_c = (_b = this.$grpSwitcher) == null ? void 0 : _b.querySelector(`span[data-index="${index2}"]`)) == null ? void 0 : _c.classList.add("active");
7784
+ (_c = (_b = this.$grpSwitcher) == null ? void 0 : _b.querySelector(`span[data-index="${index}"]`)) == null ? void 0 : _c.classList.add("active");
7776
7785
  this.changeListHeight();
7777
7786
  }
7778
7787
  changeListHeight() {
@@ -7784,7 +7793,7 @@ class Emoticons extends EditorPlug {
7784
7793
  this.emoticons.forEach((grp) => {
7785
7794
  if (grp.type !== "image")
7786
7795
  return;
7787
- Object.entries(grp.items).forEach(([index2, item]) => {
7796
+ Object.entries(grp.items).forEach(([index, item]) => {
7788
7797
  text = text.split(`:[${item.key}]`).join(`<img src="${item.val}" atk-emoticon="${item.key}">`);
7789
7798
  });
7790
7799
  });
@@ -8300,7 +8309,7 @@ function extractCommentID() {
8300
8309
  }
8301
8310
  return commentId || null;
8302
8311
  }
8303
- const version = "2.7.2";
8312
+ const version = "2.7.3";
8304
8313
  const Copyright = (ctx) => {
8305
8314
  ctx.on("conf-loaded", () => {
8306
8315
  const list = ctx.get("list");
@@ -8712,15 +8721,11 @@ const DefaultPlugins = [
8712
8721
  const GlobalPlugins = [...DefaultPlugins];
8713
8722
  class Artalk {
8714
8723
  constructor(conf) {
8715
- __publicField(this, "conf");
8716
8724
  __publicField(this, "ctx");
8717
- __publicField(this, "$root");
8718
8725
  /** Plugins */
8719
8726
  __publicField(this, "plugins", [...GlobalPlugins]);
8720
- this.conf = handelCustomConf(conf);
8721
- if (this.conf.el instanceof HTMLElement)
8722
- this.$root = this.conf.el;
8723
- this.ctx = new Context(this.conf, this.$root);
8727
+ const handledConf = handelCustomConf(conf, true);
8728
+ this.ctx = new Context(handledConf);
8724
8729
  Object.entries(services).forEach(([name, initService]) => {
8725
8730
  const obj = initService(this.ctx);
8726
8731
  if (obj)
@@ -8732,6 +8737,14 @@ class Artalk {
8732
8737
  });
8733
8738
  this.ctx.trigger("inited");
8734
8739
  }
8740
+ /** Get the config of Artalk */
8741
+ getConf() {
8742
+ return this.ctx.getConf();
8743
+ }
8744
+ /** Get the root element of Artalk */
8745
+ getEl() {
8746
+ return this.ctx.$root;
8747
+ }
8735
8748
  /** Update config of Artalk */
8736
8749
  update(conf) {
8737
8750
  this.ctx.updateConf(conf);
@@ -8744,7 +8757,7 @@ class Artalk {
8744
8757
  /** Destroy instance of Artalk */
8745
8758
  destroy() {
8746
8759
  this.ctx.trigger("destroy");
8747
- this.$root.remove();
8760
+ this.ctx.$root.remove();
8748
8761
  }
8749
8762
  /** Add an event listener */
8750
8763
  on(name, handler) {
@@ -8777,7 +8790,7 @@ class Artalk {
8777
8790
  }
8778
8791
  /** Load count widget */
8779
8792
  static loadCountWidget(c) {
8780
- const conf = handelCustomConf(c);
8793
+ const conf = handelCustomConf(c, true);
8781
8794
  initCountWidget({
8782
8795
  getApi: () => new Api(convertApiOptions(conf)),
8783
8796
  pageKey: conf.pageKey,
@@ -8786,18 +8799,25 @@ class Artalk {
8786
8799
  pvAdd: false
8787
8800
  });
8788
8801
  }
8802
+ // ===========================
8803
+ // Deprecated
8804
+ // ===========================
8805
+ /** @deprecated Please use `getEl()` instead */
8806
+ get $root() {
8807
+ return this.ctx.$root;
8808
+ }
8809
+ /** @description Please use `getConf()` instead */
8810
+ get conf() {
8811
+ return this.ctx.getConf();
8812
+ }
8789
8813
  }
8790
- const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8791
- __proto__: null
8792
- }, Symbol.toStringTag, { value: "Module" }));
8793
8814
  const init = Artalk.init;
8794
8815
  const use = Artalk.use;
8795
8816
  const loadCountWidget = Artalk.loadCountWidget;
8796
8817
  export {
8797
- index as ArtalkType,
8798
8818
  Artalk as default,
8799
8819
  init,
8800
8820
  loadCountWidget,
8801
8821
  use
8802
8822
  };
8803
- //# sourceMappingURL=Artalk.es.js.map
8823
+ //# sourceMappingURL=Artalk.mjs.map