Skip to content

如何清除文档的全部内容 #7507

Answered by raintoway
mazhenjie233 asked this question in Q&A
Discussion options

You must be logged in to vote

with [email protected]
thepackages/presets/src/fragments/doc-title/doc-title.ts as follow,

 // 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.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mazhenjie233
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants