artalk 2.7.1 → 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.
- package/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/Artalk.cjs +2 -0
- package/dist/Artalk.cjs.map +1 -0
- package/dist/Artalk.css +1 -1
- package/dist/Artalk.iife.js +1 -1
- package/dist/Artalk.iife.js.map +1 -1
- package/dist/Artalk.js +1 -1
- package/dist/Artalk.js.map +1 -1
- package/dist/{Artalk.es.js → Artalk.mjs} +250 -222
- package/dist/Artalk.mjs.map +1 -0
- package/dist/ArtalkLite.cjs +2 -0
- package/dist/ArtalkLite.cjs.map +1 -0
- 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.es.js → ArtalkLite.mjs} +250 -227
- package/dist/ArtalkLite.mjs.map +1 -0
- package/dist/i18n/jp.cjs +1 -0
- package/dist/i18n/jp.d.cts +3 -0
- package/dist/i18n/jp.d.ts +3 -0
- package/dist/i18n/jp.js +1 -1
- package/dist/i18n/jp.mjs +93 -0
- package/dist/i18n/zh-TW.cjs +1 -0
- package/dist/i18n/zh-TW.d.cts +3 -0
- package/dist/i18n/zh-TW.d.ts +3 -0
- package/dist/i18n/zh-TW.js +1 -1
- package/dist/i18n/zh-TW.mjs +93 -0
- package/dist/main.d.cts +1476 -0
- package/dist/main.d.ts +1476 -0
- package/package.json +80 -22
- package/dist/Artalk.es.js.map +0 -1
- package/dist/ArtalkLite.es.js.map +0 -1
- package/dist/src/api/_base.d.ts +0 -10
- package/dist/src/api/_options.d.ts +0 -19
- package/dist/src/api/_request.d.ts +0 -12
- package/dist/src/api/admin.d.ts +0 -10
- package/dist/src/api/captcha.d.ts +0 -14
- package/dist/src/api/comment.d.ts +0 -29
- package/dist/src/api/index.d.ts +0 -29
- package/dist/src/api/page.d.ts +0 -22
- package/dist/src/api/site.d.ts +0 -17
- package/dist/src/api/system.d.ts +0 -33
- package/dist/src/api/upload.d.ts +0 -11
- package/dist/src/api/user.d.ts +0 -42
- package/dist/src/artalk.d.ts +0 -35
- package/dist/src/comment/actions.d.ts +0 -17
- package/dist/src/comment/comment.d.ts +0 -66
- package/dist/src/comment/height-limit.d.ts +0 -30
- package/dist/src/comment/index.d.ts +0 -2
- package/dist/src/comment/render.d.ts +0 -46
- package/dist/src/comment/renders/actions.d.ts +0 -5
- package/dist/src/comment/renders/avatar.d.ts +0 -5
- package/dist/src/comment/renders/content.d.ts +0 -5
- package/dist/src/comment/renders/header.d.ts +0 -5
- package/dist/src/comment/renders/index.d.ts +0 -2
- package/dist/src/comment/renders/pending.d.ts +0 -5
- package/dist/src/comment/renders/reply-at.d.ts +0 -5
- package/dist/src/comment/renders/reply-to.d.ts +0 -5
- package/dist/src/components/action-btn.d.ts +0 -50
- package/dist/src/components/checker/admin.d.ts +0 -3
- package/dist/src/components/checker/captcha-renders.d.ts +0 -5
- package/dist/src/components/checker/captcha.d.ts +0 -3
- package/dist/src/components/checker/index.d.ts +0 -51
- package/dist/src/components/dark-mode.d.ts +0 -2
- package/dist/src/components/dialog.d.ts +0 -16
- package/dist/src/components/error-dialog.d.ts +0 -8
- package/dist/src/components/pagination.d.ts +0 -31
- package/dist/src/components/read-more-btn.d.ts +0 -33
- package/dist/src/config.d.ts +0 -24
- package/dist/src/context.d.ts +0 -45
- package/dist/src/data.d.ts +0 -27
- package/dist/src/defaults.d.ts +0 -3
- package/dist/src/editor/editor.d.ts +0 -31
- package/dist/src/editor/state.d.ts +0 -20
- package/dist/src/editor/ui.d.ts +0 -25
- package/dist/src/i18n/en.d.ts +0 -72
- package/dist/src/i18n/external.d.ts +0 -73
- package/dist/src/i18n/index.d.ts +0 -233
- package/dist/src/i18n/jp.d.ts +0 -72
- package/dist/src/i18n/zh-CN.d.ts +0 -3
- package/dist/src/i18n/zh-TW.d.ts +0 -72
- package/dist/src/layer/index.d.ts +0 -4
- package/dist/src/layer/layer-manager.d.ts +0 -9
- package/dist/src/layer/layer.d.ts +0 -12
- package/dist/src/layer/scrollbar-helper.d.ts +0 -5
- package/dist/src/layer/sidebar-layer.d.ts +0 -20
- package/dist/src/layer/wrap.d.ts +0 -13
- package/dist/src/lib/component.d.ts +0 -7
- package/dist/src/lib/detect.d.ts +0 -10
- package/dist/src/lib/event-manager.d.ts +0 -28
- package/dist/src/lib/highlight.d.ts +0 -1
- package/dist/src/lib/marked-renderer.d.ts +0 -4
- package/dist/src/lib/marked.d.ts +0 -11
- package/dist/src/lib/sanitizer.d.ts +0 -1
- package/dist/src/lib/ui.d.ts +0 -24
- package/dist/src/lib/user.d.ts +0 -19
- package/dist/src/lib/utils.d.ts +0 -41
- package/dist/src/list/comment.d.ts +0 -3
- package/dist/src/list/layout.d.ts +0 -23
- package/dist/src/list/list.d.ts +0 -14
- package/dist/src/list/nest.d.ts +0 -10
- package/dist/src/list/page.d.ts +0 -2
- package/dist/src/list/paginator/index.d.ts +0 -25
- package/dist/src/list/paginator/read-more.d.ts +0 -18
- package/dist/src/list/paginator/up-down.d.ts +0 -14
- package/dist/src/main.d.ts +0 -7
- package/dist/src/plugins/admin-only-elem.d.ts +0 -2
- package/dist/src/plugins/conf-remoter.d.ts +0 -2
- package/dist/src/plugins/dark-mode.d.ts +0 -2
- package/dist/src/plugins/editor/_kit.d.ts +0 -27
- package/dist/src/plugins/editor/_plug.d.ts +0 -29
- package/dist/src/plugins/editor/_sample.d.ts +0 -5
- package/dist/src/plugins/editor/closable.d.ts +0 -7
- package/dist/src/plugins/editor/emoticons.d.ts +0 -30
- package/dist/src/plugins/editor/header-event.d.ts +0 -6
- package/dist/src/plugins/editor/header-link.d.ts +0 -6
- package/dist/src/plugins/editor/header-user.d.ts +0 -16
- package/dist/src/plugins/editor/index.d.ts +0 -6
- package/dist/src/plugins/editor/local-storage.d.ts +0 -6
- package/dist/src/plugins/editor/mover.d.ts +0 -6
- package/dist/src/plugins/editor/preview.d.ts +0 -7
- package/dist/src/plugins/editor/state-edit.d.ts +0 -11
- package/dist/src/plugins/editor/state-reply.d.ts +0 -8
- package/dist/src/plugins/editor/submit-add.d.ts +0 -18
- package/dist/src/plugins/editor/submit-btn.d.ts +0 -5
- package/dist/src/plugins/editor/submit.d.ts +0 -17
- package/dist/src/plugins/editor/textarea.d.ts +0 -8
- package/dist/src/plugins/editor/upload.d.ts +0 -9
- package/dist/src/plugins/editor-kit.d.ts +0 -42
- package/dist/src/plugins/index.d.ts +0 -2
- package/dist/src/plugins/list/copyright.d.ts +0 -2
- package/dist/src/plugins/list/count.d.ts +0 -2
- package/dist/src/plugins/list/dropdown.d.ts +0 -2
- package/dist/src/plugins/list/error-dialog.d.ts +0 -2
- package/dist/src/plugins/list/fetch.d.ts +0 -2
- package/dist/src/plugins/list/goto-first.d.ts +0 -3
- package/dist/src/plugins/list/goto.d.ts +0 -2
- package/dist/src/plugins/list/index.d.ts +0 -3
- package/dist/src/plugins/list/loading.d.ts +0 -2
- package/dist/src/plugins/list/no-comment.d.ts +0 -2
- package/dist/src/plugins/list/reach-bottom.d.ts +0 -2
- package/dist/src/plugins/list/sidebar-btn.d.ts +0 -2
- package/dist/src/plugins/list/time-ticking.d.ts +0 -3
- package/dist/src/plugins/list/unread-badge.d.ts +0 -2
- package/dist/src/plugins/list/unread.d.ts +0 -2
- package/dist/src/plugins/list/with-editor.d.ts +0 -2
- package/dist/src/plugins/markdown.d.ts +0 -2
- package/dist/src/plugins/stat.d.ts +0 -13
- package/dist/src/plugins/version-check.d.ts +0 -2
- package/dist/src/service.d.ts +0 -42
- package/dist/tests/e2e/comment-add.spec.d.ts +0 -1
- package/dist/types/config.d.ts +0 -110
- package/dist/types/context.d.ts +0 -62
- package/dist/types/data.d.ts +0 -194
- package/dist/types/editor.d.ts +0 -76
- package/dist/types/event.d.ts +0 -39
- package/dist/types/global.d.ts +0 -1
- package/dist/types/index.d.ts +0 -7
- package/dist/types/plugin.d.ts +0 -2
- package/dist/types/sidebar.d.ts +0 -3
- package/src/api/_base.ts +0 -18
- package/src/api/_options.ts +0 -25
- package/src/api/_request.ts +0 -104
- package/src/api/admin.ts +0 -18
- package/src/api/captcha.ts +0 -24
- package/src/api/comment.ts +0 -84
- package/src/api/index.ts +0 -29
- package/src/api/page.ts +0 -83
- package/src/api/site.ts +0 -51
- package/src/api/system.ts +0 -49
- package/src/api/upload.ts +0 -28
- package/src/api/user.ts +0 -132
- package/src/artalk.ts +0 -115
- package/src/comment/actions.ts +0 -83
- package/src/comment/comment.html +0 -18
- package/src/comment/comment.ts +0 -192
- package/src/comment/height-limit.ts +0 -100
- package/src/comment/index.ts +0 -3
- package/src/comment/render.ts +0 -150
- package/src/comment/renders/actions.ts +0 -114
- package/src/comment/renders/avatar.ts +0 -22
- package/src/comment/renders/content.ts +0 -39
- package/src/comment/renders/header.ts +0 -84
- package/src/comment/renders/index.ts +0 -19
- package/src/comment/renders/pending.ts +0 -12
- package/src/comment/renders/reply-at.ts +0 -16
- package/src/comment/renders/reply-to.ts +0 -24
- package/src/components/action-btn.ts +0 -170
- package/src/components/checker/admin.ts +0 -37
- package/src/components/checker/captcha-renders.ts +0 -69
- package/src/components/checker/captcha.ts +0 -26
- package/src/components/checker/index.ts +0 -192
- package/src/components/dark-mode.ts +0 -30
- package/src/components/dialog.ts +0 -62
- package/src/components/error-dialog.ts +0 -35
- package/src/components/pagination.ts +0 -153
- package/src/components/read-more-btn.ts +0 -92
- package/src/config.ts +0 -119
- package/src/context.ts +0 -146
- package/src/data.ts +0 -110
- package/src/defaults.ts +0 -61
- package/src/editor/editor.html +0 -18
- package/src/editor/editor.ts +0 -114
- package/src/editor/state.ts +0 -52
- package/src/editor/ui.ts +0 -36
- package/src/i18n/en.ts +0 -84
- package/src/i18n/external.ts +0 -10
- package/src/i18n/index.ts +0 -67
- package/src/i18n/jp.ts +0 -86
- package/src/i18n/zh-CN.ts +0 -88
- package/src/i18n/zh-TW.ts +0 -86
- package/src/layer/index.ts +0 -4
- package/src/layer/layer-manager.ts +0 -32
- package/src/layer/layer.ts +0 -39
- package/src/layer/scrollbar-helper.ts +0 -24
- package/src/layer/sidebar-layer.html +0 -8
- package/src/layer/sidebar-layer.ts +0 -155
- package/src/layer/wrap.ts +0 -77
- package/src/lib/component.ts +0 -12
- package/src/lib/detect.ts +0 -222
- package/src/lib/event-manager.ts +0 -47
- package/src/lib/highlight.ts +0 -5
- package/src/lib/marked-renderer.ts +0 -32
- package/src/lib/marked.ts +0 -72
- package/src/lib/sanitizer.ts +0 -57
- package/src/lib/ui.ts +0 -193
- package/src/lib/user.ts +0 -55
- package/src/lib/utils.ts +0 -236
- package/src/list/comment.ts +0 -20
- package/src/list/layout.ts +0 -120
- package/src/list/list.html +0 -20
- package/src/list/list.ts +0 -79
- package/src/list/nest.ts +0 -66
- package/src/list/page.ts +0 -97
- package/src/list/paginator/index.ts +0 -25
- package/src/list/paginator/read-more.ts +0 -67
- package/src/list/paginator/up-down.ts +0 -51
- package/src/main.ts +0 -14
- package/src/plugins/admin-only-elem.ts +0 -40
- package/src/plugins/conf-remoter.ts +0 -54
- package/src/plugins/dark-mode.ts +0 -12
- package/src/plugins/editor/_kit.ts +0 -57
- package/src/plugins/editor/_plug.ts +0 -60
- package/src/plugins/editor/_sample.ts +0 -8
- package/src/plugins/editor/closable.ts +0 -44
- package/src/plugins/editor/emoticons.scss +0 -72
- package/src/plugins/editor/emoticons.ts +0 -293
- package/src/plugins/editor/header-event.ts +0 -35
- package/src/plugins/editor/header-link.ts +0 -31
- package/src/plugins/editor/header-user.ts +0 -98
- package/src/plugins/editor/index.ts +0 -40
- package/src/plugins/editor/local-storage.ts +0 -36
- package/src/plugins/editor/mover.ts +0 -29
- package/src/plugins/editor/preview.scss +0 -7
- package/src/plugins/editor/preview.ts +0 -41
- package/src/plugins/editor/state-edit.ts +0 -116
- package/src/plugins/editor/state-reply.ts +0 -91
- package/src/plugins/editor/submit-add.ts +0 -33
- package/src/plugins/editor/submit-btn.ts +0 -25
- package/src/plugins/editor/submit.ts +0 -73
- package/src/plugins/editor/textarea.ts +0 -55
- package/src/plugins/editor/upload.ts +0 -145
- package/src/plugins/editor-kit.ts +0 -161
- package/src/plugins/index.ts +0 -16
- package/src/plugins/list/copyright.ts +0 -16
- package/src/plugins/list/count.ts +0 -31
- package/src/plugins/list/dropdown.ts +0 -95
- package/src/plugins/list/error-dialog.ts +0 -22
- package/src/plugins/list/fetch.ts +0 -64
- package/src/plugins/list/goto-first.ts +0 -23
- package/src/plugins/list/goto.ts +0 -72
- package/src/plugins/list/index.ts +0 -25
- package/src/plugins/list/loading.ts +0 -17
- package/src/plugins/list/no-comment.ts +0 -25
- package/src/plugins/list/reach-bottom.ts +0 -46
- package/src/plugins/list/sidebar-btn.ts +0 -39
- package/src/plugins/list/time-ticking.ts +0 -22
- package/src/plugins/list/unread-badge.ts +0 -26
- package/src/plugins/list/unread.ts +0 -38
- package/src/plugins/list/with-editor.ts +0 -59
- package/src/plugins/markdown.ts +0 -10
- package/src/plugins/stat.ts +0 -82
- package/src/plugins/version-check.ts +0 -36
- package/src/service.ts +0 -91
- package/src/style/_color.scss +0 -41
- package/src/style/_extend.scss +0 -20
- package/src/style/_variables.scss +0 -3
- package/src/style/comment.scss +0 -360
- package/src/style/editor.scss +0 -194
- package/src/style/list.scss +0 -212
- package/src/style/main.scss +0 -486
- package/src/style/pagination.scss +0 -58
- package/src/style/sidebar-layer.scss +0 -92
- package/types/config.ts +0 -153
- package/types/context.ts +0 -84
- package/types/data.ts +0 -271
- package/types/editor.ts +0 -95
- package/types/event.ts +0 -40
- package/types/global.d.ts +0 -1
- package/types/index.ts +0 -7
- package/types/plugin.ts +0 -3
- package/types/sidebar.ts +0 -3
|
@@ -55,7 +55,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
57
|
var _parseMarkdown, parseMarkdown_fn, _onError, onError_fn;
|
|
58
|
-
const main = "";
|
|
59
58
|
function createElement(htmlStr = "") {
|
|
60
59
|
const div = document.createElement("div");
|
|
61
60
|
div.innerHTML = htmlStr.trim();
|
|
@@ -224,24 +223,6 @@ function getURLBasedOnApi(opts) {
|
|
|
224
223
|
function getURLBasedOn(baseURL, path) {
|
|
225
224
|
return `${baseURL.replace(/\/$/, "")}/${path.replace(/^\//, "")}`;
|
|
226
225
|
}
|
|
227
|
-
function mergeDeep(target, source) {
|
|
228
|
-
const isObject = (obj) => obj && typeof obj === "object";
|
|
229
|
-
if (!isObject(target) || !isObject(source)) {
|
|
230
|
-
return source;
|
|
231
|
-
}
|
|
232
|
-
Object.keys(source).forEach((key) => {
|
|
233
|
-
const targetValue = target[key];
|
|
234
|
-
const sourceValue = source[key];
|
|
235
|
-
if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
|
|
236
|
-
target[key] = targetValue.concat(sourceValue);
|
|
237
|
-
} else if (isObject(targetValue) && isObject(sourceValue)) {
|
|
238
|
-
target[key] = mergeDeep(__spreadValues({}, targetValue), sourceValue);
|
|
239
|
-
} else {
|
|
240
|
-
target[key] = sourceValue;
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
return target;
|
|
244
|
-
}
|
|
245
226
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
246
227
|
function getDefaultExportFromCjs(x) {
|
|
247
228
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -642,48 +623,6 @@ function getDefaultExportFromCjs(x) {
|
|
|
642
623
|
});
|
|
643
624
|
})(typeof self !== "undefined" ? self : commonjsGlobal);
|
|
644
625
|
});
|
|
645
|
-
const LOCAL_USER_KEY = "ArtalkUser";
|
|
646
|
-
class User {
|
|
647
|
-
constructor() {
|
|
648
|
-
__publicField(this, "data");
|
|
649
|
-
__publicField(this, "onUserChanged", null);
|
|
650
|
-
const localUser = JSON.parse(window.localStorage.getItem(LOCAL_USER_KEY) || "{}");
|
|
651
|
-
this.data = {
|
|
652
|
-
nick: localUser.nick || "",
|
|
653
|
-
email: localUser.email || "",
|
|
654
|
-
link: localUser.link || "",
|
|
655
|
-
token: localUser.token || "",
|
|
656
|
-
isAdmin: localUser.isAdmin || false
|
|
657
|
-
};
|
|
658
|
-
}
|
|
659
|
-
/** 保存用户到 localStorage 中 */
|
|
660
|
-
update(obj = {}) {
|
|
661
|
-
Object.entries(obj).forEach(([key, value]) => {
|
|
662
|
-
this.data[key] = value;
|
|
663
|
-
});
|
|
664
|
-
window.localStorage.setItem(LOCAL_USER_KEY, JSON.stringify(this.data));
|
|
665
|
-
this.onUserChanged && this.onUserChanged(this.data);
|
|
666
|
-
}
|
|
667
|
-
setOnUserChanged(fn) {
|
|
668
|
-
this.onUserChanged = fn;
|
|
669
|
-
}
|
|
670
|
-
/**
|
|
671
|
-
* Logout
|
|
672
|
-
*
|
|
673
|
-
* @description Logout will clear login status, but not clear user data (nick, email, link)
|
|
674
|
-
*/
|
|
675
|
-
logout() {
|
|
676
|
-
this.update({
|
|
677
|
-
token: "",
|
|
678
|
-
isAdmin: false
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
/** 是否已填写基本用户信息 */
|
|
682
|
-
checkHasBasicUserInfo() {
|
|
683
|
-
return !!this.data.nick && !!this.data.email;
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
const UserInstance = new User();
|
|
687
626
|
const en = {
|
|
688
627
|
/* Editor */
|
|
689
628
|
placeholder: "Leave a comment",
|
|
@@ -760,7 +699,8 @@ const en = {
|
|
|
760
699
|
reqAborted: "Request timed out or terminated unexpectedly",
|
|
761
700
|
updateMsg: "Please update Artalk {name} to get the full experience",
|
|
762
701
|
currentVersion: "Current Version",
|
|
763
|
-
ignore: "Ignore"
|
|
702
|
+
ignore: "Ignore",
|
|
703
|
+
open: "Open"
|
|
764
704
|
};
|
|
765
705
|
const zhCN = {
|
|
766
706
|
/* Editor */
|
|
@@ -838,7 +778,8 @@ const zhCN = {
|
|
|
838
778
|
reqAborted: "请求超时或意外终止",
|
|
839
779
|
updateMsg: "请更新 Artalk {name} 以获得完整体验",
|
|
840
780
|
currentVersion: "当前版本",
|
|
841
|
-
ignore: "忽略"
|
|
781
|
+
ignore: "忽略",
|
|
782
|
+
open: "打开"
|
|
842
783
|
};
|
|
843
784
|
const GLOBAL_LOCALES_KEY = "ArtalkI18n";
|
|
844
785
|
const internal = {
|
|
@@ -875,9 +816,9 @@ function t(key, args = {}) {
|
|
|
875
816
|
function Fetch$1(opts, input, init2, timeout) {
|
|
876
817
|
return __async(this, null, function* () {
|
|
877
818
|
var _a, _b;
|
|
878
|
-
if (
|
|
819
|
+
if (opts.apiToken) {
|
|
879
820
|
const headers = new Headers(init2.headers);
|
|
880
|
-
headers.set("Authorization", `Bearer ${
|
|
821
|
+
headers.set("Authorization", `Bearer ${opts.apiToken}`);
|
|
881
822
|
init2.headers = headers;
|
|
882
823
|
}
|
|
883
824
|
const resp = yield timeoutFetch(input, timeout || opts.timeout || 15e3, init2);
|
|
@@ -969,6 +910,20 @@ class ApiBase {
|
|
|
969
910
|
return Fetch$1(this.options, this.options.baseURL + path, init2, timeout);
|
|
970
911
|
});
|
|
971
912
|
}
|
|
913
|
+
/**
|
|
914
|
+
* Carry user info to request params
|
|
915
|
+
*
|
|
916
|
+
* @param params Request params
|
|
917
|
+
* @returns Request params with user info
|
|
918
|
+
*/
|
|
919
|
+
withUserInfo(params) {
|
|
920
|
+
const user = this.options.userInfo;
|
|
921
|
+
if (user == null ? void 0 : user.name)
|
|
922
|
+
params.name = user.name;
|
|
923
|
+
if (user == null ? void 0 : user.email)
|
|
924
|
+
params.email = user.email;
|
|
925
|
+
return params;
|
|
926
|
+
}
|
|
972
927
|
}
|
|
973
928
|
class CommentApi extends ApiBase {
|
|
974
929
|
/** 评论 · 获取 */
|
|
@@ -981,10 +936,7 @@ class CommentApi extends ApiBase {
|
|
|
981
936
|
};
|
|
982
937
|
if (flatMode)
|
|
983
938
|
params.flat_mode = flatMode;
|
|
984
|
-
|
|
985
|
-
params.name = UserInstance.data.nick;
|
|
986
|
-
params.email = UserInstance.data.email;
|
|
987
|
-
}
|
|
939
|
+
this.withUserInfo(params);
|
|
988
940
|
if (paramsEditor)
|
|
989
941
|
paramsEditor(params);
|
|
990
942
|
return this.POST("/get", params);
|
|
@@ -1033,10 +985,7 @@ class CommentApi extends ApiBase {
|
|
|
1033
985
|
target_id: targetID,
|
|
1034
986
|
type
|
|
1035
987
|
};
|
|
1036
|
-
|
|
1037
|
-
params.name = UserInstance.data.nick;
|
|
1038
|
-
params.email = UserInstance.data.email;
|
|
1039
|
-
}
|
|
988
|
+
this.withUserInfo(params);
|
|
1040
989
|
const data = yield this.POST("/vote", params);
|
|
1041
990
|
return data;
|
|
1042
991
|
});
|
|
@@ -1205,10 +1154,7 @@ class UserApi extends ApiBase {
|
|
|
1205
1154
|
/** 用户 · 登录状态 */
|
|
1206
1155
|
loginStatus() {
|
|
1207
1156
|
return __async(this, null, function* () {
|
|
1208
|
-
const data = yield this.POST("/login-status", {
|
|
1209
|
-
name: UserInstance.data.nick,
|
|
1210
|
-
email: UserInstance.data.email
|
|
1211
|
-
});
|
|
1157
|
+
const data = yield this.POST("/login-status", this.withUserInfo({}));
|
|
1212
1158
|
return data || { is_login: false, is_admin: false };
|
|
1213
1159
|
});
|
|
1214
1160
|
}
|
|
@@ -1228,8 +1174,7 @@ class UserApi extends ApiBase {
|
|
|
1228
1174
|
delete params.comment_id;
|
|
1229
1175
|
delete params.notify_key;
|
|
1230
1176
|
params.read_all = true;
|
|
1231
|
-
params
|
|
1232
|
-
params.email = UserInstance.data.email;
|
|
1177
|
+
this.withUserInfo(params);
|
|
1233
1178
|
}
|
|
1234
1179
|
return this.POST(`/mark-read`, params);
|
|
1235
1180
|
}
|
|
@@ -1366,10 +1311,9 @@ class UploadApi extends ApiBase {
|
|
|
1366
1311
|
imgUpload(file) {
|
|
1367
1312
|
return __async(this, null, function* () {
|
|
1368
1313
|
const params = {
|
|
1369
|
-
name: UserInstance.data.nick,
|
|
1370
|
-
email: UserInstance.data.email,
|
|
1371
1314
|
page_key: this.options.pageKey
|
|
1372
1315
|
};
|
|
1316
|
+
this.withUserInfo(params);
|
|
1373
1317
|
const form = ToFormData(params);
|
|
1374
1318
|
form.set("file", file);
|
|
1375
1319
|
const init2 = {
|
|
@@ -3733,12 +3677,12 @@ function parser$1(html, handler) {
|
|
|
3733
3677
|
}
|
|
3734
3678
|
}
|
|
3735
3679
|
function parseComment() {
|
|
3736
|
-
var
|
|
3737
|
-
if (
|
|
3680
|
+
var index = html.indexOf("-->");
|
|
3681
|
+
if (index >= 0) {
|
|
3738
3682
|
if (handler.comment) {
|
|
3739
|
-
handler.comment(html.substring(4,
|
|
3683
|
+
handler.comment(html.substring(4, index));
|
|
3740
3684
|
}
|
|
3741
|
-
html = html.substring(
|
|
3685
|
+
html = html.substring(index + 3);
|
|
3742
3686
|
chars = false;
|
|
3743
3687
|
}
|
|
3744
3688
|
}
|
|
@@ -3747,10 +3691,10 @@ function parser$1(html, handler) {
|
|
|
3747
3691
|
return;
|
|
3748
3692
|
}
|
|
3749
3693
|
var text;
|
|
3750
|
-
var
|
|
3751
|
-
if (
|
|
3752
|
-
text = html.substring(0,
|
|
3753
|
-
html = html.substring(
|
|
3694
|
+
var index = html.indexOf("<");
|
|
3695
|
+
if (index >= 0) {
|
|
3696
|
+
text = html.substring(0, index);
|
|
3697
|
+
html = html.substring(index);
|
|
3754
3698
|
} else {
|
|
3755
3699
|
text = html;
|
|
3756
3700
|
html = "";
|
|
@@ -4101,13 +4045,13 @@ var hanabi$1 = { exports: {} };
|
|
|
4101
4045
|
};
|
|
4102
4046
|
});
|
|
4103
4047
|
var defaultColors = ["23AC69", "91C132", "F19726", "E8552D", "1AAB8E", "E1147F", "2980C1", "1BA1E6", "9FA0A0", "F19726", "E30B20", "E30B20", "A3338B"];
|
|
4104
|
-
var
|
|
4048
|
+
var index = function(input, ref) {
|
|
4105
4049
|
if (ref === void 0)
|
|
4106
4050
|
ref = {};
|
|
4107
4051
|
var colors = ref.colors;
|
|
4108
4052
|
if (colors === void 0)
|
|
4109
4053
|
colors = defaultColors;
|
|
4110
|
-
var
|
|
4054
|
+
var index2 = 0;
|
|
4111
4055
|
var cache = {};
|
|
4112
4056
|
var wordRe = /[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/;
|
|
4113
4057
|
var leftAngleRe = /</;
|
|
@@ -4123,18 +4067,18 @@ var hanabi$1 = { exports: {} };
|
|
|
4123
4067
|
if (cache[word]) {
|
|
4124
4068
|
color = cache[word];
|
|
4125
4069
|
} else {
|
|
4126
|
-
color = colors[
|
|
4070
|
+
color = colors[index2];
|
|
4127
4071
|
cache[word] = color;
|
|
4128
4072
|
}
|
|
4129
4073
|
var out = '<span style="color: #' + color + '">' + word + "</span>";
|
|
4130
|
-
|
|
4074
|
+
index2 = ++index2 % colors.length;
|
|
4131
4075
|
return out;
|
|
4132
4076
|
});
|
|
4133
4077
|
};
|
|
4134
4078
|
function toComment(cm) {
|
|
4135
4079
|
return '<span style="color: slategray">' + cm + "</span>";
|
|
4136
4080
|
}
|
|
4137
|
-
return
|
|
4081
|
+
return index;
|
|
4138
4082
|
});
|
|
4139
4083
|
})(hanabi$1);
|
|
4140
4084
|
var hanabiExports = hanabi$1.exports;
|
|
@@ -4213,6 +4157,26 @@ function marked(src) {
|
|
|
4213
4157
|
function simpleMarked(src) {
|
|
4214
4158
|
return src.replace(/```\s*([^]+?.*?[^]+?[^]+?)```/g, (_, code) => `<pre><code>${renderCode(code)}</code></pre>`).replace(/!\[(.*?)\]\((.*?)\)/g, (_, alt, imgSrc) => `<img src="${imgSrc}" alt="${alt}" />`).replace(/\[(.*?)\]\((.*?)\)/g, (_, text, link) => `<a href="${link}" target="_blank">${text}</a>`).replace(/\n/g, "<br>");
|
|
4215
4159
|
}
|
|
4160
|
+
function mergeDeep(...objects) {
|
|
4161
|
+
const isObject = (obj) => obj && typeof obj === "object" && obj.constructor === Object;
|
|
4162
|
+
return objects.reduce((prev, obj) => {
|
|
4163
|
+
Object.keys(obj != null ? obj : {}).forEach((key) => {
|
|
4164
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
4165
|
+
return;
|
|
4166
|
+
}
|
|
4167
|
+
const pVal = prev[key];
|
|
4168
|
+
const oVal = obj[key];
|
|
4169
|
+
if (Array.isArray(pVal) && Array.isArray(oVal)) {
|
|
4170
|
+
prev[key] = pVal.concat(...oVal);
|
|
4171
|
+
} else if (isObject(pVal) && isObject(oVal)) {
|
|
4172
|
+
prev[key] = mergeDeep(pVal, oVal);
|
|
4173
|
+
} else {
|
|
4174
|
+
prev[key] = oVal;
|
|
4175
|
+
}
|
|
4176
|
+
});
|
|
4177
|
+
return prev;
|
|
4178
|
+
}, {});
|
|
4179
|
+
}
|
|
4216
4180
|
class DataManager {
|
|
4217
4181
|
constructor(events) {
|
|
4218
4182
|
__publicField(this, "loading", false);
|
|
@@ -4370,11 +4334,9 @@ const defaults = {
|
|
|
4370
4334
|
useBackendConf: true,
|
|
4371
4335
|
locale: "zh-CN"
|
|
4372
4336
|
};
|
|
4373
|
-
function handelCustomConf(customConf) {
|
|
4374
|
-
const conf = mergeDeep(defaults, customConf);
|
|
4375
|
-
if (
|
|
4376
|
-
conf.el = customConf.el;
|
|
4377
|
-
if (typeof conf.el === "string" && !!conf.el) {
|
|
4337
|
+
function handelCustomConf(customConf, full = false) {
|
|
4338
|
+
const conf = full ? mergeDeep(defaults, customConf) : customConf;
|
|
4339
|
+
if (conf.el && typeof conf.el === "string") {
|
|
4378
4340
|
try {
|
|
4379
4341
|
const findEl = document.querySelector(conf.el);
|
|
4380
4342
|
if (!findEl)
|
|
@@ -4385,20 +4347,18 @@ function handelCustomConf(customConf) {
|
|
|
4385
4347
|
throw new Error("Please check your Artalk `el` config.");
|
|
4386
4348
|
}
|
|
4387
4349
|
}
|
|
4388
|
-
|
|
4389
|
-
if (!conf.pageKey) {
|
|
4350
|
+
if (conf.pageKey === "")
|
|
4390
4351
|
conf.pageKey = `${window.location.pathname}`;
|
|
4391
|
-
|
|
4392
|
-
if (!conf.pageTitle) {
|
|
4352
|
+
if (conf.pageTitle === "")
|
|
4393
4353
|
conf.pageTitle = `${document.title}`;
|
|
4394
|
-
|
|
4395
|
-
|
|
4354
|
+
if (conf.server)
|
|
4355
|
+
conf.server = conf.server.replace(/\/$/, "").replace(/\/api\/?$/, "");
|
|
4356
|
+
if (conf.locale === "auto")
|
|
4396
4357
|
conf.locale = navigator.language;
|
|
4397
|
-
}
|
|
4398
|
-
if (conf.flatMode === true || Number(conf.nestMax) <= 1)
|
|
4399
|
-
conf.flatMode = true;
|
|
4400
4358
|
if (conf.flatMode === "auto")
|
|
4401
4359
|
conf.flatMode = window.matchMedia("(max-width: 768px)").matches;
|
|
4360
|
+
if (typeof conf.nestMax === "number" && Number(conf.nestMax) <= 1)
|
|
4361
|
+
conf.flatMode = true;
|
|
4402
4362
|
return conf;
|
|
4403
4363
|
}
|
|
4404
4364
|
function handleConfFormServer(conf) {
|
|
@@ -4431,6 +4391,11 @@ function convertApiOptions(conf, ctx) {
|
|
|
4431
4391
|
pageKey: conf.pageKey || "",
|
|
4432
4392
|
pageTitle: conf.pageTitle || "",
|
|
4433
4393
|
timeout: conf.reqTimeout,
|
|
4394
|
+
apiToken: ctx == null ? void 0 : ctx.get("user").getData().token,
|
|
4395
|
+
userInfo: (ctx == null ? void 0 : ctx.get("user").checkHasBasicUserInfo()) ? {
|
|
4396
|
+
name: ctx == null ? void 0 : ctx.get("user").getData().nick,
|
|
4397
|
+
email: ctx == null ? void 0 : ctx.get("user").getData().email
|
|
4398
|
+
} : void 0,
|
|
4434
4399
|
onNeedCheckAdmin(payload) {
|
|
4435
4400
|
ctx == null ? void 0 : ctx.checkAdmin({
|
|
4436
4401
|
onSuccess: () => {
|
|
@@ -4456,7 +4421,7 @@ function convertApiOptions(conf, ctx) {
|
|
|
4456
4421
|
};
|
|
4457
4422
|
}
|
|
4458
4423
|
class Context {
|
|
4459
|
-
constructor(conf
|
|
4424
|
+
constructor(conf) {
|
|
4460
4425
|
/* 运行参数 */
|
|
4461
4426
|
__publicField(this, "conf");
|
|
4462
4427
|
__publicField(this, "data");
|
|
@@ -4464,7 +4429,7 @@ class Context {
|
|
|
4464
4429
|
/* Event Manager */
|
|
4465
4430
|
__publicField(this, "events", new EventManager());
|
|
4466
4431
|
this.conf = conf;
|
|
4467
|
-
this.$root =
|
|
4432
|
+
this.$root = conf.el;
|
|
4468
4433
|
this.$root.classList.add("artalk");
|
|
4469
4434
|
this.$root.innerHTML = "";
|
|
4470
4435
|
this.data = new DataManager(this.events);
|
|
@@ -4494,7 +4459,7 @@ class Context {
|
|
|
4494
4459
|
this.data.fetchComments({ offset: 0 });
|
|
4495
4460
|
}
|
|
4496
4461
|
listGotoFirst() {
|
|
4497
|
-
this.trigger("list-goto-first");
|
|
4462
|
+
this.events.trigger("list-goto-first");
|
|
4498
4463
|
}
|
|
4499
4464
|
/* 编辑器 */
|
|
4500
4465
|
editorShowLoading() {
|
|
@@ -4539,11 +4504,17 @@ class Context {
|
|
|
4539
4504
|
}
|
|
4540
4505
|
setDarkMode(darkMode) {
|
|
4541
4506
|
this.conf.darkMode = darkMode;
|
|
4542
|
-
this.trigger("dark-mode-changed", darkMode);
|
|
4507
|
+
this.events.trigger("dark-mode-changed", darkMode);
|
|
4543
4508
|
}
|
|
4544
4509
|
updateConf(nConf) {
|
|
4545
|
-
this.conf = mergeDeep(this.conf, handelCustomConf(nConf));
|
|
4546
|
-
this.trigger("conf-loaded", this.conf);
|
|
4510
|
+
this.conf = mergeDeep(this.conf, handelCustomConf(nConf, false));
|
|
4511
|
+
this.events.trigger("conf-loaded", this.conf);
|
|
4512
|
+
}
|
|
4513
|
+
getConf() {
|
|
4514
|
+
return this.conf;
|
|
4515
|
+
}
|
|
4516
|
+
getEl() {
|
|
4517
|
+
return this.$root;
|
|
4547
4518
|
}
|
|
4548
4519
|
getMarked() {
|
|
4549
4520
|
return getInstance();
|
|
@@ -4750,7 +4721,7 @@ function imgBody(checker) {
|
|
|
4750
4721
|
}
|
|
4751
4722
|
function iframeBody(checker) {
|
|
4752
4723
|
const $iframeWrap = createElement(`<div class="atk-checker-iframe-wrap"></div>`);
|
|
4753
|
-
const $iframe = createElement(`<iframe class="atk-fade-in"></iframe>`);
|
|
4724
|
+
const $iframe = createElement(`<iframe class="atk-fade-in" referrerpolicy="strict-origin-when-cross-origin"></iframe>`);
|
|
4754
4725
|
$iframe.style.display = "none";
|
|
4755
4726
|
showLoading($iframeWrap, { transparentBg: true });
|
|
4756
4727
|
$iframe.src = `${checker.getOpts().getIframeURLBase() || ""}/api/captcha/get?t=${+/* @__PURE__ */ new Date()}`;
|
|
@@ -4814,8 +4785,8 @@ const AdminChecker = {
|
|
|
4814
4785
|
inputType: "password",
|
|
4815
4786
|
request(checker, inputVal) {
|
|
4816
4787
|
const data = {
|
|
4817
|
-
name:
|
|
4818
|
-
email:
|
|
4788
|
+
name: checker.getUser().getData().nick,
|
|
4789
|
+
email: checker.getUser().getData().email,
|
|
4819
4790
|
password: inputVal
|
|
4820
4791
|
};
|
|
4821
4792
|
return (() => __async(this, null, function* () {
|
|
@@ -4827,7 +4798,7 @@ const AdminChecker = {
|
|
|
4827
4798
|
return createElement(`<span>${t("adminCheck")}</span>`);
|
|
4828
4799
|
},
|
|
4829
4800
|
onSuccess(checker, userToken, inputVal, formEl) {
|
|
4830
|
-
|
|
4801
|
+
checker.getUser().update({
|
|
4831
4802
|
isAdmin: true,
|
|
4832
4803
|
token: userToken
|
|
4833
4804
|
});
|
|
@@ -4860,6 +4831,7 @@ class CheckerLauncher {
|
|
|
4860
4831
|
},
|
|
4861
4832
|
get: (key) => checkerStore[key],
|
|
4862
4833
|
getOpts: () => this.opts,
|
|
4834
|
+
getUser: () => this.opts.getCtx().get("user"),
|
|
4863
4835
|
getApi: () => this.opts.getApi(),
|
|
4864
4836
|
hideInteractInput: () => {
|
|
4865
4837
|
hideInteractInput = true;
|
|
@@ -5251,7 +5223,7 @@ class SidebarLayer extends Component {
|
|
|
5251
5223
|
});
|
|
5252
5224
|
}
|
|
5253
5225
|
createIframe(view) {
|
|
5254
|
-
const $iframe = createElement(
|
|
5226
|
+
const $iframe = createElement('<iframe referrerpolicy="strict-origin-when-cross-origin"></iframe>');
|
|
5255
5227
|
const baseURL = getURLBasedOnApi({
|
|
5256
5228
|
base: this.ctx.conf.server,
|
|
5257
5229
|
path: "/sidebar/"
|
|
@@ -5259,7 +5231,7 @@ class SidebarLayer extends Component {
|
|
|
5259
5231
|
const query = {
|
|
5260
5232
|
pageKey: this.conf.pageKey,
|
|
5261
5233
|
site: this.conf.site || "",
|
|
5262
|
-
user: JSON.stringify(
|
|
5234
|
+
user: JSON.stringify(this.ctx.get("user").getData()),
|
|
5263
5235
|
time: +/* @__PURE__ */ new Date()
|
|
5264
5236
|
};
|
|
5265
5237
|
if (view)
|
|
@@ -5336,7 +5308,7 @@ class ListLayout {
|
|
|
5336
5308
|
constructor(options) {
|
|
5337
5309
|
this.options = options;
|
|
5338
5310
|
}
|
|
5339
|
-
// TODO refactor `if syntax` to strategy pattern
|
|
5311
|
+
// TODO: refactor `if syntax` to strategy pattern
|
|
5340
5312
|
import(comments) {
|
|
5341
5313
|
if (this.options.flatMode) {
|
|
5342
5314
|
comments.forEach((commentData) => {
|
|
@@ -5412,9 +5384,9 @@ class ListLayout {
|
|
|
5412
5384
|
scrollIntoView(comment.getEl());
|
|
5413
5385
|
}
|
|
5414
5386
|
}
|
|
5415
|
-
const win = window || {};
|
|
5416
|
-
const nav = navigator || {};
|
|
5417
5387
|
function Detect(userAgent) {
|
|
5388
|
+
const win = window || {};
|
|
5389
|
+
const nav = navigator || {};
|
|
5418
5390
|
const u = String(userAgent || nav.userAgent);
|
|
5419
5391
|
const dest = {
|
|
5420
5392
|
os: "",
|
|
@@ -6763,20 +6735,6 @@ const initListPaginatorFunc = (ctx) => {
|
|
|
6763
6735
|
var _a;
|
|
6764
6736
|
(_a = paginator == null ? void 0 : paginator.showErr) == null ? void 0 : _a.call(paginator, t("loadFail"));
|
|
6765
6737
|
});
|
|
6766
|
-
const autoSwitchPageForFindComment = (commentID) => {
|
|
6767
|
-
const comment = ctx.getData().findComment(commentID);
|
|
6768
|
-
if (!!comment || !(paginator == null ? void 0 : paginator.getHasMore()))
|
|
6769
|
-
return;
|
|
6770
|
-
ctx.on("list-loaded", () => {
|
|
6771
|
-
autoSwitchPageForFindComment(commentID);
|
|
6772
|
-
}, { once: true });
|
|
6773
|
-
setTimeout(() => {
|
|
6774
|
-
paginator == null ? void 0 : paginator.next();
|
|
6775
|
-
}, 80);
|
|
6776
|
-
};
|
|
6777
|
-
ctx.on("list-goto", (commentID) => {
|
|
6778
|
-
autoSwitchPageForFindComment(commentID);
|
|
6779
|
-
});
|
|
6780
6738
|
ctx.on("list-fetch", (params) => {
|
|
6781
6739
|
paginator == null ? void 0 : paginator.setLoading(true);
|
|
6782
6740
|
});
|
|
@@ -6974,6 +6932,47 @@ class LayerManager {
|
|
|
6974
6932
|
return layer;
|
|
6975
6933
|
}
|
|
6976
6934
|
}
|
|
6935
|
+
const LOCAL_USER_KEY = "ArtalkUser";
|
|
6936
|
+
class User {
|
|
6937
|
+
constructor(opts) {
|
|
6938
|
+
__publicField(this, "data");
|
|
6939
|
+
this.opts = opts;
|
|
6940
|
+
const localUser = JSON.parse(window.localStorage.getItem(LOCAL_USER_KEY) || "{}");
|
|
6941
|
+
this.data = {
|
|
6942
|
+
nick: localUser.nick || "",
|
|
6943
|
+
email: localUser.email || "",
|
|
6944
|
+
link: localUser.link || "",
|
|
6945
|
+
token: localUser.token || "",
|
|
6946
|
+
isAdmin: localUser.isAdmin || false
|
|
6947
|
+
};
|
|
6948
|
+
}
|
|
6949
|
+
getData() {
|
|
6950
|
+
return this.data;
|
|
6951
|
+
}
|
|
6952
|
+
/** 保存用户到 localStorage 中 */
|
|
6953
|
+
update(obj = {}) {
|
|
6954
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
6955
|
+
this.data[key] = value;
|
|
6956
|
+
});
|
|
6957
|
+
window.localStorage.setItem(LOCAL_USER_KEY, JSON.stringify(this.data));
|
|
6958
|
+
this.opts.onUserChanged && this.opts.onUserChanged(this.data);
|
|
6959
|
+
}
|
|
6960
|
+
/**
|
|
6961
|
+
* Logout
|
|
6962
|
+
*
|
|
6963
|
+
* @description Logout will clear login status, but not clear user data (nick, email, link)
|
|
6964
|
+
*/
|
|
6965
|
+
logout() {
|
|
6966
|
+
this.update({
|
|
6967
|
+
token: "",
|
|
6968
|
+
isAdmin: false
|
|
6969
|
+
});
|
|
6970
|
+
}
|
|
6971
|
+
/** 是否已填写基本用户信息 */
|
|
6972
|
+
checkHasBasicUserInfo() {
|
|
6973
|
+
return !!this.data.nick && !!this.data.email;
|
|
6974
|
+
}
|
|
6975
|
+
}
|
|
6977
6976
|
const services = {
|
|
6978
6977
|
// I18n
|
|
6979
6978
|
i18n(ctx) {
|
|
@@ -6984,10 +6983,12 @@ const services = {
|
|
|
6984
6983
|
},
|
|
6985
6984
|
// User Store
|
|
6986
6985
|
user(ctx) {
|
|
6987
|
-
|
|
6988
|
-
|
|
6986
|
+
const user = new User({
|
|
6987
|
+
onUserChanged: (data) => {
|
|
6988
|
+
ctx.trigger("user-changed", data);
|
|
6989
|
+
}
|
|
6989
6990
|
});
|
|
6990
|
-
return
|
|
6991
|
+
return user;
|
|
6991
6992
|
},
|
|
6992
6993
|
// 弹出层
|
|
6993
6994
|
layerManager(ctx) {
|
|
@@ -7037,17 +7038,19 @@ function showErrorDialog(opts) {
|
|
|
7037
7038
|
errEl.appendChild($retryBtn);
|
|
7038
7039
|
}
|
|
7039
7040
|
if (opts.onOpenSidebar) {
|
|
7040
|
-
const $openSidebar = createElement(
|
|
7041
|
+
const $openSidebar = createElement(`<span atk-only-admin-show> | <span style="cursor:pointer;">${t("open") + t("ctrlCenter")}</span></span>`);
|
|
7041
7042
|
errEl.appendChild($openSidebar);
|
|
7042
|
-
if (!UserInstance.data.isAdmin) {
|
|
7043
|
-
$openSidebar.classList.add("atk-hide");
|
|
7044
|
-
}
|
|
7045
7043
|
$openSidebar.onclick = () => opts.onOpenSidebar && opts.onOpenSidebar();
|
|
7046
7044
|
}
|
|
7047
7045
|
setError(opts.$err, errEl);
|
|
7048
7046
|
}
|
|
7049
7047
|
const ConfRemoter = (ctx) => {
|
|
7050
7048
|
ctx.on("inited", () => {
|
|
7049
|
+
if (ctx.conf.immediateFetch === false)
|
|
7050
|
+
return;
|
|
7051
|
+
ctx.trigger("conf-fetch");
|
|
7052
|
+
});
|
|
7053
|
+
ctx.on("conf-fetch", () => {
|
|
7051
7054
|
loadConf(ctx);
|
|
7052
7055
|
});
|
|
7053
7056
|
};
|
|
@@ -7077,9 +7080,10 @@ function loadConf(ctx) {
|
|
|
7077
7080
|
errMsg: err.msg || String(err),
|
|
7078
7081
|
errData: err.data,
|
|
7079
7082
|
retryFn: () => loadConf(ctx),
|
|
7080
|
-
onOpenSidebar: () => ctx.showSidebar({
|
|
7083
|
+
onOpenSidebar: ctx.get("user").getData().isAdmin ? () => ctx.showSidebar({
|
|
7081
7084
|
view: sidebarOpenView
|
|
7082
|
-
})
|
|
7085
|
+
}) : void 0
|
|
7086
|
+
// only show open sidebar button when user is admin
|
|
7083
7087
|
});
|
|
7084
7088
|
throw err;
|
|
7085
7089
|
}).then(() => {
|
|
@@ -7184,7 +7188,7 @@ class SubmitAddPreset {
|
|
|
7184
7188
|
});
|
|
7185
7189
|
}
|
|
7186
7190
|
getSubmitAddParams() {
|
|
7187
|
-
const { nick, email, link } =
|
|
7191
|
+
const { nick, email, link } = this.kit.useUser().getData();
|
|
7188
7192
|
const conf = this.kit.useConf();
|
|
7189
7193
|
return {
|
|
7190
7194
|
content: this.kit.useEditor().getContentFinal(),
|
|
@@ -7382,7 +7386,7 @@ class StateEdit extends EditorPlug {
|
|
|
7382
7386
|
ui.$editCancelBtn = void 0;
|
|
7383
7387
|
}
|
|
7384
7388
|
this.comment = void 0;
|
|
7385
|
-
const { nick, email, link } =
|
|
7389
|
+
const { nick, email, link } = this.kit.useUser().getData();
|
|
7386
7390
|
ui.$nick.value = nick;
|
|
7387
7391
|
ui.$email.value = email;
|
|
7388
7392
|
ui.$link.value = link;
|
|
@@ -7421,7 +7425,7 @@ class Closable extends EditorPlug {
|
|
|
7421
7425
|
close() {
|
|
7422
7426
|
if (!this.kit.useUI().$textareaWrap.querySelector(".atk-comment-closed"))
|
|
7423
7427
|
this.kit.useUI().$textareaWrap.prepend(createElement(`<div class="atk-comment-closed">${t("onlyAdminCanReply")}</div>`));
|
|
7424
|
-
if (!
|
|
7428
|
+
if (!this.kit.useUser().getData().isAdmin) {
|
|
7425
7429
|
this.kit.useUI().$textarea.style.display = "none";
|
|
7426
7430
|
this.kit.useEvents().trigger("panel-close");
|
|
7427
7431
|
this.kit.useUI().$bottom.style.display = "none";
|
|
@@ -7466,14 +7470,14 @@ class HeaderUser extends EditorPlug {
|
|
|
7466
7470
|
const onInput = ({ $input, field }) => {
|
|
7467
7471
|
if (this.kit.useEditor().getState() === "edit")
|
|
7468
7472
|
return;
|
|
7469
|
-
|
|
7473
|
+
this.kit.useUser().update({ [field]: $input.value.trim() });
|
|
7470
7474
|
if (field === "nick" || field === "email")
|
|
7471
7475
|
this.fetchUserInfo();
|
|
7472
7476
|
};
|
|
7473
7477
|
this.kit.useMounted(() => {
|
|
7474
7478
|
Object.entries(this.kit.useEditor().getHeaderInputEls()).forEach(([key, $input]) => {
|
|
7475
7479
|
$input.placeholder = `${t(key)}`;
|
|
7476
|
-
$input.value =
|
|
7480
|
+
$input.value = this.kit.useUser().getData()[key] || "";
|
|
7477
7481
|
});
|
|
7478
7482
|
this.kit.useEvents().on("header-input", onInput);
|
|
7479
7483
|
});
|
|
@@ -7485,7 +7489,7 @@ class HeaderUser extends EditorPlug {
|
|
|
7485
7489
|
* Fetch user info from server
|
|
7486
7490
|
*/
|
|
7487
7491
|
fetchUserInfo() {
|
|
7488
|
-
|
|
7492
|
+
this.kit.useUser().logout();
|
|
7489
7493
|
if (this.query.timer)
|
|
7490
7494
|
window.clearTimeout(this.query.timer);
|
|
7491
7495
|
if (this.query.abortFn)
|
|
@@ -7493,8 +7497,8 @@ class HeaderUser extends EditorPlug {
|
|
|
7493
7497
|
this.query.timer = window.setTimeout(() => {
|
|
7494
7498
|
this.query.timer = null;
|
|
7495
7499
|
const { req, abort } = this.kit.useApi().user.userGet(
|
|
7496
|
-
|
|
7497
|
-
|
|
7500
|
+
this.kit.useUser().getData().nick,
|
|
7501
|
+
this.kit.useUser().getData().email
|
|
7498
7502
|
);
|
|
7499
7503
|
this.query.abortFn = abort;
|
|
7500
7504
|
req.then((data) => this.onUserInfoFetched(data)).catch((err) => {
|
|
@@ -7511,9 +7515,9 @@ class HeaderUser extends EditorPlug {
|
|
|
7511
7515
|
onUserInfoFetched(data) {
|
|
7512
7516
|
var _a;
|
|
7513
7517
|
if (!data.is_login)
|
|
7514
|
-
|
|
7518
|
+
this.kit.useUser().logout();
|
|
7515
7519
|
this.kit.useGlobalCtx().getData().updateUnreads(data.unread);
|
|
7516
|
-
if (
|
|
7520
|
+
if (this.kit.useUser().checkHasBasicUserInfo() && !data.is_login && ((_a = data.user) == null ? void 0 : _a.is_admin)) {
|
|
7517
7521
|
this.kit.useGlobalCtx().checkAdmin({
|
|
7518
7522
|
onSuccess: () => {
|
|
7519
7523
|
}
|
|
@@ -7521,7 +7525,7 @@ class HeaderUser extends EditorPlug {
|
|
|
7521
7525
|
}
|
|
7522
7526
|
if (data.user && data.user.link) {
|
|
7523
7527
|
this.kit.useUI().$link.value = data.user.link;
|
|
7524
|
-
|
|
7528
|
+
this.kit.useUser().update({ link: data.user.link });
|
|
7525
7529
|
}
|
|
7526
7530
|
}
|
|
7527
7531
|
}
|
|
@@ -7543,11 +7547,10 @@ class HeaderLink extends EditorPlug {
|
|
|
7543
7547
|
const link = this.kit.useUI().$link.value.trim();
|
|
7544
7548
|
if (!!link && !/^(http|https):\/\//.test(link)) {
|
|
7545
7549
|
this.kit.useUI().$link.value = `https://${link}`;
|
|
7546
|
-
|
|
7550
|
+
this.kit.useUser().update({ link: this.kit.useUI().$link.value });
|
|
7547
7551
|
}
|
|
7548
7552
|
}
|
|
7549
7553
|
}
|
|
7550
|
-
const emoticons = "";
|
|
7551
7554
|
class Emoticons extends EditorPlug {
|
|
7552
7555
|
constructor(kit) {
|
|
7553
7556
|
super(kit);
|
|
@@ -7619,7 +7622,7 @@ class Emoticons extends EditorPlug {
|
|
|
7619
7622
|
data.push(grp);
|
|
7620
7623
|
};
|
|
7621
7624
|
const remoteLoad = (d) => __async(this, null, function* () {
|
|
7622
|
-
yield Promise.all(d.map((grp,
|
|
7625
|
+
yield Promise.all(d.map((grp, index) => __async(this, null, function* () {
|
|
7623
7626
|
if (typeof grp === "object" && !Array.isArray(grp)) {
|
|
7624
7627
|
pushGrp(grp);
|
|
7625
7628
|
} else if (Array.isArray(grp)) {
|
|
@@ -7663,7 +7666,8 @@ class Emoticons extends EditorPlug {
|
|
|
7663
7666
|
return json;
|
|
7664
7667
|
} catch (err) {
|
|
7665
7668
|
hideLoading(this.$panel);
|
|
7666
|
-
|
|
7669
|
+
console.error("[Emoticons] Load Failed:", err);
|
|
7670
|
+
setError(this.$panel, `${t("emoticon")}${t("loadFail")} ${String(err)}`);
|
|
7667
7671
|
return [];
|
|
7668
7672
|
}
|
|
7669
7673
|
});
|
|
@@ -7671,9 +7675,9 @@ class Emoticons extends EditorPlug {
|
|
|
7671
7675
|
/** 避免表情 item.key 为 null 的情况 */
|
|
7672
7676
|
solveNullKey(data) {
|
|
7673
7677
|
data.forEach((grp) => {
|
|
7674
|
-
grp.items.forEach((item,
|
|
7678
|
+
grp.items.forEach((item, index) => {
|
|
7675
7679
|
if (!item.key)
|
|
7676
|
-
item.key = `${grp.name} ${
|
|
7680
|
+
item.key = `${grp.name} ${index + 1}`;
|
|
7677
7681
|
});
|
|
7678
7682
|
});
|
|
7679
7683
|
}
|
|
@@ -7706,14 +7710,14 @@ class Emoticons extends EditorPlug {
|
|
|
7706
7710
|
const dest = [];
|
|
7707
7711
|
Object.entries(owoData).forEach(([grpName, grp]) => {
|
|
7708
7712
|
const nGrp = { name: grpName, type: grp.type, items: [] };
|
|
7709
|
-
grp.container.forEach((item,
|
|
7713
|
+
grp.container.forEach((item, index) => {
|
|
7710
7714
|
const iconStr = item.icon;
|
|
7711
7715
|
if (/<(img|IMG)/.test(iconStr)) {
|
|
7712
7716
|
const find = /src=["'](.*?)["']/.exec(iconStr);
|
|
7713
7717
|
if (find && find.length > 1)
|
|
7714
7718
|
item.icon = find[1];
|
|
7715
7719
|
}
|
|
7716
|
-
nGrp.items.push({ key: item.text || `${grpName} ${
|
|
7720
|
+
nGrp.items.push({ key: item.text || `${grpName} ${index + 1}`, val: item.icon });
|
|
7717
7721
|
});
|
|
7718
7722
|
dest.push(nGrp);
|
|
7719
7723
|
});
|
|
@@ -7723,10 +7727,10 @@ class Emoticons extends EditorPlug {
|
|
|
7723
7727
|
initEmoticonsList() {
|
|
7724
7728
|
this.$grpWrap = createElement(`<div class="atk-grp-wrap"></div>`);
|
|
7725
7729
|
this.$panel.append(this.$grpWrap);
|
|
7726
|
-
this.emoticons.forEach((grp,
|
|
7730
|
+
this.emoticons.forEach((grp, index) => {
|
|
7727
7731
|
const $grp = createElement(`<div class="atk-grp" style="display: none;"></div>`);
|
|
7728
7732
|
this.$grpWrap.append($grp);
|
|
7729
|
-
$grp.setAttribute("data-index", String(
|
|
7733
|
+
$grp.setAttribute("data-index", String(index));
|
|
7730
7734
|
$grp.setAttribute("data-grp-name", grp.name);
|
|
7731
7735
|
$grp.setAttribute("data-type", grp.type);
|
|
7732
7736
|
grp.items.forEach((item) => {
|
|
@@ -7754,11 +7758,11 @@ class Emoticons extends EditorPlug {
|
|
|
7754
7758
|
if (this.emoticons.length > 1) {
|
|
7755
7759
|
this.$grpSwitcher = createElement(`<div class="atk-grp-switcher"></div>`);
|
|
7756
7760
|
this.$panel.append(this.$grpSwitcher);
|
|
7757
|
-
this.emoticons.forEach((grp,
|
|
7761
|
+
this.emoticons.forEach((grp, index) => {
|
|
7758
7762
|
const $item = createElement("<span />");
|
|
7759
7763
|
$item.innerText = grp.name;
|
|
7760
|
-
$item.setAttribute("data-index", String(
|
|
7761
|
-
$item.onclick = () => this.openGrp(
|
|
7764
|
+
$item.setAttribute("data-index", String(index));
|
|
7765
|
+
$item.onclick = () => this.openGrp(index);
|
|
7762
7766
|
this.$grpSwitcher.append($item);
|
|
7763
7767
|
});
|
|
7764
7768
|
}
|
|
@@ -7766,18 +7770,18 @@ class Emoticons extends EditorPlug {
|
|
|
7766
7770
|
this.openGrp(0);
|
|
7767
7771
|
}
|
|
7768
7772
|
/** 打开一个表情组 */
|
|
7769
|
-
openGrp(
|
|
7773
|
+
openGrp(index) {
|
|
7770
7774
|
var _a, _b, _c;
|
|
7771
7775
|
Array.from(this.$grpWrap.children).forEach((item) => {
|
|
7772
7776
|
const el = item;
|
|
7773
|
-
if (el.getAttribute("data-index") !== String(
|
|
7777
|
+
if (el.getAttribute("data-index") !== String(index)) {
|
|
7774
7778
|
el.style.display = "none";
|
|
7775
7779
|
} else {
|
|
7776
7780
|
el.style.display = "";
|
|
7777
7781
|
}
|
|
7778
7782
|
});
|
|
7779
7783
|
(_a = this.$grpSwitcher) == null ? void 0 : _a.querySelectorAll("span.active").forEach((item) => item.classList.remove("active"));
|
|
7780
|
-
(_c = (_b = this.$grpSwitcher) == null ? void 0 : _b.querySelector(`span[data-index="${
|
|
7784
|
+
(_c = (_b = this.$grpSwitcher) == null ? void 0 : _b.querySelector(`span[data-index="${index}"]`)) == null ? void 0 : _c.classList.add("active");
|
|
7781
7785
|
this.changeListHeight();
|
|
7782
7786
|
}
|
|
7783
7787
|
changeListHeight() {
|
|
@@ -7789,7 +7793,7 @@ class Emoticons extends EditorPlug {
|
|
|
7789
7793
|
this.emoticons.forEach((grp) => {
|
|
7790
7794
|
if (grp.type !== "image")
|
|
7791
7795
|
return;
|
|
7792
|
-
Object.entries(grp.items).forEach(([
|
|
7796
|
+
Object.entries(grp.items).forEach(([index, item]) => {
|
|
7793
7797
|
text = text.split(`:[${item.key}]`).join(`<img src="${item.val}" atk-emoticon="${item.key}">`);
|
|
7794
7798
|
});
|
|
7795
7799
|
});
|
|
@@ -7872,7 +7876,7 @@ class Upload extends EditorPlug {
|
|
|
7872
7876
|
const fileExt = /[^.]+$/.exec(file.name);
|
|
7873
7877
|
if (!fileExt || !AllowImgExts.includes(fileExt[0]))
|
|
7874
7878
|
return;
|
|
7875
|
-
if (!
|
|
7879
|
+
if (!this.kit.useUser().checkHasBasicUserInfo()) {
|
|
7876
7880
|
this.kit.useEditor().showNotify(t("uploadLoginMsg"), "w");
|
|
7877
7881
|
return;
|
|
7878
7882
|
}
|
|
@@ -7907,7 +7911,6 @@ class Upload extends EditorPlug {
|
|
|
7907
7911
|
});
|
|
7908
7912
|
}
|
|
7909
7913
|
}
|
|
7910
|
-
const preview = "";
|
|
7911
7914
|
class Preview extends EditorPlug {
|
|
7912
7915
|
constructor(kit) {
|
|
7913
7916
|
super(kit);
|
|
@@ -7970,7 +7973,11 @@ class PlugKit {
|
|
|
7970
7973
|
useEditor() {
|
|
7971
7974
|
return this.plugs.editor;
|
|
7972
7975
|
}
|
|
7973
|
-
/**
|
|
7976
|
+
/**
|
|
7977
|
+
* Use the context of global
|
|
7978
|
+
*
|
|
7979
|
+
* @deprecated The calls to this function should be reduced as much as possible
|
|
7980
|
+
*/
|
|
7974
7981
|
useGlobalCtx() {
|
|
7975
7982
|
return this.plugs.editor.ctx;
|
|
7976
7983
|
}
|
|
@@ -7982,6 +7989,10 @@ class PlugKit {
|
|
|
7982
7989
|
useApi() {
|
|
7983
7990
|
return this.plugs.editor.ctx.getApi();
|
|
7984
7991
|
}
|
|
7992
|
+
/** Use the user manager */
|
|
7993
|
+
useUser() {
|
|
7994
|
+
return this.plugs.editor.ctx.get("user");
|
|
7995
|
+
}
|
|
7985
7996
|
/** Use the ui of editor */
|
|
7986
7997
|
useUI() {
|
|
7987
7998
|
return this.plugs.editor.getUI();
|
|
@@ -8199,7 +8210,7 @@ const SidebarBtn = (ctx) => {
|
|
|
8199
8210
|
const syncByUser = () => {
|
|
8200
8211
|
if (!$openSidebarBtn)
|
|
8201
8212
|
return;
|
|
8202
|
-
const user = ctx.get("user").
|
|
8213
|
+
const user = ctx.get("user").getData();
|
|
8203
8214
|
if (!!user.nick && !!user.email) {
|
|
8204
8215
|
$openSidebarBtn.classList.remove("atk-hide");
|
|
8205
8216
|
const $btnText = $openSidebarBtn.querySelector(".atk-text");
|
|
@@ -8298,7 +8309,7 @@ function extractCommentID() {
|
|
|
8298
8309
|
}
|
|
8299
8310
|
return commentId || null;
|
|
8300
8311
|
}
|
|
8301
|
-
const version = "2.7.
|
|
8312
|
+
const version = "2.7.3";
|
|
8302
8313
|
const Copyright = (ctx) => {
|
|
8303
8314
|
ctx.on("conf-loaded", () => {
|
|
8304
8315
|
const list = ctx.get("list");
|
|
@@ -8631,7 +8642,7 @@ function versionCheck(list, feVer, beVer) {
|
|
|
8631
8642
|
}
|
|
8632
8643
|
const AdminOnlyElem = (ctx) => {
|
|
8633
8644
|
const scanApply = () => {
|
|
8634
|
-
applyAdminOnlyEls(ctx.get("user").
|
|
8645
|
+
applyAdminOnlyEls(ctx.get("user").getData().isAdmin, getAdminOnlyEls({
|
|
8635
8646
|
$root: ctx.$root
|
|
8636
8647
|
}));
|
|
8637
8648
|
};
|
|
@@ -8658,38 +8669,44 @@ function applyAdminOnlyEls(isAdmin, els) {
|
|
|
8658
8669
|
$item.classList.add("atk-hide");
|
|
8659
8670
|
});
|
|
8660
8671
|
}
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
darkModeMedia.addEventListener("change", darkModeAutoFunc);
|
|
8671
|
-
}
|
|
8672
|
-
apply(darkModeMedia.matches);
|
|
8673
|
-
} else {
|
|
8674
|
-
if (darkModeAutoFunc)
|
|
8675
|
-
darkModeMedia.removeEventListener("change", darkModeAutoFunc);
|
|
8676
|
-
apply(darkMode);
|
|
8677
|
-
}
|
|
8678
|
-
}
|
|
8679
|
-
const DarkModeClassName = "atk-dark-mode";
|
|
8680
|
-
function updateClassName($el, darkMode) {
|
|
8681
|
-
if (darkMode)
|
|
8682
|
-
$el.classList.add(DarkModeClassName);
|
|
8683
|
-
else
|
|
8684
|
-
$el.classList.remove(DarkModeClassName);
|
|
8672
|
+
let darkModeMedia;
|
|
8673
|
+
function updateClassnames($els, darkMode) {
|
|
8674
|
+
const DarkModeClassName = "atk-dark-mode";
|
|
8675
|
+
$els.forEach(($el) => {
|
|
8676
|
+
if (darkMode)
|
|
8677
|
+
$el.classList.add(DarkModeClassName);
|
|
8678
|
+
else
|
|
8679
|
+
$el.classList.remove(DarkModeClassName);
|
|
8680
|
+
});
|
|
8685
8681
|
}
|
|
8686
8682
|
const DarkMode = (ctx) => {
|
|
8687
|
-
|
|
8688
|
-
|
|
8683
|
+
let darkModeAutoHandler;
|
|
8684
|
+
const sync = (darkMode) => {
|
|
8685
|
+
const $els = [ctx.$root, ctx.get("layerManager").getEl()];
|
|
8686
|
+
if (!darkModeMedia) {
|
|
8687
|
+
darkModeMedia = window.matchMedia("(prefers-color-scheme: dark)");
|
|
8688
|
+
}
|
|
8689
|
+
if (darkMode === "auto") {
|
|
8690
|
+
if (!darkModeAutoHandler) {
|
|
8691
|
+
darkModeAutoHandler = (evt) => updateClassnames($els, evt.matches);
|
|
8692
|
+
darkModeMedia.addEventListener("change", darkModeAutoHandler);
|
|
8693
|
+
}
|
|
8694
|
+
updateClassnames($els, darkModeMedia.matches);
|
|
8695
|
+
} else {
|
|
8696
|
+
if (darkModeAutoHandler) {
|
|
8697
|
+
darkModeMedia.removeEventListener("change", darkModeAutoHandler);
|
|
8698
|
+
darkModeAutoHandler = void 0;
|
|
8699
|
+
}
|
|
8700
|
+
updateClassnames($els, darkMode);
|
|
8701
|
+
}
|
|
8689
8702
|
};
|
|
8690
|
-
ctx.on("inited", () => sync());
|
|
8691
|
-
ctx.on("conf-loaded", () => sync());
|
|
8692
|
-
ctx.on("dark-mode-changed", () => sync());
|
|
8703
|
+
ctx.on("inited", () => sync(ctx.conf.darkMode));
|
|
8704
|
+
ctx.on("conf-loaded", (conf) => sync(conf.darkMode));
|
|
8705
|
+
ctx.on("dark-mode-changed", (darkMode) => sync(darkMode));
|
|
8706
|
+
ctx.on("destroy", () => {
|
|
8707
|
+
darkModeAutoHandler && (darkModeMedia == null ? void 0 : darkModeMedia.removeEventListener("change", darkModeAutoHandler));
|
|
8708
|
+
darkModeAutoHandler = void 0;
|
|
8709
|
+
});
|
|
8693
8710
|
};
|
|
8694
8711
|
const DefaultPlugins = [
|
|
8695
8712
|
ConfRemoter,
|
|
@@ -8704,15 +8721,11 @@ const DefaultPlugins = [
|
|
|
8704
8721
|
const GlobalPlugins = [...DefaultPlugins];
|
|
8705
8722
|
class Artalk {
|
|
8706
8723
|
constructor(conf) {
|
|
8707
|
-
__publicField(this, "conf");
|
|
8708
8724
|
__publicField(this, "ctx");
|
|
8709
|
-
__publicField(this, "$root");
|
|
8710
8725
|
/** Plugins */
|
|
8711
8726
|
__publicField(this, "plugins", [...GlobalPlugins]);
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
this.$root = this.conf.el;
|
|
8715
|
-
this.ctx = new Context(this.conf, this.$root);
|
|
8727
|
+
const handledConf = handelCustomConf(conf, true);
|
|
8728
|
+
this.ctx = new Context(handledConf);
|
|
8716
8729
|
Object.entries(services).forEach(([name, initService]) => {
|
|
8717
8730
|
const obj = initService(this.ctx);
|
|
8718
8731
|
if (obj)
|
|
@@ -8724,6 +8737,14 @@ class Artalk {
|
|
|
8724
8737
|
});
|
|
8725
8738
|
this.ctx.trigger("inited");
|
|
8726
8739
|
}
|
|
8740
|
+
/** Get the config of Artalk */
|
|
8741
|
+
getConf() {
|
|
8742
|
+
return this.ctx.getConf();
|
|
8743
|
+
}
|
|
8744
|
+
/** Get the root element of Artalk */
|
|
8745
|
+
getEl() {
|
|
8746
|
+
return this.ctx.$root;
|
|
8747
|
+
}
|
|
8727
8748
|
/** Update config of Artalk */
|
|
8728
8749
|
update(conf) {
|
|
8729
8750
|
this.ctx.updateConf(conf);
|
|
@@ -8736,7 +8757,7 @@ class Artalk {
|
|
|
8736
8757
|
/** Destroy instance of Artalk */
|
|
8737
8758
|
destroy() {
|
|
8738
8759
|
this.ctx.trigger("destroy");
|
|
8739
|
-
this.$root.remove();
|
|
8760
|
+
this.ctx.$root.remove();
|
|
8740
8761
|
}
|
|
8741
8762
|
/** Add an event listener */
|
|
8742
8763
|
on(name, handler) {
|
|
@@ -8769,7 +8790,7 @@ class Artalk {
|
|
|
8769
8790
|
}
|
|
8770
8791
|
/** Load count widget */
|
|
8771
8792
|
static loadCountWidget(c) {
|
|
8772
|
-
const conf = handelCustomConf(c);
|
|
8793
|
+
const conf = handelCustomConf(c, true);
|
|
8773
8794
|
initCountWidget({
|
|
8774
8795
|
getApi: () => new Api(convertApiOptions(conf)),
|
|
8775
8796
|
pageKey: conf.pageKey,
|
|
@@ -8778,18 +8799,25 @@ class Artalk {
|
|
|
8778
8799
|
pvAdd: false
|
|
8779
8800
|
});
|
|
8780
8801
|
}
|
|
8802
|
+
// ===========================
|
|
8803
|
+
// Deprecated
|
|
8804
|
+
// ===========================
|
|
8805
|
+
/** @deprecated Please use `getEl()` instead */
|
|
8806
|
+
get $root() {
|
|
8807
|
+
return this.ctx.$root;
|
|
8808
|
+
}
|
|
8809
|
+
/** @description Please use `getConf()` instead */
|
|
8810
|
+
get conf() {
|
|
8811
|
+
return this.ctx.getConf();
|
|
8812
|
+
}
|
|
8781
8813
|
}
|
|
8782
|
-
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
8783
|
-
__proto__: null
|
|
8784
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
8785
8814
|
const init = Artalk.init;
|
|
8786
8815
|
const use = Artalk.use;
|
|
8787
8816
|
const loadCountWidget = Artalk.loadCountWidget;
|
|
8788
8817
|
export {
|
|
8789
|
-
index as ArtalkType,
|
|
8790
8818
|
Artalk as default,
|
|
8791
8819
|
init,
|
|
8792
8820
|
loadCountWidget,
|
|
8793
8821
|
use
|
|
8794
8822
|
};
|
|
8795
|
-
//# sourceMappingURL=Artalk.
|
|
8823
|
+
//# sourceMappingURL=Artalk.mjs.map
|