mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 08:48:49 +01:00
This commit is contained in:
parent
2aeb531d65
commit
7898a21d85
3 changed files with 17 additions and 8 deletions
|
|
@ -385,6 +385,7 @@
|
|||
font-weight: bold;
|
||||
line-height: 1.625;
|
||||
padding: 0 4px;
|
||||
white-space: break-spaces;
|
||||
|
||||
&:empty:after {
|
||||
content: attr(data-tip);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import {code160to32} from "../util/code160to32";
|
|||
export class Title {
|
||||
public element: HTMLElement;
|
||||
public editElement: HTMLElement;
|
||||
private timeout: number
|
||||
|
||||
constructor(protyle: IProtyle) {
|
||||
this.element = document.createElement("div");
|
||||
|
|
@ -228,16 +229,19 @@ export class Title {
|
|||
}
|
||||
|
||||
private rename(protyle: IProtyle) {
|
||||
clearTimeout(this.timeout)
|
||||
if (!validateName(this.editElement.textContent)) {
|
||||
return false;
|
||||
}
|
||||
const fileName = replaceFileName(this.editElement.textContent);
|
||||
fetchPost("/api/filetree/renameDoc", {
|
||||
notebook: protyle.notebookId,
|
||||
path: protyle.path,
|
||||
title: fileName,
|
||||
});
|
||||
this.setTitle(fileName)
|
||||
this.timeout = window.setTimeout(() => {
|
||||
const fileName = replaceFileName(this.editElement.textContent);
|
||||
fetchPost("/api/filetree/renameDoc", {
|
||||
notebook: protyle.notebookId,
|
||||
path: protyle.path,
|
||||
title: fileName,
|
||||
});
|
||||
this.setTitle(fileName)
|
||||
}, Constants.TIMEOUT_INPUT)
|
||||
}
|
||||
|
||||
private renderMenu(protyle: IProtyle, iconElement: Element, position: { x: number, y: number }) {
|
||||
|
|
|
|||
|
|
@ -108,7 +108,11 @@ class Protyle {
|
|||
this.protyle.model.parent.updateTitle(data.data.title);
|
||||
}
|
||||
if (this.protyle.options.render.title && this.protyle.block.parentID === data.data.id) {
|
||||
this.protyle.title.setTitle(data.data.title);
|
||||
if (getSelection().rangeCount > 0 && this.protyle.element.contains(getSelection().getRangeAt(0).startContainer)) {
|
||||
// 编辑中的不用更新
|
||||
} else {
|
||||
this.protyle.title.setTitle(data.data.title);
|
||||
}
|
||||
}
|
||||
// update ref
|
||||
this.protyle.wysiwyg.element.querySelectorAll(`[data-type="block-ref"][data-id="${data.data.id}"]`).forEach(item => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue