Skip to content

Commit

Permalink
Merge branch 'release/1.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
doitian committed Oct 13, 2022
2 parents ad9b35e + 79dc0c6 commit 599c110
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
31 changes: 25 additions & 6 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ function defaultSetting(
return value;
}

// Finds the ancestor which can be resized horizontally.
function findResizeEl(el: HTMLElement): HTMLElement {
// Since v0.16.0, the leaf is wrapped inside .workspace-tabs
const parent = el.parentElement;
if (parent !== null && parent.hasClass("workspace-tab-container")) {
const grandParent = parent.parentElement;
if (grandParent !== null && grandParent.hasClass("workspace-tabs")) {
return grandParent;
}
}

return el;
}

export default class MinWidthPlugin extends Plugin {
settings: MinWidthPluginSettings;
styleTag: HTMLStyleElement;
Expand Down Expand Up @@ -66,17 +80,22 @@ export default class MinWidthPlugin extends Plugin {
}

this.removeClassesFrom(leafEl.doc.body);
leafEl.addClass(CLASS_ACTIVE);

const resizeEl = findResizeEl(leafEl);
resizeEl.addClass(CLASS_ACTIVE);

// bubble up data-type
const dataType = leaf.view.containerEl.getAttribute("data-type");
leafEl.setAttr(DATA_VIEW_TYPE, dataType);
resizeEl.setAttr(DATA_VIEW_TYPE, dataType);

// add active class and data-type to current horizontal split container
const leafParentEl = leafEl.parentElement;
if (leafParentEl !== null && leafParentEl.hasClass("mod-horizontal")) {
leafParentEl.addClass(CLASS_ACTIVE);
leafParentEl.setAttr(DATA_VIEW_TYPE, dataType);
const resizeParentEl = resizeEl.parentElement;
if (
resizeParentEl !== null &&
resizeParentEl.hasClass("mod-horizontal")
) {
resizeParentEl.addClass(CLASS_ACTIVE);
resizeParentEl.setAttr(DATA_VIEW_TYPE, dataType);
}
}

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-min-width",
"name": "Min Width",
"version": "1.0.3",
"version": "1.0.4",
"minAppVersion": "0.15.0",
"description": "Set the Minimum Width of the Active Pane in Obsidian",
"author": "doitian",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-min-width",
"version": "1.0.3",
"version": "1.0.4",
"description": "Set the Minimum Width of the Active Pane in Obsidian",
"main": "main.js",
"scripts": {
Expand Down
5 changes: 3 additions & 2 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"1.0.0": "0.15.0",
"1.0.2": "0.15.0",
"1.0.3": "0.15.0"
}
"1.0.3": "0.15.0",
"1.0.4": "0.15.0"
}

0 comments on commit 599c110

Please sign in to comment.