Skip to content

How to manually set and render the document's title using setDocMeta? The title does not render. #7497

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 handleChangeTitle() {
    (this.doc.root as RootBlockModel)?.title.replace(
      0,
      this._rootModel.title.length,
      Math.random() + ''
    );
  }

  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}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mazhenjie233
Comment options

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