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
-
如何手动设置文档的标题并且渲染,通过setDocMeta标题不渲染 |
Beta Was this translation helpful? Give feedback.
Answered by
raintoway
Jul 5, 2024
Replies: 1 comment 1 reply
-
// 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}
.verticalScrollContainerGetter=${() => this._viewport}
.readonly=${this.doc.readonly}
.enableFormat=${false}
></rich-text>
<div @click=${this.handleChangeTitle}>点击我,更新title内容</div>
</div>
`;
} the key class is |
Beta Was this translation helpful? Give feedback.
1 reply
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,