artalk 2.2.8 → 2.2.11

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
@@ -97,14 +97,15 @@ const defaults$3 = {
97
97
  sendBtn: "\u53D1\u9001\u8BC4\u8BBA",
98
98
  darkMode: false,
99
99
  editorTravel: true,
100
+ flatMode: "auto",
101
+ nestMax: 2,
102
+ nestSort: "DATE_ASC",
100
103
  emoticons: "https://cdn.jsdelivr.net/gh/ArtalkJS/Emoticons/grps/default.json",
101
104
  vote: true,
102
105
  voteDown: false,
103
106
  uaBadge: true,
104
107
  listSort: true,
105
108
  pvEl: "#ArtalkPV",
106
- flatMode: "auto",
107
- maxNesting: 3,
108
109
  gravatar: {
109
110
  default: "mp",
110
111
  mirror: "https://sdn.geekzu.org/avatar/"
@@ -4045,15 +4046,26 @@ class Editor extends Component {
4045
4046
  const inputEl = this.getInputEl(field);
4046
4047
  if (inputEl && inputEl instanceof HTMLInputElement) {
4047
4048
  inputEl.value = this.user.data[field] || "";
4048
- inputEl.addEventListener("input", () => this.onHeaderInputChanged(field, inputEl));
4049
+ inputEl.addEventListener("input", () => this.onHeaderInput(field, inputEl));
4049
4050
  }
4050
4051
  });
4052
+ const $linkInput = this.getInputEl("link");
4053
+ if ($linkInput) {
4054
+ $linkInput.addEventListener("change", () => {
4055
+ const link = $linkInput.value.trim();
4056
+ if (!!link && !/^(http|https):\/\//.test(link)) {
4057
+ $linkInput.value = `https://${link}`;
4058
+ this.user.data.link = $linkInput.value;
4059
+ this.saveUser();
4060
+ }
4061
+ });
4062
+ }
4051
4063
  }
4052
4064
  getInputEl(field) {
4053
4065
  const inputEl = this.$header.querySelector(`[name="${field}"]`);
4054
4066
  return inputEl;
4055
4067
  }
4056
- onHeaderInputChanged(field, inputEl) {
4068
+ onHeaderInput(field, inputEl) {
4057
4069
  this.user.data[field] = inputEl.value.trim();
4058
4070
  if (field === "nick" || field === "email") {
4059
4071
  this.user.data.token = "";
@@ -4747,6 +4759,8 @@ class Comment extends Component {
4747
4759
  __publicField(this, "data");
4748
4760
  __publicField(this, "$main");
4749
4761
  __publicField(this, "$header");
4762
+ __publicField(this, "$headerNick");
4763
+ __publicField(this, "$headerBadge");
4750
4764
  __publicField(this, "$body");
4751
4765
  __publicField(this, "$content");
4752
4766
  __publicField(this, "$children");
@@ -4754,11 +4768,13 @@ class Comment extends Component {
4754
4768
  __publicField(this, "voteBtnUp");
4755
4769
  __publicField(this, "voteBtnDown");
4756
4770
  __publicField(this, "parent");
4757
- __publicField(this, "nestedNum");
4758
- __publicField(this, "maxNestingNum");
4771
+ __publicField(this, "nestCurt");
4772
+ __publicField(this, "nestMax");
4759
4773
  __publicField(this, "children", []);
4774
+ __publicField(this, "flatMode", false);
4760
4775
  __publicField(this, "replyTo");
4761
4776
  __publicField(this, "$replyTo");
4777
+ __publicField(this, "$replyAt");
4762
4778
  __publicField(this, "afterRender");
4763
4779
  __publicField(this, "unread", false);
4764
4780
  __publicField(this, "openable", false);
@@ -4766,11 +4782,11 @@ class Comment extends Component {
4766
4782
  __publicField(this, "openEvt");
4767
4783
  __publicField(this, "onReplyBtnClick");
4768
4784
  __publicField(this, "onDelete");
4769
- this.maxNestingNum = ctx.conf.maxNesting || 3;
4785
+ this.nestMax = ctx.conf.nestMax || 3;
4770
4786
  this.data = __spreadValues({}, data);
4771
4787
  this.data.date = this.data.date.replace(/-/g, "/");
4772
4788
  this.parent = null;
4773
- this.nestedNum = 1;
4789
+ this.nestCurt = 1;
4774
4790
  }
4775
4791
  render() {
4776
4792
  this.$el = createElement(CommentHTML);
@@ -4786,6 +4802,7 @@ class Comment extends Component {
4786
4802
  this.renderAvatar();
4787
4803
  this.renderHeader();
4788
4804
  this.renderContent();
4805
+ this.renderReplyAt();
4789
4806
  this.renderReplyTo();
4790
4807
  this.renderPending();
4791
4808
  this.renderActionBtn();
@@ -4828,26 +4845,27 @@ class Comment extends Component {
4828
4845
  }
4829
4846
  }
4830
4847
  renderHeader() {
4831
- const $nick = this.$el.querySelector(".atk-nick");
4848
+ this.$headerNick = this.$el.querySelector(".atk-nick");
4832
4849
  if (this.data.link) {
4833
4850
  const $nickA = createElement('<a target="_blank" rel="noreferrer noopener nofollow"></a>');
4834
4851
  $nickA.innerText = this.data.nick;
4835
4852
  $nickA.href = this.data.link;
4836
- $nick.append($nickA);
4853
+ this.$headerNick.append($nickA);
4837
4854
  } else {
4838
- $nick.innerText = this.data.nick;
4855
+ this.$headerNick.innerText = this.data.nick;
4839
4856
  }
4840
- const $badge = this.$el.querySelector(".atk-badge");
4857
+ this.$headerBadge = this.$el.querySelector(".atk-badge");
4841
4858
  if (this.data.badge_name) {
4842
- $badge.innerText = this.data.badge_name;
4859
+ this.$headerBadge.innerText = this.data.badge_name;
4843
4860
  if (this.data.badge_color)
4844
- $badge.style.backgroundColor = this.data.badge_color;
4861
+ this.$headerBadge.style.backgroundColor = this.data.badge_color;
4845
4862
  } else {
4846
- $badge.remove();
4863
+ this.$headerBadge.remove();
4864
+ this.$headerBadge = void 0;
4847
4865
  }
4848
4866
  if (this.data.is_pinned) {
4849
4867
  const $pinnedBadge = createElement(`<span class="atk-item atk-pinned-badge">\u7F6E\u9876</span>`);
4850
- $nick.insertAdjacentElement("afterend", $pinnedBadge);
4868
+ this.$headerNick.insertAdjacentElement("afterend", $pinnedBadge);
4851
4869
  }
4852
4870
  const $date = this.$el.querySelector(".atk-date");
4853
4871
  $date.innerText = this.getDateFormatted();
@@ -4890,7 +4908,24 @@ class Comment extends Component {
4890
4908
  }
4891
4909
  });
4892
4910
  }
4911
+ renderReplyAt() {
4912
+ if (this.flatMode || this.data.rid === 0)
4913
+ return;
4914
+ if (this.$replyAt)
4915
+ return;
4916
+ if (!this.replyTo)
4917
+ return;
4918
+ this.$replyAt = createElement(`<span class="atk-item atk-reply-at"><span class="atk-arrow"></span><span class="atk-nick"></span></span>`);
4919
+ this.$replyAt.querySelector(".atk-nick").innerText = `${this.replyTo.nick}`;
4920
+ this.$replyAt.onclick = () => {
4921
+ this.goToReplyComment();
4922
+ };
4923
+ const $after = this.$headerBadge || this.$headerNick;
4924
+ $after.insertAdjacentElement("afterend", this.$replyAt);
4925
+ }
4893
4926
  renderReplyTo() {
4927
+ if (!this.flatMode)
4928
+ return;
4894
4929
  if (!this.replyTo)
4895
4930
  return;
4896
4931
  this.$replyTo = createElement(`
@@ -4898,13 +4933,24 @@ class Comment extends Component {
4898
4933
  <div class="atk-meta">\u56DE\u590D <span class="atk-nick"></span>:</div>
4899
4934
  <div class="atk-content"></div>
4900
4935
  </div>`);
4901
- this.$replyTo.querySelector(".atk-nick").innerText = `@${this.replyTo.nick}`;
4936
+ const $nick = this.$replyTo.querySelector(".atk-nick");
4937
+ $nick.innerText = `@${this.replyTo.nick}`;
4938
+ $nick.onclick = () => {
4939
+ this.goToReplyComment();
4940
+ };
4902
4941
  let replyContent = marked(this.ctx, this.replyTo.content);
4903
4942
  if (this.replyTo.is_collapsed)
4904
4943
  replyContent = "[\u5DF2\u6298\u53E0]";
4905
4944
  this.$replyTo.querySelector(".atk-content").innerHTML = replyContent;
4906
4945
  this.$body.prepend(this.$replyTo);
4907
4946
  }
4947
+ goToReplyComment() {
4948
+ const origHash = window.location.hash;
4949
+ const modifyHash = `#atk-comment-${this.data.rid}`;
4950
+ window.location.hash = modifyHash;
4951
+ if (modifyHash === origHash)
4952
+ window.dispatchEvent(new Event("hashchange"));
4953
+ }
4908
4954
  renderPending() {
4909
4955
  if (!this.data.is_pending)
4910
4956
  return;
@@ -4999,19 +5045,23 @@ class Comment extends Component {
4999
5045
  getChildren() {
5000
5046
  return this.children;
5001
5047
  }
5002
- putChild(childC) {
5048
+ putChild(childC, insertMode = "append") {
5003
5049
  childC.parent = this;
5004
- childC.nestedNum = this.nestedNum + 1;
5050
+ childC.nestCurt = this.nestCurt + 1;
5005
5051
  this.children.push(childC);
5006
- this.getChildrenEl().appendChild(childC.getEl());
5052
+ const $children = this.getChildrenEl();
5053
+ if (insertMode === "append")
5054
+ $children.append(childC.getEl());
5055
+ else if (insertMode === "prepend")
5056
+ $children.prepend(childC.getEl());
5007
5057
  childC.playFadeInAnim();
5008
5058
  childC.checkHeightLimitArea("content");
5009
5059
  }
5010
5060
  getChildrenEl() {
5011
- if (this.$children === null) {
5012
- if (this.nestedNum < this.maxNestingNum) {
5061
+ if (!this.$children) {
5062
+ if (this.nestCurt < this.nestMax) {
5013
5063
  this.$children = createElement('<div class="atk-comment-children"></div>');
5014
- this.$main.appendChild(this.$children);
5064
+ this.$main.append(this.$children);
5015
5065
  } else if (this.parent) {
5016
5066
  this.$children = this.parent.getChildrenEl();
5017
5067
  }
@@ -5389,16 +5439,68 @@ class ReadMoreBtn {
5389
5439
  this.hide();
5390
5440
  }
5391
5441
  }
5442
+ function makeNestCommentNodeList(srcData, sortBy = "DATE_DESC", nestMax = 2) {
5443
+ const nodeList = [];
5444
+ const roots = srcData.filter((o) => o.rid === 0);
5445
+ roots.forEach((root) => {
5446
+ const rootNode = {
5447
+ id: root.id,
5448
+ comment: root,
5449
+ children: [],
5450
+ level: 1
5451
+ };
5452
+ rootNode.parent = rootNode;
5453
+ nodeList.push(rootNode);
5454
+ (function loadChildren(parentNode) {
5455
+ const children = srcData.filter((o) => o.rid === parentNode.id);
5456
+ if (children.length === 0)
5457
+ return;
5458
+ if (parentNode.level >= nestMax)
5459
+ parentNode = parentNode.parent;
5460
+ children.forEach((child) => {
5461
+ const childNode = {
5462
+ id: child.id,
5463
+ comment: child,
5464
+ children: [],
5465
+ parent: parentNode,
5466
+ level: parentNode.level + 1
5467
+ };
5468
+ parentNode.children.push(childNode);
5469
+ loadChildren(childNode);
5470
+ });
5471
+ })(rootNode);
5472
+ });
5473
+ const sortFunc = (a, b) => {
5474
+ let v = a.id - b.id;
5475
+ if (sortBy === "DATE_ASC")
5476
+ v = +new Date(a.comment.date) - +new Date(b.comment.date);
5477
+ else if (sortBy === "DATE_DESC")
5478
+ v = +new Date(b.comment.date) - +new Date(a.comment.date);
5479
+ else if (sortBy === "SRC_INDEX")
5480
+ v = srcData.indexOf(a.comment) - srcData.indexOf(b.comment);
5481
+ else if (sortBy === "VOTE_UP_DESC")
5482
+ v = b.comment.vote_up - a.comment.vote_up;
5483
+ return v;
5484
+ };
5485
+ (function sortLevels(nodes) {
5486
+ nodes.forEach((node) => {
5487
+ node.children = node.children.sort(sortFunc);
5488
+ sortLevels(node.children);
5489
+ });
5490
+ })(nodeList);
5491
+ return nodeList;
5492
+ }
5392
5493
  const backendMinVersion = "2.1.4";
5393
5494
  class ListLite extends Component {
5394
5495
  constructor(ctx) {
5395
5496
  super(ctx);
5396
5497
  __publicField(this, "$commentsWrap");
5397
- __publicField(this, "comments", []);
5498
+ __publicField(this, "commentList", []);
5398
5499
  __publicField(this, "data");
5399
5500
  __publicField(this, "isLoading", false);
5400
5501
  __publicField(this, "noCommentText", "\u65E0\u5185\u5BB9");
5401
5502
  __publicField(this, "flatMode", false);
5503
+ __publicField(this, "nestSortBy");
5402
5504
  __publicField(this, "pageMode", "pagination");
5403
5505
  __publicField(this, "pageSize", 20);
5404
5506
  __publicField(this, "scrollListenerAt");
@@ -5417,6 +5519,7 @@ class ListLite extends Component {
5417
5519
  this.$commentsWrap = this.$el.querySelector(".atk-list-comments-wrap");
5418
5520
  if (ctx.conf.noComment)
5419
5521
  this.noCommentText = ctx.conf.noComment;
5522
+ this.nestSortBy = this.ctx.conf.nestSort || "DATE_ASC";
5420
5523
  window.setInterval(() => {
5421
5524
  this.$el.querySelectorAll("[data-atk-comment-date]").forEach((el) => {
5422
5525
  const date = el.getAttribute("data-atk-comment-date");
@@ -5425,6 +5528,9 @@ class ListLite extends Component {
5425
5528
  }, 30 * 1e3);
5426
5529
  this.ctx.on("unread-update", (data) => this.updateUnread(data.notifies));
5427
5530
  }
5531
+ get commentDataList() {
5532
+ return this.commentList.map((c) => c.data);
5533
+ }
5428
5534
  fetchComments(offset) {
5429
5535
  return __async(this, null, function* () {
5430
5536
  if (this.isLoading)
@@ -5479,7 +5585,7 @@ class ListLite extends Component {
5479
5585
  }
5480
5586
  this.data = data;
5481
5587
  const feMinVersion = ((_a = data.api_version) == null ? void 0 : _a.fe_min_version) || "0.0.0";
5482
- if (this.ctx.conf.versionCheck && this.versionCheck("\u524D\u7AEF", feMinVersion, "2.2.8"))
5588
+ if (this.ctx.conf.versionCheck && this.versionCheck("\u524D\u7AEF", feMinVersion, "2.2.11"))
5483
5589
  return;
5484
5590
  if (this.ctx.conf.versionCheck && this.versionCheck("\u540E\u7AEF", backendMinVersion, (_b = data.api_version) == null ? void 0 : _b.version))
5485
5591
  return;
@@ -5590,7 +5696,7 @@ class ListLite extends Component {
5590
5696
  setError(this.$el, $err);
5591
5697
  }
5592
5698
  refreshUI() {
5593
- const isNoComment = this.comments.length <= 0;
5699
+ const isNoComment = this.commentList.length <= 0;
5594
5700
  let $noComment = this.$commentsWrap.querySelector(".atk-list-no-comment");
5595
5701
  if (isNoComment) {
5596
5702
  if (!$noComment) {
@@ -5603,8 +5709,11 @@ class ListLite extends Component {
5603
5709
  }
5604
5710
  this.ctx.trigger("check-admin-show-el");
5605
5711
  }
5606
- createComment(data) {
5607
- const comment2 = new Comment(this.ctx, data);
5712
+ createComment(cData, ctxData) {
5713
+ if (!ctxData)
5714
+ ctxData = this.commentDataList;
5715
+ const comment2 = new Comment(this.ctx, cData);
5716
+ comment2.flatMode = this.flatMode;
5608
5717
  comment2.afterRender = () => {
5609
5718
  if (this.renderComment)
5610
5719
  this.renderComment(comment2);
@@ -5613,6 +5722,7 @@ class ListLite extends Component {
5613
5722
  this.deleteComment(c);
5614
5723
  this.refreshUI();
5615
5724
  };
5725
+ comment2.replyTo = cData.rid ? ctxData.find((c) => c.id === cData.rid) : void 0;
5616
5726
  return comment2;
5617
5727
  }
5618
5728
  importComments(srcData) {
@@ -5621,44 +5731,37 @@ class ListLite extends Component {
5621
5731
  this.putCommentFlatMode(commentData, srcData, "append");
5622
5732
  });
5623
5733
  } else {
5624
- this.importCommentsNesting(srcData);
5734
+ this.importCommentsNest(srcData);
5625
5735
  }
5626
5736
  }
5627
- importCommentsNesting(srcData) {
5628
- const loadChildren = (parentC) => {
5629
- const children = srcData.filter((o) => o.rid === parentC.data.id);
5630
- children.forEach((childData) => {
5631
- const childC = this.createComment(childData);
5632
- childC.render();
5633
- parentC.putChild(childC);
5634
- loadChildren(childC);
5635
- });
5636
- };
5637
- const rootComments = srcData.filter((o) => o.rid === 0);
5638
- rootComments.forEach((rootData) => {
5639
- const rootC = this.createComment(rootData);
5737
+ importCommentsNest(srcData) {
5738
+ const rootNodes = makeNestCommentNodeList(srcData, this.nestSortBy, this.conf.nestMax);
5739
+ rootNodes.forEach((rootNode) => {
5740
+ const rootC = this.createComment(rootNode.comment, srcData);
5640
5741
  rootC.render();
5641
5742
  this.$commentsWrap.appendChild(rootC.getEl());
5642
5743
  rootC.playFadeInAnim();
5643
- this.comments.push(rootC);
5644
- loadChildren(rootC);
5744
+ this.commentList.push(rootC);
5745
+ const that = this;
5746
+ (function loadChildren(parentC, parentNode) {
5747
+ parentNode.children.forEach((node) => {
5748
+ const childD = node.comment;
5749
+ const childC = that.createComment(childD, srcData);
5750
+ childC.render();
5751
+ parentC.putChild(childC);
5752
+ that.commentList.push(childC);
5753
+ loadChildren(childC, node);
5754
+ });
5755
+ })(rootC, rootNode);
5645
5756
  rootC.checkHeightLimit();
5646
5757
  });
5647
5758
  }
5648
- putCommentFlatMode(cData, srcData, insertMode) {
5759
+ putCommentFlatMode(cData, ctxData, insertMode) {
5649
5760
  if (cData.is_collapsed)
5650
5761
  cData.is_allow_reply = false;
5651
- const comment2 = this.createComment(cData);
5652
- if (cData.rid !== 0) {
5653
- const rComment = srcData.find((o) => o.id === cData.rid);
5654
- if (rComment)
5655
- comment2.replyTo = rComment;
5656
- }
5762
+ const comment2 = this.createComment(cData, ctxData);
5657
5763
  comment2.render();
5658
- if (insertMode === "append")
5659
- this.comments.push(comment2);
5660
- if (insertMode === "prepend")
5661
- this.comments.unshift(comment2);
5764
+ this.commentList.push(comment2);
5662
5765
  if (cData.visible) {
5663
5766
  if (insertMode === "append")
5664
5767
  this.$commentsWrap.append(comment2.getEl());
@@ -5672,14 +5775,15 @@ class ListLite extends Component {
5672
5775
  insertComment(commentData) {
5673
5776
  if (!this.flatMode) {
5674
5777
  const comment2 = this.createComment(commentData);
5675
- comment2.render();
5676
5778
  if (commentData.rid === 0) {
5779
+ comment2.render();
5677
5780
  this.$commentsWrap.prepend(comment2.getEl());
5678
- this.comments.unshift(comment2);
5781
+ this.commentList.push(comment2);
5679
5782
  } else {
5680
5783
  const parent = this.findComment(commentData.rid);
5681
5784
  if (parent) {
5682
- parent.putChild(comment2);
5785
+ comment2.render();
5786
+ parent.putChild(comment2, this.nestSortBy === "DATE_ASC" ? "append" : "prepend");
5683
5787
  comment2.getParents().forEach((p) => {
5684
5788
  if (p.$children)
5685
5789
  p.heightLimitRemove(p.$children);
@@ -5690,7 +5794,7 @@ class ListLite extends Component {
5690
5794
  scrollIntoView(comment2.getEl());
5691
5795
  comment2.playFadeInAnim();
5692
5796
  } else {
5693
- const comment2 = this.putCommentFlatMode(commentData, this.comments.map((c) => c.data), "prepend");
5797
+ const comment2 = this.putCommentFlatMode(commentData, this.commentDataList, "prepend");
5694
5798
  scrollIntoView(comment2.getEl());
5695
5799
  }
5696
5800
  if (this.data)
@@ -5698,45 +5802,20 @@ class ListLite extends Component {
5698
5802
  this.refreshUI();
5699
5803
  this.ctx.trigger("comments-loaded");
5700
5804
  }
5701
- eachComment(commentList, action) {
5702
- if (commentList.length === 0)
5703
- return;
5704
- commentList.every((item) => {
5705
- if (action(item, commentList) === false)
5706
- return false;
5707
- this.eachComment(item.getChildren(), action);
5708
- return true;
5709
- });
5710
- }
5711
- findComment(id, src) {
5712
- if (!src)
5713
- src = this.comments;
5714
- let comment2 = null;
5715
- this.eachComment(src, (item) => {
5716
- if (item.data.id === id) {
5717
- comment2 = item;
5718
- return false;
5719
- }
5720
- return true;
5721
- });
5722
- return comment2;
5805
+ findComment(id) {
5806
+ return this.commentList.find((c) => c.data.id === id);
5723
5807
  }
5724
- deleteComment(comment2) {
5725
- let findComment;
5726
- if (typeof comment2 === "number") {
5727
- findComment = this.findComment(comment2);
5808
+ deleteComment(_comment) {
5809
+ let comment2;
5810
+ if (typeof _comment === "number") {
5811
+ const findComment = this.findComment(_comment);
5728
5812
  if (!findComment)
5729
- throw Error(`\u672A\u627E\u5230\u8BC4\u8BBA ${comment2}`);
5813
+ throw Error(`\u672A\u627E\u5230\u8BC4\u8BBA ${_comment}`);
5814
+ comment2 = findComment;
5730
5815
  } else
5731
- findComment = comment2;
5732
- findComment.getEl().remove();
5733
- this.eachComment(this.comments, (item, levelList) => {
5734
- if (item === findComment) {
5735
- levelList.splice(levelList.indexOf(item), 1);
5736
- return false;
5737
- }
5738
- return true;
5739
- });
5816
+ comment2 = _comment;
5817
+ comment2.getEl().remove();
5818
+ this.commentList.splice(this.commentList.indexOf(comment2), 1);
5740
5819
  if (this.data)
5741
5820
  this.data.total -= 1;
5742
5821
  this.refreshUI();
@@ -5744,12 +5823,12 @@ class ListLite extends Component {
5744
5823
  clearAllComments() {
5745
5824
  this.$commentsWrap.innerHTML = "";
5746
5825
  this.data = void 0;
5747
- this.comments = [];
5826
+ this.commentList = [];
5748
5827
  }
5749
5828
  updateUnread(notifies) {
5750
5829
  this.unread = notifies;
5751
5830
  if (this.unreadHighlight === true) {
5752
- this.eachComment(this.comments, (comment2) => {
5831
+ this.commentList.forEach((comment2) => {
5753
5832
  const notify = this.unread.find((o) => o.comment_id === comment2.data.id);
5754
5833
  if (notify) {
5755
5834
  comment2.setUnread(true);
@@ -5793,6 +5872,8 @@ class List extends ListLite {
5793
5872
  __publicField(this, "$unreadBadge");
5794
5873
  __publicField(this, "$commentCount");
5795
5874
  __publicField(this, "$dropdownWrap");
5875
+ __publicField(this, "goToCommentFounded", false);
5876
+ __publicField(this, "goToCommentDelay", true);
5796
5877
  el.querySelector(".atk-list-body").append(this.$el);
5797
5878
  this.$el = el;
5798
5879
  let flatMode = false;
@@ -5811,7 +5892,7 @@ class List extends ListLite {
5811
5892
  if (this.ctx.conf.listSort) {
5812
5893
  this.initDropdown();
5813
5894
  }
5814
- this.$el.querySelector(".atk-copyright").innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${"2.2.8"}">Artalk</a>`;
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>`;
5815
5896
  this.ctx.on("list-reload", () => this.fetchComments(0));
5816
5897
  this.ctx.on("list-refresh-ui", () => this.refreshUI());
5817
5898
  this.ctx.on("list-import", (data) => this.importComments(data));
@@ -5861,36 +5942,55 @@ class List extends ListLite {
5861
5942
  }
5862
5943
  onLoad(data, offset) {
5863
5944
  super.onLoad(data, offset);
5864
- this.checkGoToCommentByUrlHash();
5945
+ if (!this.goToCommentFounded)
5946
+ this.checkGoToCommentByUrlHash();
5947
+ if (this.ctx.conf.editorTravel === true) {
5948
+ this.ctx.trigger("editor-travel-back");
5949
+ }
5865
5950
  }
5866
5951
  checkGoToCommentByUrlHash() {
5867
- return __async(this, null, function* () {
5868
- let commentId = Number(getQueryParam("atk_comment"));
5869
- if (!commentId) {
5870
- const match = window.location.hash.match(/#atk-comment-([0-9]+)/);
5871
- if (!match || !match[1] || Number.isNaN(Number(match[1])))
5872
- return;
5873
- commentId = Number(match[1]);
5874
- }
5875
- if (!commentId)
5952
+ let commentId = Number(getQueryParam("atk_comment"));
5953
+ if (!commentId) {
5954
+ const match = window.location.hash.match(/#atk-comment-([0-9]+)/);
5955
+ if (!match || !match[1] || Number.isNaN(Number(match[1])))
5876
5956
  return;
5877
- const notifyKey = getQueryParam("atk_notify_key");
5878
- if (notifyKey) {
5879
- new Api(this.ctx).markRead(notifyKey).then(() => {
5880
- this.unread = this.unread.filter((o) => o.comment_id !== commentId);
5881
- this.ctx.trigger("unread-update", {
5882
- notifies: this.unread
5883
- });
5957
+ commentId = Number(match[1]);
5958
+ }
5959
+ if (!commentId)
5960
+ return;
5961
+ const comment2 = this.findComment(commentId);
5962
+ if (!comment2) {
5963
+ if (this.readMoreBtn)
5964
+ this.readMoreBtn.click();
5965
+ else if (this.pagination)
5966
+ this.pagination.next();
5967
+ return;
5968
+ }
5969
+ const notifyKey = getQueryParam("atk_notify_key");
5970
+ if (notifyKey) {
5971
+ new Api(this.ctx).markRead(notifyKey).then(() => {
5972
+ this.unread = this.unread.filter((o) => o.comment_id !== commentId);
5973
+ this.ctx.trigger("unread-update", {
5974
+ notifies: this.unread
5884
5975
  });
5885
- }
5886
- const comment2 = this.findComment(commentId);
5887
- if (!comment2)
5888
- return;
5976
+ });
5977
+ }
5978
+ comment2.getParents().forEach((p) => {
5979
+ if (p.$children)
5980
+ p.heightLimitRemove(p.$children);
5981
+ });
5982
+ const goTo = () => {
5889
5983
  scrollIntoView(comment2.getEl(), false);
5984
+ comment2.getEl().classList.remove("atk-flash-once");
5890
5985
  window.setTimeout(() => {
5891
5986
  comment2.getEl().classList.add("atk-flash-once");
5892
- }, 800);
5893
- });
5987
+ }, 150);
5988
+ };
5989
+ if (!this.goToCommentDelay)
5990
+ goTo();
5991
+ else
5992
+ window.setTimeout(() => goTo(), 350);
5993
+ this.goToCommentFounded = true;
5894
5994
  }
5895
5995
  adminPageEditSave() {
5896
5996
  if (!this.data || !this.data.page)
@@ -6117,6 +6217,9 @@ const _Artalk = class {
6117
6217
  if (!this.conf.pageTitle) {
6118
6218
  this.conf.pageTitle = `${document.title}`;
6119
6219
  }
6220
+ if (this.conf.nestMax && this.conf.nestMax <= 1) {
6221
+ this.conf.flatMode = true;
6222
+ }
6120
6223
  if (!!this.conf.el && this.conf.el instanceof HTMLElement) {
6121
6224
  this.$root = this.conf.el;
6122
6225
  } else {
@@ -6177,6 +6280,7 @@ const _Artalk = class {
6177
6280
  }
6178
6281
  initEventBind() {
6179
6282
  window.addEventListener("hashchange", () => {
6283
+ this.list.goToCommentDelay = false;
6180
6284
  this.list.checkGoToCommentByUrlHash();
6181
6285
  });
6182
6286
  this.ctx.on("check-admin-show-el", () => {