artalk 2.4.4 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/dist/Artalk.css +1 -1
- package/dist/Artalk.es.js +4872 -4072
- package/dist/Artalk.iife.js +1 -1
- package/dist/Artalk.js +1 -1
- package/dist/ArtalkLite.css +1 -1
- package/dist/ArtalkLite.es.js +2468 -1779
- package/dist/ArtalkLite.iife.js +1 -1
- package/dist/ArtalkLite.js +1 -1
- package/dist/i18n/jp.js +1 -1
- package/dist/i18n/zh-TW.js +1 -1
- package/dist/src/api/index.d.ts +2 -2
- package/dist/src/api/system.d.ts +5 -2
- package/dist/src/artalk.d.ts +42 -34
- package/dist/src/comment/comment.d.ts +2 -2
- package/dist/src/comment/height-limit.d.ts +30 -0
- package/dist/src/comment/render-ctx.d.ts +23 -0
- package/dist/src/comment/render.d.ts +2 -50
- package/dist/src/comment/renders/actions.d.ts +5 -0
- package/dist/src/comment/renders/avatar.d.ts +5 -0
- package/dist/src/comment/renders/content.d.ts +5 -0
- package/dist/src/comment/renders/header.d.ts +5 -0
- package/dist/src/comment/renders/index.d.ts +2 -0
- package/dist/src/comment/renders/pending.d.ts +5 -0
- package/dist/src/comment/renders/reply-at.d.ts +5 -0
- package/dist/src/comment/renders/reply-to.d.ts +5 -0
- package/dist/src/components/dialog.d.ts +1 -1
- package/dist/src/config.d.ts +8 -0
- package/dist/src/context.d.ts +15 -29
- package/dist/src/editor/edit-mode.d.ts +9 -0
- package/dist/src/editor/editor-ui.d.ts +25 -0
- package/dist/src/editor/editor.d.ts +37 -45
- package/dist/src/editor/funcs.d.ts +2 -0
- package/dist/src/editor/mover.d.ts +8 -0
- package/dist/src/editor/plug-manager.d.ts +17 -0
- package/dist/src/editor/plugs/editor-plug.d.ts +13 -1
- package/dist/src/editor/reply.d.ts +9 -0
- package/dist/src/editor/submit.d.ts +16 -0
- package/dist/src/editor/ui.d.ts +25 -0
- package/dist/src/i18n/index.d.ts +11 -7
- package/dist/src/layer/index.d.ts +2 -2
- package/dist/src/layer/layer.d.ts +1 -1
- package/dist/src/lib/checker/captcha-renders.d.ts +5 -0
- package/dist/src/lib/checker/index.d.ts +18 -10
- package/dist/src/lib/dark-mode.d.ts +4 -0
- package/dist/src/lib/marked.d.ts +9 -0
- package/dist/src/lib/utils.d.ts +1 -5
- package/dist/src/list/list-lite.d.ts +15 -11
- package/dist/src/list/list-nest.d.ts +2 -2
- package/dist/src/list/list-ui.d.ts +7 -0
- package/dist/src/list/paginator/adaptors/index.d.ts +12 -0
- package/dist/src/list/paginator/adaptors/pagination.d.ts +9 -0
- package/dist/src/list/paginator/adaptors/read-more.d.ts +10 -0
- package/dist/src/list/paginator/holder.d.ts +16 -0
- package/dist/src/list/paginator/index.d.ts +10 -0
- package/dist/src/service.d.ts +40 -0
- package/dist/types/artalk-config.d.ts +5 -2
- package/dist/types/artalk-data.d.ts +3 -3
- package/dist/types/context.d.ts +11 -17
- package/dist/types/global.d.ts +1 -0
- package/package.json +6 -7
- package/src/api/system.ts +3 -12
- package/src/artalk.ts +101 -158
- package/src/comment/comment.ts +7 -6
- package/src/comment/height-limit.ts +100 -0
- package/src/comment/render-ctx.ts +30 -0
- package/src/comment/render.ts +31 -375
- package/src/comment/renders/actions.ts +114 -0
- package/src/comment/renders/avatar.ts +22 -0
- package/src/comment/renders/content.ts +39 -0
- package/src/comment/renders/header.ts +84 -0
- package/src/comment/renders/index.ts +19 -0
- package/src/comment/renders/pending.ts +12 -0
- package/src/comment/renders/reply-at.ts +16 -0
- package/src/comment/renders/reply-to.ts +24 -0
- package/src/config.ts +65 -0
- package/src/context.ts +31 -86
- package/src/defaults.ts +1 -0
- package/src/editor/edit-mode.ts +102 -0
- package/src/editor/editor.ts +100 -395
- package/src/editor/funcs.ts +96 -0
- package/src/editor/mover.ts +43 -0
- package/src/editor/plug-manager.ts +172 -0
- package/src/editor/plugs/editor-plug.ts +20 -2
- package/src/editor/plugs/{emoticons-plug.less → emoticons-plug.scss} +5 -4
- package/src/editor/plugs/emoticons-plug.ts +2 -1
- package/src/editor/plugs/header-input-plug.ts +5 -5
- package/src/editor/plugs/{preview-plug.less → preview-plug.scss} +1 -1
- package/src/editor/plugs/preview-plug.ts +8 -4
- package/src/editor/plugs/upload-plug.ts +10 -13
- package/src/editor/reply.ts +62 -0
- package/src/editor/submit.ts +98 -0
- package/src/editor/ui.ts +36 -0
- package/src/i18n/index.ts +21 -10
- package/src/layer/index.ts +2 -2
- package/src/layer/layer.ts +4 -4
- package/src/layer/sidebar-layer.ts +2 -1
- package/src/lib/checker/admin.ts +36 -0
- package/src/lib/checker/captcha-renders.ts +68 -0
- package/src/lib/checker/captcha.ts +26 -0
- package/src/lib/checker/index.ts +38 -20
- package/src/lib/dark-mode.ts +48 -0
- package/src/lib/marked.ts +133 -0
- package/src/lib/utils.ts +1 -123
- package/src/list/list-lite.ts +59 -162
- package/src/list/list-ui.ts +80 -0
- package/src/list/list.ts +16 -8
- package/src/list/paginator/adaptors/index.ts +21 -0
- package/src/list/paginator/adaptors/pagination.ts +42 -0
- package/src/list/paginator/adaptors/read-more.ts +56 -0
- package/src/list/paginator/holder.ts +55 -0
- package/src/list/paginator/index.ts +13 -0
- package/src/service.ts +118 -0
- package/src/style/{_color.less → _color.scss} +3 -3
- package/src/style/{_extend.less → _extend.scss} +1 -1
- package/src/style/_variables.scss +3 -0
- package/src/style/{comment.less → comment.scss} +36 -12
- package/src/style/{editor.less → editor.scss} +11 -11
- package/src/style/{list.less → list.scss} +8 -6
- package/src/style/{main.less → main.scss} +24 -23
- package/src/style/{sidebar-layer.less → sidebar-layer.scss} +8 -8
- package/types/artalk-config.d.ts +5 -2
- package/types/artalk-data.d.ts +3 -3
- package/types/context.d.ts +11 -17
- package/types/global.d.ts +1 -0
- package/CNAME +0 -1
- package/LICENSE +0 -165
- package/index.html +0 -157
- package/postcss.config.js +0 -5
- package/scripts/build-i18n.mjs +0 -46
- package/src/lib/checker/admin-checker.ts +0 -36
- package/src/lib/checker/captcha-checker.ts +0 -84
- package/src/style/_variables.less +0 -3
- package/test/ArtalkCount.html +0 -16
- package/test/ArtalkI18n.html +0 -16
- package/test/ArtalkLite.html +0 -15
- package/test/CSRF.html +0 -26
- package/tsconfig.json +0 -12
- package/vite-base.config.ts +0 -21
- package/vite-demo.config.ts +0 -12
- package/vite-lite.config.ts +0 -22
- package/vite.config.ts +0 -27
- /package/dist/src/lib/checker/{admin-checker.d.ts → admin.d.ts} +0 -0
- /package/dist/src/lib/checker/{captcha-checker.d.ts → captcha.d.ts} +0 -0
- /package/src/style/{pagination.less → pagination.scss} +0 -0
package/dist/i18n/jp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,
|
|
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={placeholder:"Leave a comment",noComment:"No Comment",send:"Send",save:"Save",nick:"Nickname",email:"Email",link:"Website",emoticon:"Emoji",preview:"Preview",image:"Image",uploadFail:"Upload Failed",commentFail:"Failed to comment",restoredMsg:"Content has been restored",onlyAdminCanReply:"Only admin can reply",uploadLoginMsg:"Please fill in your name and email to upload",counter:"{count} Comments",sortLatest:"Latest",sortOldest:"Oldest",sortBest:"Best",sortAuthor:"Author",openComment:"Open Comment",closeComment:"Close Comment",listLoadFailMsg:"Failed to load comments",listRetry:"Click to retry",loadMore:"Load More",admin:"Admin",reply:"Reply",voteUp:"Up",voteDown:"Down",voteFail:"Vote Failed",readMore:"Read More",actionConfirm:"Confirm",collapse:"Collapse",collapsed:"Collapsed",collapsedMsg:"This comment has been collapsed",expand:"Expand",approved:"Approved",pending:"Pending",pendingMsg:"Pending, visible only to commenter.",edit:"Edit",editCancel:"Cancel Edit",delete:"Delete",deleteConfirm:"Confirm",pin:"Pin",unpin:"Unpin",seconds:"seconds ago",minutes:"minutes ago",hours:"hours ago",days:"days ago",now:"just now",adminCheck:"Enter admin password:",captchaCheck:"Enter the CAPTCHA to continue:",confirm:"Confirm",cancel:"Cancel",msgCenter:"Messages",ctrlCenter:"Admin",frontend:"Frontend",backend:"Backend",loading:"Loading",loadFail:"Load Failed",editing:"Editing",editFail:"Edit Failed",deleting:"Deleting",deleteFail:"Delete Failed",reqGot:"Request got",reqAborted:"Request timed out or terminated unexpectedly"},o={en:e,"en-US":e,"zh-CN":{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:"请求超时或意外终止"}},n="ArtalkI18n";var t;t=(t="en").replace(/^([a-zA-Z]+)(-[a-zA-Z]+)?$/,((e,o,n)=>o.toLowerCase()+(n||"").toUpperCase())),o[t]?o[t]:window[n]&&window[n][t]?window[n][t]:o.en;const i=function(e,o,t){return window[n]||(window[n]={}),window[n][e]=o,t&&t.forEach((e=>{window[n][e]=o})),o}("jp",{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:"リクエストがタイムアウトしたか、予期せず終了した"},["jp-JP"]);return i}));
|
package/dist/i18n/zh-TW.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,
|
|
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={placeholder:"Leave a comment",noComment:"No Comment",send:"Send",save:"Save",nick:"Nickname",email:"Email",link:"Website",emoticon:"Emoji",preview:"Preview",image:"Image",uploadFail:"Upload Failed",commentFail:"Failed to comment",restoredMsg:"Content has been restored",onlyAdminCanReply:"Only admin can reply",uploadLoginMsg:"Please fill in your name and email to upload",counter:"{count} Comments",sortLatest:"Latest",sortOldest:"Oldest",sortBest:"Best",sortAuthor:"Author",openComment:"Open Comment",closeComment:"Close Comment",listLoadFailMsg:"Failed to load comments",listRetry:"Click to retry",loadMore:"Load More",admin:"Admin",reply:"Reply",voteUp:"Up",voteDown:"Down",voteFail:"Vote Failed",readMore:"Read More",actionConfirm:"Confirm",collapse:"Collapse",collapsed:"Collapsed",collapsedMsg:"This comment has been collapsed",expand:"Expand",approved:"Approved",pending:"Pending",pendingMsg:"Pending, visible only to commenter.",edit:"Edit",editCancel:"Cancel Edit",delete:"Delete",deleteConfirm:"Confirm",pin:"Pin",unpin:"Unpin",seconds:"seconds ago",minutes:"minutes ago",hours:"hours ago",days:"days ago",now:"just now",adminCheck:"Enter admin password:",captchaCheck:"Enter the CAPTCHA to continue:",confirm:"Confirm",cancel:"Cancel",msgCenter:"Messages",ctrlCenter:"Admin",frontend:"Frontend",backend:"Backend",loading:"Loading",loadFail:"Load Failed",editing:"Editing",editFail:"Edit Failed",deleting:"Deleting",deleteFail:"Delete Failed",reqGot:"Request got",reqAborted:"Request timed out or terminated unexpectedly"},o={en:e,"en-US":e,"zh-CN":{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:"请求超时或意外终止"}},n="ArtalkI18n";var t;t=(t="en").replace(/^([a-zA-Z]+)(-[a-zA-Z]+)?$/,((e,o,n)=>o.toLowerCase()+(n||"").toUpperCase())),o[t]?o[t]:window[n]&&window[n][t]?window[n][t]:o.en;const i=function(e,o,t){return window[n]||(window[n]={}),window[n][e]=o,t&&t.forEach((e=>{window[n][e]=o})),o}("zh-TW",{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:"請求超時或意外終止"});return i}));
|
package/dist/src/api/index.d.ts
CHANGED
|
@@ -22,8 +22,8 @@ declare class Api {
|
|
|
22
22
|
get baseURL(): string;
|
|
23
23
|
constructor(ctx: Context);
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
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 {
|
package/dist/src/api/system.d.ts
CHANGED
|
@@ -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<
|
|
10
|
+
getSettings(): Promise<{
|
|
11
|
+
custom: string;
|
|
12
|
+
template: string;
|
|
13
|
+
}>;
|
|
11
14
|
/** 保存配置数据 */
|
|
12
15
|
saveSettings(yamlStr: string): Promise<boolean>;
|
|
13
16
|
/** 获取 API 版本信息 */
|
package/dist/src/artalk.d.ts
CHANGED
|
@@ -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
|
-
* @
|
|
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
|
|
18
|
-
protected static
|
|
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(
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
|
|
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 (
|
|
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
|
-
/**
|
|
49
|
-
static
|
|
50
|
-
/**
|
|
51
|
-
static
|
|
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
|
|
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():
|
|
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
|
-
|
|
4
|
-
|
|
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,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>;
|
package/dist/src/context.d.ts
CHANGED
|
@@ -1,38 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
36
23
|
getApi(): Api;
|
|
37
24
|
getCommentList(): Comment[];
|
|
38
25
|
getCommentDataList(): CommentData[];
|
|
@@ -65,12 +52,11 @@ export default class Context implements ContextApi {
|
|
|
65
52
|
on(name: any, handler: any, scope?: any): void;
|
|
66
53
|
off(name: any, handler: any, scope?: any): void;
|
|
67
54
|
trigger(name: any, payload?: any, scope?: any): void;
|
|
68
|
-
$t(key:
|
|
55
|
+
$t(key: I18n.I18nKeys, args?: {
|
|
69
56
|
[key: string]: string;
|
|
70
57
|
}): string;
|
|
71
58
|
setDarkMode(darkMode: boolean): void;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
private refreshDarkModeConf;
|
|
75
|
-
updateConf(conf: Partial<ArtalkConfig>): void;
|
|
59
|
+
updateConf(nConf: Partial<ArtalkConfig>): void;
|
|
60
|
+
getMarkedInstance(): typeof import("marked").marked | undefined;
|
|
76
61
|
}
|
|
62
|
+
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;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const Sel: {
|
|
2
|
+
$header: string;
|
|
3
|
+
$nick: string;
|
|
4
|
+
$email: string;
|
|
5
|
+
$link: string;
|
|
6
|
+
$textareaWrap: string;
|
|
7
|
+
$textarea: string;
|
|
8
|
+
$bottom: string;
|
|
9
|
+
$submitBtn: string;
|
|
10
|
+
$notifyWrap: string;
|
|
11
|
+
$plugBtnWrap: string;
|
|
12
|
+
$plugPanelWrap: string;
|
|
13
|
+
};
|
|
14
|
+
export interface EditorUI extends Record<keyof typeof Sel, HTMLElement> {
|
|
15
|
+
$el: HTMLElement;
|
|
16
|
+
$nick: HTMLInputElement;
|
|
17
|
+
$email: HTMLInputElement;
|
|
18
|
+
$link: HTMLInputElement;
|
|
19
|
+
$textarea: HTMLTextAreaElement;
|
|
20
|
+
$submitBtn: HTMLButtonElement;
|
|
21
|
+
$sendReply?: HTMLElement;
|
|
22
|
+
$editCancelBtn?: HTMLElement;
|
|
23
|
+
}
|
|
24
|
+
export declare function render(): EditorUI;
|
|
25
|
+
export {};
|
|
@@ -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
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
24
|
-
|
|
22
|
+
private reply?;
|
|
23
|
+
setReplyManager(m: ReplyManager): void;
|
|
24
|
+
getReplyManager(): ReplyManager | undefined;
|
|
25
25
|
get isReplyMode(): boolean;
|
|
26
26
|
/** 编辑评论 */
|
|
27
|
-
private
|
|
28
|
-
|
|
27
|
+
private editMode?;
|
|
28
|
+
setEditModeManager(m: EditModeManager): void;
|
|
29
29
|
get isEditMode(): boolean;
|
|
30
|
-
/**
|
|
31
|
-
private
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
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,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;
|