Merge branch 'master' into feature/25-search-filters
This commit is contained in:
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -6,7 +6,7 @@ on:
|
|||||||
- "*"
|
- "*"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
PLUGIN_NAME: scambier.obsidian-omnisearch
|
PLUGIN_NAME: omnisearch
|
||||||
DIST_FOLDER: ./dist
|
DIST_FOLDER: ./dist
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|||||||
@@ -20,10 +20,9 @@ Under the hood, it uses the excellent [MiniSearch](https://github.com/lucaong/mi
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Omnisearch is not yet available on the official community plugins repository. You can either:
|
[Omnisearch is available on the official Community Plugins repository](https://obsidian.md/plugins?search=omnisearch#).
|
||||||
|
|
||||||
- Install it through [BRAT](https://github.com/TfTHacker/obsidian42-brat)
|
You can also install it through [BRAT](https://github.com/TfTHacker/obsidian42-brat) for the future beta releases.
|
||||||
- Or download the `scambier.obsidian-omnisearch-x.y.z.zip` file from the [releases page](https://github.com/scambier/obsidian-omnisearch/releases) and unzip it in your `.obsidian/plugins` folder. You'll have to update it manually, though.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -64,4 +63,4 @@ For example, if you'd like the usual yellow highlight on search matches, you can
|
|||||||
|
|
||||||
## LICENSE
|
## LICENSE
|
||||||
|
|
||||||
Omnisearch is licensed under [GPL-3](https://tldrlegal.com/license/gnu-general-public-license-v3-(gpl-3)).
|
Omnisearch is licensed under [GPL-3](https://tldrlegal.com/license/gnu-general-public-license-v3-(gpl-3)).
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "scambier.obsidian-omnisearch",
|
"id": "omnisearch",
|
||||||
"name": "Omnisearch",
|
"name": "Omnisearch",
|
||||||
"version": "0.2.5",
|
"version": "1.0.1",
|
||||||
"minAppVersion": "0.14.2",
|
"minAppVersion": "0.14.2",
|
||||||
"description": "A search engine that just works",
|
"description": "A search engine that just works",
|
||||||
"author": "Simon Cambier",
|
"author": "Simon Cambier",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "scambier.obsidian-search",
|
"name": "scambier.obsidian-search",
|
||||||
"version": "0.2.5",
|
"version": "1.0.1",
|
||||||
"description": "A search engine for Obsidian",
|
"description": "A search engine for Obsidian",
|
||||||
"main": "dist/main.js",
|
"main": "dist/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ let selectedIndex = 0
|
|||||||
let note: ResultNote | null = null
|
let note: ResultNote | null = null
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
searchQuery = lastSearch
|
if (lastSearch && !searchQuery) {
|
||||||
|
searchQuery = lastSearch
|
||||||
|
}
|
||||||
eventBus.disable("vault")
|
eventBus.disable("vault")
|
||||||
|
|
||||||
eventBus.on("infile", "enter", openSelection)
|
eventBus.on("infile", "enter", openSelection)
|
||||||
@@ -61,7 +63,7 @@ $: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Group together close
|
* Group together close matches to reduce the number of results
|
||||||
*/
|
*/
|
||||||
function getGroups(matches: SearchMatch[]): SearchMatch[][] {
|
function getGroups(matches: SearchMatch[]): SearchMatch[][] {
|
||||||
const groups: SearchMatch[][] = []
|
const groups: SearchMatch[][] = []
|
||||||
|
|||||||
29
src/main.ts
29
src/main.ts
@@ -1,4 +1,4 @@
|
|||||||
import { MarkdownView, Plugin, TFile } from 'obsidian'
|
import { Notice, Plugin, TFile } from 'obsidian'
|
||||||
import {
|
import {
|
||||||
addToIndex,
|
addToIndex,
|
||||||
initGlobalSearchIndex,
|
initGlobalSearchIndex,
|
||||||
@@ -9,6 +9,8 @@ import { OmnisearchInFileModal, OmnisearchVaultModal } from './modals'
|
|||||||
|
|
||||||
export default class OmnisearchPlugin extends Plugin {
|
export default class OmnisearchPlugin extends Plugin {
|
||||||
async onload(): Promise<void> {
|
async onload(): Promise<void> {
|
||||||
|
warningOldVersion()
|
||||||
|
|
||||||
// Commands to display Omnisearch modals
|
// Commands to display Omnisearch modals
|
||||||
this.addCommand({
|
this.addCommand({
|
||||||
id: 'show-modal',
|
id: 'show-modal',
|
||||||
@@ -21,16 +23,8 @@ export default class OmnisearchPlugin extends Plugin {
|
|||||||
this.addCommand({
|
this.addCommand({
|
||||||
id: 'show-modal-infile',
|
id: 'show-modal-infile',
|
||||||
name: 'In-file search',
|
name: 'In-file search',
|
||||||
checkCallback: (checking: boolean) => {
|
editorCallback: (_editor, view) => {
|
||||||
// Can only be shown when a note is active
|
new OmnisearchInFileModal(app, view.file).open()
|
||||||
const view = app.workspace.getActiveViewOfType(MarkdownView)
|
|
||||||
if (view) {
|
|
||||||
if (!checking) {
|
|
||||||
new OmnisearchInFileModal(app, view.file).open()
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -65,3 +59,16 @@ export default class OmnisearchPlugin extends Plugin {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function warningOldVersion(): void {
|
||||||
|
const plugins = ((app as any).plugins?.plugins ?? {}) as Record<string, any>
|
||||||
|
if (plugins['scambier.omnisearch']) {
|
||||||
|
new Notice(
|
||||||
|
`OMNISEARCH
|
||||||
|
It looks like you have 2 versions of Omnisearch installed.
|
||||||
|
Please uninstall the old one (up to 0.2.5) and keep the new one (1.0.0+)
|
||||||
|
(Click to dismiss)`,
|
||||||
|
0,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,37 +17,27 @@ abstract class OmnisearchModal extends Modal {
|
|||||||
this.modalEl.tabIndex = -1
|
this.modalEl.tabIndex = -1
|
||||||
|
|
||||||
// Setup events that can be listened through the event bus
|
// Setup events that can be listened through the event bus
|
||||||
this.modalEl.onkeydown = ev => {
|
this.scope.register([], 'ArrowDown', () => {
|
||||||
switch (ev.key) {
|
eventBus.emit('arrow-down')
|
||||||
case 'ArrowDown':
|
})
|
||||||
ev.preventDefault()
|
this.scope.register([], 'ArrowUp', () => {
|
||||||
eventBus.emit('arrow-down')
|
eventBus.emit('arrow-up')
|
||||||
break
|
})
|
||||||
case 'ArrowUp':
|
this.scope.register(['Ctrl'], 'Enter', () => {
|
||||||
ev.preventDefault()
|
eventBus.emit('ctrl-enter') // Open in new pane
|
||||||
eventBus.emit('arrow-up')
|
})
|
||||||
break
|
this.scope.register(['Meta'], 'Enter', () => {
|
||||||
case 'Enter':
|
eventBus.emit('ctrl-enter') // Open in new pane (but on Mac)
|
||||||
ev.preventDefault()
|
})
|
||||||
if (ev.ctrlKey || ev.metaKey) {
|
this.scope.register(['Alt'], 'Enter', () => {
|
||||||
// Open in a new pane
|
eventBus.emit('alt-enter') // Open the InFile modal
|
||||||
eventBus.emit('ctrl-enter')
|
})
|
||||||
}
|
this.scope.register(['Shift'], 'Enter', () => {
|
||||||
else if (ev.shiftKey) {
|
eventBus.emit('shift-enter') // Create a new note
|
||||||
// Create a new note
|
})
|
||||||
eventBus.emit('shift-enter')
|
this.scope.register([], 'Enter', () => {
|
||||||
}
|
eventBus.emit('enter') // Open in current pane
|
||||||
else if (ev.altKey) {
|
})
|
||||||
// Expand in-note results
|
|
||||||
eventBus.emit('alt-enter')
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Open in current pane
|
|
||||||
eventBus.emit('enter')
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,5 +13,7 @@
|
|||||||
"0.2.2": "0.14.2",
|
"0.2.2": "0.14.2",
|
||||||
"0.2.3": "0.14.2",
|
"0.2.3": "0.14.2",
|
||||||
"0.2.4": "0.14.2",
|
"0.2.4": "0.14.2",
|
||||||
"0.2.5": "0.14.2"
|
"0.2.5": "0.14.2",
|
||||||
|
"1.0.0": "0.14.2",
|
||||||
|
"1.0.1": "0.14.2"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user