@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,215 @@
|
|
|
1
|
+
import type { DataAdapter, TFile } from "./storage/fs";
|
|
2
|
+
import type { WorkspaceLeaf } from "./workspace.svelte";
|
|
3
|
+
import type { Menu } from "./menu.svelte";
|
|
4
|
+
import { Editor } from "./editor.svelte";
|
|
5
|
+
import type { App } from "./context.svelte";
|
|
6
|
+
import "./enhance";
|
|
7
|
+
import { EventDispatcher, type EventNames, type EventRef, type ValidEventTypes } from "./events";
|
|
8
|
+
import type { Scope } from "./command.svelte";
|
|
9
|
+
/**
|
|
10
|
+
* Base lifecycle helper used throughout the public API.
|
|
11
|
+
*
|
|
12
|
+
* Components can own child components and cleanup callbacks so complex views
|
|
13
|
+
* and plugins can tear themselves down predictably.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export declare abstract class Component<Events extends ValidEventTypes = Record<string, any>> extends EventDispatcher<Events> {
|
|
18
|
+
children: Component[];
|
|
19
|
+
private unloaders;
|
|
20
|
+
loaded: boolean;
|
|
21
|
+
protected _containerEl: HTMLElement;
|
|
22
|
+
get containerEl(): HTMLElement;
|
|
23
|
+
set containerEl(el: HTMLElement);
|
|
24
|
+
/**
|
|
25
|
+
* Load this component and its children
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
load(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Override this to load your component
|
|
32
|
+
*
|
|
33
|
+
* @abstract
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
onload(): Promise<void> | void;
|
|
37
|
+
protected loadAsync(): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Unload this component and its children
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
unload(): void;
|
|
44
|
+
protected unloadAsync(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Override this to unload your component
|
|
47
|
+
*
|
|
48
|
+
* @abstract
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
onunload(): void;
|
|
52
|
+
private cleanupAsync;
|
|
53
|
+
/**
|
|
54
|
+
* Adds a child component, loading it if this component is loaded
|
|
55
|
+
*
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
addChild<T extends Component>(component: T): T;
|
|
59
|
+
/**
|
|
60
|
+
* Removes a child component, unloading it
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
removeChild<T extends Component>(component: T): T;
|
|
65
|
+
/**
|
|
66
|
+
* Registers a callback to be called when unloading
|
|
67
|
+
*
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
register(cb: () => any): void;
|
|
71
|
+
registerEvent<T extends ValidEventTypes, K extends EventNames<T>>(eventRef: EventRef<T, K, any>): void;
|
|
72
|
+
registerInterval(id: ReturnType<typeof setInterval>): void;
|
|
73
|
+
/**
|
|
74
|
+
* Registers an DOM event to be detached when unloading
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
registerDomEvent<K extends keyof HTMLElementEventMap>(el: HTMLElement, type: K, callback: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
79
|
+
registerDomEvent<K extends keyof DocumentEventMap>(el: Document, type: K, callback: (this: HTMLElement, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
80
|
+
registerDomEvent<K extends keyof WindowEventMap>(el: Window, type: K, callback: (this: HTMLElement, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Additional metadata returned from view-state transitions.
|
|
84
|
+
*
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
export interface ViewStateResult {
|
|
88
|
+
/**
|
|
89
|
+
* Set this to true to indicate that there is a state change which should be
|
|
90
|
+
* recorded in the navigation history.
|
|
91
|
+
*
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
history: boolean;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Serialized workspace state for a single leaf.
|
|
98
|
+
*
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
export interface ViewState {
|
|
102
|
+
/** @public */
|
|
103
|
+
type: string;
|
|
104
|
+
/** @public */
|
|
105
|
+
state?: Record<string, unknown>;
|
|
106
|
+
/** @public */
|
|
107
|
+
active?: boolean;
|
|
108
|
+
/** @public */
|
|
109
|
+
pinned?: boolean;
|
|
110
|
+
/** @public */
|
|
111
|
+
group?: WorkspaceLeaf;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Header breadcrumb contributed by a view. Keep the leaf filename in the
|
|
115
|
+
* header title rather than this list.
|
|
116
|
+
*
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
export interface ViewBreadcrumb {
|
|
120
|
+
id: string;
|
|
121
|
+
label: string;
|
|
122
|
+
onSelect?: () => void;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Base class for anything that can be mounted inside a workspace leaf.
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
export declare abstract class View extends Component {
|
|
130
|
+
icon: string;
|
|
131
|
+
leaf: WorkspaceLeaf;
|
|
132
|
+
scope: Scope | null;
|
|
133
|
+
protected state: Record<string, unknown>;
|
|
134
|
+
constructor(leaf?: WorkspaceLeaf);
|
|
135
|
+
get containerEl(): HTMLElement;
|
|
136
|
+
get app(): App;
|
|
137
|
+
/** @public */
|
|
138
|
+
protected abstract onOpen(): Promise<void>;
|
|
139
|
+
/** @public */
|
|
140
|
+
protected abstract onClose(): Promise<void>;
|
|
141
|
+
/** @public */
|
|
142
|
+
abstract getViewType(): string;
|
|
143
|
+
getState(): Record<string, unknown>;
|
|
144
|
+
setState(state: Record<string, unknown>, result?: ViewStateResult): Promise<void>;
|
|
145
|
+
getIcon(): string;
|
|
146
|
+
abstract getDisplayText(): string;
|
|
147
|
+
getBreadcrumbFilePath(): string | null;
|
|
148
|
+
getBreadcrumbs(): ViewBreadcrumb[];
|
|
149
|
+
onPaneMenu(menu: Menu, source: "more-options" | "tab-header" | string): void;
|
|
150
|
+
}
|
|
151
|
+
export declare class EmptyView extends View {
|
|
152
|
+
private component;
|
|
153
|
+
constructor(leaf?: WorkspaceLeaf);
|
|
154
|
+
protected onOpen(): Promise<void>;
|
|
155
|
+
protected onClose(): Promise<void>;
|
|
156
|
+
load(): void;
|
|
157
|
+
unload(): void;
|
|
158
|
+
getViewType(): string;
|
|
159
|
+
getDisplayText(): string;
|
|
160
|
+
getIcon(): string;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* View base class with an action bar and content area.
|
|
164
|
+
*
|
|
165
|
+
* @public
|
|
166
|
+
*/
|
|
167
|
+
export declare abstract class ItemView extends View {
|
|
168
|
+
actions: Array<{
|
|
169
|
+
icon: string;
|
|
170
|
+
title: string;
|
|
171
|
+
callback: (evt: MouseEvent) => any;
|
|
172
|
+
disabled?: boolean;
|
|
173
|
+
}>;
|
|
174
|
+
constructor(leaf?: WorkspaceLeaf);
|
|
175
|
+
get contentEl(): HTMLElement;
|
|
176
|
+
unload(): void;
|
|
177
|
+
addAction(icon: string, title: string, callback: (evt: MouseEvent) => any, options?: {
|
|
178
|
+
disabled?: boolean;
|
|
179
|
+
}): void;
|
|
180
|
+
protected onOpen(): Promise<void>;
|
|
181
|
+
protected onClose(): Promise<void>;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Item view base class that is backed by a vault file.
|
|
185
|
+
*
|
|
186
|
+
* @public
|
|
187
|
+
*/
|
|
188
|
+
export declare abstract class FileView extends ItemView {
|
|
189
|
+
file: TFile | null;
|
|
190
|
+
constructor(leaf?: WorkspaceLeaf);
|
|
191
|
+
getBreadcrumbFilePath(): string | null;
|
|
192
|
+
abstract onLoadFile(file: TFile): Promise<void>;
|
|
193
|
+
abstract onUnloadFile(file: TFile): Promise<void>;
|
|
194
|
+
abstract onRename(file: TFile): Promise<void>;
|
|
195
|
+
abstract canAcceptExtension(extension: string): boolean;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* File view base class for text-backed editors.
|
|
199
|
+
*
|
|
200
|
+
* @public
|
|
201
|
+
*/
|
|
202
|
+
export declare abstract class TextFileView extends FileView {
|
|
203
|
+
editor: Editor;
|
|
204
|
+
data: string;
|
|
205
|
+
constructor(leaf?: WorkspaceLeaf);
|
|
206
|
+
get adapter(): DataAdapter;
|
|
207
|
+
abstract getViewData(): string;
|
|
208
|
+
abstract setViewData(data: string, clear?: boolean): void;
|
|
209
|
+
abstract clear(): void;
|
|
210
|
+
onLoadFile(file: TFile): Promise<void>;
|
|
211
|
+
getIcon(): string;
|
|
212
|
+
onRename(file: TFile): Promise<void>;
|
|
213
|
+
onUnloadFile(file: TFile): Promise<void>;
|
|
214
|
+
save(clear?: boolean): Promise<void>;
|
|
215
|
+
}
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import { DateTime } from "luxon";
|
|
3
|
+
import { Editor } from "./editor.svelte";
|
|
4
|
+
import { mount, unmount } from "svelte";
|
|
5
|
+
import EmptyViewComponent from "./components/empty-view/empty-view.svelte";
|
|
6
|
+
import "./enhance";
|
|
7
|
+
import { EventDispatcher, } from "./events";
|
|
8
|
+
import { t } from "./localization-manager.svelte";
|
|
9
|
+
/**
|
|
10
|
+
* Base lifecycle helper used throughout the public API.
|
|
11
|
+
*
|
|
12
|
+
* Components can own child components and cleanup callbacks so complex views
|
|
13
|
+
* and plugins can tear themselves down predictably.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export class Component extends EventDispatcher {
|
|
18
|
+
children = [];
|
|
19
|
+
unloaders = new Set();
|
|
20
|
+
loaded = false;
|
|
21
|
+
_containerEl = $state(createDiv());
|
|
22
|
+
get containerEl() {
|
|
23
|
+
return this._containerEl;
|
|
24
|
+
}
|
|
25
|
+
set containerEl(el) {
|
|
26
|
+
this._containerEl = el;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Load this component and its children
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
load() {
|
|
34
|
+
if (this.loaded) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.onload();
|
|
38
|
+
this.children.forEach((it) => it.load());
|
|
39
|
+
this.loaded = true;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Override this to load your component
|
|
43
|
+
*
|
|
44
|
+
* @abstract
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
onload() { }
|
|
48
|
+
async loadAsync() {
|
|
49
|
+
if (this.loaded) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
await this.onload();
|
|
54
|
+
for (const child of [...this.children]) {
|
|
55
|
+
await child.loadAsync();
|
|
56
|
+
}
|
|
57
|
+
this.loaded = true;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
try {
|
|
61
|
+
await this.cleanupAsync(false);
|
|
62
|
+
}
|
|
63
|
+
catch (cleanupError) {
|
|
64
|
+
console.error("Failed to rollback component load", cleanupError);
|
|
65
|
+
}
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Unload this component and its children
|
|
71
|
+
*
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
unload() {
|
|
75
|
+
if (!this.loaded) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.children.forEach((child) => child.unload());
|
|
79
|
+
this.unloaders.forEach((cb) => cb());
|
|
80
|
+
this.unloaders.clear();
|
|
81
|
+
this.children = [];
|
|
82
|
+
this.onunload();
|
|
83
|
+
this.loaded = false;
|
|
84
|
+
}
|
|
85
|
+
async unloadAsync() {
|
|
86
|
+
if (!this.loaded &&
|
|
87
|
+
this.children.length === 0 &&
|
|
88
|
+
this.unloaders.size === 0) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
await this.cleanupAsync(this.loaded);
|
|
92
|
+
this.loaded = false;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Override this to unload your component
|
|
96
|
+
*
|
|
97
|
+
* @abstract
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
100
|
+
onunload() { }
|
|
101
|
+
async cleanupAsync(callOnUnload) {
|
|
102
|
+
let firstError = null;
|
|
103
|
+
for (const child of [...this.children].reverse()) {
|
|
104
|
+
try {
|
|
105
|
+
await child.unloadAsync();
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
firstError ??= error;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
this.children = [];
|
|
112
|
+
for (const cb of [...this.unloaders]) {
|
|
113
|
+
try {
|
|
114
|
+
cb();
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
firstError ??= error;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
this.unloaders.clear();
|
|
121
|
+
if (callOnUnload) {
|
|
122
|
+
try {
|
|
123
|
+
await this.onunload();
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
firstError ??= error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (firstError) {
|
|
130
|
+
throw firstError;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Adds a child component, loading it if this component is loaded
|
|
135
|
+
*
|
|
136
|
+
* @public
|
|
137
|
+
*/
|
|
138
|
+
addChild(component) {
|
|
139
|
+
if (this.children.indexOf(component) === -1) {
|
|
140
|
+
this.children.push(component);
|
|
141
|
+
if (this.loaded) {
|
|
142
|
+
component.load();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return component;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Removes a child component, unloading it
|
|
149
|
+
*
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
152
|
+
removeChild(component) {
|
|
153
|
+
const index = this.children.indexOf(component);
|
|
154
|
+
if (index > -1) {
|
|
155
|
+
this.children.splice(index, 1);
|
|
156
|
+
}
|
|
157
|
+
return component;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Registers a callback to be called when unloading
|
|
161
|
+
*
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
register(cb) {
|
|
165
|
+
this.unloaders.add(cb);
|
|
166
|
+
}
|
|
167
|
+
registerEvent(eventRef) {
|
|
168
|
+
this.register(() => eventRef.dispatcher.offref(eventRef));
|
|
169
|
+
}
|
|
170
|
+
registerInterval(id) {
|
|
171
|
+
this.register(() => clearInterval(id));
|
|
172
|
+
}
|
|
173
|
+
registerDomEvent(el, type, callback, options) {
|
|
174
|
+
el.addEventListener(type, callback, options);
|
|
175
|
+
this.register(() => el.removeEventListener(type, callback, options));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Base class for anything that can be mounted inside a workspace leaf.
|
|
180
|
+
*
|
|
181
|
+
* @public
|
|
182
|
+
*/
|
|
183
|
+
export class View extends Component {
|
|
184
|
+
icon = "";
|
|
185
|
+
leaf;
|
|
186
|
+
scope = null;
|
|
187
|
+
state = $state({});
|
|
188
|
+
constructor(leaf) {
|
|
189
|
+
super();
|
|
190
|
+
if (leaf) {
|
|
191
|
+
this.leaf = leaf;
|
|
192
|
+
leaf.view = this;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
get containerEl() {
|
|
196
|
+
return this.leaf.containerEl;
|
|
197
|
+
}
|
|
198
|
+
get app() {
|
|
199
|
+
return this.leaf.app;
|
|
200
|
+
}
|
|
201
|
+
getState() {
|
|
202
|
+
return { ...this.state };
|
|
203
|
+
}
|
|
204
|
+
setState(state, result) {
|
|
205
|
+
this.state = { ...state };
|
|
206
|
+
return Promise.resolve();
|
|
207
|
+
}
|
|
208
|
+
getIcon() {
|
|
209
|
+
return this.icon;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Vault path used for parent-path header breadcrumbs. File views return
|
|
213
|
+
* the open file; other views MAY return a related path or null.
|
|
214
|
+
*
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
getBreadcrumbFilePath() {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Prefix breadcrumbs rendered before parent-path segments.
|
|
222
|
+
*
|
|
223
|
+
* @public
|
|
224
|
+
*/
|
|
225
|
+
getBreadcrumbs() {
|
|
226
|
+
return [];
|
|
227
|
+
}
|
|
228
|
+
onPaneMenu(menu, source) { }
|
|
229
|
+
}
|
|
230
|
+
export class EmptyView extends View {
|
|
231
|
+
component;
|
|
232
|
+
constructor(leaf) {
|
|
233
|
+
super(leaf);
|
|
234
|
+
}
|
|
235
|
+
onOpen() {
|
|
236
|
+
return Promise.resolve();
|
|
237
|
+
}
|
|
238
|
+
onClose() {
|
|
239
|
+
return Promise.resolve();
|
|
240
|
+
}
|
|
241
|
+
load() {
|
|
242
|
+
if (this.containerEl) {
|
|
243
|
+
this.containerEl.innerHTML = "";
|
|
244
|
+
this.component = mount(EmptyViewComponent, {
|
|
245
|
+
target: this.containerEl,
|
|
246
|
+
props: {
|
|
247
|
+
app: this.app,
|
|
248
|
+
onClose: () => this.leaf.close(),
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
unload() {
|
|
254
|
+
if (this.component) {
|
|
255
|
+
unmount(this.component);
|
|
256
|
+
this.component = null;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
getViewType() {
|
|
260
|
+
return "empty";
|
|
261
|
+
}
|
|
262
|
+
getDisplayText() {
|
|
263
|
+
const missingViewType = this.state["__missingViewType"];
|
|
264
|
+
if (typeof missingViewType === "string" && missingViewType.length > 0) {
|
|
265
|
+
return missingViewType;
|
|
266
|
+
}
|
|
267
|
+
return t("base/empty-view", "New Tab");
|
|
268
|
+
}
|
|
269
|
+
getIcon() {
|
|
270
|
+
const missingViewType = this.state["__missingViewType"];
|
|
271
|
+
if (typeof missingViewType === "string" && missingViewType.length > 0) {
|
|
272
|
+
return "ghost";
|
|
273
|
+
}
|
|
274
|
+
return "file";
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* View base class with an action bar and content area.
|
|
279
|
+
*
|
|
280
|
+
* @public
|
|
281
|
+
*/
|
|
282
|
+
export class ItemView extends View {
|
|
283
|
+
actions = $state([]);
|
|
284
|
+
constructor(leaf) {
|
|
285
|
+
super(leaf);
|
|
286
|
+
}
|
|
287
|
+
get contentEl() {
|
|
288
|
+
return this.leaf.contentEl;
|
|
289
|
+
}
|
|
290
|
+
unload() {
|
|
291
|
+
super.unload();
|
|
292
|
+
}
|
|
293
|
+
addAction(icon, title, callback, options) {
|
|
294
|
+
this.actions.push({ icon, title, callback, disabled: options?.disabled });
|
|
295
|
+
}
|
|
296
|
+
onOpen() {
|
|
297
|
+
return Promise.resolve();
|
|
298
|
+
}
|
|
299
|
+
onClose() {
|
|
300
|
+
return Promise.resolve();
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Item view base class that is backed by a vault file.
|
|
305
|
+
*
|
|
306
|
+
* @public
|
|
307
|
+
*/
|
|
308
|
+
export class FileView extends ItemView {
|
|
309
|
+
file = $state();
|
|
310
|
+
constructor(leaf) {
|
|
311
|
+
super(leaf);
|
|
312
|
+
}
|
|
313
|
+
getBreadcrumbFilePath() {
|
|
314
|
+
return this.file?.path ?? null;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* File view base class for text-backed editors.
|
|
319
|
+
*
|
|
320
|
+
* @public
|
|
321
|
+
*/
|
|
322
|
+
export class TextFileView extends FileView {
|
|
323
|
+
editor;
|
|
324
|
+
data = $state("");
|
|
325
|
+
constructor(leaf) {
|
|
326
|
+
super(leaf);
|
|
327
|
+
this.editor = new Editor(this.data, [], leaf?.application);
|
|
328
|
+
}
|
|
329
|
+
get adapter() {
|
|
330
|
+
return this.app.vault.adapter;
|
|
331
|
+
}
|
|
332
|
+
async onLoadFile(file) {
|
|
333
|
+
return this.app.telemetry.measureAsync("view.text_file.on_load_file", async (span) => {
|
|
334
|
+
span.setAttribute("view.type", this.getViewType());
|
|
335
|
+
span.setAttribute("file.extension", file.extension);
|
|
336
|
+
const contents = await this.app.telemetry.measureAsync("vault.read", async () => this.app.vault.read(file), {
|
|
337
|
+
attributes: {
|
|
338
|
+
"file.extension": file.extension,
|
|
339
|
+
"view.type": this.getViewType(),
|
|
340
|
+
},
|
|
341
|
+
slowThresholdMs: 100,
|
|
342
|
+
});
|
|
343
|
+
this.file = file.copy();
|
|
344
|
+
this.editor.file = file;
|
|
345
|
+
await this.setState({ ...this.getState(), file: file.path });
|
|
346
|
+
this.editor.extensions = this.app.editorExtensions(this.file.extension, this.getState());
|
|
347
|
+
this.data = contents;
|
|
348
|
+
this.setViewData(contents, true);
|
|
349
|
+
}, {
|
|
350
|
+
attributes: {
|
|
351
|
+
"view.type": this.getViewType(),
|
|
352
|
+
"file.extension": file.extension,
|
|
353
|
+
},
|
|
354
|
+
slowThresholdMs: 150,
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
getIcon() {
|
|
358
|
+
return "file";
|
|
359
|
+
}
|
|
360
|
+
onRename(file) {
|
|
361
|
+
this.file = file.copy();
|
|
362
|
+
this.editor.file = file;
|
|
363
|
+
this.setState({ ...this.getState(), file: file.path });
|
|
364
|
+
return Promise.resolve();
|
|
365
|
+
}
|
|
366
|
+
onUnloadFile(file) {
|
|
367
|
+
this.setState({ ...this.getState(), file: "" });
|
|
368
|
+
return Promise.resolve();
|
|
369
|
+
}
|
|
370
|
+
save(clear) {
|
|
371
|
+
return this.app.vault
|
|
372
|
+
.modify(this.file, this.data, {
|
|
373
|
+
mtime: DateTime.now().toMillis(),
|
|
374
|
+
})
|
|
375
|
+
.then(() => {
|
|
376
|
+
if (clear) {
|
|
377
|
+
this.clear();
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AppShellController } from "@lapismd/design-core/workspace/core";
|
|
2
|
+
import type { Workspace } from "./workspace.svelte";
|
|
3
|
+
export interface WorkspaceHostBinding {
|
|
4
|
+
readonly controller: AppShellController;
|
|
5
|
+
}
|
|
6
|
+
export declare function setWorkspaceHostBinding(workspace: Workspace, binding: WorkspaceHostBinding): void;
|
|
7
|
+
export declare function resolveWorkspaceHostBinding(workspace: Workspace): WorkspaceHostBinding | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const workspaceHostBindings = new WeakMap();
|
|
2
|
+
export function setWorkspaceHostBinding(workspace, binding) {
|
|
3
|
+
workspaceHostBindings.set(workspace, Object.freeze(binding));
|
|
4
|
+
}
|
|
5
|
+
export function resolveWorkspaceHostBinding(workspace) {
|
|
6
|
+
return workspaceHostBindings.get(workspace);
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Workspace } from "./workspace.svelte";
|
|
2
|
+
import { type WorkspaceHostBinding } from "./workspace-host-internal";
|
|
3
|
+
export type { WorkspaceHostBinding } from "./workspace-host-internal";
|
|
4
|
+
/**
|
|
5
|
+
* Return the renderer binding owned by a Lapis workspace.
|
|
6
|
+
*
|
|
7
|
+
* This host-only entry point intentionally keeps design-core controller types
|
|
8
|
+
* out of the root Obsidian-compatible API export.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getWorkspaceHostBinding(workspace: Workspace): WorkspaceHostBinding;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { resolveWorkspaceHostBinding, } from "./workspace-host-internal";
|
|
2
|
+
/**
|
|
3
|
+
* Return the renderer binding owned by a Lapis workspace.
|
|
4
|
+
*
|
|
5
|
+
* This host-only entry point intentionally keeps design-core controller types
|
|
6
|
+
* out of the root Obsidian-compatible API export.
|
|
7
|
+
*/
|
|
8
|
+
export function getWorkspaceHostBinding(workspace) {
|
|
9
|
+
const binding = resolveWorkspaceHostBinding(workspace);
|
|
10
|
+
if (!binding) {
|
|
11
|
+
throw new Error("Workspace host binding is not initialized");
|
|
12
|
+
}
|
|
13
|
+
return binding;
|
|
14
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { App } from "./context.svelte";
|
|
2
|
+
export declare function promptSaveWorkspaceLayout(app: App, existingNames: string[], onSave: (name: string) => Promise<void>): void;
|
|
3
|
+
export declare function promptLoadWorkspaceLayout(app: App, names: string[], onLoad: (name: string) => Promise<void>): void;
|