mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-01 06:18:49 +01:00
This commit is contained in:
parent
5cd040b302
commit
9021467f0c
2 changed files with 7 additions and 3 deletions
|
|
@ -14,7 +14,7 @@ import {getAllModels} from "../layout/getAll";
|
|||
import {getAllEditor} from "../layout/getAll";
|
||||
|
||||
export const validateName = (name: string, targetElement?: HTMLElement) => {
|
||||
if (/\r\n|\r|\n|\u2028|\u2029|\t|\//.test(name)) {
|
||||
if (/\r\n|\r|\n|\u2028|\u2029|\t/.test(name)) {
|
||||
if (targetElement) {
|
||||
showTooltip(window.siyuan.languages.fileNameRule, targetElement, "error");
|
||||
} else {
|
||||
|
|
@ -34,7 +34,7 @@ export const validateName = (name: string, targetElement?: HTMLElement) => {
|
|||
};
|
||||
|
||||
export const replaceFileName = (name: string) => {
|
||||
return name.replace(/\r\n|\r|\n|\u2028|\u2029|\t|\//g, "").substring(0, Constants.SIZE_TITLE);
|
||||
return name.replace(/\r\n|\r|\n|\u2028|\u2029|\t|/g, "").replace(/\//g, "/").substring(0, Constants.SIZE_TITLE);
|
||||
};
|
||||
|
||||
export const replaceLocalPath = (name: string) => {
|
||||
|
|
|
|||
|
|
@ -318,7 +318,11 @@ export class Title {
|
|||
path: protyle.path,
|
||||
title: fileName,
|
||||
});
|
||||
this.setTitle(fileName);
|
||||
if (fileName !== this.editElement.textContent) {
|
||||
const offset = getSelectionOffset(this.editElement);
|
||||
this.setTitle(fileName);
|
||||
focusByOffset(this.editElement, offset.start, offset.end);
|
||||
}
|
||||
setTitle(fileName);
|
||||
}, Constants.TIMEOUT_INPUT);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue