Skip to content

Commit

Permalink
fix placement of rich-foot when in editing mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jparkerweb committed Oct 21, 2024
1 parent 00fec7d commit 591795b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,33 @@ var RichFootPlugin = class extends Plugin {
if (view.getMode() === "preview") {
container = content.querySelector(".markdown-preview-section");
} else if (view.getMode() === "source" || view.getMode() === "live") {
container = content.querySelector(".cm-scroller");
container = content.querySelector(".cm-sizer");
}
if (!container) {
return;
}
this.removeExistingRichFoot(container);
const richFoot = this.createRichFoot(file);
container.appendChild(richFoot);
if (view.getMode() === "source" || view.getMode() === "live") {
container.appendChild(richFoot);
} else {
container.appendChild(richFoot);
}
this.observeContainer(container);
}
removeExistingRichFoot(container) {
var _a;
const existingRichFoot = container.querySelector(".rich-foot");
if (existingRichFoot) {
existingRichFoot.remove();
}
const cmSizer = (_a = container.closest(".cm-editor")) == null ? void 0 : _a.querySelector(".cm-sizer");
if (cmSizer) {
const richFootInSizer = cmSizer.querySelector(".rich-foot");
if (richFootInSizer) {
richFootInSizer.remove();
}
}
}
observeContainer(container) {
if (this.containerObserver) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"id": "rich-foot",
"name": "Rich Foot",
"version": "1.3.2",
"minAppVersion": "1.7.2",
"version": "1.3.3",
"minAppVersion": "1.6.0",
"description": "Adds backlink tags and created/modified dates to the footer of your notes.",
"author": "Justin Parker",
"authorUrl": "https://www.jparkerweb.com",
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"id": "rich-foot",
"name": "Rich Foot",
"version": "1.3.2",
"minAppVersion": "1.7.2",
"version": "1.3.3",
"minAppVersion": "1.6.0",
"description": "Adds backlink tags and created/modified dates to the footer of your notes.",
"author": "Justin Parker",
"authorUrl": "https://www.jparkerweb.com",
Expand Down
16 changes: 14 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class RichFootPlugin extends Plugin {
if (view.getMode() === 'preview') {
container = content.querySelector('.markdown-preview-section');
} else if (view.getMode() === 'source' || view.getMode() === 'live') {
container = content.querySelector('.cm-scroller');
container = content.querySelector('.cm-sizer');
}

if (!container) {
Expand All @@ -80,7 +80,11 @@ class RichFootPlugin extends Plugin {
const richFoot = this.createRichFoot(file);

// Append the Rich Foot to the container
container.appendChild(richFoot);
if (view.getMode() === 'source' || view.getMode() === 'live') {
container.appendChild(richFoot);
} else {
container.appendChild(richFoot);
}

// Set up a mutation observer for this specific container
this.observeContainer(container);
Expand All @@ -91,6 +95,14 @@ class RichFootPlugin extends Plugin {
if (existingRichFoot) {
existingRichFoot.remove();
}
// Also check in .cm-sizer for editing mode
const cmSizer = container.closest('.cm-editor')?.querySelector('.cm-sizer');
if (cmSizer) {
const richFootInSizer = cmSizer.querySelector('.rich-foot');
if (richFootInSizer) {
richFootInSizer.remove();
}
}
}

observeContainer(container) {
Expand Down

0 comments on commit 591795b

Please sign in to comment.