artalk 2.6.3 → 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.
Files changed (300) hide show
  1. package/dist/Artalk.css +1 -1
  2. package/dist/Artalk.es.js +7673 -7330
  3. package/dist/Artalk.iife.js +1 -1
  4. package/dist/Artalk.js +1 -1
  5. package/dist/ArtalkLite.css +1 -1
  6. package/dist/ArtalkLite.es.js +5304 -4961
  7. package/dist/ArtalkLite.iife.js +1 -1
  8. package/dist/ArtalkLite.js +1 -1
  9. package/dist/src/api/{api-base.d.ts → _base.d.ts} +3 -7
  10. package/dist/src/api/_options.d.ts +19 -0
  11. package/dist/src/api/{request.d.ts → _request.d.ts} +3 -3
  12. package/dist/src/api/admin.d.ts +1 -1
  13. package/dist/src/api/captcha.d.ts +1 -1
  14. package/dist/src/api/comment.d.ts +2 -2
  15. package/dist/src/api/index.d.ts +2 -4
  16. package/dist/src/api/page.d.ts +3 -3
  17. package/dist/src/api/site.d.ts +2 -2
  18. package/dist/src/api/system.d.ts +13 -3
  19. package/dist/src/api/upload.d.ts +1 -1
  20. package/dist/src/api/user.d.ts +2 -2
  21. package/dist/src/artalk.d.ts +14 -37
  22. package/dist/src/comment/actions.d.ts +1 -1
  23. package/dist/src/comment/comment.d.ts +3 -4
  24. package/dist/src/comment/render.d.ts +21 -3
  25. package/dist/src/comment/renders/actions.d.ts +2 -2
  26. package/dist/src/comment/renders/avatar.d.ts +2 -2
  27. package/dist/src/comment/renders/content.d.ts +2 -2
  28. package/dist/src/comment/renders/header.d.ts +2 -2
  29. package/dist/src/comment/renders/index.d.ts +2 -2
  30. package/dist/src/comment/renders/pending.d.ts +2 -2
  31. package/dist/src/comment/renders/reply-at.d.ts +2 -2
  32. package/dist/src/comment/renders/reply-to.d.ts +2 -2
  33. package/dist/src/components/action-btn.d.ts +3 -5
  34. package/dist/src/{lib → components}/checker/admin.d.ts +1 -1
  35. package/dist/src/{lib → components}/checker/captcha-renders.d.ts +1 -1
  36. package/dist/src/{lib → components}/checker/captcha.d.ts +1 -1
  37. package/dist/src/{lib → components}/checker/index.d.ts +10 -7
  38. package/dist/src/components/dark-mode.d.ts +2 -0
  39. package/dist/src/components/dialog.d.ts +1 -3
  40. package/dist/src/components/error-dialog.d.ts +8 -0
  41. package/dist/src/components/pagination.d.ts +4 -3
  42. package/dist/src/components/read-more-btn.d.ts +3 -3
  43. package/dist/src/config.d.ts +24 -8
  44. package/dist/src/context.d.ts +16 -35
  45. package/dist/src/data.d.ts +27 -0
  46. package/dist/src/defaults.d.ts +1 -1
  47. package/dist/src/editor/editor.d.ts +14 -59
  48. package/dist/src/editor/state.d.ts +20 -0
  49. package/dist/src/i18n/zh-CN.d.ts +1 -1
  50. package/dist/src/layer/index.d.ts +4 -3
  51. package/dist/src/layer/layer-manager.d.ts +9 -0
  52. package/dist/src/layer/layer.d.ts +8 -28
  53. package/dist/src/layer/scrollbar-helper.d.ts +5 -0
  54. package/dist/src/layer/sidebar-layer.d.ts +6 -6
  55. package/dist/src/layer/wrap.d.ts +13 -0
  56. package/dist/src/lib/component.d.ts +3 -8
  57. package/dist/src/lib/event-manager.d.ts +28 -0
  58. package/dist/src/lib/highlight.d.ts +1 -0
  59. package/dist/src/lib/marked-renderer.d.ts +4 -0
  60. package/dist/src/lib/marked.d.ts +4 -2
  61. package/dist/src/lib/sanitizer.d.ts +1 -0
  62. package/dist/src/lib/ui.d.ts +3 -2
  63. package/dist/src/lib/user.d.ts +8 -5
  64. package/dist/src/lib/utils.d.ts +11 -5
  65. package/dist/src/list/comment.d.ts +3 -0
  66. package/dist/src/list/layout.d.ts +23 -0
  67. package/dist/src/list/list.d.ts +13 -25
  68. package/dist/src/list/{list-nest.d.ts → nest.d.ts} +1 -1
  69. package/dist/src/list/page.d.ts +2 -0
  70. package/dist/src/list/paginator/index.d.ts +22 -7
  71. package/dist/src/list/paginator/read-more.d.ts +18 -0
  72. package/dist/src/list/paginator/up-down.d.ts +14 -0
  73. package/dist/src/main.d.ts +2 -0
  74. package/dist/src/plugins/admin-only-elem.d.ts +2 -0
  75. package/dist/src/plugins/conf-remoter.d.ts +2 -0
  76. package/dist/src/plugins/dark-mode.d.ts +2 -0
  77. package/dist/src/plugins/editor/_kit.d.ts +27 -0
  78. package/dist/src/plugins/editor/_plug.d.ts +29 -0
  79. package/dist/src/plugins/editor/_sample.d.ts +5 -0
  80. package/dist/src/plugins/editor/closable.d.ts +7 -0
  81. package/dist/src/{editor/plugs/emoticons-plug.d.ts → plugins/editor/emoticons.d.ts} +10 -16
  82. package/dist/src/plugins/editor/header-event.d.ts +6 -0
  83. package/dist/src/plugins/editor/header-link.d.ts +6 -0
  84. package/dist/src/plugins/editor/header-user.d.ts +16 -0
  85. package/dist/src/plugins/editor/index.d.ts +6 -0
  86. package/dist/src/plugins/editor/local-storage.d.ts +6 -0
  87. package/dist/src/plugins/editor/mover.d.ts +6 -0
  88. package/dist/src/plugins/editor/preview.d.ts +7 -0
  89. package/dist/src/plugins/editor/state-edit.d.ts +11 -0
  90. package/dist/src/plugins/editor/state-reply.d.ts +8 -0
  91. package/dist/src/plugins/editor/submit-add.d.ts +18 -0
  92. package/dist/src/plugins/editor/submit-btn.d.ts +5 -0
  93. package/dist/src/plugins/editor/submit.d.ts +17 -0
  94. package/dist/src/plugins/editor/textarea.d.ts +8 -0
  95. package/dist/src/plugins/editor/upload.d.ts +9 -0
  96. package/dist/src/plugins/editor-kit.d.ts +42 -0
  97. package/dist/src/plugins/index.d.ts +2 -0
  98. package/dist/src/plugins/list/copyright.d.ts +2 -0
  99. package/dist/src/plugins/list/count.d.ts +2 -0
  100. package/dist/src/plugins/list/dropdown.d.ts +2 -0
  101. package/dist/src/plugins/list/error-dialog.d.ts +2 -0
  102. package/dist/src/plugins/list/fetch.d.ts +2 -0
  103. package/dist/src/plugins/list/goto-first.d.ts +3 -0
  104. package/dist/src/plugins/list/goto.d.ts +2 -0
  105. package/dist/src/plugins/list/index.d.ts +3 -0
  106. package/dist/src/plugins/list/loading.d.ts +2 -0
  107. package/dist/src/plugins/list/no-comment.d.ts +2 -0
  108. package/dist/src/plugins/list/reach-bottom.d.ts +2 -0
  109. package/dist/src/plugins/list/sidebar-btn.d.ts +2 -0
  110. package/dist/src/plugins/list/time-ticking.d.ts +3 -0
  111. package/dist/src/plugins/list/unread-badge.d.ts +2 -0
  112. package/dist/src/plugins/list/unread.d.ts +2 -0
  113. package/dist/src/plugins/list/with-editor.d.ts +2 -0
  114. package/dist/src/plugins/markdown.d.ts +2 -0
  115. package/dist/src/plugins/stat.d.ts +13 -0
  116. package/dist/src/plugins/version-check.d.ts +2 -0
  117. package/dist/src/service.d.ts +19 -23
  118. package/dist/tests/e2e/comment-add.spec.d.ts +1 -0
  119. package/dist/types/config.d.ts +110 -0
  120. package/dist/types/context.d.ts +56 -136
  121. package/dist/types/data.d.ts +194 -0
  122. package/dist/types/editor.d.ts +76 -0
  123. package/dist/types/event.d.ts +36 -25
  124. package/dist/types/index.d.ts +7 -0
  125. package/dist/types/plugin.d.ts +2 -0
  126. package/dist/types/sidebar.d.ts +3 -0
  127. package/package.json +5 -2
  128. package/src/api/_base.ts +18 -0
  129. package/src/api/_options.ts +25 -0
  130. package/src/api/{request.ts → _request.ts} +19 -18
  131. package/src/api/admin.ts +1 -1
  132. package/src/api/captcha.ts +1 -1
  133. package/src/api/comment.ts +4 -4
  134. package/src/api/index.ts +3 -12
  135. package/src/api/page.ts +5 -5
  136. package/src/api/site.ts +2 -2
  137. package/src/api/system.ts +19 -7
  138. package/src/api/upload.ts +3 -3
  139. package/src/api/user.ts +3 -3
  140. package/src/artalk.ts +49 -97
  141. package/src/comment/actions.ts +1 -4
  142. package/src/comment/comment.ts +9 -6
  143. package/src/comment/render.ts +27 -5
  144. package/src/comment/renders/actions.ts +45 -45
  145. package/src/comment/renders/avatar.ts +7 -7
  146. package/src/comment/renders/content.ts +18 -18
  147. package/src/comment/renders/header.ts +13 -13
  148. package/src/comment/renders/index.ts +3 -3
  149. package/src/comment/renders/pending.ts +5 -5
  150. package/src/comment/renders/reply-at.ts +8 -8
  151. package/src/comment/renders/reply-to.ts +13 -13
  152. package/src/components/action-btn.ts +11 -13
  153. package/src/{lib → components}/checker/admin.ts +6 -6
  154. package/src/{lib → components}/checker/captcha-renders.ts +7 -6
  155. package/src/{lib → components}/checker/captcha.ts +1 -1
  156. package/src/{lib → components}/checker/index.ts +21 -26
  157. package/src/components/dark-mode.ts +30 -0
  158. package/src/components/dialog.ts +4 -9
  159. package/src/components/error-dialog.ts +35 -0
  160. package/src/components/pagination.ts +10 -6
  161. package/src/components/read-more-btn.ts +7 -7
  162. package/src/config.ts +60 -6
  163. package/src/context.ts +39 -144
  164. package/src/data.ts +110 -0
  165. package/src/defaults.ts +1 -1
  166. package/src/editor/editor.ts +41 -146
  167. package/src/editor/state.ts +52 -0
  168. package/src/i18n/zh-CN.ts +1 -1
  169. package/src/layer/index.ts +4 -4
  170. package/src/layer/layer-manager.ts +32 -0
  171. package/src/layer/layer.ts +20 -144
  172. package/src/layer/scrollbar-helper.ts +24 -0
  173. package/src/layer/sidebar-layer.ts +74 -64
  174. package/src/layer/wrap.ts +77 -0
  175. package/src/lib/component.ts +4 -11
  176. package/src/lib/detect.ts +1 -1
  177. package/src/lib/event-manager.ts +47 -0
  178. package/src/lib/highlight.ts +5 -0
  179. package/src/lib/marked-renderer.ts +32 -0
  180. package/src/lib/marked.ts +43 -104
  181. package/src/lib/sanitizer.ts +57 -0
  182. package/src/lib/ui.ts +22 -15
  183. package/src/lib/user.ts +21 -16
  184. package/src/lib/utils.ts +29 -18
  185. package/src/list/comment.ts +20 -0
  186. package/src/list/layout.ts +120 -0
  187. package/src/list/list.html +3 -1
  188. package/src/list/list.ts +56 -200
  189. package/src/list/{list-nest.ts → nest.ts} +1 -1
  190. package/src/list/page.ts +97 -0
  191. package/src/list/paginator/index.ts +20 -8
  192. package/src/list/paginator/read-more.ts +67 -0
  193. package/src/list/paginator/up-down.ts +51 -0
  194. package/src/main.ts +2 -0
  195. package/src/plugins/admin-only-elem.ts +40 -0
  196. package/src/plugins/conf-remoter.ts +54 -0
  197. package/src/plugins/dark-mode.ts +12 -0
  198. package/src/plugins/editor/_kit.ts +57 -0
  199. package/src/plugins/editor/_plug.ts +60 -0
  200. package/src/plugins/editor/_sample.ts +8 -0
  201. package/src/plugins/editor/closable.ts +44 -0
  202. package/src/{editor/plugs/emoticons-plug.ts → plugins/editor/emoticons.ts} +51 -52
  203. package/src/plugins/editor/header-event.ts +35 -0
  204. package/src/plugins/editor/header-link.ts +31 -0
  205. package/src/plugins/editor/header-user.ts +98 -0
  206. package/src/plugins/editor/index.ts +40 -0
  207. package/src/plugins/editor/local-storage.ts +36 -0
  208. package/src/plugins/editor/mover.ts +29 -0
  209. package/src/plugins/editor/preview.ts +41 -0
  210. package/src/plugins/editor/state-edit.ts +116 -0
  211. package/src/plugins/editor/state-reply.ts +91 -0
  212. package/src/plugins/editor/submit-add.ts +33 -0
  213. package/src/plugins/editor/submit-btn.ts +25 -0
  214. package/src/plugins/editor/submit.ts +73 -0
  215. package/src/plugins/editor/textarea.ts +55 -0
  216. package/src/plugins/editor/upload.ts +145 -0
  217. package/src/plugins/editor-kit.ts +161 -0
  218. package/src/plugins/index.ts +16 -0
  219. package/src/plugins/list/copyright.ts +16 -0
  220. package/src/plugins/list/count.ts +31 -0
  221. package/src/plugins/list/dropdown.ts +95 -0
  222. package/src/plugins/list/error-dialog.ts +22 -0
  223. package/src/plugins/list/fetch.ts +64 -0
  224. package/src/plugins/list/goto-first.ts +23 -0
  225. package/src/plugins/list/goto.ts +72 -0
  226. package/src/plugins/list/index.ts +25 -0
  227. package/src/plugins/list/loading.ts +17 -0
  228. package/src/plugins/list/no-comment.ts +25 -0
  229. package/src/plugins/list/reach-bottom.ts +46 -0
  230. package/src/plugins/list/sidebar-btn.ts +39 -0
  231. package/src/plugins/list/time-ticking.ts +22 -0
  232. package/src/plugins/list/unread-badge.ts +26 -0
  233. package/src/plugins/list/unread.ts +38 -0
  234. package/src/plugins/list/with-editor.ts +59 -0
  235. package/src/plugins/markdown.ts +10 -0
  236. package/src/plugins/stat.ts +79 -0
  237. package/src/plugins/version-check.ts +37 -0
  238. package/src/service.ts +34 -61
  239. package/src/style/comment.scss +5 -7
  240. package/src/style/editor.scss +5 -0
  241. package/src/style/list.scss +2 -7
  242. package/types/{artalk-config.d.ts → config.ts} +16 -2
  243. package/types/context.ts +84 -0
  244. package/{dist/types/artalk-data.d.ts → types/data.ts} +41 -0
  245. package/types/editor.ts +95 -0
  246. package/types/event.ts +40 -0
  247. package/types/index.ts +7 -0
  248. package/types/plugin.ts +3 -0
  249. package/types/sidebar.ts +3 -0
  250. package/dist/src/comment/render-ctx.d.ts +0 -23
  251. package/dist/src/editor/edit-mode.d.ts +0 -9
  252. package/dist/src/editor/funcs.d.ts +0 -2
  253. package/dist/src/editor/index.d.ts +0 -2
  254. package/dist/src/editor/mover.d.ts +0 -8
  255. package/dist/src/editor/plug-manager.d.ts +0 -17
  256. package/dist/src/editor/plugs/editor-plug.d.ts +0 -38
  257. package/dist/src/editor/plugs/header-input-plug.d.ts +0 -13
  258. package/dist/src/editor/plugs/preview-plug.d.ts +0 -10
  259. package/dist/src/editor/plugs/upload-plug.d.ts +0 -10
  260. package/dist/src/editor/reply.d.ts +0 -9
  261. package/dist/src/editor/submit.d.ts +0 -16
  262. package/dist/src/lib/dark-mode.d.ts +0 -4
  263. package/dist/src/lib/stat.d.ts +0 -15
  264. package/dist/src/list/index.d.ts +0 -2
  265. package/dist/src/list/list-lite.d.ts +0 -77
  266. package/dist/src/list/list-ui.d.ts +0 -16
  267. package/dist/src/list/paginator/adaptors/index.d.ts +0 -12
  268. package/dist/src/list/paginator/adaptors/pagination.d.ts +0 -9
  269. package/dist/src/list/paginator/adaptors/read-more.d.ts +0 -10
  270. package/dist/src/list/paginator/holder.d.ts +0 -16
  271. package/dist/types/artalk-config.d.ts +0 -139
  272. package/dist/types/plug.d.ts +0 -4
  273. package/src/api/api-base.ts +0 -27
  274. package/src/comment/render-ctx.ts +0 -30
  275. package/src/editor/edit-mode.ts +0 -103
  276. package/src/editor/funcs.ts +0 -97
  277. package/src/editor/index.ts +0 -3
  278. package/src/editor/mover.ts +0 -43
  279. package/src/editor/plug-manager.ts +0 -172
  280. package/src/editor/plugs/editor-plug.ts +0 -69
  281. package/src/editor/plugs/header-input-plug.ts +0 -79
  282. package/src/editor/plugs/preview-plug.ts +0 -44
  283. package/src/editor/plugs/upload-plug.ts +0 -122
  284. package/src/editor/reply.ts +0 -62
  285. package/src/editor/submit.ts +0 -99
  286. package/src/lib/dark-mode.ts +0 -48
  287. package/src/lib/stat.ts +0 -71
  288. package/src/list/index.ts +0 -3
  289. package/src/list/list-lite.ts +0 -424
  290. package/src/list/list-ui.ts +0 -137
  291. package/src/list/paginator/adaptors/index.ts +0 -21
  292. package/src/list/paginator/adaptors/pagination.ts +0 -42
  293. package/src/list/paginator/adaptors/read-more.ts +0 -56
  294. package/src/list/paginator/holder.ts +0 -56
  295. package/types/artalk-data.d.ts +0 -230
  296. package/types/context.d.ts +0 -142
  297. package/types/event.d.ts +0 -28
  298. package/types/plug.d.ts +0 -4
  299. /package/src/{editor/plugs/emoticons-plug.scss → plugins/editor/emoticons.scss} +0 -0
  300. /package/src/{editor/plugs/preview-plug.scss → plugins/editor/preview.scss} +0 -0
@@ -1,10 +0,0 @@
1
- import Editor from '../editor';
2
- import EditorPlug from './editor-plug';
3
- export default class UploadPlug extends EditorPlug {
4
- static Name: string;
5
- $imgUploadInput?: HTMLInputElement;
6
- /** 允许的图片格式 */
7
- allowImgExts: string[];
8
- constructor(editor: Editor);
9
- uploadImg(file: File): Promise<void>;
10
- }
@@ -1,9 +0,0 @@
1
- import type { CommentData } from '../../types/artalk-data';
2
- import Editor from './editor';
3
- export interface ReplyManager {
4
- editor: Editor;
5
- comment?: CommentData;
6
- setReply(comment: CommentData, $comment: HTMLElement, scroll?: boolean): void;
7
- cancelReply(): void;
8
- }
9
- export declare function createReplyManager(editor: Editor): ReplyManager;
@@ -1,16 +0,0 @@
1
- import type { CommentData } from '../../types/artalk-data';
2
- import Editor from './editor';
3
- export interface SubmitManager {
4
- editor: Editor;
5
- do: () => Promise<void>;
6
- customs: CustomSubmit[];
7
- registerCustom(c: CustomSubmit): void;
8
- }
9
- export declare function createSubmitManager(editor: Editor): SubmitManager;
10
- interface CustomSubmit {
11
- activeCond: () => void;
12
- pre?: () => void;
13
- req?: () => Promise<CommentData>;
14
- post?: (nComment: CommentData) => void;
15
- }
16
- export {};
@@ -1,4 +0,0 @@
1
- import type Context from '../../types/context';
2
- export declare function syncDarkModeConf(ctx: Context): void;
3
- export declare function setDarkMode(ctx: Context, darkMode: boolean | 'auto', alterConf?: boolean): void;
4
- export declare function updateClassName(ctx: Context, darkMode: boolean): void;
@@ -1,15 +0,0 @@
1
- import ContextApi from '../../types/context';
2
- import ArtalkPlug from '../../types/plug';
3
- export interface CountConf {
4
- ctx: ContextApi;
5
- /** 是否增加当前页面 PV 数 */
6
- pvAdd?: boolean;
7
- }
8
- export declare const PvCountWidget: ArtalkPlug;
9
- /** 初始化评论数和 PV 数量展示元素 */
10
- export declare function initCountWidget(p: CountConf): Promise<void>;
11
- export declare function handleStatCount(p: CountConf, args: {
12
- api: 'page_pv' | 'page_comment';
13
- countEl: string;
14
- curtPageCount?: number;
15
- }): Promise<void>;
@@ -1,2 +0,0 @@
1
- import List from './list';
2
- export default List;
@@ -1,77 +0,0 @@
1
- import { ListData, CommentData, NotifyData } from '../../types/artalk-data';
2
- import Context from '../../types/context';
3
- import Component from '../lib/component';
4
- import Comment from '../comment';
5
- import PgHolder, { TPgMode } from './paginator';
6
- import * as ListNest from './list-nest';
7
- export default class ListLite extends Component {
8
- /** 列表评论集区域元素 */
9
- protected $commentsWrap: HTMLElement;
10
- /** 最后一次请求得到的列表数据 */
11
- protected data?: ListData;
12
- /** 是否处于加载中状态 */
13
- protected isLoading: boolean;
14
- /** 配置是否已加载 */
15
- private confLoaded;
16
- /** 无评论显示文字 */
17
- noCommentText?: string;
18
- /** 嵌套模式下的排序方式 */
19
- private _nestSortBy?;
20
- get nestSortBy(): ListNest.SortByType;
21
- set nestSortBy(val: ListNest.SortByType);
22
- /** 平铺模式 */
23
- private _flatMode?;
24
- get flatMode(): boolean;
25
- set flatMode(val: boolean);
26
- /** 分页方式 */
27
- _pageMode?: TPgMode;
28
- get pageMode(): 'pagination' | 'read-more';
29
- set pageMode(val: 'pagination' | 'read-more');
30
- /** 分页方式持有者 */
31
- pgHolder?: PgHolder;
32
- /** 每页数量 (每次请求获取量) */
33
- private _pageSize?;
34
- get pageSize(): number;
35
- set pageSize(val: number);
36
- /** 监听指定元素上的滚动 */
37
- scrollListenerAt?: HTMLElement;
38
- /** 翻页归位到指定元素 */
39
- repositionAt?: HTMLElement;
40
- renderComment?: (comment: Comment) => void;
41
- paramsEditor?: (params: any) => void;
42
- onAfterLoad?: (data: ListData) => void;
43
- /** 未读标记 */
44
- protected unread: NotifyData[];
45
- unreadHighlight?: boolean;
46
- constructor(ctx: Context);
47
- getData(): ListData | undefined;
48
- clearData(): void;
49
- getLoading(): boolean;
50
- getCommentsWrapEl(): HTMLElement;
51
- /** 设置加载状态 */
52
- setLoading(val: boolean, isFirstLoad?: boolean): void;
53
- /** 评论获取 */
54
- fetchComments(offset: number): Promise<void>;
55
- protected onLoad(data: ListData, offset: number): void;
56
- /** 分页模式 */
57
- private refreshPagination;
58
- /** 错误处理 */
59
- protected onError(msg: any, offset: number, errData?: any): void;
60
- /** 刷新界面 */
61
- refreshUI(): void;
62
- /** 重新加载列表 */
63
- reload(): void;
64
- /** 创建新评论 */
65
- protected createComment(cData: CommentData, ctxData?: CommentData[]): Comment;
66
- /** 导入评论 · 通过请求数据 */
67
- importComments(srcData: CommentData[]): void;
68
- private importCommentsNest;
69
- /** 导入评论 · 平铺模式 */
70
- private putCommentFlatMode;
71
- /** 新增评论 · 首部添加 */
72
- insertComment(commentData: CommentData): void;
73
- /** 更新评论 */
74
- updateComment(commentData: CommentData): void;
75
- /** 更新未读数据 */
76
- updateUnread(notifies: NotifyData[]): void;
77
- }
@@ -1,16 +0,0 @@
1
- import ListLite from './list-lite';
2
- /** 界面刷新 */
3
- export declare function refreshUI(list: ListLite): void;
4
- /** 构建错误提示界面 */
5
- export declare function renderErrorDialog(list: ListLite, errMsg: string, errData?: any): HTMLElement;
6
- /** 版本检测弹窗 */
7
- export declare function versionCheckDialog(list: ListLite, feVer: string, beVer: string): boolean;
8
- /** 评论排序方式选择下拉菜单 */
9
- export declare function renderDropdown(conf: {
10
- $dropdownWrap: HTMLElement;
11
- dropdownList: [string, () => void][];
12
- }): void;
13
- /** 删除评论排序方式选择下拉菜单 */
14
- export declare function removeDropdown(conf: {
15
- $dropdownWrap: HTMLElement;
16
- }): void;
@@ -1,12 +0,0 @@
1
- import { IPgHolderConf, TPgMode } from '../index';
2
- declare const Adaptors: Record<TPgMode, IPgAdaptor<any>>;
3
- export default Adaptors;
4
- export interface IPgAdaptor<T> {
5
- instance: T;
6
- el: HTMLElement;
7
- createInstance(conf: IPgHolderConf): [T, HTMLElement];
8
- setLoading(val: boolean): void;
9
- update(offset: number, total: number): void;
10
- next(): void;
11
- showErr?(msg: string): void;
12
- }
@@ -1,9 +0,0 @@
1
- import Pagination from '../../../components/pagination';
2
- import { IPgAdaptor } from '.';
3
- interface IPaginationAdaptor extends IPgAdaptor<Pagination> {
4
- }
5
- /**
6
- * 翻页形式的分页
7
- */
8
- declare const _default: IPaginationAdaptor;
9
- export default _default;
@@ -1,10 +0,0 @@
1
- import ReadMoreBtn from '../../../components/read-more-btn';
2
- import { IPgAdaptor } from '.';
3
- interface IReadMoreAdaptor extends IPgAdaptor<ReadMoreBtn> {
4
- autoLoadScrollEvent?: () => void;
5
- }
6
- /**
7
- * 阅读更多形式的分页
8
- */
9
- declare const _default: IReadMoreAdaptor;
10
- export default _default;
@@ -1,16 +0,0 @@
1
- import { IPgHolderConf, TPgMode } from '.';
2
- /**
3
- * 分页方式持有者(调度器)
4
- */
5
- export default class PgHolder {
6
- private conf;
7
- constructor(conf: IPgHolderConf);
8
- getAdaptor(): import("./adaptors").IPgAdaptor<any>;
9
- init(): void;
10
- setLoading(val: boolean): void;
11
- update(offset: number, total: number): void;
12
- getEl(): HTMLElement;
13
- showErr(msg: string): void;
14
- setMode(val: TPgMode): void;
15
- next(): void;
16
- }
@@ -1,139 +0,0 @@
1
- import { I18n } from '../src/i18n'
2
- import { CommentData } from './artalk-data'
3
-
4
- export default interface ArtalkConfig {
5
- /** 装载元素 */
6
- el: string|HTMLElement
7
-
8
- /** 页面唯一标识(完整 URL) */
9
- pageKey: string
10
-
11
- /** 页面标题 */
12
- pageTitle: string
13
-
14
- /** 服务器地址 */
15
- server: string
16
-
17
- /** 站点名 */
18
- site: string
19
-
20
- /** 评论框占位字符 */
21
- placeholder: string
22
-
23
- /** 评论为空时显示字符 */
24
- noComment: string
25
-
26
- /** 发送按钮文字 */
27
- sendBtn: string
28
-
29
- /** 评论框穿梭(显示在待回复评论后面) */
30
- editorTravel: boolean
31
-
32
- /** 表情包 */
33
- emoticons: object|any[]|string|false
34
-
35
- /** Gravatar 头像 */
36
- gravatar: {
37
- /** API 地址 */
38
- mirror: string
39
- /** API 参数 */
40
- params: string
41
- }
42
-
43
- /** 头像链接生成器 */
44
- avatarURLBuilder?: (comment: CommentData) => string,
45
-
46
- /** 分页配置 */
47
- pagination: {
48
- /** 每次请求获取数量 */
49
- pageSize: number
50
- /** 阅读更多模式 */
51
- readMore: boolean
52
- /** 滚动到底部自动加载 */
53
- autoLoad: boolean
54
- }
55
-
56
- /** 内容限高 */
57
- heightLimit: {
58
- /** 评论内容限高 */
59
- content: number
60
-
61
- /** 子评论区域限高 */
62
- children: number
63
-
64
- /** 滚动限高 */
65
- scrollable: boolean
66
- }
67
-
68
- /** 评论投票按钮 */
69
- vote: boolean
70
-
71
- /** 评论投票反对按钮 */
72
- voteDown: boolean
73
-
74
- /** 评论预览功能 */
75
- preview: boolean
76
-
77
- /** 评论数绑定元素 Selector */
78
- countEl: string
79
-
80
- /** PV 数绑定元素 Selector */
81
- pvEl: string
82
-
83
- /** 夜间模式 */
84
- darkMode: boolean|'auto'
85
-
86
- /** 请求超时(单位:秒) */
87
- reqTimeout: number
88
-
89
- /** 平铺模式 */
90
- flatMode: boolean|'auto'
91
-
92
- /** 嵌套模式 · 最大层数 */
93
- nestMax: number
94
-
95
- /** 嵌套模式 · 排序方式 */
96
- nestSort: 'DATE_ASC'|'DATE_DESC'
97
-
98
- /** 显示 UA 徽标 */
99
- uaBadge: boolean
100
-
101
- /** 评论列表排序功能 (显示 Dropdown) */
102
- listSort: boolean
103
-
104
- /** 图片上传功能 */
105
- imgUpload: boolean
106
-
107
- /** 图片上传器 */
108
- imgUploader?: (file: File) => Promise<string>
109
-
110
- /** 版本检测 */
111
- versionCheck: boolean
112
-
113
- /** 引用后端配置 */
114
- useBackendConf: boolean
115
-
116
- /** 语言本地化 */
117
- locale: I18n|string
118
- }
119
-
120
- /**
121
- * 本地持久化用户数据
122
- * @note 始终保持一层结构,不支持多层结构
123
- */
124
- export interface LocalUser {
125
- /** 昵称 */
126
- nick: string
127
-
128
- /** 邮箱 */
129
- email: string
130
-
131
- /** 链接 */
132
- link: string
133
-
134
- /** TOKEN */
135
- token: string
136
-
137
- /** 是否为管理员 */
138
- isAdmin: boolean
139
- }
@@ -1,4 +0,0 @@
1
- import ContextApi from './context'
2
-
3
- type ArtalkPlug = (ctx: ContextApi) => void
4
- export default ArtalkPlug
@@ -1,27 +0,0 @@
1
- import Context from '~/types/context'
2
- import Api from '.'
3
- import { POST, Fetch } from './request'
4
-
5
- abstract class ApiBase {
6
- protected api: Api
7
- protected ctx: Context
8
-
9
- constructor(api: Api, ctx: Context) {
10
- this.api = api
11
- this.ctx = ctx
12
- }
13
-
14
- protected async POST<T>(path: string, data?: {[key: string]: any}) {
15
- return POST<T>(this.ctx, this.api.baseURL+path, data)
16
- }
17
-
18
- protected async Fetch(path: string, init: RequestInit, timeout?: number): Promise<any> {
19
- return Fetch(this.ctx, this.api.baseURL+path, init, timeout)
20
- }
21
- }
22
-
23
- interface ApiBase {
24
-
25
- }
26
-
27
- export default ApiBase
@@ -1,30 +0,0 @@
1
- import Comment from './comment'
2
- import ActionBtn from '../components/action-btn'
3
-
4
- export default class RenderCtx {
5
- public comment: Comment
6
-
7
- public get ctx() { return this.comment.ctx }
8
- public get data() { return this.comment.getData() }
9
- public get conf() { return this.comment.conf }
10
- public get cConf() { return this.comment.getConf() }
11
-
12
- public $el!: HTMLElement
13
- public $main!: HTMLElement
14
- public $header!: HTMLElement
15
- public $headerNick!: HTMLElement
16
- public $headerBadgeWrap!: HTMLElement
17
- public $body!: HTMLElement
18
- public $content!: HTMLElement
19
- public $childrenWrap!: HTMLElement|null
20
- public $actions!: HTMLElement
21
- public voteBtnUp?: ActionBtn
22
- public voteBtnDown?: ActionBtn
23
-
24
- public $replyTo?: HTMLElement // 回复评论内容 (平铺下显示)
25
- public $replyAt?: HTMLElement // 回复 AT(层级嵌套下显示)
26
-
27
- public constructor(comment: Comment) {
28
- this.comment = comment
29
- }
30
- }
@@ -1,103 +0,0 @@
1
- import type { CommentData } from '~/types/artalk-data'
2
- import * as Utils from '../lib/utils'
3
- import Editor from './editor'
4
- import User from '../lib/user'
5
-
6
- export interface EditModeManager {
7
- editor: Editor
8
- comment?: CommentData
9
- setEdit: (comment: CommentData, $comment: HTMLElement) => void
10
- cancelEdit: () => void
11
- }
12
-
13
- export function createEditModeManager(editor: Editor) {
14
- const m: EditModeManager = {
15
- editor,
16
- comment: undefined,
17
- setEdit: (c, e) => edit(m, c, e),
18
- cancelEdit: () => cancelEdit(m)
19
- }
20
-
21
- initEditModeSubmit(m)
22
-
23
- return m
24
- }
25
-
26
- function edit(m: EditModeManager, comment: CommentData, $comment: HTMLElement) {
27
- cancelEdit(m)
28
- m.editor.cancelReply()
29
-
30
- const ui = m.editor.getUI()
31
- if (!ui.$editCancelBtn) {
32
- const $btn = Utils.createElement(
33
- `<div class="atk-send-reply">` +
34
- `${m.editor.$t('editCancel')} ` +
35
- `<span class="atk-cancel">×</span>` +
36
- `</div>`
37
- )
38
- $btn.onclick = () => {
39
- cancelEdit(m)
40
- }
41
- ui.$textareaWrap.append($btn)
42
- ui.$editCancelBtn = $btn
43
- }
44
- m.comment = comment
45
-
46
- ui.$header.style.display = 'none' // TODO support modify header information
47
-
48
- m.editor.travel($comment)
49
-
50
- ui.$nick.value = comment.nick || ''
51
- ui.$email.value = comment.email || ''
52
- ui.$link.value = comment.link || ''
53
-
54
- m.editor.setContent(comment.content)
55
- ui.$textarea.focus()
56
-
57
- m.editor.refreshSendBtnText()
58
- }
59
-
60
- function cancelEdit(m: EditModeManager) {
61
- if (!m.comment) return
62
-
63
- const ui = m.editor.getUI()
64
-
65
- if (ui.$editCancelBtn) {
66
- ui.$editCancelBtn.remove()
67
- ui.$editCancelBtn = undefined
68
- }
69
-
70
- m.comment = undefined
71
- m.editor.travelBack()
72
-
73
- const { nick, email, link } = User.data
74
- ui.$nick.value = nick
75
- ui.$email.value = email
76
- ui.$link.value = link
77
-
78
- m.editor.setContent('')
79
- m.editor.refreshSendBtnText()
80
-
81
- ui.$header.style.display = '' // TODO support modify header information
82
- }
83
-
84
- function initEditModeSubmit(m: EditModeManager) {
85
- m.editor.getSubmitManager()!.registerCustom({
86
- activeCond: () => !!m.comment, // active this custom submit when edit mode
87
- req: async () => {
88
- const saveData = {
89
- content: m.editor.getFinalContent(),
90
- nick: m.editor.getUI().$nick.value,
91
- email: m.editor.getUI().$email.value,
92
- link: m.editor.getUI().$link.value,
93
- }
94
- const nComment = await m.editor.ctx.getApi().comment.commentEdit({
95
- ...m.comment, ...saveData
96
- })
97
- return nComment
98
- },
99
- post: (nComment: CommentData) => {
100
- m.editor.ctx.updateComment(nComment)
101
- }
102
- })
103
- }
@@ -1,97 +0,0 @@
1
- import Editor from './editor'
2
- import User from '../lib/user'
3
- import { createMover } from './mover'
4
- import { createPlugManager } from './plug-manager'
5
- import { createReplyManager } from './reply'
6
- import { createEditModeManager } from './edit-mode'
7
- import { createSubmitManager } from './submit'
8
-
9
- const EditorFuncs = {
10
- localStorage, header, textarea, submitBtn, submitManager,
11
- plugs, mover, replyManager, editModeManager,
12
- }
13
-
14
- export default function initEditorFuncs(editor: Editor) {
15
- Object.entries(EditorFuncs).forEach(([k, init]) => {
16
- init(editor)
17
- })
18
- }
19
-
20
- // ================== Editor Functions ======================
21
-
22
- function localStorage(editor: Editor) {
23
- const localContent = window.localStorage.getItem('ArtalkContent') || ''
24
- if (localContent.trim() !== '') {
25
- editor.showNotify(editor.$t('restoredMsg'), 'i')
26
- editor.setContent(localContent)
27
- }
28
-
29
- editor.getUI().$textarea.addEventListener('input', () => (editor.saveToLocalStorage()))
30
- }
31
-
32
- function header(editor: Editor) {
33
- const $inputs = editor.getHeaderInputEls()
34
- Object.entries($inputs).forEach(([key, $input]) => {
35
- $input.value = User.data[key] || ''
36
- $input.addEventListener('input', () => onHeaderInput(editor, key, $input))
37
-
38
- // 设置 Placeholder
39
- $input.placeholder = `${editor.$t(key as any)}`
40
- })
41
- }
42
-
43
- function onHeaderInput(editor: Editor, field: string, $input: HTMLInputElement) {
44
- if (editor.isEditMode) return // 评论编辑模式,不修改个人信息
45
-
46
- User.update({
47
- [field]: $input.value.trim()
48
- })
49
-
50
- editor.getPlugs()?.triggerHeaderInputEvt(field, $input)
51
- }
52
-
53
- function textarea(editor: Editor) {
54
- // 占位符
55
- editor.getUI().$textarea.placeholder = editor.ctx.conf.placeholder || editor.$t('placeholder')
56
-
57
- // 修复按下 Tab 输入的内容
58
- editor.getUI().$textarea.addEventListener('keydown', (e) => {
59
- const keyCode = e.keyCode || e.which
60
-
61
- if (keyCode === 9) {
62
- e.preventDefault()
63
- editor.insertContent('\t')
64
- }
65
- })
66
-
67
- // 输入框高度随内容而变化
68
- editor.getUI().$textarea.addEventListener('input', () => {
69
- editor.adjustTextareaHeight()
70
- })
71
- }
72
-
73
- function submitBtn(editor: Editor) {
74
- editor.refreshSendBtnText()
75
- editor.getUI().$submitBtn.addEventListener('click', () => (editor.submit()))
76
- }
77
-
78
- function plugs(editor: Editor) {
79
- editor.setPlugs(createPlugManager(editor))
80
- }
81
-
82
- function mover(editor: Editor) {
83
- if (!editor.conf.editorTravel) return
84
- editor.setMover(createMover(editor))
85
- }
86
-
87
- function replyManager(editor: Editor) {
88
- editor.setReplyManager(createReplyManager(editor))
89
- }
90
-
91
- function editModeManager(editor: Editor) {
92
- editor.setEditModeManager(createEditModeManager(editor))
93
- }
94
-
95
- function submitManager(editor: Editor) {
96
- editor.setSubmitManager(createSubmitManager(editor))
97
- }
@@ -1,3 +0,0 @@
1
- import Editor from './editor'
2
-
3
- export default Editor
@@ -1,43 +0,0 @@
1
- import Editor from './editor'
2
- import * as Utils from '../lib/utils'
3
-
4
- export interface Mover {
5
- editor: Editor
6
- isMoved: boolean
7
- move(afterEl: HTMLElement): void
8
- back(): void
9
- }
10
-
11
- export function createMover(editor: Editor): Mover {
12
- const m: Mover = {
13
- editor,
14
- isMoved: false,
15
- move: (el) => move(m, el),
16
- back: () => back(m)
17
- }
18
-
19
- return m
20
- }
21
-
22
- function move(m: Mover, afterEl: HTMLElement) {
23
- if (m.isMoved) return
24
- m.isMoved = true
25
-
26
- const editorEl = m.editor.getUI().$el
27
-
28
- editorEl.after(Utils.createElement('<div class="atk-editor-travel-placeholder"></div>'))
29
-
30
- const $travelPlace = Utils.createElement('<div></div>')
31
- afterEl.after($travelPlace)
32
- $travelPlace.replaceWith(editorEl)
33
-
34
- editorEl.classList.add('atk-fade-in') // 添加渐入动画
35
- }
36
-
37
- function back(m: Mover) {
38
- if (!m.isMoved) return
39
- m.isMoved = false
40
- m.editor.ctx.$root.querySelector('.atk-editor-travel-placeholder')?.replaceWith(m.editor.getUI().$el)
41
-
42
- m.editor.cancelReply() // 取消回复
43
- }