artalk 2.7.2 → 2.8.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 (161) hide show
  1. package/LICENSE +21 -0
  2. package/dist/Artalk.cjs +11 -0
  3. package/dist/Artalk.cjs.map +1 -0
  4. package/dist/Artalk.css +1 -1
  5. package/dist/Artalk.iife.js +10 -1
  6. package/dist/Artalk.iife.js.map +1 -1
  7. package/dist/Artalk.js +10 -1
  8. package/dist/Artalk.js.map +1 -1
  9. package/dist/{Artalk.es.js → Artalk.mjs} +2552 -1857
  10. package/dist/Artalk.mjs.map +1 -0
  11. package/dist/ArtalkLite.cjs +11 -0
  12. package/dist/ArtalkLite.cjs.map +1 -0
  13. package/dist/ArtalkLite.css +1 -1
  14. package/dist/ArtalkLite.iife.js +10 -1
  15. package/dist/ArtalkLite.iife.js.map +1 -1
  16. package/dist/ArtalkLite.js +10 -1
  17. package/dist/ArtalkLite.js.map +1 -1
  18. package/dist/{ArtalkLite.es.js → ArtalkLite.mjs} +2150 -1261
  19. package/dist/ArtalkLite.mjs.map +1 -0
  20. package/dist/i18n/jp.cjs +1 -0
  21. package/dist/i18n/jp.d.cts +3 -0
  22. package/dist/i18n/jp.d.ts +3 -0
  23. package/dist/i18n/jp.js +1 -1
  24. package/dist/i18n/jp.mjs +94 -0
  25. package/dist/i18n/zh-TW.cjs +1 -0
  26. package/dist/i18n/zh-TW.d.cts +3 -0
  27. package/dist/i18n/zh-TW.d.ts +3 -0
  28. package/dist/i18n/zh-TW.js +1 -1
  29. package/dist/i18n/zh-TW.mjs +94 -0
  30. package/dist/main.d.cts +2812 -0
  31. package/dist/main.d.ts +2812 -0
  32. package/package.json +62 -30
  33. package/dist/Artalk.es.js.map +0 -1
  34. package/dist/ArtalkLite.es.js.map +0 -1
  35. package/dist/src/api/_base.d.ts +0 -17
  36. package/dist/src/api/_options.d.ts +0 -24
  37. package/dist/src/api/_request.d.ts +0 -12
  38. package/dist/src/api/admin.d.ts +0 -10
  39. package/dist/src/api/captcha.d.ts +0 -14
  40. package/dist/src/api/comment.d.ts +0 -29
  41. package/dist/src/api/index.d.ts +0 -29
  42. package/dist/src/api/page.d.ts +0 -22
  43. package/dist/src/api/site.d.ts +0 -17
  44. package/dist/src/api/system.d.ts +0 -33
  45. package/dist/src/api/upload.d.ts +0 -11
  46. package/dist/src/api/user.d.ts +0 -42
  47. package/dist/src/artalk.d.ts +0 -35
  48. package/dist/src/comment/actions.d.ts +0 -17
  49. package/dist/src/comment/comment.d.ts +0 -66
  50. package/dist/src/comment/height-limit.d.ts +0 -30
  51. package/dist/src/comment/index.d.ts +0 -2
  52. package/dist/src/comment/render.d.ts +0 -46
  53. package/dist/src/comment/renders/actions.d.ts +0 -5
  54. package/dist/src/comment/renders/avatar.d.ts +0 -5
  55. package/dist/src/comment/renders/content.d.ts +0 -5
  56. package/dist/src/comment/renders/header.d.ts +0 -5
  57. package/dist/src/comment/renders/index.d.ts +0 -2
  58. package/dist/src/comment/renders/pending.d.ts +0 -5
  59. package/dist/src/comment/renders/reply-at.d.ts +0 -5
  60. package/dist/src/comment/renders/reply-to.d.ts +0 -5
  61. package/dist/src/components/action-btn.d.ts +0 -50
  62. package/dist/src/components/checker/admin.d.ts +0 -3
  63. package/dist/src/components/checker/captcha-renders.d.ts +0 -5
  64. package/dist/src/components/checker/captcha.d.ts +0 -3
  65. package/dist/src/components/checker/index.d.ts +0 -53
  66. package/dist/src/components/dialog.d.ts +0 -16
  67. package/dist/src/components/error-dialog.d.ts +0 -8
  68. package/dist/src/components/pagination.d.ts +0 -31
  69. package/dist/src/components/read-more-btn.d.ts +0 -33
  70. package/dist/src/config.d.ts +0 -24
  71. package/dist/src/context.d.ts +0 -45
  72. package/dist/src/data.d.ts +0 -27
  73. package/dist/src/defaults.d.ts +0 -3
  74. package/dist/src/editor/editor.d.ts +0 -31
  75. package/dist/src/editor/state.d.ts +0 -20
  76. package/dist/src/editor/ui.d.ts +0 -25
  77. package/dist/src/i18n/en.d.ts +0 -73
  78. package/dist/src/i18n/external.d.ts +0 -74
  79. package/dist/src/i18n/index.d.ts +0 -236
  80. package/dist/src/i18n/jp.d.ts +0 -73
  81. package/dist/src/i18n/zh-CN.d.ts +0 -3
  82. package/dist/src/i18n/zh-TW.d.ts +0 -73
  83. package/dist/src/layer/index.d.ts +0 -4
  84. package/dist/src/layer/layer-manager.d.ts +0 -9
  85. package/dist/src/layer/layer.d.ts +0 -12
  86. package/dist/src/layer/scrollbar-helper.d.ts +0 -5
  87. package/dist/src/layer/sidebar-layer.d.ts +0 -20
  88. package/dist/src/layer/wrap.d.ts +0 -13
  89. package/dist/src/lib/component.d.ts +0 -7
  90. package/dist/src/lib/detect.d.ts +0 -10
  91. package/dist/src/lib/event-manager.d.ts +0 -28
  92. package/dist/src/lib/highlight.d.ts +0 -1
  93. package/dist/src/lib/marked-renderer.d.ts +0 -4
  94. package/dist/src/lib/marked.d.ts +0 -11
  95. package/dist/src/lib/sanitizer.d.ts +0 -1
  96. package/dist/src/lib/ui.d.ts +0 -24
  97. package/dist/src/lib/user.d.ts +0 -21
  98. package/dist/src/lib/utils.d.ts +0 -41
  99. package/dist/src/list/comment.d.ts +0 -3
  100. package/dist/src/list/layout.d.ts +0 -23
  101. package/dist/src/list/list.d.ts +0 -14
  102. package/dist/src/list/nest.d.ts +0 -10
  103. package/dist/src/list/page.d.ts +0 -2
  104. package/dist/src/list/paginator/index.d.ts +0 -25
  105. package/dist/src/list/paginator/read-more.d.ts +0 -18
  106. package/dist/src/list/paginator/up-down.d.ts +0 -14
  107. package/dist/src/main.d.ts +0 -7
  108. package/dist/src/plugins/admin-only-elem.d.ts +0 -2
  109. package/dist/src/plugins/conf-remoter.d.ts +0 -2
  110. package/dist/src/plugins/dark-mode.d.ts +0 -2
  111. package/dist/src/plugins/editor/_kit.d.ts +0 -33
  112. package/dist/src/plugins/editor/_plug.d.ts +0 -29
  113. package/dist/src/plugins/editor/_sample.d.ts +0 -5
  114. package/dist/src/plugins/editor/closable.d.ts +0 -7
  115. package/dist/src/plugins/editor/emoticons.d.ts +0 -30
  116. package/dist/src/plugins/editor/header-event.d.ts +0 -6
  117. package/dist/src/plugins/editor/header-link.d.ts +0 -6
  118. package/dist/src/plugins/editor/header-user.d.ts +0 -16
  119. package/dist/src/plugins/editor/index.d.ts +0 -6
  120. package/dist/src/plugins/editor/local-storage.d.ts +0 -6
  121. package/dist/src/plugins/editor/mover.d.ts +0 -6
  122. package/dist/src/plugins/editor/preview.d.ts +0 -7
  123. package/dist/src/plugins/editor/state-edit.d.ts +0 -11
  124. package/dist/src/plugins/editor/state-reply.d.ts +0 -8
  125. package/dist/src/plugins/editor/submit-add.d.ts +0 -18
  126. package/dist/src/plugins/editor/submit-btn.d.ts +0 -5
  127. package/dist/src/plugins/editor/submit.d.ts +0 -17
  128. package/dist/src/plugins/editor/textarea.d.ts +0 -8
  129. package/dist/src/plugins/editor/upload.d.ts +0 -9
  130. package/dist/src/plugins/editor-kit.d.ts +0 -42
  131. package/dist/src/plugins/index.d.ts +0 -2
  132. package/dist/src/plugins/list/copyright.d.ts +0 -2
  133. package/dist/src/plugins/list/count.d.ts +0 -2
  134. package/dist/src/plugins/list/dropdown.d.ts +0 -2
  135. package/dist/src/plugins/list/error-dialog.d.ts +0 -2
  136. package/dist/src/plugins/list/fetch.d.ts +0 -2
  137. package/dist/src/plugins/list/goto-first.d.ts +0 -3
  138. package/dist/src/plugins/list/goto.d.ts +0 -2
  139. package/dist/src/plugins/list/index.d.ts +0 -3
  140. package/dist/src/plugins/list/loading.d.ts +0 -2
  141. package/dist/src/plugins/list/no-comment.d.ts +0 -2
  142. package/dist/src/plugins/list/reach-bottom.d.ts +0 -2
  143. package/dist/src/plugins/list/sidebar-btn.d.ts +0 -2
  144. package/dist/src/plugins/list/time-ticking.d.ts +0 -3
  145. package/dist/src/plugins/list/unread-badge.d.ts +0 -2
  146. package/dist/src/plugins/list/unread.d.ts +0 -2
  147. package/dist/src/plugins/list/with-editor.d.ts +0 -2
  148. package/dist/src/plugins/markdown.d.ts +0 -2
  149. package/dist/src/plugins/stat.d.ts +0 -13
  150. package/dist/src/plugins/version-check.d.ts +0 -2
  151. package/dist/src/service.d.ts +0 -36
  152. package/dist/tests/e2e/comment-add.spec.d.ts +0 -1
  153. package/dist/types/config.d.ts +0 -110
  154. package/dist/types/context.d.ts +0 -62
  155. package/dist/types/data.d.ts +0 -194
  156. package/dist/types/editor.d.ts +0 -76
  157. package/dist/types/event.d.ts +0 -39
  158. package/dist/types/global.d.ts +0 -1
  159. package/dist/types/index.d.ts +0 -7
  160. package/dist/types/plugin.d.ts +0 -2
  161. package/dist/types/sidebar.d.ts +0 -3
@@ -1,16 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
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)[];
@@ -1,6 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- import EditorPlug from './_plug';
2
- export default class Mover extends EditorPlug {
3
- private isMoved;
4
- move(afterEl: HTMLElement): void;
5
- back(): void;
6
- }
@@ -1,7 +0,0 @@
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
- }
@@ -1,11 +0,0 @@
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
- }
@@ -1,8 +0,0 @@
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
- }
@@ -1,18 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
1
- import EditorPlug from './_plug';
2
- import type PlugKit from './_kit';
3
- export default class SubmitBtn extends EditorPlug {
4
- constructor(kit: PlugKit);
5
- }
@@ -1,17 +0,0 @@
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 {};
@@ -1,8 +0,0 @@
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
- }
@@ -1,9 +0,0 @@
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
- }
@@ -1,42 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- import type { ArtalkPlugin } from '../../types';
2
- export declare const DefaultPlugins: ArtalkPlugin[];
@@ -1,2 +0,0 @@
1
- import type { ArtalkPlugin } from '../../../types';
2
- export declare const Copyright: ArtalkPlugin;
@@ -1,2 +0,0 @@
1
- import type { ArtalkPlugin } from '../../../types';
2
- export declare const Count: ArtalkPlugin;
@@ -1,2 +0,0 @@
1
- import type { ArtalkPlugin } from '../../../types';
2
- export declare const Dropdown: ArtalkPlugin;
@@ -1,2 +0,0 @@
1
- import type { ArtalkPlugin } from '../../../types';
2
- export declare const ErrorDialog: ArtalkPlugin;
@@ -1,2 +0,0 @@
1
- import type { ArtalkPlugin } from '../../../types';
2
- export declare const Fetch: ArtalkPlugin;
@@ -1,3 +0,0 @@
1
- import type { ArtalkPlugin } from '../../../types';
2
- /** List scroll to the first comment */
3
- export declare const GotoFirst: ArtalkPlugin;
@@ -1,2 +0,0 @@
1
- import type { ArtalkPlugin } from '../../../types';
2
- export declare const Goto: ArtalkPlugin;
@@ -1,3 +0,0 @@
1
- import type { ArtalkPlugin } from '../../../types';
2
- declare const ListPlugins: ArtalkPlugin[];
3
- export { ListPlugins };
@@ -1,2 +0,0 @@
1
- import type { ArtalkPlugin } from '../../../types';
2
- export declare const Loading: ArtalkPlugin;
@@ -1,2 +0,0 @@
1
- import type { ArtalkPlugin } from '../../../types';
2
- export declare const NoComment: ArtalkPlugin;
@@ -1,2 +0,0 @@
1
- import type { ArtalkPlugin } from '../../../types';
2
- export declare const ReachBottom: ArtalkPlugin;
@@ -1,2 +0,0 @@
1
- import type { ArtalkPlugin } from '../../../types';
2
- export declare const SidebarBtn: ArtalkPlugin;
@@ -1,3 +0,0 @@
1
- import type { ArtalkPlugin } from '../../../types';
2
- /** 评论时间自动更新 */
3
- export declare const TimeTicking: ArtalkPlugin;
@@ -1,2 +0,0 @@
1
- import type { ArtalkPlugin } from '../../../types';
2
- export declare const UnreadBadge: ArtalkPlugin;
@@ -1,2 +0,0 @@
1
- import type { ArtalkPlugin } from '../../../types';
2
- export declare const Unread: ArtalkPlugin;
@@ -1,2 +0,0 @@
1
- import type { ArtalkPlugin } from '../../../types';
2
- export declare const WithEditor: ArtalkPlugin;
@@ -1,2 +0,0 @@
1
- import type { ArtalkPlugin } from '../../types';
2
- export declare const Markdown: ArtalkPlugin;
@@ -1,13 +0,0 @@
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>;
@@ -1,2 +0,0 @@
1
- import type { ArtalkPlugin } from '../../types';
2
- export declare const VersionCheck: ArtalkPlugin;
@@ -1,36 +0,0 @@
1
- import type { ContextApi } from '../types';
2
- import CheckerLauncher from './components/checker';
3
- import Editor from './editor/editor';
4
- import SidebarLayer from './layer/sidebar-layer';
5
- import List from './list/list';
6
- import { PlugManager } from './plugins/editor-kit';
7
- import { LayerManager } from './layer/layer-manager';
8
- import User from './lib/user';
9
- /**
10
- * Services
11
- *
12
- * @description Call these services by `ctx.get('serviceName')` or `ctx.serviceName`
13
- */
14
- declare const services: {
15
- i18n(ctx: ContextApi): void;
16
- user(ctx: ContextApi): User;
17
- layerManager(ctx: ContextApi): LayerManager;
18
- checkerLauncher(ctx: ContextApi): CheckerLauncher;
19
- editor(ctx: ContextApi): Editor;
20
- list(ctx: ContextApi): List;
21
- sidebarLayer(ctx: ContextApi): SidebarLayer;
22
- editorPlugs(): PlugManager | undefined;
23
- };
24
- export default services;
25
- type TServiceImps = typeof services;
26
- type TObjectWithFuncs = {
27
- [k: string]: (...args: any) => any;
28
- };
29
- type TKeysOnlyReturn<T extends TObjectWithFuncs, V> = {
30
- [K in keyof T]: ReturnType<T[K]> extends V ? K : never;
31
- }[keyof T];
32
- type TOmitConditions = TKeysOnlyReturn<TServiceImps, void>;
33
- type TServiceInjectors = Omit<TServiceImps, TOmitConditions>;
34
- export type TInjectedServices = {
35
- [K in keyof TServiceInjectors]: ReturnType<TServiceInjectors[K]>;
36
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,110 +0,0 @@
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
- }
@@ -1,62 +0,0 @@
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 '.';
8
- /**
9
- * Context 接口
10
- *
11
- * (面向接口的编程)
12
- */
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;
62
- }