Skip to content

Commit

Permalink
Release v1.10.3: Improved parent selector matching to exclude Rich Fo…
Browse files Browse the repository at this point in the history
…ot when specified selectors are present in the view or its parent elements.
  • Loading branch information
jparkerweb committed Dec 14, 2024
1 parent 9e53aa0 commit 80d9d64
Show file tree
Hide file tree
Showing 14 changed files with 138 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to Rich Foot will be documented in this file.

## [1.10.3] - 2024-12-14
### 🐛 Fixed
- Improved parent selector matching to properly detect and exclude Rich Foot when specified selectors are present in the view or its parent elements

## [1.10.2] - 2024-12-11
### 🐛 Fixed
- Missing `Excluded Folders` section in the settings
Expand Down
4 changes: 4 additions & 0 deletions UPDATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## 🛑 Exclude Me Please


### [1.10.3] - 2024-12-14
#### 🐛 Fixed
- Improved parent selector matching to properly detect and exclude Rich Foot when specified selectors are present in the view or its parent elements

### [1.10.2] - 2024-12-11
#### 🐛 Fixed
- Missing `Excluded Folders` section in the settings
Expand Down
Binary file modified example-vault.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
"css-editor",
"obsidian-custom-frames",
"markdown-attributes",
"obsidian-memos",
"obsidian-kanban"
]
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"showPinIcon": true,
"pinnedImageFolder": "pixel-banner-images",
"showReleaseNotes": true,
"lastVersion": "2.13.0",
"lastVersion": "2.13.1",
"showRefreshIcon": true,
"showViewImageIcon": false,
"hidePixelBannerFields": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ var ImageViewModal = class extends import_obsidian2.Modal {
};

// virtual-module:virtual:release-notes
var releaseNotes = '<h2>\u{1F389} What&#39;s New</h2>\n<h3>v2.13.0</h3>\n<h4>\u2728 Added</h4>\n<ul>\n<li>New <code>view image</code> button icon option to open the banner image in a full-screen modal \xA0<br>(works with plugins like <code>image toolkit</code>, etc.)</li>\n</ul>\n<p><a href="https://raw.githubusercontent.com/jparkerweb/ref/refs/heads/main/equill-labs/pixel-banner/pixel-banner-v2.13.0.jpg"><img src="https://raw.githubusercontent.com/jparkerweb/ref/refs/heads/main/equill-labs/pixel-banner/pixel-banner-v2.13.0.jpg" alt="screenshot"></a></p>\n';
var releaseNotes = '<h2>\u{1F389} What&#39;s New</h2>\n<h3>v2.13.1</h3>\n<h4>\u{1F4E6} Updated</h4>\n<ul>\n<li>Banner width now updates when the window is resized</li>\n<li>Banner width is now compatible with the popular <code>minimal</code> theme</li>\n</ul>\n<h3>v2.13.0</h3>\n<h4>\u2728 Added</h4>\n<ul>\n<li>New <code>view image</code> button icon option to open the banner image in a full-screen modal \xA0<br>(works with plugins like <code>image toolkit</code>, etc.)</li>\n</ul>\n<p><a href="https://raw.githubusercontent.com/jparkerweb/ref/refs/heads/main/equill-labs/pixel-banner/pixel-banner-v2.13.0.jpg"><img src="https://raw.githubusercontent.com/jparkerweb/ref/refs/heads/main/equill-labs/pixel-banner/pixel-banner-v2.13.0.jpg" alt="screenshot"></a></p>\n';

// src/main.js
function getFrontmatterValue(frontmatter, fieldNames) {
Expand Down Expand Up @@ -2084,13 +2084,30 @@ module.exports = class PixelBannerPlugin extends import_obsidian3.Plugin {
if (this.observer) {
this.observer.disconnect();
}
this.app.workspace.iterateAllLeaves((leaf) => {
if (leaf.view instanceof import_obsidian3.MarkdownView) {
const viewContent = leaf.view.contentEl;
if (viewContent._resizeObserver) {
viewContent._resizeObserver.disconnect();
delete viewContent._resizeObserver;
}
}
});
}
applyContentStartPosition(el, contentStartPosition) {
if (!el) {
return;
}
el.style.setProperty("--pixel-banner-content-start", `${contentStartPosition}px`);
}
applyBannerWidth(el) {
if (!el) {
return;
}
const elWidth = el.clientWidth;
const scrollbarWidth = 12;
el.style.setProperty("--pixel-banner-width", `${elWidth - scrollbarWidth}px`);
}
getFolderSpecificSetting(filePath, settingName) {
var _a;
const folderPath = this.getFolderPath(filePath);
Expand Down Expand Up @@ -2178,6 +2195,13 @@ module.exports = class PixelBannerPlugin extends import_obsidian3.Plugin {
}
} else {
container = isReadingView ? viewContent.querySelector(".markdown-preview-sizer:not(.internal-embed .markdown-preview-sizer)") : viewContent.querySelector(".cm-sizer");
if (!viewContent._resizeObserver) {
const debouncedResize = debounce(() => {
this.applyBannerWidth(viewContent);
}, 100);
viewContent._resizeObserver = new ResizeObserver(debouncedResize);
viewContent._resizeObserver.observe(viewContent);
}
}
if (!container) {
return;
Expand Down Expand Up @@ -2301,6 +2325,7 @@ module.exports = class PixelBannerPlugin extends import_obsidian3.Plugin {
const frontmatterContentStart = getFrontmatterValue(frontmatter, this.settings.customContentStartField);
const effectiveContentStart = (_b = frontmatterContentStart != null ? frontmatterContentStart : folderSpecific == null ? void 0 : folderSpecific.contentStartPosition) != null ? _b : this.settings.contentStartPosition;
this.applyContentStartPosition(viewContent, effectiveContentStart);
this.applyBannerWidth(viewContent);
if (!isEmbedded && (inputType === "keyword" || inputType === "url") && this.settings.showPinIcon) {
const refreshIcon = container.querySelector(":scope > .refresh-icon");
if (pinIcon) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "pexels-banner",
"name": "Pixel Banner",
"version": "2.13.0",
"version": "2.13.1",
"minAppVersion": "1.6.0",
"description": "Apply an image from various sources as a banner to your notes.",
"author": "Justin Parker (eQui\\\\ Labs)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
top: 0;
left: 0;
right: 0;
width: var(--pixel-banner-width, 100vw) !important; /* fix banner width with some themes */
max-width: var(--pixel-banner-width, 100vw) !important; /* fix banner width with some themes */
background-size: cover;
background-position: 50% 50%;
overflow: hidden;
Expand All @@ -25,6 +27,11 @@
z-index: -1;
}

/* for embedded notes, do not override the width */
.markdown-embed .pixel-banner-image {
width: inherit !important;
}

/* Apply title color to both reading and editing mode */
.pixel-banner div.inline-title,
.markdown-source-view div.inline-title {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"showDates": true,
"combineLinks": true,
"updateDelay": 3000,
"excludedParentSelectors": [],
"excludedParentSelectors": [
"[data-type=\"thino_view\"]"
],
"frontmatterExclusionField": "",
"lastVersion": "1.10.1"
"lastVersion": "1.10.2"
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ var ReleaseNotesModal = class extends import_obsidian.Modal {
};

// virtual-module:virtual:release-notes
var releaseNotes = '<h2>\u{1F6D1} Exclude Me Please</h2>\n<h3>[1.10.2] - 2024-12-11</h3>\n<h4>\u{1F41B} Fixed</h4>\n<ul>\n<li>Missing <code>Excluded Folders</code> section in the settings</li>\n</ul>\n<h3>[1.10.1] - 2024-12-10</h3>\n<h4>\u{1F41B} Fixed</h4>\n<ul>\n<li>Extra padding on the bottom of the editor in Canvas / Kanban Cards</li>\n</ul>\n<h3>[1.10.0] - 2024-12-08</h3>\n<h4>\u2728 Added</h4>\n<ul>\n<li>Exclusion rule via <code>frontmatter</code> field</li>\n<li>Custom exclusions using specified DOM parent selectors for advanced control</li>\n</ul>\n<p><a href="https://raw.githubusercontent.com/jparkerweb/ref/refs/heads/main/equill-labs/rich-foot/rich-foot-v1.10.0.jpg"><img src="https://raw.githubusercontent.com/jparkerweb/ref/refs/heads/main/equill-labs/rich-foot/rich-foot-v1.10.0.jpg" alt="screenshot"></a></p>\n';
var releaseNotes = '<h2>\u{1F6D1} Exclude Me Please</h2>\n<h3>[1.10.3] - 2024-12-14</h3>\n<h4>\u{1F41B} Fixed</h4>\n<ul>\n<li>Improved parent selector matching to properly detect and exclude Rich Foot when specified selectors are present in the view or its parent elements</li>\n</ul>\n<h3>[1.10.2] - 2024-12-11</h3>\n<h4>\u{1F41B} Fixed</h4>\n<ul>\n<li>Missing <code>Excluded Folders</code> section in the settings</li>\n</ul>\n<h3>[1.10.1] - 2024-12-10</h3>\n<h4>\u{1F41B} Fixed</h4>\n<ul>\n<li>Extra padding on the bottom of the editor in Canvas / Kanban Cards</li>\n</ul>\n<h3>[1.10.0] - 2024-12-08</h3>\n<h4>\u2728 Added</h4>\n<ul>\n<li>Exclusion rule via <code>frontmatter</code> field</li>\n<li>Custom exclusions using specified DOM parent selectors for advanced control</li>\n</ul>\n<p><a href="https://raw.githubusercontent.com/jparkerweb/ref/refs/heads/main/equill-labs/rich-foot/rich-foot-v1.10.0.jpg"><img src="https://raw.githubusercontent.com/jparkerweb/ref/refs/heads/main/equill-labs/rich-foot/rich-foot-v1.10.0.jpg" alt="screenshot"></a></p>\n';

// src/settings.js
var import_obsidian2 = require("obsidian");
Expand Down Expand Up @@ -1217,11 +1217,19 @@ var RichFootPlugin = class extends import_obsidian3.Plugin {
const activeLeaf = this.app.workspace.activeLeaf;
if ((_d = activeLeaf == null ? void 0 : activeLeaf.view) == null ? void 0 : _d.containerEl) {
return (_f = (_e = this.settings) == null ? void 0 : _e.excludedParentSelectors) == null ? void 0 : _f.some((selector) => {
var _a2, _b2;
try {
const matchingElements = document.querySelectorAll(selector);
return Array.from(matchingElements).some(
(el) => el === activeLeaf.view.containerEl || el.contains(activeLeaf.view.containerEl)
);
let element = activeLeaf.view.containerEl;
while (element) {
if ((_a2 = element.matches) == null ? void 0 : _a2.call(element, selector)) {
return true;
}
if ((_b2 = element.querySelector) == null ? void 0 : _b2.call(element, selector)) {
return true;
}
element = element.parentElement;
}
return false;
} catch (e) {
console.error(`Invalid selector in Rich Foot settings: ${selector}`);
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "rich-foot",
"name": "Rich Foot",
"version": "1.10.2",
"version": "1.10.3",
"minAppVersion": "1.5.0",
"description": "Adds backlink tags and created/modified dates to the footer of your notes.",
"author": "Justin Parker (eQui\\\\ Labs)",
Expand Down
65 changes: 63 additions & 2 deletions example-vault/rich-foot-example/.obsidian/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -3248,6 +3248,66 @@
{
"id": "27f7e05636c07604",
"type": "leaf",
"state": {
"type": "empty",
"state": {},
"icon": "lucide-file",
"title": "New tab"
}
},
{
"id": "8fe0e89fd7400747",
"type": "leaf",
"state": {
"type": "empty",
"state": {},
"icon": "lucide-file",
"title": "New tab"
}
},
{
"id": "270a09f1d0e40ed5",
"type": "leaf",
"state": {
"type": "empty",
"state": {},
"icon": "lucide-file",
"title": "New tab"
}
},
{
"id": "bb5fed5c313e1001",
"type": "leaf",
"state": {
"type": "empty",
"state": {},
"icon": "lucide-file",
"title": "New tab"
}
},
{
"id": "15e55b37b64c7a08",
"type": "leaf",
"state": {
"type": "empty",
"state": {},
"icon": "lucide-file",
"title": "New tab"
}
},
{
"id": "f10409eafe229c82",
"type": "leaf",
"state": {
"type": "empty",
"state": {},
"icon": "lucide-file",
"title": "New tab"
}
},
{
"id": "3810900fdf31cef5",
"type": "leaf",
"state": {
"type": "Saved Queries View",
"state": {},
Expand All @@ -3256,7 +3316,7 @@
}
}
],
"currentTab": 315
"currentTab": 321
}
],
"direction": "horizontal",
Expand All @@ -3279,9 +3339,10 @@
},
"active": "bf09cc60e5809e92",
"lastOpenFiles": [
"thino test.md",
"🦶 Rich Foot.md",
"exclude/me too/no rich-feet here either.md",
"exclude/no rich-feet here.md",
"🦶 Rich Foot.md",
"releases/v1.10.0 - 🛑 Exclude Me Please.md",
"2024-12-07.md",
"Untitled Kanban.md",
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": "rich-foot",
"name": "Rich Foot",
"version": "1.10.2",
"version": "1.10.3",
"minAppVersion": "1.5.0",
"description": "Adds backlink tags and created/modified dates to the footer of your notes.",
"author": "Justin Parker (eQui\\\\ Labs)",
Expand Down
19 changes: 13 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,12 +851,19 @@ class RichFootPlugin extends Plugin {
if (activeLeaf?.view?.containerEl) {
return this.settings?.excludedParentSelectors?.some(selector => {
try {
// Check if the container or any of its parents match the selector
const matchingElements = document.querySelectorAll(selector);
return Array.from(matchingElements).some(el =>
el === activeLeaf.view.containerEl ||
el.contains(activeLeaf.view.containerEl)
);
// Check if any parent element matches the selector
let element = activeLeaf.view.containerEl;
while (element) {
if (element.matches?.(selector)) {
return true;
}
// Also check if the current element contains any matching elements
if (element.querySelector?.(selector)) {
return true;
}
element = element.parentElement;
}
return false;
} catch (e) {
console.error(`Invalid selector in Rich Foot settings: ${selector}`);
return false;
Expand Down

0 comments on commit 80d9d64

Please sign in to comment.