如何清除文档的全部内容 #7507
Answered
by
raintoway
mazhenjie233
asked this question in
Q&A
如何清除文档的全部内容
#7507
-
如何清除文档的全部内容,用什么api |
Beta Was this translation helpful? Give feedback.
Answered by
raintoway
Jul 6, 2024
Replies: 1 comment
-
with [email protected] // eslint-disable-next-line @typescript-eslint/member-ordering
private handleClear() {
(this.doc.root as RootBlockModel)?.children.forEach((item) => {
const block = this.doc.getBlock(item.id);
if (block) {
this.doc.deleteBlock(block.model);
}
});
}
override render() {
const isEmpty = !this._rootModel.title.length && !this._isComposing;
return html`
<div
class="doc-title-container ${isEmpty
? 'doc-title-container-empty'
: ''}"
data-block-is-title="true"
>
<rich-text
.yText=${this._rootModel.title.yText}
.undoManager=${this.doc.history}
.verticalScrollContainerGetter=${() => this._viewport}
.readonly=${this.doc.readonly}
.enableFormat=${false}
></rich-text>
<div @click=${this.handleClear}>点击我,清空所有元素</div>
</div>
`;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mazhenjie233
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
with [email protected]
the
packages/presets/src/fragments/doc-title/doc-title.ts
as follow,