Compare commits
12
Commits
ba535966ab
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
921a72b015 | ||
|
|
92a7af6ec5 | ||
|
|
52ada90150 | ||
|
|
d3c7e7ea8e | ||
|
|
99fd363c22 | ||
|
|
dd7d7a367d | ||
|
|
282fd1be13 | ||
|
|
46a5d3d114 | ||
|
|
d821344ade | ||
|
|
960b0260f9 | ||
|
|
d34c06e57a | ||
|
|
a008b15a6a |
No files matched your search
@@ -1,32 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: "[BUG] "
|
||||
labels: ''
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
<!-- PLEASE FILL THIS TEMPLATE -->
|
||||
<!-- If you don't fill it, I'll ask you to fill it before looking at your issue -->
|
||||
|
||||
**Problem description:**
|
||||
|
||||
<!-- Describe your problem in details. -->
|
||||
<!-- If applicable, you can copy-paste the console logs (ctrl+shift+i in Obsidian) -->
|
||||
<!-- and attach screenshots -->
|
||||
|
||||
**Your environment:**
|
||||
|
||||
<!-- Please, if possible and before filing an issue, -->
|
||||
<!-- make sure that you have the latest available version of Omnisearch. -->
|
||||
|
||||
- Omnisearch version:
|
||||
- Obsidian version:
|
||||
- Operating system:
|
||||
- Number of indexed documents in your vault (approx.):
|
||||
|
||||
**Things to try:**
|
||||
|
||||
- Does the problem occur when Omnisearch is the only active community plugin:
|
||||
- Does the problem occur when you _don't_ index PDFs, images, or other non-notes files:
|
||||
- Does the problem occur after a cache reset:
|
||||
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: "[Feature request]"
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
|
||||
|
||||
**Describe the solution you'd like**
|
||||
<!-- A clear and concise description of what you want to happen. -->
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
|
||||
|
||||
**Additional context**
|
||||
<!-- Add any other context or screenshots about the feature request here. -->
|
||||
@@ -6,7 +6,7 @@ on:
|
||||
- "*"
|
||||
|
||||
env:
|
||||
PLUGIN_NAME: omnisearch
|
||||
PLUGIN_NAME: locator
|
||||
DIST_FOLDER: ./dist
|
||||
|
||||
jobs:
|
||||
|
||||
+1
-241
@@ -1,243 +1,3 @@
|
||||
# Omnisearch Changelog
|
||||
# Locator Changelog
|
||||
|
||||
This changelog is not exhaustive.
|
||||
|
||||
## 1.27.x
|
||||
|
||||
- Updated Svelte from v3 to v5
|
||||
- Highlighting improvements
|
||||
|
||||
## 1.26.x
|
||||
|
||||
- Allow `# headings` as display titles in search results
|
||||
- Added an experimental recency boost
|
||||
- Added lazy loading for the vault modal items
|
||||
|
||||
## 1.25.x
|
||||
|
||||
- Added basic support for embed references in Vault Search results
|
||||
- Added support for [Iconize](https://github.com/FlorianWoelki/obsidian-iconize)
|
||||
- Weights are now 1-10 (instead of 1-5)
|
||||
- Small performance improvements
|
||||
|
||||
## 1.24.x
|
||||
|
||||
- Added support for [AI Image Analyzer](https://github.com/Swaggeroo/obsidian-ai-image-analyzer)
|
||||
|
||||
## 1.23.x
|
||||
|
||||
- Updated Chinese tokenizer
|
||||
- Added user-defined boosted fields
|
||||
- No more freezes when loading large caches (hopefully)
|
||||
- Large refactoring to properly clean up several older warnings
|
||||
|
||||
## 1.22.x
|
||||
|
||||
- Improved highlighting
|
||||
|
||||
## 1.21.x
|
||||
|
||||
- Added support for .docx and .xlsx
|
||||
|
||||
## 1.20.x
|
||||
|
||||
- Refactored indexing tokenization process to correctly take diacritics into account
|
||||
- Added highlighting in the note's path
|
||||
- Improved the selection of the chosen excerpt in the results list
|
||||
|
||||
## 1.19.x
|
||||
|
||||
- Various bugfixes and improvements
|
||||
|
||||
## 1.18.x
|
||||
|
||||
- Added a localhost server to use Omnisearch's API from outside Obsidian
|
||||
|
||||
## 1.17.x
|
||||
|
||||
- Added a shortcut to open files without closing Omnisearch
|
||||
- Prefill the search field with selected text
|
||||
- Improved highlighting
|
||||
|
||||
## 1.16.x
|
||||
|
||||
- Various indexing/tokenization improvements
|
||||
|
||||
## 1.15.x
|
||||
|
||||
- Added support of webp images
|
||||
- Configurable fuzziness
|
||||
- Added support for DataLoom plugin files
|
||||
- Unsupported files are now indexed by their path
|
||||
- Unmarked tags are now slightly boosted
|
||||
|
||||
## 1.14.x
|
||||
|
||||
- Added a `path:` option
|
||||
- Bugfixes
|
||||
|
||||
## 1.13.x
|
||||
|
||||
- CamelCaseWords are now indexed as 3 words
|
||||
- Reduced search freezes in some cases
|
||||
|
||||
## 1.12.x
|
||||
|
||||
- You can filter files by their extension
|
||||
- Refreshed UI
|
||||
- New API functions
|
||||
- Fixed some tokenization issues
|
||||
|
||||
## 1.10.x - 1.11.x
|
||||
|
||||
- Added support for Text Extractor; Omnisearch no longer extracts text itself
|
||||
- Added canvas indexing
|
||||
- Improved tags indexing
|
||||
|
||||
## 1.9.x
|
||||
|
||||
- PDFs are no longer indexed on mobile
|
||||
- Performance improvements
|
||||
- Various bugfixes
|
||||
|
||||
## 1.8.x
|
||||
|
||||
- Added OCR for images
|
||||
- OCR and PDF indexing are now restricted to desktop. They either don't work or consume too much resources during indexing of big vaults. Too many headaches.
|
||||
- Notes caching is deactivated on iOS because of crashes: memory usage too high during (de)serializing.
|
||||
- Added an URL scheme for integration with external tools: `obsidian://omnisearch?query=foo bar`
|
||||
|
||||
## 1.7.x
|
||||
|
||||
### New
|
||||
|
||||
- PDF Indexing https://github.com/scambier/obsidian-omnisearch/issues/58
|
||||
|
||||
### Improved
|
||||
|
||||
- Code refactor to better scale and handle PDFs as smoothly as possible
|
||||
|
||||
### Fixed
|
||||
|
||||
- Search history https://github.com/scambier/obsidian-omnisearch/issues/104
|
||||
- Text in search input was not always correctly selected https://github.com/scambier/obsidian-omnisearch/issues/105
|
||||
- Padding issue https://github.com/scambier/obsidian-omnisearch/issues/113
|
||||
|
||||
### Removed
|
||||
|
||||
- Caching data https://github.com/scambier/obsidian-omnisearch/issues/92#issuecomment-1287647725
|
||||
|
||||
|
||||
## 1.6.x
|
||||
|
||||
### New
|
||||
|
||||
- Omnisearch can now index other plaintext files ~~and PDFs~~ https://github.com/scambier/obsidian-omnisearch/issues/58
|
||||
- Search history, navigable with <code>alt+up/down</code> https://github.com/scambier/obsidian-omnisearch/issues/90
|
||||
- Added a setting to toggle the visibility of the note excerpt in results https://github.com/scambier/obsidian-omnisearch/issues/70
|
||||
|
||||
### Improved
|
||||
|
||||
- You can now create a new note in a new pane https://github.com/scambier/obsidian-omnisearch/issues/87
|
||||
- Added a setting to show a "create note" button https://github.com/scambier/obsidian-omnisearch/issues/96
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed layout issues https://github.com/scambier/obsidian-omnisearch/issues/97
|
||||
|
||||
## 1.5.x
|
||||
|
||||
### New
|
||||
|
||||
* Added a toggleable sidebar button to open Omnisearch: https://github.com/scambier/obsidian-omnisearch/issues/60
|
||||
* Added a cache-clearing mechanism in case of corruption: https://github.com/scambier/obsidian-omnisearch/issues/83
|
||||
|
||||
### Improved
|
||||
|
||||
* Notes created by Omnisearch now honour the default note location https://github.com/scambier/obsidian-omnisearch/pull/81
|
||||
* Ctrl+click now opens the note in a new pane https://github.com/scambier/obsidian-omnisearch/issues/61
|
||||
* Improved highlighting https://github.com/scambier/obsidian-omnisearch/issues/85
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed some edge cases when opening an already open/pinned note https://github.com/scambier/obsidian-omnisearch/issues/51 https://github.com/scambier/obsidian-omnisearch/issues/80
|
||||
* Fixed nested tags searching https://github.com/scambier/obsidian-omnisearch/issues/79
|
||||
* Fixed a silent crash when clicking on In-File search results https://github.com/scambier/obsidian-omnisearch/issues/84
|
||||
|
||||
## 1.4.x
|
||||
|
||||
### New
|
||||
|
||||
- Opt-in support for Vim navigation keys: https://github.com/scambier/obsidian-omnisearch/issues/26
|
||||
- Opt-in display of "short form" links: https://github.com/scambier/obsidian-omnisearch/issues/59
|
||||
- Opt-in search index serialization, for faster loading times: https://github.com/scambier/obsidian-omnisearch/pull/64 by @mnaoumov
|
||||
- Opt-out: diacritics can now be ignored
|
||||
- Added support for `#tag` searches: https://github.com/scambier/obsidian-omnisearch/issues/48
|
||||
- Added a basic public API for integration with other plugins: https://github.com/scambier/obsidian-omnisearch/issues/22 https://github.com/scambier/obsidian-omnisearch/issues/69
|
||||
- Use `alt+enter` to inject a link to the currently selected search result item: https://github.com/scambier/obsidian-omnisearch/issues/32
|
||||
|
||||
|
||||
### Improved
|
||||
|
||||
- You can now switch between "Vault" and "In-File" modals with `tab`
|
||||
- Search index updates are now done only when Omnisearch is invoked: https://github.com/scambier/obsidian-omnisearch/issues/57
|
||||
- New files are now created empty: https://github.com/scambier/obsidian-omnisearch/issues/77
|
||||
|
||||
### Fixed
|
||||
|
||||
- Opening a pinned note would open it a second time: https://github.com/scambier/obsidian-omnisearch/issues/51
|
||||
- Fixed an issue that would index "non-existing notes" multiple times: https://github.com/scambier/obsidian-omnisearch/issues/68
|
||||
- Fixed a visual bug for Obsidian 0.15.3: https://github.com/scambier/obsidian-omnisearch/issues/76
|
||||
- Fixed the diacritics normalization of the note's title: https://github.com/scambier/obsidian-omnisearch/issues/72
|
||||
|
||||
## 1.3.x
|
||||
|
||||
### New
|
||||
|
||||
* Chinese support by @aidenlx in https://github.com/scambier/obsidian-omnisearch/pull/37
|
||||
* You need to install https://github.com/aidenlx/cm-chs-patch to enable this feature
|
||||
* Settings page https://github.com/scambier/obsidian-omnisearch/issues/41
|
||||
* Do not show indexing Notice by default by @chrisgrieser in https://github.com/scambier/obsidian-omnisearch/pull/46
|
||||
* Include notes that don't exist https://github.com/scambier/obsidian-omnisearch/issues/14
|
||||
|
||||
### Improved
|
||||
|
||||
* Better accessibility https://github.com/scambier/obsidian-omnisearch/issues/50
|
||||
* Note aliases are now scored as high as the filename in search results https://github.com/scambier/obsidian-omnisearch/issues/34
|
||||
* By default, reindexing is now done when the app is out of focus, and not after each save https://github.com/scambier/obsidian-omnisearch/issues/57
|
||||
* On mobile, indexing is only done at startup
|
||||
|
||||
### Fixed
|
||||
|
||||
* Showing an error when a note can't be created https://github.com/scambier/obsidian-omnisearch/issues/52
|
||||
|
||||
|
||||
## 1.2.x
|
||||
|
||||
### New
|
||||
* #42 Files that are present in Obsidian's "Excluded Files" list are downranked by a factor of 3 (_desktop only_)
|
||||
|
||||
## 1.1.1
|
||||
|
||||
### Fixes
|
||||
* Fixed a crash when no results were returned
|
||||
|
||||
## 1.1.0
|
||||
|
||||
### New
|
||||
* #25 Search filters: expressions in quotes and exclusions
|
||||
* Added support for beta versions with [BRAT](https://github.com/TfTHacker/obsidian42-brat)
|
||||
|
||||
This works as a "post-search" filter and does not allow for partial words searches (see #35)
|
||||
|
||||
### Fixes
|
||||
* #39 Fixed key events not correctly prevented in the search input
|
||||
|
||||
**Full Changelog**: https://github.com/scambier/obsidian-omnisearch/compare/1.0.1...1.1.0
|
||||
|
||||
## 1.0.1
|
||||
|
||||
## 1.0.0
|
||||
|
||||
* First non-beta release
|
||||
* Includes Vault search and In-File search
|
||||
@@ -1,38 +1,30 @@
|
||||
# Omnisearch for Obsidian
|
||||
> [!CAUTION]
|
||||
> This project is a heavy work-in-progress, there are bugs, and features may change or disappear.
|
||||
|
||||
# Locator for Obsidian
|
||||
|
||||
[](https://github.com/sponsors/scambier)
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
> 🏆 Winner of the _[2023 Gems of the Year](https://obsidian.md/blog/2023-goty-winners/)_ in the "Existing plugin" category 🏆
|
||||
|
||||
|
||||
---
|
||||
|
||||
**Omnisearch** is a search engine that "_just works_".
|
||||
**Locator** is an Obsidian plugin that lets you locate your files in a few keystrokes. It is an experimental fork of Omnisearch.
|
||||
|
||||
It always instantly shows you the most relevant results, thanks to its smart weighting algorithm.
|
||||
|
||||
Under the hood, it uses the excellent [MiniSearch](https://github.com/lucaong/minisearch) library. This free plugin is totally unrelated to the omnisearch.ai paid product.
|
||||
Under the hood, it uses the excellent [MiniSearch](https://github.com/lucaong/minisearch) library.
|
||||
|
||||
|
||||

|
||||
|
||||
## Documentation
|
||||
|
||||
https://publish.obsidian.md/omnisearch/Index
|
||||
|
||||
## Installation
|
||||
|
||||
- Omnisearch is available on [the official Community Plugins repository](https://obsidian.md/plugins?search=Omnisearch).
|
||||
- Beta releases can be installed through [BRAT](https://github.com/TfTHacker/obsidian42-brat). **Be advised that those
|
||||
versions can be buggy and break things.**
|
||||
- Locator can be installed through [BRAT](https://github.com/TfTHacker/obsidian42-brat).
|
||||
|
||||
You can check the [CHANGELOG](./CHANGELOG.md) for more information on the different versions.
|
||||
|
||||
## Features
|
||||
|
||||
> Omnisearch's first goal is to _locate_ files instantly. You can see it as a _Quick Switcher_ on steroids.
|
||||
> Locator's first goal is to _locate_ files instantly. You can see it as a _Quick Switcher_ on steroids.
|
||||
|
||||
- Find your **📝notes, 📄Office documents, 📄PDFs, and 🖼images** faster than ever
|
||||
- Images, documents, and PDF indexing is available
|
||||
@@ -45,31 +37,25 @@ You can check the [CHANGELOG](./CHANGELOG.md) for more information on the differ
|
||||
- Workflow similar to the "Quick Switcher" core plugin
|
||||
- Opt-in local HTTP server to query Omnisearch from outside of Obsidian
|
||||
- Resistance to typos
|
||||
- Switch between Vault and In-file search to quickly skim multiple results in a single note
|
||||
- Supports `"expressions in quotes"` and `-exclusions`
|
||||
- Filters file types with `.jpg` or `.md`
|
||||
- Directly Insert a `[[link]]` from the search results
|
||||
- Supports Vim navigation keys
|
||||
|
||||
**Note:** support of Chinese depends
|
||||
on [this additional plugin](https://github.com/aidenlx/cm-chs-patch) (also you may need to clear search cache data to apply new Chinese index). Please read its documentation for more
|
||||
information.
|
||||
|
||||
## Projects that use Omnisearch
|
||||
## Issues & Feature Requests
|
||||
|
||||
_Submit a PR to add your own project!_
|
||||
Locator is a personal hobby project, tailored for my own needs. It is publicly available because you may find it useful too, but I'm not interested in your issues or pull requests.
|
||||
|
||||
- [Omnisearch Companion](https://github.com/ALegendsTale/omnisearch-companion), an extension for your browser ([Firefox](https://addons.mozilla.org/en-US/firefox/addon/omnisearch-companion/), [Chrome](https://chromewebstore.google.com/detail/omnisearch-companion/kcjcnnlpfbilodfnnkpioijobpjhokkd))
|
||||
- [Actions for Obsidian](https://actions.work/actions-for-obsidian)
|
||||
- [Userscripts](https://publish.obsidian.md/omnisearch/Inject+Omnisearch+results+into+your+search+engine) to inject Omnisearch into your favorite web search engine
|
||||
If you'd like to participate in a similar project (thank you!), I'll be glad to review your pull requests for [**Omnisearch**](https://github.com/scambier/obsidian-omnisearch)
|
||||
|
||||
Thank you for your understanding.
|
||||
|
||||
## LICENSE
|
||||
|
||||
Omnisearch is licensed under [GPL-3](https://tldrlegal.com/license/gnu-general-public-license-v3-(gpl-3)).
|
||||
Locator is licensed under [GPL-3](https://tldrlegal.com/license/gnu-general-public-license-v3-(gpl-3)).
|
||||
|
||||
## Thanks
|
||||
|
||||
To all people who donate through [Ko-Fi](https://ko-fi.com/scambier)
|
||||
or [Github Sponsors](https://github.com/sponsors/scambier) ❤
|
||||
|
||||

|
||||
+22
-22
@@ -1,7 +1,7 @@
|
||||
.omnisearch-modal {
|
||||
.locator-modal {
|
||||
}
|
||||
|
||||
.omnisearch-result {
|
||||
.locator-result {
|
||||
white-space: normal;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@@ -9,7 +9,7 @@
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.omnisearch-result__title-container {
|
||||
.locator-result__title-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
@@ -17,17 +17,17 @@
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.omnisearch-result__title {
|
||||
.locator-result__title {
|
||||
white-space: pre-wrap;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.omnisearch-result__title > span {
|
||||
.locator-result__title > span {
|
||||
}
|
||||
|
||||
.omnisearch-result__folder-path {
|
||||
.locator-result__folder-path {
|
||||
font-size: 0.75rem;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
@@ -35,17 +35,17 @@
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.omnisearch-result__extension {
|
||||
.locator-result__extension {
|
||||
font-size: 0.7rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.omnisearch-result__counter {
|
||||
.locator-result__counter {
|
||||
font-size: 0.7rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.omnisearch-result__body {
|
||||
.locator-result__body {
|
||||
white-space: normal;
|
||||
font-size: small;
|
||||
word-wrap: normal;
|
||||
@@ -59,20 +59,20 @@
|
||||
margin-inline-start: 0.5em;
|
||||
}
|
||||
|
||||
.omnisearch-result__embed {
|
||||
.locator-result__embed {
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
|
||||
.omnisearch-result__image-container {
|
||||
.locator-result__image-container {
|
||||
flex-basis: 20%;
|
||||
text-align: end;
|
||||
}
|
||||
|
||||
.omnisearch-highlight {
|
||||
.locator-highlight {
|
||||
}
|
||||
|
||||
.omnisearch-default-highlight {
|
||||
.locator-default-highlight {
|
||||
text-decoration: underline;
|
||||
text-decoration-color: var(--text-highlight-bg);
|
||||
text-decoration-thickness: 3px;
|
||||
@@ -80,14 +80,14 @@
|
||||
text-decoration-skip-ink: none;
|
||||
}
|
||||
|
||||
.omnisearch-input-container {
|
||||
.locator-input-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: row;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.omnisearch-result__icon {
|
||||
.locator-result__icon {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
width: 16px;
|
||||
@@ -95,41 +95,41 @@
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.omnisearch-result__icon svg {
|
||||
.locator-result__icon svg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.omnisearch-result__icon--emoji {
|
||||
.locator-result__icon--emoji {
|
||||
font-size: 16px;
|
||||
vertical-align: middle;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 600px) {
|
||||
.omnisearch-input-container {
|
||||
.locator-input-container {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.omnisearch-input-container__buttons {
|
||||
.locator-input-container__buttons {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
padding: 0 1em 0 1em;
|
||||
gap: 1em;
|
||||
}
|
||||
.omnisearch-input-container__buttons > button {
|
||||
.locator-input-container__buttons > button {
|
||||
flex-grow: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (min-width: 600px) {
|
||||
.omnisearch-input-container__buttons {
|
||||
.locator-input-container__buttons {
|
||||
margin-inline-end: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
.omnisearch-input-field {
|
||||
.locator-input-field {
|
||||
position: relative;
|
||||
flex-grow: 1;
|
||||
}
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "scambier.obsidian-locator",
|
||||
"version": "1.27.1",
|
||||
"version": "0.1.0",
|
||||
"description": "Locate your notes in a few keystrokes",
|
||||
"main": "dist/main.js",
|
||||
"scripts": {
|
||||
@@ -22,6 +22,7 @@
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^16.18.126",
|
||||
"@types/pako": "^2.0.3",
|
||||
"@types/stopword": "^2.0.3",
|
||||
"babel-jest": "^27.5.1",
|
||||
"builtin-modules": "^3.3.0",
|
||||
"esbuild": "0.17.19",
|
||||
@@ -48,7 +49,7 @@
|
||||
"minisearch": "7.1.0",
|
||||
"pure-md5": "^0.1.14",
|
||||
"search-query-parser": "^1.6.0",
|
||||
"svelte-multiselect": "github:janosh/svelte-multiselect"
|
||||
"stopword": "^3.1.5"
|
||||
},
|
||||
"pnpm": {
|
||||
"overrides": {
|
||||
|
||||
Generated
+16
-73
@@ -32,9 +32,9 @@ importers:
|
||||
search-query-parser:
|
||||
specifier: ^1.6.0
|
||||
version: 1.6.0
|
||||
svelte-multiselect:
|
||||
specifier: github:janosh/svelte-multiselect
|
||||
version: https://codeload.github.com/janosh/svelte-multiselect/tar.gz/91f22d0cafdf931607288d18c5268badd358d83b
|
||||
stopword:
|
||||
specifier: ^3.1.5
|
||||
version: 3.1.5
|
||||
devDependencies:
|
||||
'@babel/preset-env':
|
||||
specifier: ^7.26.9
|
||||
@@ -60,6 +60,9 @@ importers:
|
||||
'@types/pako':
|
||||
specifier: ^2.0.3
|
||||
version: 2.0.3
|
||||
'@types/stopword':
|
||||
specifier: ^2.0.3
|
||||
version: 2.0.3
|
||||
babel-jest:
|
||||
specifier: ^27.5.1
|
||||
version: 27.5.1(@babel/core@7.26.10)
|
||||
@@ -1140,6 +1143,9 @@ packages:
|
||||
'@types/stack-utils@2.0.3':
|
||||
resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==}
|
||||
|
||||
'@types/stopword@2.0.3':
|
||||
resolution: {integrity: sha512-hioMj0lOvISM+EDevf7ijG8EMbU+J3pj4SstCyfQC1t39uPYpAe7beSfBdU6c1d9jeECTQQtR3UJWtVoUO8Weg==}
|
||||
|
||||
'@types/tern@0.23.9':
|
||||
resolution: {integrity: sha512-ypzHFE/wBzh+BlH6rrBgS5I/Z7RD21pGhZ2rltb/+ZrVM1awdZwjx7hE5XfuYgHWk9uvV5HLZN3SloevCAp3Bw==}
|
||||
|
||||
@@ -1424,9 +1430,6 @@ packages:
|
||||
resolution: {integrity: sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==}
|
||||
engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'}
|
||||
|
||||
code-red@1.0.4:
|
||||
resolution: {integrity: sha512-7qJWqItLA8/VPVlKJlFXU+NBlo/qyfs39aJcuMT/2ere32ZqvF5OSxgdM5xOfJJ7O429gg2HM47y8v9P+9wrNw==}
|
||||
|
||||
collect-v8-coverage@1.0.2:
|
||||
resolution: {integrity: sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==}
|
||||
|
||||
@@ -1471,10 +1474,6 @@ packages:
|
||||
css-select@5.1.0:
|
||||
resolution: {integrity: sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==}
|
||||
|
||||
css-tree@2.3.1:
|
||||
resolution: {integrity: sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==}
|
||||
engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0}
|
||||
|
||||
css-what@6.1.0:
|
||||
resolution: {integrity: sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==}
|
||||
engines: {node: '>= 6'}
|
||||
@@ -1836,9 +1835,6 @@ packages:
|
||||
estree-walker@2.0.2:
|
||||
resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
|
||||
|
||||
estree-walker@3.0.3:
|
||||
resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==}
|
||||
|
||||
esutils@2.0.3:
|
||||
resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@@ -2376,9 +2372,6 @@ packages:
|
||||
resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
mdn-data@2.0.30:
|
||||
resolution: {integrity: sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==}
|
||||
|
||||
merge-stream@2.0.0:
|
||||
resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==}
|
||||
|
||||
@@ -2542,9 +2535,6 @@ packages:
|
||||
resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
periscopic@3.1.0:
|
||||
resolution: {integrity: sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==}
|
||||
|
||||
picocolors@1.1.1:
|
||||
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
|
||||
|
||||
@@ -2802,6 +2792,9 @@ packages:
|
||||
resolution: {integrity: sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
stopword@3.1.5:
|
||||
resolution: {integrity: sha512-OgLYGVFCNa430WOrj9tYZhQge5yg6vd6JsKredveAqEhdLVQkfrpnQIGjx0L9lLqzL4Kq4J8yNTcfQR/MpBwhg==}
|
||||
|
||||
stream-to-array@2.3.0:
|
||||
resolution: {integrity: sha512-UsZtOYEn4tWU2RGLOXr/o/xjRBftZRlG3dEWoaHr8j4GuypJ3isitGbVyjQKAuMu+xbiop8q224TjiZWc4XTZA==}
|
||||
|
||||
@@ -2887,10 +2880,6 @@ packages:
|
||||
jest: '>= 27'
|
||||
svelte: '>= 3'
|
||||
|
||||
svelte-multiselect@https://codeload.github.com/janosh/svelte-multiselect/tar.gz/91f22d0cafdf931607288d18c5268badd358d83b:
|
||||
resolution: {tarball: https://codeload.github.com/janosh/svelte-multiselect/tar.gz/91f22d0cafdf931607288d18c5268badd358d83b}
|
||||
version: 11.0.0-rc.1
|
||||
|
||||
svelte-preprocess@6.0.3:
|
||||
resolution: {integrity: sha512-PLG2k05qHdhmRG7zR/dyo5qKvakhm8IJ+hD2eFRQmMLHp7X3eJnjeupUtvuRpbNiF31RjVw45W+abDwHEmP5OA==}
|
||||
engines: {node: '>= 18.0.0'}
|
||||
@@ -2928,10 +2917,6 @@ packages:
|
||||
typescript:
|
||||
optional: true
|
||||
|
||||
svelte@4.2.12:
|
||||
resolution: {integrity: sha512-d8+wsh5TfPwqVzbm4/HCXC783/KPHV60NvwitJnyTA5lWn1elhXMNWhXGCJ7PwPa8qFUnyJNIyuIRt2mT0WMug==}
|
||||
engines: {node: '>=16'}
|
||||
|
||||
svelte@5.23.2:
|
||||
resolution: {integrity: sha512-PHP1o0aYJNMatiZ+0nq1W/Z1W1/l5Z94B9nhMIo7gsuTBbxC454g4O5SQMjQpZBUZi5ANYUrXJOE4gPzcN/VQw==}
|
||||
engines: {node: '>=18'}
|
||||
@@ -4375,6 +4360,8 @@ snapshots:
|
||||
|
||||
'@types/stack-utils@2.0.3': {}
|
||||
|
||||
'@types/stopword@2.0.3': {}
|
||||
|
||||
'@types/tern@0.23.9':
|
||||
dependencies:
|
||||
'@types/estree': 1.0.6
|
||||
@@ -4714,14 +4701,6 @@ snapshots:
|
||||
|
||||
co@4.6.0: {}
|
||||
|
||||
code-red@1.0.4:
|
||||
dependencies:
|
||||
'@jridgewell/sourcemap-codec': 1.5.0
|
||||
'@types/estree': 1.0.6
|
||||
acorn: 8.14.1
|
||||
estree-walker: 3.0.3
|
||||
periscopic: 3.1.0
|
||||
|
||||
collect-v8-coverage@1.0.2: {}
|
||||
|
||||
color-convert@2.0.1:
|
||||
@@ -4764,11 +4743,6 @@ snapshots:
|
||||
domutils: 3.2.2
|
||||
nth-check: 2.1.1
|
||||
|
||||
css-tree@2.3.1:
|
||||
dependencies:
|
||||
mdn-data: 2.0.30
|
||||
source-map-js: 1.2.1
|
||||
|
||||
css-what@6.1.0: {}
|
||||
|
||||
css.escape@1.5.1: {}
|
||||
@@ -5099,10 +5073,6 @@ snapshots:
|
||||
|
||||
estree-walker@2.0.2: {}
|
||||
|
||||
estree-walker@3.0.3:
|
||||
dependencies:
|
||||
'@types/estree': 1.0.6
|
||||
|
||||
esutils@2.0.3: {}
|
||||
|
||||
execa@5.1.1:
|
||||
@@ -5885,8 +5855,6 @@ snapshots:
|
||||
|
||||
math-intrinsics@1.1.0: {}
|
||||
|
||||
mdn-data@2.0.30: {}
|
||||
|
||||
merge-stream@2.0.0: {}
|
||||
|
||||
merge2@1.4.1: {}
|
||||
@@ -6034,12 +6002,6 @@ snapshots:
|
||||
|
||||
path-type@4.0.0: {}
|
||||
|
||||
periscopic@3.1.0:
|
||||
dependencies:
|
||||
'@types/estree': 1.0.6
|
||||
estree-walker: 3.0.3
|
||||
is-reference: 3.0.3
|
||||
|
||||
picocolors@1.1.1: {}
|
||||
|
||||
picomatch@2.3.1: {}
|
||||
@@ -6283,6 +6245,8 @@ snapshots:
|
||||
dependencies:
|
||||
escape-string-regexp: 2.0.0
|
||||
|
||||
stopword@3.1.5: {}
|
||||
|
||||
stream-to-array@2.3.0:
|
||||
dependencies:
|
||||
any-promise: 1.3.0
|
||||
@@ -6364,10 +6328,6 @@ snapshots:
|
||||
jest: 27.5.1
|
||||
svelte: 5.23.2
|
||||
|
||||
svelte-multiselect@https://codeload.github.com/janosh/svelte-multiselect/tar.gz/91f22d0cafdf931607288d18c5268badd358d83b:
|
||||
dependencies:
|
||||
svelte: 4.2.12
|
||||
|
||||
svelte-preprocess@6.0.3(@babel/core@7.26.10)(postcss@8.5.3)(sass@1.86.0)(svelte@5.23.2)(typescript@5.8.2):
|
||||
dependencies:
|
||||
svelte: 5.23.2
|
||||
@@ -6377,23 +6337,6 @@ snapshots:
|
||||
sass: 1.86.0
|
||||
typescript: 5.8.2
|
||||
|
||||
svelte@4.2.12:
|
||||
dependencies:
|
||||
'@ampproject/remapping': 2.3.0
|
||||
'@jridgewell/sourcemap-codec': 1.5.0
|
||||
'@jridgewell/trace-mapping': 0.3.25
|
||||
'@types/estree': 1.0.6
|
||||
acorn: 8.14.1
|
||||
aria-query: 5.3.2
|
||||
axobject-query: 4.1.0
|
||||
code-red: 1.0.4
|
||||
css-tree: 2.3.1
|
||||
estree-walker: 3.0.3
|
||||
is-reference: 3.0.3
|
||||
locate-character: 3.0.0
|
||||
magic-string: 0.30.17
|
||||
periscopic: 3.1.0
|
||||
|
||||
svelte@5.23.2:
|
||||
dependencies:
|
||||
'@ampproject/remapping': 2.3.0
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { cancelable, CancelablePromise } from 'cancelable-promise'
|
||||
import { debounce } from 'lodash-es'
|
||||
import { MarkdownView, Notice, Platform, TFile } from 'obsidian'
|
||||
import { MarkdownView, Notice } from 'obsidian'
|
||||
import { onDestroy, onMount, tick } from 'svelte'
|
||||
import {
|
||||
type LocatorVaultModal,
|
||||
@@ -21,8 +21,7 @@
|
||||
getAltKeyLabel,
|
||||
getCtrlKeyLabel,
|
||||
getExtension,
|
||||
isFilePDF,
|
||||
loopIndex,
|
||||
loopIndex
|
||||
} from '../tools/utils'
|
||||
import InputSearch from './InputSearch.svelte'
|
||||
import LazyLoader from './lazy-loader/LazyLoader.svelte'
|
||||
@@ -293,7 +292,7 @@
|
||||
placeholder="Locator - Vault">
|
||||
<div class="omnisearch-input-container__buttons">
|
||||
{#if plugin.settings.showCreateButton}
|
||||
<button on:click={onClickCreateNote}>Create note</button>
|
||||
<button onclick={onClickCreateNote}>Create note</button>
|
||||
{/if}
|
||||
</div>
|
||||
</InputSearch>
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
<script lang="ts">
|
||||
import type { ResultNote } from '../globals'
|
||||
import ResultItemContainer from './ResultItemContainer.svelte'
|
||||
import type LocatorPlugin from '../main'
|
||||
|
||||
export let plugin: LocatorPlugin
|
||||
export let offset: number
|
||||
export let note: ResultNote
|
||||
export let index = 0
|
||||
export let selected = false
|
||||
|
||||
$: cleanedContent = plugin.textProcessor.makeExcerpt(note?.content ?? '', offset)
|
||||
</script>
|
||||
|
||||
<ResultItemContainer
|
||||
id="{index.toString()}"
|
||||
on:auxclick
|
||||
on:click
|
||||
on:mousemove
|
||||
selected="{selected}">
|
||||
<div class="omnisearch-result__body">
|
||||
{@html plugin.textProcessor.highlightText(cleanedContent, note.matches)}
|
||||
</div>
|
||||
</ResultItemContainer>
|
||||
@@ -1,8 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { setIcon, TFile } from 'obsidian'
|
||||
import { showExcerpt } from 'src/settings/utils'
|
||||
import { onMount } from 'svelte'
|
||||
import type { ResultNote } from '../globals'
|
||||
import type LocatorPlugin from '../main'
|
||||
import { getDefaultIconSVG } from '../tools/icon-utils'
|
||||
import {
|
||||
getExtension,
|
||||
isFileCanvas,
|
||||
@@ -12,15 +14,6 @@
|
||||
pathWithoutFilename,
|
||||
} from '../tools/utils'
|
||||
import ResultItemContainer from './ResultItemContainer.svelte'
|
||||
// Import icon utility functions
|
||||
import { showExcerpt } from 'src/settings/utils'
|
||||
import {
|
||||
getDefaultIconSVG,
|
||||
getIconNameForPath,
|
||||
initializeIconPacks,
|
||||
loadIconData,
|
||||
loadIconSVG,
|
||||
} from '../tools/icon-utils'
|
||||
|
||||
export let selected = false
|
||||
export let note: ResultNote
|
||||
@@ -29,19 +22,12 @@
|
||||
let imagePath: string | null = null
|
||||
let title = ''
|
||||
let notePath = ''
|
||||
let iconData = {}
|
||||
let folderIconSVG: string | null = null
|
||||
let fileIconSVG: string | null = null
|
||||
let prefixToIconPack: { [prefix: string]: string } = {}
|
||||
let iconsPath: string
|
||||
const folderIconSVG = getDefaultIconSVG('folder')
|
||||
const fileIconSVG = getDefaultIconSVG(note.path)
|
||||
let iconDataLoaded = false // Flag to indicate iconData is loaded
|
||||
|
||||
// Initialize icon data and icon packs once when the component mounts
|
||||
onMount(async () => {
|
||||
iconData = await loadIconData(plugin)
|
||||
const iconPacks = await initializeIconPacks(plugin)
|
||||
prefixToIconPack = iconPacks.prefixToIconPack
|
||||
iconsPath = iconPacks.iconsPath
|
||||
iconDataLoaded = true // Set the flag after iconData is loaded
|
||||
})
|
||||
|
||||
@@ -51,40 +37,9 @@
|
||||
// Update title and notePath before loading icons
|
||||
title = note.displayTitle || note.basename
|
||||
notePath = pathWithoutFilename(note.path)
|
||||
await loadIcons()
|
||||
})()
|
||||
}
|
||||
|
||||
async function loadIcons() {
|
||||
// Load folder icon
|
||||
const folderIconName = getIconNameForPath(notePath, iconData)
|
||||
if (folderIconName) {
|
||||
folderIconSVG = await loadIconSVG(
|
||||
folderIconName,
|
||||
plugin,
|
||||
iconsPath,
|
||||
prefixToIconPack
|
||||
)
|
||||
} else {
|
||||
// Fallback to default folder icon
|
||||
folderIconSVG = getDefaultIconSVG('folder', plugin)
|
||||
}
|
||||
|
||||
// Load file icon
|
||||
const fileIconName = getIconNameForPath(note.path, iconData)
|
||||
if (fileIconName) {
|
||||
fileIconSVG = await loadIconSVG(
|
||||
fileIconName,
|
||||
plugin,
|
||||
iconsPath,
|
||||
prefixToIconPack
|
||||
)
|
||||
} else {
|
||||
// Fallback to default icons based on file type
|
||||
fileIconSVG = getDefaultIconSVG(note.path, plugin)
|
||||
}
|
||||
}
|
||||
|
||||
// Svelte action to render SVG content with dynamic updates
|
||||
function renderSVG(node: HTMLElement, svgContent: string) {
|
||||
node.innerHTML = svgContent
|
||||
@@ -163,10 +118,8 @@
|
||||
title="The document above is embedded in this note" />
|
||||
{:else}
|
||||
<!-- File Icon -->
|
||||
{#if fileIconSVG}
|
||||
<span class="omnisearch-result__icon" use:renderSVG={fileIconSVG} />
|
||||
{/if}
|
||||
{/if}
|
||||
<span>
|
||||
{@html plugin.textProcessor.highlightText(title, matchesTitle)}
|
||||
</span>
|
||||
@@ -191,9 +144,8 @@
|
||||
{#if notePath}
|
||||
<div class="omnisearch-result__folder-path">
|
||||
<!-- Folder Icon -->
|
||||
{#if folderIconSVG}
|
||||
<span class="omnisearch-result__icon" use:renderSVG={folderIconSVG} />
|
||||
{/if}
|
||||
|
||||
<span>
|
||||
{@html plugin.textProcessor.highlightText(notePath, matchesNotePath)}
|
||||
</span>
|
||||
|
||||
@@ -164,10 +164,8 @@ export class LocatorVaultModal extends LocatorModal {
|
||||
?.editor.getSelection()
|
||||
|
||||
plugin.searchHistory.getHistory().then(history => {
|
||||
// Previously searched query (if enabled in settings)
|
||||
const previous = plugin.settings.showPreviousQueryResults
|
||||
? history[0]
|
||||
: null
|
||||
// Previously searched query
|
||||
const previous = history[0]
|
||||
|
||||
// Instantiate and display the Svelte component
|
||||
const cmp = mount(ModalVault, {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import { Notice } from 'obsidian'
|
||||
import type LocatorPlugin from './main'
|
||||
|
||||
export class Database extends Dexie {
|
||||
public static readonly dbVersion = 10
|
||||
public static readonly dbVersion = 1
|
||||
searchHistory!: Dexie.Table<{ id?: number; query: string }, number>
|
||||
minisearch!: Dexie.Table<
|
||||
{
|
||||
|
||||
@@ -274,6 +274,7 @@ export default class LocatorPlugin extends Plugin {
|
||||
}
|
||||
|
||||
console.timeEnd('Indexing total time')
|
||||
console.log(`Indexed ${diff.toAdd.length} files, removed ${diff.toRemove.length} files`)
|
||||
if (diff.toAdd.length >= 1000 && isCacheEnabled()) {
|
||||
new Notice(`Your files have been indexed.`)
|
||||
}
|
||||
|
||||
@@ -190,15 +190,16 @@ export class SearchEngine {
|
||||
}
|
||||
const mtime = storedFields?.mtime as number
|
||||
const now = new Date().valueOf()
|
||||
const daysElapsed = (now - mtime) / (24 * 3600)
|
||||
|
||||
const daysElapsed = (now - mtime) / (24 * 3600_000)
|
||||
// Documents boost
|
||||
const cutoff = {
|
||||
[RecencyCutoff.Day]: -3,
|
||||
[RecencyCutoff.Week]: -0.3,
|
||||
[RecencyCutoff.Month]: -0.1,
|
||||
} as const
|
||||
return 1 + Math.exp(cutoff[settings.recencyBoost] * daysElapsed)
|
||||
return (
|
||||
1 + Math.exp(cutoff[settings.recencyBoost] * (daysElapsed / 1000))
|
||||
)
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
+9
-10
@@ -1,7 +1,8 @@
|
||||
import type { QueryCombination } from 'minisearch'
|
||||
import { removeStopwords } from 'stopword'
|
||||
import { BRACKETS_AND_SPACE, chsRegex, SPACE_OR_PUNCTUATION } from '../globals'
|
||||
import type LocatorPlugin from '../main'
|
||||
import { splitCamelCase, splitHyphens } from '../tools/utils'
|
||||
import { getStopWords, splitCamelCase, splitHyphens } from '../tools/utils'
|
||||
|
||||
const markdownLinkExtractor = require('markdown-link-extractor')
|
||||
|
||||
@@ -16,9 +17,10 @@ export class Tokenizer {
|
||||
*/
|
||||
public tokenizeForIndexing(text: string): string[] {
|
||||
try {
|
||||
const words = this.tokenizeWords(text)
|
||||
let words = this.tokenizeIntoWords(text)
|
||||
words = removeStopwords(words, getStopWords())
|
||||
let tokens = this.tokenizeIntoTokens(text, { skipChs: true })
|
||||
|
||||
let tokens = this.tokenizeTokens(text, { skipChs: true })
|
||||
tokens = [
|
||||
...tokens.flatMap(token => [
|
||||
token,
|
||||
@@ -28,9 +30,6 @@ export class Tokenizer {
|
||||
...words,
|
||||
]
|
||||
|
||||
// Remove duplicates
|
||||
tokens = [...new Set(tokens)]
|
||||
|
||||
return tokens
|
||||
} catch (e) {
|
||||
console.error('Error tokenizing text, skipping document', e)
|
||||
@@ -49,7 +48,7 @@ export class Tokenizer {
|
||||
const urls: string[] = markdownLinkExtractor(text)
|
||||
text = urls.reduce((acc, url) => acc.replace(url, ''), text)
|
||||
|
||||
const tokens = [...this.tokenizeTokens(text), ...urls].filter(Boolean)
|
||||
const tokens = [...this.tokenizeIntoTokens(text), ...urls].filter(Boolean)
|
||||
|
||||
return {
|
||||
combineWith: 'OR',
|
||||
@@ -57,7 +56,7 @@ export class Tokenizer {
|
||||
{ combineWith: 'AND', queries: tokens },
|
||||
{
|
||||
combineWith: 'AND',
|
||||
queries: this.tokenizeWords(text).filter(Boolean),
|
||||
queries: this.tokenizeIntoWords(text).filter(Boolean),
|
||||
},
|
||||
{ combineWith: 'AND', queries: tokens.flatMap(splitHyphens) },
|
||||
{ combineWith: 'AND', queries: tokens.flatMap(splitCamelCase) },
|
||||
@@ -65,13 +64,13 @@ export class Tokenizer {
|
||||
}
|
||||
}
|
||||
|
||||
private tokenizeWords(text: string, { skipChs = false } = {}): string[] {
|
||||
private tokenizeIntoWords(text: string, { skipChs = false } = {}): string[] {
|
||||
const tokens = text.split(BRACKETS_AND_SPACE)
|
||||
if (skipChs) return tokens
|
||||
return this.tokenizeChsWord(tokens)
|
||||
}
|
||||
|
||||
private tokenizeTokens(text: string, { skipChs = false } = {}): string[] {
|
||||
private tokenizeIntoTokens(text: string, { skipChs = false } = {}): string[] {
|
||||
const tokens = text.split(SPACE_OR_PUNCTUATION)
|
||||
if (skipChs) return tokens
|
||||
return this.tokenizeChsWord(tokens)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import { App, Plugin, PluginSettingTab, Setting } from 'obsidian'
|
||||
import { RecencyCutoff } from '../globals'
|
||||
import type LocatorPlugin from '../main'
|
||||
import { enableVerboseLogging } from '../tools/utils'
|
||||
import { injectSettingsBehavior } from './settings-behavior'
|
||||
import { injectSettingsDanger } from './settings-danger'
|
||||
import { injectSettingsHttp } from './settings-http'
|
||||
@@ -64,7 +63,6 @@ export class SettingsTab extends PluginSettingTab {
|
||||
.addToggle(toggle =>
|
||||
toggle.setValue(settings.verboseLogging).onChange(async v => {
|
||||
settings.verboseLogging = v
|
||||
enableVerboseLogging(v)
|
||||
await saveSettings(this.plugin)
|
||||
})
|
||||
)
|
||||
@@ -97,7 +95,6 @@ export function getDefaultSettings(app: App): LocatorSettings {
|
||||
maxEmbeds: 5,
|
||||
renderLineReturnInExcerpts: true,
|
||||
showCreateButton: false,
|
||||
showPreviousQueryResults: true,
|
||||
simpleSearch: false,
|
||||
fuzziness: '1',
|
||||
|
||||
@@ -138,6 +135,5 @@ export async function loadSettings(plugin: Plugin): Promise<LocatorSettings> {
|
||||
await plugin.loadData()
|
||||
)
|
||||
showExcerpt.set(settings.showExcerpt)
|
||||
enableVerboseLogging(settings.verboseLogging)
|
||||
return settings
|
||||
}
|
||||
@@ -27,17 +27,6 @@ export function injectSettingsBehavior(
|
||||
})
|
||||
)
|
||||
|
||||
// Show previous query results
|
||||
new Setting(containerEl)
|
||||
.setName('Show previous query results')
|
||||
.setDesc('Re-executes the previous query when opening Locator.')
|
||||
.addToggle(toggle =>
|
||||
toggle.setValue(settings.showPreviousQueryResults).onChange(async v => {
|
||||
settings.showPreviousQueryResults = v
|
||||
await saveSettings(plugin)
|
||||
})
|
||||
)
|
||||
|
||||
// Respect excluded files
|
||||
new Setting(containerEl)
|
||||
.setName('Respect Obsidian\'s "Excluded Files"')
|
||||
|
||||
@@ -68,8 +68,6 @@ export interface LocatorSettings extends WeightingSettings {
|
||||
renderLineReturnInExcerpts: boolean
|
||||
/** Enable a "create note" button in the Vault Search modal */
|
||||
showCreateButton: boolean
|
||||
/** Re-execute the last query when opening Locator */
|
||||
showPreviousQueryResults: boolean
|
||||
/** Key for the welcome message when Obsidian is updated. A message is only shown once. */
|
||||
welcomeMessage: string
|
||||
/** If a query returns 0 result, try again with more relax conditions */
|
||||
|
||||
+8
-177
@@ -1,183 +1,13 @@
|
||||
import { getIcon, normalizePath } from 'obsidian'
|
||||
import type LocatorPlugin from '../main'
|
||||
import {
|
||||
isFileImage,
|
||||
isFilePDF,
|
||||
isFileCanvas,
|
||||
isFileExcalidraw,
|
||||
warnVerbose,
|
||||
} from './utils'
|
||||
import { escapeHTML } from './text-processing'
|
||||
import { getIcon } from 'obsidian'
|
||||
import { isFileCanvas, isFileExcalidraw, isFileImage, isFilePDF } from './utils'
|
||||
|
||||
export interface IconPacks {
|
||||
prefixToIconPack: { [prefix: string]: string }
|
||||
iconsPath: string
|
||||
}
|
||||
|
||||
export async function loadIconData(plugin: LocatorPlugin): Promise<any> {
|
||||
const app = plugin.app
|
||||
|
||||
// Check if the 'obsidian-icon-folder' plugin is installed and enabled
|
||||
// Casting 'app' to 'any' here to avoid TypeScript errors since 'plugins' might not be defined on 'App'
|
||||
const iconFolderPlugin = (app as any).plugins.getPlugin(
|
||||
'obsidian-icon-folder'
|
||||
)
|
||||
if (!iconFolderPlugin) {
|
||||
return {}
|
||||
}
|
||||
|
||||
const dataJsonPath = `${app.vault.configDir}/plugins/obsidian-icon-folder/data.json`
|
||||
try {
|
||||
const dataJsonContent = await app.vault.adapter.read(dataJsonPath)
|
||||
const rawIconData = JSON.parse(dataJsonContent)
|
||||
// Normalize keys
|
||||
const iconData: any = {}
|
||||
for (const key in rawIconData) {
|
||||
const normalizedKey = normalizePath(key)
|
||||
iconData[normalizedKey] = rawIconData[key]
|
||||
}
|
||||
return iconData
|
||||
} catch (e) {
|
||||
warnVerbose('Failed to read data.json:', e)
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
export async function initializeIconPacks(
|
||||
plugin: LocatorPlugin
|
||||
): Promise<IconPacks> {
|
||||
// Add 'Li' prefix for Lucide icons
|
||||
const prefixToIconPack: { [prefix: string]: string } = { Li: 'lucide-icons' }
|
||||
let iconsPath = 'icons'
|
||||
|
||||
const app = plugin.app
|
||||
|
||||
// Access the obsidian-icon-folder plugin
|
||||
const iconFolderPlugin = (app as any).plugins.getPlugin(
|
||||
'obsidian-icon-folder'
|
||||
)
|
||||
|
||||
if (iconFolderPlugin) {
|
||||
// Get the icons path from the plugin's settings
|
||||
const iconFolderSettings = iconFolderPlugin.settings
|
||||
iconsPath = iconFolderSettings?.iconPacksPath || 'icons'
|
||||
const iconsDir = `${app.vault.configDir}/${iconsPath}`
|
||||
|
||||
try {
|
||||
const iconPackDirs = await app.vault.adapter.list(iconsDir)
|
||||
if (iconPackDirs.folders && iconPackDirs.folders.length > 0) {
|
||||
for (const folderPath of iconPackDirs.folders) {
|
||||
const pathParts = folderPath.split('/')
|
||||
const iconPackName = pathParts[pathParts.length - 1]
|
||||
const prefix = createIconPackPrefix(iconPackName)
|
||||
prefixToIconPack[prefix] = iconPackName
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
warnVerbose('Failed to list icon packs:', e)
|
||||
}
|
||||
}
|
||||
|
||||
return { prefixToIconPack, iconsPath }
|
||||
}
|
||||
|
||||
function createIconPackPrefix(iconPackName: string): string {
|
||||
if (iconPackName.includes('-')) {
|
||||
const splitted = iconPackName.split('-')
|
||||
let result = splitted[0].charAt(0).toUpperCase()
|
||||
for (let i = 1; i < splitted.length; i++) {
|
||||
result += splitted[i].charAt(0).toLowerCase()
|
||||
}
|
||||
return result
|
||||
}
|
||||
return (
|
||||
iconPackName.charAt(0).toUpperCase() + iconPackName.charAt(1).toLowerCase()
|
||||
)
|
||||
}
|
||||
|
||||
export function getIconNameForPath(path: string, iconData: any): string | null {
|
||||
const normalizedPath = normalizePath(path)
|
||||
const iconEntry = iconData[normalizedPath]
|
||||
if (iconEntry) {
|
||||
if (typeof iconEntry === 'string') {
|
||||
return iconEntry
|
||||
} else if (typeof iconEntry === 'object' && iconEntry.iconName) {
|
||||
return iconEntry.iconName
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export function parseIconName(iconName: string): {
|
||||
prefix: string
|
||||
name: string
|
||||
} {
|
||||
const prefixMatch = iconName.match(/^[A-Z][a-z]*/)
|
||||
if (prefixMatch) {
|
||||
const prefix = prefixMatch[0]
|
||||
const name = iconName.substring(prefix.length)
|
||||
return { prefix, name }
|
||||
} else {
|
||||
// No prefix, treat the entire iconName as the name
|
||||
return { prefix: '', name: iconName }
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadIconSVG(
|
||||
iconName: string,
|
||||
plugin: LocatorPlugin,
|
||||
iconsPath: string,
|
||||
prefixToIconPack: { [prefix: string]: string }
|
||||
): Promise<string | null> {
|
||||
const parsed = parseIconName(iconName)
|
||||
const { prefix, name } = parsed
|
||||
|
||||
if (!prefix) {
|
||||
// No prefix, assume it's an emoji or text
|
||||
return `<span class="locator-result__icon--emoji">${escapeHTML(
|
||||
name
|
||||
)}</span>`
|
||||
}
|
||||
|
||||
const iconPackName = prefixToIconPack[prefix]
|
||||
|
||||
if (!iconPackName) {
|
||||
warnVerbose(`No icon pack found for prefix: ${prefix}`)
|
||||
return null
|
||||
}
|
||||
|
||||
if (iconPackName === 'lucide-icons') {
|
||||
// Convert CamelCase to dash-case for Lucide icons
|
||||
const dashedName = name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
|
||||
const iconEl = getIcon(dashedName)
|
||||
if (iconEl) {
|
||||
return iconEl.outerHTML
|
||||
} else {
|
||||
warnVerbose(`Lucide icon not found: ${dashedName}`)
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
if (!iconsPath) {
|
||||
warnVerbose('Icons path is not set. Cannot load icon SVG.')
|
||||
return null
|
||||
}
|
||||
const iconPath = `${plugin.app.vault.configDir}/${iconsPath}/${iconPackName}/${name}.svg`
|
||||
try {
|
||||
const svgContent = await plugin.app.vault.adapter.read(iconPath)
|
||||
return svgContent
|
||||
} catch (e) {
|
||||
warnVerbose(`Failed to load icon SVG for ${iconName} at ${iconPath}:`, e)
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getDefaultIconSVG(
|
||||
notePath: string,
|
||||
plugin: LocatorPlugin
|
||||
): string {
|
||||
export function getDefaultIconSVG(notePath: string): string {
|
||||
// Return SVG content for default icons based on file type
|
||||
let iconName = 'file'
|
||||
|
||||
if (notePath === 'folder') {
|
||||
iconName = 'folder'
|
||||
} else {
|
||||
if (isFileImage(notePath)) {
|
||||
iconName = 'image'
|
||||
} else if (isFilePDF(notePath)) {
|
||||
@@ -185,6 +15,7 @@ export function getDefaultIconSVG(
|
||||
} else if (isFileCanvas(notePath) || isFileExcalidraw(notePath)) {
|
||||
iconName = 'layout-dashboard'
|
||||
}
|
||||
}
|
||||
const iconEl = getIcon(iconName)
|
||||
return iconEl ? iconEl.outerHTML : ''
|
||||
}
|
||||
+18
-9
@@ -1,3 +1,4 @@
|
||||
import { type BinaryLike, createHash } from 'crypto'
|
||||
import {
|
||||
type CachedMetadata,
|
||||
getAllTags,
|
||||
@@ -5,9 +6,10 @@ import {
|
||||
parseFrontMatterAliases,
|
||||
Platform,
|
||||
} from 'obsidian'
|
||||
import { isSearchMatch, type SearchMatch } from '../globals'
|
||||
import { type BinaryLike, createHash } from 'crypto'
|
||||
import { md5 } from 'pure-md5'
|
||||
import { eng, fra } from 'stopword'
|
||||
import { isSearchMatch, type SearchMatch } from '../globals'
|
||||
import { settings } from 'src/settings'
|
||||
|
||||
export function pathWithoutFilename(path: string): string {
|
||||
const split = path.split('/')
|
||||
@@ -120,11 +122,12 @@ export function removeDiacritics(str: string, arabic = true): string {
|
||||
return ''
|
||||
}
|
||||
|
||||
// TODO: add a global setting to toggle this, this impacts performances
|
||||
if (arabic) {
|
||||
// Arabic diacritics
|
||||
// https://stackoverflow.com/a/40959537
|
||||
str = str
|
||||
.replace(/([^\u0621-\u063A\u0641-\u064A\u0660-\u0669a-zA-Z 0-9])/g, '')
|
||||
// .replace(/([^\u0621-\u063A\u0641-\u064A\u0660-\u0669a-zA-Z 0-9])/g, '')
|
||||
.replace(/(آ|إ|أ)/g, 'ا')
|
||||
.replace(/(ة)/g, 'ه')
|
||||
.replace(/(ئ|ؤ)/g, 'ء')
|
||||
@@ -143,6 +146,7 @@ export function removeDiacritics(str: string, arabic = true): string {
|
||||
str = str.normalize('NFD').replace(diacriticsRegex, '').normalize('NFC')
|
||||
str = str.replaceAll('[__locator__backtick__]', '`')
|
||||
str = str.replaceAll('[__locator__caret__]', '^')
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
@@ -249,13 +253,8 @@ export function warnVerbose(...args: any[]): void {
|
||||
printVerbose(console.warn, ...args)
|
||||
}
|
||||
|
||||
let verboseLoggingEnabled = false
|
||||
export function enableVerboseLogging(enable: boolean): void {
|
||||
verboseLoggingEnabled = enable
|
||||
}
|
||||
|
||||
function printVerbose(fn: (...args: any[]) => any, ...args: any[]): void {
|
||||
if (verboseLoggingEnabled) {
|
||||
if (settings.verboseLogging) {
|
||||
fn(...args)
|
||||
}
|
||||
}
|
||||
@@ -279,3 +278,13 @@ export const countError = (() => {
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
let stopWords: string[] = []
|
||||
export function getStopWords(): string[] {
|
||||
if (!stopWords.length) {
|
||||
stopWords = [...eng, ...fra]
|
||||
// Remove duplicates
|
||||
stopWords = [...new Set(stopWords)]
|
||||
}
|
||||
return stopWords
|
||||
}
|
||||
Reference in new issue
Block a user