artalk 2.6.4 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Artalk.css +1 -1
- package/dist/Artalk.es.js +7794 -7483
- package/dist/Artalk.iife.js +1 -1
- package/dist/Artalk.js +1 -1
- package/dist/ArtalkLite.css +1 -1
- package/dist/ArtalkLite.es.js +5587 -5276
- package/dist/ArtalkLite.iife.js +1 -1
- package/dist/ArtalkLite.js +1 -1
- package/dist/src/api/{api-base.d.ts → _base.d.ts} +3 -7
- package/dist/src/api/_options.d.ts +19 -0
- package/dist/src/api/{request.d.ts → _request.d.ts} +3 -3
- package/dist/src/api/admin.d.ts +1 -1
- package/dist/src/api/captcha.d.ts +1 -1
- package/dist/src/api/comment.d.ts +2 -2
- package/dist/src/api/index.d.ts +2 -4
- package/dist/src/api/page.d.ts +3 -3
- package/dist/src/api/site.d.ts +2 -2
- package/dist/src/api/system.d.ts +13 -3
- package/dist/src/api/upload.d.ts +1 -1
- package/dist/src/api/user.d.ts +2 -2
- package/dist/src/artalk.d.ts +14 -37
- package/dist/src/comment/actions.d.ts +1 -1
- package/dist/src/comment/comment.d.ts +3 -4
- package/dist/src/comment/render.d.ts +21 -3
- package/dist/src/comment/renders/actions.d.ts +2 -2
- package/dist/src/comment/renders/avatar.d.ts +2 -2
- package/dist/src/comment/renders/content.d.ts +2 -2
- package/dist/src/comment/renders/header.d.ts +2 -2
- package/dist/src/comment/renders/index.d.ts +2 -2
- package/dist/src/comment/renders/pending.d.ts +2 -2
- package/dist/src/comment/renders/reply-at.d.ts +2 -2
- package/dist/src/comment/renders/reply-to.d.ts +2 -2
- package/dist/src/components/action-btn.d.ts +3 -5
- package/dist/src/{lib → components}/checker/admin.d.ts +1 -1
- package/dist/src/{lib → components}/checker/captcha-renders.d.ts +1 -1
- package/dist/src/{lib → components}/checker/captcha.d.ts +1 -1
- package/dist/src/{lib → components}/checker/index.d.ts +10 -7
- package/dist/src/components/dark-mode.d.ts +2 -0
- package/dist/src/components/dialog.d.ts +1 -3
- package/dist/src/components/error-dialog.d.ts +8 -0
- package/dist/src/components/pagination.d.ts +4 -3
- package/dist/src/components/read-more-btn.d.ts +3 -3
- package/dist/src/config.d.ts +24 -8
- package/dist/src/context.d.ts +16 -35
- package/dist/src/data.d.ts +27 -0
- package/dist/src/defaults.d.ts +1 -1
- package/dist/src/editor/editor.d.ts +14 -61
- package/dist/src/editor/state.d.ts +20 -0
- package/dist/src/i18n/zh-CN.d.ts +1 -1
- package/dist/src/layer/index.d.ts +4 -3
- package/dist/src/layer/layer-manager.d.ts +9 -0
- package/dist/src/layer/layer.d.ts +8 -28
- package/dist/src/layer/scrollbar-helper.d.ts +5 -0
- package/dist/src/layer/sidebar-layer.d.ts +6 -6
- package/dist/src/layer/wrap.d.ts +13 -0
- package/dist/src/lib/component.d.ts +3 -8
- package/dist/src/lib/event-manager.d.ts +28 -0
- package/dist/src/lib/highlight.d.ts +1 -0
- package/dist/src/lib/marked-renderer.d.ts +4 -0
- package/dist/src/lib/marked.d.ts +4 -2
- package/dist/src/lib/sanitizer.d.ts +1 -0
- package/dist/src/lib/ui.d.ts +3 -2
- package/dist/src/lib/user.d.ts +8 -5
- package/dist/src/lib/utils.d.ts +11 -5
- package/dist/src/list/comment.d.ts +3 -0
- package/dist/src/list/layout.d.ts +23 -0
- package/dist/src/list/list.d.ts +13 -25
- package/dist/src/list/{list-nest.d.ts → nest.d.ts} +1 -1
- package/dist/src/list/page.d.ts +2 -0
- package/dist/src/list/paginator/index.d.ts +22 -7
- package/dist/src/list/paginator/read-more.d.ts +18 -0
- package/dist/src/list/paginator/up-down.d.ts +14 -0
- package/dist/src/main.d.ts +2 -0
- package/dist/src/plugins/admin-only-elem.d.ts +2 -0
- package/dist/src/plugins/conf-remoter.d.ts +2 -0
- package/dist/src/plugins/dark-mode.d.ts +2 -0
- package/dist/src/plugins/editor/_kit.d.ts +27 -0
- package/dist/src/plugins/editor/_plug.d.ts +29 -0
- package/dist/src/plugins/editor/_sample.d.ts +5 -0
- package/dist/src/plugins/editor/closable.d.ts +7 -0
- package/dist/src/{editor/plugs/emoticons-plug.d.ts → plugins/editor/emoticons.d.ts} +10 -16
- package/dist/src/plugins/editor/header-event.d.ts +6 -0
- package/dist/src/plugins/editor/header-link.d.ts +6 -0
- package/dist/src/plugins/editor/header-user.d.ts +16 -0
- package/dist/src/plugins/editor/index.d.ts +6 -0
- package/dist/src/plugins/editor/local-storage.d.ts +6 -0
- package/dist/src/plugins/editor/mover.d.ts +6 -0
- package/dist/src/plugins/editor/preview.d.ts +7 -0
- package/dist/src/plugins/editor/state-edit.d.ts +11 -0
- package/dist/src/plugins/editor/state-reply.d.ts +8 -0
- package/dist/src/plugins/editor/submit-add.d.ts +18 -0
- package/dist/src/plugins/editor/submit-btn.d.ts +5 -0
- package/dist/src/plugins/editor/submit.d.ts +17 -0
- package/dist/src/plugins/editor/textarea.d.ts +8 -0
- package/dist/src/plugins/editor/upload.d.ts +9 -0
- package/dist/src/plugins/editor-kit.d.ts +42 -0
- package/dist/src/plugins/index.d.ts +2 -0
- package/dist/src/plugins/list/copyright.d.ts +2 -0
- package/dist/src/plugins/list/count.d.ts +2 -0
- package/dist/src/plugins/list/dropdown.d.ts +2 -0
- package/dist/src/plugins/list/error-dialog.d.ts +2 -0
- package/dist/src/plugins/list/fetch.d.ts +2 -0
- package/dist/src/plugins/list/goto-first.d.ts +3 -0
- package/dist/src/plugins/list/goto.d.ts +2 -0
- package/dist/src/plugins/list/index.d.ts +3 -0
- package/dist/src/plugins/list/loading.d.ts +2 -0
- package/dist/src/plugins/list/no-comment.d.ts +2 -0
- package/dist/src/plugins/list/reach-bottom.d.ts +2 -0
- package/dist/src/plugins/list/sidebar-btn.d.ts +2 -0
- package/dist/src/plugins/list/time-ticking.d.ts +3 -0
- package/dist/src/plugins/list/unread-badge.d.ts +2 -0
- package/dist/src/plugins/list/unread.d.ts +2 -0
- package/dist/src/plugins/list/with-editor.d.ts +2 -0
- package/dist/src/plugins/markdown.d.ts +2 -0
- package/dist/src/plugins/stat.d.ts +13 -0
- package/dist/src/plugins/version-check.d.ts +2 -0
- package/dist/src/service.d.ts +19 -23
- package/dist/tests/e2e/comment-add.spec.d.ts +1 -0
- package/dist/types/config.d.ts +110 -0
- package/dist/types/context.d.ts +56 -136
- package/dist/types/data.d.ts +194 -0
- package/dist/types/editor.d.ts +76 -0
- package/dist/types/event.d.ts +36 -25
- package/dist/types/index.d.ts +7 -0
- package/dist/types/plugin.d.ts +2 -0
- package/dist/types/sidebar.d.ts +3 -0
- package/package.json +5 -2
- package/src/api/_base.ts +18 -0
- package/src/api/_options.ts +25 -0
- package/src/api/{request.ts → _request.ts} +19 -18
- package/src/api/admin.ts +1 -1
- package/src/api/captcha.ts +1 -1
- package/src/api/comment.ts +4 -4
- package/src/api/index.ts +3 -12
- package/src/api/page.ts +5 -5
- package/src/api/site.ts +2 -2
- package/src/api/system.ts +19 -7
- package/src/api/upload.ts +3 -3
- package/src/api/user.ts +3 -3
- package/src/artalk.ts +49 -97
- package/src/comment/actions.ts +1 -4
- package/src/comment/comment.ts +9 -6
- package/src/comment/render.ts +27 -5
- package/src/comment/renders/actions.ts +45 -45
- package/src/comment/renders/avatar.ts +7 -7
- package/src/comment/renders/content.ts +18 -18
- package/src/comment/renders/header.ts +13 -13
- package/src/comment/renders/index.ts +3 -3
- package/src/comment/renders/pending.ts +5 -5
- package/src/comment/renders/reply-at.ts +8 -8
- package/src/comment/renders/reply-to.ts +13 -13
- package/src/components/action-btn.ts +11 -13
- package/src/{lib → components}/checker/admin.ts +6 -6
- package/src/{lib → components}/checker/captcha-renders.ts +7 -6
- package/src/{lib → components}/checker/captcha.ts +1 -1
- package/src/{lib → components}/checker/index.ts +21 -26
- package/src/components/dark-mode.ts +30 -0
- package/src/components/dialog.ts +4 -9
- package/src/components/error-dialog.ts +35 -0
- package/src/components/pagination.ts +10 -6
- package/src/components/read-more-btn.ts +7 -7
- package/src/config.ts +60 -6
- package/src/context.ts +39 -144
- package/src/data.ts +110 -0
- package/src/defaults.ts +1 -1
- package/src/editor/editor.ts +39 -152
- package/src/editor/state.ts +52 -0
- package/src/i18n/zh-CN.ts +1 -1
- package/src/layer/index.ts +4 -4
- package/src/layer/layer-manager.ts +32 -0
- package/src/layer/layer.ts +20 -144
- package/src/layer/scrollbar-helper.ts +24 -0
- package/src/layer/sidebar-layer.ts +74 -64
- package/src/layer/wrap.ts +77 -0
- package/src/lib/component.ts +4 -11
- package/src/lib/detect.ts +1 -1
- package/src/lib/event-manager.ts +47 -0
- package/src/lib/highlight.ts +5 -0
- package/src/lib/marked-renderer.ts +32 -0
- package/src/lib/marked.ts +43 -104
- package/src/lib/sanitizer.ts +57 -0
- package/src/lib/ui.ts +22 -15
- package/src/lib/user.ts +21 -16
- package/src/lib/utils.ts +29 -18
- package/src/list/comment.ts +20 -0
- package/src/list/layout.ts +120 -0
- package/src/list/list.html +3 -1
- package/src/list/list.ts +56 -200
- package/src/list/{list-nest.ts → nest.ts} +1 -1
- package/src/list/page.ts +97 -0
- package/src/list/paginator/index.ts +20 -8
- package/src/list/paginator/read-more.ts +67 -0
- package/src/list/paginator/up-down.ts +51 -0
- package/src/main.ts +2 -0
- package/src/plugins/admin-only-elem.ts +40 -0
- package/src/plugins/conf-remoter.ts +54 -0
- package/src/plugins/dark-mode.ts +12 -0
- package/src/plugins/editor/_kit.ts +57 -0
- package/src/plugins/editor/_plug.ts +60 -0
- package/src/plugins/editor/_sample.ts +8 -0
- package/src/plugins/editor/closable.ts +44 -0
- package/src/{editor/plugs/emoticons-plug.ts → plugins/editor/emoticons.ts} +51 -52
- package/src/plugins/editor/header-event.ts +35 -0
- package/src/plugins/editor/header-link.ts +31 -0
- package/src/plugins/editor/header-user.ts +98 -0
- package/src/plugins/editor/index.ts +40 -0
- package/src/plugins/editor/local-storage.ts +36 -0
- package/src/plugins/editor/mover.ts +29 -0
- package/src/plugins/editor/preview.ts +41 -0
- package/src/plugins/editor/state-edit.ts +116 -0
- package/src/plugins/editor/state-reply.ts +91 -0
- package/src/plugins/editor/submit-add.ts +33 -0
- package/src/plugins/editor/submit-btn.ts +25 -0
- package/src/plugins/editor/submit.ts +73 -0
- package/src/plugins/editor/textarea.ts +55 -0
- package/src/plugins/editor/upload.ts +145 -0
- package/src/plugins/editor-kit.ts +161 -0
- package/src/plugins/index.ts +16 -0
- package/src/plugins/list/copyright.ts +16 -0
- package/src/plugins/list/count.ts +31 -0
- package/src/plugins/list/dropdown.ts +95 -0
- package/src/plugins/list/error-dialog.ts +22 -0
- package/src/plugins/list/fetch.ts +64 -0
- package/src/plugins/list/goto-first.ts +23 -0
- package/src/plugins/list/goto.ts +72 -0
- package/src/plugins/list/index.ts +25 -0
- package/src/plugins/list/loading.ts +17 -0
- package/src/plugins/list/no-comment.ts +25 -0
- package/src/plugins/list/reach-bottom.ts +46 -0
- package/src/plugins/list/sidebar-btn.ts +39 -0
- package/src/plugins/list/time-ticking.ts +22 -0
- package/src/plugins/list/unread-badge.ts +26 -0
- package/src/plugins/list/unread.ts +38 -0
- package/src/plugins/list/with-editor.ts +59 -0
- package/src/plugins/markdown.ts +10 -0
- package/src/plugins/stat.ts +79 -0
- package/src/plugins/version-check.ts +37 -0
- package/src/service.ts +34 -61
- package/src/style/comment.scss +5 -7
- package/src/style/editor.scss +5 -0
- package/src/style/list.scss +1 -1
- package/types/{artalk-config.d.ts → config.ts} +16 -2
- package/types/context.ts +84 -0
- package/types/{artalk-data.d.ts → data.ts} +41 -0
- package/types/editor.ts +95 -0
- package/types/event.ts +40 -0
- package/types/index.ts +7 -0
- package/types/plugin.ts +3 -0
- package/types/sidebar.ts +3 -0
- package/dist/src/comment/render-ctx.d.ts +0 -23
- package/dist/src/editor/edit-mode.d.ts +0 -9
- package/dist/src/editor/funcs.d.ts +0 -2
- package/dist/src/editor/index.d.ts +0 -2
- package/dist/src/editor/mover.d.ts +0 -8
- package/dist/src/editor/plug-manager.d.ts +0 -17
- package/dist/src/editor/plugs/editor-plug.d.ts +0 -38
- package/dist/src/editor/plugs/header-input-plug.d.ts +0 -13
- package/dist/src/editor/plugs/preview-plug.d.ts +0 -10
- package/dist/src/editor/plugs/upload-plug.d.ts +0 -10
- package/dist/src/editor/reply.d.ts +0 -9
- package/dist/src/editor/submit.d.ts +0 -16
- package/dist/src/lib/dark-mode.d.ts +0 -4
- package/dist/src/lib/stat.d.ts +0 -15
- package/dist/src/list/index.d.ts +0 -2
- package/dist/src/list/list-lite.d.ts +0 -77
- package/dist/src/list/list-ui.d.ts +0 -16
- package/dist/src/list/paginator/adaptors/index.d.ts +0 -12
- package/dist/src/list/paginator/adaptors/pagination.d.ts +0 -9
- package/dist/src/list/paginator/adaptors/read-more.d.ts +0 -10
- package/dist/src/list/paginator/holder.d.ts +0 -16
- package/dist/types/artalk-config.d.ts +0 -139
- package/dist/types/artalk-data.d.ts +0 -230
- package/dist/types/plug.d.ts +0 -4
- package/src/api/api-base.ts +0 -27
- package/src/comment/render-ctx.ts +0 -30
- package/src/editor/edit-mode.ts +0 -105
- package/src/editor/funcs.ts +0 -150
- package/src/editor/index.ts +0 -3
- package/src/editor/mover.ts +0 -43
- package/src/editor/plug-manager.ts +0 -172
- package/src/editor/plugs/editor-plug.ts +0 -69
- package/src/editor/plugs/header-input-plug.ts +0 -79
- package/src/editor/plugs/preview-plug.ts +0 -44
- package/src/editor/plugs/upload-plug.ts +0 -122
- package/src/editor/reply.ts +0 -62
- package/src/editor/submit.ts +0 -99
- package/src/lib/dark-mode.ts +0 -48
- package/src/lib/stat.ts +0 -71
- package/src/list/index.ts +0 -3
- package/src/list/list-lite.ts +0 -424
- package/src/list/list-ui.ts +0 -137
- package/src/list/paginator/adaptors/index.ts +0 -21
- package/src/list/paginator/adaptors/pagination.ts +0 -42
- package/src/list/paginator/adaptors/read-more.ts +0 -56
- package/src/list/paginator/holder.ts +0 -56
- package/types/context.d.ts +0 -142
- package/types/event.d.ts +0 -28
- package/types/plug.d.ts +0 -4
- /package/src/{editor/plugs/emoticons-plug.scss → plugins/editor/emoticons.scss} +0 -0
- /package/src/{editor/plugs/preview-plug.scss → plugins/editor/preview.scss} +0 -0
package/dist/types/context.d.ts
CHANGED
|
@@ -1,142 +1,62 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { SidebarShowPayload } from '../src/layer/sidebar-layer'
|
|
9
|
-
import { CheckerCaptchaPayload, CheckerPayload } from '../src/lib/checker'
|
|
10
|
-
import type { TMarked } from '../src/lib/marked'
|
|
11
|
-
import type { TInjectedServices } from '../src/service'
|
|
12
|
-
|
|
1
|
+
import type { TInjectedServices } from '../src/service';
|
|
2
|
+
import type { CheckerCaptchaPayload, CheckerPayload } from '../src/components/checker';
|
|
3
|
+
import type { EventManagerFuncs } from '../src/lib/event-manager';
|
|
4
|
+
import type { TMarked } from '../src/lib/marked';
|
|
5
|
+
import type { I18n } from '../src/i18n';
|
|
6
|
+
import type Api from '../src/api';
|
|
7
|
+
import type { SidebarShowPayload, EventPayloadMap, ArtalkConfig, CommentData, DataManagerApi, ListFetchParams, NotifyLevel } from '.';
|
|
13
8
|
/**
|
|
14
9
|
* Context 接口
|
|
15
10
|
*
|
|
16
11
|
* (面向接口的编程)
|
|
17
12
|
*/
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
/** 编辑评论 */
|
|
69
|
-
editComment(commentData: CommentData, $comment: HTMLElement): void
|
|
70
|
-
|
|
71
|
-
/** 取消编辑评论 */
|
|
72
|
-
cancelEditComment(): void
|
|
73
|
-
|
|
74
|
-
/** 更新通知数据 */
|
|
75
|
-
updateNotifies(notifies: NotifyData[]): void
|
|
76
|
-
|
|
77
|
-
/** 列表 - 重新加载数据 */
|
|
78
|
-
listReload(): void
|
|
79
|
-
|
|
80
|
-
/** 列表 - 重新加载数据 (别名) */
|
|
81
|
-
reload(): void
|
|
82
|
-
|
|
83
|
-
/** 列表 - UI 更新 */
|
|
84
|
-
listRefreshUI(): void
|
|
85
|
-
|
|
86
|
-
/** 列表 - HashGoto 功能检测 */
|
|
87
|
-
listHashGotoCheck(): void
|
|
88
|
-
|
|
89
|
-
/** 显示侧边栏 */
|
|
90
|
-
showSidebar(payload?: SidebarShowPayload): void
|
|
91
|
-
|
|
92
|
-
/** 隐藏侧边栏 */
|
|
93
|
-
hideSidebar(): void
|
|
94
|
-
|
|
95
|
-
/** 编辑器 - 关闭评论 */
|
|
96
|
-
editorClose(): void
|
|
97
|
-
|
|
98
|
-
/** 编辑器 - 打开评论 */
|
|
99
|
-
editorOpen(): void
|
|
100
|
-
|
|
101
|
-
/** 编辑器 - 显示加载 */
|
|
102
|
-
editorShowLoading(): void
|
|
103
|
-
|
|
104
|
-
/** 编辑器 - 隐藏加载 */
|
|
105
|
-
editorHideLoading(): void
|
|
106
|
-
|
|
107
|
-
/** 编辑器 - 显示提示消息 */
|
|
108
|
-
editorShowNotify(msg: string, type: "i" | "s" | "w" | "e"): void
|
|
109
|
-
|
|
110
|
-
/** 评论框 - 位置移动 */
|
|
111
|
-
editorTravel($el: HTMLElement): void
|
|
112
|
-
|
|
113
|
-
/** 评论框 - 位置回归 */
|
|
114
|
-
editorTravelBack(): void
|
|
115
|
-
|
|
116
|
-
/** 验证码检测 */
|
|
117
|
-
checkCaptcha(payload: CheckerCaptchaPayload): void
|
|
118
|
-
|
|
119
|
-
/** 管理员检测 */
|
|
120
|
-
checkAdmin(payload: CheckerPayload): void
|
|
121
|
-
|
|
122
|
-
/** 管理员显示元素可见性更新 */
|
|
123
|
-
checkAdminShowEl(): void
|
|
124
|
-
|
|
125
|
-
/** 订阅注册 */
|
|
126
|
-
on<K extends keyof EventPayloadMap>(name: K, handler: Handler<EventPayloadMap[K]>, scope?: EventScopeType): void
|
|
127
|
-
|
|
128
|
-
/** 订阅取消 */
|
|
129
|
-
off<K extends keyof EventPayloadMap>(name: K, handler?: Handler<EventPayloadMap[K]>, scope?: EventScopeType): void
|
|
130
|
-
|
|
131
|
-
/** 订阅发布 */
|
|
132
|
-
trigger<K extends keyof EventPayloadMap>(name: K, payload?: EventPayloadMap[K], scope?: EventScopeType): void
|
|
133
|
-
|
|
134
|
-
/** i18n 翻译 */
|
|
135
|
-
$t(key: keyof I18n, args?: {[key: string]: string}): string
|
|
136
|
-
|
|
137
|
-
/** 设置夜间模式 */
|
|
138
|
-
setDarkMode(darkMode: boolean): void
|
|
139
|
-
|
|
140
|
-
/** 更新配置 */
|
|
141
|
-
updateConf(conf: Partial<ArtalkConfig>): void
|
|
13
|
+
export interface ContextApi extends EventManagerFuncs<EventPayloadMap> {
|
|
14
|
+
/** Artalk 根元素对象 */
|
|
15
|
+
$root: HTMLElement;
|
|
16
|
+
/** 依赖注入函数 */
|
|
17
|
+
inject<K extends keyof TInjectedServices>(depName: K, obj: TInjectedServices[K]): void;
|
|
18
|
+
/** 获取依赖对象 */
|
|
19
|
+
get<K extends keyof TInjectedServices>(depName: K): TInjectedServices[K];
|
|
20
|
+
/** 配置对象 */
|
|
21
|
+
conf: ArtalkConfig;
|
|
22
|
+
/** marked 依赖对象 */
|
|
23
|
+
getMarked(): TMarked | undefined;
|
|
24
|
+
/** 获取 API 以供 HTTP 请求 */
|
|
25
|
+
getApi(): Api;
|
|
26
|
+
/** 获取数据管理器对象 */
|
|
27
|
+
getData(): DataManagerApi;
|
|
28
|
+
/** 评论回复 */
|
|
29
|
+
replyComment(commentData: CommentData, $comment: HTMLElement): void;
|
|
30
|
+
/** 编辑评论 */
|
|
31
|
+
editComment(commentData: CommentData, $comment: HTMLElement): void;
|
|
32
|
+
/** 获取评论数据 */
|
|
33
|
+
fetch(params: Partial<ListFetchParams>): void;
|
|
34
|
+
/** 重载评论数据 */
|
|
35
|
+
reload(): void;
|
|
36
|
+
/** 列表滚动到第一个评论的位置 */
|
|
37
|
+
listGotoFirst(): void;
|
|
38
|
+
/** 显示侧边栏 */
|
|
39
|
+
showSidebar(payload?: SidebarShowPayload): void;
|
|
40
|
+
/** 隐藏侧边栏 */
|
|
41
|
+
hideSidebar(): void;
|
|
42
|
+
/** 编辑器 - 显示加载 */
|
|
43
|
+
editorShowLoading(): void;
|
|
44
|
+
/** 编辑器 - 隐藏加载 */
|
|
45
|
+
editorHideLoading(): void;
|
|
46
|
+
/** 编辑器 - 显示提示消息 */
|
|
47
|
+
editorShowNotify(msg: string, type: NotifyLevel): void;
|
|
48
|
+
/** 评论框 - 复原状态 */
|
|
49
|
+
editorResetState(): void;
|
|
50
|
+
/** 验证码检测 */
|
|
51
|
+
checkCaptcha(payload: CheckerCaptchaPayload): void;
|
|
52
|
+
/** 管理员检测 */
|
|
53
|
+
checkAdmin(payload: CheckerPayload): void;
|
|
54
|
+
/** i18n 翻译 */
|
|
55
|
+
$t(key: keyof I18n, args?: {
|
|
56
|
+
[key: string]: string;
|
|
57
|
+
}): string;
|
|
58
|
+
/** 设置夜间模式 */
|
|
59
|
+
setDarkMode(darkMode: boolean | 'auto'): void;
|
|
60
|
+
/** 更新配置 */
|
|
61
|
+
updateConf(conf: Partial<ArtalkConfig>): void;
|
|
142
62
|
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
export interface CommentData {
|
|
2
|
+
/** 评论 ID */
|
|
3
|
+
id: number;
|
|
4
|
+
/** 评论正文 */
|
|
5
|
+
content: string;
|
|
6
|
+
/** 用户昵称 */
|
|
7
|
+
nick: string;
|
|
8
|
+
/** 用户邮箱 (该字段仅管理员可见) */
|
|
9
|
+
email?: string;
|
|
10
|
+
/** 用户邮箱(已加密) */
|
|
11
|
+
email_encrypted: string;
|
|
12
|
+
/** 用户链接 */
|
|
13
|
+
link: string;
|
|
14
|
+
/** 回复目标评论 ID */
|
|
15
|
+
rid: number;
|
|
16
|
+
/** User Agent */
|
|
17
|
+
ua: string;
|
|
18
|
+
/** 评论日期 */
|
|
19
|
+
date: string;
|
|
20
|
+
/** 是否折叠 */
|
|
21
|
+
is_collapsed?: boolean;
|
|
22
|
+
/** 是否待审 */
|
|
23
|
+
is_pending?: boolean;
|
|
24
|
+
/** 是否置顶 */
|
|
25
|
+
is_pinned?: boolean;
|
|
26
|
+
/** 是否为管理员 */
|
|
27
|
+
is_admin?: boolean;
|
|
28
|
+
/** 徽章文字 */
|
|
29
|
+
badge_name?: string;
|
|
30
|
+
/** 徽章颜色 */
|
|
31
|
+
badge_color?: string;
|
|
32
|
+
/** IP 归属地 */
|
|
33
|
+
ip_region?: string;
|
|
34
|
+
/** 是否允许回复 */
|
|
35
|
+
is_allow_reply?: boolean;
|
|
36
|
+
/** 评论页面 key */
|
|
37
|
+
page_key: string;
|
|
38
|
+
/** 评论页面 url */
|
|
39
|
+
page_url?: string;
|
|
40
|
+
/** 是否可见 */
|
|
41
|
+
visible: boolean;
|
|
42
|
+
/** 站点名(用于隔离) */
|
|
43
|
+
site_name: string;
|
|
44
|
+
/** 赞同数 */
|
|
45
|
+
vote_up: number;
|
|
46
|
+
/** 反对数 */
|
|
47
|
+
vote_down: number;
|
|
48
|
+
}
|
|
49
|
+
export interface ListData {
|
|
50
|
+
/** 评论数据 */
|
|
51
|
+
comments: CommentData[];
|
|
52
|
+
/** 根评论总数 */
|
|
53
|
+
total_roots: number;
|
|
54
|
+
/** 评论总数(包括所有子评论) */
|
|
55
|
+
total: number;
|
|
56
|
+
/** 页面信息 */
|
|
57
|
+
page: PageData;
|
|
58
|
+
/** 站点信息 */
|
|
59
|
+
site: SiteData;
|
|
60
|
+
/** 未读的 Notifies */
|
|
61
|
+
unread: NotifyData[];
|
|
62
|
+
/** 未读计数 */
|
|
63
|
+
unread_count: number;
|
|
64
|
+
/** API 版本 */
|
|
65
|
+
api_version: ApiVersionData;
|
|
66
|
+
/** 后端配置 */
|
|
67
|
+
conf: any;
|
|
68
|
+
}
|
|
69
|
+
export interface PageData {
|
|
70
|
+
/** 页面 ID */
|
|
71
|
+
id: number;
|
|
72
|
+
/** 页面唯一标识符 */
|
|
73
|
+
key: string;
|
|
74
|
+
/** 页面标题 */
|
|
75
|
+
title: string;
|
|
76
|
+
/** 页面 url */
|
|
77
|
+
url: string;
|
|
78
|
+
/** 仅管理员可评 */
|
|
79
|
+
admin_only: boolean;
|
|
80
|
+
/** 站点名(用于隔离) */
|
|
81
|
+
site_name: string;
|
|
82
|
+
/** 赞同数 */
|
|
83
|
+
vote_up: number;
|
|
84
|
+
/** 反对数 */
|
|
85
|
+
vote_down: number;
|
|
86
|
+
}
|
|
87
|
+
export interface SiteData {
|
|
88
|
+
/** 站点 ID */
|
|
89
|
+
id: number;
|
|
90
|
+
/** 站点名 */
|
|
91
|
+
name: string;
|
|
92
|
+
/** 站点 URLs */
|
|
93
|
+
urls: string[];
|
|
94
|
+
/** 站点 URLs(原始字符串) */
|
|
95
|
+
urls_raw: string;
|
|
96
|
+
/** 站点主 URL */
|
|
97
|
+
first_url: string;
|
|
98
|
+
}
|
|
99
|
+
export interface UserData {
|
|
100
|
+
/** 用户 ID */
|
|
101
|
+
id: number;
|
|
102
|
+
/** 用户名 */
|
|
103
|
+
name: string;
|
|
104
|
+
/** 邮箱 */
|
|
105
|
+
email: string;
|
|
106
|
+
/** 链接 */
|
|
107
|
+
link: string;
|
|
108
|
+
/** 徽章名称 */
|
|
109
|
+
badge_name: string;
|
|
110
|
+
/** 徽章颜色 */
|
|
111
|
+
badge_color: string;
|
|
112
|
+
/** 是否属于管理员 */
|
|
113
|
+
is_admin: boolean;
|
|
114
|
+
/** 所属站点名 */
|
|
115
|
+
site_names: string[];
|
|
116
|
+
/** 所属站点名 (字符串) */
|
|
117
|
+
site_names_raw: string;
|
|
118
|
+
/** 是否允许接收邮件通知 */
|
|
119
|
+
receive_email: boolean;
|
|
120
|
+
}
|
|
121
|
+
export interface UserDataForAdmin extends UserData {
|
|
122
|
+
/** 最后一次操作 IP */
|
|
123
|
+
last_ip: string;
|
|
124
|
+
/** 最后一次操作 UA */
|
|
125
|
+
last_ua: string;
|
|
126
|
+
/** 是否存在于配置文件中 */
|
|
127
|
+
is_in_conf: boolean;
|
|
128
|
+
/** 评论数 */
|
|
129
|
+
comment_count: number;
|
|
130
|
+
/** 密码 */
|
|
131
|
+
password: string;
|
|
132
|
+
}
|
|
133
|
+
export interface NotifyData {
|
|
134
|
+
/** 通知 ID */
|
|
135
|
+
id: number;
|
|
136
|
+
/** 用户 ID */
|
|
137
|
+
user_id: number;
|
|
138
|
+
/** 评论 ID */
|
|
139
|
+
comment_id: number;
|
|
140
|
+
/** 是否已读 */
|
|
141
|
+
is_read: boolean;
|
|
142
|
+
/** 是否已发送邮件通知 */
|
|
143
|
+
is_emailed: boolean;
|
|
144
|
+
/** 标为已读地址 */
|
|
145
|
+
read_link: string;
|
|
146
|
+
}
|
|
147
|
+
export type EmoticonGrpData = {
|
|
148
|
+
name: string;
|
|
149
|
+
type: 'emoticon' | 'image' | 'emoji';
|
|
150
|
+
items: {
|
|
151
|
+
key: string;
|
|
152
|
+
val: string;
|
|
153
|
+
}[];
|
|
154
|
+
};
|
|
155
|
+
export type EmoticonListData = EmoticonGrpData[];
|
|
156
|
+
export interface ApiVersionData {
|
|
157
|
+
/** API 程序名 */
|
|
158
|
+
app: string;
|
|
159
|
+
/** API 程序版本号 */
|
|
160
|
+
version: string;
|
|
161
|
+
/** API 程序 CommitHash */
|
|
162
|
+
commit_hash: string;
|
|
163
|
+
}
|
|
164
|
+
export interface ListFetchParams {
|
|
165
|
+
offset: number;
|
|
166
|
+
limit: number;
|
|
167
|
+
flatMode: boolean;
|
|
168
|
+
paramsModifier?: (p: any) => void;
|
|
169
|
+
onSuccess?: (data: ListData) => void;
|
|
170
|
+
onError?: (err: any) => void;
|
|
171
|
+
}
|
|
172
|
+
export interface ListLastFetchData {
|
|
173
|
+
params: ListFetchParams;
|
|
174
|
+
data?: ListData;
|
|
175
|
+
}
|
|
176
|
+
export interface DataManagerApi {
|
|
177
|
+
getLoading(): boolean;
|
|
178
|
+
setLoading(val: boolean): void;
|
|
179
|
+
getListLastFetch(): ListLastFetchData | undefined;
|
|
180
|
+
setListLastFetch(val: ListLastFetchData): void;
|
|
181
|
+
getComments(): CommentData[];
|
|
182
|
+
findComment(id: number): CommentData | undefined;
|
|
183
|
+
fetchComments(params: Partial<ListFetchParams>): void;
|
|
184
|
+
loadComments(comments: CommentData[]): void;
|
|
185
|
+
clearComments(): void;
|
|
186
|
+
insertComment(comment: CommentData): void;
|
|
187
|
+
updateComment(comment: CommentData): void;
|
|
188
|
+
deleteComment(id: number): void;
|
|
189
|
+
getUnreads(): NotifyData[];
|
|
190
|
+
updateUnreads(unreads: NotifyData[]): void;
|
|
191
|
+
getPage(): PageData | undefined;
|
|
192
|
+
updatePage(pageData: PageData): void;
|
|
193
|
+
}
|
|
194
|
+
export type NotifyLevel = "i" | "s" | "w" | "e";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { CommentData, NotifyLevel } from '.';
|
|
2
|
+
import type Component from '../src/lib/component';
|
|
3
|
+
import type { EditorUI } from '../src/editor/ui';
|
|
4
|
+
export type EditorState = 'reply' | 'edit' | 'normal';
|
|
5
|
+
export interface EditorApi extends Component {
|
|
6
|
+
getUI(): EditorUI;
|
|
7
|
+
/**
|
|
8
|
+
* Get the header input elements
|
|
9
|
+
*/
|
|
10
|
+
getHeaderInputEls(): Record<string, HTMLInputElement>;
|
|
11
|
+
/**
|
|
12
|
+
* Set content
|
|
13
|
+
*/
|
|
14
|
+
setContent(val: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Insert content
|
|
17
|
+
*/
|
|
18
|
+
insertContent(val: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Get the final content
|
|
21
|
+
*
|
|
22
|
+
* This function returns the raw content or the content transformed through a plugin hook.
|
|
23
|
+
*/
|
|
24
|
+
getContentFinal(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Get the raw content which is inputed by user
|
|
27
|
+
*/
|
|
28
|
+
getContentRaw(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Get the HTML format content which is rendered by marked (a markdown parser)
|
|
31
|
+
*/
|
|
32
|
+
getContentMarked(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Get editor current state
|
|
35
|
+
*/
|
|
36
|
+
getState(): EditorState;
|
|
37
|
+
/**
|
|
38
|
+
* Focus editor
|
|
39
|
+
*/
|
|
40
|
+
focus(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Reset editor
|
|
43
|
+
*/
|
|
44
|
+
reset(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Reset editor UI
|
|
47
|
+
*
|
|
48
|
+
* call it will move editor to the initial position
|
|
49
|
+
*/
|
|
50
|
+
resetState(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Submit comment
|
|
53
|
+
*/
|
|
54
|
+
submit(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Show notification message
|
|
57
|
+
*/
|
|
58
|
+
showNotify(msg: string, type: NotifyLevel): void;
|
|
59
|
+
/**
|
|
60
|
+
* Show loading on editor
|
|
61
|
+
*/
|
|
62
|
+
showLoading(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Hide loading on editor
|
|
65
|
+
*/
|
|
66
|
+
hideLoading(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Start replaying a comment
|
|
69
|
+
*/
|
|
70
|
+
setReply(commentData: CommentData, $comment: HTMLElement, scroll?: boolean): void;
|
|
71
|
+
/**
|
|
72
|
+
* Start editing a comment
|
|
73
|
+
*/
|
|
74
|
+
setEditComment(commentData: CommentData, $comment: HTMLElement): void;
|
|
75
|
+
}
|
|
76
|
+
export default EditorApi;
|
package/dist/types/event.d.ts
CHANGED
|
@@ -1,28 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
'list-loaded': undefined // 评论装载后
|
|
8
|
-
'list-inserted': CommentData // 评论插入后
|
|
9
|
-
'editor-submit': undefined // 编辑器提交时
|
|
10
|
-
'editor-submitted': undefined // 编辑器提交后
|
|
11
|
-
'user-changed': LocalUser // 本地用户数据变更时
|
|
12
|
-
'conf-loaded': undefined // Artalk 配置变更时
|
|
13
|
-
'sidebar-show': undefined // 侧边栏显示
|
|
14
|
-
'sidebar-hide': undefined // 侧边栏隐藏
|
|
1
|
+
import type Comment from '../src/comment';
|
|
2
|
+
import { CommentData, ListData, ListFetchParams, NotifyData, PageData } from './data';
|
|
3
|
+
import { ArtalkConfig, LocalUser } from './config';
|
|
4
|
+
interface ErrorData {
|
|
5
|
+
msg: string;
|
|
6
|
+
data?: any;
|
|
15
7
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
interface ListFetchedArgs {
|
|
9
|
+
params: Partial<ListFetchParams>;
|
|
10
|
+
data?: ListData;
|
|
11
|
+
error?: ErrorData;
|
|
20
12
|
}
|
|
21
|
-
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
13
|
+
/** EventName to EventPayload Type */
|
|
14
|
+
export interface EventPayloadMap {
|
|
15
|
+
'inited': undefined;
|
|
16
|
+
'destroy': undefined;
|
|
17
|
+
'list-fetch': Partial<ListFetchParams>;
|
|
18
|
+
'list-fetched': ListFetchedArgs;
|
|
19
|
+
'list-load': CommentData[];
|
|
20
|
+
'list-loaded': CommentData[];
|
|
21
|
+
'list-error': ErrorData;
|
|
22
|
+
'list-goto-first': undefined;
|
|
23
|
+
'list-reach-bottom': undefined;
|
|
24
|
+
'comment-inserted': CommentData;
|
|
25
|
+
'comment-updated': CommentData;
|
|
26
|
+
'comment-deleted': CommentData;
|
|
27
|
+
'comment-rendered': Comment;
|
|
28
|
+
'unreads-updated': NotifyData[];
|
|
29
|
+
'list-goto': number;
|
|
30
|
+
'page-loaded': PageData;
|
|
31
|
+
'editor-submit': undefined;
|
|
32
|
+
'editor-submitted': undefined;
|
|
33
|
+
'user-changed': LocalUser;
|
|
34
|
+
'conf-loaded': ArtalkConfig;
|
|
35
|
+
'dark-mode-changed': boolean;
|
|
36
|
+
'sidebar-show': undefined;
|
|
37
|
+
'sidebar-hide': undefined;
|
|
28
38
|
}
|
|
39
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "artalk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "A Selfhosted Comment System",
|
|
6
6
|
"keywords": [
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"jsdelivr": "./dist/Artalk.iife.js",
|
|
23
23
|
"module": "./dist/Artalk.es.js",
|
|
24
24
|
"types": "./dist/src/main.d.ts",
|
|
25
|
+
"typings": "./dist/src/main.d.ts",
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"@types/marked": "5.0.1"
|
|
27
28
|
},
|
|
@@ -41,6 +42,8 @@
|
|
|
41
42
|
"deploy": "gh-pages -d deploy",
|
|
42
43
|
"predeploy": "pnpm build && pnpm build:demo && pnpm copy:deploy",
|
|
43
44
|
"copy:deploy": "cp -r dist deploy && cp CNAME deploy",
|
|
44
|
-
"lint": "eslint --ext .js,.ts src"
|
|
45
|
+
"lint": "eslint --ext .js,.ts src",
|
|
46
|
+
"test:e2e": "playwright test",
|
|
47
|
+
"test:report": "playwright show-report"
|
|
45
48
|
}
|
|
46
49
|
}
|
package/src/api/_base.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ApiOptions } from './_options'
|
|
2
|
+
import { POST, Fetch } from './_request'
|
|
3
|
+
|
|
4
|
+
abstract class ApiBase {
|
|
5
|
+
constructor(
|
|
6
|
+
protected options: ApiOptions
|
|
7
|
+
) {}
|
|
8
|
+
|
|
9
|
+
protected async POST<T>(path: string, data?: {[key: string]: any}) {
|
|
10
|
+
return POST<T>(this.options, this.options.baseURL+path, data)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
protected async Fetch(path: string, init: RequestInit, timeout?: number): Promise<any> {
|
|
14
|
+
return Fetch(this.options, this.options.baseURL+path, init, timeout)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default ApiBase
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ApiOptions {
|
|
2
|
+
baseURL: string
|
|
3
|
+
siteName: string
|
|
4
|
+
pageKey: string
|
|
5
|
+
pageTitle: string
|
|
6
|
+
timeout?: number
|
|
7
|
+
|
|
8
|
+
// -------------------------------------------------------------------
|
|
9
|
+
// Hooks
|
|
10
|
+
// -------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
onNeedCheckCaptcha?: (payload: {
|
|
13
|
+
recall: () => void
|
|
14
|
+
reject: () => void
|
|
15
|
+
data: {
|
|
16
|
+
imgData: string
|
|
17
|
+
iframe: string
|
|
18
|
+
}
|
|
19
|
+
}) => void
|
|
20
|
+
|
|
21
|
+
onNeedCheckAdmin?: (payload: {
|
|
22
|
+
recall: () => void
|
|
23
|
+
reject: () => void
|
|
24
|
+
}) => void
|
|
25
|
+
}
|