@lapis-notes/api 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/LICENSE.md +4 -0
- package/README.md +43 -0
- package/dist/__tests__/data-adapter-conformance.js +205 -0
- package/dist/__tests__/lapis-runtime-manifest.js +32 -0
- package/dist/__tests__/svelte-internal-client.d.ts +3 -0
- package/dist/agent-result-views.d.ts +52 -0
- package/dist/agent-result-views.js +89 -0
- package/dist/agent-skills.d.ts +99 -0
- package/dist/agent-skills.js +182 -0
- package/dist/agent-tools.d.ts +92 -0
- package/dist/agent-tools.js +139 -0
- package/dist/app-database-host.d.ts +4 -0
- package/dist/app-database-host.js +4 -0
- package/dist/app-shell-plugin-persistence.d.ts +15 -0
- package/dist/app-shell-plugin-persistence.js +34 -0
- package/dist/app-url.d.ts +54 -0
- package/dist/app-url.js +269 -0
- package/dist/application-compatibility.d.ts +31 -0
- package/dist/application-compatibility.js +64 -0
- package/dist/application-state.svelte.d.ts +14 -0
- package/dist/application-state.svelte.js +30 -0
- package/dist/assets/lapis-logo.svg +471 -0
- package/dist/bases.d.ts +281 -0
- package/dist/bases.js +475 -0
- package/dist/cache.svelte.d.ts +569 -0
- package/dist/cache.svelte.js +1433 -0
- package/dist/command.svelte.d.ts +337 -0
- package/dist/command.svelte.js +571 -0
- package/dist/compat.d.ts +29 -0
- package/dist/compat.js +30 -0
- package/dist/components/configuration/configuration.css +199 -0
- package/dist/components/configuration/date-setting.svelte +71 -0
- package/dist/components/configuration/date-setting.svelte.d.ts +8 -0
- package/dist/components/configuration/list-setting.svelte +128 -0
- package/dist/components/configuration/list-setting.svelte.d.ts +13 -0
- package/dist/components/configuration/object-array-row-grip.svelte +78 -0
- package/dist/components/configuration/object-array-row-grip.svelte.d.ts +9 -0
- package/dist/components/configuration/object-array-row.svelte +163 -0
- package/dist/components/configuration/object-array-row.svelte.d.ts +19 -0
- package/dist/components/configuration/object-array-setting.svelte +196 -0
- package/dist/components/configuration/object-array-setting.svelte.d.ts +15 -0
- package/dist/components/configuration/object-array-table-dnd.d.ts +8 -0
- package/dist/components/configuration/object-array-table-dnd.js +10 -0
- package/dist/components/configuration/object-array-utils.d.ts +11 -0
- package/dist/components/configuration/object-array-utils.js +103 -0
- package/dist/components/configuration/object-grid-setting.svelte +79 -0
- package/dist/components/configuration/object-grid-setting.svelte.d.ts +10 -0
- package/dist/components/configuration/object-map-row.svelte +147 -0
- package/dist/components/configuration/object-map-row.svelte.d.ts +15 -0
- package/dist/components/configuration/object-map-setting.svelte +137 -0
- package/dist/components/configuration/object-map-setting.svelte.d.ts +14 -0
- package/dist/components/configuration/object-map-types.d.ts +5 -0
- package/dist/components/configuration/object-map-types.js +1 -0
- package/dist/components/configuration/options-combobox-setting.svelte +129 -0
- package/dist/components/configuration/options-combobox-setting.svelte.d.ts +12 -0
- package/dist/components/copy-button/button.svelte +93 -0
- package/dist/components/copy-button/button.svelte.d.ts +13 -0
- package/dist/components/copy-button/index.d.ts +2 -0
- package/dist/components/copy-button/index.js +2 -0
- package/dist/components/editor/editor.css +565 -0
- package/dist/components/editor/editor.d.ts +33 -0
- package/dist/components/editor/editor.js +132 -0
- package/dist/components/editor/editor.svelte +176 -0
- package/dist/components/editor/editor.svelte.d.ts +15 -0
- package/dist/components/editor/embedded-editor-surface.d.ts +12 -0
- package/dist/components/editor/embedded-editor-surface.js +22 -0
- package/dist/components/editor/embedded-editor-surface.svelte +115 -0
- package/dist/components/editor/embedded-editor-surface.svelte.d.ts +17 -0
- package/dist/components/editor/extensions/autocomplete/index.d.ts +2 -0
- package/dist/components/editor/extensions/autocomplete/index.js +2 -0
- package/dist/components/editor/extensions/autocomplete/lapis-code-mirror-autocomplete.d.ts +16 -0
- package/dist/components/editor/extensions/autocomplete/lapis-code-mirror-autocomplete.js +34 -0
- package/dist/components/editor/extensions/autocomplete/vault-completion-sources.d.ts +27 -0
- package/dist/components/editor/extensions/autocomplete/vault-completion-sources.js +55 -0
- package/dist/components/editor/extensions/class-highlighter/index.d.ts +1 -0
- package/dist/components/editor/extensions/class-highlighter/index.js +47 -0
- package/dist/components/editor/extensions/fold-gutter/index.d.ts +8 -0
- package/dist/components/editor/extensions/fold-gutter/index.js +40 -0
- package/dist/components/editor/extensions/gutter-line-style-sync/index.d.ts +2 -0
- package/dist/components/editor/extensions/gutter-line-style-sync/index.js +118 -0
- package/dist/components/editor/extensions/lint/index.d.ts +4 -0
- package/dist/components/editor/extensions/lint/index.js +4 -0
- package/dist/components/editor/extensions/lint/lapis-code-mirror-lint.d.ts +26 -0
- package/dist/components/editor/extensions/lint/lapis-code-mirror-lint.js +101 -0
- package/dist/components/editor/extensions/lint/lapis-lint-diagnostic-helpers.d.ts +8 -0
- package/dist/components/editor/extensions/lint/lapis-lint-diagnostic-helpers.js +7 -0
- package/dist/components/editor/extensions/lint/lapis-lint-diagnostic.d.ts +20 -0
- package/dist/components/editor/extensions/lint/lapis-lint-diagnostic.js +47 -0
- package/dist/components/editor/extensions/lint/lapis-lint-hover-tooltip.d.ts +9 -0
- package/dist/components/editor/extensions/lint/lapis-lint-hover-tooltip.js +373 -0
- package/dist/components/editor/extensions/lint/lapis-lint-inline-widget.d.ts +31 -0
- package/dist/components/editor/extensions/lint/lapis-lint-inline-widget.js +191 -0
- package/dist/components/editor/extensions/lint/lapis-lint-tooltip.svelte +176 -0
- package/dist/components/editor/extensions/lint/lapis-lint-tooltip.svelte.d.ts +15 -0
- package/dist/components/editor/extensions/lint/lint-tooltip-actions.d.ts +11 -0
- package/dist/components/editor/extensions/lint/lint-tooltip-actions.js +21 -0
- package/dist/components/editor/extensions/lint/mount-lint-tooltip.d.ts +16 -0
- package/dist/components/editor/extensions/lint/mount-lint-tooltip.js +60 -0
- package/dist/components/editor/extensions/search/dom.d.ts +2 -0
- package/dist/components/editor/extensions/search/dom.js +6 -0
- package/dist/components/editor/extensions/search/index.d.ts +35 -0
- package/dist/components/editor/extensions/search/index.js +44 -0
- package/dist/components/editor/extensions/search/search.svelte +335 -0
- package/dist/components/editor/extensions/search/search.svelte.d.ts +8 -0
- package/dist/components/editor/index.d.ts +9 -0
- package/dist/components/editor/index.js +9 -0
- package/dist/components/editor/language-service/dom.d.ts +1 -0
- package/dist/components/editor/language-service/dom.js +6 -0
- package/dist/components/editor/language-service/index.d.ts +28 -0
- package/dist/components/editor/language-service/index.js +342 -0
- package/dist/components/empty-view/empty-view.css +39 -0
- package/dist/components/empty-view/empty-view.svelte +26 -0
- package/dist/components/empty-view/empty-view.svelte.d.ts +9 -0
- package/dist/components/empty-view/index.d.ts +2 -0
- package/dist/components/empty-view/index.js +2 -0
- package/dist/components/icon/icon-list.css +74 -0
- package/dist/components/icon/icon-list.svelte +213 -0
- package/dist/components/icon/icon-list.svelte.d.ts +11 -0
- package/dist/components/icon/icon.svelte +15 -0
- package/dist/components/icon/icon.svelte.d.ts +7 -0
- package/dist/components/icon/index.d.ts +3 -0
- package/dist/components/icon/index.js +3 -0
- package/dist/components/menu/context-menu.svelte +89 -0
- package/dist/components/menu/context-menu.svelte.d.ts +11 -0
- package/dist/components/menu/drawer-menu.svelte +83 -0
- package/dist/components/menu/drawer-menu.svelte.d.ts +8 -0
- package/dist/components/menu/dropdown-menu.svelte +89 -0
- package/dist/components/menu/dropdown-menu.svelte.d.ts +11 -0
- package/dist/components/menu/index.d.ts +6 -0
- package/dist/components/menu/index.js +6 -0
- package/dist/components/menu/menu.css +139 -0
- package/dist/components/menu/menu.svelte +37 -0
- package/dist/components/menu/menu.svelte.d.ts +11 -0
- package/dist/components/menu/mobile-menu-query.svelte.d.ts +3 -0
- package/dist/components/menu/mobile-menu-query.svelte.js +21 -0
- package/dist/components/menu/popover-menu.svelte +90 -0
- package/dist/components/menu/popover-menu.svelte.d.ts +10 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +2 -0
- package/dist/components/select/select.svelte +72 -0
- package/dist/components/select/select.svelte.d.ts +25 -0
- package/dist/configuration-option-source-providers.d.ts +17 -0
- package/dist/configuration-option-source-providers.js +59 -0
- package/dist/configuration-option-source-registry.d.ts +59 -0
- package/dist/configuration-option-source-registry.js +123 -0
- package/dist/configuration.svelte.d.ts +258 -0
- package/dist/configuration.svelte.js +887 -0
- package/dist/context-keys.svelte.d.ts +42 -0
- package/dist/context-keys.svelte.js +278 -0
- package/dist/context.svelte.d.ts +247 -0
- package/dist/context.svelte.js +540 -0
- package/dist/daily-document-provider.d.ts +38 -0
- package/dist/daily-document-provider.js +176 -0
- package/dist/design-core-button-types.d.ts +7 -0
- package/dist/design-core-button-types.js +1 -0
- package/dist/diagnostics.d.ts +93 -0
- package/dist/diagnostics.js +84 -0
- package/dist/dialog-portal.d.ts +3 -0
- package/dist/dialog-portal.js +3 -0
- package/dist/docs-api.d.ts +44 -0
- package/dist/docs-api.js +29 -0
- package/dist/editor-view-registry.d.ts +35 -0
- package/dist/editor-view-registry.js +112 -0
- package/dist/editor.svelte.d.ts +126 -0
- package/dist/editor.svelte.js +454 -0
- package/dist/embed-registry.d.ts +15 -0
- package/dist/embed-registry.js +16 -0
- package/dist/enhance.d.ts +111 -0
- package/dist/enhance.js +309 -0
- package/dist/events.d.ts +28 -0
- package/dist/events.js +49 -0
- package/dist/file-manager.d.ts +90 -0
- package/dist/file-manager.js +289 -0
- package/dist/file-tools/app-tools.d.ts +3 -0
- package/dist/file-tools/app-tools.js +242 -0
- package/dist/file-tools/index.d.ts +3 -0
- package/dist/file-tools/index.js +3 -0
- package/dist/file-tools/paths.d.ts +14 -0
- package/dist/file-tools/paths.js +33 -0
- package/dist/file-tools/vault-operations.d.ts +3 -0
- package/dist/file-tools/vault-operations.js +60 -0
- package/dist/generated/plugin-host-modules.schema.generated.d.ts +371 -0
- package/dist/generated/plugin-host-modules.schema.generated.js +374 -0
- package/dist/glob.d.ts +15 -0
- package/dist/glob.js +68 -0
- package/dist/history.svelte.d.ts +24 -0
- package/dist/history.svelte.js +74 -0
- package/dist/hooks/createVirtualizer.svelte.d.ts +7 -0
- package/dist/hooks/createVirtualizer.svelte.js +70 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/is-mobile.svelte.d.ts +5 -0
- package/dist/hooks/is-mobile.svelte.js +23 -0
- package/dist/hooks/mountComponent.svelte.d.ts +7 -0
- package/dist/hooks/mountComponent.svelte.js +16 -0
- package/dist/hooks/use-text-highlight.d.ts +17 -0
- package/dist/hooks/use-text-highlight.js +82 -0
- package/dist/hooks/useBoundingRect.svelte.d.ts +11 -0
- package/dist/hooks/useBoundingRect.svelte.js +46 -0
- package/dist/icons/index.d.ts +57 -0
- package/dist/icons/index.js +288 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.js +87 -0
- package/dist/language-service/index.d.ts +9 -0
- package/dist/language-service/index.js +7 -0
- package/dist/language-service/manager.d.ts +47 -0
- package/dist/language-service/manager.js +404 -0
- package/dist/language-service/types.d.ts +92 -0
- package/dist/language-service/types.js +1 -0
- package/dist/language-service/virtual-document.d.ts +11 -0
- package/dist/language-service/virtual-document.js +45 -0
- package/dist/language-service/worker-protocol.d.ts +63 -0
- package/dist/language-service/worker-protocol.js +1 -0
- package/dist/language-service/worker-provider.d.ts +9 -0
- package/dist/language-service/worker-provider.js +38 -0
- package/dist/lapis-extension.d.ts +244 -0
- package/dist/lapis-extension.js +591 -0
- package/dist/links.d.ts +34 -0
- package/dist/links.js +191 -0
- package/dist/loaders.d.ts +9 -0
- package/dist/loaders.js +59 -0
- package/dist/localization-manager.svelte.d.ts +56 -0
- package/dist/localization-manager.svelte.js +157 -0
- package/dist/logging.d.ts +172 -0
- package/dist/logging.js +352 -0
- package/dist/markdown-extension-registry.d.ts +31 -0
- package/dist/markdown-extension-registry.js +31 -0
- package/dist/markdown-file-surface-registry.d.ts +25 -0
- package/dist/markdown-file-surface-registry.js +23 -0
- package/dist/markdown.d.ts +205 -0
- package/dist/markdown.js +147 -0
- package/dist/menu-utils.d.ts +1 -0
- package/dist/menu-utils.js +47 -0
- package/dist/menu.svelte.d.ts +121 -0
- package/dist/menu.svelte.js +295 -0
- package/dist/metadata-value.d.ts +10 -0
- package/dist/metadata-value.js +173 -0
- package/dist/metadata.svelte.d.ts +106 -0
- package/dist/metadata.svelte.js +608 -0
- package/dist/notifications.d.ts +209 -0
- package/dist/notifications.js +338 -0
- package/dist/open-file.d.ts +23 -0
- package/dist/open-file.js +102 -0
- package/dist/platform.d.ts +86 -0
- package/dist/platform.js +86 -0
- package/dist/plugin-asset-server.d.ts +60 -0
- package/dist/plugin-asset-server.js +222 -0
- package/dist/plugin-assets.d.ts +4 -0
- package/dist/plugin-assets.js +3 -0
- package/dist/plugin-capability-facade.d.ts +104 -0
- package/dist/plugin-capability-facade.js +61 -0
- package/dist/plugin-dependency-resolver.d.ts +36 -0
- package/dist/plugin-dependency-resolver.js +54 -0
- package/dist/plugin-dependency-scanner.d.ts +9 -0
- package/dist/plugin-dependency-scanner.js +274 -0
- package/dist/plugin-distribution/canonical-json.d.ts +1 -0
- package/dist/plugin-distribution/canonical-json.js +40 -0
- package/dist/plugin-distribution/compatibility.d.ts +5 -0
- package/dist/plugin-distribution/compatibility.js +38 -0
- package/dist/plugin-distribution/errors.d.ts +11 -0
- package/dist/plugin-distribution/errors.js +13 -0
- package/dist/plugin-distribution/hashes.d.ts +2 -0
- package/dist/plugin-distribution/hashes.js +17 -0
- package/dist/plugin-distribution/index.d.ts +18 -0
- package/dist/plugin-distribution/index.js +18 -0
- package/dist/plugin-distribution/installed-plugin-state.d.ts +20 -0
- package/dist/plugin-distribution/installed-plugin-state.js +73 -0
- package/dist/plugin-distribution/installer.d.ts +89 -0
- package/dist/plugin-distribution/installer.js +395 -0
- package/dist/plugin-distribution/manager.d.ts +128 -0
- package/dist/plugin-distribution/manager.js +358 -0
- package/dist/plugin-distribution/path-safety.d.ts +2 -0
- package/dist/plugin-distribution/path-safety.js +20 -0
- package/dist/plugin-distribution/plugin-bundle-verifier.d.ts +28 -0
- package/dist/plugin-distribution/plugin-bundle-verifier.js +96 -0
- package/dist/plugin-distribution/plugin-bundle-worker.d.ts +34 -0
- package/dist/plugin-distribution/plugin-bundle-worker.js +99 -0
- package/dist/plugin-distribution/plugin-bundle.d.ts +16 -0
- package/dist/plugin-distribution/plugin-bundle.js +244 -0
- package/dist/plugin-distribution/plugin-bundle.worker.d.ts +1 -0
- package/dist/plugin-distribution/plugin-bundle.worker.js +38 -0
- package/dist/plugin-distribution/registry-cache.d.ts +26 -0
- package/dist/plugin-distribution/registry-cache.js +85 -0
- package/dist/plugin-distribution/registry-client.d.ts +36 -0
- package/dist/plugin-distribution/registry-client.js +115 -0
- package/dist/plugin-distribution/reserved-ids.d.ts +4 -0
- package/dist/plugin-distribution/reserved-ids.js +10 -0
- package/dist/plugin-distribution/runtime-validation.d.ts +14 -0
- package/dist/plugin-distribution/runtime-validation.js +388 -0
- package/dist/plugin-distribution/schemas.d.ts +4895 -0
- package/dist/plugin-distribution/schemas.js +299 -0
- package/dist/plugin-distribution/signing.d.ts +5 -0
- package/dist/plugin-distribution/signing.js +38 -0
- package/dist/plugin-distribution/types.d.ts +217 -0
- package/dist/plugin-distribution/types.js +1 -0
- package/dist/plugin-install-progress.d.ts +15 -0
- package/dist/plugin-install-progress.js +86 -0
- package/dist/plugin-manager.d.ts +306 -0
- package/dist/plugin-manager.js +2848 -0
- package/dist/plugin-runtime-entry.d.ts +19 -0
- package/dist/plugin-runtime-entry.js +135 -0
- package/dist/plugin.d.ts +350 -0
- package/dist/plugin.js +754 -0
- package/dist/popover.d.ts +20 -0
- package/dist/popover.js +32 -0
- package/dist/promise-worker.d.ts +22 -0
- package/dist/promise-worker.js +65 -0
- package/dist/prompt-confirm.d.ts +9 -0
- package/dist/prompt-confirm.js +33 -0
- package/dist/search-document-provider.d.ts +45 -0
- package/dist/search-document-provider.js +54 -0
- package/dist/search-query/index.d.ts +78 -0
- package/dist/search-query/index.js +426 -0
- package/dist/search-query/parser.d.ts +3 -0
- package/dist/search-query/parser.js +16 -0
- package/dist/search-query/parser.terms.js +26 -0
- package/dist/search-query/search-query.grammar +128 -0
- package/dist/search.d.ts +19 -0
- package/dist/search.js +104 -0
- package/dist/setting-section-layout.d.ts +19 -0
- package/dist/setting-section-layout.js +194 -0
- package/dist/settings.svelte.d.ts +474 -0
- package/dist/settings.svelte.js +1421 -0
- package/dist/source-text-file-view.d.ts +25 -0
- package/dist/source-text-file-view.js +78 -0
- package/dist/status-bar.svelte.d.ts +29 -0
- package/dist/status-bar.svelte.js +72 -0
- package/dist/storage/app-database.d.ts +860 -0
- package/dist/storage/app-database.js +2372 -0
- package/dist/storage/blob-store.d.ts +12 -0
- package/dist/storage/blob-store.js +1 -0
- package/dist/storage/browser-app-database-coordination.d.ts +35 -0
- package/dist/storage/browser-app-database-coordination.js +207 -0
- package/dist/storage/browser-coordinated-app-database.d.ts +109 -0
- package/dist/storage/browser-coordinated-app-database.js +704 -0
- package/dist/storage/browser.d.ts +153 -0
- package/dist/storage/browser.js +794 -0
- package/dist/storage/desktop-native.d.ts +184 -0
- package/dist/storage/desktop-native.js +415 -0
- package/dist/storage/fs.d.ts +188 -0
- package/dist/storage/fs.js +307 -0
- package/dist/storage/index-projection.d.ts +236 -0
- package/dist/storage/index-projection.js +402 -0
- package/dist/storage/index.d.ts +17 -0
- package/dist/storage/index.js +17 -0
- package/dist/storage/keyval.d.ts +94 -0
- package/dist/storage/keyval.js +199 -0
- package/dist/storage/memory-vault-adapter.d.ts +44 -0
- package/dist/storage/memory-vault-adapter.js +351 -0
- package/dist/storage/native-vault-bootstrap-kv.d.ts +22 -0
- package/dist/storage/native-vault-bootstrap-kv.js +96 -0
- package/dist/storage/path.d.ts +22 -0
- package/dist/storage/path.js +110 -0
- package/dist/storage/search-embedding-provider.d.ts +75 -0
- package/dist/storage/search-embedding-provider.js +446 -0
- package/dist/storage/search-embedding-worker.d.ts +1 -0
- package/dist/storage/search-embedding-worker.js +63 -0
- package/dist/storage/search-query-evaluator.d.ts +14 -0
- package/dist/storage/search-query-evaluator.js +678 -0
- package/dist/storage/task-projection.d.ts +152 -0
- package/dist/storage/task-projection.js +154 -0
- package/dist/storage/turso-app-database.d.ts +150 -0
- package/dist/storage/turso-app-database.js +2671 -0
- package/dist/storage/vault-session.d.ts +37 -0
- package/dist/storage/vault-session.js +196 -0
- package/dist/storage/vault-state.d.ts +74 -0
- package/dist/storage/vault-state.js +181 -0
- package/dist/storage/vault.svelte.d.ts +257 -0
- package/dist/storage/vault.svelte.js +661 -0
- package/dist/suggest.d.ts +193 -0
- package/dist/suggest.js +391 -0
- package/dist/tasks.d.ts +7 -0
- package/dist/tasks.js +18 -0
- package/dist/telemetry.d.ts +116 -0
- package/dist/telemetry.js +103 -0
- package/dist/utils.d.ts +55 -0
- package/dist/utils.js +314 -0
- package/dist/vault-api.d.ts +5 -0
- package/dist/vault-api.js +3 -0
- package/dist/vault-maintenance-commands.d.ts +5 -0
- package/dist/vault-maintenance-commands.js +32 -0
- package/dist/view.svelte.d.ts +215 -0
- package/dist/view.svelte.js +381 -0
- package/dist/vite-env.d.ts +2 -0
- package/dist/workspace-host-internal.d.ts +7 -0
- package/dist/workspace-host-internal.js +7 -0
- package/dist/workspace-host.d.ts +10 -0
- package/dist/workspace-host.js +14 -0
- package/dist/workspace-layout-commands.d.ts +3 -0
- package/dist/workspace-layout-commands.js +72 -0
- package/dist/workspace-layout-normalizer.d.ts +92 -0
- package/dist/workspace-layout-normalizer.js +301 -0
- package/dist/workspace-layouts.d.ts +7 -0
- package/dist/workspace-layouts.js +23 -0
- package/dist/workspace-trust.d.ts +32 -0
- package/dist/workspace-trust.js +72 -0
- package/dist/workspace.svelte.d.ts +796 -0
- package/dist/workspace.svelte.js +4380 -0
- package/package.json +240 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { indentUnit } from "@codemirror/language";
|
|
2
|
+
import { Compartment, EditorState } from "@codemirror/state";
|
|
3
|
+
import { EditorView, GutterMarker, keymap, lineNumbers, } from "@codemirror/view";
|
|
4
|
+
import { indentMore, indentLess } from "@codemirror/commands";
|
|
5
|
+
import { createBaseCodeMirrorExtensions } from "@lapismd/mira/codemirror";
|
|
6
|
+
import { foldGutter } from "./extensions/fold-gutter";
|
|
7
|
+
import { resolveApplication } from "../../application-compatibility";
|
|
8
|
+
export class BlockLineMarker extends GutterMarker {
|
|
9
|
+
from;
|
|
10
|
+
to;
|
|
11
|
+
constructor(from, to) {
|
|
12
|
+
super();
|
|
13
|
+
this.from = from;
|
|
14
|
+
this.to = to;
|
|
15
|
+
}
|
|
16
|
+
eq(other) {
|
|
17
|
+
return this.from === other.from && this.to === other.to;
|
|
18
|
+
}
|
|
19
|
+
toDOM() {
|
|
20
|
+
const div = createDiv();
|
|
21
|
+
div.className = "cm-line-block";
|
|
22
|
+
div.createDiv({ cls: "" }).setText(this.from.toString());
|
|
23
|
+
if (this.from !== this.to) {
|
|
24
|
+
const mid = Math.floor((this.from + this.to) / 2);
|
|
25
|
+
div.createDiv({ cls: "" }).setText(mid.toString());
|
|
26
|
+
div.createDiv({ cls: "" }).setText(this.to.toString());
|
|
27
|
+
}
|
|
28
|
+
return div;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class EditorConfig {
|
|
32
|
+
configs = {};
|
|
33
|
+
register(key, controller) {
|
|
34
|
+
const compartment = new Compartment();
|
|
35
|
+
this.configs[key] = { config: compartment, controller };
|
|
36
|
+
}
|
|
37
|
+
has(key) {
|
|
38
|
+
return !!this.configs[key];
|
|
39
|
+
}
|
|
40
|
+
extension(application) {
|
|
41
|
+
const app = resolveApplication(application);
|
|
42
|
+
const config = app.configuration.getConfiguration();
|
|
43
|
+
return Object.entries(this.configs).map(([key, props]) => props.config.of(props.controller(config.get(key), app) || []));
|
|
44
|
+
}
|
|
45
|
+
update(view, key, value, application) {
|
|
46
|
+
if (!this.has(key))
|
|
47
|
+
return;
|
|
48
|
+
const app = resolveApplication(application);
|
|
49
|
+
const props = this.configs[key];
|
|
50
|
+
const configValue = value ?? app.configuration.getConfiguration().get(key);
|
|
51
|
+
const newValue = props.controller(configValue, app) || [];
|
|
52
|
+
view.dispatch({ effects: props.config.reconfigure(newValue) });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Source-editor CodeMirror shell backed by Mira base extensions + Lapis live
|
|
57
|
+
* configuration compartments. Language packs are passed in by the caller;
|
|
58
|
+
* Markdown live-preview / rich Mira surfaces are not included.
|
|
59
|
+
*/
|
|
60
|
+
export function markupEditor(options = {}, ...extensions) {
|
|
61
|
+
const language = options.language?.trim() || "text";
|
|
62
|
+
return [
|
|
63
|
+
...extensions,
|
|
64
|
+
...createBaseCodeMirrorExtensions({
|
|
65
|
+
// Lapis editorConfig compartments own these live toggles.
|
|
66
|
+
lineNumbers: false,
|
|
67
|
+
lineWrapping: false,
|
|
68
|
+
spellcheck: false,
|
|
69
|
+
}),
|
|
70
|
+
editorConfig.extension(options.app),
|
|
71
|
+
EditorView.editorAttributes.of({
|
|
72
|
+
class: "cm-editor-source markdown-editor-surface",
|
|
73
|
+
"data-language": language,
|
|
74
|
+
}),
|
|
75
|
+
EditorView.contentAttributes.of({ "aria-label": "Source editor" }),
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
export const editorConfig = new EditorConfig();
|
|
79
|
+
function normalizeIndentWidth(width) {
|
|
80
|
+
if (typeof width !== "number" || !Number.isFinite(width)) {
|
|
81
|
+
return 2;
|
|
82
|
+
}
|
|
83
|
+
return Math.max(1, Math.floor(width));
|
|
84
|
+
}
|
|
85
|
+
editorConfig.register("editor.display.showLineNumbers", (show) => {
|
|
86
|
+
show = show ?? true;
|
|
87
|
+
return show
|
|
88
|
+
? [
|
|
89
|
+
lineNumbers({}),
|
|
90
|
+
// lineNumberWidgetMarker.of((view, widget, block) => {
|
|
91
|
+
// if (block.from > 1) {
|
|
92
|
+
// return new BlockLineMarker(
|
|
93
|
+
// view.state.doc.lineAt(block.from).number,
|
|
94
|
+
// view.state.doc.lineAt(block.to).number,
|
|
95
|
+
// );
|
|
96
|
+
// }
|
|
97
|
+
// return null;
|
|
98
|
+
// }),
|
|
99
|
+
]
|
|
100
|
+
: [];
|
|
101
|
+
});
|
|
102
|
+
editorConfig.register("editor.display.foldIndent", (fold) => {
|
|
103
|
+
// Language packs supply fold ranges; Mira base registers codeFolding() +
|
|
104
|
+
// foldKeymap. This mounts the Mira-styled fold gutter chevrons.
|
|
105
|
+
fold = fold ?? true;
|
|
106
|
+
return fold ? foldGutter() : [];
|
|
107
|
+
});
|
|
108
|
+
editorConfig.register("editor.display.wrapLines", (wrap) => {
|
|
109
|
+
wrap = wrap ?? true;
|
|
110
|
+
return wrap ? [EditorView.lineWrapping] : [];
|
|
111
|
+
});
|
|
112
|
+
editorConfig.register("editor.display.showIndentationGuides", (show) => show
|
|
113
|
+
? EditorView.editorAttributes.of({ class: "cm-show-indentation-guides" })
|
|
114
|
+
: []);
|
|
115
|
+
editorConfig.register("editor.behaviour.indentVisualWidth", (width) => {
|
|
116
|
+
const normalizedWidth = normalizeIndentWidth(width);
|
|
117
|
+
return EditorState.tabSize.of(normalizedWidth);
|
|
118
|
+
});
|
|
119
|
+
editorConfig.register("editor.behaviour.indentUsingTabs", (useTabs, app) => {
|
|
120
|
+
const config = app.configuration.getConfiguration();
|
|
121
|
+
const width = normalizeIndentWidth(config.get("editor.behaviour.indentVisualWidth"));
|
|
122
|
+
return [
|
|
123
|
+
indentUnit.of((useTabs ?? true) ? "\t" : " ".repeat(width)),
|
|
124
|
+
keymap.of([
|
|
125
|
+
{
|
|
126
|
+
key: "Tab",
|
|
127
|
+
run: indentMore,
|
|
128
|
+
shift: indentLess,
|
|
129
|
+
},
|
|
130
|
+
]),
|
|
131
|
+
];
|
|
132
|
+
});
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount, untrack } from "svelte";
|
|
3
|
+
import { type Editor as EditorApi } from "../../editor.svelte";
|
|
4
|
+
import { dirname } from "../../storage/path";
|
|
5
|
+
import { WorkspaceLeaf } from "../../workspace.svelte";
|
|
6
|
+
import { editorConfig } from "./editor";
|
|
7
|
+
import { ScrollArea } from "@lapismd/design-core/shadcn/scroll-area";
|
|
8
|
+
import { cn } from "../../utils";
|
|
9
|
+
import type { App } from "../../context.svelte";
|
|
10
|
+
import { useApplicationState } from "../../application-state.svelte";
|
|
11
|
+
import "@lapismd/mira/themes/obsidian.css";
|
|
12
|
+
import "./editor.css";
|
|
13
|
+
|
|
14
|
+
type Props = {
|
|
15
|
+
app?: App;
|
|
16
|
+
leaf?: WorkspaceLeaf;
|
|
17
|
+
editor: EditorApi;
|
|
18
|
+
class?: string;
|
|
19
|
+
scrollOwner?: "self" | "ancestor";
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
let {
|
|
23
|
+
app: providedApplication,
|
|
24
|
+
leaf,
|
|
25
|
+
editor,
|
|
26
|
+
class: className = "",
|
|
27
|
+
scrollOwner = "self",
|
|
28
|
+
}: Props = $props();
|
|
29
|
+
const ownership = untrack(() => ({ providedApplication, leaf, editor }));
|
|
30
|
+
const app = useApplicationState(
|
|
31
|
+
ownership.providedApplication ?? ownership.leaf?.application,
|
|
32
|
+
);
|
|
33
|
+
ownership.editor.bindApplication(app);
|
|
34
|
+
let file = $derived(editor.file);
|
|
35
|
+
let isMobileWorkspace = $derived(app.workspace.displayMode === "mobile");
|
|
36
|
+
let showInlineTitle = $derived(
|
|
37
|
+
app.configuration
|
|
38
|
+
.getConfiguration()
|
|
39
|
+
.get("appearence.interface.showInlineTitle"),
|
|
40
|
+
);
|
|
41
|
+
let shouldShowDesktopInlineTitle = $derived(
|
|
42
|
+
showInlineTitle && !isMobileWorkspace,
|
|
43
|
+
);
|
|
44
|
+
let shouldShowMobileInlineTitle = $derived(
|
|
45
|
+
isMobileWorkspace && file !== null,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
let spellcheck = $derived(
|
|
49
|
+
app.configuration
|
|
50
|
+
.getConfiguration()
|
|
51
|
+
.get("editor.behaviour.spellCheck", false),
|
|
52
|
+
);
|
|
53
|
+
const codeMirror = (node: HTMLDivElement) => {
|
|
54
|
+
let focusTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
55
|
+
const root = node.getRootNode();
|
|
56
|
+
if (root instanceof Document || root instanceof ShadowRoot) {
|
|
57
|
+
editor.view.setRoot(root);
|
|
58
|
+
}
|
|
59
|
+
node.append(editor.view.dom);
|
|
60
|
+
focusTimeout = setTimeout(() => {
|
|
61
|
+
editor.view.focus();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
update(qs: string) {},
|
|
66
|
+
destroy() {
|
|
67
|
+
if (focusTimeout !== null) {
|
|
68
|
+
clearTimeout(focusTimeout);
|
|
69
|
+
focusTimeout = null;
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
function editorConfigUpdated({ key, value }: { key: string; value: any }) {
|
|
76
|
+
editorConfig.update(editor.view, key, value, app);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
onMount(() => {
|
|
80
|
+
const trackChanges = editor.trackChanges();
|
|
81
|
+
const configUpdated = app.configuration.on("updated", editorConfigUpdated);
|
|
82
|
+
return () => {
|
|
83
|
+
trackChanges();
|
|
84
|
+
app.configuration.offref(configUpdated);
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
function renameFile(name: string | null) {
|
|
89
|
+
if (name && editor.file && name !== editor.file.name) {
|
|
90
|
+
const path = `${dirname(editor.file.path)}/${name}.${editor.file.extension}`;
|
|
91
|
+
app.fileManager.renameFile(editor.file, path);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function renameDone(evt: KeyboardEvent) {
|
|
96
|
+
if (evt.key == "Enter") {
|
|
97
|
+
renameFile((evt.target as HTMLDivElement).getText());
|
|
98
|
+
editor.view.focus();
|
|
99
|
+
evt.preventDefault();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
{#snippet editorContent()}
|
|
105
|
+
<div
|
|
106
|
+
class={cn(
|
|
107
|
+
"cm-editor-scroll-area-content markdown-editor-surface",
|
|
108
|
+
className,
|
|
109
|
+
)}
|
|
110
|
+
data-ui-component="editor"
|
|
111
|
+
data-ui-part="scroll-content"
|
|
112
|
+
data-mira-theme="obsidian"
|
|
113
|
+
>
|
|
114
|
+
<div
|
|
115
|
+
class="cm-editor-scroll-area-inner"
|
|
116
|
+
data-ui-component="editor"
|
|
117
|
+
data-ui-part="scroll-inner"
|
|
118
|
+
>
|
|
119
|
+
<div class="cm-scroller">
|
|
120
|
+
<div class="cm-sizer">
|
|
121
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
122
|
+
{#if shouldShowDesktopInlineTitle && file}
|
|
123
|
+
<div
|
|
124
|
+
onkeydown={renameDone}
|
|
125
|
+
onfocusout={(evt) =>
|
|
126
|
+
renameFile((evt.target as HTMLDivElement).getText())}
|
|
127
|
+
class="inline-title cm-editor-inline-title"
|
|
128
|
+
contenteditable="true"
|
|
129
|
+
{spellcheck}
|
|
130
|
+
autocapitalize="on"
|
|
131
|
+
tabindex="-1"
|
|
132
|
+
enterkeyhint="done"
|
|
133
|
+
>
|
|
134
|
+
{file?.name}
|
|
135
|
+
</div>
|
|
136
|
+
{/if}
|
|
137
|
+
{#if shouldShowMobileInlineTitle && file}
|
|
138
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
139
|
+
<div
|
|
140
|
+
onkeydown={renameDone}
|
|
141
|
+
onfocusout={(evt) =>
|
|
142
|
+
renameFile((evt.target as HTMLDivElement).getText())}
|
|
143
|
+
class="inline-title cm-editor-inline-title"
|
|
144
|
+
data-mobile-inline-title="true"
|
|
145
|
+
data-mobile-inline-title-input="true"
|
|
146
|
+
aria-label="Active note title"
|
|
147
|
+
contenteditable="true"
|
|
148
|
+
{spellcheck}
|
|
149
|
+
autocapitalize="on"
|
|
150
|
+
tabindex="-1"
|
|
151
|
+
enterkeyhint="done"
|
|
152
|
+
>
|
|
153
|
+
{file?.name}
|
|
154
|
+
</div>
|
|
155
|
+
{/if}
|
|
156
|
+
<div use:codeMirror class="cm-editor-content"></div>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
{/snippet}
|
|
162
|
+
|
|
163
|
+
{#if scrollOwner === "self"}
|
|
164
|
+
<ScrollArea class="cm-editor-scroll-area" data-mira-theme="obsidian">
|
|
165
|
+
{@render editorContent()}
|
|
166
|
+
</ScrollArea>
|
|
167
|
+
{:else}
|
|
168
|
+
<div
|
|
169
|
+
class="cm-editor-scroll-area cm-editor-scroll-area--ancestor"
|
|
170
|
+
data-ui-component="editor"
|
|
171
|
+
data-ui-part="scroll-owner-ancestor"
|
|
172
|
+
data-mira-theme="obsidian"
|
|
173
|
+
>
|
|
174
|
+
{@render editorContent()}
|
|
175
|
+
</div>
|
|
176
|
+
{/if}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Editor as EditorApi } from "../../editor.svelte";
|
|
2
|
+
import { WorkspaceLeaf } from "../../workspace.svelte";
|
|
3
|
+
import type { App } from "../../context.svelte";
|
|
4
|
+
import "@lapismd/mira/themes/obsidian.css";
|
|
5
|
+
import "./editor.css";
|
|
6
|
+
type Props = {
|
|
7
|
+
app?: App;
|
|
8
|
+
leaf?: WorkspaceLeaf;
|
|
9
|
+
editor: EditorApi;
|
|
10
|
+
class?: string;
|
|
11
|
+
scrollOwner?: "self" | "ancestor";
|
|
12
|
+
};
|
|
13
|
+
declare const Editor: import("svelte").Component<Props, {}, "">;
|
|
14
|
+
type Editor = ReturnType<typeof Editor>;
|
|
15
|
+
export default Editor;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Extension } from "@codemirror/state";
|
|
2
|
+
import type { App } from "../../context.svelte";
|
|
3
|
+
import type { Editor } from "../../editor.svelte";
|
|
4
|
+
export interface EmbeddedEditorExtensionOptions {
|
|
5
|
+
viewType: string;
|
|
6
|
+
mode?: string;
|
|
7
|
+
sourcePath?: string;
|
|
8
|
+
fallbackLanguage?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function embeddedEditorContext(options: EmbeddedEditorExtensionOptions): Record<string, unknown>;
|
|
11
|
+
export declare function resolveEmbeddedEditorExtensions(app: App, options: EmbeddedEditorExtensionOptions): Extension[];
|
|
12
|
+
export declare function applyEmbeddedEditorExtensions(app: App, editor: Editor, options: EmbeddedEditorExtensionOptions): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { markupEditor } from "./editor";
|
|
2
|
+
export function embeddedEditorContext(options) {
|
|
3
|
+
return {
|
|
4
|
+
...(options.mode ? { mode: options.mode } : {}),
|
|
5
|
+
...(options.sourcePath ? { file: options.sourcePath } : {}),
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export function resolveEmbeddedEditorExtensions(app, options) {
|
|
9
|
+
const registered = app.editorExtensions(options.viewType, embeddedEditorContext(options));
|
|
10
|
+
if (registered.length > 0) {
|
|
11
|
+
return registered;
|
|
12
|
+
}
|
|
13
|
+
return [
|
|
14
|
+
markupEditor({
|
|
15
|
+
language: options.fallbackLanguage ?? options.viewType,
|
|
16
|
+
app,
|
|
17
|
+
}),
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
export function applyEmbeddedEditorExtensions(app, editor, options) {
|
|
21
|
+
editor.updateExtensions(resolveEmbeddedEditorExtensions(app, options));
|
|
22
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount, untrack } from "svelte";
|
|
3
|
+
import type { App, Editor, WorkspaceLeaf } from "../..";
|
|
4
|
+
import { Editor as EditorController } from "../../editor.svelte";
|
|
5
|
+
import NoteEditor from "./editor.svelte";
|
|
6
|
+
import { applyEmbeddedEditorExtensions } from "./embedded-editor-surface";
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
app,
|
|
10
|
+
leaf,
|
|
11
|
+
editor: providedEditor,
|
|
12
|
+
value = "",
|
|
13
|
+
viewType = "markdown",
|
|
14
|
+
mode = "source",
|
|
15
|
+
sourcePath = "",
|
|
16
|
+
fallbackLanguage = viewType,
|
|
17
|
+
scrollOwner = "self",
|
|
18
|
+
class: className = "",
|
|
19
|
+
onChange,
|
|
20
|
+
}: {
|
|
21
|
+
app: App;
|
|
22
|
+
leaf?: WorkspaceLeaf;
|
|
23
|
+
editor?: Editor;
|
|
24
|
+
value?: string;
|
|
25
|
+
viewType?: string;
|
|
26
|
+
mode?: string;
|
|
27
|
+
sourcePath?: string;
|
|
28
|
+
fallbackLanguage?: string;
|
|
29
|
+
scrollOwner?: "self" | "ancestor";
|
|
30
|
+
class?: string;
|
|
31
|
+
onChange?: (value: string) => void | Promise<void>;
|
|
32
|
+
} = $props();
|
|
33
|
+
|
|
34
|
+
const initial = untrack(() => ({ app, providedEditor, value }));
|
|
35
|
+
const ownsEditor = initial.providedEditor === undefined;
|
|
36
|
+
const editor =
|
|
37
|
+
initial.providedEditor ??
|
|
38
|
+
new EditorController(initial.value, [], initial.app);
|
|
39
|
+
editor.bindApplication(initial.app);
|
|
40
|
+
|
|
41
|
+
function refreshExtensions(): void {
|
|
42
|
+
applyEmbeddedEditorExtensions(app, editor, {
|
|
43
|
+
viewType,
|
|
44
|
+
mode,
|
|
45
|
+
sourcePath,
|
|
46
|
+
fallbackLanguage,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
$effect(() => {
|
|
51
|
+
viewType;
|
|
52
|
+
mode;
|
|
53
|
+
sourcePath;
|
|
54
|
+
fallbackLanguage;
|
|
55
|
+
refreshExtensions();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
$effect(() => {
|
|
59
|
+
if (ownsEditor && value !== editor.getValue()) {
|
|
60
|
+
editor.replaceContent(value);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
onMount(() => {
|
|
65
|
+
const changed = editor.on("change", (next) => {
|
|
66
|
+
void onChange?.(next);
|
|
67
|
+
});
|
|
68
|
+
const configurationChanged = app.configuration.on("updated", () => {
|
|
69
|
+
refreshExtensions();
|
|
70
|
+
});
|
|
71
|
+
const pluginEnabled = app.plugins?.on("plugin-enabled", () => {
|
|
72
|
+
refreshExtensions();
|
|
73
|
+
});
|
|
74
|
+
const pluginDisabled = app.plugins?.on("plugin-disabled", () => {
|
|
75
|
+
refreshExtensions();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return () => {
|
|
79
|
+
const flushed = editor.flushChanges();
|
|
80
|
+
editor.offref(changed);
|
|
81
|
+
app.configuration.offref(configurationChanged);
|
|
82
|
+
if (pluginEnabled) app.plugins.offref(pluginEnabled);
|
|
83
|
+
if (pluginDisabled) app.plugins.offref(pluginDisabled);
|
|
84
|
+
void flushed.finally(() => {
|
|
85
|
+
if (ownsEditor) editor.destroy();
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<div
|
|
92
|
+
class={["embedded-editor-surface", className].filter(Boolean).join(" ")}
|
|
93
|
+
data-ui-component="embedded-editor-surface"
|
|
94
|
+
data-ui-part="root"
|
|
95
|
+
data-editor-view-type={viewType}
|
|
96
|
+
data-editor-mode={mode}
|
|
97
|
+
data-editor-scroll-owner={scrollOwner}
|
|
98
|
+
>
|
|
99
|
+
<NoteEditor {app} {leaf} {editor} {scrollOwner} />
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<style>
|
|
103
|
+
.embedded-editor-surface {
|
|
104
|
+
display: flex;
|
|
105
|
+
flex: 1 1 auto;
|
|
106
|
+
min-height: 0;
|
|
107
|
+
overflow: hidden;
|
|
108
|
+
width: 100%;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.embedded-editor-surface :global(.cm-editor-scroll-area) {
|
|
112
|
+
flex: 1 1 auto;
|
|
113
|
+
min-height: 0;
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { App, Editor, WorkspaceLeaf } from "../..";
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
app: App;
|
|
4
|
+
leaf?: WorkspaceLeaf;
|
|
5
|
+
editor?: Editor;
|
|
6
|
+
value?: string;
|
|
7
|
+
viewType?: string;
|
|
8
|
+
mode?: string;
|
|
9
|
+
sourcePath?: string;
|
|
10
|
+
fallbackLanguage?: string;
|
|
11
|
+
scrollOwner?: "self" | "ancestor";
|
|
12
|
+
class?: string;
|
|
13
|
+
onChange?: (value: string) => void | Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
declare const EmbeddedEditorSurface: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
16
|
+
type EmbeddedEditorSurface = ReturnType<typeof EmbeddedEditorSurface>;
|
|
17
|
+
export default EmbeddedEditorSurface;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { lapisCodeMirrorAutocomplete, type LapisCodeMirrorAutocompleteConfig, } from "./lapis-code-mirror-autocomplete";
|
|
2
|
+
export { vaultFilesMatchingPathSubstring, markdownNotesVaultFilter, embeddableMediaVaultFilter, isImageEmbedLinkPath, type VaultFilePredicate, type VaultFilesPathMatchOptions, } from "./vault-completion-sources";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { autocompletion } from "@codemirror/autocomplete";
|
|
2
|
+
import type { Extension } from "@codemirror/state";
|
|
3
|
+
/** Options accepted by `@codemirror/autocomplete`'s `autocompletion()`. */
|
|
4
|
+
export type LapisCodeMirrorAutocompleteConfig = Exclude<Parameters<typeof autocompletion>[0], undefined>;
|
|
5
|
+
/**
|
|
6
|
+
* Shared CodeMirror autocompletion defaults for Lapis editors. Popover-aligned
|
|
7
|
+
* surfaces come from `@lapis-notes/ui/codemirror-autocomplete.css`; this sets
|
|
8
|
+
* shared defaults (e.g. `icons: false`) plus a light `EditorView.theme`.
|
|
9
|
+
*
|
|
10
|
+
* **Facet merge:** multiple `autocompletion()` extensions merge completion
|
|
11
|
+
* config (`addToOptions` concatenate; `optionClass` / `tooltipClass` join with
|
|
12
|
+
* spaces; `icons` uses AND). Avoid defining conflicting `override` arrays in
|
|
13
|
+
* two extensions — either pass every `CompletionSource` in one call or rely on
|
|
14
|
+
* a single extension that provides `override`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function lapisCodeMirrorAutocomplete(config?: LapisCodeMirrorAutocompleteConfig): Extension[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { autocompletion } from "@codemirror/autocomplete";
|
|
2
|
+
import { EditorView } from "@codemirror/view";
|
|
3
|
+
/**
|
|
4
|
+
* Align tooltip typography with the app shell. List chrome is themed via
|
|
5
|
+
* `@lapis-notes/ui/codemirror-autocomplete.css`.
|
|
6
|
+
*/
|
|
7
|
+
const lapisAutocompleteTooltipTheme = EditorView.theme({
|
|
8
|
+
".cm-tooltip.cm-tooltip-autocomplete": {
|
|
9
|
+
fontFamily: "inherit",
|
|
10
|
+
},
|
|
11
|
+
".cm-tooltip.cm-completionInfo": {
|
|
12
|
+
fontFamily: "inherit",
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Shared CodeMirror autocompletion defaults for Lapis editors. Popover-aligned
|
|
17
|
+
* surfaces come from `@lapis-notes/ui/codemirror-autocomplete.css`; this sets
|
|
18
|
+
* shared defaults (e.g. `icons: false`) plus a light `EditorView.theme`.
|
|
19
|
+
*
|
|
20
|
+
* **Facet merge:** multiple `autocompletion()` extensions merge completion
|
|
21
|
+
* config (`addToOptions` concatenate; `optionClass` / `tooltipClass` join with
|
|
22
|
+
* spaces; `icons` uses AND). Avoid defining conflicting `override` arrays in
|
|
23
|
+
* two extensions — either pass every `CompletionSource` in one call or rely on
|
|
24
|
+
* a single extension that provides `override`.
|
|
25
|
+
*/
|
|
26
|
+
export function lapisCodeMirrorAutocomplete(config = {}) {
|
|
27
|
+
return [
|
|
28
|
+
lapisAutocompleteTooltipTheme,
|
|
29
|
+
autocompletion({
|
|
30
|
+
...config,
|
|
31
|
+
icons: false,
|
|
32
|
+
}),
|
|
33
|
+
];
|
|
34
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { TFile } from "../../../../storage/fs";
|
|
2
|
+
import type { App } from "../../../../context.svelte";
|
|
3
|
+
export type VaultFilePredicate = (file: TFile) => boolean;
|
|
4
|
+
/** Markdown notes only — useful for wiki-link targets. */
|
|
5
|
+
export declare function markdownNotesVaultFilter(file: TFile): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Common raster / SVG extensions suitable for embed completions (![[...]]).
|
|
8
|
+
* Aligns with plugin-markdown media MIME keys where practical.
|
|
9
|
+
*/
|
|
10
|
+
export declare function embeddableMediaVaultFilter(file: TFile): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* True when `linkPath` (wiki target or path string) uses an image-like
|
|
13
|
+
* extension. Replaces plugin-local string checks against `isImageAsset`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isImageEmbedLinkPath(linkPath: string): boolean;
|
|
16
|
+
export interface VaultFilesPathMatchOptions {
|
|
17
|
+
/** Application that owns the vault. */
|
|
18
|
+
app?: App;
|
|
19
|
+
filter?: VaultFilePredicate;
|
|
20
|
+
/** Max matches (default 150). */
|
|
21
|
+
limit?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Vault files whose path contains `query`, optionally filtered, capped for UI
|
|
25
|
+
* performance.
|
|
26
|
+
*/
|
|
27
|
+
export declare function vaultFilesMatchingPathSubstring(query: string, options?: VaultFilesPathMatchOptions): TFile[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { resolveApplication } from "../../../../application-compatibility";
|
|
2
|
+
const IMAGE_EMBED_EXTENSIONS = new Set([
|
|
3
|
+
"png",
|
|
4
|
+
"jpg",
|
|
5
|
+
"jpeg",
|
|
6
|
+
"gif",
|
|
7
|
+
"webp",
|
|
8
|
+
"svg",
|
|
9
|
+
"bmp",
|
|
10
|
+
"ico",
|
|
11
|
+
"tif",
|
|
12
|
+
"tiff",
|
|
13
|
+
"avif",
|
|
14
|
+
"apng",
|
|
15
|
+
]);
|
|
16
|
+
/** Markdown notes only — useful for wiki-link targets. */
|
|
17
|
+
export function markdownNotesVaultFilter(file) {
|
|
18
|
+
const ext = file.extension.toLowerCase();
|
|
19
|
+
return ext === "md" || ext === "markdown";
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Common raster / SVG extensions suitable for embed completions (![[...]]).
|
|
23
|
+
* Aligns with plugin-markdown media MIME keys where practical.
|
|
24
|
+
*/
|
|
25
|
+
export function embeddableMediaVaultFilter(file) {
|
|
26
|
+
return IMAGE_EMBED_EXTENSIONS.has(file.extension.toLowerCase());
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* True when `linkPath` (wiki target or path string) uses an image-like
|
|
30
|
+
* extension. Replaces plugin-local string checks against `isImageAsset`.
|
|
31
|
+
*/
|
|
32
|
+
export function isImageEmbedLinkPath(linkPath) {
|
|
33
|
+
const index = linkPath.lastIndexOf(".");
|
|
34
|
+
if (index === -1) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return IMAGE_EMBED_EXTENSIONS.has(linkPath.slice(index + 1).toLowerCase());
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Vault files whose path contains `query`, optionally filtered, capped for UI
|
|
41
|
+
* performance.
|
|
42
|
+
*/
|
|
43
|
+
export function vaultFilesMatchingPathSubstring(query, options = {}) {
|
|
44
|
+
const limit = options.limit ?? 150;
|
|
45
|
+
const filter = options.filter;
|
|
46
|
+
const application = resolveApplication(options.app);
|
|
47
|
+
return application.vault
|
|
48
|
+
.getFiles()
|
|
49
|
+
.filter((file) => {
|
|
50
|
+
if (filter && !filter(file))
|
|
51
|
+
return false;
|
|
52
|
+
return file.path.includes(query);
|
|
53
|
+
})
|
|
54
|
+
.slice(0, limit);
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const classHighlighter: import("@lezer/highlight").Highlighter;
|