artalk 2.8.3 → 2.8.5
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.cjs +2 -2
- package/dist/Artalk.cjs.map +1 -1
- package/dist/Artalk.css +1 -1
- package/dist/Artalk.iife.js +2 -2
- package/dist/Artalk.iife.js.map +1 -1
- package/dist/Artalk.js +1 -1
- package/dist/Artalk.js.map +1 -1
- package/dist/Artalk.mjs +258 -156
- package/dist/Artalk.mjs.map +1 -1
- package/dist/ArtalkLite.cjs +1 -1
- package/dist/ArtalkLite.cjs.map +1 -1
- package/dist/ArtalkLite.css +1 -1
- package/dist/ArtalkLite.iife.js +1 -1
- package/dist/ArtalkLite.iife.js.map +1 -1
- package/dist/ArtalkLite.js +1 -1
- package/dist/ArtalkLite.js.map +1 -1
- package/dist/ArtalkLite.mjs +254 -152
- package/dist/ArtalkLite.mjs.map +1 -1
- package/dist/i18n/jp.cjs +1 -1
- package/dist/i18n/jp.js +1 -1
- package/dist/i18n/jp.mjs +85 -81
- package/dist/i18n/zh-TW.cjs +1 -1
- package/dist/i18n/zh-TW.js +1 -1
- package/dist/i18n/zh-TW.mjs +1 -1
- package/dist/main.d.cts +12 -12
- package/dist/main.d.ts +12 -12
- package/package.json +49 -30
package/dist/Artalk.mjs
CHANGED
|
@@ -1719,7 +1719,7 @@ function getDefaultExportFromCjs(x) {
|
|
|
1719
1719
|
const Fetch$1 = (opts, input, init2) => __async(void 0, null, function* () {
|
|
1720
1720
|
const apiToken = opts.getApiToken && opts.getApiToken();
|
|
1721
1721
|
const headers = new Headers(__spreadValues({
|
|
1722
|
-
|
|
1722
|
+
Authorization: apiToken ? `Bearer ${apiToken}` : ""
|
|
1723
1723
|
}, init2 == null ? void 0 : init2.headers));
|
|
1724
1724
|
if (!headers.get("Authorization"))
|
|
1725
1725
|
headers.delete("Authorization");
|
|
@@ -2598,14 +2598,14 @@ const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\
|
|
|
2598
2598
|
const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
2599
2599
|
const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
2600
2600
|
const bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
2601
|
-
const lheading = edit(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet).getRegex();
|
|
2601
|
+
const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet).replace(/blockCode/g, / {4}/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).getRegex();
|
|
2602
2602
|
const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
|
|
2603
2603
|
const blockText = /^[^\n]+/;
|
|
2604
2604
|
const _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
|
|
2605
2605
|
const def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
|
|
2606
2606
|
const list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
|
|
2607
|
-
const _tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|
|
|
2608
|
-
const _comment = /<!--(
|
|
2607
|
+
const _tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
|
|
2608
|
+
const _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
2609
2609
|
const html = edit("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))", "i").replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
2610
2610
|
const paragraph = edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
|
|
2611
2611
|
const blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
|
|
@@ -2642,7 +2642,7 @@ const escape = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
|
2642
2642
|
const inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
2643
2643
|
const br = /^( {2,}|\\)\n(?!\s*$)/;
|
|
2644
2644
|
const inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
|
|
2645
|
-
const _punctuation = "\\p{P}
|
|
2645
|
+
const _punctuation = "\\p{P}\\p{S}";
|
|
2646
2646
|
const punctuation = edit(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, _punctuation).getRegex();
|
|
2647
2647
|
const blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
|
|
2648
2648
|
const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, _punctuation).getRegex();
|
|
@@ -4343,7 +4343,10 @@ function getRenderer() {
|
|
|
4343
4343
|
const markedLinkRenderer = (renderer, orgLinkRenderer) => (href, title, text) => {
|
|
4344
4344
|
const localLink = href == null ? void 0 : href.startsWith(`${window.location.protocol}//${window.location.hostname}`);
|
|
4345
4345
|
const html2 = orgLinkRenderer.call(renderer, href, title, text);
|
|
4346
|
-
return html2.replace(
|
|
4346
|
+
return html2.replace(
|
|
4347
|
+
/^<a /,
|
|
4348
|
+
`<a target="_blank" ${!localLink ? `rel="noreferrer noopener nofollow"` : ""} `
|
|
4349
|
+
);
|
|
4347
4350
|
};
|
|
4348
4351
|
const markedCodeRenderer = () => (block2, lang) => {
|
|
4349
4352
|
const realLang = !lang ? "plaintext" : lang;
|
|
@@ -4398,7 +4401,13 @@ function marked(src) {
|
|
|
4398
4401
|
return dest;
|
|
4399
4402
|
}
|
|
4400
4403
|
function simpleMarked(src) {
|
|
4401
|
-
return src.replace(
|
|
4404
|
+
return src.replace(
|
|
4405
|
+
/```\s*([^]+?.*?[^]+?[^]+?)```/g,
|
|
4406
|
+
(_, code) => `<pre><code>${renderCode(code)}</code></pre>`
|
|
4407
|
+
).replace(/!\[(.*?)\]\((.*?)\)/g, (_, alt, imgSrc) => `<img src="${imgSrc}" alt="${alt}" />`).replace(
|
|
4408
|
+
/\[(.*?)\]\((.*?)\)/g,
|
|
4409
|
+
(_, text, link2) => `<a href="${link2}" target="_blank">${text}</a>`
|
|
4410
|
+
).replace(/\n/g, "<br>");
|
|
4402
4411
|
}
|
|
4403
4412
|
function mergeDeep(...objects) {
|
|
4404
4413
|
const isObject = (obj) => obj && typeof obj === "object" && obj.constructor === Object;
|
|
@@ -4581,7 +4590,7 @@ const en = {
|
|
|
4581
4590
|
deleteFail: "Delete Failed",
|
|
4582
4591
|
reqGot: "Request got",
|
|
4583
4592
|
reqAborted: "Request timed out or terminated unexpectedly",
|
|
4584
|
-
updateMsg: "Please update Artalk {name} to get the
|
|
4593
|
+
updateMsg: "Please update Artalk {name} to get the best experience!",
|
|
4585
4594
|
currentVersion: "Current Version",
|
|
4586
4595
|
ignore: "Ignore",
|
|
4587
4596
|
open: "Open",
|
|
@@ -4662,7 +4671,7 @@ const zhCN = {
|
|
|
4662
4671
|
deleteFail: "删除失败",
|
|
4663
4672
|
reqGot: "请求响应",
|
|
4664
4673
|
reqAborted: "请求超时或意外终止",
|
|
4665
|
-
updateMsg: "请更新 Artalk {name}
|
|
4674
|
+
updateMsg: "请更新 Artalk {name} 以获得更好的体验!",
|
|
4666
4675
|
currentVersion: "当前版本",
|
|
4667
4676
|
ignore: "忽略",
|
|
4668
4677
|
open: "打开",
|
|
@@ -4816,7 +4825,10 @@ function getCorrectUserAgent() {
|
|
|
4816
4825
|
}
|
|
4817
4826
|
if (uaData.platform === "macOS") {
|
|
4818
4827
|
if (majorPlatformVersion >= 11) {
|
|
4819
|
-
return uaRaw.replace(
|
|
4828
|
+
return uaRaw.replace(
|
|
4829
|
+
/(Mac OS X \d+_\d+_\d+|Mac OS X)/,
|
|
4830
|
+
`Mac OS X ${uaGot.platformVersion.replace(/\./g, "_")}`
|
|
4831
|
+
);
|
|
4820
4832
|
}
|
|
4821
4833
|
}
|
|
4822
4834
|
return uaRaw;
|
|
@@ -4838,7 +4850,7 @@ function getURLBasedOn(baseURL, path) {
|
|
|
4838
4850
|
return `${baseURL.replace(/\/$/, "")}/${path.replace(/^\//, "")}`;
|
|
4839
4851
|
}
|
|
4840
4852
|
const internal = {
|
|
4841
|
-
|
|
4853
|
+
en,
|
|
4842
4854
|
"en-US": en,
|
|
4843
4855
|
"zh-CN": zhCN
|
|
4844
4856
|
};
|
|
@@ -4876,7 +4888,10 @@ class EventManager {
|
|
|
4876
4888
|
* Add an event listener for a specific event name
|
|
4877
4889
|
*/
|
|
4878
4890
|
on(name, handler, opts = {}) {
|
|
4879
|
-
this.events.push(__spreadValues({
|
|
4891
|
+
this.events.push(__spreadValues({
|
|
4892
|
+
name,
|
|
4893
|
+
handler
|
|
4894
|
+
}, opts));
|
|
4880
4895
|
}
|
|
4881
4896
|
/**
|
|
4882
4897
|
* Remove an event listener for a specific event name and handler
|
|
@@ -5354,7 +5369,9 @@ function imgBody(checker) {
|
|
|
5354
5369
|
}
|
|
5355
5370
|
function iframeBody(checker) {
|
|
5356
5371
|
const $iframeWrap = createElement(`<div class="atk-checker-iframe-wrap"></div>`);
|
|
5357
|
-
const $iframe = createElement(
|
|
5372
|
+
const $iframe = createElement(
|
|
5373
|
+
`<iframe class="atk-fade-in" referrerpolicy="strict-origin-when-cross-origin"></iframe>`
|
|
5374
|
+
);
|
|
5358
5375
|
$iframe.style.display = "none";
|
|
5359
5376
|
showLoading($iframeWrap, { transparentBg: true });
|
|
5360
5377
|
$iframe.src = checker.getOpts().getCaptchaIframeURL();
|
|
@@ -5363,7 +5380,9 @@ function iframeBody(checker) {
|
|
|
5363
5380
|
hideLoading($iframeWrap);
|
|
5364
5381
|
};
|
|
5365
5382
|
$iframeWrap.append($iframe);
|
|
5366
|
-
const $closeBtn = createElement(
|
|
5383
|
+
const $closeBtn = createElement(
|
|
5384
|
+
`<div class="atk-close-btn"><i class="atk-icon atk-icon-close"></i></div>`
|
|
5385
|
+
);
|
|
5367
5386
|
$iframeWrap.append($closeBtn);
|
|
5368
5387
|
checker.hideInteractInput();
|
|
5369
5388
|
let stop = false;
|
|
@@ -5575,7 +5594,7 @@ class Component {
|
|
|
5575
5594
|
return this.$el;
|
|
5576
5595
|
}
|
|
5577
5596
|
}
|
|
5578
|
-
const EditorHTML = '<div class="atk-main-editor">\n <div class="atk-header">\n <input name="nick" class="atk-nick" type="text" required="required"
|
|
5597
|
+
const EditorHTML = '<div class="atk-main-editor">\n <div class="atk-header">\n <input name="nick" class="atk-nick" type="text" required="required" />\n <input name="email" class="atk-email" type="email" required="required" />\n <input name="link" class="atk-link" type="url" />\n </div>\n <div class="atk-textarea-wrap">\n <textarea class="atk-textarea"></textarea>\n </div>\n <div class="atk-plug-panel-wrap" style="display: none"></div>\n <div class="atk-bottom">\n <div class="atk-item atk-bottom-left">\n <span class="atk-state-wrap"></span>\n <span class="atk-plug-btn-wrap"></span>\n </div>\n <div class="atk-item">\n <button type="button" class="atk-send-btn"></button>\n </div>\n </div>\n <div class="atk-notify-wrap"></div>\n</div>\n';
|
|
5579
5598
|
const Sel = {
|
|
5580
5599
|
$header: ".atk-header",
|
|
5581
5600
|
$nick: '.atk-header [name="nick"]',
|
|
@@ -5749,7 +5768,9 @@ class Editor extends Component {
|
|
|
5749
5768
|
const sStart = this.ui.$textarea.selectionStart;
|
|
5750
5769
|
const sEnd = this.ui.$textarea.selectionEnd;
|
|
5751
5770
|
const sT = this.ui.$textarea.scrollTop;
|
|
5752
|
-
this.setContent(
|
|
5771
|
+
this.setContent(
|
|
5772
|
+
this.ui.$textarea.value.substring(0, sStart) + val + this.ui.$textarea.value.substring(sEnd, this.ui.$textarea.value.length)
|
|
5773
|
+
);
|
|
5753
5774
|
this.ui.$textarea.focus();
|
|
5754
5775
|
this.ui.$textarea.selectionStart = sStart + val.length;
|
|
5755
5776
|
this.ui.$textarea.selectionEnd = sStart + val.length;
|
|
@@ -5793,7 +5814,7 @@ class Editor extends Component {
|
|
|
5793
5814
|
}
|
|
5794
5815
|
}
|
|
5795
5816
|
}
|
|
5796
|
-
const SidebarHTML = '<div class="atk-sidebar-layer">\n <div class="atk-sidebar-inner">\n <div class="atk-sidebar-header">\n <div class="atk-sidebar-close"
|
|
5817
|
+
const SidebarHTML = '<div class="atk-sidebar-layer">\n <div class="atk-sidebar-inner">\n <div class="atk-sidebar-header">\n <div class="atk-sidebar-close">\n <i class="atk-icon atk-icon-close-slim"></i>\n </div>\n </div>\n <div class="atk-sidebar-iframe-wrap"></div>\n </div>\n</div>\n';
|
|
5797
5818
|
class SidebarLayer extends Component {
|
|
5798
5819
|
constructor(ctx) {
|
|
5799
5820
|
super(ctx);
|
|
@@ -5832,7 +5853,10 @@ class SidebarLayer extends Component {
|
|
|
5832
5853
|
const $iframe = this.$iframe;
|
|
5833
5854
|
const iFrameSrc = $iframe.src;
|
|
5834
5855
|
if (this.conf.darkMode !== iFrameSrc.includes("darkMode=1")) {
|
|
5835
|
-
this.iframeLoad(
|
|
5856
|
+
this.iframeLoad(
|
|
5857
|
+
$iframe,
|
|
5858
|
+
this.conf.darkMode ? iFrameSrc.concat("&darkMode=1") : iFrameSrc.replace("&darkMode=1", "")
|
|
5859
|
+
);
|
|
5836
5860
|
}
|
|
5837
5861
|
}
|
|
5838
5862
|
this.authCheck({
|
|
@@ -5886,7 +5910,9 @@ class SidebarLayer extends Component {
|
|
|
5886
5910
|
});
|
|
5887
5911
|
}
|
|
5888
5912
|
createIframe(view) {
|
|
5889
|
-
const $iframe = createElement(
|
|
5913
|
+
const $iframe = createElement(
|
|
5914
|
+
'<iframe referrerpolicy="strict-origin-when-cross-origin"></iframe>'
|
|
5915
|
+
);
|
|
5890
5916
|
const baseURL = getURLBasedOnApi({
|
|
5891
5917
|
base: this.ctx.conf.server,
|
|
5892
5918
|
path: "/sidebar/"
|
|
@@ -5913,7 +5939,7 @@ class SidebarLayer extends Component {
|
|
|
5913
5939
|
};
|
|
5914
5940
|
}
|
|
5915
5941
|
}
|
|
5916
|
-
const ListHTML = '<div class="atk-list">\n <div class="atk-list-header">\n <div class="atk-comment-count">\n <div class="atk-text"></div>\n </div>\n <div class="atk-right-action">\n <span data-action="admin-close-comment" class="atk-hide" atk-only-admin-show></span>\n <span data-action="open-sidebar" class="atk-hide atk-on">\n <span class="atk-unread-badge" style="display: none
|
|
5942
|
+
const ListHTML = '<div class="atk-list">\n <div class="atk-list-header">\n <div class="atk-comment-count">\n <div class="atk-text"></div>\n </div>\n <div class="atk-right-action">\n <span data-action="admin-close-comment" class="atk-hide" atk-only-admin-show></span>\n <span data-action="open-sidebar" class="atk-hide atk-on">\n <span class="atk-unread-badge" style="display: none"></span>\n <div class="atk-text"></div>\n </span>\n </div>\n </div>\n <div class="atk-list-body">\n <div class="atk-list-comments-wrap"></div>\n </div>\n <div class="atk-list-footer">\n <div class="atk-copyright"></div>\n </div>\n</div>\n';
|
|
5917
5943
|
function makeNestCommentNodeList(srcData, sortBy = "DATE_DESC", nestMax = 2) {
|
|
5918
5944
|
const nodeList = [];
|
|
5919
5945
|
const roots = srcData.filter((o) => o.rid === 0);
|
|
@@ -5975,8 +6001,9 @@ const createNestStrategy = (opts) => ({
|
|
|
5975
6001
|
rootC.getRender().playFadeAnim();
|
|
5976
6002
|
const loadChildren = (parentC, parentNode) => {
|
|
5977
6003
|
parentNode.children.forEach((node) => {
|
|
6004
|
+
const replyD = comments.find((c) => c.id === node.comment.rid);
|
|
5978
6005
|
const childD = node.comment;
|
|
5979
|
-
const childC = opts.createCommentNode(childD,
|
|
6006
|
+
const childC = opts.createCommentNode(childD, replyD);
|
|
5980
6007
|
parentC.putChild(childC);
|
|
5981
6008
|
loadChildren(childC, node);
|
|
5982
6009
|
});
|
|
@@ -6238,16 +6265,16 @@ function Detect(userAgent) {
|
|
|
6238
6265
|
return dest;
|
|
6239
6266
|
}
|
|
6240
6267
|
function check(conf, rules) {
|
|
6241
|
-
rules.forEach(({
|
|
6242
|
-
el,
|
|
6243
|
-
max: maxHeight,
|
|
6244
|
-
imgContains
|
|
6245
|
-
}) => {
|
|
6268
|
+
rules.forEach(({ el, max: maxHeight, imgContains }) => {
|
|
6246
6269
|
const _apply = () => {
|
|
6247
6270
|
if (!el)
|
|
6248
6271
|
return;
|
|
6249
6272
|
if (!conf.scrollable)
|
|
6250
|
-
applyHeightLimit({
|
|
6273
|
+
applyHeightLimit({
|
|
6274
|
+
el,
|
|
6275
|
+
maxHeight,
|
|
6276
|
+
postBtnClick: conf.postExpandBtnClick
|
|
6277
|
+
});
|
|
6251
6278
|
else
|
|
6252
6279
|
applyScrollableHeightLimit({ el, maxHeight });
|
|
6253
6280
|
};
|
|
@@ -6271,7 +6298,9 @@ function applyHeightLimit(obj) {
|
|
|
6271
6298
|
obj.el.classList.add(HEIGHT_LIMIT_CSS);
|
|
6272
6299
|
obj.el.style.height = `${obj.maxHeight}px`;
|
|
6273
6300
|
obj.el.style.overflow = "hidden";
|
|
6274
|
-
const $expandBtn = createElement(
|
|
6301
|
+
const $expandBtn = createElement(
|
|
6302
|
+
`<div class="atk-height-limit-btn">${t("readMore")}</span>`
|
|
6303
|
+
);
|
|
6275
6304
|
$expandBtn.onclick = (e) => {
|
|
6276
6305
|
e.stopPropagation();
|
|
6277
6306
|
disposeHeightLimit(obj.el);
|
|
@@ -6309,7 +6338,9 @@ function renderAvatar(r) {
|
|
|
6309
6338
|
const avatarURLBuilder = r.opts.avatarURLBuilder;
|
|
6310
6339
|
$avatarImg.src = avatarURLBuilder ? avatarURLBuilder(r.data) : r.comment.getGravatarURL();
|
|
6311
6340
|
if (r.data.link) {
|
|
6312
|
-
const $avatarA = createElement(
|
|
6341
|
+
const $avatarA = createElement(
|
|
6342
|
+
'<a target="_blank" rel="noreferrer noopener nofollow"></a>'
|
|
6343
|
+
);
|
|
6313
6344
|
$avatarA.href = isValidURL(r.data.link) ? r.data.link : `https://${r.data.link}`;
|
|
6314
6345
|
$avatarA.append($avatarImg);
|
|
6315
6346
|
$avatar.append($avatarA);
|
|
@@ -6330,7 +6361,9 @@ function renderHeader(r) {
|
|
|
6330
6361
|
function renderNick(r) {
|
|
6331
6362
|
r.$headerNick = r.$el.querySelector(".atk-nick");
|
|
6332
6363
|
if (r.data.link) {
|
|
6333
|
-
const $nickA = createElement(
|
|
6364
|
+
const $nickA = createElement(
|
|
6365
|
+
'<a target="_blank" rel="noreferrer noopener nofollow"></a>'
|
|
6366
|
+
);
|
|
6334
6367
|
$nickA.innerText = r.data.nick;
|
|
6335
6368
|
$nickA.href = isValidURL(r.data.link) ? r.data.link : `https://${r.data.link}`;
|
|
6336
6369
|
r.$headerNick.append($nickA);
|
|
@@ -6349,7 +6382,9 @@ function renderVerifyBadge(ctx) {
|
|
|
6349
6382
|
$badge.style.backgroundColor = badgeColor || "";
|
|
6350
6383
|
ctx.$headerBadgeWrap.append($badge);
|
|
6351
6384
|
} else if (ctx.data.is_verified) {
|
|
6352
|
-
const $verifiedBadge = createElement(
|
|
6385
|
+
const $verifiedBadge = createElement(
|
|
6386
|
+
`<span class="atk-verified-icon" title="${t("emailVerified")}"></span>`
|
|
6387
|
+
);
|
|
6353
6388
|
ctx.$headerBadgeWrap.append($verifiedBadge);
|
|
6354
6389
|
}
|
|
6355
6390
|
if (ctx.data.is_pinned) {
|
|
@@ -6423,7 +6458,9 @@ function renderReplyAt(r) {
|
|
|
6423
6458
|
return;
|
|
6424
6459
|
if (!r.opts.replyTo)
|
|
6425
6460
|
return;
|
|
6426
|
-
r.$replyAt = createElement(
|
|
6461
|
+
r.$replyAt = createElement(
|
|
6462
|
+
`<span class="atk-item atk-reply-at"><span class="atk-arrow"></span><span class="atk-nick"></span></span>`
|
|
6463
|
+
);
|
|
6427
6464
|
r.$replyAt.querySelector(".atk-nick").innerText = `${r.opts.replyTo.nick}`;
|
|
6428
6465
|
r.$replyAt.onclick = () => {
|
|
6429
6466
|
r.comment.getActions().goToReplyComment();
|
|
@@ -6614,7 +6651,9 @@ function renderVote(r) {
|
|
|
6614
6651
|
r.comment.getActions().vote("up");
|
|
6615
6652
|
});
|
|
6616
6653
|
if (r.opts.voteDown) {
|
|
6617
|
-
r.voteBtnDown = new ActionBtn(() => `${t("voteDown")} (${r.data.vote_down || 0})`).appendTo(
|
|
6654
|
+
r.voteBtnDown = new ActionBtn(() => `${t("voteDown")} (${r.data.vote_down || 0})`).appendTo(
|
|
6655
|
+
r.$actions
|
|
6656
|
+
);
|
|
6618
6657
|
r.voteBtnDown.setClick(() => {
|
|
6619
6658
|
r.comment.getActions().vote("down");
|
|
6620
6659
|
});
|
|
@@ -6752,20 +6791,23 @@ class Render {
|
|
|
6752
6791
|
return;
|
|
6753
6792
|
const contentMaxH = conf.content;
|
|
6754
6793
|
const childrenMaxH = conf.children;
|
|
6755
|
-
check(
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6794
|
+
check(
|
|
6795
|
+
{
|
|
6796
|
+
postExpandBtnClick: () => {
|
|
6797
|
+
const children = this.comment.getChildren();
|
|
6798
|
+
if (children.length === 1)
|
|
6799
|
+
disposeHeightLimit(children[0].getRender().$content);
|
|
6800
|
+
},
|
|
6801
|
+
scrollable: conf.scrollable
|
|
6760
6802
|
},
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6803
|
+
[
|
|
6804
|
+
// 评论内容限高
|
|
6805
|
+
{ el: this.$content, max: contentMaxH, imgContains: true },
|
|
6806
|
+
{ el: this.$replyTo, max: contentMaxH, imgContains: true },
|
|
6807
|
+
// 子评论区域限高(仅嵌套模式)
|
|
6808
|
+
{ el: this.$childrenWrap, max: childrenMaxH, imgContains: false }
|
|
6809
|
+
]
|
|
6810
|
+
);
|
|
6769
6811
|
}
|
|
6770
6812
|
/** 子评论区域移除限高 */
|
|
6771
6813
|
heightLimitRemoveForChildren() {
|
|
@@ -7484,7 +7526,9 @@ class List extends Component {
|
|
|
7484
7526
|
}
|
|
7485
7527
|
});
|
|
7486
7528
|
this.ctx.on("comment-inserted", (comment) => {
|
|
7487
|
-
|
|
7529
|
+
var _a;
|
|
7530
|
+
const replyComment = comment.rid ? (_a = this.commentNodes.find((c) => c.getID() === comment.rid)) == null ? void 0 : _a.getData() : void 0;
|
|
7531
|
+
this.getListLayout().insert(comment, replyComment);
|
|
7488
7532
|
});
|
|
7489
7533
|
this.ctx.on("comment-deleted", (comment) => {
|
|
7490
7534
|
const node = this.commentNodes.find((c) => c.getID() === comment.id);
|
|
@@ -7515,7 +7559,10 @@ function getScrollbarHelper() {
|
|
|
7515
7559
|
},
|
|
7516
7560
|
lock() {
|
|
7517
7561
|
document.body.style.overflow = "hidden";
|
|
7518
|
-
const barPaddingRight = parseInt(
|
|
7562
|
+
const barPaddingRight = parseInt(
|
|
7563
|
+
window.getComputedStyle(document.body, null).getPropertyValue("padding-right"),
|
|
7564
|
+
10
|
|
7565
|
+
);
|
|
7519
7566
|
document.body.style.paddingRight = `${getScrollBarWidth() + barPaddingRight || 0}px`;
|
|
7520
7567
|
}
|
|
7521
7568
|
};
|
|
@@ -7726,13 +7773,7 @@ const services = {
|
|
|
7726
7773
|
}
|
|
7727
7774
|
};
|
|
7728
7775
|
const PvCountWidget = (ctx) => {
|
|
7729
|
-
ctx.watchConf([
|
|
7730
|
-
"site",
|
|
7731
|
-
"pageKey",
|
|
7732
|
-
"pageTitle",
|
|
7733
|
-
"countEl",
|
|
7734
|
-
"pvEl"
|
|
7735
|
-
], (conf) => {
|
|
7776
|
+
ctx.watchConf(["site", "pageKey", "pageTitle", "countEl", "pvEl"], (conf) => {
|
|
7736
7777
|
initCountWidget({
|
|
7737
7778
|
getApi: () => ctx.getApi(),
|
|
7738
7779
|
siteName: conf.site,
|
|
@@ -7799,7 +7840,9 @@ ${opts.errMsg}`;
|
|
|
7799
7840
|
errEl.appendChild($retryBtn);
|
|
7800
7841
|
}
|
|
7801
7842
|
if (opts.onOpenSidebar) {
|
|
7802
|
-
const $openSidebar = createElement(
|
|
7843
|
+
const $openSidebar = createElement(
|
|
7844
|
+
`<span atk-only-admin-show> | <span style="cursor:pointer;">${t("openName", { name: t("ctrlCenter") })}</span></span>`
|
|
7845
|
+
);
|
|
7803
7846
|
errEl.appendChild($openSidebar);
|
|
7804
7847
|
$openSidebar.onclick = () => opts.onOpenSidebar && opts.onOpenSidebar();
|
|
7805
7848
|
}
|
|
@@ -8142,7 +8185,9 @@ class Closable extends EditorPlug {
|
|
|
8142
8185
|
}
|
|
8143
8186
|
close() {
|
|
8144
8187
|
if (!this.kit.useUI().$textareaWrap.querySelector(".atk-comment-closed"))
|
|
8145
|
-
this.kit.useUI().$textareaWrap.prepend(
|
|
8188
|
+
this.kit.useUI().$textareaWrap.prepend(
|
|
8189
|
+
createElement(`<div class="atk-comment-closed">${t("onlyAdminCanReply")}</div>`)
|
|
8190
|
+
);
|
|
8146
8191
|
if (!this.kit.useUser().getData().isAdmin) {
|
|
8147
8192
|
this.kit.useUI().$textarea.style.display = "none";
|
|
8148
8193
|
this.kit.useEvents().trigger("panel-close");
|
|
@@ -8166,8 +8211,14 @@ class HeaderEvent extends EditorPlug {
|
|
|
8166
8211
|
};
|
|
8167
8212
|
this.kit.useMounted(() => {
|
|
8168
8213
|
Object.entries(this.$inputs).forEach(([key, $input]) => {
|
|
8169
|
-
$input.addEventListener(
|
|
8170
|
-
|
|
8214
|
+
$input.addEventListener(
|
|
8215
|
+
"input",
|
|
8216
|
+
inputEventFns[key] = trigger("header-input", $input, key)
|
|
8217
|
+
);
|
|
8218
|
+
$input.addEventListener(
|
|
8219
|
+
"change",
|
|
8220
|
+
changeEventFns[key] = trigger("header-change", $input, key)
|
|
8221
|
+
);
|
|
8171
8222
|
});
|
|
8172
8223
|
});
|
|
8173
8224
|
this.kit.useUnmounted(() => {
|
|
@@ -8217,9 +8268,12 @@ class HeaderUser extends EditorPlug {
|
|
|
8217
8268
|
const api = this.kit.useApi();
|
|
8218
8269
|
const CANCEL_TOKEN = "getUserCancelToken";
|
|
8219
8270
|
this.query.abortFn = () => api.abortRequest(CANCEL_TOKEN);
|
|
8220
|
-
api.user.getUser(
|
|
8221
|
-
|
|
8222
|
-
|
|
8271
|
+
api.user.getUser(
|
|
8272
|
+
__spreadValues({}, api.getUserFields()),
|
|
8273
|
+
{
|
|
8274
|
+
cancelToken: CANCEL_TOKEN
|
|
8275
|
+
}
|
|
8276
|
+
).then((res) => this.onUserInfoFetched(res.data)).catch((err) => {
|
|
8223
8277
|
}).finally(() => {
|
|
8224
8278
|
this.query.abortFn = null;
|
|
8225
8279
|
});
|
|
@@ -8280,7 +8334,9 @@ class Emoticons extends EditorPlug {
|
|
|
8280
8334
|
__publicField(this, "isImgLoaded", false);
|
|
8281
8335
|
this.kit.useMounted(() => {
|
|
8282
8336
|
this.usePanel(`<div class="atk-editor-plug-emoticons"></div>`);
|
|
8283
|
-
this.useBtn(
|
|
8337
|
+
this.useBtn(
|
|
8338
|
+
`<i aria-label="${t("emoticon")}"><svg fill="currentColor" aria-hidden="true" height="14" viewBox="0 0 14 14" width="14"><path d="m4.26829 5.29294c0-.94317.45893-1.7074 1.02439-1.7074.56547 0 1.02439.76423 1.02439 1.7074s-.45892 1.7074-1.02439 1.7074c-.56546 0-1.02439-.76423-1.02439-1.7074zm4.43903 1.7074c.56546 0 1.02439-.76423 1.02439-1.7074s-.45893-1.7074-1.02439-1.7074c-.56547 0-1.02439.76423-1.02439 1.7074s.45892 1.7074 1.02439 1.7074zm-1.70732 2.73184c-1.51883 0-2.06312-1.52095-2.08361-1.58173l-1.29551.43231c.03414.10244.868 2.51604 3.3798 2.51604 2.51181 0 3.34502-2.41291 3.37982-2.51604l-1.29484-.43573c-.02254.06488-.56683 1.58583-2.08498 1.58583zm7-2.73252c0 3.86004-3.1401 7.00034-7 7.00034s-7-3.1396-7-6.99966c0-3.86009 3.1401-7.00034 7-7.00034s7 3.14025 7 7.00034zm-1.3659 0c0-3.10679-2.5275-5.63442-5.6341-5.63442-3.10663 0-5.63415 2.52832-5.63415 5.6351 0 3.10676 2.52752 5.63446 5.63415 5.63446 3.1066 0 5.6341-2.5277 5.6341-5.63446z"/></svg></i>`
|
|
8339
|
+
);
|
|
8284
8340
|
});
|
|
8285
8341
|
this.kit.useUnmounted(() => {
|
|
8286
8342
|
});
|
|
@@ -8340,19 +8396,21 @@ class Emoticons extends EditorPlug {
|
|
|
8340
8396
|
data.push(grp);
|
|
8341
8397
|
};
|
|
8342
8398
|
const remoteLoad = (d) => __async(this, null, function* () {
|
|
8343
|
-
yield Promise.all(
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8399
|
+
yield Promise.all(
|
|
8400
|
+
d.map((grp, index) => __async(this, null, function* () {
|
|
8401
|
+
if (typeof grp === "object" && !Array.isArray(grp)) {
|
|
8402
|
+
pushGrp(grp);
|
|
8403
|
+
} else if (Array.isArray(grp)) {
|
|
8404
|
+
yield remoteLoad(grp);
|
|
8405
|
+
} else if (typeof grp === "string") {
|
|
8406
|
+
const grpData = yield this.remoteLoad(grp);
|
|
8407
|
+
if (Array.isArray(grpData))
|
|
8408
|
+
yield remoteLoad(grpData);
|
|
8409
|
+
else if (typeof grpData === "object")
|
|
8410
|
+
pushGrp(grpData);
|
|
8411
|
+
}
|
|
8412
|
+
}))
|
|
8413
|
+
);
|
|
8356
8414
|
});
|
|
8357
8415
|
yield remoteLoad(data);
|
|
8358
8416
|
data.forEach((item) => {
|
|
@@ -8367,7 +8425,9 @@ class Emoticons extends EditorPlug {
|
|
|
8367
8425
|
});
|
|
8368
8426
|
}
|
|
8369
8427
|
});
|
|
8370
|
-
data = data.filter(
|
|
8428
|
+
data = data.filter(
|
|
8429
|
+
(item) => typeof item === "object" && !Array.isArray(item) && !!item && !!item.name
|
|
8430
|
+
);
|
|
8371
8431
|
this.solveNullKey(data);
|
|
8372
8432
|
this.solveSameKey(data);
|
|
8373
8433
|
return data;
|
|
@@ -8435,7 +8495,10 @@ class Emoticons extends EditorPlug {
|
|
|
8435
8495
|
if (find && find.length > 1)
|
|
8436
8496
|
item.icon = find[1];
|
|
8437
8497
|
}
|
|
8438
|
-
nGrp.items.push({
|
|
8498
|
+
nGrp.items.push({
|
|
8499
|
+
key: item.text || `${grpName} ${index + 1}`,
|
|
8500
|
+
val: item.icon
|
|
8501
|
+
});
|
|
8439
8502
|
});
|
|
8440
8503
|
dest.push(nGrp);
|
|
8441
8504
|
});
|
|
@@ -8531,7 +8594,9 @@ class Upload extends EditorPlug {
|
|
|
8531
8594
|
this.$imgUploadInput.type = "file";
|
|
8532
8595
|
this.$imgUploadInput.style.display = "none";
|
|
8533
8596
|
this.$imgUploadInput.accept = AllowImgExts.map((o) => `.${o}`).join(",");
|
|
8534
|
-
const $btn = this.useBtn(
|
|
8597
|
+
const $btn = this.useBtn(
|
|
8598
|
+
`<i aria-label="${t("uploadImage")}"><svg fill="currentColor" aria-hidden="true" height="14" viewBox="0 0 14 14" width="14"><path d="m0 1.94444c0-1.074107.870333-1.94444 1.94444-1.94444h10.11116c1.0741 0 1.9444.870333 1.9444 1.94444v10.11116c0 1.0741-.8703 1.9444-1.9444 1.9444h-10.11116c-1.074107 0-1.94444-.8703-1.94444-1.9444zm1.94444-.38888c-.21466 0-.38888.17422-.38888.38888v7.06689l2.33333-2.33333 2.33333 2.33333 3.88888-3.88889 2.3333 2.33334v-5.51134c0-.21466-.1742-.38888-.3888-.38888zm10.49996 8.09977-2.3333-2.33333-3.88888 3.8889-2.33333-2.33334-2.33333 2.33334v.8447c0 .2146.17422.3888.38888.3888h10.11116c.2146 0 .3888-.1742.3888-.3888zm-7.1944-6.54422c-.75133 0-1.36111.60978-1.36111 1.36111 0 .75134.60978 1.36111 1.36111 1.36111s1.36111-.60977 1.36111-1.36111c0-.75133-.60978-1.36111-1.36111-1.36111z"/></svg></i>`
|
|
8599
|
+
);
|
|
8535
8600
|
$btn.after(this.$imgUploadInput);
|
|
8536
8601
|
$btn.onclick = () => {
|
|
8537
8602
|
const $input = this.$imgUploadInput;
|
|
@@ -8592,7 +8657,7 @@ class Upload extends EditorPlug {
|
|
|
8592
8657
|
uploadImg(file) {
|
|
8593
8658
|
return __async(this, null, function* () {
|
|
8594
8659
|
const fileExt = /[^.]+$/.exec(file.name);
|
|
8595
|
-
if (!fileExt || !AllowImgExts.includes(fileExt[0]))
|
|
8660
|
+
if (!fileExt || !AllowImgExts.includes(String(fileExt[0]).toLowerCase()))
|
|
8596
8661
|
return;
|
|
8597
8662
|
if (!this.kit.useUser().checkHasBasicUserInfo()) {
|
|
8598
8663
|
this.kit.useEditor().showNotify(t("uploadLoginMsg"), "w");
|
|
@@ -8622,7 +8687,9 @@ class Upload extends EditorPlug {
|
|
|
8622
8687
|
base: this.kit.useConf().server,
|
|
8623
8688
|
path: imgURL
|
|
8624
8689
|
});
|
|
8625
|
-
this.kit.useEditor().setContent(
|
|
8690
|
+
this.kit.useEditor().setContent(
|
|
8691
|
+
this.kit.useUI().$textarea.value.replace(uploadPlaceholderTxt, `${insertPrefix}`)
|
|
8692
|
+
);
|
|
8626
8693
|
} else {
|
|
8627
8694
|
this.kit.useEditor().setContent(this.kit.useUI().$textarea.value.replace(uploadPlaceholderTxt, ""));
|
|
8628
8695
|
}
|
|
@@ -8635,7 +8702,9 @@ class Preview extends EditorPlug {
|
|
|
8635
8702
|
__publicField(this, "isPlugPanelShow", false);
|
|
8636
8703
|
this.kit.useMounted(() => {
|
|
8637
8704
|
this.usePanel(`<div class="atk-editor-plug-preview"></div>`);
|
|
8638
|
-
this.useBtn(
|
|
8705
|
+
this.useBtn(
|
|
8706
|
+
`<i aria-label="${t("preview")}"><svg fill="currentColor" aria-hidden="true" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M14.85 3H1.15C.52 3 0 3.52 0 4.15v7.69C0 12.48.52 13 1.15 13h13.69c.64 0 1.15-.52 1.15-1.15v-7.7C16 3.52 15.48 3 14.85 3zM9 11H7V8L5.5 9.92 4 8v3H2V5h2l1.5 2L7 5h2v6zm2.99.5L9.5 8H11V5h2v3h1.5l-2.51 3.5z"></path></svg></i>`
|
|
8707
|
+
);
|
|
8639
8708
|
});
|
|
8640
8709
|
this.kit.useUnmounted(() => {
|
|
8641
8710
|
});
|
|
@@ -8741,23 +8810,20 @@ class PlugManager {
|
|
|
8741
8810
|
__publicField(this, "events", new EventManager());
|
|
8742
8811
|
this.editor = editor;
|
|
8743
8812
|
let confLoaded = false;
|
|
8744
|
-
this.editor.ctx.watchConf(
|
|
8745
|
-
"imgUpload",
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
this.
|
|
8756
|
-
}
|
|
8757
|
-
|
|
8758
|
-
confLoaded = true;
|
|
8759
|
-
this.loadPluginUI();
|
|
8760
|
-
});
|
|
8813
|
+
this.editor.ctx.watchConf(
|
|
8814
|
+
["imgUpload", "emoticons", "preview", "editorTravel", "locale"],
|
|
8815
|
+
(conf) => {
|
|
8816
|
+
confLoaded && this.getEvents().trigger("unmounted");
|
|
8817
|
+
this.clear();
|
|
8818
|
+
getEnabledPlugs(conf).forEach((Plug) => {
|
|
8819
|
+
const kit = new PlugKit(this);
|
|
8820
|
+
this.plugs.push(new Plug(kit));
|
|
8821
|
+
});
|
|
8822
|
+
this.getEvents().trigger("mounted");
|
|
8823
|
+
confLoaded = true;
|
|
8824
|
+
this.loadPluginUI();
|
|
8825
|
+
}
|
|
8826
|
+
);
|
|
8761
8827
|
this.events.on("panel-close", () => this.closePlugPanel());
|
|
8762
8828
|
}
|
|
8763
8829
|
getPlugs() {
|
|
@@ -8896,7 +8962,9 @@ const Unread = (ctx) => {
|
|
|
8896
8962
|
const notifyKey = getQueryParam("atk_notify_key");
|
|
8897
8963
|
if (notifyKey) {
|
|
8898
8964
|
ctx.getApi().notifies.markNotifyRead(commentID, notifyKey).then(() => {
|
|
8899
|
-
ctx.getData().updateNotifies(
|
|
8965
|
+
ctx.getData().updateNotifies(
|
|
8966
|
+
ctx.getData().getNotifies().filter((o) => o.comment_id !== commentID)
|
|
8967
|
+
);
|
|
8900
8968
|
});
|
|
8901
8969
|
}
|
|
8902
8970
|
});
|
|
@@ -8908,7 +8976,11 @@ const Count = (ctx) => {
|
|
|
8908
8976
|
const $count = list2.$el.querySelector(".atk-comment-count .atk-text");
|
|
8909
8977
|
if (!$count)
|
|
8910
8978
|
return;
|
|
8911
|
-
const text = htmlEncode(
|
|
8979
|
+
const text = htmlEncode(
|
|
8980
|
+
t("counter", {
|
|
8981
|
+
count: `${Number((_b = (_a = ctx.getData().getListLastFetch()) == null ? void 0 : _a.data) == null ? void 0 : _b.count) || 0}`
|
|
8982
|
+
})
|
|
8983
|
+
);
|
|
8912
8984
|
$count.innerHTML = text.replace(/(\d+)/, '<span class="atk-comment-count-num">$1</span>');
|
|
8913
8985
|
};
|
|
8914
8986
|
ctx.on("list-loaded", () => {
|
|
@@ -9017,7 +9089,7 @@ const GotoFocus = (ctx) => {
|
|
|
9017
9089
|
comment.focus();
|
|
9018
9090
|
}));
|
|
9019
9091
|
};
|
|
9020
|
-
const version = "2.8.
|
|
9092
|
+
const version = "2.8.5";
|
|
9021
9093
|
const Copyright = (ctx) => {
|
|
9022
9094
|
ctx.on("mounted", () => {
|
|
9023
9095
|
const list2 = ctx.get("list");
|
|
@@ -9052,26 +9124,38 @@ const Dropdown = (ctx) => {
|
|
|
9052
9124
|
renderDropdown({
|
|
9053
9125
|
$dropdownWrap: $dropdownOn,
|
|
9054
9126
|
dropdownList: [
|
|
9055
|
-
[
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9127
|
+
[
|
|
9128
|
+
t("sortLatest"),
|
|
9129
|
+
() => {
|
|
9130
|
+
reloadUseParamsEditor((p) => {
|
|
9131
|
+
p.sort_by = "date_desc";
|
|
9132
|
+
});
|
|
9133
|
+
}
|
|
9134
|
+
],
|
|
9135
|
+
[
|
|
9136
|
+
t("sortBest"),
|
|
9137
|
+
() => {
|
|
9138
|
+
reloadUseParamsEditor((p) => {
|
|
9139
|
+
p.sort_by = "vote";
|
|
9140
|
+
});
|
|
9141
|
+
}
|
|
9142
|
+
],
|
|
9143
|
+
[
|
|
9144
|
+
t("sortOldest"),
|
|
9145
|
+
() => {
|
|
9146
|
+
reloadUseParamsEditor((p) => {
|
|
9147
|
+
p.sort_by = "date_asc";
|
|
9148
|
+
});
|
|
9149
|
+
}
|
|
9150
|
+
],
|
|
9151
|
+
[
|
|
9152
|
+
t("sortAuthor"),
|
|
9153
|
+
() => {
|
|
9154
|
+
reloadUseParamsEditor((p) => {
|
|
9155
|
+
p.view_only_admin = true;
|
|
9156
|
+
});
|
|
9157
|
+
}
|
|
9158
|
+
]
|
|
9075
9159
|
]
|
|
9076
9160
|
});
|
|
9077
9161
|
};
|
|
@@ -9220,18 +9304,21 @@ const ReachBottom = (ctx) => {
|
|
|
9220
9304
|
let observer = null;
|
|
9221
9305
|
const setupObserver = ($target) => {
|
|
9222
9306
|
const scrollEvtAt = ctx.conf.scrollRelativeTo && ctx.conf.scrollRelativeTo() || null;
|
|
9223
|
-
observer = new IntersectionObserver(
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
|
|
9307
|
+
observer = new IntersectionObserver(
|
|
9308
|
+
([entries]) => {
|
|
9309
|
+
if (entries.isIntersecting) {
|
|
9310
|
+
clearObserver();
|
|
9311
|
+
ctx.trigger("list-reach-bottom");
|
|
9312
|
+
}
|
|
9313
|
+
},
|
|
9314
|
+
{
|
|
9315
|
+
threshold: 0.9,
|
|
9316
|
+
// when the target is 90% visible
|
|
9317
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/root
|
|
9318
|
+
// If the root is null, then the bounds of the actual document viewport are used.
|
|
9319
|
+
root: scrollEvtAt
|
|
9227
9320
|
}
|
|
9228
|
-
|
|
9229
|
-
threshold: 0.9,
|
|
9230
|
-
// when the target is 90% visible
|
|
9231
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/root
|
|
9232
|
-
// If the root is null, then the bounds of the actual document viewport are used.
|
|
9233
|
-
root: scrollEvtAt
|
|
9234
|
-
});
|
|
9321
|
+
);
|
|
9235
9322
|
observer.observe($target);
|
|
9236
9323
|
};
|
|
9237
9324
|
const clearObserver = () => {
|
|
@@ -9315,22 +9402,26 @@ function versionCheck(list2, feVer, beVer) {
|
|
|
9315
9402
|
if (sameVer)
|
|
9316
9403
|
return;
|
|
9317
9404
|
const errEl = createElement(
|
|
9318
|
-
`<div
|
|
9405
|
+
`<div class="atk-version-check-notice">${t("updateMsg", {
|
|
9406
|
+
name: comp < 0 ? t("frontend") : t("backend")
|
|
9407
|
+
})} <span class="atk-info">${t("currentVersion")}: ${t("frontend")} ${feVer} / ${t("backend")} ${beVer}</span></div>`
|
|
9319
9408
|
);
|
|
9320
|
-
const ignoreBtn = createElement(`<span
|
|
9409
|
+
const ignoreBtn = createElement(`<span class="atk-ignore-btn">${t("ignore")}</span>`);
|
|
9321
9410
|
ignoreBtn.onclick = () => {
|
|
9322
|
-
|
|
9411
|
+
errEl.remove();
|
|
9323
9412
|
IgnoreVersionCheck = true;
|
|
9324
|
-
list2.ctx.fetch({ offset: 0 });
|
|
9325
9413
|
};
|
|
9326
9414
|
errEl.append(ignoreBtn);
|
|
9327
|
-
|
|
9415
|
+
list2.$el.parentElement.prepend(errEl);
|
|
9328
9416
|
}
|
|
9329
9417
|
const AdminOnlyElem = (ctx) => {
|
|
9330
9418
|
const scanApply = () => {
|
|
9331
|
-
applyAdminOnlyEls(
|
|
9332
|
-
|
|
9333
|
-
|
|
9419
|
+
applyAdminOnlyEls(
|
|
9420
|
+
ctx.get("user").getData().isAdmin,
|
|
9421
|
+
getAdminOnlyEls({
|
|
9422
|
+
$root: ctx.$root
|
|
9423
|
+
})
|
|
9424
|
+
);
|
|
9334
9425
|
};
|
|
9335
9426
|
ctx.on("list-loaded", () => {
|
|
9336
9427
|
scanApply();
|
|
@@ -9427,7 +9518,9 @@ function load(ctx) {
|
|
|
9427
9518
|
};
|
|
9428
9519
|
if (ctx.conf.useBackendConf) {
|
|
9429
9520
|
if (!data.frontend_conf)
|
|
9430
|
-
throw new Error(
|
|
9521
|
+
throw new Error(
|
|
9522
|
+
"The remote backend does not respond to the frontend conf, but `useBackendConf` conf is enabled"
|
|
9523
|
+
);
|
|
9431
9524
|
conf = __spreadValues(__spreadValues({}, conf), handleConfFormServer(data.frontend_conf));
|
|
9432
9525
|
}
|
|
9433
9526
|
ctx.conf.remoteConfModifier && ctx.conf.remoteConfModifier(conf);
|
|
@@ -9452,17 +9545,19 @@ function loadNetworkPlugins(scripts, apiBase) {
|
|
|
9452
9545
|
scripts.forEach((url) => {
|
|
9453
9546
|
if (!/^(http|https):\/\//.test(url))
|
|
9454
9547
|
url = `${apiBase.replace(/\/$/, "")}/${url.replace(/^\//, "")}`;
|
|
9455
|
-
tasks.push(
|
|
9456
|
-
|
|
9457
|
-
|
|
9458
|
-
|
|
9459
|
-
|
|
9460
|
-
|
|
9461
|
-
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9548
|
+
tasks.push(
|
|
9549
|
+
new Promise((resolve, reject) => {
|
|
9550
|
+
if (document.querySelector(`script[src="${url}"]`)) {
|
|
9551
|
+
resolve();
|
|
9552
|
+
return;
|
|
9553
|
+
}
|
|
9554
|
+
const script = document.createElement("script");
|
|
9555
|
+
script.src = url;
|
|
9556
|
+
document.head.appendChild(script);
|
|
9557
|
+
script.onload = () => resolve();
|
|
9558
|
+
script.onerror = (err) => reject(err);
|
|
9559
|
+
})
|
|
9560
|
+
);
|
|
9466
9561
|
});
|
|
9467
9562
|
yield Promise.all(tasks);
|
|
9468
9563
|
return Object.values(window.ArtalkPlugins || {});
|
|
@@ -9472,7 +9567,10 @@ function onLoadErr(ctx, err) {
|
|
|
9472
9567
|
var _a;
|
|
9473
9568
|
let sidebarOpenView = "";
|
|
9474
9569
|
if ((_a = err.data) == null ? void 0 : _a.err_no_site) {
|
|
9475
|
-
const viewLoadParam = {
|
|
9570
|
+
const viewLoadParam = {
|
|
9571
|
+
create_name: ctx.conf.site,
|
|
9572
|
+
create_urls: `${window.location.protocol}//${window.location.host}`
|
|
9573
|
+
};
|
|
9476
9574
|
sidebarOpenView = `sites|${JSON.stringify(viewLoadParam)}`;
|
|
9477
9575
|
}
|
|
9478
9576
|
showErrorDialog({
|
|
@@ -9495,7 +9593,9 @@ class Artalk {
|
|
|
9495
9593
|
const obj = initService(this.ctx);
|
|
9496
9594
|
obj && this.ctx.inject(name, obj);
|
|
9497
9595
|
});
|
|
9498
|
-
|
|
9596
|
+
{
|
|
9597
|
+
load(this.ctx);
|
|
9598
|
+
}
|
|
9499
9599
|
}
|
|
9500
9600
|
/** Get the config of Artalk */
|
|
9501
9601
|
getConf() {
|
|
@@ -9517,7 +9617,9 @@ class Artalk {
|
|
|
9517
9617
|
/** Destroy instance of Artalk */
|
|
9518
9618
|
destroy() {
|
|
9519
9619
|
this.ctx.trigger("unmounted");
|
|
9520
|
-
this.ctx.$root.
|
|
9620
|
+
while (this.ctx.$root.firstChild) {
|
|
9621
|
+
this.ctx.$root.removeChild(this.ctx.$root.firstChild);
|
|
9622
|
+
}
|
|
9521
9623
|
}
|
|
9522
9624
|
/** Add an event listener */
|
|
9523
9625
|
on(name, handler) {
|