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,2 +1,4 @@
1
1
  import Artalk from './artalk';
2
+ import * as ArtalkType from '../types';
3
+ export { ArtalkType };
2
4
  export default Artalk;
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../types';
2
+ export declare const AdminOnlyElem: ArtalkPlugin;
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../types';
2
+ export declare const ConfRemoter: ArtalkPlugin;
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../types';
2
+ export declare const DarkMode: ArtalkPlugin;
@@ -0,0 +1,27 @@
1
+ import type { PlugManager } from '../editor-kit';
2
+ import type EditorPlug from "./_plug";
3
+ /**
4
+ * PlugKit provides a set of methods to help you develop editor plug
5
+ */
6
+ export default class PlugKit {
7
+ private plugs;
8
+ constructor(plugs: PlugManager);
9
+ /** Use the editor */
10
+ useEditor(): import("../../../types").EditorApi;
11
+ /** Use the context of global */
12
+ useGlobalCtx(): import("../../../types").ContextApi;
13
+ /** Use the config of Artalk */
14
+ useConf(): import("../../../types").ArtalkConfig;
15
+ /** Use the http api client */
16
+ useApi(): import("../../api").default;
17
+ /** Use the ui of editor */
18
+ useUI(): import("../../editor/ui").EditorUI;
19
+ /** Use the events in editor scope */
20
+ useEvents(): import("../../lib/event-manager").default<import("../editor-kit").EditorEventPayloadMap>;
21
+ /** Listen the event when plug is mounted */
22
+ useMounted(func: () => void): void;
23
+ /** Listen the event when plug is unmounted */
24
+ useUnmounted(func: () => void): void;
25
+ /** Use the deps of other plug */
26
+ useDeps<T extends typeof EditorPlug>(plug: T): InstanceType<T> | undefined;
27
+ }
@@ -0,0 +1,29 @@
1
+ import type { CommentData, EditorState } from '../../../types';
2
+ import type PlugKit from './_kit';
3
+ /**
4
+ * Editor 插件
5
+ */
6
+ interface EditorPlug {
7
+ $btn?: HTMLElement;
8
+ $panel?: HTMLElement;
9
+ contentTransformer?(rawContent: string): string;
10
+ editorStateEffectWhen?: EditorState;
11
+ editorStateEffect?(comment: CommentData): () => void;
12
+ }
13
+ declare class EditorPlug {
14
+ protected kit: PlugKit;
15
+ constructor(kit: PlugKit);
16
+ /** Use plug btn will add a btn on the bottom of editor */
17
+ useBtn(html?: string): HTMLElement;
18
+ /** Use plug panel will show the panel when btn is clicked */
19
+ usePanel(html?: string): HTMLElement;
20
+ /** Use the content transformer to handle the content of the last submit by the editor */
21
+ useContentTransformer(func: (raw: string) => string): void;
22
+ /** Listen the event of panel show */
23
+ usePanelShow(func: () => void): void;
24
+ /** Listen the event of panel hide */
25
+ usePanelHide(func: () => void): void;
26
+ /** Use editor state modifier */
27
+ useEditorStateEffect(stateName: EditorState, effectFn: (comment: CommentData) => () => void): void;
28
+ }
29
+ export default EditorPlug;
@@ -0,0 +1,5 @@
1
+ import EditorPlug from './_plug';
2
+ import type PlugKit from './_kit';
3
+ export default class SamplePlug extends EditorPlug {
4
+ constructor(kit: PlugKit);
5
+ }
@@ -0,0 +1,7 @@
1
+ import EditorPlug from './_plug';
2
+ import type PlugKit from './_kit';
3
+ export default class Closable extends EditorPlug {
4
+ constructor(kit: PlugKit);
5
+ private open;
6
+ private close;
7
+ }
@@ -1,19 +1,13 @@
1
- import { EmoticonListData } from '../../../types/artalk-data';
2
- import EditorPlug from './editor-plug';
3
- import Editor from '../editor';
4
- export default class EmoticonsPlug extends EditorPlug {
5
- editor: Editor;
6
- static Name: string;
7
- protected $panel: HTMLElement;
8
- emoticons: EmoticonListData;
9
- loadingTask: Promise<void> | null;
10
- $grpWrap: HTMLElement;
11
- $grpSwitcher: HTMLElement;
12
- constructor(editor: Editor);
13
- onPanelShow(): void;
14
- onPanelHide(): void;
15
- isListLoaded: boolean;
16
- isImgLoaded: boolean;
1
+ import EditorPlug from './_plug';
2
+ import type PlugKit from './_kit';
3
+ export default class Emoticons extends EditorPlug {
4
+ private emoticons;
5
+ private loadingTask;
6
+ private $grpWrap;
7
+ private $grpSwitcher;
8
+ constructor(kit: PlugKit);
9
+ private isListLoaded;
10
+ private isImgLoaded;
17
11
  loadEmoticonsData(): Promise<void>;
18
12
  private handleData;
19
13
  /** 远程加载 */
@@ -0,0 +1,6 @@
1
+ import EditorPlug from './_plug';
2
+ import type PlugKit from './_kit';
3
+ export default class HeaderEvent extends EditorPlug {
4
+ private get $inputs();
5
+ constructor(kit: PlugKit);
6
+ }
@@ -0,0 +1,6 @@
1
+ import EditorPlug from './_plug';
2
+ import type PlugKit from './_kit';
3
+ export default class HeaderLink extends EditorPlug {
4
+ constructor(kit: PlugKit);
5
+ private onLinkInputChange;
6
+ }
@@ -0,0 +1,16 @@
1
+ import EditorPlug from './_plug';
2
+ import type PlugKit from './_kit';
3
+ export default class HeaderUser extends EditorPlug {
4
+ constructor(kit: PlugKit);
5
+ private query;
6
+ /**
7
+ * Fetch user info from server
8
+ */
9
+ private fetchUserInfo;
10
+ /**
11
+ * Function called when user info fetched
12
+ *
13
+ * @param data The response data from server
14
+ */
15
+ private onUserInfoFetched;
16
+ }
@@ -0,0 +1,6 @@
1
+ import type { ArtalkConfig } from '../../../types';
2
+ import type EditorPlug from './_plug';
3
+ /** The default enabled plugs */
4
+ export declare const ENABLED_PLUGS: (typeof EditorPlug)[];
5
+ /** Get the name list of disabled plugs */
6
+ export declare function getDisabledPlugByConf(conf: ArtalkConfig): (typeof EditorPlug)[];
@@ -0,0 +1,6 @@
1
+ import type PlugKit from './_kit';
2
+ import EditorPlug from './_plug';
3
+ export default class LocalStorage extends EditorPlug {
4
+ constructor(kit: PlugKit);
5
+ save(): void;
6
+ }
@@ -0,0 +1,6 @@
1
+ import EditorPlug from './_plug';
2
+ export default class Mover extends EditorPlug {
3
+ private isMoved;
4
+ move(afterEl: HTMLElement): void;
5
+ back(): void;
6
+ }
@@ -0,0 +1,7 @@
1
+ import EditorPlug from './_plug';
2
+ import type PlugKit from './_kit';
3
+ export default class Preview extends EditorPlug {
4
+ private isPlugPanelShow;
5
+ constructor(kit: PlugKit);
6
+ updateContent(): void;
7
+ }
@@ -0,0 +1,11 @@
1
+ import type PlugKit from './_kit';
2
+ import EditorPlug from './_plug';
3
+ export default class StateEdit extends EditorPlug {
4
+ private comment?;
5
+ constructor(kit: PlugKit);
6
+ private edit;
7
+ private cancelEdit;
8
+ private originalSubmitBtnText;
9
+ private updateSubmitBtnText;
10
+ private restoreSubmitBtnText;
11
+ }
@@ -0,0 +1,8 @@
1
+ import EditorPlug from './_plug';
2
+ import type PlugKit from './_kit';
3
+ export default class StateReply extends EditorPlug {
4
+ private comment?;
5
+ constructor(kit: PlugKit);
6
+ private setReply;
7
+ private cancelReply;
8
+ }
@@ -0,0 +1,18 @@
1
+ import type { CommentData } from '../../../types';
2
+ import type PlugKit from './_kit';
3
+ export default class SubmitAddPreset {
4
+ private kit;
5
+ constructor(kit: PlugKit);
6
+ reqAdd(): Promise<CommentData>;
7
+ getSubmitAddParams(): {
8
+ content: string;
9
+ nick: string;
10
+ email: string;
11
+ link: string;
12
+ rid: number;
13
+ page_key: string;
14
+ page_title: string;
15
+ site_name: string;
16
+ };
17
+ postSubmitAdd(commentNew: CommentData): void;
18
+ }
@@ -0,0 +1,5 @@
1
+ import EditorPlug from './_plug';
2
+ import type PlugKit from './_kit';
3
+ export default class SubmitBtn extends EditorPlug {
4
+ constructor(kit: PlugKit);
5
+ }
@@ -0,0 +1,17 @@
1
+ import type { CommentData } from '../../../types';
2
+ import EditorPlug from './_plug';
3
+ import type PlugKit from './_kit';
4
+ interface CustomSubmit {
5
+ activeCond: () => void;
6
+ pre?: () => void;
7
+ req?: () => Promise<CommentData>;
8
+ post?: (nComment: CommentData) => void;
9
+ }
10
+ export default class Submit extends EditorPlug {
11
+ private customs;
12
+ private defaultPreset;
13
+ constructor(kit: PlugKit);
14
+ registerCustom(c: CustomSubmit): void;
15
+ private do;
16
+ }
17
+ export {};
@@ -0,0 +1,8 @@
1
+ import EditorPlug from './_plug';
2
+ import type PlugKit from './_kit';
3
+ export default class Textarea extends EditorPlug {
4
+ constructor(kit: PlugKit);
5
+ private onKeydown;
6
+ private onInput;
7
+ adaptiveHeightByContent(): void;
8
+ }
@@ -0,0 +1,9 @@
1
+ import type PlugKit from './_kit';
2
+ import EditorPlug from './_plug';
3
+ export default class Upload extends EditorPlug {
4
+ private $imgUploadInput?;
5
+ constructor(kit: PlugKit);
6
+ private init;
7
+ private initDragImg;
8
+ uploadImg(file: File): Promise<void>;
9
+ }
@@ -0,0 +1,42 @@
1
+ import type { EditorApi, ArtalkPlugin } from '../../types';
2
+ import EventManager from '../lib/event-manager';
3
+ import EditorPlug from './editor/_plug';
4
+ export interface EditorEventPayloadMap {
5
+ 'mounted': undefined;
6
+ 'unmounted': undefined;
7
+ 'header-input': {
8
+ field: string;
9
+ $input: HTMLInputElement;
10
+ };
11
+ 'header-change': {
12
+ field: string;
13
+ $input: HTMLInputElement;
14
+ };
15
+ 'content-updated': string;
16
+ 'panel-show': EditorPlug;
17
+ 'panel-hide': EditorPlug;
18
+ 'panel-close': undefined;
19
+ 'editor-close': undefined;
20
+ 'editor-open': undefined;
21
+ }
22
+ export declare const EditorKit: ArtalkPlugin;
23
+ export declare class PlugManager {
24
+ editor: EditorApi;
25
+ private plugs;
26
+ private openedPlug;
27
+ private events;
28
+ getPlugs(): EditorPlug[];
29
+ getEvents(): EventManager<EditorEventPayloadMap>;
30
+ private clear;
31
+ constructor(editor: EditorApi);
32
+ private loadPluginUI;
33
+ /** Load the plug btn and plug panel on editor ui */
34
+ private loadPluginItem;
35
+ get<T extends typeof EditorPlug>(plug: T): InstanceType<T> | undefined;
36
+ /** Open the editor plug panel */
37
+ openPlugPanel(plug: EditorPlug): void;
38
+ /** Close the editor plug panel */
39
+ closePlugPanel(): void;
40
+ /** Get the content which is transformed by plugs */
41
+ getTransformedContent(rawContent: string): string;
42
+ }
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../types';
2
+ export declare const DefaultPlugins: ArtalkPlugin[];
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../../types';
2
+ export declare const Copyright: ArtalkPlugin;
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../../types';
2
+ export declare const Count: ArtalkPlugin;
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../../types';
2
+ export declare const Dropdown: ArtalkPlugin;
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../../types';
2
+ export declare const ErrorDialog: ArtalkPlugin;
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../../types';
2
+ export declare const Fetch: ArtalkPlugin;
@@ -0,0 +1,3 @@
1
+ import type { ArtalkPlugin } from '../../../types';
2
+ /** List scroll to the first comment */
3
+ export declare const GotoFirst: ArtalkPlugin;
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../../types';
2
+ export declare const Goto: ArtalkPlugin;
@@ -0,0 +1,3 @@
1
+ import type { ArtalkPlugin } from '../../../types';
2
+ declare const ListPlugins: ArtalkPlugin[];
3
+ export { ListPlugins };
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../../types';
2
+ export declare const Loading: ArtalkPlugin;
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../../types';
2
+ export declare const NoComment: ArtalkPlugin;
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../../types';
2
+ export declare const ReachBottom: ArtalkPlugin;
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../../types';
2
+ export declare const SidebarBtn: ArtalkPlugin;
@@ -0,0 +1,3 @@
1
+ import type { ArtalkPlugin } from '../../../types';
2
+ /** 评论时间自动更新 */
3
+ export declare const TimeTicking: ArtalkPlugin;
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../../types';
2
+ export declare const UnreadBadge: ArtalkPlugin;
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../../types';
2
+ export declare const Unread: ArtalkPlugin;
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../../types';
2
+ export declare const WithEditor: ArtalkPlugin;
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../types';
2
+ export declare const Markdown: ArtalkPlugin;
@@ -0,0 +1,13 @@
1
+ import type { ArtalkPlugin } from '../../types';
2
+ import Api from '../api';
3
+ export interface CountOptions {
4
+ getApi(): Api;
5
+ pageKey: string;
6
+ countEl: string;
7
+ pvEl: string;
8
+ /** 是否增加当前页面 PV 数 */
9
+ pvAdd?: boolean;
10
+ }
11
+ export declare const PvCountWidget: ArtalkPlugin;
12
+ /** 初始化评论数和 PV 数量展示元素 */
13
+ export declare function initCountWidget(opt: CountOptions): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { ArtalkPlugin } from '../../types';
2
+ export declare const VersionCheck: ArtalkPlugin;
@@ -1,35 +1,31 @@
1
- import Context from '../types/context';
2
- import CheckerLauncher from './lib/checker';
3
- import Api from './api';
4
- import Editor from './editor';
1
+ import type { ContextApi } from '../types';
2
+ import CheckerLauncher from './components/checker';
3
+ import Editor from './editor/editor';
5
4
  import SidebarLayer from './layer/sidebar-layer';
6
- import ListLite from './list/list-lite';
5
+ import List from './list/list';
6
+ import { PlugManager } from './plugins/editor-kit';
7
+ import { LayerManager } from './layer/layer-manager';
7
8
  /**
8
9
  * Services
9
10
  *
10
- * @description
11
- * 当函数有返回值时,该值将自动添加到 Context 类作为一个 private 成员的值,
12
- * 这个成员的名称与函数名对应。可在 Context 类中访问该对象(同事类)。
11
+ * @description Call these services by `ctx.get('serviceName')` or `ctx.serviceName`
13
12
  */
14
13
  declare const services: {
15
- i18n(ctx: Context): void;
16
- markdown(): void;
17
- user(ctx: Context): {
18
- ctx?: Context | undefined;
19
- data: import("../types/artalk-config").LocalUser;
20
- setContext(ctx: Context): void;
21
- update(obj?: Partial<import("../types/artalk-config").LocalUser>): void;
14
+ i18n(ctx: ContextApi): void;
15
+ user(ctx: ContextApi): {
16
+ data: import('../types').LocalUser;
17
+ onUserChanged: ((user: import('../types').LocalUser) => void) | null;
18
+ update(obj?: Partial<import('../types').LocalUser>): void;
19
+ setOnUserChanged(fn: ((user: import('../types').LocalUser) => void) | null): void;
22
20
  logout(): void;
23
21
  checkHasBasicUserInfo(): boolean;
24
22
  };
25
- api(ctx: Context): Api;
26
- checkerLauncher(ctx: Context): CheckerLauncher;
27
- editor(ctx: Context): Editor;
28
- list(ctx: Context): ListLite | undefined;
29
- layer(ctx: Context): void;
30
- sidebarLayer(ctx: Context): SidebarLayer;
31
- eventsDefault(ctx: Context): void;
32
- darkMode(ctx: Context): void;
23
+ layerManager(ctx: ContextApi): LayerManager;
24
+ checkerLauncher(ctx: ContextApi): CheckerLauncher;
25
+ editor(ctx: ContextApi): Editor;
26
+ list(ctx: ContextApi): List;
27
+ sidebarLayer(ctx: ContextApi): SidebarLayer;
28
+ editorPlugs(): PlugManager | undefined;
33
29
  };
34
30
  export default services;
35
31
  type TServiceImps = typeof services;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,110 @@
1
+ import { I18n } from '../src/i18n';
2
+ import { CommentData } from './data';
3
+ export interface ArtalkConfig {
4
+ /** 装载元素 */
5
+ el: string | HTMLElement;
6
+ /** 页面唯一标识(完整 URL) */
7
+ pageKey: string;
8
+ /** 页面标题 */
9
+ pageTitle: string;
10
+ /** 服务器地址 */
11
+ server: string;
12
+ /** 站点名 */
13
+ site: string;
14
+ /** 评论框占位字符 */
15
+ placeholder: string;
16
+ /** 评论为空时显示字符 */
17
+ noComment: string;
18
+ /** 发送按钮文字 */
19
+ sendBtn: string;
20
+ /** 评论框穿梭(显示在待回复评论后面) */
21
+ editorTravel: boolean;
22
+ /** 表情包 */
23
+ emoticons: object | any[] | string | false;
24
+ /** Gravatar 头像 */
25
+ gravatar: {
26
+ /** API 地址 */
27
+ mirror: string;
28
+ /** API 参数 */
29
+ params: string;
30
+ };
31
+ /** 头像链接生成器 */
32
+ avatarURLBuilder?: (comment: CommentData) => string;
33
+ /** 分页配置 */
34
+ pagination: {
35
+ /** 每次请求获取数量 */
36
+ pageSize: number;
37
+ /** 阅读更多模式 */
38
+ readMore: boolean;
39
+ /** 滚动到底部自动加载 */
40
+ autoLoad: boolean;
41
+ };
42
+ /** 内容限高 */
43
+ heightLimit: {
44
+ /** 评论内容限高 */
45
+ content: number;
46
+ /** 子评论区域限高 */
47
+ children: number;
48
+ /** 滚动限高 */
49
+ scrollable: boolean;
50
+ };
51
+ /** 评论投票按钮 */
52
+ vote: boolean;
53
+ /** 评论投票反对按钮 */
54
+ voteDown: boolean;
55
+ /** 评论预览功能 */
56
+ preview: boolean;
57
+ /** 评论数绑定元素 Selector */
58
+ countEl: string;
59
+ /** PV 数绑定元素 Selector */
60
+ pvEl: string;
61
+ /** 夜间模式 */
62
+ darkMode: boolean | 'auto';
63
+ /** 请求超时(单位:秒) */
64
+ reqTimeout: number;
65
+ /** 平铺模式 */
66
+ flatMode: boolean | 'auto';
67
+ /** 嵌套模式 · 最大层数 */
68
+ nestMax: number;
69
+ /** 嵌套模式 · 排序方式 */
70
+ nestSort: 'DATE_ASC' | 'DATE_DESC';
71
+ /** 显示 UA 徽标 */
72
+ uaBadge: boolean;
73
+ /** 评论列表排序功能 (显示 Dropdown) */
74
+ listSort: boolean;
75
+ /** 图片上传功能 */
76
+ imgUpload: boolean;
77
+ /** 图片上传器 */
78
+ imgUploader?: (file: File) => Promise<string>;
79
+ /** 版本检测 */
80
+ versionCheck: boolean;
81
+ /** 引用后端配置 */
82
+ useBackendConf: boolean;
83
+ /** 语言本地化 */
84
+ locale: I18n | string;
85
+ /** 后端版本 (系统数据,用户不允许更改) */
86
+ apiVersion?: string;
87
+ /** Replacer for marked */
88
+ markedReplacers?: ((raw: string) => string)[];
89
+ /** 列表请求参数修改器 */
90
+ listFetchParamsModifier?: (params: any) => void;
91
+ remoteConfModifier?: (conf: Partial<ArtalkConfig>) => void;
92
+ listUnreadHighlight?: boolean;
93
+ scrollRelativeTo?: () => HTMLElement;
94
+ }
95
+ /**
96
+ * 本地持久化用户数据
97
+ * @note 始终保持一层结构,不支持多层结构
98
+ */
99
+ export interface LocalUser {
100
+ /** 昵称 */
101
+ nick: string;
102
+ /** 邮箱 */
103
+ email: string;
104
+ /** 链接 */
105
+ link: string;
106
+ /** TOKEN */
107
+ token: string;
108
+ /** 是否为管理员 */
109
+ isAdmin: boolean;
110
+ }