artalk 2.2.8 → 2.2.9

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