@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/markdown.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { resolveApplication } from "./application-compatibility";
|
|
2
|
+
import { Component, FileView, TextFileView } from "./view.svelte";
|
|
3
|
+
import { HoverPopover } from "./popover";
|
|
4
|
+
function createFallbackElement() {
|
|
5
|
+
if (typeof document !== "undefined") {
|
|
6
|
+
return document.createElement("div");
|
|
7
|
+
}
|
|
8
|
+
return {};
|
|
9
|
+
}
|
|
10
|
+
export 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) {
|
|
20
|
+
super();
|
|
21
|
+
this.containerEl = containerEl;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export const livePreviewState = null;
|
|
25
|
+
export class EditableFileView extends FileView {
|
|
26
|
+
}
|
|
27
|
+
export class MarkdownView extends TextFileView {
|
|
28
|
+
hoverPopover = null;
|
|
29
|
+
previewMode;
|
|
30
|
+
currentMode;
|
|
31
|
+
constructor(leaf) {
|
|
32
|
+
super(leaf);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class MarkdownPreviewRenderer {
|
|
36
|
+
static registerPostProcessor(postProcessor, sortOrder) {
|
|
37
|
+
postProcessor.sortOrder = sortOrder ?? postProcessor.sortOrder ?? 0;
|
|
38
|
+
resolveApplication().registerMarkdownPostProcessor(postProcessor);
|
|
39
|
+
}
|
|
40
|
+
static unregisterPostProcessor(postProcessor) {
|
|
41
|
+
resolveApplication().unregisterMarkdownPostProcessor(postProcessor);
|
|
42
|
+
}
|
|
43
|
+
static createCodeBlockPostProcessor(language, handler) {
|
|
44
|
+
return (el, ctx) => {
|
|
45
|
+
const source = ctx.getSectionInfo(el)?.text ?? "";
|
|
46
|
+
handler(source.replace(/^([`]{3}[^\n]*\n+)|\n+[`]{3}\n*$/g, ""), el, ctx);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export class MarkdownRenderer extends MarkdownRenderChild {
|
|
51
|
+
app;
|
|
52
|
+
hoverPopover = null;
|
|
53
|
+
constructor(containerEl = createFallbackElement(), application) {
|
|
54
|
+
super(containerEl);
|
|
55
|
+
this.app = resolveApplication(application);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Renders Markdown string to an HTML element.
|
|
59
|
+
*
|
|
60
|
+
* @deprecated - Use {@link MarkdownRenderer.render}
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
static renderMarkdown(markdown, el, sourcePath, component) {
|
|
64
|
+
return MarkdownRenderer.render(app, markdown, el, sourcePath, component);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Renders Markdown string to an HTML element.
|
|
68
|
+
*
|
|
69
|
+
* @param app - A reference to the app object
|
|
70
|
+
* @param markdown - The Markdown source code
|
|
71
|
+
* @param el - The element to append to
|
|
72
|
+
* @param sourcePath - The normalized path of this Markdown file, used to
|
|
73
|
+
* resolve relative internal links
|
|
74
|
+
* @param component - A parent component to manage the lifecycle of the
|
|
75
|
+
* rendered child components.
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
static async render(app, markdown, el, sourcePath, component) {
|
|
79
|
+
await app.props.markdownRenderer(markdown, el, sourcePath, component);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export class MarkdownPreviewView extends MarkdownRenderer {
|
|
83
|
+
view;
|
|
84
|
+
data = "";
|
|
85
|
+
scroll = 0;
|
|
86
|
+
constructor(view) {
|
|
87
|
+
super(view?.containerEl ?? createFallbackElement(), view?.app);
|
|
88
|
+
this.view = view;
|
|
89
|
+
}
|
|
90
|
+
get file() {
|
|
91
|
+
return this.view?.file ?? null;
|
|
92
|
+
}
|
|
93
|
+
get() {
|
|
94
|
+
return this.data;
|
|
95
|
+
}
|
|
96
|
+
set(data, clear) {
|
|
97
|
+
if (clear)
|
|
98
|
+
this.clear();
|
|
99
|
+
this.data = data;
|
|
100
|
+
}
|
|
101
|
+
clear() {
|
|
102
|
+
this.containerEl?.replaceChildren?.();
|
|
103
|
+
}
|
|
104
|
+
rerender(full) { }
|
|
105
|
+
getScroll() {
|
|
106
|
+
return this.containerEl?.scrollTop ?? this.scroll;
|
|
107
|
+
}
|
|
108
|
+
applyScroll(scroll) {
|
|
109
|
+
this.scroll = scroll;
|
|
110
|
+
if (this.containerEl) {
|
|
111
|
+
this.containerEl.scrollTop = scroll;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export class MarkdownEditView {
|
|
116
|
+
view;
|
|
117
|
+
app;
|
|
118
|
+
hoverPopover = null;
|
|
119
|
+
constructor(view) {
|
|
120
|
+
this.view = view;
|
|
121
|
+
this.app = view.app;
|
|
122
|
+
}
|
|
123
|
+
clear() {
|
|
124
|
+
this.view.clear();
|
|
125
|
+
}
|
|
126
|
+
get() {
|
|
127
|
+
return this.view.getViewData();
|
|
128
|
+
}
|
|
129
|
+
set(data, clear) {
|
|
130
|
+
this.view.setViewData(data, clear);
|
|
131
|
+
}
|
|
132
|
+
get file() {
|
|
133
|
+
return this.view.file;
|
|
134
|
+
}
|
|
135
|
+
get editor() {
|
|
136
|
+
return this.view.editor;
|
|
137
|
+
}
|
|
138
|
+
getSelection() {
|
|
139
|
+
return this.view.editor.getSelection();
|
|
140
|
+
}
|
|
141
|
+
getScroll() {
|
|
142
|
+
return this.view.editor.getScrollInfo().top;
|
|
143
|
+
}
|
|
144
|
+
applyScroll(scroll) {
|
|
145
|
+
this.view.editor.scrollTo(null, scroll);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function trimMenuEdgeSeparators<T>(sections: Record<string, Array<T | "separator">> | null | undefined): Record<string, Array<T | "separator">>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function trimMenuEdgeSeparators(sections) {
|
|
2
|
+
const entries = Object.entries(sections ?? {});
|
|
3
|
+
let firstContentSection = -1;
|
|
4
|
+
let firstContentIndex = -1;
|
|
5
|
+
let lastContentSection = -1;
|
|
6
|
+
let lastContentIndex = -1;
|
|
7
|
+
for (let sectionIndex = 0; sectionIndex < entries.length; sectionIndex++) {
|
|
8
|
+
const [, items] = entries[sectionIndex];
|
|
9
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
10
|
+
if (items[itemIndex] !== "separator") {
|
|
11
|
+
firstContentSection = sectionIndex;
|
|
12
|
+
firstContentIndex = itemIndex;
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (firstContentSection !== -1) {
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
for (let sectionIndex = entries.length - 1; sectionIndex >= 0; sectionIndex--) {
|
|
21
|
+
const [, items] = entries[sectionIndex];
|
|
22
|
+
for (let itemIndex = items.length - 1; itemIndex >= 0; itemIndex--) {
|
|
23
|
+
if (items[itemIndex] !== "separator") {
|
|
24
|
+
lastContentSection = sectionIndex;
|
|
25
|
+
lastContentIndex = itemIndex;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (lastContentSection !== -1) {
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (firstContentSection === -1 || lastContentSection === -1) {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
const trimmedSections = {};
|
|
37
|
+
for (let sectionIndex = firstContentSection; sectionIndex <= lastContentSection; sectionIndex++) {
|
|
38
|
+
const [sectionId, items] = entries[sectionIndex];
|
|
39
|
+
const start = sectionIndex === firstContentSection ? firstContentIndex : 0;
|
|
40
|
+
const end = sectionIndex === lastContentSection ? lastContentIndex + 1 : items.length;
|
|
41
|
+
const slice = items.slice(start, end);
|
|
42
|
+
if (slice.length) {
|
|
43
|
+
trimmedSections[sectionId] = slice;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return trimmedSections;
|
|
47
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { type MountComponent } from "./hooks/mountComponent.svelte";
|
|
2
|
+
declare const MENU_ITEM_TAG: unique symbol;
|
|
3
|
+
export declare class MenuItem {
|
|
4
|
+
readonly menu: Menu;
|
|
5
|
+
readonly [MENU_ITEM_TAG] = true;
|
|
6
|
+
private props;
|
|
7
|
+
get section(): string;
|
|
8
|
+
get title(): string | DocumentFragment;
|
|
9
|
+
get icon(): string | null;
|
|
10
|
+
get checked(): boolean | null;
|
|
11
|
+
get disabled(): boolean;
|
|
12
|
+
get isLabel(): boolean;
|
|
13
|
+
click(evt: MouseEvent | KeyboardEvent): any;
|
|
14
|
+
static create(menu: Menu): MenuItem;
|
|
15
|
+
/**
|
|
16
|
+
* Private constructor. Use {@link addItem} instead.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
private constructor();
|
|
21
|
+
/** @public */
|
|
22
|
+
setTitle(title: string | DocumentFragment): this;
|
|
23
|
+
/**
|
|
24
|
+
* @param icon - ID of the icon, can use any icon loaded with {@link addIcon}
|
|
25
|
+
* or from the built-in lucide library.
|
|
26
|
+
* @public
|
|
27
|
+
* @see The Obsidian icon library includes the {@link https://lucide.dev/ Lucide icon library}, any icon name from their site will work here.
|
|
28
|
+
*/
|
|
29
|
+
setIcon(icon: string | null): this;
|
|
30
|
+
/** @public */
|
|
31
|
+
setChecked(checked: boolean | null): this;
|
|
32
|
+
/** @public */
|
|
33
|
+
setDisabled(disabled: boolean): this;
|
|
34
|
+
setWarning(warning?: boolean): this;
|
|
35
|
+
/** @public */
|
|
36
|
+
setIsLabel(isLabel: boolean): this;
|
|
37
|
+
/** @public */
|
|
38
|
+
onClick(callback: (evt: MouseEvent | KeyboardEvent) => any): this;
|
|
39
|
+
/**
|
|
40
|
+
* Sets the section this menu item should belong in. To find the section IDs
|
|
41
|
+
* of an existing menu, inspect the DOM elements to see their `data-section`
|
|
42
|
+
* attribute.
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
setSection(section: string): this;
|
|
47
|
+
}
|
|
48
|
+
export declare function isMenuItem(value: unknown): value is MenuItem;
|
|
49
|
+
export interface MenuPositionDef {
|
|
50
|
+
/** @public */
|
|
51
|
+
x: number;
|
|
52
|
+
/** @public */
|
|
53
|
+
y: number;
|
|
54
|
+
/** @public */
|
|
55
|
+
width?: number;
|
|
56
|
+
/** @public */
|
|
57
|
+
overlap?: boolean;
|
|
58
|
+
/** @public */
|
|
59
|
+
left?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export declare class MenuSeparator {
|
|
62
|
+
readonly section: string;
|
|
63
|
+
constructor(section?: string);
|
|
64
|
+
}
|
|
65
|
+
type Separator = "separator";
|
|
66
|
+
type MenuEntry = MenuItem | Separator | Menu;
|
|
67
|
+
export declare class Menu {
|
|
68
|
+
component: MountComponent<any> | null;
|
|
69
|
+
open: boolean;
|
|
70
|
+
filter: string;
|
|
71
|
+
private lastSection;
|
|
72
|
+
private readonly props;
|
|
73
|
+
get noIcon(): boolean;
|
|
74
|
+
get useNativeMenu(): boolean;
|
|
75
|
+
get items(): Record<string, MenuEntry[]>;
|
|
76
|
+
get renderedItems(): Record<string, ("separator" | MenuItem | Menu)[]>;
|
|
77
|
+
get filteredItems(): Record<string, ("separator" | MenuItem | Menu)[]>;
|
|
78
|
+
get title(): string;
|
|
79
|
+
get section(): string;
|
|
80
|
+
popover(): this;
|
|
81
|
+
dropdown(): this;
|
|
82
|
+
search(value: string): this;
|
|
83
|
+
clear(): this;
|
|
84
|
+
/** @public */
|
|
85
|
+
constructor();
|
|
86
|
+
/** @public */
|
|
87
|
+
setNoIcon(): this;
|
|
88
|
+
setTitle(title: string): this;
|
|
89
|
+
setSection(section: string): this;
|
|
90
|
+
/**
|
|
91
|
+
* Force this menu to use native or DOM. (Only works on the desktop app)
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
setUseNativeMenu(useNativeMenu: boolean): this;
|
|
96
|
+
/**
|
|
97
|
+
* Adds a menu item. Only works when menu is not shown yet.
|
|
98
|
+
*
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
addItem(cb: (item: MenuItem) => any): this;
|
|
102
|
+
addMenu(cb: (item: Menu) => any): this;
|
|
103
|
+
addGroups(...groups: Array<string | Array<string>>): this;
|
|
104
|
+
/**
|
|
105
|
+
* Adds a separator. Only works when menu is not shown yet.
|
|
106
|
+
*
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
109
|
+
addSeparator(section?: string): this;
|
|
110
|
+
/** @public */
|
|
111
|
+
hide(): this;
|
|
112
|
+
/** @public */
|
|
113
|
+
close(): void;
|
|
114
|
+
/** @public */
|
|
115
|
+
onHide(callback: () => any): void;
|
|
116
|
+
showAtElement(target?: HTMLElement | null): this;
|
|
117
|
+
showAtMouseEvent(evt: Event): this;
|
|
118
|
+
forEvent(evt: Event): this;
|
|
119
|
+
showAtPosition(position: MenuPositionDef, doc?: Document): this;
|
|
120
|
+
}
|
|
121
|
+
export {};
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { mountComponent, } from "./hooks/mountComponent.svelte";
|
|
3
|
+
import MenuComponent from "./components/menu/menu.svelte";
|
|
4
|
+
import { fuzzyMatchScore } from "@lapis-notes/ui";
|
|
5
|
+
import { trimMenuEdgeSeparators } from "./menu-utils";
|
|
6
|
+
const MENU_ITEM_TAG = Symbol.for("@lapis-notes/menu-item");
|
|
7
|
+
export class MenuItem {
|
|
8
|
+
menu;
|
|
9
|
+
[MENU_ITEM_TAG] = true;
|
|
10
|
+
props = $state({
|
|
11
|
+
section: "default",
|
|
12
|
+
title: "",
|
|
13
|
+
icon: "",
|
|
14
|
+
checked: null,
|
|
15
|
+
disabled: false,
|
|
16
|
+
isLabel: false,
|
|
17
|
+
onClick: () => {
|
|
18
|
+
this.menu.setOpen(false);
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
get section() {
|
|
22
|
+
return this.props.section;
|
|
23
|
+
}
|
|
24
|
+
get title() {
|
|
25
|
+
return this.props.title;
|
|
26
|
+
}
|
|
27
|
+
get icon() {
|
|
28
|
+
return this.props.icon;
|
|
29
|
+
}
|
|
30
|
+
get checked() {
|
|
31
|
+
return this.props.checked;
|
|
32
|
+
}
|
|
33
|
+
get disabled() {
|
|
34
|
+
return this.props.disabled;
|
|
35
|
+
}
|
|
36
|
+
get isLabel() {
|
|
37
|
+
return this.props.isLabel;
|
|
38
|
+
}
|
|
39
|
+
click(evt) {
|
|
40
|
+
return this.props.onClick(evt);
|
|
41
|
+
}
|
|
42
|
+
static create(menu) {
|
|
43
|
+
return new MenuItem(menu);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Private constructor. Use {@link addItem} instead.
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
constructor(menu) {
|
|
51
|
+
this.menu = menu;
|
|
52
|
+
}
|
|
53
|
+
/** @public */
|
|
54
|
+
setTitle(title) {
|
|
55
|
+
this.props.title = title;
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @param icon - ID of the icon, can use any icon loaded with {@link addIcon}
|
|
60
|
+
* or from the built-in lucide library.
|
|
61
|
+
* @public
|
|
62
|
+
* @see The Obsidian icon library includes the {@link https://lucide.dev/ Lucide icon library}, any icon name from their site will work here.
|
|
63
|
+
*/
|
|
64
|
+
setIcon(icon) {
|
|
65
|
+
this.props.icon = icon;
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
/** @public */
|
|
69
|
+
setChecked(checked) {
|
|
70
|
+
this.props.checked = checked;
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
/** @public */
|
|
74
|
+
setDisabled(disabled) {
|
|
75
|
+
this.props.disabled = disabled;
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
setWarning(warning = true) {
|
|
79
|
+
return this.setSection(warning ? "danger" : this.section);
|
|
80
|
+
}
|
|
81
|
+
/** @public */
|
|
82
|
+
setIsLabel(isLabel) {
|
|
83
|
+
this.props.isLabel = isLabel;
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
/** @public */
|
|
87
|
+
onClick(callback) {
|
|
88
|
+
this.props.onClick = (evt) => {
|
|
89
|
+
callback(evt);
|
|
90
|
+
this.menu.setOpen(false);
|
|
91
|
+
};
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Sets the section this menu item should belong in. To find the section IDs
|
|
96
|
+
* of an existing menu, inspect the DOM elements to see their `data-section`
|
|
97
|
+
* attribute.
|
|
98
|
+
*
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
setSection(section) {
|
|
102
|
+
this.props.section = section;
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export function isMenuItem(value) {
|
|
107
|
+
return Boolean(value && typeof value === "object" && MENU_ITEM_TAG in value);
|
|
108
|
+
}
|
|
109
|
+
export class MenuSeparator {
|
|
110
|
+
section;
|
|
111
|
+
constructor(section = "default") {
|
|
112
|
+
this.section = section;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export class Menu {
|
|
116
|
+
component = null;
|
|
117
|
+
open = $state(false);
|
|
118
|
+
filter = $state("");
|
|
119
|
+
lastSection = "default";
|
|
120
|
+
props = {
|
|
121
|
+
noIcon: false,
|
|
122
|
+
section: "default",
|
|
123
|
+
type: "context-menu",
|
|
124
|
+
useNativeMenu: false,
|
|
125
|
+
items: {},
|
|
126
|
+
title: "",
|
|
127
|
+
onHide: () => { },
|
|
128
|
+
};
|
|
129
|
+
get noIcon() {
|
|
130
|
+
return this.props.noIcon;
|
|
131
|
+
}
|
|
132
|
+
get useNativeMenu() {
|
|
133
|
+
return this.props.useNativeMenu;
|
|
134
|
+
}
|
|
135
|
+
get items() {
|
|
136
|
+
return this.props.items ?? {};
|
|
137
|
+
}
|
|
138
|
+
get renderedItems() {
|
|
139
|
+
return trimMenuEdgeSeparators(this.items);
|
|
140
|
+
}
|
|
141
|
+
get filteredItems() {
|
|
142
|
+
const data = {};
|
|
143
|
+
for (const [id, values] of Object.entries(this.items)) {
|
|
144
|
+
const items = values
|
|
145
|
+
.map((item) => {
|
|
146
|
+
let score = 1;
|
|
147
|
+
if (isMenuItem(item) && typeof item.title === "string") {
|
|
148
|
+
score = fuzzyMatchScore(item.title, this.filter, []);
|
|
149
|
+
}
|
|
150
|
+
return { item, score };
|
|
151
|
+
})
|
|
152
|
+
.filter((i) => i.score > 0)
|
|
153
|
+
.map((i) => i.item);
|
|
154
|
+
if (items.length) {
|
|
155
|
+
data[id] = items;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return trimMenuEdgeSeparators(data);
|
|
159
|
+
}
|
|
160
|
+
get title() {
|
|
161
|
+
return this.props.title;
|
|
162
|
+
}
|
|
163
|
+
get section() {
|
|
164
|
+
return this.props.section;
|
|
165
|
+
}
|
|
166
|
+
popover() {
|
|
167
|
+
this.props.type = "popover";
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
dropdown() {
|
|
171
|
+
this.props.type = "dropdown-menu";
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
search(value) {
|
|
175
|
+
this.filter = value;
|
|
176
|
+
return this;
|
|
177
|
+
}
|
|
178
|
+
clear() {
|
|
179
|
+
this.props.items = {};
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
/** @public */
|
|
183
|
+
constructor() { }
|
|
184
|
+
/** @public */
|
|
185
|
+
setNoIcon() {
|
|
186
|
+
this.props.noIcon = true;
|
|
187
|
+
return this;
|
|
188
|
+
}
|
|
189
|
+
setTitle(title) {
|
|
190
|
+
this.props.title = title;
|
|
191
|
+
return this;
|
|
192
|
+
}
|
|
193
|
+
setSection(section) {
|
|
194
|
+
this.props.section = section;
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Force this menu to use native or DOM. (Only works on the desktop app)
|
|
199
|
+
*
|
|
200
|
+
* @public
|
|
201
|
+
*/
|
|
202
|
+
setUseNativeMenu(useNativeMenu) {
|
|
203
|
+
this.props.useNativeMenu = useNativeMenu;
|
|
204
|
+
return this;
|
|
205
|
+
}
|
|
206
|
+
setOpen(open) {
|
|
207
|
+
const wasOpen = this.open;
|
|
208
|
+
this.open = open;
|
|
209
|
+
if (wasOpen && !open) {
|
|
210
|
+
this.props.onHide();
|
|
211
|
+
}
|
|
212
|
+
return this;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Adds a menu item. Only works when menu is not shown yet.
|
|
216
|
+
*
|
|
217
|
+
* @public
|
|
218
|
+
*/
|
|
219
|
+
addItem(cb) {
|
|
220
|
+
const item = MenuItem.create(this);
|
|
221
|
+
cb(item);
|
|
222
|
+
this.lastSection = item.section;
|
|
223
|
+
this.props.items[item.section] ||= [];
|
|
224
|
+
this.props.items[item.section].push(item);
|
|
225
|
+
return this;
|
|
226
|
+
}
|
|
227
|
+
addMenu(cb) {
|
|
228
|
+
const item = new Menu();
|
|
229
|
+
cb(item);
|
|
230
|
+
this.lastSection = item.section;
|
|
231
|
+
this.props.items[item.section] ||= [];
|
|
232
|
+
this.props.items[item.section].push(item);
|
|
233
|
+
return this;
|
|
234
|
+
}
|
|
235
|
+
addGroups(...groups) {
|
|
236
|
+
groups.flat().forEach((group) => (this.props.items[group] ||= []));
|
|
237
|
+
return this;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Adds a separator. Only works when menu is not shown yet.
|
|
241
|
+
*
|
|
242
|
+
* @public
|
|
243
|
+
*/
|
|
244
|
+
addSeparator(section) {
|
|
245
|
+
const items = this.props.items[section ?? this.lastSection];
|
|
246
|
+
if (!items.length || items[items.length - 1] === "separator")
|
|
247
|
+
return this;
|
|
248
|
+
items.push("separator");
|
|
249
|
+
return this;
|
|
250
|
+
}
|
|
251
|
+
/** @public */
|
|
252
|
+
hide() {
|
|
253
|
+
return this.setOpen(false);
|
|
254
|
+
}
|
|
255
|
+
/** @public */
|
|
256
|
+
close() {
|
|
257
|
+
this.setOpen(false);
|
|
258
|
+
}
|
|
259
|
+
/** @public */
|
|
260
|
+
onHide(callback) {
|
|
261
|
+
this.props.onHide = callback;
|
|
262
|
+
}
|
|
263
|
+
showAtElement(target) {
|
|
264
|
+
if (target) {
|
|
265
|
+
if (this.component && this.component.target === target) {
|
|
266
|
+
this.component.props.menu = this;
|
|
267
|
+
this.setOpen(true);
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
this.setOpen(true);
|
|
271
|
+
this.component?.destroy();
|
|
272
|
+
this.component = mountComponent(MenuComponent, {
|
|
273
|
+
target,
|
|
274
|
+
props: {
|
|
275
|
+
anchor: target,
|
|
276
|
+
type: this.props.type,
|
|
277
|
+
menu: this,
|
|
278
|
+
},
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return this;
|
|
283
|
+
}
|
|
284
|
+
showAtMouseEvent(evt) {
|
|
285
|
+
const target = evt.target;
|
|
286
|
+
return this.showAtElement(target);
|
|
287
|
+
}
|
|
288
|
+
forEvent(evt) {
|
|
289
|
+
return this.showAtMouseEvent(evt);
|
|
290
|
+
}
|
|
291
|
+
showAtPosition(position, doc) {
|
|
292
|
+
const target = (doc ?? document).elementFromPoint(position.x, position.y);
|
|
293
|
+
return this.showAtElement(target);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MetadataType } from "./metadata.svelte";
|
|
2
|
+
/** Infer a metadata type from a raw frontmatter value. */
|
|
3
|
+
export declare function inferMetadataType(value: unknown): MetadataType;
|
|
4
|
+
/** Infer a metadata type from a top-level frontmatter property name and value. */
|
|
5
|
+
export declare function inferMetadataPropertyType(name: string, value: unknown): MetadataType;
|
|
6
|
+
/**
|
|
7
|
+
* Best-effort normalization of a frontmatter value against a declared metadata
|
|
8
|
+
* type. Coerces when unambiguous; otherwise returns the original value.
|
|
9
|
+
*/
|
|
10
|
+
export declare function normalizeMetadataValue(type: MetadataType, value: unknown): unknown;
|