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
|
@@ -42,7 +42,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
44
|
import { marked as marked$1 } from "marked";
|
|
45
|
-
const main = "";
|
|
46
45
|
function createElement(htmlStr = "") {
|
|
47
46
|
const div = document.createElement("div");
|
|
48
47
|
div.innerHTML = htmlStr.trim();
|
|
@@ -211,24 +210,6 @@ function getURLBasedOnApi(opts) {
|
|
|
211
210
|
function getURLBasedOn(baseURL, path) {
|
|
212
211
|
return `${baseURL.replace(/\/$/, "")}/${path.replace(/^\//, "")}`;
|
|
213
212
|
}
|
|
214
|
-
function mergeDeep(target, source) {
|
|
215
|
-
const isObject = (obj) => obj && typeof obj === "object";
|
|
216
|
-
if (!isObject(target) || !isObject(source)) {
|
|
217
|
-
return source;
|
|
218
|
-
}
|
|
219
|
-
Object.keys(source).forEach((key) => {
|
|
220
|
-
const targetValue = target[key];
|
|
221
|
-
const sourceValue = source[key];
|
|
222
|
-
if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
|
|
223
|
-
target[key] = targetValue.concat(sourceValue);
|
|
224
|
-
} else if (isObject(targetValue) && isObject(sourceValue)) {
|
|
225
|
-
target[key] = mergeDeep(__spreadValues({}, targetValue), sourceValue);
|
|
226
|
-
} else {
|
|
227
|
-
target[key] = sourceValue;
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
return target;
|
|
231
|
-
}
|
|
232
213
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
233
214
|
function getDefaultExportFromCjs(x) {
|
|
234
215
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -629,48 +610,6 @@ function getDefaultExportFromCjs(x) {
|
|
|
629
610
|
});
|
|
630
611
|
})(typeof self !== "undefined" ? self : commonjsGlobal);
|
|
631
612
|
});
|
|
632
|
-
const LOCAL_USER_KEY = "ArtalkUser";
|
|
633
|
-
class User {
|
|
634
|
-
constructor() {
|
|
635
|
-
__publicField(this, "data");
|
|
636
|
-
__publicField(this, "onUserChanged", null);
|
|
637
|
-
const localUser = JSON.parse(window.localStorage.getItem(LOCAL_USER_KEY) || "{}");
|
|
638
|
-
this.data = {
|
|
639
|
-
nick: localUser.nick || "",
|
|
640
|
-
email: localUser.email || "",
|
|
641
|
-
link: localUser.link || "",
|
|
642
|
-
token: localUser.token || "",
|
|
643
|
-
isAdmin: localUser.isAdmin || false
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
/** 保存用户到 localStorage 中 */
|
|
647
|
-
update(obj = {}) {
|
|
648
|
-
Object.entries(obj).forEach(([key, value]) => {
|
|
649
|
-
this.data[key] = value;
|
|
650
|
-
});
|
|
651
|
-
window.localStorage.setItem(LOCAL_USER_KEY, JSON.stringify(this.data));
|
|
652
|
-
this.onUserChanged && this.onUserChanged(this.data);
|
|
653
|
-
}
|
|
654
|
-
setOnUserChanged(fn) {
|
|
655
|
-
this.onUserChanged = fn;
|
|
656
|
-
}
|
|
657
|
-
/**
|
|
658
|
-
* Logout
|
|
659
|
-
*
|
|
660
|
-
* @description Logout will clear login status, but not clear user data (nick, email, link)
|
|
661
|
-
*/
|
|
662
|
-
logout() {
|
|
663
|
-
this.update({
|
|
664
|
-
token: "",
|
|
665
|
-
isAdmin: false
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
/** 是否已填写基本用户信息 */
|
|
669
|
-
checkHasBasicUserInfo() {
|
|
670
|
-
return !!this.data.nick && !!this.data.email;
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
const UserInstance = new User();
|
|
674
613
|
const en = {
|
|
675
614
|
/* Editor */
|
|
676
615
|
placeholder: "Leave a comment",
|
|
@@ -747,7 +686,8 @@ const en = {
|
|
|
747
686
|
reqAborted: "Request timed out or terminated unexpectedly",
|
|
748
687
|
updateMsg: "Please update Artalk {name} to get the full experience",
|
|
749
688
|
currentVersion: "Current Version",
|
|
750
|
-
ignore: "Ignore"
|
|
689
|
+
ignore: "Ignore",
|
|
690
|
+
open: "Open"
|
|
751
691
|
};
|
|
752
692
|
const zhCN = {
|
|
753
693
|
/* Editor */
|
|
@@ -825,7 +765,8 @@ const zhCN = {
|
|
|
825
765
|
reqAborted: "请求超时或意外终止",
|
|
826
766
|
updateMsg: "请更新 Artalk {name} 以获得完整体验",
|
|
827
767
|
currentVersion: "当前版本",
|
|
828
|
-
ignore: "忽略"
|
|
768
|
+
ignore: "忽略",
|
|
769
|
+
open: "打开"
|
|
829
770
|
};
|
|
830
771
|
const GLOBAL_LOCALES_KEY = "ArtalkI18n";
|
|
831
772
|
const internal = {
|
|
@@ -862,9 +803,9 @@ function t(key, args = {}) {
|
|
|
862
803
|
function Fetch$1(opts, input, init2, timeout) {
|
|
863
804
|
return __async(this, null, function* () {
|
|
864
805
|
var _a, _b;
|
|
865
|
-
if (
|
|
806
|
+
if (opts.apiToken) {
|
|
866
807
|
const headers = new Headers(init2.headers);
|
|
867
|
-
headers.set("Authorization", `Bearer ${
|
|
808
|
+
headers.set("Authorization", `Bearer ${opts.apiToken}`);
|
|
868
809
|
init2.headers = headers;
|
|
869
810
|
}
|
|
870
811
|
const resp = yield timeoutFetch(input, timeout || opts.timeout || 15e3, init2);
|
|
@@ -956,6 +897,20 @@ class ApiBase {
|
|
|
956
897
|
return Fetch$1(this.options, this.options.baseURL + path, init2, timeout);
|
|
957
898
|
});
|
|
958
899
|
}
|
|
900
|
+
/**
|
|
901
|
+
* Carry user info to request params
|
|
902
|
+
*
|
|
903
|
+
* @param params Request params
|
|
904
|
+
* @returns Request params with user info
|
|
905
|
+
*/
|
|
906
|
+
withUserInfo(params) {
|
|
907
|
+
const user = this.options.userInfo;
|
|
908
|
+
if (user == null ? void 0 : user.name)
|
|
909
|
+
params.name = user.name;
|
|
910
|
+
if (user == null ? void 0 : user.email)
|
|
911
|
+
params.email = user.email;
|
|
912
|
+
return params;
|
|
913
|
+
}
|
|
959
914
|
}
|
|
960
915
|
class CommentApi extends ApiBase {
|
|
961
916
|
/** 评论 · 获取 */
|
|
@@ -968,10 +923,7 @@ class CommentApi extends ApiBase {
|
|
|
968
923
|
};
|
|
969
924
|
if (flatMode)
|
|
970
925
|
params.flat_mode = flatMode;
|
|
971
|
-
|
|
972
|
-
params.name = UserInstance.data.nick;
|
|
973
|
-
params.email = UserInstance.data.email;
|
|
974
|
-
}
|
|
926
|
+
this.withUserInfo(params);
|
|
975
927
|
if (paramsEditor)
|
|
976
928
|
paramsEditor(params);
|
|
977
929
|
return this.POST("/get", params);
|
|
@@ -1020,10 +972,7 @@ class CommentApi extends ApiBase {
|
|
|
1020
972
|
target_id: targetID,
|
|
1021
973
|
type
|
|
1022
974
|
};
|
|
1023
|
-
|
|
1024
|
-
params.name = UserInstance.data.nick;
|
|
1025
|
-
params.email = UserInstance.data.email;
|
|
1026
|
-
}
|
|
975
|
+
this.withUserInfo(params);
|
|
1027
976
|
const data = yield this.POST("/vote", params);
|
|
1028
977
|
return data;
|
|
1029
978
|
});
|
|
@@ -1192,10 +1141,7 @@ class UserApi extends ApiBase {
|
|
|
1192
1141
|
/** 用户 · 登录状态 */
|
|
1193
1142
|
loginStatus() {
|
|
1194
1143
|
return __async(this, null, function* () {
|
|
1195
|
-
const data = yield this.POST("/login-status", {
|
|
1196
|
-
name: UserInstance.data.nick,
|
|
1197
|
-
email: UserInstance.data.email
|
|
1198
|
-
});
|
|
1144
|
+
const data = yield this.POST("/login-status", this.withUserInfo({}));
|
|
1199
1145
|
return data || { is_login: false, is_admin: false };
|
|
1200
1146
|
});
|
|
1201
1147
|
}
|
|
@@ -1215,8 +1161,7 @@ class UserApi extends ApiBase {
|
|
|
1215
1161
|
delete params.comment_id;
|
|
1216
1162
|
delete params.notify_key;
|
|
1217
1163
|
params.read_all = true;
|
|
1218
|
-
params
|
|
1219
|
-
params.email = UserInstance.data.email;
|
|
1164
|
+
this.withUserInfo(params);
|
|
1220
1165
|
}
|
|
1221
1166
|
return this.POST(`/mark-read`, params);
|
|
1222
1167
|
}
|
|
@@ -1353,10 +1298,9 @@ class UploadApi extends ApiBase {
|
|
|
1353
1298
|
imgUpload(file) {
|
|
1354
1299
|
return __async(this, null, function* () {
|
|
1355
1300
|
const params = {
|
|
1356
|
-
name: UserInstance.data.nick,
|
|
1357
|
-
email: UserInstance.data.email,
|
|
1358
1301
|
page_key: this.options.pageKey
|
|
1359
1302
|
};
|
|
1303
|
+
this.withUserInfo(params);
|
|
1360
1304
|
const form = ToFormData(params);
|
|
1361
1305
|
form.set("file", file);
|
|
1362
1306
|
const init2 = {
|
|
@@ -1513,12 +1457,12 @@ function parser$1(html, handler) {
|
|
|
1513
1457
|
}
|
|
1514
1458
|
}
|
|
1515
1459
|
function parseComment() {
|
|
1516
|
-
var
|
|
1517
|
-
if (
|
|
1460
|
+
var index = html.indexOf("-->");
|
|
1461
|
+
if (index >= 0) {
|
|
1518
1462
|
if (handler.comment) {
|
|
1519
|
-
handler.comment(html.substring(4,
|
|
1463
|
+
handler.comment(html.substring(4, index));
|
|
1520
1464
|
}
|
|
1521
|
-
html = html.substring(
|
|
1465
|
+
html = html.substring(index + 3);
|
|
1522
1466
|
chars = false;
|
|
1523
1467
|
}
|
|
1524
1468
|
}
|
|
@@ -1527,10 +1471,10 @@ function parser$1(html, handler) {
|
|
|
1527
1471
|
return;
|
|
1528
1472
|
}
|
|
1529
1473
|
var text;
|
|
1530
|
-
var
|
|
1531
|
-
if (
|
|
1532
|
-
text = html.substring(0,
|
|
1533
|
-
html = html.substring(
|
|
1474
|
+
var index = html.indexOf("<");
|
|
1475
|
+
if (index >= 0) {
|
|
1476
|
+
text = html.substring(0, index);
|
|
1477
|
+
html = html.substring(index);
|
|
1534
1478
|
} else {
|
|
1535
1479
|
text = html;
|
|
1536
1480
|
html = "";
|
|
@@ -1881,13 +1825,13 @@ var hanabi$1 = { exports: {} };
|
|
|
1881
1825
|
};
|
|
1882
1826
|
});
|
|
1883
1827
|
var defaultColors = ["23AC69", "91C132", "F19726", "E8552D", "1AAB8E", "E1147F", "2980C1", "1BA1E6", "9FA0A0", "F19726", "E30B20", "E30B20", "A3338B"];
|
|
1884
|
-
var
|
|
1828
|
+
var index = function(input, ref) {
|
|
1885
1829
|
if (ref === void 0)
|
|
1886
1830
|
ref = {};
|
|
1887
1831
|
var colors = ref.colors;
|
|
1888
1832
|
if (colors === void 0)
|
|
1889
1833
|
colors = defaultColors;
|
|
1890
|
-
var
|
|
1834
|
+
var index2 = 0;
|
|
1891
1835
|
var cache = {};
|
|
1892
1836
|
var wordRe = /[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/;
|
|
1893
1837
|
var leftAngleRe = /</;
|
|
@@ -1903,18 +1847,18 @@ var hanabi$1 = { exports: {} };
|
|
|
1903
1847
|
if (cache[word]) {
|
|
1904
1848
|
color = cache[word];
|
|
1905
1849
|
} else {
|
|
1906
|
-
color = colors[
|
|
1850
|
+
color = colors[index2];
|
|
1907
1851
|
cache[word] = color;
|
|
1908
1852
|
}
|
|
1909
1853
|
var out = '<span style="color: #' + color + '">' + word + "</span>";
|
|
1910
|
-
|
|
1854
|
+
index2 = ++index2 % colors.length;
|
|
1911
1855
|
return out;
|
|
1912
1856
|
});
|
|
1913
1857
|
};
|
|
1914
1858
|
function toComment(cm) {
|
|
1915
1859
|
return '<span style="color: slategray">' + cm + "</span>";
|
|
1916
1860
|
}
|
|
1917
|
-
return
|
|
1861
|
+
return index;
|
|
1918
1862
|
});
|
|
1919
1863
|
})(hanabi$1);
|
|
1920
1864
|
var hanabiExports = hanabi$1.exports;
|
|
@@ -1993,6 +1937,26 @@ function marked(src) {
|
|
|
1993
1937
|
function simpleMarked(src) {
|
|
1994
1938
|
return src.replace(/```\s*([^]+?.*?[^]+?[^]+?)```/g, (_, code) => `<pre><code>${renderCode(code)}</code></pre>`).replace(/!\[(.*?)\]\((.*?)\)/g, (_, alt, imgSrc) => `<img src="${imgSrc}" alt="${alt}" />`).replace(/\[(.*?)\]\((.*?)\)/g, (_, text, link) => `<a href="${link}" target="_blank">${text}</a>`).replace(/\n/g, "<br>");
|
|
1995
1939
|
}
|
|
1940
|
+
function mergeDeep(...objects) {
|
|
1941
|
+
const isObject = (obj) => obj && typeof obj === "object" && obj.constructor === Object;
|
|
1942
|
+
return objects.reduce((prev, obj) => {
|
|
1943
|
+
Object.keys(obj != null ? obj : {}).forEach((key) => {
|
|
1944
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
1945
|
+
return;
|
|
1946
|
+
}
|
|
1947
|
+
const pVal = prev[key];
|
|
1948
|
+
const oVal = obj[key];
|
|
1949
|
+
if (Array.isArray(pVal) && Array.isArray(oVal)) {
|
|
1950
|
+
prev[key] = pVal.concat(...oVal);
|
|
1951
|
+
} else if (isObject(pVal) && isObject(oVal)) {
|
|
1952
|
+
prev[key] = mergeDeep(pVal, oVal);
|
|
1953
|
+
} else {
|
|
1954
|
+
prev[key] = oVal;
|
|
1955
|
+
}
|
|
1956
|
+
});
|
|
1957
|
+
return prev;
|
|
1958
|
+
}, {});
|
|
1959
|
+
}
|
|
1996
1960
|
class DataManager {
|
|
1997
1961
|
constructor(events) {
|
|
1998
1962
|
__publicField(this, "loading", false);
|
|
@@ -2150,16 +2114,9 @@ const defaults = {
|
|
|
2150
2114
|
useBackendConf: true,
|
|
2151
2115
|
locale: "zh-CN"
|
|
2152
2116
|
};
|
|
2153
|
-
{
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
defaults.emoticons = false;
|
|
2157
|
-
}
|
|
2158
|
-
function handelCustomConf(customConf) {
|
|
2159
|
-
const conf = mergeDeep(defaults, customConf);
|
|
2160
|
-
if (customConf.el)
|
|
2161
|
-
conf.el = customConf.el;
|
|
2162
|
-
if (typeof conf.el === "string" && !!conf.el) {
|
|
2117
|
+
function handelCustomConf(customConf, full = false) {
|
|
2118
|
+
const conf = full ? mergeDeep(defaults, customConf) : customConf;
|
|
2119
|
+
if (conf.el && typeof conf.el === "string") {
|
|
2163
2120
|
try {
|
|
2164
2121
|
const findEl = document.querySelector(conf.el);
|
|
2165
2122
|
if (!findEl)
|
|
@@ -2170,20 +2127,18 @@ function handelCustomConf(customConf) {
|
|
|
2170
2127
|
throw new Error("Please check your Artalk `el` config.");
|
|
2171
2128
|
}
|
|
2172
2129
|
}
|
|
2173
|
-
|
|
2174
|
-
if (!conf.pageKey) {
|
|
2130
|
+
if (conf.pageKey === "")
|
|
2175
2131
|
conf.pageKey = `${window.location.pathname}`;
|
|
2176
|
-
|
|
2177
|
-
if (!conf.pageTitle) {
|
|
2132
|
+
if (conf.pageTitle === "")
|
|
2178
2133
|
conf.pageTitle = `${document.title}`;
|
|
2179
|
-
|
|
2180
|
-
|
|
2134
|
+
if (conf.server)
|
|
2135
|
+
conf.server = conf.server.replace(/\/$/, "").replace(/\/api\/?$/, "");
|
|
2136
|
+
if (conf.locale === "auto")
|
|
2181
2137
|
conf.locale = navigator.language;
|
|
2182
|
-
}
|
|
2183
|
-
if (conf.flatMode === true || Number(conf.nestMax) <= 1)
|
|
2184
|
-
conf.flatMode = true;
|
|
2185
2138
|
if (conf.flatMode === "auto")
|
|
2186
2139
|
conf.flatMode = window.matchMedia("(max-width: 768px)").matches;
|
|
2140
|
+
if (typeof conf.nestMax === "number" && Number(conf.nestMax) <= 1)
|
|
2141
|
+
conf.flatMode = true;
|
|
2187
2142
|
return conf;
|
|
2188
2143
|
}
|
|
2189
2144
|
function handleConfFormServer(conf) {
|
|
@@ -2216,6 +2171,11 @@ function convertApiOptions(conf, ctx) {
|
|
|
2216
2171
|
pageKey: conf.pageKey || "",
|
|
2217
2172
|
pageTitle: conf.pageTitle || "",
|
|
2218
2173
|
timeout: conf.reqTimeout,
|
|
2174
|
+
apiToken: ctx == null ? void 0 : ctx.get("user").getData().token,
|
|
2175
|
+
userInfo: (ctx == null ? void 0 : ctx.get("user").checkHasBasicUserInfo()) ? {
|
|
2176
|
+
name: ctx == null ? void 0 : ctx.get("user").getData().nick,
|
|
2177
|
+
email: ctx == null ? void 0 : ctx.get("user").getData().email
|
|
2178
|
+
} : void 0,
|
|
2219
2179
|
onNeedCheckAdmin(payload) {
|
|
2220
2180
|
ctx == null ? void 0 : ctx.checkAdmin({
|
|
2221
2181
|
onSuccess: () => {
|
|
@@ -2241,7 +2201,7 @@ function convertApiOptions(conf, ctx) {
|
|
|
2241
2201
|
};
|
|
2242
2202
|
}
|
|
2243
2203
|
class Context {
|
|
2244
|
-
constructor(conf
|
|
2204
|
+
constructor(conf) {
|
|
2245
2205
|
/* 运行参数 */
|
|
2246
2206
|
__publicField(this, "conf");
|
|
2247
2207
|
__publicField(this, "data");
|
|
@@ -2249,7 +2209,7 @@ class Context {
|
|
|
2249
2209
|
/* Event Manager */
|
|
2250
2210
|
__publicField(this, "events", new EventManager());
|
|
2251
2211
|
this.conf = conf;
|
|
2252
|
-
this.$root =
|
|
2212
|
+
this.$root = conf.el;
|
|
2253
2213
|
this.$root.classList.add("artalk");
|
|
2254
2214
|
this.$root.innerHTML = "";
|
|
2255
2215
|
this.data = new DataManager(this.events);
|
|
@@ -2279,7 +2239,7 @@ class Context {
|
|
|
2279
2239
|
this.data.fetchComments({ offset: 0 });
|
|
2280
2240
|
}
|
|
2281
2241
|
listGotoFirst() {
|
|
2282
|
-
this.trigger("list-goto-first");
|
|
2242
|
+
this.events.trigger("list-goto-first");
|
|
2283
2243
|
}
|
|
2284
2244
|
/* 编辑器 */
|
|
2285
2245
|
editorShowLoading() {
|
|
@@ -2324,11 +2284,17 @@ class Context {
|
|
|
2324
2284
|
}
|
|
2325
2285
|
setDarkMode(darkMode) {
|
|
2326
2286
|
this.conf.darkMode = darkMode;
|
|
2327
|
-
this.trigger("dark-mode-changed", darkMode);
|
|
2287
|
+
this.events.trigger("dark-mode-changed", darkMode);
|
|
2328
2288
|
}
|
|
2329
2289
|
updateConf(nConf) {
|
|
2330
|
-
this.conf = mergeDeep(this.conf, handelCustomConf(nConf));
|
|
2331
|
-
this.trigger("conf-loaded", this.conf);
|
|
2290
|
+
this.conf = mergeDeep(this.conf, handelCustomConf(nConf, false));
|
|
2291
|
+
this.events.trigger("conf-loaded", this.conf);
|
|
2292
|
+
}
|
|
2293
|
+
getConf() {
|
|
2294
|
+
return this.conf;
|
|
2295
|
+
}
|
|
2296
|
+
getEl() {
|
|
2297
|
+
return this.$root;
|
|
2332
2298
|
}
|
|
2333
2299
|
getMarked() {
|
|
2334
2300
|
return getInstance();
|
|
@@ -2535,7 +2501,7 @@ function imgBody(checker) {
|
|
|
2535
2501
|
}
|
|
2536
2502
|
function iframeBody(checker) {
|
|
2537
2503
|
const $iframeWrap = createElement(`<div class="atk-checker-iframe-wrap"></div>`);
|
|
2538
|
-
const $iframe = createElement(`<iframe class="atk-fade-in"></iframe>`);
|
|
2504
|
+
const $iframe = createElement(`<iframe class="atk-fade-in" referrerpolicy="strict-origin-when-cross-origin"></iframe>`);
|
|
2539
2505
|
$iframe.style.display = "none";
|
|
2540
2506
|
showLoading($iframeWrap, { transparentBg: true });
|
|
2541
2507
|
$iframe.src = `${checker.getOpts().getIframeURLBase() || ""}/api/captcha/get?t=${+/* @__PURE__ */ new Date()}`;
|
|
@@ -2599,8 +2565,8 @@ const AdminChecker = {
|
|
|
2599
2565
|
inputType: "password",
|
|
2600
2566
|
request(checker, inputVal) {
|
|
2601
2567
|
const data = {
|
|
2602
|
-
name:
|
|
2603
|
-
email:
|
|
2568
|
+
name: checker.getUser().getData().nick,
|
|
2569
|
+
email: checker.getUser().getData().email,
|
|
2604
2570
|
password: inputVal
|
|
2605
2571
|
};
|
|
2606
2572
|
return (() => __async(this, null, function* () {
|
|
@@ -2612,7 +2578,7 @@ const AdminChecker = {
|
|
|
2612
2578
|
return createElement(`<span>${t("adminCheck")}</span>`);
|
|
2613
2579
|
},
|
|
2614
2580
|
onSuccess(checker, userToken, inputVal, formEl) {
|
|
2615
|
-
|
|
2581
|
+
checker.getUser().update({
|
|
2616
2582
|
isAdmin: true,
|
|
2617
2583
|
token: userToken
|
|
2618
2584
|
});
|
|
@@ -2645,6 +2611,7 @@ class CheckerLauncher {
|
|
|
2645
2611
|
},
|
|
2646
2612
|
get: (key) => checkerStore[key],
|
|
2647
2613
|
getOpts: () => this.opts,
|
|
2614
|
+
getUser: () => this.opts.getCtx().get("user"),
|
|
2648
2615
|
getApi: () => this.opts.getApi(),
|
|
2649
2616
|
hideInteractInput: () => {
|
|
2650
2617
|
hideInteractInput = true;
|
|
@@ -3036,7 +3003,7 @@ class SidebarLayer extends Component {
|
|
|
3036
3003
|
});
|
|
3037
3004
|
}
|
|
3038
3005
|
createIframe(view) {
|
|
3039
|
-
const $iframe = createElement(
|
|
3006
|
+
const $iframe = createElement('<iframe referrerpolicy="strict-origin-when-cross-origin"></iframe>');
|
|
3040
3007
|
const baseURL = getURLBasedOnApi({
|
|
3041
3008
|
base: this.ctx.conf.server,
|
|
3042
3009
|
path: "/sidebar/"
|
|
@@ -3044,7 +3011,7 @@ class SidebarLayer extends Component {
|
|
|
3044
3011
|
const query = {
|
|
3045
3012
|
pageKey: this.conf.pageKey,
|
|
3046
3013
|
site: this.conf.site || "",
|
|
3047
|
-
user: JSON.stringify(
|
|
3014
|
+
user: JSON.stringify(this.ctx.get("user").getData()),
|
|
3048
3015
|
time: +/* @__PURE__ */ new Date()
|
|
3049
3016
|
};
|
|
3050
3017
|
if (view)
|
|
@@ -3121,7 +3088,7 @@ class ListLayout {
|
|
|
3121
3088
|
constructor(options) {
|
|
3122
3089
|
this.options = options;
|
|
3123
3090
|
}
|
|
3124
|
-
// TODO refactor `if syntax` to strategy pattern
|
|
3091
|
+
// TODO: refactor `if syntax` to strategy pattern
|
|
3125
3092
|
import(comments) {
|
|
3126
3093
|
if (this.options.flatMode) {
|
|
3127
3094
|
comments.forEach((commentData) => {
|
|
@@ -3197,9 +3164,9 @@ class ListLayout {
|
|
|
3197
3164
|
scrollIntoView(comment.getEl());
|
|
3198
3165
|
}
|
|
3199
3166
|
}
|
|
3200
|
-
const win = window || {};
|
|
3201
|
-
const nav = navigator || {};
|
|
3202
3167
|
function Detect(userAgent) {
|
|
3168
|
+
const win = window || {};
|
|
3169
|
+
const nav = navigator || {};
|
|
3203
3170
|
const u = String(userAgent || nav.userAgent);
|
|
3204
3171
|
const dest = {
|
|
3205
3172
|
os: "",
|
|
@@ -4548,20 +4515,6 @@ const initListPaginatorFunc = (ctx) => {
|
|
|
4548
4515
|
var _a;
|
|
4549
4516
|
(_a = paginator == null ? void 0 : paginator.showErr) == null ? void 0 : _a.call(paginator, t("loadFail"));
|
|
4550
4517
|
});
|
|
4551
|
-
const autoSwitchPageForFindComment = (commentID) => {
|
|
4552
|
-
const comment = ctx.getData().findComment(commentID);
|
|
4553
|
-
if (!!comment || !(paginator == null ? void 0 : paginator.getHasMore()))
|
|
4554
|
-
return;
|
|
4555
|
-
ctx.on("list-loaded", () => {
|
|
4556
|
-
autoSwitchPageForFindComment(commentID);
|
|
4557
|
-
}, { once: true });
|
|
4558
|
-
setTimeout(() => {
|
|
4559
|
-
paginator == null ? void 0 : paginator.next();
|
|
4560
|
-
}, 80);
|
|
4561
|
-
};
|
|
4562
|
-
ctx.on("list-goto", (commentID) => {
|
|
4563
|
-
autoSwitchPageForFindComment(commentID);
|
|
4564
|
-
});
|
|
4565
4518
|
ctx.on("list-fetch", (params) => {
|
|
4566
4519
|
paginator == null ? void 0 : paginator.setLoading(true);
|
|
4567
4520
|
});
|
|
@@ -4759,6 +4712,47 @@ class LayerManager {
|
|
|
4759
4712
|
return layer;
|
|
4760
4713
|
}
|
|
4761
4714
|
}
|
|
4715
|
+
const LOCAL_USER_KEY = "ArtalkUser";
|
|
4716
|
+
class User {
|
|
4717
|
+
constructor(opts) {
|
|
4718
|
+
__publicField(this, "data");
|
|
4719
|
+
this.opts = opts;
|
|
4720
|
+
const localUser = JSON.parse(window.localStorage.getItem(LOCAL_USER_KEY) || "{}");
|
|
4721
|
+
this.data = {
|
|
4722
|
+
nick: localUser.nick || "",
|
|
4723
|
+
email: localUser.email || "",
|
|
4724
|
+
link: localUser.link || "",
|
|
4725
|
+
token: localUser.token || "",
|
|
4726
|
+
isAdmin: localUser.isAdmin || false
|
|
4727
|
+
};
|
|
4728
|
+
}
|
|
4729
|
+
getData() {
|
|
4730
|
+
return this.data;
|
|
4731
|
+
}
|
|
4732
|
+
/** 保存用户到 localStorage 中 */
|
|
4733
|
+
update(obj = {}) {
|
|
4734
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
4735
|
+
this.data[key] = value;
|
|
4736
|
+
});
|
|
4737
|
+
window.localStorage.setItem(LOCAL_USER_KEY, JSON.stringify(this.data));
|
|
4738
|
+
this.opts.onUserChanged && this.opts.onUserChanged(this.data);
|
|
4739
|
+
}
|
|
4740
|
+
/**
|
|
4741
|
+
* Logout
|
|
4742
|
+
*
|
|
4743
|
+
* @description Logout will clear login status, but not clear user data (nick, email, link)
|
|
4744
|
+
*/
|
|
4745
|
+
logout() {
|
|
4746
|
+
this.update({
|
|
4747
|
+
token: "",
|
|
4748
|
+
isAdmin: false
|
|
4749
|
+
});
|
|
4750
|
+
}
|
|
4751
|
+
/** 是否已填写基本用户信息 */
|
|
4752
|
+
checkHasBasicUserInfo() {
|
|
4753
|
+
return !!this.data.nick && !!this.data.email;
|
|
4754
|
+
}
|
|
4755
|
+
}
|
|
4762
4756
|
const services = {
|
|
4763
4757
|
// I18n
|
|
4764
4758
|
i18n(ctx) {
|
|
@@ -4769,10 +4763,12 @@ const services = {
|
|
|
4769
4763
|
},
|
|
4770
4764
|
// User Store
|
|
4771
4765
|
user(ctx) {
|
|
4772
|
-
|
|
4773
|
-
|
|
4766
|
+
const user = new User({
|
|
4767
|
+
onUserChanged: (data) => {
|
|
4768
|
+
ctx.trigger("user-changed", data);
|
|
4769
|
+
}
|
|
4774
4770
|
});
|
|
4775
|
-
return
|
|
4771
|
+
return user;
|
|
4776
4772
|
},
|
|
4777
4773
|
// 弹出层
|
|
4778
4774
|
layerManager(ctx) {
|
|
@@ -4822,17 +4818,19 @@ function showErrorDialog(opts) {
|
|
|
4822
4818
|
errEl.appendChild($retryBtn);
|
|
4823
4819
|
}
|
|
4824
4820
|
if (opts.onOpenSidebar) {
|
|
4825
|
-
const $openSidebar = createElement(
|
|
4821
|
+
const $openSidebar = createElement(`<span atk-only-admin-show> | <span style="cursor:pointer;">${t("open") + t("ctrlCenter")}</span></span>`);
|
|
4826
4822
|
errEl.appendChild($openSidebar);
|
|
4827
|
-
if (!UserInstance.data.isAdmin) {
|
|
4828
|
-
$openSidebar.classList.add("atk-hide");
|
|
4829
|
-
}
|
|
4830
4823
|
$openSidebar.onclick = () => opts.onOpenSidebar && opts.onOpenSidebar();
|
|
4831
4824
|
}
|
|
4832
4825
|
setError(opts.$err, errEl);
|
|
4833
4826
|
}
|
|
4834
4827
|
const ConfRemoter = (ctx) => {
|
|
4835
4828
|
ctx.on("inited", () => {
|
|
4829
|
+
if (ctx.conf.immediateFetch === false)
|
|
4830
|
+
return;
|
|
4831
|
+
ctx.trigger("conf-fetch");
|
|
4832
|
+
});
|
|
4833
|
+
ctx.on("conf-fetch", () => {
|
|
4836
4834
|
loadConf(ctx);
|
|
4837
4835
|
});
|
|
4838
4836
|
};
|
|
@@ -4862,9 +4860,10 @@ function loadConf(ctx) {
|
|
|
4862
4860
|
errMsg: err.msg || String(err),
|
|
4863
4861
|
errData: err.data,
|
|
4864
4862
|
retryFn: () => loadConf(ctx),
|
|
4865
|
-
onOpenSidebar: () => ctx.showSidebar({
|
|
4863
|
+
onOpenSidebar: ctx.get("user").getData().isAdmin ? () => ctx.showSidebar({
|
|
4866
4864
|
view: sidebarOpenView
|
|
4867
|
-
})
|
|
4865
|
+
}) : void 0
|
|
4866
|
+
// only show open sidebar button when user is admin
|
|
4868
4867
|
});
|
|
4869
4868
|
throw err;
|
|
4870
4869
|
}).then(() => {
|
|
@@ -4969,7 +4968,7 @@ class SubmitAddPreset {
|
|
|
4969
4968
|
});
|
|
4970
4969
|
}
|
|
4971
4970
|
getSubmitAddParams() {
|
|
4972
|
-
const { nick, email, link } =
|
|
4971
|
+
const { nick, email, link } = this.kit.useUser().getData();
|
|
4973
4972
|
const conf = this.kit.useConf();
|
|
4974
4973
|
return {
|
|
4975
4974
|
content: this.kit.useEditor().getContentFinal(),
|
|
@@ -5167,7 +5166,7 @@ class StateEdit extends EditorPlug {
|
|
|
5167
5166
|
ui.$editCancelBtn = void 0;
|
|
5168
5167
|
}
|
|
5169
5168
|
this.comment = void 0;
|
|
5170
|
-
const { nick, email, link } =
|
|
5169
|
+
const { nick, email, link } = this.kit.useUser().getData();
|
|
5171
5170
|
ui.$nick.value = nick;
|
|
5172
5171
|
ui.$email.value = email;
|
|
5173
5172
|
ui.$link.value = link;
|
|
@@ -5206,7 +5205,7 @@ class Closable extends EditorPlug {
|
|
|
5206
5205
|
close() {
|
|
5207
5206
|
if (!this.kit.useUI().$textareaWrap.querySelector(".atk-comment-closed"))
|
|
5208
5207
|
this.kit.useUI().$textareaWrap.prepend(createElement(`<div class="atk-comment-closed">${t("onlyAdminCanReply")}</div>`));
|
|
5209
|
-
if (!
|
|
5208
|
+
if (!this.kit.useUser().getData().isAdmin) {
|
|
5210
5209
|
this.kit.useUI().$textarea.style.display = "none";
|
|
5211
5210
|
this.kit.useEvents().trigger("panel-close");
|
|
5212
5211
|
this.kit.useUI().$bottom.style.display = "none";
|
|
@@ -5251,14 +5250,14 @@ class HeaderUser extends EditorPlug {
|
|
|
5251
5250
|
const onInput = ({ $input, field }) => {
|
|
5252
5251
|
if (this.kit.useEditor().getState() === "edit")
|
|
5253
5252
|
return;
|
|
5254
|
-
|
|
5253
|
+
this.kit.useUser().update({ [field]: $input.value.trim() });
|
|
5255
5254
|
if (field === "nick" || field === "email")
|
|
5256
5255
|
this.fetchUserInfo();
|
|
5257
5256
|
};
|
|
5258
5257
|
this.kit.useMounted(() => {
|
|
5259
5258
|
Object.entries(this.kit.useEditor().getHeaderInputEls()).forEach(([key, $input]) => {
|
|
5260
5259
|
$input.placeholder = `${t(key)}`;
|
|
5261
|
-
$input.value =
|
|
5260
|
+
$input.value = this.kit.useUser().getData()[key] || "";
|
|
5262
5261
|
});
|
|
5263
5262
|
this.kit.useEvents().on("header-input", onInput);
|
|
5264
5263
|
});
|
|
@@ -5270,7 +5269,7 @@ class HeaderUser extends EditorPlug {
|
|
|
5270
5269
|
* Fetch user info from server
|
|
5271
5270
|
*/
|
|
5272
5271
|
fetchUserInfo() {
|
|
5273
|
-
|
|
5272
|
+
this.kit.useUser().logout();
|
|
5274
5273
|
if (this.query.timer)
|
|
5275
5274
|
window.clearTimeout(this.query.timer);
|
|
5276
5275
|
if (this.query.abortFn)
|
|
@@ -5278,8 +5277,8 @@ class HeaderUser extends EditorPlug {
|
|
|
5278
5277
|
this.query.timer = window.setTimeout(() => {
|
|
5279
5278
|
this.query.timer = null;
|
|
5280
5279
|
const { req, abort } = this.kit.useApi().user.userGet(
|
|
5281
|
-
|
|
5282
|
-
|
|
5280
|
+
this.kit.useUser().getData().nick,
|
|
5281
|
+
this.kit.useUser().getData().email
|
|
5283
5282
|
);
|
|
5284
5283
|
this.query.abortFn = abort;
|
|
5285
5284
|
req.then((data) => this.onUserInfoFetched(data)).catch((err) => {
|
|
@@ -5296,9 +5295,9 @@ class HeaderUser extends EditorPlug {
|
|
|
5296
5295
|
onUserInfoFetched(data) {
|
|
5297
5296
|
var _a;
|
|
5298
5297
|
if (!data.is_login)
|
|
5299
|
-
|
|
5298
|
+
this.kit.useUser().logout();
|
|
5300
5299
|
this.kit.useGlobalCtx().getData().updateUnreads(data.unread);
|
|
5301
|
-
if (
|
|
5300
|
+
if (this.kit.useUser().checkHasBasicUserInfo() && !data.is_login && ((_a = data.user) == null ? void 0 : _a.is_admin)) {
|
|
5302
5301
|
this.kit.useGlobalCtx().checkAdmin({
|
|
5303
5302
|
onSuccess: () => {
|
|
5304
5303
|
}
|
|
@@ -5306,7 +5305,7 @@ class HeaderUser extends EditorPlug {
|
|
|
5306
5305
|
}
|
|
5307
5306
|
if (data.user && data.user.link) {
|
|
5308
5307
|
this.kit.useUI().$link.value = data.user.link;
|
|
5309
|
-
|
|
5308
|
+
this.kit.useUser().update({ link: data.user.link });
|
|
5310
5309
|
}
|
|
5311
5310
|
}
|
|
5312
5311
|
}
|
|
@@ -5328,11 +5327,10 @@ class HeaderLink extends EditorPlug {
|
|
|
5328
5327
|
const link = this.kit.useUI().$link.value.trim();
|
|
5329
5328
|
if (!!link && !/^(http|https):\/\//.test(link)) {
|
|
5330
5329
|
this.kit.useUI().$link.value = `https://${link}`;
|
|
5331
|
-
|
|
5330
|
+
this.kit.useUser().update({ link: this.kit.useUI().$link.value });
|
|
5332
5331
|
}
|
|
5333
5332
|
}
|
|
5334
5333
|
}
|
|
5335
|
-
const emoticons = "";
|
|
5336
5334
|
class Emoticons extends EditorPlug {
|
|
5337
5335
|
constructor(kit) {
|
|
5338
5336
|
super(kit);
|
|
@@ -5404,7 +5402,7 @@ class Emoticons extends EditorPlug {
|
|
|
5404
5402
|
data.push(grp);
|
|
5405
5403
|
};
|
|
5406
5404
|
const remoteLoad = (d) => __async(this, null, function* () {
|
|
5407
|
-
yield Promise.all(d.map((grp,
|
|
5405
|
+
yield Promise.all(d.map((grp, index) => __async(this, null, function* () {
|
|
5408
5406
|
if (typeof grp === "object" && !Array.isArray(grp)) {
|
|
5409
5407
|
pushGrp(grp);
|
|
5410
5408
|
} else if (Array.isArray(grp)) {
|
|
@@ -5448,7 +5446,8 @@ class Emoticons extends EditorPlug {
|
|
|
5448
5446
|
return json;
|
|
5449
5447
|
} catch (err) {
|
|
5450
5448
|
hideLoading(this.$panel);
|
|
5451
|
-
|
|
5449
|
+
console.error("[Emoticons] Load Failed:", err);
|
|
5450
|
+
setError(this.$panel, `${t("emoticon")}${t("loadFail")} ${String(err)}`);
|
|
5452
5451
|
return [];
|
|
5453
5452
|
}
|
|
5454
5453
|
});
|
|
@@ -5456,9 +5455,9 @@ class Emoticons extends EditorPlug {
|
|
|
5456
5455
|
/** 避免表情 item.key 为 null 的情况 */
|
|
5457
5456
|
solveNullKey(data) {
|
|
5458
5457
|
data.forEach((grp) => {
|
|
5459
|
-
grp.items.forEach((item,
|
|
5458
|
+
grp.items.forEach((item, index) => {
|
|
5460
5459
|
if (!item.key)
|
|
5461
|
-
item.key = `${grp.name} ${
|
|
5460
|
+
item.key = `${grp.name} ${index + 1}`;
|
|
5462
5461
|
});
|
|
5463
5462
|
});
|
|
5464
5463
|
}
|
|
@@ -5491,14 +5490,14 @@ class Emoticons extends EditorPlug {
|
|
|
5491
5490
|
const dest = [];
|
|
5492
5491
|
Object.entries(owoData).forEach(([grpName, grp]) => {
|
|
5493
5492
|
const nGrp = { name: grpName, type: grp.type, items: [] };
|
|
5494
|
-
grp.container.forEach((item,
|
|
5493
|
+
grp.container.forEach((item, index) => {
|
|
5495
5494
|
const iconStr = item.icon;
|
|
5496
5495
|
if (/<(img|IMG)/.test(iconStr)) {
|
|
5497
5496
|
const find = /src=["'](.*?)["']/.exec(iconStr);
|
|
5498
5497
|
if (find && find.length > 1)
|
|
5499
5498
|
item.icon = find[1];
|
|
5500
5499
|
}
|
|
5501
|
-
nGrp.items.push({ key: item.text || `${grpName} ${
|
|
5500
|
+
nGrp.items.push({ key: item.text || `${grpName} ${index + 1}`, val: item.icon });
|
|
5502
5501
|
});
|
|
5503
5502
|
dest.push(nGrp);
|
|
5504
5503
|
});
|
|
@@ -5508,10 +5507,10 @@ class Emoticons extends EditorPlug {
|
|
|
5508
5507
|
initEmoticonsList() {
|
|
5509
5508
|
this.$grpWrap = createElement(`<div class="atk-grp-wrap"></div>`);
|
|
5510
5509
|
this.$panel.append(this.$grpWrap);
|
|
5511
|
-
this.emoticons.forEach((grp,
|
|
5510
|
+
this.emoticons.forEach((grp, index) => {
|
|
5512
5511
|
const $grp = createElement(`<div class="atk-grp" style="display: none;"></div>`);
|
|
5513
5512
|
this.$grpWrap.append($grp);
|
|
5514
|
-
$grp.setAttribute("data-index", String(
|
|
5513
|
+
$grp.setAttribute("data-index", String(index));
|
|
5515
5514
|
$grp.setAttribute("data-grp-name", grp.name);
|
|
5516
5515
|
$grp.setAttribute("data-type", grp.type);
|
|
5517
5516
|
grp.items.forEach((item) => {
|
|
@@ -5539,11 +5538,11 @@ class Emoticons extends EditorPlug {
|
|
|
5539
5538
|
if (this.emoticons.length > 1) {
|
|
5540
5539
|
this.$grpSwitcher = createElement(`<div class="atk-grp-switcher"></div>`);
|
|
5541
5540
|
this.$panel.append(this.$grpSwitcher);
|
|
5542
|
-
this.emoticons.forEach((grp,
|
|
5541
|
+
this.emoticons.forEach((grp, index) => {
|
|
5543
5542
|
const $item = createElement("<span />");
|
|
5544
5543
|
$item.innerText = grp.name;
|
|
5545
|
-
$item.setAttribute("data-index", String(
|
|
5546
|
-
$item.onclick = () => this.openGrp(
|
|
5544
|
+
$item.setAttribute("data-index", String(index));
|
|
5545
|
+
$item.onclick = () => this.openGrp(index);
|
|
5547
5546
|
this.$grpSwitcher.append($item);
|
|
5548
5547
|
});
|
|
5549
5548
|
}
|
|
@@ -5551,18 +5550,18 @@ class Emoticons extends EditorPlug {
|
|
|
5551
5550
|
this.openGrp(0);
|
|
5552
5551
|
}
|
|
5553
5552
|
/** 打开一个表情组 */
|
|
5554
|
-
openGrp(
|
|
5553
|
+
openGrp(index) {
|
|
5555
5554
|
var _a, _b, _c;
|
|
5556
5555
|
Array.from(this.$grpWrap.children).forEach((item) => {
|
|
5557
5556
|
const el = item;
|
|
5558
|
-
if (el.getAttribute("data-index") !== String(
|
|
5557
|
+
if (el.getAttribute("data-index") !== String(index)) {
|
|
5559
5558
|
el.style.display = "none";
|
|
5560
5559
|
} else {
|
|
5561
5560
|
el.style.display = "";
|
|
5562
5561
|
}
|
|
5563
5562
|
});
|
|
5564
5563
|
(_a = this.$grpSwitcher) == null ? void 0 : _a.querySelectorAll("span.active").forEach((item) => item.classList.remove("active"));
|
|
5565
|
-
(_c = (_b = this.$grpSwitcher) == null ? void 0 : _b.querySelector(`span[data-index="${
|
|
5564
|
+
(_c = (_b = this.$grpSwitcher) == null ? void 0 : _b.querySelector(`span[data-index="${index}"]`)) == null ? void 0 : _c.classList.add("active");
|
|
5566
5565
|
this.changeListHeight();
|
|
5567
5566
|
}
|
|
5568
5567
|
changeListHeight() {
|
|
@@ -5574,7 +5573,7 @@ class Emoticons extends EditorPlug {
|
|
|
5574
5573
|
this.emoticons.forEach((grp) => {
|
|
5575
5574
|
if (grp.type !== "image")
|
|
5576
5575
|
return;
|
|
5577
|
-
Object.entries(grp.items).forEach(([
|
|
5576
|
+
Object.entries(grp.items).forEach(([index, item]) => {
|
|
5578
5577
|
text = text.split(`:[${item.key}]`).join(`<img src="${item.val}" atk-emoticon="${item.key}">`);
|
|
5579
5578
|
});
|
|
5580
5579
|
});
|
|
@@ -5657,7 +5656,7 @@ class Upload extends EditorPlug {
|
|
|
5657
5656
|
const fileExt = /[^.]+$/.exec(file.name);
|
|
5658
5657
|
if (!fileExt || !AllowImgExts.includes(fileExt[0]))
|
|
5659
5658
|
return;
|
|
5660
|
-
if (!
|
|
5659
|
+
if (!this.kit.useUser().checkHasBasicUserInfo()) {
|
|
5661
5660
|
this.kit.useEditor().showNotify(t("uploadLoginMsg"), "w");
|
|
5662
5661
|
return;
|
|
5663
5662
|
}
|
|
@@ -5692,7 +5691,6 @@ class Upload extends EditorPlug {
|
|
|
5692
5691
|
});
|
|
5693
5692
|
}
|
|
5694
5693
|
}
|
|
5695
|
-
const preview = "";
|
|
5696
5694
|
class Preview extends EditorPlug {
|
|
5697
5695
|
constructor(kit) {
|
|
5698
5696
|
super(kit);
|
|
@@ -5755,7 +5753,11 @@ class PlugKit {
|
|
|
5755
5753
|
useEditor() {
|
|
5756
5754
|
return this.plugs.editor;
|
|
5757
5755
|
}
|
|
5758
|
-
/**
|
|
5756
|
+
/**
|
|
5757
|
+
* Use the context of global
|
|
5758
|
+
*
|
|
5759
|
+
* @deprecated The calls to this function should be reduced as much as possible
|
|
5760
|
+
*/
|
|
5759
5761
|
useGlobalCtx() {
|
|
5760
5762
|
return this.plugs.editor.ctx;
|
|
5761
5763
|
}
|
|
@@ -5767,6 +5769,10 @@ class PlugKit {
|
|
|
5767
5769
|
useApi() {
|
|
5768
5770
|
return this.plugs.editor.ctx.getApi();
|
|
5769
5771
|
}
|
|
5772
|
+
/** Use the user manager */
|
|
5773
|
+
useUser() {
|
|
5774
|
+
return this.plugs.editor.ctx.get("user");
|
|
5775
|
+
}
|
|
5770
5776
|
/** Use the ui of editor */
|
|
5771
5777
|
useUI() {
|
|
5772
5778
|
return this.plugs.editor.getUI();
|
|
@@ -5984,7 +5990,7 @@ const SidebarBtn = (ctx) => {
|
|
|
5984
5990
|
const syncByUser = () => {
|
|
5985
5991
|
if (!$openSidebarBtn)
|
|
5986
5992
|
return;
|
|
5987
|
-
const user = ctx.get("user").
|
|
5993
|
+
const user = ctx.get("user").getData();
|
|
5988
5994
|
if (!!user.nick && !!user.email) {
|
|
5989
5995
|
$openSidebarBtn.classList.remove("atk-hide");
|
|
5990
5996
|
const $btnText = $openSidebarBtn.querySelector(".atk-text");
|
|
@@ -6083,7 +6089,7 @@ function extractCommentID() {
|
|
|
6083
6089
|
}
|
|
6084
6090
|
return commentId || null;
|
|
6085
6091
|
}
|
|
6086
|
-
const version = "2.7.
|
|
6092
|
+
const version = "2.7.3";
|
|
6087
6093
|
const Copyright = (ctx) => {
|
|
6088
6094
|
ctx.on("conf-loaded", () => {
|
|
6089
6095
|
const list = ctx.get("list");
|
|
@@ -6416,7 +6422,7 @@ function versionCheck(list, feVer, beVer) {
|
|
|
6416
6422
|
}
|
|
6417
6423
|
const AdminOnlyElem = (ctx) => {
|
|
6418
6424
|
const scanApply = () => {
|
|
6419
|
-
applyAdminOnlyEls(ctx.get("user").
|
|
6425
|
+
applyAdminOnlyEls(ctx.get("user").getData().isAdmin, getAdminOnlyEls({
|
|
6420
6426
|
$root: ctx.$root
|
|
6421
6427
|
}));
|
|
6422
6428
|
};
|
|
@@ -6443,38 +6449,44 @@ function applyAdminOnlyEls(isAdmin, els) {
|
|
|
6443
6449
|
$item.classList.add("atk-hide");
|
|
6444
6450
|
});
|
|
6445
6451
|
}
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
darkModeMedia.addEventListener("change", darkModeAutoFunc);
|
|
6456
|
-
}
|
|
6457
|
-
apply(darkModeMedia.matches);
|
|
6458
|
-
} else {
|
|
6459
|
-
if (darkModeAutoFunc)
|
|
6460
|
-
darkModeMedia.removeEventListener("change", darkModeAutoFunc);
|
|
6461
|
-
apply(darkMode);
|
|
6462
|
-
}
|
|
6463
|
-
}
|
|
6464
|
-
const DarkModeClassName = "atk-dark-mode";
|
|
6465
|
-
function updateClassName($el, darkMode) {
|
|
6466
|
-
if (darkMode)
|
|
6467
|
-
$el.classList.add(DarkModeClassName);
|
|
6468
|
-
else
|
|
6469
|
-
$el.classList.remove(DarkModeClassName);
|
|
6452
|
+
let darkModeMedia;
|
|
6453
|
+
function updateClassnames($els, darkMode) {
|
|
6454
|
+
const DarkModeClassName = "atk-dark-mode";
|
|
6455
|
+
$els.forEach(($el) => {
|
|
6456
|
+
if (darkMode)
|
|
6457
|
+
$el.classList.add(DarkModeClassName);
|
|
6458
|
+
else
|
|
6459
|
+
$el.classList.remove(DarkModeClassName);
|
|
6460
|
+
});
|
|
6470
6461
|
}
|
|
6471
6462
|
const DarkMode = (ctx) => {
|
|
6472
|
-
|
|
6473
|
-
|
|
6463
|
+
let darkModeAutoHandler;
|
|
6464
|
+
const sync = (darkMode) => {
|
|
6465
|
+
const $els = [ctx.$root, ctx.get("layerManager").getEl()];
|
|
6466
|
+
if (!darkModeMedia) {
|
|
6467
|
+
darkModeMedia = window.matchMedia("(prefers-color-scheme: dark)");
|
|
6468
|
+
}
|
|
6469
|
+
if (darkMode === "auto") {
|
|
6470
|
+
if (!darkModeAutoHandler) {
|
|
6471
|
+
darkModeAutoHandler = (evt) => updateClassnames($els, evt.matches);
|
|
6472
|
+
darkModeMedia.addEventListener("change", darkModeAutoHandler);
|
|
6473
|
+
}
|
|
6474
|
+
updateClassnames($els, darkModeMedia.matches);
|
|
6475
|
+
} else {
|
|
6476
|
+
if (darkModeAutoHandler) {
|
|
6477
|
+
darkModeMedia.removeEventListener("change", darkModeAutoHandler);
|
|
6478
|
+
darkModeAutoHandler = void 0;
|
|
6479
|
+
}
|
|
6480
|
+
updateClassnames($els, darkMode);
|
|
6481
|
+
}
|
|
6474
6482
|
};
|
|
6475
|
-
ctx.on("inited", () => sync());
|
|
6476
|
-
ctx.on("conf-loaded", () => sync());
|
|
6477
|
-
ctx.on("dark-mode-changed", () => sync());
|
|
6483
|
+
ctx.on("inited", () => sync(ctx.conf.darkMode));
|
|
6484
|
+
ctx.on("conf-loaded", (conf) => sync(conf.darkMode));
|
|
6485
|
+
ctx.on("dark-mode-changed", (darkMode) => sync(darkMode));
|
|
6486
|
+
ctx.on("destroy", () => {
|
|
6487
|
+
darkModeAutoHandler && (darkModeMedia == null ? void 0 : darkModeMedia.removeEventListener("change", darkModeAutoHandler));
|
|
6488
|
+
darkModeAutoHandler = void 0;
|
|
6489
|
+
});
|
|
6478
6490
|
};
|
|
6479
6491
|
const DefaultPlugins = [
|
|
6480
6492
|
ConfRemoter,
|
|
@@ -6489,15 +6501,11 @@ const DefaultPlugins = [
|
|
|
6489
6501
|
const GlobalPlugins = [...DefaultPlugins];
|
|
6490
6502
|
class Artalk {
|
|
6491
6503
|
constructor(conf) {
|
|
6492
|
-
__publicField(this, "conf");
|
|
6493
6504
|
__publicField(this, "ctx");
|
|
6494
|
-
__publicField(this, "$root");
|
|
6495
6505
|
/** Plugins */
|
|
6496
6506
|
__publicField(this, "plugins", [...GlobalPlugins]);
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
this.$root = this.conf.el;
|
|
6500
|
-
this.ctx = new Context(this.conf, this.$root);
|
|
6507
|
+
const handledConf = handelCustomConf(conf, true);
|
|
6508
|
+
this.ctx = new Context(handledConf);
|
|
6501
6509
|
Object.entries(services).forEach(([name, initService]) => {
|
|
6502
6510
|
const obj = initService(this.ctx);
|
|
6503
6511
|
if (obj)
|
|
@@ -6509,6 +6517,14 @@ class Artalk {
|
|
|
6509
6517
|
});
|
|
6510
6518
|
this.ctx.trigger("inited");
|
|
6511
6519
|
}
|
|
6520
|
+
/** Get the config of Artalk */
|
|
6521
|
+
getConf() {
|
|
6522
|
+
return this.ctx.getConf();
|
|
6523
|
+
}
|
|
6524
|
+
/** Get the root element of Artalk */
|
|
6525
|
+
getEl() {
|
|
6526
|
+
return this.ctx.$root;
|
|
6527
|
+
}
|
|
6512
6528
|
/** Update config of Artalk */
|
|
6513
6529
|
update(conf) {
|
|
6514
6530
|
this.ctx.updateConf(conf);
|
|
@@ -6521,7 +6537,7 @@ class Artalk {
|
|
|
6521
6537
|
/** Destroy instance of Artalk */
|
|
6522
6538
|
destroy() {
|
|
6523
6539
|
this.ctx.trigger("destroy");
|
|
6524
|
-
this.$root.remove();
|
|
6540
|
+
this.ctx.$root.remove();
|
|
6525
6541
|
}
|
|
6526
6542
|
/** Add an event listener */
|
|
6527
6543
|
on(name, handler) {
|
|
@@ -6554,7 +6570,7 @@ class Artalk {
|
|
|
6554
6570
|
}
|
|
6555
6571
|
/** Load count widget */
|
|
6556
6572
|
static loadCountWidget(c) {
|
|
6557
|
-
const conf = handelCustomConf(c);
|
|
6573
|
+
const conf = handelCustomConf(c, true);
|
|
6558
6574
|
initCountWidget({
|
|
6559
6575
|
getApi: () => new Api(convertApiOptions(conf)),
|
|
6560
6576
|
pageKey: conf.pageKey,
|
|
@@ -6563,18 +6579,25 @@ class Artalk {
|
|
|
6563
6579
|
pvAdd: false
|
|
6564
6580
|
});
|
|
6565
6581
|
}
|
|
6582
|
+
// ===========================
|
|
6583
|
+
// Deprecated
|
|
6584
|
+
// ===========================
|
|
6585
|
+
/** @deprecated Please use `getEl()` instead */
|
|
6586
|
+
get $root() {
|
|
6587
|
+
return this.ctx.$root;
|
|
6588
|
+
}
|
|
6589
|
+
/** @description Please use `getConf()` instead */
|
|
6590
|
+
get conf() {
|
|
6591
|
+
return this.ctx.getConf();
|
|
6592
|
+
}
|
|
6566
6593
|
}
|
|
6567
|
-
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
6568
|
-
__proto__: null
|
|
6569
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
6570
6594
|
const init = Artalk.init;
|
|
6571
6595
|
const use = Artalk.use;
|
|
6572
6596
|
const loadCountWidget = Artalk.loadCountWidget;
|
|
6573
6597
|
export {
|
|
6574
|
-
index as ArtalkType,
|
|
6575
6598
|
Artalk as default,
|
|
6576
6599
|
init,
|
|
6577
6600
|
loadCountWidget,
|
|
6578
6601
|
use
|
|
6579
6602
|
};
|
|
6580
|
-
//# sourceMappingURL=ArtalkLite.
|
|
6603
|
+
//# sourceMappingURL=ArtalkLite.mjs.map
|