mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-02 18:01:15 +08:00
This commit is contained in:
parent
5cd040b302
commit
9021467f0c
@ -14,7 +14,7 @@ import {getAllModels} from "../layout/getAll";
|
|||||||
import {getAllEditor} from "../layout/getAll";
|
import {getAllEditor} from "../layout/getAll";
|
||||||
|
|
||||||
export const validateName = (name: string, targetElement?: HTMLElement) => {
|
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) {
|
if (targetElement) {
|
||||||
showTooltip(window.siyuan.languages.fileNameRule, targetElement, "error");
|
showTooltip(window.siyuan.languages.fileNameRule, targetElement, "error");
|
||||||
} else {
|
} else {
|
||||||
@ -34,7 +34,7 @@ export const validateName = (name: string, targetElement?: HTMLElement) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const replaceFileName = (name: string) => {
|
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) => {
|
export const replaceLocalPath = (name: string) => {
|
||||||
|
@ -318,7 +318,11 @@ export class Title {
|
|||||||
path: protyle.path,
|
path: protyle.path,
|
||||||
title: fileName,
|
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);
|
setTitle(fileName);
|
||||||
}, Constants.TIMEOUT_INPUT);
|
}, Constants.TIMEOUT_INPUT);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user