Skip to content

Commit

Permalink
更新版本为 v0.0.9
Browse files Browse the repository at this point in the history
优化拖拽宽度计算,兼容部分主题
  • Loading branch information
Misuzu2027 committed Oct 14, 2024
1 parent f90c842 commit 466d4e4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "syplugin-dual-doc-list",
"author": "Misuzu2027",
"url": "https://github.com/Misuzu2027/syplugin-dual-doc-list",
"version": "0.0.8",
"version": "0.0.9",
"minAppVersion": "3.0.12",
"backends": [
"all"
Expand Down
10 changes: 1 addition & 9 deletions src/components/doc-list/doc-list.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import { createDoc, getBlockByID, getDocInfo } from "@/utils/api";
import { SiyuanConstants } from "@/models/siyuan-constant";
import {
clearSyFileTreeItemFocus,
convertNumberToSordMode,
getParentPath,
} from "@/utils/siyuan-util";
Expand Down Expand Up @@ -465,15 +466,6 @@
});
}
function clearSyFileTreeItemFocus() {
document
.querySelector("div.file-tree.sy__file")
.querySelectorAll("li.b3-list-item--focus")
.forEach((liItem) => {
liItem.classList.remove("b3-list-item--focus");
});
}
async function openBlockTab(
blockId: string,
tabPosition: "right" | "bottom",
Expand Down
6 changes: 4 additions & 2 deletions src/service/doc-list/DocListManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SettingConfig } from "@/models/setting-model";
import { SettingService } from "@/service/setting/SettingService";
import { findParentElementWithAttribute, getAttributeRecursively } from "@/utils/html-util";
import Instance from "@/utils/Instance";
import { isElementHidden } from "@/utils/siyuan-util";
import { clearSyFileTreeItemFocus, isElementHidden } from "@/utils/siyuan-util";

const EmbedDualDocListElementAttrName = "data-misuzu2027-embed-dualDocList";

Expand Down Expand Up @@ -278,6 +278,7 @@ function getDragElement(): HTMLElement {
if (!fileTreeDocElement || !docListElement) {
return;
}
clearSyFileTreeItemFocus();
startX = e.clientX;
// 获取当前 flex-item 的初始宽度
startWidth = docListElement.offsetWidth;
Expand Down Expand Up @@ -317,7 +318,8 @@ function getDragElement(): HTMLElement {
if (newWidth > containerWidth - 1) {
return;
}
let anotherWidth = containerWidth - newWidth;
let anotherWidth = fileTreeDocElement.offsetWidth;

let newFlexGrow = newWidth / anotherWidth
if (deltaX > 0 && newFlexGrow < startFlexGrow) {
//return
Expand Down
10 changes: 10 additions & 0 deletions src/utils/siyuan-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,13 @@ export function getParentPath(path: string): string {
return parentPath;
}



export function clearSyFileTreeItemFocus() {
document
.querySelector("div.file-tree.sy__file")
.querySelectorAll("li.b3-list-item--focus")
.forEach((liItem) => {
liItem.classList.remove("b3-list-item--focus");
});
}

0 comments on commit 466d4e4

Please sign in to comment.