Skip to content

Commit

Permalink
add controls back to native search sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingislost committed Aug 27, 2023
1 parent 22d39a0 commit b7e397f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
4 changes: 2 additions & 2 deletions manifest-beta.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"id": "obsidian-query-control",
"name": "Query Control",
"version": "0.5.3",
"minAppVersion": "0.12.5",
"version": "0.6.0",
"minAppVersion": "1.2.0",
"description": "An experimental Obsidian plugin that adds additional control to queries",
"author": "NothingIsLost",
"authorUrl": "https://github.com/nothingislost",
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": "obsidian-query-control",
"name": "Query Control",
"version": "0.5.3",
"minAppVersion": "0.12.5",
"version": "0.6.0",
"minAppVersion": "1.2.0",
"description": "An experimental Obsidian plugin that adds additional control to queries",
"author": "NothingIsLost",
"authorUrl": "https://github.com/nothingislost",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-query-control",
"version": "0.5.3",
"version": "0.6.0",
"description": "An experimental Obsidian plugin that adds additional control to queries",
"main": "main.js",
"scripts": {
Expand Down
22 changes: 21 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
requireApiVersion,
BacklinksClass,
BacklinkDOMClass,
Setting
} from "obsidian";
import { SearchMarkdownRenderer } from "./search-renderer";
import { DEFAULT_SETTINGS, EmbeddedQueryControlSettings, SettingTab, sortOptions } from "./settings";
Expand Down Expand Up @@ -282,7 +283,7 @@ export default class EmbeddedQueryControlPlugin extends Plugin {
startLoader(old: any) {
return function (...args: any[]) {
try {
// were we called from a backlinks view?
// are we in a backlinks view?
let containerEl = this.el.closest(".backlink-pane");
let backlinksInstance = backlinkDoms.get(containerEl);
if (containerEl && backlinksInstance) {
Expand All @@ -291,6 +292,25 @@ export default class EmbeddedQueryControlPlugin extends Plugin {
}
}

// are we in a native search view?
if (!this.parent?.searchParamsContainerEl?.patched && this.el?.parentElement?.getAttribute("data-type") === "search" ) {
this.parent.searchParamsContainerEl.patched = true;
new Setting(this.parent.searchParamsContainerEl).setName("Render Markdown").setClass("mod-toggle").addToggle(toggle => {
toggle.setValue(plugin.settings.defaultRenderMarkdown);
toggle.onChange(value => {
this.renderMarkdown = value;
const _children = isFifteenPlus ? this.vChildren?._children : this.children;
_children.forEach((child: any) => {
child.renderContentMatches();
});
this.infinityScroll.invalidateAll();
this.childrenEl.toggleClass("cm-preview-code-block", value);
this.childrenEl.toggleClass("is-rendered", value);
});
})
}

// are we in a embedded search view?
if (!this.patched && this.el.parentElement?.hasClass("internal-query") ) {
let _SearchHeaderDOM = plugin.SearchHeaderDOM ? plugin.SearchHeaderDOM : plugin.getSearchHeader();
if (this.el?.closest(".internal-query")) {
Expand Down
4 changes: 4 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@
margin-block-end: 0;
margin-block-start: 0;
}

.cm-preview-code-block.is-rendered .markdown-preview-view {
height: inherit;
}

0 comments on commit b7e397f

Please sign in to comment.