feat(#245): in results list, show where an image/pdf is embedded

* Add an index of embeds for reference in results

* Notes embedding images are now shown in results

* Updated dependencies

* Correctly referencing all embeds

* Updated docs

* Basic embedded feature ok
This commit is contained in:
Simon Cambier
2024-09-25 20:47:27 +02:00
committed by GitHub
parent 437b7e2b9a
commit 1b442d1f24
14 changed files with 280 additions and 101 deletions

View File

@@ -5,8 +5,8 @@
- Omnisearch is available on [the official Community Plugins repository](https://obsidian.md/plugins?search=Omnisearch). - 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.** - Beta releases can be installed through [BRAT](https://github.com/TfTHacker/obsidian42-brat). **Be advised that those versions can be buggy and break things.**
> [!INFO] Chinese, Japanese, Korean, ... > [!INFO] Chinese users
> If you have notes in a CJK language, you should install [this additional plugin](https://github.com/aidenlx/cm-chs-patch) > If you have notes in Chinese, you should install [this additional plugin](https://github.com/aidenlx/cm-chs-patch) for better search results.
## Documentation ## Documentation
@@ -22,8 +22,9 @@ Omnisearch is licensed under [GPL-3](https://tldrlegal.com/license/gnu-general-p
## Thanks ## Thanks
❤ To all people who donate through [Ko-Fi](https://ko-fi.com/scambier)or [Github Sponsors](https://github.com/sponsors/scambier), to code contributors, and to Obsidian who graciously provides this Publish space ❤ ❤ To all people who donate through [Ko-Fi](https://ko-fi.com/scambier) or [Github Sponsors](https://github.com/sponsors/scambier), to code contributors, and to the Obsidian team who graciously provides this Publish space ❤
If you wish to get involved in Omnisearch's development, there are [open issues](https://github.com/scambier/obsidian-omnisearch/issues) that need to be solved, and probably several of them tagged as "[good first issue](https://github.com/scambier/obsidian-omnisearch/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)" :) If you wish to get involved in Omnisearch's development, there are [open issues](https://github.com/scambier/obsidian-omnisearch/issues) that need to be solved, and probably several of them tagged as "[good first issue](https://github.com/scambier/obsidian-omnisearch/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)" :)
![JetBrains Logo (Main) logo](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)
![JetBrains logo](https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.svg)

View File

@@ -5,7 +5,7 @@
white-space: normal; white-space: normal;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: space-between; /* justify-content: space-between; */
flex-wrap: nowrap; flex-wrap: nowrap;
} }
@@ -59,6 +59,11 @@
margin-inline-start: 0.5em; margin-inline-start: 0.5em;
} }
.omnisearch-result__embed {
margin-left: 1em;
}
.omnisearch-result__image-container { .omnisearch-result__image-container {
flex-basis: 20%; flex-basis: 20%;
text-align: end; text-align: end;

View File

@@ -2,7 +2,7 @@
"id": "omnisearch", "id": "omnisearch",
"name": "Omnisearch", "name": "Omnisearch",
"version": "1.24.1", "version": "1.24.1",
"minAppVersion": "1.3.0", "minAppVersion": "1.7.2",
"description": "A search engine that just works", "description": "A search engine that just works",
"author": "Simon Cambier", "author": "Simon Cambier",
"authorUrl": "https://github.com/scambier/obsidian-omnisearch", "authorUrl": "https://github.com/scambier/obsidian-omnisearch",

View File

@@ -28,7 +28,7 @@
"esbuild-plugin-copy": "1.3.0", "esbuild-plugin-copy": "1.3.0",
"esbuild-svelte": "0.7.1", "esbuild-svelte": "0.7.1",
"jest": "^27.5.1", "jest": "^27.5.1",
"obsidian": "1.5.7-1", "obsidian": "1.7.2",
"prettier": "^2.8.8", "prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.1", "prettier-plugin-svelte": "^2.10.1",
"svelte": "^3.59.2", "svelte": "^3.59.2",
@@ -37,7 +37,7 @@
"svelte-preprocess": "^4.10.7", "svelte-preprocess": "^4.10.7",
"tslib": "2.3.1", "tslib": "2.3.1",
"typescript": "^4.9.5", "typescript": "^4.9.5",
"vite": "^3.2.10" "vite": "^3.2.11"
}, },
"dependencies": { "dependencies": {
"cancelable-promise": "^4.3.1", "cancelable-promise": "^4.3.1",

90
pnpm-lock.yaml generated
View File

@@ -76,8 +76,8 @@ importers:
specifier: ^27.5.1 specifier: ^27.5.1
version: 27.5.1 version: 27.5.1
obsidian: obsidian:
specifier: 1.5.7-1 specifier: 1.7.2
version: 1.5.7-1(@codemirror/state@6.4.1)(@codemirror/view@6.26.3) version: 1.7.2(@codemirror/state@6.4.1)(@codemirror/view@6.26.3)
prettier: prettier:
specifier: ^2.8.8 specifier: ^2.8.8
version: 2.8.8 version: 2.8.8
@@ -89,13 +89,13 @@ importers:
version: 3.59.2 version: 3.59.2
svelte-check: svelte-check:
specifier: ^2.10.3 specifier: ^2.10.3
version: 2.10.3(@babel/core@7.25.2)(postcss@8.4.47)(sass@1.78.0)(svelte@3.59.2) version: 2.10.3(@babel/core@7.25.2)(postcss@8.4.47)(sass@1.79.3)(svelte@3.59.2)
svelte-jester: svelte-jester:
specifier: ^2.3.2 specifier: ^2.3.2
version: 2.3.2(jest@27.5.1)(svelte@3.59.2) version: 2.3.2(jest@27.5.1)(svelte@3.59.2)
svelte-preprocess: svelte-preprocess:
specifier: ^4.10.7 specifier: ^4.10.7
version: 4.10.7(@babel/core@7.25.2)(postcss@8.4.47)(sass@1.78.0)(svelte@3.59.2)(typescript@4.9.5) version: 4.10.7(@babel/core@7.25.2)(postcss@8.4.47)(sass@1.79.3)(svelte@3.59.2)(typescript@4.9.5)
tslib: tslib:
specifier: 2.3.1 specifier: 2.3.1
version: 2.3.1 version: 2.3.1
@@ -103,8 +103,8 @@ importers:
specifier: ^4.9.5 specifier: ^4.9.5
version: 4.9.5 version: 4.9.5
vite: vite:
specifier: ^3.2.10 specifier: ^3.2.11
version: 3.2.10(@types/node@16.18.108)(sass@1.78.0) version: 3.2.11(@types/node@16.18.108)(sass@1.79.3)
packages: packages:
@@ -861,8 +861,8 @@ packages:
'@types/codemirror@5.60.8': '@types/codemirror@5.60.8':
resolution: {integrity: sha512-VjFgDF/eB+Aklcy15TtOTLQeMjTo07k7KAjql8OK5Dirr7a6sJY4T1uVBDuTVG9VEmn1uUsohOpYnVfgC6/jyw==} resolution: {integrity: sha512-VjFgDF/eB+Aklcy15TtOTLQeMjTo07k7KAjql8OK5Dirr7a6sJY4T1uVBDuTVG9VEmn1uUsohOpYnVfgC6/jyw==}
'@types/estree@1.0.5': '@types/estree@1.0.6':
resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==}
'@types/graceful-fs@4.1.9': '@types/graceful-fs@4.1.9':
resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==} resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==}
@@ -968,8 +968,8 @@ packages:
argparse@1.0.10: argparse@1.0.10:
resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==}
aria-query@5.3.1: aria-query@5.3.2:
resolution: {integrity: sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g==} resolution: {integrity: sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==}
engines: {node: '>= 0.4'} engines: {node: '>= 0.4'}
array-union@2.1.0: array-union@2.1.0:
@@ -1072,8 +1072,8 @@ packages:
cancelable-promise@4.3.1: cancelable-promise@4.3.1:
resolution: {integrity: sha512-A/8PwLk/T7IJDfUdQ68NR24QHa8rIlnN/stiJEBo6dmVUkD4K14LswG0w3VwdeK/o7qOwRUR1k2MhK5Rpy2m7A==} resolution: {integrity: sha512-A/8PwLk/T7IJDfUdQ68NR24QHa8rIlnN/stiJEBo6dmVUkD4K14LswG0w3VwdeK/o7qOwRUR1k2MhK5Rpy2m7A==}
caniuse-lite@1.0.30001660: caniuse-lite@1.0.30001662:
resolution: {integrity: sha512-GacvNTTuATm26qC74pt+ad1fW15mlQ/zuTzzY1ZoIzECTP8HURDfF43kNxPgf7H1jmelCBQTTbBNxdSXOA7Bqg==} resolution: {integrity: sha512-sgMUVwLmGseH8ZIrm1d51UbrhqMCH3jvS7gF/M6byuHOnKyLOBL7W8yz5V02OHwgLGA36o/AFhWzzh4uc5aqTA==}
chalk@2.4.2: chalk@2.4.2:
resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==}
@@ -1102,6 +1102,10 @@ packages:
resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==}
engines: {node: '>= 8.10.0'} engines: {node: '>= 8.10.0'}
chokidar@4.0.0:
resolution: {integrity: sha512-mxIojEAQcuEvT/lyXq+jf/3cO/KoA6z4CeNDGGevTybECPOMFCnQy3OPahluUkbqgPNGw5Bi78UC7Po6Lhy+NA==}
engines: {node: '>= 14.16.0'}
ci-info@3.9.0: ci-info@3.9.0:
resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==}
engines: {node: '>=8'} engines: {node: '>=8'}
@@ -1240,8 +1244,8 @@ packages:
domutils@3.1.0: domutils@3.1.0:
resolution: {integrity: sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==} resolution: {integrity: sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==}
electron-to-chromium@1.5.23: electron-to-chromium@1.5.27:
resolution: {integrity: sha512-mBhODedOXg4v5QWwl21DjM5amzjmI1zw9EPrPK/5Wx7C8jt33bpZNrC7OhHUG3pxRtbLpr3W2dXT+Ph1SsfRZA==} resolution: {integrity: sha512-o37j1vZqCoEgBuWWXLHQgTN/KDKe7zwpiY5CPeq2RvUqOyJw9xnrULzZAEVQ5p4h+zjMk7hgtOoPdnLxr7m/jw==}
emittery@0.8.1: emittery@0.8.1:
resolution: {integrity: sha512-uDfvUjVrfGJJhymx/kz6prltenw1u7WrCg1oa94zYY8xxVpLLUu045LAT0dhDZdXG58/EpPL/5kA180fQ/qudg==} resolution: {integrity: sha512-uDfvUjVrfGJJhymx/kz6prltenw1u7WrCg1oa94zYY8xxVpLLUu045LAT0dhDZdXG58/EpPL/5kA180fQ/qudg==}
@@ -2044,8 +2048,8 @@ packages:
nwsapi@2.2.12: nwsapi@2.2.12:
resolution: {integrity: sha512-qXDmcVlZV4XRtKFzddidpfVP4oMSGhga+xdMc25mv8kaLUHtgzCDhUxkrN8exkGdTlLNaXj7CV3GtON7zuGZ+w==} resolution: {integrity: sha512-qXDmcVlZV4XRtKFzddidpfVP4oMSGhga+xdMc25mv8kaLUHtgzCDhUxkrN8exkGdTlLNaXj7CV3GtON7zuGZ+w==}
obsidian@1.5.7-1: obsidian@1.7.2:
resolution: {integrity: sha512-T5ZRuQ1FnfXqEoakTTHVDYvzUEEoT8zSPnQCW31PVgYwG4D4tZCQfKHN2hTz1ifnCe8upvwa6mBTAP2WUA5Vng==} resolution: {integrity: sha512-k9hN9brdknJC+afKr5FQzDRuEFGDKbDjfCazJwpgibwCAoZNYHYV8p/s3mM8I6AsnKrPKNXf8xGuMZ4enWelZQ==}
peerDependencies: peerDependencies:
'@codemirror/state': ^6.0.0 '@codemirror/state': ^6.0.0
'@codemirror/view': ^6.0.0 '@codemirror/view': ^6.0.0
@@ -2169,6 +2173,10 @@ packages:
resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==}
engines: {node: '>=8.10.0'} engines: {node: '>=8.10.0'}
readdirp@4.0.1:
resolution: {integrity: sha512-GkMg9uOTpIWWKbSsgwb5fA4EavTR+SG/PMPoAY8hkhHfEEY0/vqljY+XHqtDf2cr2IJtoNRDbrrEpZUiZCkYRw==}
engines: {node: '>= 14.16.0'}
redent@3.0.0: redent@3.0.0:
resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==} resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==}
engines: {node: '>=8'} engines: {node: '>=8'}
@@ -2253,8 +2261,8 @@ packages:
sander@0.5.1: sander@0.5.1:
resolution: {integrity: sha512-3lVqBir7WuKDHGrKRDn/1Ye3kwpXaDOMsiRP1wd6wpZW56gJhsbp5RqQpA6JG/P+pkXizygnr1dKR8vzWaVsfA==} resolution: {integrity: sha512-3lVqBir7WuKDHGrKRDn/1Ye3kwpXaDOMsiRP1wd6wpZW56gJhsbp5RqQpA6JG/P+pkXizygnr1dKR8vzWaVsfA==}
sass@1.78.0: sass@1.79.3:
resolution: {integrity: sha512-AaIqGSrjo5lA2Yg7RvFZrlXDBCp3nV4XP73GrLGvdRWWwk+8H3l0SDvq/5bA4eF+0RFPLuWUk3E+P1U/YqnpsQ==} resolution: {integrity: sha512-m7dZxh0W9EZ3cw50Me5GOuYm/tVAJAn91SUnohLRo9cXBixGUOdvmryN+dXpwR831bhoY3Zv7rEFt85PUwTmzA==}
engines: {node: '>=14.0.0'} engines: {node: '>=14.0.0'}
hasBin: true hasBin: true
@@ -2523,8 +2531,8 @@ packages:
resolution: {integrity: sha512-FGtKtv3xIpR6BYhvgH8MI/y78oT7d8Au3ww4QIxymrCtZEh5b8gCw2siywE+puhEmuWKDtmfrvF5UlB298ut3w==} resolution: {integrity: sha512-FGtKtv3xIpR6BYhvgH8MI/y78oT7d8Au3ww4QIxymrCtZEh5b8gCw2siywE+puhEmuWKDtmfrvF5UlB298ut3w==}
engines: {node: '>=10.12.0'} engines: {node: '>=10.12.0'}
vite@3.2.10: vite@3.2.11:
resolution: {integrity: sha512-Dx3olBo/ODNiMVk/cA5Yft9Ws+snLOXrhLtrI3F4XLt4syz2Yg8fayZMWScPKoz12v5BUv7VEmQHnsfpY80fYw==} resolution: {integrity: sha512-K/jGKL/PgbIgKCiJo5QbASQhFiV02X9Jh+Qq0AKCRCRKZtOTVi4t6wh75FDpGf2N9rYOnzH87OEFQNaFy6pdxQ==}
engines: {node: ^14.18.0 || >=16.0.0} engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true hasBin: true
peerDependencies: peerDependencies:
@@ -3659,7 +3667,7 @@ snapshots:
'@adobe/css-tools': 4.4.0 '@adobe/css-tools': 4.4.0
'@babel/runtime': 7.25.6 '@babel/runtime': 7.25.6
'@types/testing-library__jest-dom': 5.14.9 '@types/testing-library__jest-dom': 5.14.9
aria-query: 5.3.1 aria-query: 5.3.2
chalk: 3.0.0 chalk: 3.0.0
css.escape: 1.5.1 css.escape: 1.5.1
dom-accessibility-api: 0.5.16 dom-accessibility-api: 0.5.16
@@ -3695,7 +3703,7 @@ snapshots:
dependencies: dependencies:
'@types/tern': 0.23.9 '@types/tern': 0.23.9
'@types/estree@1.0.5': {} '@types/estree@1.0.6': {}
'@types/graceful-fs@4.1.9': '@types/graceful-fs@4.1.9':
dependencies: dependencies:
@@ -3732,13 +3740,13 @@ snapshots:
'@types/sass@1.45.0': '@types/sass@1.45.0':
dependencies: dependencies:
sass: 1.78.0 sass: 1.79.3
'@types/stack-utils@2.0.3': {} '@types/stack-utils@2.0.3': {}
'@types/tern@0.23.9': '@types/tern@0.23.9':
dependencies: dependencies:
'@types/estree': 1.0.5 '@types/estree': 1.0.6
'@types/testing-library__jest-dom@5.14.9': '@types/testing-library__jest-dom@5.14.9':
dependencies: dependencies:
@@ -3794,7 +3802,7 @@ snapshots:
dependencies: dependencies:
sprintf-js: 1.0.3 sprintf-js: 1.0.3
aria-query@5.3.1: {} aria-query@5.3.2: {}
array-union@2.1.0: {} array-union@2.1.0: {}
@@ -3899,8 +3907,8 @@ snapshots:
browserslist@4.23.3: browserslist@4.23.3:
dependencies: dependencies:
caniuse-lite: 1.0.30001660 caniuse-lite: 1.0.30001662
electron-to-chromium: 1.5.23 electron-to-chromium: 1.5.27
node-releases: 2.0.18 node-releases: 2.0.18
update-browserslist-db: 1.1.0(browserslist@4.23.3) update-browserslist-db: 1.1.0(browserslist@4.23.3)
@@ -3922,7 +3930,7 @@ snapshots:
cancelable-promise@4.3.1: {} cancelable-promise@4.3.1: {}
caniuse-lite@1.0.30001660: {} caniuse-lite@1.0.30001662: {}
chalk@2.4.2: chalk@2.4.2:
dependencies: dependencies:
@@ -3977,6 +3985,10 @@ snapshots:
optionalDependencies: optionalDependencies:
fsevents: 2.3.3 fsevents: 2.3.3
chokidar@4.0.0:
dependencies:
readdirp: 4.0.1
ci-info@3.9.0: {} ci-info@3.9.0: {}
cjs-module-lexer@1.4.1: {} cjs-module-lexer@1.4.1: {}
@@ -4097,7 +4109,7 @@ snapshots:
domelementtype: 2.3.0 domelementtype: 2.3.0
domhandler: 5.0.3 domhandler: 5.0.3
electron-to-chromium@1.5.23: {} electron-to-chromium@1.5.27: {}
emittery@0.8.1: {} emittery@0.8.1: {}
@@ -5049,7 +5061,7 @@ snapshots:
nwsapi@2.2.12: {} nwsapi@2.2.12: {}
obsidian@1.5.7-1(@codemirror/state@6.4.1)(@codemirror/view@6.26.3): obsidian@1.7.2(@codemirror/state@6.4.1)(@codemirror/view@6.26.3):
dependencies: dependencies:
'@codemirror/state': 6.4.1 '@codemirror/state': 6.4.1
'@codemirror/view': 6.26.3 '@codemirror/view': 6.26.3
@@ -5160,6 +5172,8 @@ snapshots:
dependencies: dependencies:
picomatch: 2.3.1 picomatch: 2.3.1
readdirp@4.0.1: {}
redent@3.0.0: redent@3.0.0:
dependencies: dependencies:
indent-string: 4.0.0 indent-string: 4.0.0
@@ -5241,9 +5255,9 @@ snapshots:
mkdirp: 0.5.6 mkdirp: 0.5.6
rimraf: 2.7.1 rimraf: 2.7.1
sass@1.78.0: sass@1.79.3:
dependencies: dependencies:
chokidar: 3.6.0 chokidar: 4.0.0
immutable: 4.3.7 immutable: 4.3.7
source-map-js: 1.2.1 source-map-js: 1.2.1
@@ -5341,7 +5355,7 @@ snapshots:
supports-preserve-symlinks-flag@1.0.0: {} supports-preserve-symlinks-flag@1.0.0: {}
svelte-check@2.10.3(@babel/core@7.25.2)(postcss@8.4.47)(sass@1.78.0)(svelte@3.59.2): svelte-check@2.10.3(@babel/core@7.25.2)(postcss@8.4.47)(sass@1.79.3)(svelte@3.59.2):
dependencies: dependencies:
'@jridgewell/trace-mapping': 0.3.25 '@jridgewell/trace-mapping': 0.3.25
chokidar: 3.6.0 chokidar: 3.6.0
@@ -5350,7 +5364,7 @@ snapshots:
picocolors: 1.1.0 picocolors: 1.1.0
sade: 1.8.1 sade: 1.8.1
svelte: 3.59.2 svelte: 3.59.2
svelte-preprocess: 4.10.7(@babel/core@7.25.2)(postcss@8.4.47)(sass@1.78.0)(svelte@3.59.2)(typescript@4.9.5) svelte-preprocess: 4.10.7(@babel/core@7.25.2)(postcss@8.4.47)(sass@1.79.3)(svelte@3.59.2)(typescript@4.9.5)
typescript: 4.9.5 typescript: 4.9.5
transitivePeerDependencies: transitivePeerDependencies:
- '@babel/core' - '@babel/core'
@@ -5369,7 +5383,7 @@ snapshots:
jest: 27.5.1 jest: 27.5.1
svelte: 3.59.2 svelte: 3.59.2
svelte-preprocess@4.10.7(@babel/core@7.25.2)(postcss@8.4.47)(sass@1.78.0)(svelte@3.59.2)(typescript@4.9.5): svelte-preprocess@4.10.7(@babel/core@7.25.2)(postcss@8.4.47)(sass@1.79.3)(svelte@3.59.2)(typescript@4.9.5):
dependencies: dependencies:
'@types/pug': 2.0.10 '@types/pug': 2.0.10
'@types/sass': 1.45.0 '@types/sass': 1.45.0
@@ -5381,7 +5395,7 @@ snapshots:
optionalDependencies: optionalDependencies:
'@babel/core': 7.25.2 '@babel/core': 7.25.2
postcss: 8.4.47 postcss: 8.4.47
sass: 1.78.0 sass: 1.79.3
typescript: 4.9.5 typescript: 4.9.5
svelte@3.59.2: {} svelte@3.59.2: {}
@@ -5466,7 +5480,7 @@ snapshots:
convert-source-map: 1.9.0 convert-source-map: 1.9.0
source-map: 0.7.4 source-map: 0.7.4
vite@3.2.10(@types/node@16.18.108)(sass@1.78.0): vite@3.2.11(@types/node@16.18.108)(sass@1.79.3):
dependencies: dependencies:
esbuild: 0.15.18 esbuild: 0.15.18
postcss: 8.4.47 postcss: 8.4.47
@@ -5475,7 +5489,7 @@ snapshots:
optionalDependencies: optionalDependencies:
'@types/node': 16.18.108 '@types/node': 16.18.108
fsevents: 2.3.3 fsevents: 2.3.3
sass: 1.78.0 sass: 1.79.3
w3c-hr-time@1.0.2: w3c-hr-time@1.0.2:
dependencies: dependencies:

View File

@@ -22,7 +22,6 @@ export class CacheManager {
* Show an empty input field next time the user opens Omnisearch modal * Show an empty input field next time the user opens Omnisearch modal
*/ */
private nextQueryIsEmpty = false private nextQueryIsEmpty = false
/** /**
* The "live cache", containing all indexed vault files * The "live cache", containing all indexed vault files
* in the form of IndexedDocuments * in the form of IndexedDocuments
@@ -45,6 +44,7 @@ export class CacheManager {
return return
} }
this.documents.set(path, doc) this.documents.set(path, doc)
this.plugin.embedsRepository.refreshEmbeds(path)
} catch (e) { } catch (e) {
console.warn(`Omnisearch: Error while adding "${path}" to live cache`, e) console.warn(`Omnisearch: Error while adding "${path}" to live cache`, e)
// Shouldn't be needed, but... // Shouldn't be needed, but...
@@ -167,12 +167,18 @@ export class CacheManager {
(this.plugin.settings.aiImageIndexing && (this.plugin.settings.aiImageIndexing &&
aiImageAnalyzer?.canBeAnalyzed(file))) aiImageAnalyzer?.canBeAnalyzed(file)))
) { ) {
if (this.plugin.settings.imagesIndexing && extractor?.canFileBeExtracted(path)){ if (
this.plugin.settings.imagesIndexing &&
extractor?.canFileBeExtracted(path)
) {
content = await extractor.extractText(file) content = await extractor.extractText(file)
} }
if (this.plugin.settings.aiImageIndexing && aiImageAnalyzer?.canBeAnalyzed(file)) { if (
content = await aiImageAnalyzer.analyzeImage(file) + (content ?? '') this.plugin.settings.aiImageIndexing &&
aiImageAnalyzer?.canBeAnalyzed(file)
) {
content = (await aiImageAnalyzer.analyzeImage(file)) + (content ?? '')
} }
} }
// ** PDF ** // ** PDF **
@@ -230,7 +236,8 @@ export class CacheManager {
} }
} }
} }
const displayTitle = metadata?.frontmatter?.[this.plugin.settings.displayTitle] ?? '' const displayTitle =
metadata?.frontmatter?.[this.plugin.settings.displayTitle] ?? ''
const tags = getTagsFromMetadata(metadata) const tags = getTagsFromMetadata(metadata)
return { return {
basename: file.basename, basename: file.basename,

View File

@@ -4,11 +4,12 @@
export let id: string export let id: string
export let selected = false export let selected = false
export let glyph = false export let glyph = false
export let cssClass = ''
</script> </script>
<div <div
data-result-id={id} data-result-id={id}
class="suggestion-item omnisearch-result" class="suggestion-item omnisearch-result {cssClass}"
class:is-selected={selected} class:is-selected={selected}
on:mousemove on:mousemove
on:click on:click

View File

@@ -3,7 +3,8 @@
import type { ResultNote } from '../globals' import type { ResultNote } from '../globals'
import { import {
getExtension, getExtension,
isFileCanvas, isFileExcalidraw, isFileCanvas,
isFileExcalidraw,
isFileImage, isFileImage,
isFilePDF, isFilePDF,
pathWithoutFilename, pathWithoutFilename,
@@ -11,6 +12,7 @@
import ResultItemContainer from './ResultItemContainer.svelte' import ResultItemContainer from './ResultItemContainer.svelte'
import { TFile, setIcon } from 'obsidian' import { TFile, setIcon } from 'obsidian'
import type OmnisearchPlugin from '../main' import type OmnisearchPlugin from '../main'
import { SvelteComponent } from 'svelte'
export let selected = false export let selected = false
export let note: ResultNote export let note: ResultNote
@@ -21,6 +23,7 @@
let notePath = '' let notePath = ''
let elFolderPathIcon: HTMLElement let elFolderPathIcon: HTMLElement
let elFilePathIcon: HTMLElement let elFilePathIcon: HTMLElement
let elEmbedIcon: HTMLElement
$: { $: {
imagePath = null imagePath = null
@@ -32,8 +35,14 @@
} }
} }
$: matchesTitle = plugin.textProcessor.getMatches(title, note.foundWords) $: matchesTitle = plugin.textProcessor.getMatches(title, note.foundWords)
$: matchesNotePath = plugin.textProcessor.getMatches(notePath, note.foundWords) $: matchesNotePath = plugin.textProcessor.getMatches(
$: cleanedContent = plugin.textProcessor.makeExcerpt(note.content, note.matches[0]?.offset ?? -1) notePath,
note.foundWords
)
$: cleanedContent = plugin.textProcessor.makeExcerpt(
note.content,
note.matches[0]?.offset ?? -1
)
$: glyph = false //cacheManager.getLiveDocument(note.path)?.doesNotExist $: glyph = false //cacheManager.getLiveDocument(note.path)?.doesNotExist
$: { $: {
title = note.displayTitle || note.basename title = note.displayTitle || note.basename
@@ -46,23 +55,24 @@
if (elFilePathIcon) { if (elFilePathIcon) {
if (isFileImage(note.path)) { if (isFileImage(note.path)) {
setIcon(elFilePathIcon, 'image') setIcon(elFilePathIcon, 'image')
} } else if (isFilePDF(note.path)) {
else if (isFilePDF(note.path)) {
setIcon(elFilePathIcon, 'file-text') setIcon(elFilePathIcon, 'file-text')
} } else if (isFileCanvas(note.path) || isFileExcalidraw(note.path)) {
else if (isFileCanvas(note.path) || isFileExcalidraw(note.path)) {
setIcon(elFilePathIcon, 'layout-dashboard') setIcon(elFilePathIcon, 'layout-dashboard')
} } else {
else {
setIcon(elFilePathIcon, 'file') setIcon(elFilePathIcon, 'file')
} }
} }
if (elEmbedIcon) {
setIcon(elEmbedIcon, 'corner-down-right')
}
} }
</script> </script>
<ResultItemContainer <ResultItemContainer
glyph="{glyph}" glyph="{glyph}"
id="{note.path}" id="{note.path}"
cssClass=" {note.isEmbed ? 'omnisearch-result__embed' : ''}"
on:auxclick on:auxclick
on:click on:click
on:mousemove on:mousemove
@@ -70,8 +80,14 @@
<div> <div>
<div class="omnisearch-result__title-container"> <div class="omnisearch-result__title-container">
<span class="omnisearch-result__title"> <span class="omnisearch-result__title">
{#if note.isEmbed}
<span bind:this="{elEmbedIcon}" title="The document above is embedded in this note"></span>
{:else}
<span bind:this="{elFilePathIcon}"></span> <span bind:this="{elFilePathIcon}"></span>
<span>{@html plugin.textProcessor.highlightText(title, matchesTitle)}</span> {/if}
<span>
{@html plugin.textProcessor.highlightText(title, matchesTitle)}
</span>
<span class="omnisearch-result__extension"> <span class="omnisearch-result__extension">
.{getExtension(note.path)} .{getExtension(note.path)}
</span> </span>
@@ -91,14 +107,23 @@
{#if notePath} {#if notePath}
<div class="omnisearch-result__folder-path"> <div class="omnisearch-result__folder-path">
<span bind:this="{elFolderPathIcon}"></span> <span bind:this="{elFolderPathIcon}"></span>
<span>{@html plugin.textProcessor.highlightText(notePath, matchesNotePath)}</span> <span>
{@html plugin.textProcessor.highlightText(
notePath,
matchesNotePath
)}</span>
</div> </div>
{/if} {/if}
<!-- Do not display the excerpt for embedding references -->
{#if !note.isEmbed}
<div style="display: flex; flex-direction: row;"> <div style="display: flex; flex-direction: row;">
{#if $showExcerpt} {#if $showExcerpt}
<div class="omnisearch-result__body"> <div class="omnisearch-result__body">
{@html plugin.textProcessor.highlightText(cleanedContent, note.matches)} {@html plugin.textProcessor.highlightText(
cleanedContent,
note.matches
)}
</div> </div>
{/if} {/if}
@@ -109,5 +134,6 @@
</div> </div>
{/if} {/if}
</div> </div>
{/if}
</div> </div>
</ResultItemContainer> </ResultItemContainer>

View File

@@ -1,12 +1,11 @@
import Dexie from 'dexie' import Dexie from 'dexie'
import type MiniSearch from 'minisearch'
import type { AsPlainObject } from 'minisearch' import type { AsPlainObject } from 'minisearch'
import type { DocumentRef } from './globals' import type { DocumentRef } from './globals'
import { Notice } from 'obsidian' import { Notice } from 'obsidian'
import type OmnisearchPlugin from './main' import type OmnisearchPlugin from './main'
export class Database extends Dexie { export class Database extends Dexie {
public static readonly dbVersion = 8 public static readonly dbVersion = 9
searchHistory!: Dexie.Table<{ id?: number; query: string }, number> searchHistory!: Dexie.Table<{ id?: number; query: string }, number>
minisearch!: Dexie.Table< minisearch!: Dexie.Table<
{ {
@@ -16,6 +15,7 @@ export class Database extends Dexie {
}, },
string string
> >
embeds!: Dexie.Table<{ embedded: string; references: string[] }, string>
constructor(private plugin: OmnisearchPlugin) { constructor(private plugin: OmnisearchPlugin) {
super(Database.getDbName(plugin.app.appId)) super(Database.getDbName(plugin.app.appId))
@@ -23,6 +23,7 @@ export class Database extends Dexie {
this.version(Database.dbVersion).stores({ this.version(Database.dbVersion).stores({
searchHistory: '++id', searchHistory: '++id',
minisearch: 'date', minisearch: 'date',
embeds: 'embedded',
}) })
} }
@@ -49,17 +50,15 @@ export class Database extends Dexie {
} }
} }
public async writeMinisearchCache( public async writeMinisearchCache(): Promise<void> {
minisearch: MiniSearch, const minisearchJson = this.plugin.searchEngine.getSerializedMiniSearch()
indexed: Map<string, number> const paths = this.plugin.searchEngine.getSerializedIndexedDocuments()
): Promise<void> {
const paths = Array.from(indexed).map(([k, v]) => ({ path: k, mtime: v }))
const database = this.plugin.database const database = this.plugin.database
await database.minisearch.clear() await database.minisearch.clear()
await database.minisearch.add({ await database.minisearch.add({
date: new Date().toISOString(), date: new Date().toISOString(),
paths, paths,
data: minisearch.toJSON(), data: minisearchJson,
}) })
console.log('Omnisearch - Search cache written') console.log('Omnisearch - Search cache written')
} }
@@ -85,7 +84,8 @@ export class Database extends Dexie {
} }
public async clearCache() { public async clearCache() {
new Notice('Omnisearch - Cache cleared. Please restart Obsidian.')
await this.minisearch.clear() await this.minisearch.clear()
await this.embeds.clear()
new Notice('Omnisearch - Cache cleared. Please restart Obsidian.')
} }
} }

View File

@@ -81,6 +81,7 @@ export type ResultNote = {
content: string content: string
foundWords: string[] foundWords: string[]
matches: SearchMatch[] matches: SearchMatch[]
isEmbed: boolean
} }
let inComposition = false let inComposition = false

View File

@@ -28,6 +28,7 @@ import { CacheManager } from './cache-manager'
import { logDebug } from './tools/utils' import { logDebug } from './tools/utils'
import { NotesIndexer } from './notes-indexer' import { NotesIndexer } from './notes-indexer'
import { TextProcessor } from './tools/text-processing' import { TextProcessor } from './tools/text-processing'
import { EmbedsRepository } from './repositories/embeds-repository'
export default class OmnisearchPlugin extends Plugin { export default class OmnisearchPlugin extends Plugin {
// FIXME: fix the type // FIXME: fix the type
@@ -42,6 +43,8 @@ export default class OmnisearchPlugin extends Plugin {
public readonly textProcessor = new TextProcessor(this) public readonly textProcessor = new TextProcessor(this)
public readonly searchEngine = new SearchEngine(this) public readonly searchEngine = new SearchEngine(this)
public readonly embedsRepository = new EmbedsRepository(this)
private ribbonButton?: HTMLElement private ribbonButton?: HTMLElement
private refreshIndexCallback?: () => void private refreshIndexCallback?: () => void
@@ -109,6 +112,7 @@ export default class OmnisearchPlugin extends Plugin {
if (this.notesIndexer.isFileIndexable(file.path)) { if (this.notesIndexer.isFileIndexable(file.path)) {
logDebug('Indexing new file', file.path) logDebug('Indexing new file', file.path)
searchEngine.addFromPaths([file.path]) searchEngine.addFromPaths([file.path])
this.embedsRepository.refreshEmbeds(file.path)
} }
}) })
) )
@@ -117,6 +121,7 @@ export default class OmnisearchPlugin extends Plugin {
logDebug('Removing file', file.path) logDebug('Removing file', file.path)
this.cacheManager.removeFromLiveCache(file.path) this.cacheManager.removeFromLiveCache(file.path)
searchEngine.removeFromPaths([file.path]) searchEngine.removeFromPaths([file.path])
this.embedsRepository.refreshEmbeds(file.path)
}) })
) )
this.registerEvent( this.registerEvent(
@@ -124,6 +129,7 @@ export default class OmnisearchPlugin extends Plugin {
if (this.notesIndexer.isFileIndexable(file.path)) { if (this.notesIndexer.isFileIndexable(file.path)) {
this.notesIndexer.flagNoteForReindex(file) this.notesIndexer.flagNoteForReindex(file)
} }
this.embedsRepository.refreshEmbeds(file.path)
}) })
) )
this.registerEvent( this.registerEvent(
@@ -240,7 +246,7 @@ export default class OmnisearchPlugin extends Plugin {
} }
} }
const diff = searchEngine.getDiff( const diff = searchEngine.getDocumentsToReindex(
files.map(f => ({ path: f.path, mtime: f.stat.mtime })) files.map(f => ({ path: f.path, mtime: f.stat.mtime }))
) )
@@ -281,7 +287,8 @@ export default class OmnisearchPlugin extends Plugin {
} }
// Write the cache // Write the cache
await searchEngine.writeToCache() await this.database.writeMinisearchCache()
await this.embedsRepository.writeToCache()
// Re-enable settings.caching // Re-enable settings.caching
if (cacheEnabled) { if (cacheEnabled) {

View File

@@ -0,0 +1,77 @@
import { getLinkpath } from 'obsidian'
import type OmnisearchPlugin from '../main'
import { logDebug } from '../tools/utils'
export class EmbedsRepository {
/** Map<image or pdf, notes where embedded> */
private embeds: Map<string, Set<string>> = new Map()
constructor(private plugin: OmnisearchPlugin) {}
public addEmbed(embed: string, notePath: string): void {
if (!this.embeds.has(embed)) {
this.embeds.set(embed, new Set())
}
this.embeds.get(embed)!.add(notePath)
}
public refreshEmbeds(notePath: string): void {
this.embeds.forEach((value, key) => {
if (value.has(notePath)) {
value.delete(notePath)
}
})
this.addEmbeds(notePath)
}
public getEmbeds(pathEmbedded: string): string[] {
const embeds = this.embeds.has(pathEmbedded)
? [...this.embeds.get(pathEmbedded)!]
: []
return embeds
}
public async writeToCache(): Promise<void> {
logDebug('Writing embeds to cache')
const database = this.plugin.database
const data: { embedded: string; references: string[] }[] = []
for (const [path, embedsList] of this.embeds) {
data.push({ embedded: path, references: [...embedsList] })
}
await database.embeds.clear()
await database.embeds.bulkAdd(data)
}
public async loadFromCache(): Promise<void> {
const database = this.plugin.database
if (!database.embeds) {
logDebug('No embeds in cache')
return
}
logDebug('Loading embeds from cache')
const embedsArr = await database.embeds.toArray()
for (const { embedded: path, references: embeds } of embedsArr) {
for (const embed of embeds) {
this.addEmbed(path, embed)
}
}
}
private addEmbeds(notePath: string): void {
// Get all embeds from the note
// and map them to TFiles to get the real path
const embeds = (
this.plugin.app.metadataCache.getCache(notePath)?.embeds ?? []
)
.map(embed =>
this.plugin.app.metadataCache.getFirstLinkpathDest(
getLinkpath(embed.link),
notePath
)
)
.filter(o => !!o)
for (const embed of embeds) {
this.addEmbed(embed.path, notePath)
}
}
}

View File

@@ -1,4 +1,8 @@
import MiniSearch, { type Options, type SearchResult } from 'minisearch' import MiniSearch, {
type AsPlainObject,
type Options,
type SearchResult,
} from 'minisearch'
import type { DocumentRef, IndexedDocument, ResultNote } from '../globals' import type { DocumentRef, IndexedDocument, ResultNote } from '../globals'
import { chunkArray, logDebug, removeDiacritics } from '../tools/utils' import { chunkArray, logDebug, removeDiacritics } from '../tools/utils'
@@ -13,6 +17,7 @@ export class SearchEngine {
private minisearch: MiniSearch private minisearch: MiniSearch
/** Map<path, mtime> */ /** Map<path, mtime> */
private indexedDocuments: Map<string, number> = new Map() private indexedDocuments: Map<string, number> = new Map()
// private previousResults: SearchResult[] = [] // private previousResults: SearchResult[] = []
// private previousQuery: Query | null = null // private previousQuery: Query | null = null
@@ -25,6 +30,7 @@ export class SearchEngine {
* Return true if the cache is valid * Return true if the cache is valid
*/ */
async loadCache(): Promise<boolean> { async loadCache(): Promise<boolean> {
await this.plugin.embedsRepository.loadFromCache()
const cache = await this.plugin.database.getMinisearchCache() const cache = await this.plugin.database.getMinisearchCache()
if (cache) { if (cache) {
this.minisearch = await MiniSearch.loadJSAsync( this.minisearch = await MiniSearch.loadJSAsync(
@@ -39,10 +45,11 @@ export class SearchEngine {
} }
/** /**
* Returns the list of documents that need to be reindexed * Returns the list of documents that need to be reindexed or removed,
* either because they are new, have been modified, or have been deleted
* @param docs * @param docs
*/ */
getDiff(docs: DocumentRef[]): { getDocumentsToReindex(docs: DocumentRef[]): {
toAdd: DocumentRef[] toAdd: DocumentRef[]
toRemove: DocumentRef[] toRemove: DocumentRef[]
} { } {
@@ -264,9 +271,9 @@ export class SearchEngine {
} }
} }
// Boost custom properties
const metadata = this.plugin.app.metadataCache.getCache(path) const metadata = this.plugin.app.metadataCache.getCache(path)
if (metadata) { if (metadata) {
// Boost custom properties
for (const { name, weight } of settings.weightCustomProperties) { for (const { name, weight } of settings.weightCustomProperties) {
const values = metadata?.frontmatter?.[name] const values = metadata?.frontmatter?.[name]
if (values && result.terms.some(t => values.includes(t))) { if (values && result.terms.some(t => values.includes(t))) {
@@ -372,6 +379,28 @@ export class SearchEngine {
) )
) )
// Inject embeds for images, documents, and PDFs
for (let i = 0; i < documents.length; i++) {
const doc = documents[i]
const embeds = this.plugin.embedsRepository
.getEmbeds(doc.path)
// Limit to 5 embeds
.slice(0, 5)
for (const embed of embeds) {
// Inject the embed in the content after index i
documents[++i] = await this.plugin.cacheManager.getDocument(embed)
results[i] = {
id: documents[i].path,
score: 0,
terms: [],
queryTerms: [],
match: {},
isEmbed: true,
}
// console.log(documents[i])
}
}
// Map the raw results to get usable suggestions // Map the raw results to get usable suggestions
const resultNotes = results.map(result => { const resultNotes = results.map(result => {
logDebug('Locating matches for', result.id) logDebug('Locating matches for', result.id)
@@ -412,6 +441,7 @@ export class SearchEngine {
score: result.score, score: result.score,
foundWords, foundWords,
matches, matches,
isEmbed: result.isEmbed,
...note, ...note,
} }
return resultNote return resultNote
@@ -419,11 +449,21 @@ export class SearchEngine {
return resultNotes return resultNotes
} }
public async writeToCache(): Promise<void> { /**
await this.plugin.database.writeMinisearchCache( * For cache saving
this.minisearch, */
this.indexedDocuments public getSerializedMiniSearch(): AsPlainObject {
) return this.minisearch.toJSON()
}
/**
* For cache saving
*/
public getSerializedIndexedDocuments(): { path: string; mtime: number }[] {
return Array.from(this.indexedDocuments).map(([path, mtime]) => ({
path,
mtime,
}))
} }
private getOptions(): Options<IndexedDocument> { private getOptions(): Options<IndexedDocument> {

View File

@@ -151,7 +151,7 @@ export function getCtrlKeyLabel(): 'ctrl' | '⌘' {
export function isFileImage(path: string): boolean { export function isFileImage(path: string): boolean {
const ext = getExtension(path) const ext = getExtension(path)
return ext === 'png' || ext === 'jpg' || ext === 'jpeg' || ext === 'webp' return ext === 'png' || ext === 'jpg' || ext === 'jpeg' || ext === 'webp' || ext === 'gif'
} }
export function isFilePDF(path: string): boolean { export function isFilePDF(path: string): boolean {