Skip to content

Commit

Permalink
fix(Path View): 🐛 Can't get max-width in source mode (fix #163)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Nov 24, 2021
1 parent 77a99f8 commit efa2652
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
7 changes: 6 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50214,7 +50214,12 @@ class BCPlugin extends obsidian.Plugin {
debugGroupEnd(settings, "debugMode");
return;
}
const max_width = getComputedStyle(document.querySelector(".markdown-preview-view.is-readable-line-width .markdown-preview-sizer")).getPropertyValue("max-width");
const elForMaxWidth = mode === "preview"
? ".markdown-preview-view.is-readable-line-width .markdown-preview-sizer"
: "";
const max_width = elForMaxWidth !== ""
? getComputedStyle(document.querySelector(elForMaxWidth)).getPropertyValue("max-width")
: null;
const trailDiv = createDiv({
cls: `BC-trail ${respectReadableLineLength
? "is-readable-line-width markdown-preview-sizer markdown-preview-section"
Expand Down
16 changes: 11 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1218,11 +1218,17 @@ export default class BCPlugin extends Plugin {
return;
}

const max_width = getComputedStyle(
document.querySelector(
".markdown-preview-view.is-readable-line-width .markdown-preview-sizer"
)
).getPropertyValue("max-width");
const elForMaxWidth =
mode === "preview"
? ".markdown-preview-view.is-readable-line-width .markdown-preview-sizer"
: "";

const max_width =
elForMaxWidth !== ""
? getComputedStyle(
document.querySelector(elForMaxWidth)
).getPropertyValue("max-width")
: null;

const trailDiv = createDiv({
cls: `BC-trail ${
Expand Down

0 comments on commit efa2652

Please sign in to comment.