Skip to content

Commit

Permalink
🚨
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Jun 3, 2024
1 parent e34fb19 commit 8f8c56d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
50 changes: 25 additions & 25 deletions app/src/layout/dock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ export class Dock {
const moveItem = document.createElement("span");
moveItem.classList.add("dock__item", "fn__none");
moveItem.style.background = "var(--b3-theme-primary-light)";
moveItem.innerHTML = "<svg></svg>"
moveItem.id = "dockMoveItem"
moveItem.innerHTML = "<svg></svg>";
moveItem.id = "dockMoveItem";
documentSelf.onmousemove = (moveEvent: MouseEvent) => {
if (window.siyuan.config.readonly ||
Math.abs(moveEvent.clientY - event.clientY) < 3 && Math.abs(moveEvent.clientX - event.clientX) < 3) {
Expand Down Expand Up @@ -190,78 +190,78 @@ export class Dock {
const selectRect = selectItem.getBoundingClientRect();
if (selectItem.parentElement.id === "dockBottom") {
if (moveEvent.clientX < selectRect.right && moveEvent.clientX > selectRect.right - 40) {
const lastFirstElement = selectItem.nextElementSibling.firstElementChild
const lastFirstElement = selectItem.nextElementSibling.firstElementChild;
if (lastFirstElement && lastFirstElement.isSameNode(item)) {
moveItem.classList.add("fn__none")
moveItem.classList.add("fn__none");
} else {
moveItem.classList.remove("fn__none")
lastFirstElement.before(moveItem)
moveItem.classList.remove("fn__none");
lastFirstElement.before(moveItem);
}
}
} else {
if (moveEvent.clientY < selectRect.bottom && moveEvent.clientY > selectRect.bottom - 40) {
const lastFirstElement = selectItem.nextElementSibling.firstElementChild
const lastFirstElement = selectItem.nextElementSibling.firstElementChild;
if (lastFirstElement && lastFirstElement.isSameNode(item)) {
moveItem.classList.add("fn__none")
moveItem.classList.add("fn__none");
} else {
moveItem.classList.remove("fn__none")
lastFirstElement.before(moveItem)
moveItem.classList.remove("fn__none");
lastFirstElement.before(moveItem);
}
}
}
} else if (selectItem.classList.contains("dock__item--pin")) {
if (item.nextElementSibling?.isSameNode(selectItem)) {
moveItem.classList.add("fn__none")
moveItem.classList.add("fn__none");
} else {
moveItem.classList.remove("fn__none")
moveItem.classList.remove("fn__none");
selectItem.before(moveItem);
}
} else if (selectItem.classList.contains("dock__item")) {
const selectRect = selectItem.getBoundingClientRect();
if (selectItem.parentElement.parentElement.id === "dockBottom") {
if (selectRect.left + selectRect.width / 2 > moveEvent.clientX) {
if (item.nextElementSibling?.isSameNode(selectItem)) {
moveItem.classList.add("fn__none")
moveItem.classList.add("fn__none");
} else {
moveItem.classList.remove("fn__none")
moveItem.classList.remove("fn__none");
selectItem.before(moveItem);
}
} else {
if (item.previousElementSibling?.isSameNode(selectItem)) {
moveItem.classList.add("fn__none")
moveItem.classList.add("fn__none");
} else {
moveItem.classList.remove("fn__none")
moveItem.classList.remove("fn__none");
selectItem.after(moveItem);
}
}
} else {
if (selectRect.top + selectRect.height / 2 > moveEvent.clientY) {
if (item.nextElementSibling?.isSameNode(selectItem)) {
moveItem.classList.add("fn__none")
moveItem.classList.add("fn__none");
} else {
moveItem.classList.remove("fn__none")
moveItem.classList.remove("fn__none");
selectItem.before(moveItem);
}
} else {
if (item.previousElementSibling?.isSameNode(selectItem)) {
moveItem.classList.add("fn__none")
moveItem.classList.add("fn__none");
} else {
moveItem.classList.remove("fn__none")
moveItem.classList.remove("fn__none");
selectItem.after(moveItem);
}
}
}
} else if (selectItem.childElementCount === 0) {
moveItem.classList.remove("fn__none")
selectItem.append(moveItem)
moveItem.classList.remove("fn__none");
selectItem.append(moveItem);
} else if (selectItem.childElementCount === 1 && selectItem.firstElementChild.id === "dockMoveItem") {
moveItem.classList.remove("fn__none");
} else if (selectItem.childElementCount === 1 && selectItem.firstElementChild.classList.contains("dock__item--pin")) {
moveItem.classList.remove("fn__none")
moveItem.classList.remove("fn__none");
selectItem.insertAdjacentElement("afterbegin", moveItem);
} else if (selectItem.childElementCount === 2 &&
selectItem.firstElementChild.id === "dockMoveItem" && selectItem.lastElementChild.classList.contains("dock__item--pin")) {
moveItem.classList.remove("fn__none")
moveItem.classList.remove("fn__none");
}
return;
}
Expand All @@ -287,7 +287,7 @@ export class Dock {
item.style.opacity = "";
item.classList.add("b3-tooltips");
if (!moveItem.classList.contains("fn__none")) {
let dock
let dock;
if (moveItem.parentElement.parentElement.id === "dockBottom") {
dock = window.siyuan.layout.bottomDock;
} else if (moveItem.parentElement.parentElement.id === "dockLeft") {
Expand Down
1 change: 0 additions & 1 deletion app/src/menus/dock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {MenuItem} from "./Menu";
import {saveLayout} from "../layout/util";

const moveMenuItem = (label: string, target: Element) => {
return new MenuItem({
Expand Down
2 changes: 1 addition & 1 deletion app/src/protyle/wysiwyg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2400,7 +2400,7 @@ export class WYSIWYG {
const imgElement = hasTopClosestByClassName(event.target, "img");
if (!event.shiftKey && !ctrlIsPressed && imgElement) {
imgElement.classList.add("img--select");
const nextSibling = hasNextSibling(imgElement)
const nextSibling = hasNextSibling(imgElement);
if (nextSibling) {
if (nextSibling.textContent.startsWith(Constants.ZWSP)) {
range.setStart(nextSibling, 1);
Expand Down

0 comments on commit 8f8c56d

Please sign in to comment.