Vanessa 2025-10-17 00:35:38 +08:00
parent f9949e3e73
commit a8583c3c04

View file

@ -953,7 +953,7 @@ export class Outline extends Model {
label: window.siyuan.languages.insertSameLevelHeadingBefore, label: window.siyuan.languages.insertSameLevelHeadingBefore,
click: () => { click: () => {
fetchPost("/api/block/insertBlock", { fetchPost("/api/block/insertBlock", {
data: "#".repeat(this.getHeadingLevel(element)) + " ", data: "#".repeat(currentLevel) + " ",
dataType: "markdown", dataType: "markdown",
nextID: id nextID: id
}, (response) => { }, (response) => {
@ -975,7 +975,7 @@ export class Outline extends Model {
id, id,
}, (deleteResponse) => { }, (deleteResponse) => {
fetchPost("/api/block/insertBlock", { fetchPost("/api/block/insertBlock", {
data: "#".repeat(this.getHeadingLevel(element)) + " ", data: "#".repeat(currentLevel) + " ",
dataType: "markdown", dataType: "markdown",
previousID: deleteResponse.data.doOperations[deleteResponse.data.doOperations.length - 1].id previousID: deleteResponse.data.doOperations[deleteResponse.data.doOperations.length - 1].id
}, (response) => { }, (response) => {
@ -995,18 +995,30 @@ export class Outline extends Model {
icon: "iconAdd", icon: "iconAdd",
label: window.siyuan.languages.addChildHeading, label: window.siyuan.languages.addChildHeading,
click: () => { click: () => {
fetchPost("/api/block/prependBlock", { fetchPost("/api/block/getHeadingDeleteTransaction", {
data: "#".repeat(Math.min(this.getHeadingLevel(element) + 1, 6)) + " ", id,
dataType: "markdown", }, (deleteResponse) => {
parentID: id let previousID = deleteResponse.data.doOperations[deleteResponse.data.doOperations.length - 1].id;
}, (response) => { deleteResponse.data.undoOperations.find((operationsItem: IOperation, index: number) => {
if (response.code === 0 && response.data && response.data.length > 0) { const startIndex = operationsItem.data.indexOf(' data-subtype="h');
openFileById({ if (startIndex > -1 && startIndex < 260 && parseInt(operationsItem.data.substring(startIndex + 16, startIndex + 17)) === currentLevel + 1) {
app: this.app, previousID = deleteResponse.data.undoOperations[index - 1].id;
id: response.data[0].doOperations[0].id, return true;
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_OUTLINE] }
}); });
} fetchPost("/api/block/insertBlock", {
data: "#".repeat(Math.min(currentLevel + 1, 6)) + " ",
dataType: "markdown",
previousID,
}, (response) => {
if (response.code === 0 && response.data && response.data.length > 0) {
openFileById({
app: this.app,
id: response.data[0].doOperations[0].id,
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_OUTLINE]
});
}
});
}); });
} }
}).element); }).element);