artalk 2.4.4 → 2.5.1

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 (156) hide show
  1. package/README.md +27 -0
  2. package/dist/Artalk.css +1 -1
  3. package/dist/Artalk.es.js +7066 -6256
  4. package/dist/Artalk.iife.js +1 -1
  5. package/dist/Artalk.js +1 -1
  6. package/dist/ArtalkLite.css +1 -1
  7. package/dist/ArtalkLite.es.js +5095 -4396
  8. package/dist/ArtalkLite.iife.js +1 -1
  9. package/dist/ArtalkLite.js +1 -1
  10. package/dist/i18n/jp.js +1 -1
  11. package/dist/i18n/zh-TW.js +1 -1
  12. package/dist/src/api/index.d.ts +2 -2
  13. package/dist/src/api/system.d.ts +5 -2
  14. package/dist/src/artalk.d.ts +42 -34
  15. package/dist/src/comment/comment.d.ts +2 -2
  16. package/dist/src/comment/height-limit.d.ts +30 -0
  17. package/dist/src/comment/render-ctx.d.ts +23 -0
  18. package/dist/src/comment/render.d.ts +2 -50
  19. package/dist/src/comment/renders/actions.d.ts +5 -0
  20. package/dist/src/comment/renders/avatar.d.ts +5 -0
  21. package/dist/src/comment/renders/content.d.ts +5 -0
  22. package/dist/src/comment/renders/header.d.ts +5 -0
  23. package/dist/src/comment/renders/index.d.ts +2 -0
  24. package/dist/src/comment/renders/pending.d.ts +5 -0
  25. package/dist/src/comment/renders/reply-at.d.ts +5 -0
  26. package/dist/src/comment/renders/reply-to.d.ts +5 -0
  27. package/dist/src/components/dialog.d.ts +1 -1
  28. package/dist/src/config.d.ts +8 -0
  29. package/dist/src/context.d.ts +16 -29
  30. package/dist/src/editor/edit-mode.d.ts +9 -0
  31. package/dist/src/editor/editor.d.ts +37 -45
  32. package/dist/src/editor/funcs.d.ts +2 -0
  33. package/dist/src/editor/mover.d.ts +8 -0
  34. package/dist/src/editor/plug-manager.d.ts +17 -0
  35. package/dist/src/editor/plugs/editor-plug.d.ts +13 -1
  36. package/dist/src/editor/reply.d.ts +9 -0
  37. package/dist/src/editor/submit.d.ts +16 -0
  38. package/dist/src/editor/ui.d.ts +25 -0
  39. package/dist/src/i18n/external.d.ts +70 -0
  40. package/dist/src/i18n/index.d.ts +11 -75
  41. package/dist/src/layer/index.d.ts +2 -2
  42. package/dist/src/layer/layer.d.ts +1 -1
  43. package/dist/src/lib/checker/captcha-renders.d.ts +5 -0
  44. package/dist/src/lib/checker/index.d.ts +16 -10
  45. package/dist/src/lib/dark-mode.d.ts +4 -0
  46. package/dist/src/lib/marked.d.ts +9 -0
  47. package/dist/src/lib/user.d.ts +6 -3
  48. package/dist/src/lib/utils.d.ts +1 -5
  49. package/dist/src/list/list-lite.d.ts +15 -11
  50. package/dist/src/list/list-nest.d.ts +2 -2
  51. package/dist/src/list/list-ui.d.ts +16 -0
  52. package/dist/src/list/list.d.ts +0 -1
  53. package/dist/src/list/paginator/adaptors/index.d.ts +12 -0
  54. package/dist/src/list/paginator/adaptors/pagination.d.ts +9 -0
  55. package/dist/src/list/paginator/adaptors/read-more.d.ts +10 -0
  56. package/dist/src/list/paginator/holder.d.ts +16 -0
  57. package/dist/src/list/paginator/index.d.ts +10 -0
  58. package/dist/src/service.d.ts +46 -0
  59. package/dist/types/artalk-config.d.ts +5 -2
  60. package/dist/types/artalk-data.d.ts +3 -3
  61. package/dist/types/context.d.ts +13 -20
  62. package/dist/types/global.d.ts +1 -0
  63. package/package.json +6 -7
  64. package/src/api/comment.ts +7 -7
  65. package/src/api/page.ts +0 -2
  66. package/src/api/request.ts +6 -4
  67. package/src/api/system.ts +3 -12
  68. package/src/api/upload.ts +3 -4
  69. package/src/api/user.ts +6 -8
  70. package/src/artalk.ts +103 -158
  71. package/src/comment/comment.ts +7 -6
  72. package/src/comment/height-limit.ts +100 -0
  73. package/src/comment/render-ctx.ts +30 -0
  74. package/src/comment/render.ts +31 -375
  75. package/src/comment/renders/actions.ts +114 -0
  76. package/src/comment/renders/avatar.ts +22 -0
  77. package/src/comment/renders/content.ts +39 -0
  78. package/src/comment/renders/header.ts +84 -0
  79. package/src/comment/renders/index.ts +19 -0
  80. package/src/comment/renders/pending.ts +12 -0
  81. package/src/comment/renders/reply-at.ts +16 -0
  82. package/src/comment/renders/reply-to.ts +24 -0
  83. package/src/config.ts +65 -0
  84. package/src/context.ts +33 -86
  85. package/src/defaults.ts +1 -0
  86. package/src/editor/edit-mode.ts +103 -0
  87. package/src/editor/editor.ts +101 -395
  88. package/src/editor/funcs.ts +97 -0
  89. package/src/editor/mover.ts +43 -0
  90. package/src/editor/plug-manager.ts +172 -0
  91. package/src/editor/plugs/editor-plug.ts +20 -2
  92. package/src/editor/plugs/{emoticons-plug.less → emoticons-plug.scss} +5 -4
  93. package/src/editor/plugs/emoticons-plug.ts +2 -1
  94. package/src/editor/plugs/header-input-plug.ts +11 -10
  95. package/src/editor/plugs/{preview-plug.less → preview-plug.scss} +1 -1
  96. package/src/editor/plugs/preview-plug.ts +8 -4
  97. package/src/editor/plugs/upload-plug.ts +12 -14
  98. package/src/editor/reply.ts +62 -0
  99. package/src/editor/submit.ts +99 -0
  100. package/src/editor/ui.ts +36 -0
  101. package/src/i18n/external.ts +10 -0
  102. package/src/i18n/index.ts +22 -19
  103. package/src/i18n/jp.ts +1 -1
  104. package/src/i18n/zh-TW.ts +1 -1
  105. package/src/layer/index.ts +2 -2
  106. package/src/layer/layer.ts +4 -4
  107. package/src/layer/sidebar-layer.ts +4 -2
  108. package/src/lib/checker/admin.ts +37 -0
  109. package/src/lib/checker/captcha-renders.ts +68 -0
  110. package/src/lib/checker/captcha.ts +26 -0
  111. package/src/lib/checker/index.ts +36 -20
  112. package/src/lib/dark-mode.ts +48 -0
  113. package/src/lib/marked.ts +133 -0
  114. package/src/lib/user.ts +13 -7
  115. package/src/lib/utils.ts +1 -123
  116. package/src/list/list-lite.ts +59 -162
  117. package/src/list/list-ui.ts +137 -0
  118. package/src/list/list.ts +33 -60
  119. package/src/list/paginator/adaptors/index.ts +21 -0
  120. package/src/list/paginator/adaptors/pagination.ts +42 -0
  121. package/src/list/paginator/adaptors/read-more.ts +56 -0
  122. package/src/list/paginator/holder.ts +56 -0
  123. package/src/list/paginator/index.ts +13 -0
  124. package/src/service.ts +118 -0
  125. package/src/style/{_color.less → _color.scss} +3 -3
  126. package/src/style/{_extend.less → _extend.scss} +1 -1
  127. package/src/style/_variables.scss +3 -0
  128. package/src/style/{comment.less → comment.scss} +36 -12
  129. package/src/style/{editor.less → editor.scss} +11 -11
  130. package/src/style/{list.less → list.scss} +12 -10
  131. package/src/style/{main.less → main.scss} +24 -23
  132. package/src/style/{sidebar-layer.less → sidebar-layer.scss} +8 -8
  133. package/types/artalk-config.d.ts +5 -2
  134. package/types/artalk-data.d.ts +3 -3
  135. package/types/context.d.ts +13 -20
  136. package/types/global.d.ts +1 -0
  137. package/CNAME +0 -1
  138. package/LICENSE +0 -165
  139. package/index.html +0 -157
  140. package/postcss.config.js +0 -5
  141. package/scripts/build-i18n.mjs +0 -46
  142. package/src/lib/checker/admin-checker.ts +0 -36
  143. package/src/lib/checker/captcha-checker.ts +0 -84
  144. package/src/style/_variables.less +0 -3
  145. package/test/ArtalkCount.html +0 -16
  146. package/test/ArtalkI18n.html +0 -16
  147. package/test/ArtalkLite.html +0 -15
  148. package/test/CSRF.html +0 -26
  149. package/tsconfig.json +0 -12
  150. package/vite-base.config.ts +0 -21
  151. package/vite-demo.config.ts +0 -12
  152. package/vite-lite.config.ts +0 -22
  153. package/vite.config.ts +0 -27
  154. /package/dist/src/lib/checker/{admin-checker.d.ts → admin.d.ts} +0 -0
  155. /package/dist/src/lib/checker/{captcha-checker.d.ts → captcha.d.ts} +0 -0
  156. /package/src/style/{pagination.less → pagination.scss} +0 -0
package/dist/i18n/jp.js CHANGED
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).jp=n()}(this,(function(){"use strict";var e,n,o;return e="jp",n={placeholder:"コメントを残す",noComment:"コメントなし",send:"送信",save:"保存",nick:"ニックネーム",email:"メール",link:"ウェブサイト",emoticon:"絵文字",preview:"プレビュー",image:"画像",uploadFail:"アップロードに失敗しました",commentFail:"コメントに失敗しました",restoredMsg:"コンテンツが復元されました",onlyAdminCanReply:"管理者のみが返信できます",uploadLoginMsg:"アップロードするには、名前とメールアドレスを入力してください",counter:"{count} コメント",sortLatest:"最新のもの",sortOldest:"最も古い",sortBest:"ベスト",sortAuthor:"著者",openComment:"コメントを開く",closeComment:"コメントを閉じる",listLoadFailMsg:"コメントの読み込みに失敗しました",listRetry:"クリックで再試行",loadMore:"もっと読み込む",admin:"管理者",reply:"返信",voteUp:"アップ",voteDown:"ダウン",voteFail:"投票に失敗しました",readMore:"続きを読む",actionConfirm:"確認",collapse:"折りたたむ",collapsed:"折りたたまれた",collapsedMsg:"このコメントは折りたたまれました",expand:"展開",approved:"承認されました",pending:"保留中",pendingMsg:"保留中、コメント投稿者にのみ表示されます",edit:"編集",editCancel:"編集をキャンセル",delete:"削除",deleteConfirm:"確認",pin:"ピン",unpin:"ピン外し",seconds:"秒前",minutes:"分前",hours:"時間前",days:"数日前",now:"たった今",adminCheck:"管理者パスワードを入力してください:",captchaCheck:"続けるにはCAPTCHAを入力してください:",confirm:"確認",cancel:"取消",msgCenter:"メッセージ",ctrlCenter:"コンソール",frontend:"フロントエンド",backend:"バックエンド",loading:"読み込み中",loadFail:"読み込みに失敗しました",editing:"編集中",editFail:"編集に失敗しました",deleting:"削除中",deleteFail:"削除に失敗しました",reqGot:"リクエストを取得しました",reqAborted:"リクエストがタイムアウトしたか、予期せず終了した"},o=["jp-JP"],window.ArtalkI18n||(window.ArtalkI18n={}),window.ArtalkI18n[e]=n,o&&o.forEach((e=>{window.ArtalkI18n[e]=n})),n}));
1
+ !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e="undefined"!=typeof globalThis?globalThis:e||self).jp=o()}(this,(function(){"use strict";const e="ArtalkI18n";var o,n,t;return o="jp",n={placeholder:"コメントを残す",noComment:"コメントなし",send:"送信",save:"保存",nick:"ニックネーム",email:"メール",link:"ウェブサイト",emoticon:"絵文字",preview:"プレビュー",image:"画像",uploadFail:"アップロードに失敗しました",commentFail:"コメントに失敗しました",restoredMsg:"コンテンツが復元されました",onlyAdminCanReply:"管理者のみが返信できます",uploadLoginMsg:"アップロードするには、名前とメールアドレスを入力してください",counter:"{count} コメント",sortLatest:"最新のもの",sortOldest:"最も古い",sortBest:"ベスト",sortAuthor:"著者",openComment:"コメントを開く",closeComment:"コメントを閉じる",listLoadFailMsg:"コメントの読み込みに失敗しました",listRetry:"クリックで再試行",loadMore:"もっと読み込む",admin:"管理者",reply:"返信",voteUp:"アップ",voteDown:"ダウン",voteFail:"投票に失敗しました",readMore:"続きを読む",actionConfirm:"確認",collapse:"折りたたむ",collapsed:"折りたたまれた",collapsedMsg:"このコメントは折りたたまれました",expand:"展開",approved:"承認されました",pending:"保留中",pendingMsg:"保留中、コメント投稿者にのみ表示されます",edit:"編集",editCancel:"編集をキャンセル",delete:"削除",deleteConfirm:"確認",pin:"ピン",unpin:"ピン外し",seconds:"秒前",minutes:"分前",hours:"時間前",days:"数日前",now:"たった今",adminCheck:"管理者パスワードを入力してください:",captchaCheck:"続けるにはCAPTCHAを入力してください:",confirm:"確認",cancel:"取消",msgCenter:"メッセージ",ctrlCenter:"コンソール",frontend:"フロントエンド",backend:"バックエンド",loading:"読み込み中",loadFail:"読み込みに失敗しました",editing:"編集中",editFail:"編集に失敗しました",deleting:"削除中",deleteFail:"削除に失敗しました",reqGot:"リクエストを取得しました",reqAborted:"リクエストがタイムアウトしたか、予期せず終了した"},t=["jp-JP"],window[e]||(window[e]={}),window[e][o]=n,t&&t.forEach((o=>{window[e][o]=n})),n}));
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self)["zh-TW"]=n()}(this,(function(){"use strict";var e,n,o;return e="zh-TW",n={placeholder:"鍵入內容...",noComment:"「此時無聲勝有聲」",send:"發送評論",save:"保存評論",nick:"昵稱",email:"郵箱",link:"網址",emoticon:"表情",preview:"預覽",image:"圖片",uploadFail:"上傳失敗",commentFail:"評論失敗",restoredMsg:"內容已自動恢復",onlyAdminCanReply:"僅管理員可評論",uploadLoginMsg:"填入你的名字郵箱才能上傳哦",counter:"{count} 條評論",sortLatest:"最新",sortOldest:"最早",sortBest:"最熱",sortAuthor:"作者",openComment:"打開評論",closeComment:"關閉評論",listLoadFailMsg:"無法獲取評論列表數據",listRetry:"點擊重新獲取",loadMore:"加載更多",admin:"管理員",reply:"回覆",voteUp:"贊同",voteDown:"反對",voteFail:"投票失敗",readMore:"閱讀更多",actionConfirm:"確認操作",collapse:"摺疊",collapsed:"已摺疊",collapsedMsg:"該評論已被系統或管理員摺疊",expand:"展開",approved:"已審",pending:"待審",pendingMsg:"審核中,僅本人可見。",edit:"編輯",editCancel:"取消編輯",delete:"刪除",deleteConfirm:"確認刪除",pin:"置頂",unpin:"取消置頂",seconds:"秒前",minutes:"分鐘前",hours:"小時前",days:"天前",now:"剛剛",adminCheck:"鍵入密碼來驗證管理員身份:",captchaCheck:"鍵入驗證碼繼續:",confirm:"確認",cancel:"取消",msgCenter:"通知中心",ctrlCenter:"控制中心",frontend:"前端",backend:"後端",loading:"加載中",loadFail:"加載失敗",editing:"修改中",editFail:"修改失敗",deleting:"刪除中",deleteFail:"刪除失敗",reqGot:"請求響應",reqAborted:"請求超時或意外終止"},window.ArtalkI18n||(window.ArtalkI18n={}),window.ArtalkI18n[e]=n,o&&o.forEach((e=>{window.ArtalkI18n[e]=n})),n}));
1
+ !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e="undefined"!=typeof globalThis?globalThis:e||self)["zh-TW"]=o()}(this,(function(){"use strict";const e="ArtalkI18n";var o,n,t;return o="zh-TW",n={placeholder:"鍵入內容...",noComment:"「此時無聲勝有聲」",send:"發送評論",save:"保存評論",nick:"昵稱",email:"郵箱",link:"網址",emoticon:"表情",preview:"預覽",image:"圖片",uploadFail:"上傳失敗",commentFail:"評論失敗",restoredMsg:"內容已自動恢復",onlyAdminCanReply:"僅管理員可評論",uploadLoginMsg:"填入你的名字郵箱才能上傳哦",counter:"{count} 條評論",sortLatest:"最新",sortOldest:"最早",sortBest:"最熱",sortAuthor:"作者",openComment:"打開評論",closeComment:"關閉評論",listLoadFailMsg:"無法獲取評論列表數據",listRetry:"點擊重新獲取",loadMore:"加載更多",admin:"管理員",reply:"回覆",voteUp:"贊同",voteDown:"反對",voteFail:"投票失敗",readMore:"閱讀更多",actionConfirm:"確認操作",collapse:"摺疊",collapsed:"已摺疊",collapsedMsg:"該評論已被系統或管理員摺疊",expand:"展開",approved:"已審",pending:"待審",pendingMsg:"審核中,僅本人可見。",edit:"編輯",editCancel:"取消編輯",delete:"刪除",deleteConfirm:"確認刪除",pin:"置頂",unpin:"取消置頂",seconds:"秒前",minutes:"分鐘前",hours:"小時前",days:"天前",now:"剛剛",adminCheck:"鍵入密碼來驗證管理員身份:",captchaCheck:"鍵入驗證碼繼續:",confirm:"確認",cancel:"取消",msgCenter:"通知中心",ctrlCenter:"控制中心",frontend:"前端",backend:"後端",loading:"加載中",loadFail:"加載失敗",editing:"修改中",editFail:"修改失敗",deleting:"刪除中",deleteFail:"刪除失敗",reqGot:"請求響應",reqAborted:"請求超時或意外終止"},window[e]||(window[e]={}),window[e][o]=n,t&&t.forEach((o=>{window[e][o]=n})),n}));
@@ -22,8 +22,8 @@ declare class Api {
22
22
  get baseURL(): string;
23
23
  constructor(ctx: Context);
24
24
  }
25
- declare type TC = typeof ApiComponents;
26
- declare type AC = {
25
+ type TC = typeof ApiComponents;
26
+ type AC = {
27
27
  [K in keyof TC]: InstanceType<TC[K]>;
28
28
  };
29
29
  interface Api extends AC {
@@ -5,9 +5,12 @@ import ApiBase from './api-base';
5
5
  */
6
6
  export default class SystemApi extends ApiBase {
7
7
  /** 获取配置 */
8
- conf(): Promise<ArtalkConfig>;
8
+ conf(): Promise<Partial<ArtalkConfig>>;
9
9
  /** 获取配置数据 */
10
- getSettings(): Promise<string>;
10
+ getSettings(): Promise<{
11
+ custom: string;
12
+ template: string;
13
+ }>;
11
14
  /** 保存配置数据 */
12
15
  saveSettings(yamlStr: string): Promise<boolean>;
13
16
  /** 获取 API 版本信息 */
@@ -1,52 +1,60 @@
1
- import ArtalkConfig from '../types/artalk-config';
2
- import { EventPayloadMap, Handler } from '../types/event';
3
- import ArtalkPlug from '../types/plug';
4
- import Context from '../types/context';
1
+ import type ArtalkConfig from '../types/artalk-config';
2
+ import type { EventPayloadMap, Handler } from '../types/event';
3
+ import type ArtalkPlug from '../types/plug';
4
+ import type Context from '../types/context';
5
5
  import ListLite from './list/list-lite';
6
6
  /**
7
7
  * Artalk
8
8
  *
9
- * @website https://artalk.js.org
9
+ * @see https://artalk.js.org
10
10
  */
11
11
  export default class Artalk {
12
+ private static instance?;
12
13
  static ListLite: typeof ListLite;
13
14
  static readonly defaults: ArtalkConfig;
14
15
  conf: ArtalkConfig;
15
16
  ctx: Context;
16
17
  $root: HTMLElement;
17
- /** Plugins (in global scope) */
18
- protected static Plugins: ArtalkPlug[];
19
- /** Plugins (in a instance scope) */
20
- protected instancePlugins: ArtalkPlug[];
21
- /** 禁用的组件 */
18
+ /** Plugins */
19
+ protected static plugins: ArtalkPlug[];
22
20
  static DisabledComponents: string[];
23
- constructor(customConf: Partial<ArtalkConfig>);
24
- /** 组件初始化 */
25
- private initComponents;
26
- /** 基本配置初始化 */
27
- static HandelBaseConf(customConf: Partial<ArtalkConfig>): ArtalkConfig;
28
- /** 事件绑定初始化 */
29
- private initEventBind;
30
- /** 语言初始化 */
31
- private initLocale;
32
- /** Layer 初始化 */
33
- private initLayer;
34
- /** 监听事件 */
21
+ constructor(conf: Partial<ArtalkConfig>);
22
+ /** Init Artalk */
23
+ static init(conf: Partial<ArtalkConfig>): Artalk;
24
+ /** Use Plugin (plugin will be called in instance `use` func) */
25
+ use(plugin: ArtalkPlug): void;
26
+ /** Update config of Artalk */
27
+ update(conf: Partial<ArtalkConfig>): Artalk;
28
+ /** Reload comment list of Artalk */
29
+ reload(): void;
30
+ /** Destroy instance of Artalk */
31
+ destroy(): void;
32
+ /** Add an event listener */
35
33
  on<K extends keyof EventPayloadMap>(name: K, handler: Handler<EventPayloadMap[K]>): void;
36
- /** 解除监听事件 */
34
+ /** Remove an event listener */
37
35
  off<K extends keyof EventPayloadMap>(name: K, handler: Handler<EventPayloadMap[K]>): void;
38
- /** 触发事件 */
36
+ /** Trigger an event */
39
37
  trigger<K extends keyof EventPayloadMap>(name: K, payload?: EventPayloadMap[K]): void;
40
- /** 重新加载 */
41
- reload(): void;
42
- /** 设置暗黑模式 */
38
+ /** Set dark mode */
43
39
  setDarkMode(darkMode: boolean): void;
44
- /** Use Plugin (specific instance) */
45
- use(plugin: ArtalkPlug): void;
46
- /** Use Plugin (static method for global scope) */
40
+ /** Use Plugin (static method) */
47
41
  static use(plugin: ArtalkPlug): void;
48
- /** @deprecated Please replace it with lowercase function name `use(...)`. */
49
- static Use(plugin: ArtalkPlug): void;
50
- /** 装载数量统计元素 */
51
- static LoadCountWidget(customConf: Partial<ArtalkConfig>): void;
42
+ /** Update config of Artalk */
43
+ static update(conf: Partial<ArtalkConfig>): Artalk | undefined;
44
+ /** Reload comment list of Artalk */
45
+ static reload(): void;
46
+ /** Destroy instance of Artalk */
47
+ static destroy(): void;
48
+ /** Add an event listener */
49
+ static on<K extends keyof EventPayloadMap>(name: K, handler: Handler<EventPayloadMap[K]>): void;
50
+ /** Remove an event listener */
51
+ static off<K extends keyof EventPayloadMap>(name: K, handler: Handler<EventPayloadMap[K]>): void;
52
+ /** Trigger an event */
53
+ static trigger<K extends keyof EventPayloadMap>(name: K, payload?: EventPayloadMap[K]): void;
54
+ /** Set dark mode */
55
+ static setDarkMode(darkMode: boolean): void;
56
+ /** Load count widget */
57
+ static loadCountWidget(conf: Partial<ArtalkConfig>): void;
58
+ /** @deprecated Please use `loadCountWidget` instead */
59
+ static LoadCountWidget(conf: Partial<ArtalkConfig>): void;
52
60
  }
@@ -1,7 +1,7 @@
1
1
  import { CommentData } from '../../types/artalk-data';
2
2
  import Context from '../../types/context';
3
3
  import Component from '../lib/component';
4
- import CommentRender from './render';
4
+ import CommentUI from './render';
5
5
  import CommentActions from './actions';
6
6
  export interface CommentConf {
7
7
  isUnread?: boolean;
@@ -28,7 +28,7 @@ export default class Comment extends Component {
28
28
  /** 获取评论操作实例对象 */
29
29
  getActions(): CommentActions;
30
30
  /** 获取评论渲染器实例对象 */
31
- getRender(): CommentRender;
31
+ getRender(): CommentUI;
32
32
  /** 获取评论数据 */
33
33
  getData(): CommentData;
34
34
  /** 设置数据 */
@@ -0,0 +1,30 @@
1
+ export interface IHeightLimitConf {
2
+ /** Post expand btn click */
3
+ postExpandBtnClick?: (e: MouseEvent) => void;
4
+ /** Allow Scroll */
5
+ scrollable?: boolean;
6
+ }
7
+ export interface IHeightLimitRule {
8
+ /** Target element need to check */
9
+ el: HTMLElement | null | undefined;
10
+ /** Max height (unit: px) */
11
+ max: number;
12
+ /** Whether or not the element contains `<img />` */
13
+ imgContains?: boolean;
14
+ }
15
+ export type THeightLimitRuleSet = IHeightLimitRule[];
16
+ /** Check all elements below the max height limit */
17
+ export declare function check(conf: IHeightLimitConf, rules: THeightLimitRuleSet): void;
18
+ /** Apply height limit on an element and add expand btn */
19
+ export declare function applyHeightLimit(obj: {
20
+ el: HTMLElement;
21
+ maxHeight: number;
22
+ postBtnClick?: (e: MouseEvent) => void;
23
+ }): void;
24
+ /** Dispose height limit on an element and remove expand btn */
25
+ export declare function disposeHeightLimit($el: HTMLElement): void;
26
+ /** Apply scrollable height limit */
27
+ export declare function applyScrollableHeightLimit(obj: {
28
+ el: HTMLElement;
29
+ maxHeight: number;
30
+ }): void;
@@ -0,0 +1,23 @@
1
+ import Comment from './comment';
2
+ import ActionBtn from '../components/action-btn';
3
+ export default class RenderCtx {
4
+ comment: Comment;
5
+ get ctx(): import("../../types/context").default;
6
+ get data(): import("../../types/artalk-data").CommentData;
7
+ get conf(): import("../../types/artalk-config").default;
8
+ get cConf(): import("./comment").CommentConf;
9
+ $el: HTMLElement;
10
+ $main: HTMLElement;
11
+ $header: HTMLElement;
12
+ $headerNick: HTMLElement;
13
+ $headerBadgeWrap: HTMLElement;
14
+ $body: HTMLElement;
15
+ $content: HTMLElement;
16
+ $childrenWrap: HTMLElement | null;
17
+ $actions: HTMLElement;
18
+ voteBtnUp?: ActionBtn;
19
+ voteBtnDown?: ActionBtn;
20
+ $replyTo?: HTMLElement;
21
+ $replyAt?: HTMLElement;
22
+ constructor(comment: Comment);
23
+ }
@@ -1,60 +1,12 @@
1
- import ActionBtn from '../components/action-btn';
2
1
  import Comment from './comment';
3
- export default class CommentRender {
4
- private comment;
5
- private get ctx();
6
- private get data();
7
- private get cConf();
8
- $el: HTMLElement;
9
- $main: HTMLElement;
10
- $header: HTMLElement;
11
- $headerNick: HTMLElement;
12
- $headerBadgeWrap: HTMLElement;
13
- $body: HTMLElement;
14
- $content: HTMLElement;
15
- private $childrenWrap;
16
- $actions: HTMLElement;
17
- voteBtnUp?: ActionBtn;
18
- voteBtnDown?: ActionBtn;
19
- $replyTo?: HTMLElement;
20
- $replyAt?: HTMLElement;
2
+ import RenderCtx from './render-ctx';
3
+ export default class CommentRender extends RenderCtx {
21
4
  constructor(comment: Comment);
22
5
  render(): HTMLElement;
23
- /** 初始化 - 评论头像 */
24
- private renderAvatar;
25
- /** 初始化 - 评论信息 */
26
- private renderHeader;
27
- private renderHeader_Nick;
28
- private renderHeader_VerifyBadge;
29
- private renderHeader_Date;
30
- private renderHeader_UABadge;
31
- /** 初始化 - 评论内容 */
32
- private renderContent;
33
- /** 初始化 - 层级嵌套模式显示 At */
34
- private renderReplyAt;
35
- /** 初始化 - 回复的对象 */
36
- private renderReplyTo;
37
- /** 初始化 - 待审核状态 */
38
- private renderPending;
39
- /** 初始化 - 评论操作按钮 */
40
- private renderActions;
41
- private renderActions_Vote;
42
- private renderActions_Reply;
43
- private renderActions_Collapse;
44
- private renderActions_Moderator;
45
- private renderActions_Pin;
46
- private renderActions_Edit;
47
- private renderActions_Del;
48
6
  /** 内容限高检测 */
49
7
  checkHeightLimit(): void;
50
- /** 目标内容限高检测 */
51
- checkHeightLimitArea(area: 'children' | 'content'): void;
52
- /** 移除限高 */
53
- private heightLimitRemove;
54
8
  /** 子评论区域移除限高 */
55
9
  heightLimitRemoveForChildren(): void;
56
- /** 内容限高区域新增 */
57
- private heightLimitAdd;
58
10
  /** 渐出动画 */
59
11
  playFadeAnim(): void;
60
12
  /** 渐出动画 · 评论内容区域 */
@@ -0,0 +1,5 @@
1
+ import RenderCtx from '../render-ctx';
2
+ /**
3
+ * 评论操作按钮界面
4
+ */
5
+ export default function renderActions(ctx: RenderCtx): void;
@@ -0,0 +1,5 @@
1
+ import RenderCtx from '../render-ctx';
2
+ /**
3
+ * 评论头像界面
4
+ */
5
+ export default function renderAvatar(ctx: RenderCtx): void;
@@ -0,0 +1,5 @@
1
+ import RenderCtx from '../render-ctx';
2
+ /**
3
+ * 评论内容界面
4
+ */
5
+ export default function renderContent(ctx: RenderCtx): void;
@@ -0,0 +1,5 @@
1
+ import RenderCtx from '../render-ctx';
2
+ /**
3
+ * 评论头部界面
4
+ */
5
+ export default function renderHeader(ctx: RenderCtx): void;
@@ -0,0 +1,2 @@
1
+ import RenderCtx from '../render-ctx';
2
+ export default function loadRenders(ctx: RenderCtx): void;
@@ -0,0 +1,5 @@
1
+ import RenderCtx from '../render-ctx';
2
+ /**
3
+ * 待审核状态界面
4
+ */
5
+ export default function renderPending(ctx: RenderCtx): void;
@@ -0,0 +1,5 @@
1
+ import RenderCtx from '../render-ctx';
2
+ /**
3
+ * 层级嵌套模式显示 AT 界面
4
+ */
5
+ export default function renderReplyAt(ctx: RenderCtx): void;
@@ -0,0 +1,5 @@
1
+ import RenderCtx from '../render-ctx';
2
+ /**
3
+ * 回复的对象界面
4
+ */
5
+ export default function renderReplyTo(ctx: RenderCtx): void;
@@ -1,5 +1,5 @@
1
1
  import Context from '../../types/context';
2
- declare type BtnClickHandler = (btnEl: HTMLElement, dialog: Dialog) => boolean | void;
2
+ type BtnClickHandler = (btnEl: HTMLElement, dialog: Dialog) => boolean | void;
3
3
  /**
4
4
  * 对话框
5
5
  */
@@ -0,0 +1,8 @@
1
+ import type ArtalkConfig from '../types/artalk-config';
2
+ declare const _default: {
3
+ handelBaseConf: typeof handelBaseConf;
4
+ };
5
+ export default _default;
6
+ /** 基本配置初始化 */
7
+ export declare function handelBaseConf(customConf: Partial<ArtalkConfig>): ArtalkConfig;
8
+ export declare function handleBackendRefConf(conf: Partial<ArtalkConfig>): Partial<ArtalkConfig>;
@@ -1,38 +1,26 @@
1
- import { marked as libMarked } from 'marked';
2
- import ArtalkConfig from '../types/artalk-config';
3
- import { CommentData, NotifyData } from '../types/artalk-data';
4
- import { I18n } from './i18n';
5
- import User from './lib/user';
6
- import ContextApi from '../types/context';
7
- import Editor from './editor';
1
+ import type ArtalkConfig from '../types/artalk-config';
2
+ import type { CommentData, NotifyData } from '../types/artalk-data';
3
+ import type ContextApi from '../types/context';
4
+ import type { TInjectedServices } from './service';
5
+ import { CheckerCaptchaPayload, CheckerPayload } from './lib/checker';
6
+ import * as I18n from './i18n';
7
+ import { SidebarShowPayload } from './layer/sidebar-layer';
8
8
  import Comment from './comment';
9
- import ListLite from './list/list-lite';
10
- import SidebarLayer, { SidebarShowPayload } from './layer/sidebar-layer';
11
- import CheckerLauncher, { CheckerCaptchaPayload, CheckerPayload } from './lib/checker';
12
9
  import Api from './api';
10
+ interface Context extends TInjectedServices {
11
+ }
13
12
  /**
14
13
  * Artalk Context
15
14
  */
16
- export default class Context implements ContextApi {
17
- private api;
18
- private editor;
19
- private list?;
20
- private sidebarLayer;
21
- private checkerLauncher;
22
- cid: number;
15
+ declare class Context implements ContextApi {
23
16
  conf: ArtalkConfig;
24
- user: User;
25
17
  $root: HTMLElement;
26
- markedInstance?: typeof libMarked;
27
18
  markedReplacers: ((raw: string) => string)[];
28
19
  private commentList;
29
20
  private eventList;
30
21
  constructor(conf: ArtalkConfig, $root?: HTMLElement);
31
- setApi(api: Api): void;
32
- setEditor(editor: Editor): void;
33
- setList(list: ListLite): void;
34
- setSidebarLayer(sidebarLayer: SidebarLayer): void;
35
- setCheckerLauncher(checkerLauncher: CheckerLauncher): void;
22
+ inject(depName: string, obj: any): void;
23
+ get(depName: string): any;
36
24
  getApi(): Api;
37
25
  getCommentList(): Comment[];
38
26
  getCommentDataList(): CommentData[];
@@ -65,12 +53,11 @@ export default class Context implements ContextApi {
65
53
  on(name: any, handler: any, scope?: any): void;
66
54
  off(name: any, handler: any, scope?: any): void;
67
55
  trigger(name: any, payload?: any, scope?: any): void;
68
- $t(key: keyof I18n, args?: {
56
+ $t(key: I18n.I18nKeys, args?: {
69
57
  [key: string]: string;
70
58
  }): string;
71
59
  setDarkMode(darkMode: boolean): void;
72
- private darkModeMedia;
73
- private darkModeAutoFunc?;
74
- private refreshDarkModeConf;
75
- updateConf(conf: Partial<ArtalkConfig>): void;
60
+ updateConf(nConf: Partial<ArtalkConfig>): void;
61
+ getMarkedInstance(): typeof import("marked").marked | undefined;
76
62
  }
63
+ export default Context;
@@ -0,0 +1,9 @@
1
+ import type { CommentData } from '../../types/artalk-data';
2
+ import Editor from './editor';
3
+ export interface EditModeManager {
4
+ editor: Editor;
5
+ comment?: CommentData;
6
+ setEdit: (comment: CommentData, $comment: HTMLElement) => void;
7
+ cancelEdit: () => void;
8
+ }
9
+ export declare function createEditModeManager(editor: Editor): EditModeManager;
@@ -1,55 +1,53 @@
1
- import { CommentData } from '../../types/artalk-data';
2
- import Context from '../../types/context';
1
+ import type { CommentData } from '../../types/artalk-data';
2
+ import type Context from '../../types/context';
3
3
  import Component from '../lib/component';
4
- import EditorPlug from './plugs/editor-plug';
4
+ import { EditorUI } from './ui';
5
+ import { PlugManager } from './plug-manager';
6
+ import { Mover } from './mover';
7
+ import { ReplyManager } from './reply';
8
+ import { EditModeManager } from './edit-mode';
9
+ import { SubmitManager } from './submit';
5
10
  export default class Editor extends Component {
6
- private get user();
7
- $header: HTMLElement;
8
- $nick: HTMLInputElement;
9
- $email: HTMLInputElement;
10
- $link: HTMLInputElement;
11
- get $inputs(): {
12
- nick: HTMLInputElement;
13
- email: HTMLInputElement;
14
- link: HTMLInputElement;
15
- };
16
- $textareaWrap: HTMLElement;
17
- $textarea: HTMLTextAreaElement;
18
- $bottom: HTMLElement;
19
- $submitBtn: HTMLButtonElement;
20
- $notifyWrap: HTMLElement;
21
- private isTraveling;
11
+ /** 界面 */
12
+ private ui;
13
+ getUI(): EditorUI;
14
+ /** 插件管理器 */
15
+ private plugs?;
16
+ getPlugs(): PlugManager | undefined;
17
+ setPlugs(p: PlugManager): void;
18
+ /** 评论框移动 */
19
+ private mover?;
20
+ setMover(m: Mover): void;
22
21
  /** 回复评论 */
23
- private replyComment;
24
- private $sendReply;
22
+ private reply?;
23
+ setReplyManager(m: ReplyManager): void;
24
+ getReplyManager(): ReplyManager | undefined;
25
25
  get isReplyMode(): boolean;
26
26
  /** 编辑评论 */
27
- private editComment;
28
- private $editCancelBtn;
27
+ private editMode?;
28
+ setEditModeManager(m: EditModeManager): void;
29
29
  get isEditMode(): boolean;
30
- /** 启用的插件 */
31
- private readonly ENABLED_PLUGS;
32
- plugList: {
33
- [name: string]: EditorPlug;
34
- };
35
- private openedPlugName;
36
- $plugPanelWrap: HTMLElement;
37
- $plugBtnWrap: HTMLElement;
30
+ /** 提交评论 */
31
+ private submitManager?;
32
+ setSubmitManager(m: SubmitManager): void;
33
+ getSubmitManager(): SubmitManager | undefined;
38
34
  constructor(ctx: Context);
39
- private initLocalStorage;
40
- private saveToLocalStorage;
41
- private initHeader;
42
- private onHeaderInput;
43
- private initTextarea;
44
- private refreshSendBtnText;
45
- private initSubmitBtn;
35
+ getHeaderInputEls(): {
36
+ nick: HTMLInputElement;
37
+ email: HTMLInputElement;
38
+ link: HTMLInputElement;
39
+ };
40
+ saveToLocalStorage(): void;
41
+ refreshSendBtnText(): void;
46
42
  /** 最终用于 submit 的数据 */
47
43
  getFinalContent(): string;
48
44
  getContentOriginal(): string;
49
45
  getContentMarked(): string;
50
46
  setContent(val: string): void;
51
47
  insertContent(val: string): void;
52
- private adjustTextareaHeight;
48
+ adjustTextareaHeight(): void;
49
+ focus(): void;
50
+ reset(): void;
53
51
  /** 设置回复评论 */
54
52
  setReply(commentData: CommentData, $comment: HTMLElement, scroll?: boolean): void;
55
53
  /** 取消回复评论 */
@@ -63,10 +61,6 @@ export default class Editor extends Component {
63
61
  hideLoading(): void;
64
62
  /** 点击评论提交按钮事件 */
65
63
  submit(): Promise<void>;
66
- /** 创建评论 */
67
- submitAdd(): Promise<void>;
68
- /** 修改评论 */
69
- submitEdit(): Promise<void>;
70
64
  /** 关闭评论 */
71
65
  close(): void;
72
66
  /** 打开评论 */
@@ -75,8 +69,6 @@ export default class Editor extends Component {
75
69
  travel($afterEl: HTMLElement): void;
76
70
  /** 评论框归位 */
77
71
  travelBack(): void;
78
- /** 插件初始化 */
79
- private initPlugs;
80
72
  /** 展开插件面板 */
81
73
  openPlugPanel(plugName: string): void;
82
74
  /** 收起插件面板 */
@@ -0,0 +1,2 @@
1
+ import Editor from './editor';
2
+ export default function initEditorFuncs(editor: Editor): void;
@@ -0,0 +1,8 @@
1
+ import Editor from './editor';
2
+ export interface Mover {
3
+ editor: Editor;
4
+ isMoved: boolean;
5
+ move(afterEl: HTMLElement): void;
6
+ back(): void;
7
+ }
8
+ export declare function createMover(editor: Editor): Mover;
@@ -0,0 +1,17 @@
1
+ import EditorPlug from './plugs/editor-plug';
2
+ import Editor from './editor';
3
+ /** Context of an editor plug manager */
4
+ export interface PlugManager {
5
+ editor: Editor;
6
+ plugList: {
7
+ [name: string]: EditorPlug;
8
+ };
9
+ openedPlugName: string | null;
10
+ openPlugPanel(plugName: string): void;
11
+ closePlugPanel(): void;
12
+ triggerHeaderInputEvt(field: string, $input: HTMLInputElement): void;
13
+ triggerContentUpdatedEvt(content: string): void;
14
+ getTransformedContent(raw: string): string;
15
+ }
16
+ /** Create an editor plug manager */
17
+ export declare function createPlugManager(editor: Editor): PlugManager;
@@ -15,12 +15,24 @@ declare abstract class EditorPlug {
15
15
  protected $panel?: HTMLElement;
16
16
  protected $btn?: HTMLElement;
17
17
  onHeaderInput?: (key: string, $input: HTMLElement) => void;
18
+ contentTransformer?: (rawContent: string) => string;
19
+ onContentUpdated?: (content: string) => void;
18
20
  constructor(editor: Editor);
21
+ /** Name of plug */
19
22
  static Name: string;
23
+ /** Register plug panel will provide a plug el */
20
24
  protected registerPanel(html?: string): HTMLElement;
25
+ /** Register plug btn will add a btn on the bottom of editor */
21
26
  protected registerBtn(html: string): HTMLElement;
22
- protected registerHeaderInputEvt(action: (key: string, $input: HTMLElement) => void): void;
27
+ /** Register the event of header input is changed */
28
+ protected registerHeaderInputEvt(func: (key: string, $input: HTMLElement) => void): void;
29
+ /** Register the content transformer to handle the content of the last submit by the editor */
30
+ protected registerContentTransformer(func: (raw: string) => string): void;
31
+ /** Register the event of editor content is updated */
32
+ protected registerContentUpdatedEvt(func: (content: string) => void): void;
33
+ /** Get panel element of plug */
23
34
  getPanel(): HTMLElement | undefined;
35
+ /** Get btn element of plug */
24
36
  getBtn(): HTMLElement | undefined;
25
37
  }
26
38
  export default EditorPlug;
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,16 @@
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 {};