mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-03 15:28:49 +01:00
This commit is contained in:
parent
916bf685ac
commit
9a1b8148e1
4 changed files with 48 additions and 33 deletions
40
app/src/menus/block.ts
Normal file
40
app/src/menus/block.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import {MenuItem} from "./Menu";
|
||||
import {Dialog} from "../dialog";
|
||||
import {isMobile} from "../util/functions";
|
||||
import {fetchPost} from "../util/fetch";
|
||||
|
||||
export const transferBlockRef = (id:string) => {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.transferBlockRef,
|
||||
click() {
|
||||
const renameDialog = new Dialog({
|
||||
title: window.siyuan.languages.transferBlockRef,
|
||||
content: `<div class="b3-dialog__content">
|
||||
<input class="b3-text-field fn__block" placeholder="${window.siyuan.languages.targetBlockID}">
|
||||
<div class="b3-label__text">${window.siyuan.languages.transferBlockRefTip}</div>
|
||||
</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: isMobile() ? "80vw" : "520px",
|
||||
});
|
||||
const inputElement = renameDialog.element.querySelector("input") as HTMLInputElement;
|
||||
const btnsElement = renameDialog.element.querySelectorAll(".b3-button");
|
||||
renameDialog.bindInput(inputElement, () => {
|
||||
(btnsElement[1] as HTMLButtonElement).click();
|
||||
});
|
||||
inputElement.focus();
|
||||
btnsElement[0].addEventListener("click", () => {
|
||||
renameDialog.destroy();
|
||||
});
|
||||
btnsElement[1].addEventListener("click", () => {
|
||||
fetchPost("/api/block/transferBlockRef", {
|
||||
fromID: id,
|
||||
toID: inputElement.value,
|
||||
});
|
||||
renameDialog.destroy();
|
||||
});
|
||||
}
|
||||
}).element);
|
||||
}
|
||||
|
|
@ -150,6 +150,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
|||
}
|
||||
}).element);
|
||||
/// #endif
|
||||
/// #endif
|
||||
let submenu: IMenu[] = [];
|
||||
if (element.getAttribute("data-subtype") === "s") {
|
||||
submenu.push({
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import {hintMoveBlock} from "../hint/extend";
|
|||
import {makeCard} from "../../card/makeCard";
|
||||
import {Dialog} from "../../dialog";
|
||||
import {isMobile} from "../../util/functions";
|
||||
import {transferBlockRef} from "../../menus/block";
|
||||
|
||||
export class Gutter {
|
||||
public element: HTMLElement;
|
||||
|
|
@ -1374,39 +1375,7 @@ export class Gutter {
|
|||
}).element);
|
||||
const countElement = nodeElement.lastElementChild.querySelector(".protyle-attr--refcount")
|
||||
if (countElement && countElement.textContent) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.transferBlockRef,
|
||||
click() {
|
||||
const renameDialog = new Dialog({
|
||||
title: window.siyuan.languages.transferBlockRef,
|
||||
content: `<div class="b3-dialog__content">
|
||||
<input class="b3-text-field fn__block" placeholder="${window.siyuan.languages.targetBlockID}">
|
||||
<div class="b3-label__text">${window.siyuan.languages.transferBlockRefTip}</div>
|
||||
</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: isMobile() ? "80vw" : "520px",
|
||||
});
|
||||
const inputElement = renameDialog.element.querySelector("input") as HTMLInputElement;
|
||||
const btnsElement = renameDialog.element.querySelectorAll(".b3-button");
|
||||
renameDialog.bindInput(inputElement, () => {
|
||||
(btnsElement[1] as HTMLButtonElement).click();
|
||||
});
|
||||
inputElement.focus();
|
||||
btnsElement[0].addEventListener("click", () => {
|
||||
renameDialog.destroy();
|
||||
});
|
||||
btnsElement[1].addEventListener("click", () => {
|
||||
fetchPost("/api/block/transferBlockRef", {
|
||||
fromID: id,
|
||||
toID: inputElement.value,
|
||||
});
|
||||
renameDialog.destroy();
|
||||
});
|
||||
}
|
||||
}).element);
|
||||
transferBlockRef(id)
|
||||
}
|
||||
}
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import {deleteFile} from "../../editor/deleteFile";
|
|||
import {genEmptyElement} from "../../block/util";
|
||||
import {transaction} from "../wysiwyg/transaction";
|
||||
import {hideTooltip} from "../../dialog/tooltip";
|
||||
import {transferBlockRef} from "../../menus/block";
|
||||
|
||||
export class Title {
|
||||
public element: HTMLElement;
|
||||
|
|
@ -307,6 +308,10 @@ export class Title {
|
|||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
const countElement = this.element.lastElementChild.querySelector(".protyle-attr--refcount")
|
||||
if (countElement && countElement.textContent) {
|
||||
transferBlockRef(protyle.block.rootID);
|
||||
}
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.attr,
|
||||
accelerator: window.siyuan.config.keymap.editor.general.attr.custom + "/" + updateHotkeyTip("⇧Click"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue