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
@@ -210,24 +210,6 @@ function getURLBasedOnApi(opts) {
210
210
  function getURLBasedOn(baseURL, path) {
211
211
  return `${baseURL.replace(/\/$/, "")}/${path.replace(/^\//, "")}`;
212
212
  }
213
- function mergeDeep(target, source) {
214
- const isObject = (obj) => obj && typeof obj === "object";
215
- if (!isObject(target) || !isObject(source)) {
216
- return source;
217
- }
218
- Object.keys(source).forEach((key) => {
219
- const targetValue = target[key];
220
- const sourceValue = source[key];
221
- if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
222
- target[key] = targetValue.concat(sourceValue);
223
- } else if (isObject(targetValue) && isObject(sourceValue)) {
224
- target[key] = mergeDeep(__spreadValues({}, targetValue), sourceValue);
225
- } else {
226
- target[key] = sourceValue;
227
- }
228
- });
229
- return target;
230
- }
231
213
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
232
214
  function getDefaultExportFromCjs(x) {
233
215
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -1475,12 +1457,12 @@ function parser$1(html, handler) {
1475
1457
  }
1476
1458
  }
1477
1459
  function parseComment() {
1478
- var index2 = html.indexOf("-->");
1479
- if (index2 >= 0) {
1460
+ var index = html.indexOf("-->");
1461
+ if (index >= 0) {
1480
1462
  if (handler.comment) {
1481
- handler.comment(html.substring(4, index2));
1463
+ handler.comment(html.substring(4, index));
1482
1464
  }
1483
- html = html.substring(index2 + 3);
1465
+ html = html.substring(index + 3);
1484
1466
  chars = false;
1485
1467
  }
1486
1468
  }
@@ -1489,10 +1471,10 @@ function parser$1(html, handler) {
1489
1471
  return;
1490
1472
  }
1491
1473
  var text;
1492
- var index2 = html.indexOf("<");
1493
- if (index2 >= 0) {
1494
- text = html.substring(0, index2);
1495
- html = html.substring(index2);
1474
+ var index = html.indexOf("<");
1475
+ if (index >= 0) {
1476
+ text = html.substring(0, index);
1477
+ html = html.substring(index);
1496
1478
  } else {
1497
1479
  text = html;
1498
1480
  html = "";
@@ -1843,13 +1825,13 @@ var hanabi$1 = { exports: {} };
1843
1825
  };
1844
1826
  });
1845
1827
  var defaultColors = ["23AC69", "91C132", "F19726", "E8552D", "1AAB8E", "E1147F", "2980C1", "1BA1E6", "9FA0A0", "F19726", "E30B20", "E30B20", "A3338B"];
1846
- var index2 = function(input, ref) {
1828
+ var index = function(input, ref) {
1847
1829
  if (ref === void 0)
1848
1830
  ref = {};
1849
1831
  var colors = ref.colors;
1850
1832
  if (colors === void 0)
1851
1833
  colors = defaultColors;
1852
- var index3 = 0;
1834
+ var index2 = 0;
1853
1835
  var cache = {};
1854
1836
  var wordRe = /[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/;
1855
1837
  var leftAngleRe = /</;
@@ -1865,18 +1847,18 @@ var hanabi$1 = { exports: {} };
1865
1847
  if (cache[word]) {
1866
1848
  color = cache[word];
1867
1849
  } else {
1868
- color = colors[index3];
1850
+ color = colors[index2];
1869
1851
  cache[word] = color;
1870
1852
  }
1871
1853
  var out = '<span style="color: #' + color + '">' + word + "</span>";
1872
- index3 = ++index3 % colors.length;
1854
+ index2 = ++index2 % colors.length;
1873
1855
  return out;
1874
1856
  });
1875
1857
  };
1876
1858
  function toComment(cm) {
1877
1859
  return '<span style="color: slategray">' + cm + "</span>";
1878
1860
  }
1879
- return index2;
1861
+ return index;
1880
1862
  });
1881
1863
  })(hanabi$1);
1882
1864
  var hanabiExports = hanabi$1.exports;
@@ -1955,6 +1937,26 @@ function marked(src) {
1955
1937
  function simpleMarked(src) {
1956
1938
  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>");
1957
1939
  }
1940
+ function mergeDeep(...objects) {
1941
+ const isObject = (obj) => obj && typeof obj === "object" && obj.constructor === Object;
1942
+ return objects.reduce((prev, obj) => {
1943
+ Object.keys(obj != null ? obj : {}).forEach((key) => {
1944
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
1945
+ return;
1946
+ }
1947
+ const pVal = prev[key];
1948
+ const oVal = obj[key];
1949
+ if (Array.isArray(pVal) && Array.isArray(oVal)) {
1950
+ prev[key] = pVal.concat(...oVal);
1951
+ } else if (isObject(pVal) && isObject(oVal)) {
1952
+ prev[key] = mergeDeep(pVal, oVal);
1953
+ } else {
1954
+ prev[key] = oVal;
1955
+ }
1956
+ });
1957
+ return prev;
1958
+ }, {});
1959
+ }
1958
1960
  class DataManager {
1959
1961
  constructor(events) {
1960
1962
  __publicField(this, "loading", false);
@@ -2112,16 +2114,9 @@ const defaults = {
2112
2114
  useBackendConf: true,
2113
2115
  locale: "zh-CN"
2114
2116
  };
2115
- {
2116
- defaults.vote = false;
2117
- defaults.uaBadge = false;
2118
- defaults.emoticons = false;
2119
- }
2120
- function handelCustomConf(customConf) {
2121
- const conf = mergeDeep(defaults, customConf);
2122
- if (customConf.el)
2123
- conf.el = customConf.el;
2124
- if (typeof conf.el === "string" && !!conf.el) {
2117
+ function handelCustomConf(customConf, full = false) {
2118
+ const conf = full ? mergeDeep(defaults, customConf) : customConf;
2119
+ if (conf.el && typeof conf.el === "string") {
2125
2120
  try {
2126
2121
  const findEl = document.querySelector(conf.el);
2127
2122
  if (!findEl)
@@ -2132,20 +2127,18 @@ function handelCustomConf(customConf) {
2132
2127
  throw new Error("Please check your Artalk `el` config.");
2133
2128
  }
2134
2129
  }
2135
- conf.server = conf.server.replace(/\/$/, "").replace(/\/api\/?$/, "");
2136
- if (!conf.pageKey) {
2130
+ if (conf.pageKey === "")
2137
2131
  conf.pageKey = `${window.location.pathname}`;
2138
- }
2139
- if (!conf.pageTitle) {
2132
+ if (conf.pageTitle === "")
2140
2133
  conf.pageTitle = `${document.title}`;
2141
- }
2142
- if (conf.locale === "auto") {
2134
+ if (conf.server)
2135
+ conf.server = conf.server.replace(/\/$/, "").replace(/\/api\/?$/, "");
2136
+ if (conf.locale === "auto")
2143
2137
  conf.locale = navigator.language;
2144
- }
2145
- if (conf.flatMode === true || Number(conf.nestMax) <= 1)
2146
- conf.flatMode = true;
2147
2138
  if (conf.flatMode === "auto")
2148
2139
  conf.flatMode = window.matchMedia("(max-width: 768px)").matches;
2140
+ if (typeof conf.nestMax === "number" && Number(conf.nestMax) <= 1)
2141
+ conf.flatMode = true;
2149
2142
  return conf;
2150
2143
  }
2151
2144
  function handleConfFormServer(conf) {
@@ -2208,7 +2201,7 @@ function convertApiOptions(conf, ctx) {
2208
2201
  };
2209
2202
  }
2210
2203
  class Context {
2211
- constructor(conf, $root) {
2204
+ constructor(conf) {
2212
2205
  /* 运行参数 */
2213
2206
  __publicField(this, "conf");
2214
2207
  __publicField(this, "data");
@@ -2216,7 +2209,7 @@ class Context {
2216
2209
  /* Event Manager */
2217
2210
  __publicField(this, "events", new EventManager());
2218
2211
  this.conf = conf;
2219
- this.$root = $root || document.createElement("div");
2212
+ this.$root = conf.el;
2220
2213
  this.$root.classList.add("artalk");
2221
2214
  this.$root.innerHTML = "";
2222
2215
  this.data = new DataManager(this.events);
@@ -2294,9 +2287,15 @@ class Context {
2294
2287
  this.events.trigger("dark-mode-changed", darkMode);
2295
2288
  }
2296
2289
  updateConf(nConf) {
2297
- this.conf = mergeDeep(this.conf, handelCustomConf(nConf));
2290
+ this.conf = mergeDeep(this.conf, handelCustomConf(nConf, false));
2298
2291
  this.events.trigger("conf-loaded", this.conf);
2299
2292
  }
2293
+ getConf() {
2294
+ return this.conf;
2295
+ }
2296
+ getEl() {
2297
+ return this.$root;
2298
+ }
2300
2299
  getMarked() {
2301
2300
  return getInstance();
2302
2301
  }
@@ -4827,6 +4826,11 @@ function showErrorDialog(opts) {
4827
4826
  }
4828
4827
  const ConfRemoter = (ctx) => {
4829
4828
  ctx.on("inited", () => {
4829
+ if (ctx.conf.immediateFetch === false)
4830
+ return;
4831
+ ctx.trigger("conf-fetch");
4832
+ });
4833
+ ctx.on("conf-fetch", () => {
4830
4834
  loadConf(ctx);
4831
4835
  });
4832
4836
  };
@@ -5398,7 +5402,7 @@ class Emoticons extends EditorPlug {
5398
5402
  data.push(grp);
5399
5403
  };
5400
5404
  const remoteLoad = (d) => __async(this, null, function* () {
5401
- yield Promise.all(d.map((grp, index2) => __async(this, null, function* () {
5405
+ yield Promise.all(d.map((grp, index) => __async(this, null, function* () {
5402
5406
  if (typeof grp === "object" && !Array.isArray(grp)) {
5403
5407
  pushGrp(grp);
5404
5408
  } else if (Array.isArray(grp)) {
@@ -5451,9 +5455,9 @@ class Emoticons extends EditorPlug {
5451
5455
  /** 避免表情 item.key 为 null 的情况 */
5452
5456
  solveNullKey(data) {
5453
5457
  data.forEach((grp) => {
5454
- grp.items.forEach((item, index2) => {
5458
+ grp.items.forEach((item, index) => {
5455
5459
  if (!item.key)
5456
- item.key = `${grp.name} ${index2 + 1}`;
5460
+ item.key = `${grp.name} ${index + 1}`;
5457
5461
  });
5458
5462
  });
5459
5463
  }
@@ -5486,14 +5490,14 @@ class Emoticons extends EditorPlug {
5486
5490
  const dest = [];
5487
5491
  Object.entries(owoData).forEach(([grpName, grp]) => {
5488
5492
  const nGrp = { name: grpName, type: grp.type, items: [] };
5489
- grp.container.forEach((item, index2) => {
5493
+ grp.container.forEach((item, index) => {
5490
5494
  const iconStr = item.icon;
5491
5495
  if (/<(img|IMG)/.test(iconStr)) {
5492
5496
  const find = /src=["'](.*?)["']/.exec(iconStr);
5493
5497
  if (find && find.length > 1)
5494
5498
  item.icon = find[1];
5495
5499
  }
5496
- nGrp.items.push({ key: item.text || `${grpName} ${index2 + 1}`, val: item.icon });
5500
+ nGrp.items.push({ key: item.text || `${grpName} ${index + 1}`, val: item.icon });
5497
5501
  });
5498
5502
  dest.push(nGrp);
5499
5503
  });
@@ -5503,10 +5507,10 @@ class Emoticons extends EditorPlug {
5503
5507
  initEmoticonsList() {
5504
5508
  this.$grpWrap = createElement(`<div class="atk-grp-wrap"></div>`);
5505
5509
  this.$panel.append(this.$grpWrap);
5506
- this.emoticons.forEach((grp, index2) => {
5510
+ this.emoticons.forEach((grp, index) => {
5507
5511
  const $grp = createElement(`<div class="atk-grp" style="display: none;"></div>`);
5508
5512
  this.$grpWrap.append($grp);
5509
- $grp.setAttribute("data-index", String(index2));
5513
+ $grp.setAttribute("data-index", String(index));
5510
5514
  $grp.setAttribute("data-grp-name", grp.name);
5511
5515
  $grp.setAttribute("data-type", grp.type);
5512
5516
  grp.items.forEach((item) => {
@@ -5534,11 +5538,11 @@ class Emoticons extends EditorPlug {
5534
5538
  if (this.emoticons.length > 1) {
5535
5539
  this.$grpSwitcher = createElement(`<div class="atk-grp-switcher"></div>`);
5536
5540
  this.$panel.append(this.$grpSwitcher);
5537
- this.emoticons.forEach((grp, index2) => {
5541
+ this.emoticons.forEach((grp, index) => {
5538
5542
  const $item = createElement("<span />");
5539
5543
  $item.innerText = grp.name;
5540
- $item.setAttribute("data-index", String(index2));
5541
- $item.onclick = () => this.openGrp(index2);
5544
+ $item.setAttribute("data-index", String(index));
5545
+ $item.onclick = () => this.openGrp(index);
5542
5546
  this.$grpSwitcher.append($item);
5543
5547
  });
5544
5548
  }
@@ -5546,18 +5550,18 @@ class Emoticons extends EditorPlug {
5546
5550
  this.openGrp(0);
5547
5551
  }
5548
5552
  /** 打开一个表情组 */
5549
- openGrp(index2) {
5553
+ openGrp(index) {
5550
5554
  var _a, _b, _c;
5551
5555
  Array.from(this.$grpWrap.children).forEach((item) => {
5552
5556
  const el = item;
5553
- if (el.getAttribute("data-index") !== String(index2)) {
5557
+ if (el.getAttribute("data-index") !== String(index)) {
5554
5558
  el.style.display = "none";
5555
5559
  } else {
5556
5560
  el.style.display = "";
5557
5561
  }
5558
5562
  });
5559
5563
  (_a = this.$grpSwitcher) == null ? void 0 : _a.querySelectorAll("span.active").forEach((item) => item.classList.remove("active"));
5560
- (_c = (_b = this.$grpSwitcher) == null ? void 0 : _b.querySelector(`span[data-index="${index2}"]`)) == null ? void 0 : _c.classList.add("active");
5564
+ (_c = (_b = this.$grpSwitcher) == null ? void 0 : _b.querySelector(`span[data-index="${index}"]`)) == null ? void 0 : _c.classList.add("active");
5561
5565
  this.changeListHeight();
5562
5566
  }
5563
5567
  changeListHeight() {
@@ -5569,7 +5573,7 @@ class Emoticons extends EditorPlug {
5569
5573
  this.emoticons.forEach((grp) => {
5570
5574
  if (grp.type !== "image")
5571
5575
  return;
5572
- Object.entries(grp.items).forEach(([index2, item]) => {
5576
+ Object.entries(grp.items).forEach(([index, item]) => {
5573
5577
  text = text.split(`:[${item.key}]`).join(`<img src="${item.val}" atk-emoticon="${item.key}">`);
5574
5578
  });
5575
5579
  });
@@ -6085,7 +6089,7 @@ function extractCommentID() {
6085
6089
  }
6086
6090
  return commentId || null;
6087
6091
  }
6088
- const version = "2.7.2";
6092
+ const version = "2.7.3";
6089
6093
  const Copyright = (ctx) => {
6090
6094
  ctx.on("conf-loaded", () => {
6091
6095
  const list = ctx.get("list");
@@ -6497,15 +6501,11 @@ const DefaultPlugins = [
6497
6501
  const GlobalPlugins = [...DefaultPlugins];
6498
6502
  class Artalk {
6499
6503
  constructor(conf) {
6500
- __publicField(this, "conf");
6501
6504
  __publicField(this, "ctx");
6502
- __publicField(this, "$root");
6503
6505
  /** Plugins */
6504
6506
  __publicField(this, "plugins", [...GlobalPlugins]);
6505
- this.conf = handelCustomConf(conf);
6506
- if (this.conf.el instanceof HTMLElement)
6507
- this.$root = this.conf.el;
6508
- this.ctx = new Context(this.conf, this.$root);
6507
+ const handledConf = handelCustomConf(conf, true);
6508
+ this.ctx = new Context(handledConf);
6509
6509
  Object.entries(services).forEach(([name, initService]) => {
6510
6510
  const obj = initService(this.ctx);
6511
6511
  if (obj)
@@ -6517,6 +6517,14 @@ class Artalk {
6517
6517
  });
6518
6518
  this.ctx.trigger("inited");
6519
6519
  }
6520
+ /** Get the config of Artalk */
6521
+ getConf() {
6522
+ return this.ctx.getConf();
6523
+ }
6524
+ /** Get the root element of Artalk */
6525
+ getEl() {
6526
+ return this.ctx.$root;
6527
+ }
6520
6528
  /** Update config of Artalk */
6521
6529
  update(conf) {
6522
6530
  this.ctx.updateConf(conf);
@@ -6529,7 +6537,7 @@ class Artalk {
6529
6537
  /** Destroy instance of Artalk */
6530
6538
  destroy() {
6531
6539
  this.ctx.trigger("destroy");
6532
- this.$root.remove();
6540
+ this.ctx.$root.remove();
6533
6541
  }
6534
6542
  /** Add an event listener */
6535
6543
  on(name, handler) {
@@ -6562,7 +6570,7 @@ class Artalk {
6562
6570
  }
6563
6571
  /** Load count widget */
6564
6572
  static loadCountWidget(c) {
6565
- const conf = handelCustomConf(c);
6573
+ const conf = handelCustomConf(c, true);
6566
6574
  initCountWidget({
6567
6575
  getApi: () => new Api(convertApiOptions(conf)),
6568
6576
  pageKey: conf.pageKey,
@@ -6571,18 +6579,25 @@ class Artalk {
6571
6579
  pvAdd: false
6572
6580
  });
6573
6581
  }
6582
+ // ===========================
6583
+ // Deprecated
6584
+ // ===========================
6585
+ /** @deprecated Please use `getEl()` instead */
6586
+ get $root() {
6587
+ return this.ctx.$root;
6588
+ }
6589
+ /** @description Please use `getConf()` instead */
6590
+ get conf() {
6591
+ return this.ctx.getConf();
6592
+ }
6574
6593
  }
6575
- const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6576
- __proto__: null
6577
- }, Symbol.toStringTag, { value: "Module" }));
6578
6594
  const init = Artalk.init;
6579
6595
  const use = Artalk.use;
6580
6596
  const loadCountWidget = Artalk.loadCountWidget;
6581
6597
  export {
6582
- index as ArtalkType,
6583
6598
  Artalk as default,
6584
6599
  init,
6585
6600
  loadCountWidget,
6586
6601
  use
6587
6602
  };
6588
- //# sourceMappingURL=ArtalkLite.es.js.map
6603
+ //# sourceMappingURL=ArtalkLite.mjs.map