Skip to content

Commit

Permalink
fix: 增加使用el初始化编辑器的能力 Tencent#203
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsonliu committed May 10, 2022
1 parent de0993a commit 0793eb5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Cherry.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ export default class Cherry extends CherryStatic {
previewer: 'show',
editor: 'show',
};
let mountEl = document.getElementById(this.options.id);

let mountEl = this.options.id ? document.getElementById(this.options.id) : this.options.el;

if (!mountEl) {
if (!this.options.forceAppend) {
Expand Down
4 changes: 3 additions & 1 deletion types/cherry.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export interface CherryOptions {
/** 外层容器不存在时,是否强制输出到body上 */
forceAppend: boolean;
/** 挂载DOM节点ID,引擎模式下不生效 */
id: string;
id?: string;
/** 挂载DOM节点,引擎模式下不生效 */
el?: HTMLElement;
/** 初始内容,引擎模式下不生效 */
value: string;
instanceId?: string;
Expand Down

0 comments on commit 0793eb5

Please sign in to comment.