Skip to content

Commit

Permalink
fix(Path View): 🐛 Work for CM6
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Nov 23, 2021
1 parent 56967f4 commit bc4c2c2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 36 deletions.
35 changes: 18 additions & 17 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50084,7 +50084,7 @@ class BCPlugin extends obsidian.Plugin {
return getSubInDirs(closed, "up");
}
async drawTrail() {
var _a, _b;
var _a, _b, _c;
const { settings } = this;
const { showBCs, hideTrailField, noPathMessage, respectReadableLineLength, showTrail, showGrid, showPrevNext, } = settings;
debugGroupStart(settings, "debugMode", "Draw Trail");
Expand All @@ -50106,17 +50106,17 @@ class BCPlugin extends obsidian.Plugin {
return;
}
let view;
switch (mode) {
case "source":
view = activeMDView.contentEl.querySelector("div.markdown-source-view");
break;
case "preview":
view = activeMDView.contentEl.querySelector("div.markdown-preview-view[tabindex='-1']");
break;
case "live":
view = activeMDView.contentEl.querySelector("div.markdown-source-view.is-live-preview");
break;
let livePreview = false;
if (mode === "preview") {
view = activeMDView.previewMode.containerEl.querySelector("div.markdown-preview-view");
}
else {
view = activeMDView.contentEl.querySelector("div.markdown-source-view");
if (view.hasClass("is-live-preview")) {
livePreview = true;
}
}
console.log({ view, livePreview });
(_b = activeMDView.containerEl
.querySelectorAll(".BC-trail")) === null || _b === void 0 ? void 0 : _b.forEach((trail) => trail.remove());
const closedUp = this.getLimitedTrailSub();
Expand Down Expand Up @@ -50156,13 +50156,14 @@ class BCPlugin extends obsidian.Plugin {
if (mode === "preview") {
view.querySelector("div.markdown-preview-sizer").before(trailDiv);
}
else if (mode === "live") {
const editorDiv = view.querySelector("div.cm-editor");
editorDiv.before(trailDiv);
}
else {
const editorDiv = view.querySelector("div.CodeMirror-sizer");
editorDiv.before(trailDiv);
const cmEditor = view.querySelector("div.cm-editor");
const cmSizer = view.querySelector("div.CodeMirror-sizer");
if (cmEditor)
(_c = cmEditor.firstChild) === null || _c === void 0 ? void 0 : _c.before(trailDiv);
if (cmSizer)
cmSizer.before(trailDiv);
// view.querySelector("div.cm-editor")?.firstChild?.before(trailDiv);
}
trailDiv.empty();
if (noItems) {
Expand Down
36 changes: 17 additions & 19 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1037,22 +1037,20 @@ export default class BCPlugin extends Plugin {
}

let view: HTMLElement;
switch (mode) {
case "source":
view = activeMDView.contentEl.querySelector("div.markdown-source-view");
break;
case "preview":
view = activeMDView.contentEl.querySelector(
"div.markdown-preview-view[tabindex='-1']"
);
break;
case "live":
view = activeMDView.contentEl.querySelector(
"div.markdown-source-view.is-live-preview"
);
break;
let livePreview: boolean = false;
if (mode === "preview") {
view = activeMDView.previewMode.containerEl.querySelector(
"div.markdown-preview-view"
);
} else {
view = activeMDView.contentEl.querySelector("div.markdown-source-view");
if (view.hasClass("is-live-preview")) {
livePreview = true;
}
}

console.log({ view, livePreview });

activeMDView.containerEl
.querySelectorAll(".BC-trail")
?.forEach((trail) => trail.remove());
Expand Down Expand Up @@ -1113,12 +1111,12 @@ export default class BCPlugin extends Plugin {

if (mode === "preview") {
view.querySelector("div.markdown-preview-sizer").before(trailDiv);
} else if (mode === "live") {
const editorDiv = view.querySelector("div.cm-editor");
editorDiv.before(trailDiv);
} else {
const editorDiv = view.querySelector("div.CodeMirror-sizer");
editorDiv.before(trailDiv);
const cmEditor = view.querySelector("div.cm-editor");
const cmSizer = view.querySelector("div.CodeMirror-sizer");
if (cmEditor) cmEditor.firstChild?.before(trailDiv);
if (cmSizer) cmSizer.before(trailDiv);
// view.querySelector("div.cm-editor")?.firstChild?.before(trailDiv);
}

trailDiv.empty();
Expand Down

0 comments on commit bc4c2c2

Please sign in to comment.