@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
package/dist/logging.js
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { EventDispatcher } from "./events";
|
|
2
|
+
import { Plugin } from "./plugin";
|
|
3
|
+
import { DateTime } from "luxon";
|
|
4
|
+
/**
|
|
5
|
+
* Logger class to handle consistency of logs across the plugin.
|
|
6
|
+
*
|
|
7
|
+
* @class LogManager
|
|
8
|
+
* @extends {EventDispatcher}
|
|
9
|
+
*/
|
|
10
|
+
export class LogManager extends EventDispatcher {
|
|
11
|
+
options = {
|
|
12
|
+
minLevels: {
|
|
13
|
+
"": "info",
|
|
14
|
+
cache: "debug",
|
|
15
|
+
app: "info",
|
|
16
|
+
notebook: "debug",
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
// Prevent the console logger from being added twice
|
|
20
|
+
consoleLoggerRegistered = false;
|
|
21
|
+
/**
|
|
22
|
+
* Set the minimum log levels for the module name or global.
|
|
23
|
+
*
|
|
24
|
+
* @param {LogOptions} options
|
|
25
|
+
* @returns {any} {LogManager}
|
|
26
|
+
*/
|
|
27
|
+
configure(options) {
|
|
28
|
+
this.options = Object.assign({}, this.options, options);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
setLevel(module, level) {
|
|
32
|
+
this.options.minLevels[module] = level;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns a logger instance for the given module name.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} module
|
|
38
|
+
* @returns {any} {Logger}
|
|
39
|
+
*/
|
|
40
|
+
getLogger(module) {
|
|
41
|
+
return new Logger(this, module, () => {
|
|
42
|
+
let minLevel = "none";
|
|
43
|
+
let match = "";
|
|
44
|
+
for (const key in this.options.minLevels) {
|
|
45
|
+
if (module.startsWith(key) && key.length >= match.length) {
|
|
46
|
+
minLevel = this.options.minLevels[key];
|
|
47
|
+
match = key;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return minLevel;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
*
|
|
56
|
+
* @param {(logEntry: LogEntry) => void} listener
|
|
57
|
+
* @returns {any} {LogManager}
|
|
58
|
+
*/
|
|
59
|
+
onLogEntry(listener) {
|
|
60
|
+
this.on("log", listener);
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
arrAvg = (arr) => arr.reduce((a, b) => a + b, 0) / arr.length;
|
|
64
|
+
/**
|
|
65
|
+
* Registers a logger that write to the console.
|
|
66
|
+
*
|
|
67
|
+
* @returns {any} {LogManager}
|
|
68
|
+
*/
|
|
69
|
+
registerConsoleLogger(props = { color: true }) {
|
|
70
|
+
if (this.consoleLoggerRegistered)
|
|
71
|
+
return this;
|
|
72
|
+
this.onLogEntry((logEntry) => {
|
|
73
|
+
let msg = `[${DateTime.now().toISO()}][${logEntry.level}][${logEntry.module}]`;
|
|
74
|
+
if (logEntry.traceId) {
|
|
75
|
+
msg += `[${logEntry.traceId}]`;
|
|
76
|
+
}
|
|
77
|
+
msg += ` ${logEntry.message}`;
|
|
78
|
+
if (logEntry.objects === undefined) {
|
|
79
|
+
logEntry.objects = "";
|
|
80
|
+
}
|
|
81
|
+
const args = [msg];
|
|
82
|
+
if (props.color) {
|
|
83
|
+
args[0] = "%c" + msg;
|
|
84
|
+
const colors = {
|
|
85
|
+
trace: "color: #9c27b0; font-weight: italic",
|
|
86
|
+
debug: "color: #666666; font-style: italic",
|
|
87
|
+
info: "color: green;",
|
|
88
|
+
warn: "color: #ffc107; font-weight: bold",
|
|
89
|
+
error: "color: #e74c3c; font-weight: bold",
|
|
90
|
+
};
|
|
91
|
+
args.push(colors[logEntry.level]);
|
|
92
|
+
}
|
|
93
|
+
args.push(logEntry.objects);
|
|
94
|
+
switch (logEntry.level) {
|
|
95
|
+
case "trace":
|
|
96
|
+
console.trace(...args);
|
|
97
|
+
break;
|
|
98
|
+
case "debug":
|
|
99
|
+
console.debug(...args);
|
|
100
|
+
break;
|
|
101
|
+
case "info":
|
|
102
|
+
console.info(...args);
|
|
103
|
+
break;
|
|
104
|
+
case "warn":
|
|
105
|
+
console.warn(...args);
|
|
106
|
+
break;
|
|
107
|
+
case "error":
|
|
108
|
+
console.error(...args);
|
|
109
|
+
break;
|
|
110
|
+
default:
|
|
111
|
+
console.log(`{${logEntry.level}}`, ...args);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
this.consoleLoggerRegistered = true;
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export const logging = new LogManager();
|
|
119
|
+
/**
|
|
120
|
+
* Main logging library, to view the logs a logger listener must be added. The
|
|
121
|
+
* Console Logger is already implemented for this project.
|
|
122
|
+
*
|
|
123
|
+
* @class Logger
|
|
124
|
+
*/
|
|
125
|
+
export class Logger {
|
|
126
|
+
getLevel;
|
|
127
|
+
logManager;
|
|
128
|
+
module;
|
|
129
|
+
levels = {
|
|
130
|
+
trace: 1,
|
|
131
|
+
debug: 2,
|
|
132
|
+
info: 3,
|
|
133
|
+
warn: 4,
|
|
134
|
+
error: 5,
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Creates an instance of Logger.
|
|
138
|
+
*
|
|
139
|
+
* @param {EventEmitter2} logManager
|
|
140
|
+
* @param {string} module
|
|
141
|
+
* @param {string} minLevel
|
|
142
|
+
*/
|
|
143
|
+
constructor(logManager, module, getLevel) {
|
|
144
|
+
this.getLevel = getLevel;
|
|
145
|
+
this.logManager = logManager;
|
|
146
|
+
this.module = module;
|
|
147
|
+
}
|
|
148
|
+
get minLevel() {
|
|
149
|
+
return this.levelToInt(this.getLevel());
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Converts a string level (trace/debug/info/warn/error) into a number
|
|
153
|
+
*
|
|
154
|
+
* @param minLevel
|
|
155
|
+
*/
|
|
156
|
+
levelToInt(minLevel) {
|
|
157
|
+
if (minLevel.toLowerCase() in this.levels)
|
|
158
|
+
return this.levels[minLevel.toLowerCase()];
|
|
159
|
+
else
|
|
160
|
+
return 99;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Central logging method.
|
|
164
|
+
*
|
|
165
|
+
* @param logLevel
|
|
166
|
+
* @param message
|
|
167
|
+
*/
|
|
168
|
+
log(logLevel, message, objects) {
|
|
169
|
+
const level = this.levelToInt(logLevel);
|
|
170
|
+
if (level < this.minLevel)
|
|
171
|
+
return;
|
|
172
|
+
const logEntry = {
|
|
173
|
+
level: logLevel,
|
|
174
|
+
module: this.module,
|
|
175
|
+
message,
|
|
176
|
+
objects,
|
|
177
|
+
traceId: undefined,
|
|
178
|
+
};
|
|
179
|
+
// Obtain the line/file through a thoroughly hacky method
|
|
180
|
+
// This creates a new stack trace and pulls the caller from it. If the caller
|
|
181
|
+
// if .trace()
|
|
182
|
+
// const error = new Error('');
|
|
183
|
+
// if (error.stack) {
|
|
184
|
+
// const cla = error.stack.split('\n');
|
|
185
|
+
// let idx = 1;
|
|
186
|
+
// while (idx < cla.length && cla[idx].includes('at Logger.Object.')) idx++;
|
|
187
|
+
// if (idx < cla.length) {
|
|
188
|
+
// logEntry.location = cla[idx].slice(cla[idx].indexOf('at ') + 3, cla[idx].length);
|
|
189
|
+
// }
|
|
190
|
+
// }
|
|
191
|
+
this.logManager.emit("log", logEntry);
|
|
192
|
+
}
|
|
193
|
+
trace(message, objects) {
|
|
194
|
+
this.log("trace", message, objects);
|
|
195
|
+
}
|
|
196
|
+
debug(message, objects) {
|
|
197
|
+
this.log("debug", message, objects);
|
|
198
|
+
}
|
|
199
|
+
info(message, objects) {
|
|
200
|
+
this.log("info", message, objects);
|
|
201
|
+
}
|
|
202
|
+
warn(message, objects) {
|
|
203
|
+
this.log("warn", message, objects);
|
|
204
|
+
}
|
|
205
|
+
error(message, objects) {
|
|
206
|
+
this.log("error", message, objects);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Central logging method with a trace ID to track calls between
|
|
210
|
+
* modules/components.
|
|
211
|
+
*
|
|
212
|
+
* @param logLevel
|
|
213
|
+
* @param message
|
|
214
|
+
*/
|
|
215
|
+
logWithId(logLevel, traceId, message, objects) {
|
|
216
|
+
const level = this.levelToInt(logLevel);
|
|
217
|
+
if (level < this.minLevel)
|
|
218
|
+
return;
|
|
219
|
+
const logEntry = {
|
|
220
|
+
level: logLevel,
|
|
221
|
+
module: this.module,
|
|
222
|
+
message,
|
|
223
|
+
objects,
|
|
224
|
+
traceId,
|
|
225
|
+
};
|
|
226
|
+
this.logManager.emit("log", logEntry);
|
|
227
|
+
}
|
|
228
|
+
traceWithId(traceId, message, objects) {
|
|
229
|
+
this.logWithId("trace", traceId, message, objects);
|
|
230
|
+
}
|
|
231
|
+
debugWithId(traceId, message, objects) {
|
|
232
|
+
this.logWithId("debug", traceId, message, objects);
|
|
233
|
+
}
|
|
234
|
+
infoWithId(traceId, message, objects) {
|
|
235
|
+
this.logWithId("info", traceId, message, objects);
|
|
236
|
+
}
|
|
237
|
+
warnWithId(traceId, message, objects) {
|
|
238
|
+
this.logWithId("warn", traceId, message, objects);
|
|
239
|
+
}
|
|
240
|
+
errorWithId(traceId, message, objects) {
|
|
241
|
+
this.logWithId("error", traceId, message, objects);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// Comment from the original author:
|
|
245
|
+
// I was calculating metrics on call times to debug some performance issues.
|
|
246
|
+
// This is a simple JS hashmap where the id could be one of the 4 items.
|
|
247
|
+
// (see the comment-out code in logCall below...)
|
|
248
|
+
const timingMap = {};
|
|
249
|
+
/**
|
|
250
|
+
* This deceleration will log the time taken to run the function it is attached
|
|
251
|
+
* to. Be careful where it is added as it increases the output.
|
|
252
|
+
*
|
|
253
|
+
* @returns {any}
|
|
254
|
+
*/
|
|
255
|
+
export const logCall = (target, propertyKey, descriptor) => {
|
|
256
|
+
const originalMethod = descriptor.value;
|
|
257
|
+
//const logger = logging.getLogger('taskssql.perf');
|
|
258
|
+
descriptor.value = function (...args) {
|
|
259
|
+
const startTime = new Date(Date.now());
|
|
260
|
+
const result = originalMethod.apply(this, args);
|
|
261
|
+
const endTime = new Date(Date.now());
|
|
262
|
+
const name = `${target?.constructor?.name}${propertyKey}`;
|
|
263
|
+
const time = endTime.getTime() - startTime.getTime();
|
|
264
|
+
if (timingMap[name] === undefined) {
|
|
265
|
+
timingMap[name] = [];
|
|
266
|
+
}
|
|
267
|
+
timingMap[name].push(time);
|
|
268
|
+
//console.log(timingMap);
|
|
269
|
+
// if (endTime.getTime() - startTime.getTime() > 50) {
|
|
270
|
+
// console.debug(
|
|
271
|
+
// `[debug][taskssql.perf] ${String(timingMap[name].avg).padEnd(4)}${String(
|
|
272
|
+
// endTime.getTime() - startTime.getTime(),
|
|
273
|
+
// ).padEnd(4)} ${target?.constructor?.name.padEnd(10)}${propertyKey.padEnd(20)}`,
|
|
274
|
+
// );
|
|
275
|
+
// // logger.debug(
|
|
276
|
+
// // `${target?.constructor?.name}:${propertyKey}:called with ${args.length} arguments. Took: ${
|
|
277
|
+
// // endTime.getTime() - startTime.getTime()
|
|
278
|
+
// // }ms`,
|
|
279
|
+
// // );
|
|
280
|
+
// }
|
|
281
|
+
return result;
|
|
282
|
+
};
|
|
283
|
+
return descriptor;
|
|
284
|
+
};
|
|
285
|
+
export function logCallDetails() {
|
|
286
|
+
return function (target, propertyKey, descriptor) {
|
|
287
|
+
const originalMethod = descriptor.value;
|
|
288
|
+
const logger = logging.getLogger("tasks");
|
|
289
|
+
descriptor.value = async function (...args) {
|
|
290
|
+
const startTime = new Date(Date.now());
|
|
291
|
+
const result = await originalMethod.apply(this, args);
|
|
292
|
+
const endTime = new Date(Date.now());
|
|
293
|
+
const elapsed = endTime.getTime() - startTime.getTime();
|
|
294
|
+
logger.debug(`${typeof target}:${propertyKey} called with ${args.length} arguments. Took: ${elapsed}ms ${JSON.stringify(args)}`);
|
|
295
|
+
return result;
|
|
296
|
+
};
|
|
297
|
+
return descriptor;
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Provides a simple log function that can be used to log messages against
|
|
302
|
+
* default module.
|
|
303
|
+
*
|
|
304
|
+
* @param {TLogLevelName} logLevel
|
|
305
|
+
* @param {string} message
|
|
306
|
+
*/
|
|
307
|
+
export function log(logLevel, message) {
|
|
308
|
+
const logger = logging.getLogger("tasks");
|
|
309
|
+
switch (logLevel) {
|
|
310
|
+
case "trace":
|
|
311
|
+
logger.trace(message);
|
|
312
|
+
break;
|
|
313
|
+
case "debug":
|
|
314
|
+
logger.debug(message);
|
|
315
|
+
break;
|
|
316
|
+
case "info":
|
|
317
|
+
logger.info(message);
|
|
318
|
+
break;
|
|
319
|
+
case "warn":
|
|
320
|
+
logger.warn(message);
|
|
321
|
+
break;
|
|
322
|
+
case "error":
|
|
323
|
+
logger.error(message);
|
|
324
|
+
break;
|
|
325
|
+
default:
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* This allows the plugin to be debugged in a mobile application add it when
|
|
331
|
+
* debugging on a device. Not meant to be used by end users. Add it into main.ts
|
|
332
|
+
* and remove before you commit.
|
|
333
|
+
*
|
|
334
|
+
* @param {Plugin} plugin
|
|
335
|
+
* @returns {any}
|
|
336
|
+
*/
|
|
337
|
+
export function monkeyPatchConsole(plugin) {
|
|
338
|
+
const logFile = `${plugin.manifest.dir}/tasks-logs.txt`;
|
|
339
|
+
const logs = [];
|
|
340
|
+
const logMessages = (prefix) => (...messages) => {
|
|
341
|
+
logs.push(`\n[${prefix}]`);
|
|
342
|
+
for (const message of messages) {
|
|
343
|
+
logs.push(String(message));
|
|
344
|
+
}
|
|
345
|
+
plugin.app.vault.adapter.write(logFile, logs.join(" "));
|
|
346
|
+
};
|
|
347
|
+
console.debug = logMessages("debug");
|
|
348
|
+
console.error = logMessages("error");
|
|
349
|
+
console.info = logMessages("info");
|
|
350
|
+
console.log = logMessages("log");
|
|
351
|
+
console.warn = logMessages("warn");
|
|
352
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Extension } from "@codemirror/state";
|
|
2
|
+
import type { App } from "./context.svelte";
|
|
3
|
+
import type { MarkdownPostProcessor } from "./markdown";
|
|
4
|
+
/** Identifies the Markdown host that is rendering or editing a document. */
|
|
5
|
+
export interface MarkdownSurfaceContext {
|
|
6
|
+
/** Stable surface identifier such as `workspace` or `tasks-list`. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Optional opaque context owned by the surface consumer. */
|
|
9
|
+
context?: unknown;
|
|
10
|
+
}
|
|
11
|
+
export type MarkdownContributionMode = "source" | "live-preview" | "reading" | "embed";
|
|
12
|
+
export interface MarkdownCodeMirrorExtensionContext {
|
|
13
|
+
app: App;
|
|
14
|
+
mode: "source" | "live-preview";
|
|
15
|
+
sourcePath: string;
|
|
16
|
+
surface: MarkdownSurfaceContext;
|
|
17
|
+
}
|
|
18
|
+
/** A plugin-owned Markdown contribution adapted by the bundled Markdown plugin. */
|
|
19
|
+
export interface MarkdownExtensionContribution {
|
|
20
|
+
id: string;
|
|
21
|
+
codeMirror?: (context: MarkdownCodeMirrorExtensionContext) => Extension | readonly Extension[] | null | undefined;
|
|
22
|
+
postProcessor?: MarkdownPostProcessor;
|
|
23
|
+
}
|
|
24
|
+
export interface RegisteredMarkdownExtensionContribution extends MarkdownExtensionContribution {
|
|
25
|
+
pluginId: string;
|
|
26
|
+
}
|
|
27
|
+
export declare class MarkdownExtensionRegistry {
|
|
28
|
+
private readonly contributions;
|
|
29
|
+
register(pluginId: string, contribution: MarkdownExtensionContribution): () => void;
|
|
30
|
+
getAll(): RegisteredMarkdownExtensionContribution[];
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function contributionKey(pluginId, contributionId) {
|
|
2
|
+
return `${pluginId}:${contributionId}`;
|
|
3
|
+
}
|
|
4
|
+
export class MarkdownExtensionRegistry {
|
|
5
|
+
contributions = new Map();
|
|
6
|
+
register(pluginId, contribution) {
|
|
7
|
+
const normalizedPluginId = pluginId.trim();
|
|
8
|
+
const normalizedId = contribution.id.trim();
|
|
9
|
+
if (!normalizedPluginId || !normalizedId) {
|
|
10
|
+
throw new Error("Markdown contributions require plugin and contribution ids.");
|
|
11
|
+
}
|
|
12
|
+
const key = contributionKey(normalizedPluginId, normalizedId);
|
|
13
|
+
if (this.contributions.has(key)) {
|
|
14
|
+
throw new Error(`Markdown contribution ${key} is already registered.`);
|
|
15
|
+
}
|
|
16
|
+
const registered = {
|
|
17
|
+
...contribution,
|
|
18
|
+
id: normalizedId,
|
|
19
|
+
pluginId: normalizedPluginId,
|
|
20
|
+
};
|
|
21
|
+
this.contributions.set(key, registered);
|
|
22
|
+
return () => {
|
|
23
|
+
if (this.contributions.get(key) === registered) {
|
|
24
|
+
this.contributions.delete(key);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
getAll() {
|
|
29
|
+
return [...this.contributions.values()];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TFile } from "./storage/fs";
|
|
2
|
+
import type { MarkdownSurfaceContext } from "./markdown-extension-registry";
|
|
3
|
+
export type MarkdownFileSurfaceActivation = "manual" | "click" | "double-click";
|
|
4
|
+
export interface MarkdownFileSurfaceOptions {
|
|
5
|
+
containerEl: HTMLElement;
|
|
6
|
+
file: TFile;
|
|
7
|
+
editable?: boolean;
|
|
8
|
+
activation?: MarkdownFileSurfaceActivation;
|
|
9
|
+
returnToPreviewOnBlur?: boolean;
|
|
10
|
+
surface: MarkdownSurfaceContext;
|
|
11
|
+
onEditingChange?: (editing: boolean) => void;
|
|
12
|
+
}
|
|
13
|
+
export interface MarkdownFileSurfaceHandle {
|
|
14
|
+
enter(): void | Promise<void>;
|
|
15
|
+
flush(): Promise<boolean>;
|
|
16
|
+
exit(): Promise<boolean>;
|
|
17
|
+
dispose(): void | Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export type MarkdownFileSurfaceProvider = (options: MarkdownFileSurfaceOptions) => MarkdownFileSurfaceHandle | Promise<MarkdownFileSurfaceHandle>;
|
|
20
|
+
export declare class MarkdownFileSurfaceRegistry {
|
|
21
|
+
private providers;
|
|
22
|
+
register(pluginId: string, provider: MarkdownFileSurfaceProvider): () => void;
|
|
23
|
+
get available(): boolean;
|
|
24
|
+
mount(options: MarkdownFileSurfaceOptions): MarkdownFileSurfaceHandle | Promise<MarkdownFileSurfaceHandle>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class MarkdownFileSurfaceRegistry {
|
|
2
|
+
providers = [];
|
|
3
|
+
register(pluginId, provider) {
|
|
4
|
+
const registered = { pluginId: pluginId.trim(), provider };
|
|
5
|
+
if (!registered.pluginId) {
|
|
6
|
+
throw new Error("Markdown file surface providers require a plugin id.");
|
|
7
|
+
}
|
|
8
|
+
this.providers = [...this.providers, registered];
|
|
9
|
+
return () => {
|
|
10
|
+
this.providers = this.providers.filter((entry) => entry !== registered);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
get available() {
|
|
14
|
+
return this.providers.length > 0;
|
|
15
|
+
}
|
|
16
|
+
mount(options) {
|
|
17
|
+
const provider = this.providers.at(-1)?.provider;
|
|
18
|
+
if (!provider) {
|
|
19
|
+
throw new Error("No Markdown file surface provider is registered.");
|
|
20
|
+
}
|
|
21
|
+
return provider(options);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import type { App } from "./context.svelte";
|
|
2
|
+
import type { Editor, MarkdownFileInfo } from "./editor.svelte";
|
|
3
|
+
import { Component, FileView, TextFileView } from "./view.svelte";
|
|
4
|
+
import type { Menu } from "./menu.svelte";
|
|
5
|
+
import type { TFile } from "./storage/fs";
|
|
6
|
+
import type { WorkspaceLeaf } from "./workspace.svelte";
|
|
7
|
+
import { HoverPopover, type HoverParent } from "./popover";
|
|
8
|
+
import type { Component as SvelteComponent } from "svelte";
|
|
9
|
+
import type { MarkdownContributionMode, MarkdownSurfaceContext } from "./markdown-extension-registry";
|
|
10
|
+
export declare class MarkdownRenderChild extends Component {
|
|
11
|
+
/**
|
|
12
|
+
* @param containerEl - This HTMLElement will be used to test whether this
|
|
13
|
+
* component is still alive. It should be a child of the Markdown preview
|
|
14
|
+
* sections, and when it's no longer attached (for example, when it is
|
|
15
|
+
* replaced with a new version because the user edited the Markdown source
|
|
16
|
+
* code), this component will be unloaded.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
constructor(containerEl: HTMLElement);
|
|
20
|
+
}
|
|
21
|
+
export interface MarkdownSectionInformation {
|
|
22
|
+
/** @public */
|
|
23
|
+
text: string;
|
|
24
|
+
/** @public */
|
|
25
|
+
lineStart: number;
|
|
26
|
+
/** @public */
|
|
27
|
+
lineEnd: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A post processor receives an element which is a section of the preview.
|
|
31
|
+
*
|
|
32
|
+
* Post processors can mutate the DOM to render various things, such as mermaid
|
|
33
|
+
* graphs, latex equations, or custom controls.
|
|
34
|
+
*
|
|
35
|
+
* If your post processor requires lifecycle management, for example, to clear
|
|
36
|
+
* an interval, kill a subprocess, etc when this element is removed from the
|
|
37
|
+
* app, look into {@link MarkdownPostProcessorContext.addChild}
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export interface MarkdownPostProcessor {
|
|
42
|
+
/**
|
|
43
|
+
* The processor function itself.
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
(el: HTMLElement, ctx: MarkdownPostProcessorContext): Promise<any> | void;
|
|
48
|
+
/**
|
|
49
|
+
* An optional integer sort order. Defaults to 0. Lower number runs before
|
|
50
|
+
* higher numbers.
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
sortOrder?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface MarkdownPostProcessorContext {
|
|
57
|
+
/** @public */
|
|
58
|
+
docId: string;
|
|
59
|
+
/**
|
|
60
|
+
* The path to the associated file. Any links are assumed to be relative to
|
|
61
|
+
* the `sourcePath`.
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
sourcePath: string;
|
|
66
|
+
/** @public */
|
|
67
|
+
frontmatter: any | null | undefined;
|
|
68
|
+
/** Rendering mode for this processor invocation. @public */
|
|
69
|
+
mode?: MarkdownContributionMode;
|
|
70
|
+
/** Owning Markdown surface and optional consumer context. @public */
|
|
71
|
+
surface?: MarkdownSurfaceContext;
|
|
72
|
+
/**
|
|
73
|
+
* Adds a child component that will have its lifecycle managed by the
|
|
74
|
+
* renderer.
|
|
75
|
+
*
|
|
76
|
+
* Use this to add a dependent child to the renderer such that if the
|
|
77
|
+
* containerEl of the child is ever removed, the component's unload will be
|
|
78
|
+
* called.
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
addChild(child: MarkdownRenderChild): void;
|
|
83
|
+
/**
|
|
84
|
+
* Gets the section information of this element at this point in time. Only
|
|
85
|
+
* call this function right before you need this information to get the most
|
|
86
|
+
* up-to-date version. This function may also return null in many
|
|
87
|
+
* circumstances; if you use it, you must be prepared to deal with nulls.
|
|
88
|
+
*
|
|
89
|
+
* @public
|
|
90
|
+
*/
|
|
91
|
+
getSectionInfo(el: HTMLElement): MarkdownSectionInformation | null;
|
|
92
|
+
}
|
|
93
|
+
export interface MarkdownViewMenuContext {
|
|
94
|
+
menu: Menu;
|
|
95
|
+
source: "more-options" | "tab-header" | string;
|
|
96
|
+
leaf: WorkspaceLeaf;
|
|
97
|
+
file: TFile;
|
|
98
|
+
}
|
|
99
|
+
export type MarkdownDirectiveRenderer = SvelteComponent<any, any, any>;
|
|
100
|
+
export type MarkdownViewMenuItemProvider = (context: MarkdownViewMenuContext) => void;
|
|
101
|
+
export interface MarkdownSubView {
|
|
102
|
+
getScroll(): number;
|
|
103
|
+
applyScroll(scroll: number): void;
|
|
104
|
+
get(): string;
|
|
105
|
+
set(data: string, clear: boolean): void;
|
|
106
|
+
}
|
|
107
|
+
export interface MarkdownPreviewEvents extends Component {
|
|
108
|
+
}
|
|
109
|
+
export type MarkdownViewModeType = "source" | "preview" | "live-preview";
|
|
110
|
+
/**
|
|
111
|
+
* A file-backed view that Markdown editing can return to without owning that
|
|
112
|
+
* view's rendering policy.
|
|
113
|
+
*
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
export interface MarkdownViewReturnTarget {
|
|
117
|
+
/** Registered workspace view type to restore. @public */
|
|
118
|
+
type: string;
|
|
119
|
+
/** Human-readable destination used by the Markdown title action. @public */
|
|
120
|
+
label: string;
|
|
121
|
+
/** Optional icon for the return action. Defaults to `book-open`. @public */
|
|
122
|
+
icon?: string;
|
|
123
|
+
/** State supplied to the restored view. The current file is preserved. @public */
|
|
124
|
+
state?: Record<string, unknown>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Public serialized state accepted by the bundled Markdown view.
|
|
128
|
+
*
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
export interface MarkdownViewState {
|
|
132
|
+
file?: string | null;
|
|
133
|
+
mode?: MarkdownViewModeType;
|
|
134
|
+
returnTarget?: MarkdownViewReturnTarget;
|
|
135
|
+
}
|
|
136
|
+
export interface LivePreviewStateType {
|
|
137
|
+
editor: Editor;
|
|
138
|
+
}
|
|
139
|
+
export declare const livePreviewState: any;
|
|
140
|
+
export declare abstract class EditableFileView extends FileView {
|
|
141
|
+
}
|
|
142
|
+
export declare abstract class MarkdownView extends TextFileView {
|
|
143
|
+
hoverPopover: HoverPopover | null;
|
|
144
|
+
previewMode: MarkdownPreviewView;
|
|
145
|
+
currentMode: MarkdownSubView;
|
|
146
|
+
constructor(leaf?: WorkspaceLeaf);
|
|
147
|
+
}
|
|
148
|
+
export declare class MarkdownPreviewRenderer {
|
|
149
|
+
static registerPostProcessor(postProcessor: MarkdownPostProcessor, sortOrder?: number): void;
|
|
150
|
+
static unregisterPostProcessor(postProcessor: MarkdownPostProcessor): void;
|
|
151
|
+
static createCodeBlockPostProcessor(language: string, handler: (source: string, el: HTMLElement, ctx: MarkdownPostProcessorContext) => Promise<any> | void): (el: HTMLElement, ctx: MarkdownPostProcessorContext) => void;
|
|
152
|
+
}
|
|
153
|
+
export declare abstract class MarkdownRenderer extends MarkdownRenderChild implements MarkdownPreviewEvents, HoverParent {
|
|
154
|
+
app: App;
|
|
155
|
+
hoverPopover: HoverPopover | null;
|
|
156
|
+
constructor(containerEl?: HTMLElement, application?: App);
|
|
157
|
+
abstract get file(): TFile | null;
|
|
158
|
+
/**
|
|
159
|
+
* Renders Markdown string to an HTML element.
|
|
160
|
+
*
|
|
161
|
+
* @deprecated - Use {@link MarkdownRenderer.render}
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
static renderMarkdown(markdown: string, el: HTMLElement, sourcePath: string, component: Component): Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Renders Markdown string to an HTML element.
|
|
167
|
+
*
|
|
168
|
+
* @param app - A reference to the app object
|
|
169
|
+
* @param markdown - The Markdown source code
|
|
170
|
+
* @param el - The element to append to
|
|
171
|
+
* @param sourcePath - The normalized path of this Markdown file, used to
|
|
172
|
+
* resolve relative internal links
|
|
173
|
+
* @param component - A parent component to manage the lifecycle of the
|
|
174
|
+
* rendered child components.
|
|
175
|
+
* @public
|
|
176
|
+
*/
|
|
177
|
+
static render(app: App, markdown: string, el: HTMLElement, sourcePath: string, component: Component): Promise<void>;
|
|
178
|
+
}
|
|
179
|
+
export declare class MarkdownPreviewView extends MarkdownRenderer implements MarkdownSubView, MarkdownPreviewEvents {
|
|
180
|
+
readonly view?: MarkdownView | undefined;
|
|
181
|
+
private data;
|
|
182
|
+
private scroll;
|
|
183
|
+
constructor(view?: MarkdownView | undefined);
|
|
184
|
+
get file(): TFile | null;
|
|
185
|
+
get(): string;
|
|
186
|
+
set(data: string, clear: boolean): void;
|
|
187
|
+
clear(): void;
|
|
188
|
+
rerender(full?: boolean): void;
|
|
189
|
+
getScroll(): number;
|
|
190
|
+
applyScroll(scroll: number): void;
|
|
191
|
+
}
|
|
192
|
+
export declare class MarkdownEditView implements MarkdownSubView, HoverParent, MarkdownFileInfo {
|
|
193
|
+
readonly view: MarkdownView;
|
|
194
|
+
app: App;
|
|
195
|
+
hoverPopover: HoverPopover | null;
|
|
196
|
+
constructor(view: MarkdownView);
|
|
197
|
+
clear(): void;
|
|
198
|
+
get(): string;
|
|
199
|
+
set(data: string, clear: boolean): void;
|
|
200
|
+
get file(): TFile | null;
|
|
201
|
+
get editor(): Editor;
|
|
202
|
+
getSelection(): string;
|
|
203
|
+
getScroll(): number;
|
|
204
|
+
applyScroll(scroll: number): void;
|
|
205
|
+
}
|