diff --git a/docs/docs/develop/fe-api.md b/docs/docs/develop/fe-api.md index 648493ff0..b4ac0dd6a 100644 --- a/docs/docs/develop/fe-api.md +++ b/docs/docs/develop/fe-api.md @@ -157,3 +157,23 @@ artalk.setDarkMode(true) ## 浏览量组件 `loadCountWidget` 详情见:[浏览量统计](../guide/frontend/pv.md) + +## 获取配置 `getConf` + +获取当前 Artalk 配置。 + +```js +const artalk = Artalk.init({ ... }) + +const conf = artalk.getConf() +``` + +## 获取挂载元素 `getEl` + +获取当前 Artalk 挂载的 DOM 元素。 + +```js +const artalk = Artalk.init({ ... }) + +const el = artalk.getEl() +``` diff --git a/ui/artalk/src/context.ts b/ui/artalk/src/context.ts index df5cb92b7..1766a73fd 100644 --- a/ui/artalk/src/context.ts +++ b/ui/artalk/src/context.ts @@ -142,6 +142,10 @@ class Context implements ContextApi { return this.conf } + public getEl(): HTMLElement { + return this.$root + } + public getMarked() { return marked.getInstance() } diff --git a/ui/artalk/types/context.ts b/ui/artalk/types/context.ts index 6e1ec4641..66c9d3ec1 100644 --- a/ui/artalk/types/context.ts +++ b/ui/artalk/types/context.ts @@ -82,6 +82,9 @@ export interface ContextApi extends EventManagerFuncs { /** 获取配置 */ getConf(): ArtalkConfig + /** 获取挂载元素 */ + getEl(): HTMLElement + /** 更新配置 */ updateConf(conf: Partial): void }