mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
This commit is contained in:
parent
4db1dc065a
commit
46b818c987
5 changed files with 135 additions and 26 deletions
|
|
@ -4,6 +4,8 @@ import {Graph} from "./Graph";
|
|||
import {Outline} from "./Outline";
|
||||
import {switchWnd} from "../util";
|
||||
import {Backlink} from "./Backlink";
|
||||
import {Dialog} from "../../dialog";
|
||||
import {fetchPost} from "../../util/fetch";
|
||||
|
||||
export const openBacklink = (protyle: IProtyle) => {
|
||||
const backlink = getAllModels().backlink.find(item => {
|
||||
|
|
@ -85,3 +87,28 @@ export const openOutline = (protyle: IProtyle) => {
|
|||
newWnd.element.style.width = "200px";
|
||||
switchWnd(newWnd, protyle.model.parent.parent);
|
||||
};
|
||||
|
||||
export const renameTag = (labelName: string) => {
|
||||
const dialog = new Dialog({
|
||||
title: window.siyuan.languages.rename,
|
||||
content: `<div class="b3-dialog__content"><input class="b3-text-field fn__block" value="${labelName}"></div>
|
||||
<div class="b3-dialog__action">
|
||||
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
|
||||
<button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
|
||||
</div>`,
|
||||
width: "520px",
|
||||
});
|
||||
const btnsElement = dialog.element.querySelectorAll(".b3-button");
|
||||
btnsElement[0].addEventListener("click", () => {
|
||||
dialog.destroy();
|
||||
});
|
||||
const inputElement = dialog.element.querySelector("input");
|
||||
dialog.bindInput(inputElement, () => {
|
||||
(btnsElement[1] as HTMLButtonElement).click();
|
||||
});
|
||||
inputElement.focus();
|
||||
inputElement.select();
|
||||
btnsElement[1].addEventListener("click", () => {
|
||||
fetchPost("/api/tag/renameTag", {oldLabel: labelName, newLabel: inputElement.value});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue