diff --git a/esbuild.config.mjs b/esbuild.config.mjs index 82cf317..f9d5a53 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -1,7 +1,9 @@ import esbuild from 'esbuild' +import sveltePlugin from 'esbuild-svelte' +import sveltePreprocess from 'svelte-preprocess' +import { copy } from 'esbuild-plugin-copy' import process from 'process' import builtins from 'builtin-modules' -import { copy } from 'esbuild-plugin-copy' import path from 'path' const banner = `/* @@ -47,6 +49,9 @@ esbuild ], outfile: path.join('./dist', 'main.js'), plugins: [ + sveltePlugin({ + preprocess: sveltePreprocess(), + }), copy({ assets: { from: ['./assets/*'], diff --git a/package.json b/package.json index 47ccbd3..f555868 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,14 @@ "author": "", "license": "MIT", "devDependencies": { + "@tsconfig/svelte": "^3.0.0", "@types/node": "^16.11.6", "@typescript-eslint/eslint-plugin": "^5.18.0", "@typescript-eslint/parser": "^5.18.0", "builtin-modules": "^3.2.0", "esbuild": "0.13.12", "esbuild-plugin-copy": "^1.2.1", + "esbuild-svelte": "^0.7.0", "eslint": "7.12.1", "eslint-config-standard": "^16.0.3", "eslint-plugin-import": "2.22.1", @@ -26,8 +28,10 @@ "obsidian": "latest", "prettier": "^2.6.2", "prettier-eslint": "^13.0.0", + "svelte": "^3.47.0", + "svelte-preprocess": "^4.10.6", "tslib": "2.3.1", - "typescript": "4.4.4" + "typescript": "^4.6.3" }, "dependencies": { "markdown-to-txt": "^2.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9eb4bdd..3428ce7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,12 +1,14 @@ lockfileVersion: 5.3 specifiers: + '@tsconfig/svelte': ^3.0.0 '@types/node': ^16.11.6 '@typescript-eslint/eslint-plugin': ^5.18.0 '@typescript-eslint/parser': ^5.18.0 builtin-modules: ^3.2.0 esbuild: 0.13.12 esbuild-plugin-copy: ^1.2.1 + esbuild-svelte: ^0.7.0 eslint: 7.12.1 eslint-config-standard: ^16.0.3 eslint-plugin-import: 2.22.1 @@ -17,30 +19,36 @@ specifiers: obsidian: latest prettier: ^2.6.2 prettier-eslint: ^13.0.0 + svelte: ^3.47.0 + svelte-preprocess: ^4.10.6 tslib: 2.3.1 - typescript: 4.4.4 + typescript: ^4.6.3 dependencies: markdown-to-txt: 2.0.0 minisearch: 5.0.0-beta1 devDependencies: + '@tsconfig/svelte': 3.0.0 '@types/node': 16.11.26 - '@typescript-eslint/eslint-plugin': 5.18.0_1a8b6b4079a82f2b09d10180d5dea1f6 - '@typescript-eslint/parser': 5.18.0_eslint@7.12.1+typescript@4.4.4 + '@typescript-eslint/eslint-plugin': 5.18.0_2e93aa916703472007e9b5dfec98785b + '@typescript-eslint/parser': 5.18.0_eslint@7.12.1+typescript@4.6.3 builtin-modules: 3.2.0 esbuild: 0.13.12 esbuild-plugin-copy: 1.2.1_esbuild@0.13.12 + esbuild-svelte: 0.7.0_esbuild@0.13.12+svelte@3.47.0 eslint: 7.12.1 eslint-config-standard: 16.0.3_0fed5a0754053d34bf68c4e5b9539157 eslint-plugin-import: 2.22.1_eslint@7.12.1 eslint-plugin-node: 11.1.0_eslint@7.12.1 eslint-plugin-promise: 5.0.0_eslint@7.12.1 - obsidian: 0.14.4 + obsidian: 0.14.6 prettier: 2.6.2 prettier-eslint: 13.0.0 + svelte: 3.47.0 + svelte-preprocess: 4.10.6_svelte@3.47.0+typescript@4.6.3 tslib: 2.3.1 - typescript: 4.4.4 + typescript: 4.6.3 packages: @@ -130,6 +138,10 @@ packages: fastq: 1.13.0 dev: true + /@tsconfig/svelte/3.0.0: + resolution: {integrity: sha512-pYrtLtOwku/7r1i9AMONsJMVYAtk3hzOfiGNekhtq5tYBGA7unMve8RvUclKLMT3PrihvJqUmzsRGh0RP84hKg==} + dev: true + /@types/codemirror/0.0.108: resolution: {integrity: sha512-3FGFcus0P7C2UOGCNUVENqObEb4SFk+S8Dnxq7K6aIsLVs/vDtlangl3PEO0ykaKXyK56swVF6Nho7VsA44uhw==} dependencies: @@ -156,13 +168,23 @@ packages: resolution: {integrity: sha512-GZ7bu5A6+4DtG7q9GsoHXy3ALcgeIHP4NnL0Vv2wu0uUB/yQex26v0tf6/na1mm0+bS9Uw+0DFex7aaKr2qawQ==} dev: true + /@types/pug/2.0.6: + resolution: {integrity: sha512-SnHmG9wN1UVmagJOnyo/qkk0Z7gejYxOYYmaAwr5u2yFYfsupN3sg10kyzN8Hep/2zbHxCnsumxOoRIRMBwKCg==} + dev: true + + /@types/sass/1.43.1: + resolution: {integrity: sha512-BPdoIt1lfJ6B7rw35ncdwBZrAssjcwzI5LByIrYs+tpXlj/CAkuVdRsgZDdP4lq5EjyWzwxZCqAoFyHKFwp32g==} + dependencies: + '@types/node': 16.11.26 + dev: true + /@types/tern/0.23.4: resolution: {integrity: sha512-JAUw1iXGO1qaWwEOzxTKJZ/5JxVeON9kvGZ/osgZaJImBnyjyn0cjovPsf6FNLmyGY8Vw9DoXZCMlfMkMwHRWg==} dependencies: '@types/estree': 0.0.51 dev: true - /@typescript-eslint/eslint-plugin/5.18.0_1a8b6b4079a82f2b09d10180d5dea1f6: + /@typescript-eslint/eslint-plugin/5.18.0_2e93aa916703472007e9b5dfec98785b: resolution: {integrity: sha512-tzrmdGMJI/uii9/V6lurMo4/o+dMTKDH82LkNjhJ3adCW22YQydoRs5MwTiqxGF9CSYxPxQ7EYb4jLNlIs+E+A==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -173,18 +195,18 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.18.0_eslint@7.12.1+typescript@4.4.4 + '@typescript-eslint/parser': 5.18.0_eslint@7.12.1+typescript@4.6.3 '@typescript-eslint/scope-manager': 5.18.0 - '@typescript-eslint/type-utils': 5.18.0_eslint@7.12.1+typescript@4.4.4 - '@typescript-eslint/utils': 5.18.0_eslint@7.12.1+typescript@4.4.4 + '@typescript-eslint/type-utils': 5.18.0_eslint@7.12.1+typescript@4.6.3 + '@typescript-eslint/utils': 5.18.0_eslint@7.12.1+typescript@4.6.3 debug: 4.3.4 eslint: 7.12.1 functional-red-black-tree: 1.0.1 ignore: 5.2.0 regexpp: 3.2.0 semver: 7.3.5 - tsutils: 3.21.0_typescript@4.4.4 - typescript: 4.4.4 + tsutils: 3.21.0_typescript@4.6.3 + typescript: 4.6.3 transitivePeerDependencies: - supports-color dev: true @@ -227,7 +249,7 @@ packages: - supports-color dev: true - /@typescript-eslint/parser/5.18.0_eslint@7.12.1+typescript@4.4.4: + /@typescript-eslint/parser/5.18.0_eslint@7.12.1+typescript@4.6.3: resolution: {integrity: sha512-+08nYfurBzSSPndngnHvFw/fniWYJ5ymOrn/63oMIbgomVQOvIDhBoJmYZ9lwQOCnQV9xHGvf88ze3jFGUYooQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -239,10 +261,10 @@ packages: dependencies: '@typescript-eslint/scope-manager': 5.18.0 '@typescript-eslint/types': 5.18.0 - '@typescript-eslint/typescript-estree': 5.18.0_typescript@4.4.4 + '@typescript-eslint/typescript-estree': 5.18.0_typescript@4.6.3 debug: 4.3.4 eslint: 7.12.1 - typescript: 4.4.4 + typescript: 4.6.3 transitivePeerDependencies: - supports-color dev: true @@ -255,7 +277,7 @@ packages: '@typescript-eslint/visitor-keys': 5.18.0 dev: true - /@typescript-eslint/type-utils/5.18.0_eslint@7.12.1+typescript@4.4.4: + /@typescript-eslint/type-utils/5.18.0_eslint@7.12.1+typescript@4.6.3: resolution: {integrity: sha512-vcn9/6J5D6jtHxpEJrgK8FhaM8r6J1/ZiNu70ZUJN554Y3D9t3iovi6u7JF8l/e7FcBIxeuTEidZDR70UuCIfA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -265,11 +287,11 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/utils': 5.18.0_eslint@7.12.1+typescript@4.4.4 + '@typescript-eslint/utils': 5.18.0_eslint@7.12.1+typescript@4.6.3 debug: 4.3.4 eslint: 7.12.1 - tsutils: 3.21.0_typescript@4.4.4 - typescript: 4.4.4 + tsutils: 3.21.0_typescript@4.6.3 + typescript: 4.6.3 transitivePeerDependencies: - supports-color dev: true @@ -306,7 +328,7 @@ packages: - supports-color dev: true - /@typescript-eslint/typescript-estree/5.18.0_typescript@4.4.4: + /@typescript-eslint/typescript-estree/5.18.0_typescript@4.6.3: resolution: {integrity: sha512-wa+2VAhOPpZs1bVij9e5gyVu60ReMi/KuOx4LKjGx2Y3XTNUDJgQ+5f77D49pHtqef/klglf+mibuHs9TrPxdQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -321,13 +343,13 @@ packages: globby: 11.1.0 is-glob: 4.0.3 semver: 7.3.5 - tsutils: 3.21.0_typescript@4.4.4 - typescript: 4.4.4 + tsutils: 3.21.0_typescript@4.6.3 + typescript: 4.6.3 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils/5.18.0_eslint@7.12.1+typescript@4.4.4: + /@typescript-eslint/utils/5.18.0_eslint@7.12.1+typescript@4.6.3: resolution: {integrity: sha512-+hFGWUMMri7OFY26TsOlGa+zgjEy1ssEipxpLjtl4wSll8zy85x0GrUSju/FHdKfVorZPYJLkF3I4XPtnCTewA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -336,7 +358,7 @@ packages: '@types/json-schema': 7.0.11 '@typescript-eslint/scope-manager': 5.18.0 '@typescript-eslint/types': 5.18.0 - '@typescript-eslint/typescript-estree': 5.18.0_typescript@4.4.4 + '@typescript-eslint/typescript-estree': 5.18.0_typescript@4.6.3 eslint: 7.12.1 eslint-scope: 5.1.1 eslint-utils: 3.0.0_eslint@7.12.1 @@ -481,6 +503,10 @@ packages: fill-range: 7.0.1 dev: true + /buffer-crc32/0.2.13: + resolution: {integrity: sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=} + dev: true + /builtin-modules/3.2.0: resolution: {integrity: sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==} engines: {node: '>=6'} @@ -605,6 +631,11 @@ packages: object-keys: 1.1.1 dev: true + /detect-indent/6.1.0: + resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==} + engines: {node: '>=8'} + dev: true + /dir-glob/3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} engines: {node: '>=8'} @@ -683,6 +714,10 @@ packages: is-symbol: 1.0.4 dev: true + /es6-promise/3.3.1: + resolution: {integrity: sha1-oIzd6EzNvzTQJ6FFG8kdS80ophM=} + dev: true + /esbuild-android-arm64/0.13.12: resolution: {integrity: sha512-TSVZVrb4EIXz6KaYjXfTzPyyRpXV5zgYIADXtQsIenjZ78myvDGaPi11o4ZSaHIwFHsuwkB6ne5SZRBwAQ7maw==} cpu: [arm64] @@ -806,6 +841,17 @@ packages: dev: true optional: true + /esbuild-svelte/0.7.0_esbuild@0.13.12+svelte@3.47.0: + resolution: {integrity: sha512-hfiauhEXtGocUf7oVcxTrLhhF57ajBbvNCCClsS3KntEeITddKU+1WFhmsCt9SO0dQJlCFzJtpPu2dI7dRkXBw==} + engines: {node: '>=12'} + peerDependencies: + esbuild: '>=0.9.6' + svelte: '>=3.43.0' + dependencies: + esbuild: 0.13.12 + svelte: 3.47.0 + dev: true + /esbuild-windows-32/0.13.12: resolution: {integrity: sha512-L9m4lLFQrFeR7F+eLZXG82SbXZfUhyfu6CexZEil6vm+lc7GDCE0Q8DiNutkpzjv1+RAbIGVva9muItQ7HVTkQ==} cpu: [ia32] @@ -1525,6 +1571,12 @@ packages: yallist: 4.0.0 dev: true + /magic-string/0.25.9: + resolution: {integrity: sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==} + dependencies: + sourcemap-codec: 1.4.8 + dev: true + /markdown-to-txt/2.0.0: resolution: {integrity: sha512-H5DSAY6frUQ6/CR0nJMlGCEuSA3pvi14dYfICJPKLAvd/rDk6eb+cj84zU5XTNYzECyCcujoAL1PHhjmOgeqUw==} dependencies: @@ -1552,6 +1604,11 @@ packages: picomatch: 2.3.1 dev: true + /min-indent/1.0.1: + resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} + engines: {node: '>=4'} + dev: true + /minimatch/3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} dependencies: @@ -1573,8 +1630,8 @@ packages: minimist: 1.2.6 dev: true - /moment/2.29.1: - resolution: {integrity: sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==} + /moment/2.29.2: + resolution: {integrity: sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg==} dev: true /ms/2.0.0: @@ -1626,13 +1683,13 @@ packages: es-abstract: 1.19.2 dev: true - /obsidian/0.14.4: - resolution: {integrity: sha512-lWU1w/NlXuswAa35ImAbyElLOOno1C13KCZE19kqtcxSPIquvi5Fzy8zBbQ6ZRZZvkvftUiToCp5lcZFRMGxrQ==} + /obsidian/0.14.6: + resolution: {integrity: sha512-oXPJ8Zt10WhN19bk5l4mZuXRZbbdT1QoMgxGGJ0bB7UcJa0bozDzugS5L/QiV9gDoujpUPxDWNVahEel6r0Fpw==} dependencies: '@codemirror/state': 0.19.9 '@codemirror/view': 0.19.48 '@types/codemirror': 0.0.108 - moment: 2.29.1 + moment: 2.29.2 dev: true /once/1.4.0: @@ -1837,6 +1894,15 @@ packages: queue-microtask: 1.2.3 dev: true + /sander/0.5.1: + resolution: {integrity: sha1-dB4kXiMfB8r7b98PEzrfohalAq0=} + dependencies: + es6-promise: 3.3.1 + graceful-fs: 4.2.9 + mkdirp: 0.5.6 + rimraf: 2.6.3 + dev: true + /semver/5.7.1: resolution: {integrity: sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==} hasBin: true @@ -1889,6 +1955,20 @@ packages: is-fullwidth-code-point: 2.0.0 dev: true + /sorcery/0.10.0: + resolution: {integrity: sha1-iukK19fLBfxZ8asMY3hF1cFaUrc=} + hasBin: true + dependencies: + buffer-crc32: 0.2.13 + minimist: 1.2.6 + sander: 0.5.1 + sourcemap-codec: 1.4.8 + dev: true + + /sourcemap-codec/1.4.8: + resolution: {integrity: sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==} + dev: true + /spdx-correct/3.1.1: resolution: {integrity: sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==} dependencies: @@ -1964,6 +2044,13 @@ packages: engines: {node: '>=4'} dev: true + /strip-indent/3.0.0: + resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} + engines: {node: '>=8'} + dependencies: + min-indent: 1.0.1 + dev: true + /strip-json-comments/3.1.1: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} engines: {node: '>=8'} @@ -1997,6 +2084,62 @@ packages: engines: {node: '>= 0.4'} dev: true + /svelte-preprocess/4.10.6_svelte@3.47.0+typescript@4.6.3: + resolution: {integrity: sha512-I2SV1w/AveMvgIQlUF/ZOO3PYVnhxfcpNyGt8pxpUVhPfyfL/CZBkkw/KPfuFix5FJ9TnnNYMhACK3DtSaYVVQ==} + engines: {node: '>= 9.11.2'} + requiresBuild: true + peerDependencies: + '@babel/core': ^7.10.2 + coffeescript: ^2.5.1 + less: ^3.11.3 || ^4.0.0 + node-sass: '*' + postcss: ^7 || ^8 + postcss-load-config: ^2.1.0 || ^3.0.0 + pug: ^3.0.0 + sass: ^1.26.8 + stylus: ^0.55.0 + sugarss: ^2.0.0 + svelte: ^3.23.0 + typescript: ^3.9.5 || ^4.0.0 + peerDependenciesMeta: + '@babel/core': + optional: true + coffeescript: + optional: true + less: + optional: true + node-sass: + optional: true + postcss: + optional: true + postcss-load-config: + optional: true + pug: + optional: true + sass: + optional: true + stylus: + optional: true + sugarss: + optional: true + typescript: + optional: true + dependencies: + '@types/pug': 2.0.6 + '@types/sass': 1.43.1 + detect-indent: 6.1.0 + magic-string: 0.25.9 + sorcery: 0.10.0 + strip-indent: 3.0.0 + svelte: 3.47.0 + typescript: 4.6.3 + dev: true + + /svelte/3.47.0: + resolution: {integrity: sha512-4JaJp3HEoTCGARRWZQIZDUanhYv0iyoHikklVHVLH9xFE9db22g4TDv7CPeNA8HD1JgjXI1vlhR1JZvvhaTu2Q==} + engines: {node: '>= 8'} + dev: true + /table/5.4.6: resolution: {integrity: sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==} engines: {node: '>=6.0.0'} @@ -2045,14 +2188,14 @@ packages: typescript: 3.9.10 dev: true - /tsutils/3.21.0_typescript@4.4.4: + /tsutils/3.21.0_typescript@4.6.3: resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} engines: {node: '>= 6'} peerDependencies: typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' dependencies: tslib: 1.14.1 - typescript: 4.4.4 + typescript: 4.6.3 dev: true /type-check/0.4.0: @@ -2073,8 +2216,8 @@ packages: hasBin: true dev: true - /typescript/4.4.4: - resolution: {integrity: sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==} + /typescript/4.6.3: + resolution: {integrity: sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==} engines: {node: '>=4.2.0'} hasBin: true dev: true diff --git a/src/Component.svelte b/src/Component.svelte new file mode 100644 index 0000000..38520a9 --- /dev/null +++ b/src/Component.svelte @@ -0,0 +1,11 @@ + + +
My number is {variable}!
+ + diff --git a/src/main.ts b/src/main.ts index 9dabc41..000f9ec 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,11 +1,7 @@ import { Notice, Plugin, TAbstractFile, TFile } from 'obsidian' import MiniSearch from 'minisearch' -import { - clearContent, - extractHeadingsFromCache, - wait, -} from './utils' -import { IndexedNote } from './globals' +import { clearContent, extractHeadingsFromCache, wait } from './utils' +import type { IndexedNote } from './globals' import { OmnisearchModal } from './modal' export default class OmnisearchPlugin extends Plugin { @@ -108,9 +104,15 @@ export default class OmnisearchPlugin extends Plugin { basename: file.basename, content: tmp.innerText, path: file.path, - headings1: fileCache ? extractHeadingsFromCache(fileCache, 1).join(' ') : '', - headings2: fileCache ? extractHeadingsFromCache(fileCache, 2).join(' ') : '', - headings3: fileCache ? extractHeadingsFromCache(fileCache, 3).join(' ') : '', + headings1: fileCache + ? extractHeadingsFromCache(fileCache, 1).join(' ') + : '', + headings2: fileCache + ? extractHeadingsFromCache(fileCache, 2).join(' ') + : '', + headings3: fileCache + ? extractHeadingsFromCache(fileCache, 3).join(' ') + : '', } this.minisearch.add(note) this.indexedNotes[file.path] = note diff --git a/src/modal.ts b/src/modal.ts index 952f8a8..72b29e5 100644 --- a/src/modal.ts +++ b/src/modal.ts @@ -1,7 +1,8 @@ import { MarkdownView, SuggestModal, TFile } from 'obsidian' -import { ResultNote } from './globals' -import OmnisearchPlugin from './main' +import type { ResultNote } from './globals' +import type OmnisearchPlugin from './main' import { escapeRegex, getAllIndexes, highlighter } from './utils' +import Component from './Component.svelte' export class OmnisearchModal extends SuggestModal { private plugin: OmnisearchPlugin @@ -64,7 +65,8 @@ export class OmnisearchModal extends SuggestModal { const record = events.find(event => (event.target as HTMLDivElement).classList.contains('is-selected'), ) - const id = (record?.target as HTMLElement)?.getAttribute('data-note-id') ?? null + const id = + (record?.target as HTMLElement)?.getAttribute('data-note-id') ?? null if (id) { this.selectedNoteId = id } @@ -160,6 +162,10 @@ export class OmnisearchModal extends SuggestModal { } renderSuggestion(value: ResultNote, el: HTMLElement): void { + const component = new Component({ + target: el, + props: { variable: 1 }, + }) el.setAttribute('data-note-id', value.path) el.addClass('omnisearch-result') diff --git a/tsconfig.json b/tsconfig.json index f70dba1..20f2ab0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,12 @@ { + "extends": "@tsconfig/svelte/tsconfig.json", "compilerOptions": { + "types": [ + "svelte", + "node" + ], "strict": true, "baseUrl": ".", - "inlineSourceMap": true, - "inlineSources": true, "module": "ESNext", "target": "ES6", "allowJs": true, @@ -21,4 +24,4 @@ "include": [ "**/*.ts" ] -} +} \ No newline at end of file