Interface Context

Artalk Context

interface Context {
    $root: HTMLElement;
    conf: Config;
    $t(key:
        | "link"
        | "open"
        | "cancel"
        | "loading"
        | "username"
        | "email"
        | "pending"
        | "confirm"
        | "days"
        | "hours"
        | "minutes"
        | "seconds"
        | "expand"
        | "emoticon"
        | "now"
        | "reply"
        | "edit"
        | "placeholder"
        | "noComment"
        | "send"
        | "signIn"
        | "signUp"
        | "save"
        | "nick"
        | "preview"
        | "uploadImage"
        | "uploadFail"
        | "commentFail"
        | "restoredMsg"
        | "onlyAdminCanReply"
        | "uploadLoginMsg"
        | "counter"
        | "sortLatest"
        | "sortOldest"
        | "sortBest"
        | "sortAuthor"
        | "openComment"
        | "closeComment"
        | "listLoadFailMsg"
        | "listRetry"
        | "loadMore"
        | "admin"
        | "voteUp"
        | "voteDown"
        | "voteFail"
        | "readMore"
        | "actionConfirm"
        | "collapse"
        | "collapsed"
        | "collapsedMsg"
        | "approved"
        | "pendingMsg"
        | "editCancel"
        | "delete"
        | "deleteConfirm"
        | "pin"
        | "unpin"
        | "adminCheck"
        | "captchaCheck"
        | "msgCenter"
        | "ctrlCenter"
        | "userProfile"
        | "noAccountPrompt"
        | "haveAccountPrompt"
        | "forgetPassword"
        | "resetPassword"
        | "changePassword"
        | "confirmPassword"
        | "passwordMismatch"
        | "verificationCode"
        | "verifySend"
        | "verifyResend"
        | "waitSeconds"
        | "emailVerified"
        | "password"
        | "nextStep"
        | "skipVerify"
        | "logoutConfirm"
        | "accountMergeNotice"
        | "accountMergeSelectOne"
        | "accountMergeConfirm"
        | "dismiss"
        | "merge"
        | "client"
        | "server"
        | "loadFail"
        | "editing"
        | "editFail"
        | "deleting"
        | "deleteFail"
        | "reqGot"
        | "reqAborted"
        | "updateMsg"
        | "currentVersion"
        | "ignore"
        | "openName", args?: {
        [key: string]: string;
    }): string;
    checkAdmin(payload: CheckerPayload): Promise<void>;
    checkCaptcha(payload: CheckerCaptchaPayload): Promise<void>;
    destroy(): void;
    editComment(commentData: CommentData, $comment: HTMLElement): void;
    editorHideLoading(): void;
    editorResetState(): void;
    editorShowLoading(): void;
    editorShowNotify(msg: string, type: NotifyLevel): void;
    fetch(params: Partial<ListFetchParams>): void;
    get<T>(key: T): Services[T];
    getApi(): Api;
    getApiHandlers(): ApiHandlers;
    getCommentDataList(): CommentData[];
    getCommentList(): CommentNode[];
    getCommentNodes(): CommentNode[];
    getComments(): CommentData[];
    getConf(): Config;
    getData(): DataManager;
    getEl(): HTMLElement;
    getMarked(): undefined | Marked;
    getUser(): UserManager;
    hideSidebar(): void;
    inject<T, K>(key: K): T extends undefined
        ? Services[K]
        : T;
    listGotoFirst(): void;
    off<K>(name: K, handler: EventHandler<EventPayloadMap[K]>): void;
    on<K>(name: K, handler: EventHandler<EventPayloadMap[K]>, opts?: EventOptions): void;
    provide<K, T, D>(key: K, impl: Constructor<T, Services, D>, deps?: D, opts?: ProvideFuncOptions): void;
    reload(): void;
    replyComment(commentData: CommentData, $comment: HTMLElement): void;
    setDarkMode(darkMode: boolean | "auto"): void;
    showSidebar(payload?: SidebarShowPayload): void;
    trigger<K>(name: K, payload?: EventPayloadMap[K]): void;
    updateConf(conf: DeepPartial<Config>): void;
    watchConf<T>(keys: T, effect: ((val: Pick<Config, T[number]>) => void)): void;
}

Hierarchy (view full)

Properties

$root: HTMLElement

The root element of Artalk

Use getEl() instead

conf: Config

Get config object

Use getConf() and updateConf() instead

Methods

  • Translate i18n message

    Parameters

    • key:
          | "link"
          | "open"
          | "cancel"
          | "loading"
          | "username"
          | "email"
          | "pending"
          | "confirm"
          | "days"
          | "hours"
          | "minutes"
          | "seconds"
          | "expand"
          | "emoticon"
          | "now"
          | "reply"
          | "edit"
          | "placeholder"
          | "noComment"
          | "send"
          | "signIn"
          | "signUp"
          | "save"
          | "nick"
          | "preview"
          | "uploadImage"
          | "uploadFail"
          | "commentFail"
          | "restoredMsg"
          | "onlyAdminCanReply"
          | "uploadLoginMsg"
          | "counter"
          | "sortLatest"
          | "sortOldest"
          | "sortBest"
          | "sortAuthor"
          | "openComment"
          | "closeComment"
          | "listLoadFailMsg"
          | "listRetry"
          | "loadMore"
          | "admin"
          | "voteUp"
          | "voteDown"
          | "voteFail"
          | "readMore"
          | "actionConfirm"
          | "collapse"
          | "collapsed"
          | "collapsedMsg"
          | "approved"
          | "pendingMsg"
          | "editCancel"
          | "delete"
          | "deleteConfirm"
          | "pin"
          | "unpin"
          | "adminCheck"
          | "captchaCheck"
          | "msgCenter"
          | "ctrlCenter"
          | "userProfile"
          | "noAccountPrompt"
          | "haveAccountPrompt"
          | "forgetPassword"
          | "resetPassword"
          | "changePassword"
          | "confirmPassword"
          | "passwordMismatch"
          | "verificationCode"
          | "verifySend"
          | "verifyResend"
          | "waitSeconds"
          | "emailVerified"
          | "password"
          | "nextStep"
          | "skipVerify"
          | "logoutConfirm"
          | "accountMergeNotice"
          | "accountMergeSelectOne"
          | "accountMergeConfirm"
          | "dismiss"
          | "merge"
          | "client"
          | "server"
          | "loadFail"
          | "editing"
          | "editFail"
          | "deleting"
          | "deleteFail"
          | "reqGot"
          | "reqAborted"
          | "updateMsg"
          | "currentVersion"
          | "ignore"
          | "openName"
    • Optionalargs: {
          [key: string]: string;
      }
      • [key: string]: string

    Returns string