Skip to content

Commit

Permalink
🎨 #11519
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed May 24, 2024
1 parent 1cba50d commit 66b6bf4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions app/src/boot/globalEvent/keydown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,15 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
event.preventDefault();
return true;
}
if (matchHotKey(window.siyuan.config.keymap.editor.general.duplicateCompletely.custom, event)) {
const nodeElement = hasClosestBlock(range.startContainer);
if (!nodeElement || !nodeElement.classList.contains("av")) {
return false;
}
duplicateCompletely(protyle, nodeElement);
event.preventDefault();
return true;
}
if (matchHotKey(window.siyuan.config.keymap.editor.general.refresh.custom, event)) {
reloadProtyle(protyle, true);
event.preventDefault();
Expand Down
3 changes: 2 additions & 1 deletion app/src/protyle/render/av/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,14 +494,15 @@ export const removeAttrViewColAnimation = (blockElement: Element, id: string) =>

export const duplicateCompletely = (protyle:IProtyle, nodeElement:HTMLElement) => {
fetchPost("/api/av/duplicateAttributeViewBlock", {avID: nodeElement.getAttribute("data-av-id")}, (response) => {
nodeElement.classList.remove("protyle-wysiwyg--select")
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);
});
scrollCenter(protyle);
transaction(protyle, [{
action: "insert",
data: cloneElement.outerHTML,
Expand Down

0 comments on commit 66b6bf4

Please sign in to comment.