Skip to content

Commit

Permalink
🎨 #11460
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed May 23, 2024
1 parent 5946933 commit 9f86cb3
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions app/src/protyle/gutter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {avContextmenu} from "../render/av/action";
import {getPlainText} from "../util/paste";
import {Menu} from "../../plugin/Menu";
import {addEditorToDatabase} from "../render/av/addToDatabase";
import {scrollCenter} from "../../util/highlightById";

export class Gutter {
public element: HTMLElement;
Expand Down Expand Up @@ -1242,10 +1243,23 @@ export class Gutter {
label: window.siyuan.languages.duplicateCompletely,
click() {
fetchPost("/api/av/duplicateAttributeViewBlock", {avID: nodeElement.getAttribute("data-av-id")}, (response) => {
const newBlock = document.createElement("div");
newBlock.innerHTML = response.data;
nodeElement.parentElement.insertBefore(newBlock, nodeElement.nextElementSibling);
focusBlock(newBlock);
const tempElement = document.createElement("template");
tempElement.innerHTML = protyle.lute.SpinBlockDOM(`<div data-node-id="${response.data.blockID}" data-av-id="${response.data.avID}" data-type="NodeAttributeView" data-av-type="table"></div>`)
const cloneElement = tempElement.content.firstElementChild;
nodeElement.after(cloneElement);
avRender(cloneElement, protyle, () => {
focusBlock(cloneElement);
});
scrollCenter(protyle);
transaction(protyle, [{
action: "insert",
data: cloneElement.outerHTML,
id: response.data.blockID,
previousID: id,
}], [{
action: "delete",
id: response.data.blockID,
}]);
});
}
});
Expand Down

0 comments on commit 9f86cb3

Please sign in to comment.