@wonderwhy-er/desktop-commander 0.2.37 → 0.2.39
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/README.md +290 -100
- package/dist/command-manager.js +6 -3
- package/dist/config-field-definitions.d.ts +41 -0
- package/dist/config-field-definitions.js +37 -0
- package/dist/config-manager.d.ts +2 -0
- package/dist/config-manager.js +22 -2
- package/dist/handlers/filesystem-handlers.d.ts +5 -0
- package/dist/handlers/filesystem-handlers.js +19 -12
- package/dist/remote-device/desktop-commander-integration.js +1 -1
- package/dist/remote-device/remote-channel.js +1 -1
- package/dist/search-manager.js +31 -38
- package/dist/server.js +11 -4
- package/dist/terminal-manager.js +4 -2
- package/dist/tools/config.d.ts +71 -0
- package/dist/tools/config.js +117 -2
- package/dist/tools/edit.js +34 -1
- package/dist/tools/filesystem.js +91 -3
- package/dist/tools/improved-process-tools.js +2 -1
- package/dist/tools/schemas.d.ts +3 -0
- package/dist/tools/schemas.js +1 -0
- package/dist/types.d.ts +0 -1
- package/dist/ui/config-editor/app.d.ts +43 -0
- package/dist/ui/config-editor/app.js +840 -0
- package/dist/ui/config-editor/array-modal.d.ts +19 -0
- package/dist/ui/config-editor/array-modal.js +185 -0
- package/dist/ui/config-editor/config-editor-runtime.js +150 -0
- package/dist/ui/config-editor/index.html +13 -0
- package/dist/ui/config-editor/main.js +2 -0
- package/dist/ui/config-editor/src/App.d.ts +43 -0
- package/dist/ui/config-editor/src/App.js +840 -0
- package/dist/ui/config-editor/src/array-modal.d.ts +19 -0
- package/dist/ui/config-editor/src/array-modal.js +185 -0
- package/dist/ui/config-editor/src/components/layout.d.ts +4 -0
- package/dist/ui/config-editor/src/components/layout.js +83 -0
- package/dist/ui/config-editor/src/components/toolbar.d.ts +1 -0
- package/dist/ui/config-editor/src/components/toolbar.js +21 -0
- package/dist/ui/config-editor/src/config-values.d.ts +6 -0
- package/dist/ui/config-editor/src/config-values.js +61 -0
- package/dist/ui/config-editor/src/contracts.d.ts +14 -0
- package/dist/ui/config-editor/src/contracts.js +3 -0
- package/dist/ui/config-editor/src/directory-browser.d.ts +6 -0
- package/dist/ui/config-editor/src/directory-browser.js +71 -0
- package/dist/ui/config-editor/src/layout.d.ts +5 -0
- package/dist/ui/config-editor/src/layout.js +90 -0
- package/dist/ui/config-editor/src/main.js +2 -0
- package/dist/ui/config-editor/src/parsing.d.ts +5 -0
- package/dist/ui/config-editor/src/parsing.js +50 -0
- package/dist/ui/config-editor/src/toolbar.d.ts +1 -0
- package/dist/ui/config-editor/src/toolbar.js +18 -0
- package/dist/ui/config-editor/src/types.d.ts +17 -0
- package/dist/ui/config-editor/src/types.js +3 -0
- package/dist/ui/config-editor/src/utils/config-values.d.ts +9 -0
- package/dist/ui/config-editor/src/utils/config-values.js +61 -0
- package/dist/ui/config-editor/src/utils/directory-browser.d.ts +31 -0
- package/dist/ui/config-editor/src/utils/directory-browser.js +201 -0
- package/dist/ui/config-editor/src/utils/parsing.d.ts +8 -0
- package/dist/ui/config-editor/src/utils/parsing.js +50 -0
- package/dist/ui/config-editor/styles.css +587 -0
- package/dist/ui/file-preview/app.d.ts +8 -0
- package/dist/ui/file-preview/app.js +2020 -0
- package/dist/ui/file-preview/components/code-viewer.d.ts +6 -0
- package/dist/ui/file-preview/components/code-viewer.js +73 -0
- package/dist/ui/file-preview/components/highlighting.d.ts +2 -0
- package/dist/ui/file-preview/components/highlighting.js +54 -0
- package/dist/ui/file-preview/components/html-renderer.d.ts +5 -0
- package/dist/ui/file-preview/components/html-renderer.js +47 -0
- package/dist/ui/file-preview/components/markdown-renderer.d.ts +1 -0
- package/dist/ui/file-preview/components/markdown-renderer.js +67 -0
- package/dist/ui/file-preview/components/toolbar.d.ts +6 -0
- package/dist/ui/file-preview/components/toolbar.js +75 -0
- package/dist/ui/file-preview/image-preview.d.ts +3 -0
- package/dist/ui/file-preview/image-preview.js +21 -0
- package/dist/ui/file-preview/main.js +5 -0
- package/dist/ui/file-preview/markdown/editor.d.ts +36 -0
- package/dist/ui/file-preview/markdown/editor.js +643 -0
- package/dist/ui/file-preview/markdown/linking.d.ts +9 -0
- package/dist/ui/file-preview/markdown/linking.js +210 -0
- package/dist/ui/file-preview/markdown/outline.d.ts +7 -0
- package/dist/ui/file-preview/markdown/outline.js +40 -0
- package/dist/ui/file-preview/markdown/preview.d.ts +8 -0
- package/dist/ui/file-preview/markdown/preview.js +33 -0
- package/dist/ui/file-preview/markdown/slugify.d.ts +3 -0
- package/dist/ui/file-preview/markdown/slugify.js +31 -0
- package/dist/ui/file-preview/markdown/toc.d.ts +11 -0
- package/dist/ui/file-preview/markdown/toc.js +75 -0
- package/dist/ui/file-preview/markdown/utils.d.ts +1 -0
- package/dist/ui/file-preview/markdown/utils.js +15 -0
- package/dist/ui/file-preview/markdown/workspace-controller.d.ts +25 -0
- package/dist/ui/file-preview/markdown/workspace-controller.js +40 -0
- package/dist/ui/file-preview/preview-runtime.js +399 -13969
- package/dist/ui/file-preview/shared/preview-file-types.d.ts +1 -1
- package/dist/ui/file-preview/shared/preview-file-types.js +3 -1
- package/dist/ui/file-preview/src/App.d.ts +4 -0
- package/dist/ui/file-preview/src/App.js +564 -0
- package/dist/ui/file-preview/src/components/CodeViewer.d.ts +6 -0
- package/dist/ui/file-preview/src/components/CodeViewer.js +60 -0
- package/dist/ui/file-preview/src/components/HtmlRenderer.d.ts +8 -0
- package/dist/ui/file-preview/src/components/HtmlRenderer.js +45 -0
- package/dist/ui/file-preview/src/components/MarkdownRenderer.d.ts +1 -0
- package/dist/ui/file-preview/src/components/MarkdownRenderer.js +15 -0
- package/dist/ui/file-preview/src/components/editor-toolbar.d.ts +15 -0
- package/dist/ui/file-preview/src/components/editor-toolbar.js +384 -0
- package/dist/ui/file-preview/src/components/html-renderer.d.ts +1 -5
- package/dist/ui/file-preview/src/components/html-renderer.js +11 -27
- package/dist/ui/file-preview/src/components/markdown-editor.d.ts +29 -0
- package/dist/ui/file-preview/src/components/markdown-editor.js +535 -0
- package/dist/ui/file-preview/src/components/markdown-renderer.js +47 -9
- package/dist/ui/file-preview/src/directory-controller.d.ts +8 -0
- package/dist/ui/file-preview/src/directory-controller.js +233 -0
- package/dist/ui/file-preview/src/document-layout.d.ts +20 -0
- package/dist/ui/file-preview/src/document-layout.js +109 -0
- package/dist/ui/file-preview/src/document-outline.d.ts +17 -0
- package/dist/ui/file-preview/src/document-outline.js +97 -0
- package/dist/ui/file-preview/src/document-workspace.d.ts +19 -0
- package/dist/ui/file-preview/src/document-workspace.js +33 -0
- package/dist/ui/file-preview/src/file-type-handlers.d.ts +10 -0
- package/dist/ui/file-preview/src/file-type-handlers.js +98 -0
- package/dist/ui/file-preview/src/host/external-actions.d.ts +19 -0
- package/dist/ui/file-preview/src/host/external-actions.js +94 -0
- package/dist/ui/file-preview/src/host/selection-context.d.ts +9 -0
- package/dist/ui/file-preview/src/host/selection-context.js +106 -0
- package/dist/ui/file-preview/src/markdown/block-merge.d.ts +25 -0
- package/dist/ui/file-preview/src/markdown/block-merge.js +86 -0
- package/dist/ui/file-preview/src/markdown/conflict-dialog.d.ts +40 -0
- package/dist/ui/file-preview/src/markdown/conflict-dialog.js +163 -0
- package/dist/ui/file-preview/src/markdown/controller.d.ts +38 -0
- package/dist/ui/file-preview/src/markdown/controller.js +921 -0
- package/dist/ui/file-preview/src/markdown/editor.d.ts +35 -0
- package/dist/ui/file-preview/src/markdown/editor.js +691 -0
- package/dist/ui/file-preview/src/markdown/link-modal.d.ts +13 -0
- package/dist/ui/file-preview/src/markdown/link-modal.js +213 -0
- package/dist/ui/file-preview/src/markdown/linking.d.ts +16 -0
- package/dist/ui/file-preview/src/markdown/linking.js +228 -0
- package/dist/ui/file-preview/src/markdown/outline.d.ts +2 -0
- package/dist/ui/file-preview/src/markdown/outline.js +16 -0
- package/dist/ui/file-preview/src/markdown/parser.d.ts +30 -0
- package/dist/ui/file-preview/src/markdown/parser.js +38 -0
- package/dist/ui/file-preview/src/markdown/preview.d.ts +1 -0
- package/dist/ui/file-preview/src/markdown/preview.js +20 -0
- package/dist/ui/file-preview/src/markdown/raw-editor.d.ts +8 -0
- package/dist/ui/file-preview/src/markdown/raw-editor.js +61 -0
- package/dist/ui/file-preview/src/markdown/selection-toolbar.d.ts +14 -0
- package/dist/ui/file-preview/src/markdown/selection-toolbar.js +128 -0
- package/dist/ui/file-preview/src/markdown/slugify.d.ts +3 -0
- package/dist/ui/file-preview/src/markdown/slugify.js +31 -0
- package/dist/ui/file-preview/src/markdown/toc.d.ts +11 -0
- package/dist/ui/file-preview/src/markdown/toc.js +75 -0
- package/dist/ui/file-preview/src/markdown/utils.d.ts +1 -0
- package/dist/ui/file-preview/src/markdown/utils.js +15 -0
- package/dist/ui/file-preview/src/markdown-workspace/editor.d.ts +36 -0
- package/dist/ui/file-preview/src/markdown-workspace/editor.js +643 -0
- package/dist/ui/file-preview/src/markdown-workspace/linking.d.ts +9 -0
- package/dist/ui/file-preview/src/markdown-workspace/linking.js +210 -0
- package/dist/ui/file-preview/src/markdown-workspace/outline.d.ts +7 -0
- package/dist/ui/file-preview/src/markdown-workspace/outline.js +40 -0
- package/dist/ui/file-preview/src/markdown-workspace/preview.d.ts +8 -0
- package/dist/ui/file-preview/src/markdown-workspace/preview.js +33 -0
- package/dist/ui/file-preview/src/markdown-workspace/slugify.d.ts +3 -0
- package/dist/ui/file-preview/src/markdown-workspace/slugify.js +31 -0
- package/dist/ui/file-preview/src/markdown-workspace/toc.d.ts +11 -0
- package/dist/ui/file-preview/src/markdown-workspace/toc.js +75 -0
- package/dist/ui/file-preview/src/markdown-workspace/utils.d.ts +1 -0
- package/dist/ui/file-preview/src/markdown-workspace/utils.js +15 -0
- package/dist/ui/file-preview/src/markdown-workspace/workspace-controller.d.ts +25 -0
- package/dist/ui/file-preview/src/markdown-workspace/workspace-controller.js +40 -0
- package/dist/ui/file-preview/src/model.d.ts +34 -0
- package/dist/ui/file-preview/src/panel-actions.d.ts +17 -0
- package/dist/ui/file-preview/src/panel-actions.js +182 -0
- package/dist/ui/file-preview/src/path-utils.d.ts +6 -0
- package/dist/ui/file-preview/src/path-utils.js +64 -0
- package/dist/ui/file-preview/src/payload-utils.d.ts +11 -0
- package/dist/ui/file-preview/src/payload-utils.js +94 -0
- package/dist/ui/file-preview/styles.css +1144 -277
- package/dist/ui/file-preview/types.d.ts +1 -0
- package/dist/ui/file-preview/types.js +1 -0
- package/dist/ui/resources.d.ts +7 -0
- package/dist/ui/resources.js +16 -2
- package/dist/ui/server-integration.d.ts +13 -0
- package/dist/ui/server-integration.js +31 -0
- package/dist/ui/shared/ToolHeader.d.ts +9 -0
- package/dist/ui/shared/ToolHeader.js +29 -0
- package/dist/ui/shared/app-bootstrap.d.ts +9 -0
- package/dist/ui/shared/app-bootstrap.js +15 -0
- package/dist/ui/shared/compact-row.d.ts +11 -0
- package/dist/ui/shared/compact-row.js +18 -0
- package/dist/ui/shared/guards.d.ts +1 -0
- package/dist/ui/shared/guards.js +3 -0
- package/dist/ui/shared/host-context.d.ts +15 -0
- package/dist/ui/shared/host-context.js +51 -0
- package/dist/ui/shared/host-lifecycle.d.ts +1 -0
- package/dist/ui/shared/host-lifecycle.js +8 -2
- package/dist/ui/shared/tool-bridge.d.ts +30 -0
- package/dist/ui/shared/tool-bridge.js +137 -0
- package/dist/ui/shared/tool-shell.d.ts +9 -0
- package/dist/ui/shared/tool-shell.js +46 -4
- package/dist/ui/shared/ui-event-tracker.d.ts +9 -0
- package/dist/ui/shared/ui-event-tracker.js +27 -0
- package/dist/ui/shared/widget-state.d.ts +6 -1
- package/dist/ui/shared/widget-state.js +102 -4
- package/dist/utils/capture.js +3 -3
- package/dist/utils/files/base.d.ts +2 -0
- package/dist/utils/open-browser.js +1 -1
- package/dist/utils/ui-call-context.d.ts +8 -0
- package/dist/utils/ui-call-context.js +72 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +13 -4
- package/dist/data/spec-kit-prompts.json +0 -123
- package/dist/handlers/node-handlers.d.ts +0 -6
- package/dist/handlers/node-handlers.js +0 -73
- package/dist/handlers/test-crash-handler.d.ts +0 -11
- package/dist/handlers/test-crash-handler.js +0 -26
- package/dist/http-index.d.ts +0 -45
- package/dist/http-index.js +0 -51
- package/dist/http-server-auto-tunnel.js +0 -667
- package/dist/http-server-named-tunnel.d.ts +0 -2
- package/dist/http-server-named-tunnel.js +0 -167
- package/dist/http-server-tunnel.d.ts +0 -2
- package/dist/http-server-tunnel.js +0 -111
- package/dist/http-server.d.ts +0 -2
- package/dist/http-server.js +0 -270
- package/dist/index-oauth.d.ts +0 -2
- package/dist/index-oauth.js +0 -201
- package/dist/oauth/auth-middleware.d.ts +0 -20
- package/dist/oauth/auth-middleware.js +0 -62
- package/dist/oauth/index.d.ts +0 -3
- package/dist/oauth/index.js +0 -3
- package/dist/oauth/oauth-manager.d.ts +0 -80
- package/dist/oauth/oauth-manager.js +0 -179
- package/dist/oauth/oauth-routes.d.ts +0 -3
- package/dist/oauth/oauth-routes.js +0 -377
- package/dist/oauth/provider.d.ts +0 -22
- package/dist/oauth/provider.js +0 -124
- package/dist/oauth/server.d.ts +0 -18
- package/dist/oauth/server.js +0 -160
- package/dist/oauth/types.d.ts +0 -54
- package/dist/oauth/types.js +0 -2
- package/dist/remote-device/templates/auth-success.d.ts +0 -1
- package/dist/remote-device/templates/auth-success.js +0 -30
- package/dist/setup.log +0 -275
- package/dist/test-setup.js +0 -14
- package/dist/tools/docx/builders/html-builder.d.ts +0 -17
- package/dist/tools/docx/builders/html-builder.js +0 -92
- package/dist/tools/docx/builders/image.d.ts +0 -14
- package/dist/tools/docx/builders/image.js +0 -84
- package/dist/tools/docx/builders/index.d.ts +0 -11
- package/dist/tools/docx/builders/index.js +0 -11
- package/dist/tools/docx/builders/markdown-builder.d.ts +0 -2
- package/dist/tools/docx/builders/markdown-builder.js +0 -260
- package/dist/tools/docx/builders/paragraph.d.ts +0 -12
- package/dist/tools/docx/builders/paragraph.js +0 -29
- package/dist/tools/docx/builders/table.d.ts +0 -10
- package/dist/tools/docx/builders/table.js +0 -138
- package/dist/tools/docx/builders/utils.d.ts +0 -5
- package/dist/tools/docx/builders/utils.js +0 -18
- package/dist/tools/docx/constants.d.ts +0 -32
- package/dist/tools/docx/constants.js +0 -61
- package/dist/tools/docx/converters/markdown-to-html.d.ts +0 -17
- package/dist/tools/docx/converters/markdown-to-html.js +0 -111
- package/dist/tools/docx/create.d.ts +0 -21
- package/dist/tools/docx/create.js +0 -386
- package/dist/tools/docx/dom.d.ts +0 -139
- package/dist/tools/docx/dom.js +0 -448
- package/dist/tools/docx/errors.d.ts +0 -28
- package/dist/tools/docx/errors.js +0 -48
- package/dist/tools/docx/extractors/images.d.ts +0 -14
- package/dist/tools/docx/extractors/images.js +0 -40
- package/dist/tools/docx/extractors/metadata.d.ts +0 -14
- package/dist/tools/docx/extractors/metadata.js +0 -64
- package/dist/tools/docx/extractors/sections.d.ts +0 -14
- package/dist/tools/docx/extractors/sections.js +0 -61
- package/dist/tools/docx/html.d.ts +0 -17
- package/dist/tools/docx/html.js +0 -111
- package/dist/tools/docx/index.d.ts +0 -10
- package/dist/tools/docx/index.js +0 -10
- package/dist/tools/docx/markdown.d.ts +0 -84
- package/dist/tools/docx/markdown.js +0 -507
- package/dist/tools/docx/modify.d.ts +0 -28
- package/dist/tools/docx/modify.js +0 -271
- package/dist/tools/docx/operations/handlers/index.d.ts +0 -39
- package/dist/tools/docx/operations/handlers/index.js +0 -152
- package/dist/tools/docx/operations/html-manipulator.d.ts +0 -24
- package/dist/tools/docx/operations/html-manipulator.js +0 -352
- package/dist/tools/docx/operations/index.d.ts +0 -14
- package/dist/tools/docx/operations/index.js +0 -61
- package/dist/tools/docx/operations/operation-handlers.d.ts +0 -3
- package/dist/tools/docx/operations/operation-handlers.js +0 -67
- package/dist/tools/docx/operations/preprocessor.d.ts +0 -14
- package/dist/tools/docx/operations/preprocessor.js +0 -44
- package/dist/tools/docx/operations/xml-replacer.d.ts +0 -9
- package/dist/tools/docx/operations/xml-replacer.js +0 -35
- package/dist/tools/docx/operations.d.ts +0 -13
- package/dist/tools/docx/operations.js +0 -13
- package/dist/tools/docx/ops/delete-paragraph-at-body-index.d.ts +0 -11
- package/dist/tools/docx/ops/delete-paragraph-at-body-index.js +0 -23
- package/dist/tools/docx/ops/header-replace-text-exact.d.ts +0 -13
- package/dist/tools/docx/ops/header-replace-text-exact.js +0 -55
- package/dist/tools/docx/ops/index.d.ts +0 -17
- package/dist/tools/docx/ops/index.js +0 -70
- package/dist/tools/docx/ops/insert-image-after-text.d.ts +0 -24
- package/dist/tools/docx/ops/insert-image-after-text.js +0 -128
- package/dist/tools/docx/ops/insert-paragraph-after-text.d.ts +0 -12
- package/dist/tools/docx/ops/insert-paragraph-after-text.js +0 -74
- package/dist/tools/docx/ops/insert-table-after-text.d.ts +0 -19
- package/dist/tools/docx/ops/insert-table-after-text.js +0 -57
- package/dist/tools/docx/ops/replace-hyperlink-url.d.ts +0 -12
- package/dist/tools/docx/ops/replace-hyperlink-url.js +0 -37
- package/dist/tools/docx/ops/replace-paragraph-at-body-index.d.ts +0 -9
- package/dist/tools/docx/ops/replace-paragraph-at-body-index.js +0 -25
- package/dist/tools/docx/ops/replace-paragraph-text-exact.d.ts +0 -21
- package/dist/tools/docx/ops/replace-paragraph-text-exact.js +0 -36
- package/dist/tools/docx/ops/replace-table-cell-text.d.ts +0 -25
- package/dist/tools/docx/ops/replace-table-cell-text.js +0 -85
- package/dist/tools/docx/ops/set-color-for-paragraph-exact.d.ts +0 -9
- package/dist/tools/docx/ops/set-color-for-paragraph-exact.js +0 -24
- package/dist/tools/docx/ops/set-color-for-style.d.ts +0 -13
- package/dist/tools/docx/ops/set-color-for-style.js +0 -31
- package/dist/tools/docx/ops/set-paragraph-style-at-body-index.d.ts +0 -8
- package/dist/tools/docx/ops/set-paragraph-style-at-body-index.js +0 -57
- package/dist/tools/docx/ops/table-set-cell-text.d.ts +0 -9
- package/dist/tools/docx/ops/table-set-cell-text.js +0 -40
- package/dist/tools/docx/parsers/image-extractor.d.ts +0 -18
- package/dist/tools/docx/parsers/image-extractor.js +0 -61
- package/dist/tools/docx/parsers/index.d.ts +0 -9
- package/dist/tools/docx/parsers/index.js +0 -9
- package/dist/tools/docx/parsers/paragraph-parser.d.ts +0 -2
- package/dist/tools/docx/parsers/paragraph-parser.js +0 -88
- package/dist/tools/docx/parsers/table-parser.d.ts +0 -9
- package/dist/tools/docx/parsers/table-parser.js +0 -72
- package/dist/tools/docx/parsers/xml-parser.d.ts +0 -25
- package/dist/tools/docx/parsers/xml-parser.js +0 -71
- package/dist/tools/docx/parsers/zip-reader.d.ts +0 -23
- package/dist/tools/docx/parsers/zip-reader.js +0 -52
- package/dist/tools/docx/read.d.ts +0 -27
- package/dist/tools/docx/read.js +0 -308
- package/dist/tools/docx/relationships.d.ts +0 -22
- package/dist/tools/docx/relationships.js +0 -76
- package/dist/tools/docx/structure.d.ts +0 -25
- package/dist/tools/docx/structure.js +0 -102
- package/dist/tools/docx/styled-html-parser.d.ts +0 -23
- package/dist/tools/docx/styled-html-parser.js +0 -1262
- package/dist/tools/docx/types.d.ts +0 -213
- package/dist/tools/docx/types.js +0 -5
- package/dist/tools/docx/utils/escaping.d.ts +0 -13
- package/dist/tools/docx/utils/escaping.js +0 -26
- package/dist/tools/docx/utils/images.d.ts +0 -9
- package/dist/tools/docx/utils/images.js +0 -26
- package/dist/tools/docx/utils/index.d.ts +0 -12
- package/dist/tools/docx/utils/index.js +0 -17
- package/dist/tools/docx/utils/markdown.d.ts +0 -13
- package/dist/tools/docx/utils/markdown.js +0 -32
- package/dist/tools/docx/utils/paths.d.ts +0 -15
- package/dist/tools/docx/utils/paths.js +0 -27
- package/dist/tools/docx/utils/versioning.d.ts +0 -25
- package/dist/tools/docx/utils/versioning.js +0 -55
- package/dist/tools/docx/utils.d.ts +0 -101
- package/dist/tools/docx/utils.js +0 -299
- package/dist/tools/docx/validate.d.ts +0 -33
- package/dist/tools/docx/validate.js +0 -49
- package/dist/tools/docx/validators.d.ts +0 -13
- package/dist/tools/docx/validators.js +0 -40
- package/dist/tools/docx/write.d.ts +0 -17
- package/dist/tools/docx/write.js +0 -88
- package/dist/tools/docx/xml-view-test.js +0 -63
- package/dist/tools/docx/xml-view.d.ts +0 -56
- package/dist/tools/docx/xml-view.js +0 -169
- package/dist/tools/docx/zip.d.ts +0 -21
- package/dist/tools/docx/zip.js +0 -35
- package/dist/tools/pdf-processor.js +0 -3
- package/dist/tools/search.d.ts +0 -32
- package/dist/tools/search.js +0 -202
- package/dist/ui/file-preview/src/app.d.ts +0 -4
- package/dist/ui/file-preview/src/app.js +0 -800
- package/dist/utils/crash-logger.d.ts +0 -18
- package/dist/utils/crash-logger.js +0 -44
- package/dist/utils/dedent.d.ts +0 -8
- package/dist/utils/dedent.js +0 -38
- /package/dist/{http-server-auto-tunnel.d.ts → ui/config-editor/main.d.ts} +0 -0
- /package/dist/{test-docx.d.ts → ui/config-editor/src/main.d.ts} +0 -0
- /package/dist/{tools/docx/xml-view-test.d.ts → ui/file-preview/main.d.ts} +0 -0
- /package/dist/ui/file-preview/src/components/{toolbar.d.ts → Toolbar.d.ts} +0 -0
- /package/dist/ui/file-preview/src/components/{toolbar.js → Toolbar.js} +0 -0
- /package/dist/{tools/pdf-processor.d.ts → ui/file-preview/src/model.js} +0 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { slugifyMarkdownHeading } from './slugify.js';
|
|
2
|
+
const WIKI_LINK_PATTERN = /\[\[([^\]|#]*)(?:#([^\]|]+))?(?:\|([^\]]+))?\]\]/g;
|
|
3
|
+
const FENCE_PATTERN = /^(`{3,}|~{3,})/;
|
|
4
|
+
function isWindowsAbsolutePath(value) {
|
|
5
|
+
return /^[A-Za-z]:[\\/]/.test(value);
|
|
6
|
+
}
|
|
7
|
+
function normalizePathSeparators(value) {
|
|
8
|
+
return value.replace(/\\/g, '/');
|
|
9
|
+
}
|
|
10
|
+
function normalizeFilePath(value) {
|
|
11
|
+
const normalized = normalizePathSeparators(value);
|
|
12
|
+
return normalized.replace(/\/+/g, '/');
|
|
13
|
+
}
|
|
14
|
+
function encodeLinkPath(pathValue) {
|
|
15
|
+
return encodeURI(normalizePathSeparators(pathValue));
|
|
16
|
+
}
|
|
17
|
+
function safeDecodeURIComponent(value) {
|
|
18
|
+
try {
|
|
19
|
+
return decodeURIComponent(value);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function parseWikiLink(rawHref) {
|
|
26
|
+
const match = rawHref.match(/^\[\[([^\]|#]*)(?:#([^\]|]+))?(?:\|([^\]]+))?\]\]$/);
|
|
27
|
+
if (!match) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
path: (match[1] ?? '').trim(),
|
|
32
|
+
anchor: match[2]?.trim(),
|
|
33
|
+
alias: match[3]?.trim(),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function buildWikiDisplayText(link) {
|
|
37
|
+
if (link.alias && link.alias.length > 0) {
|
|
38
|
+
return link.alias;
|
|
39
|
+
}
|
|
40
|
+
if (link.path && link.anchor) {
|
|
41
|
+
return `${link.path}#${link.anchor}`;
|
|
42
|
+
}
|
|
43
|
+
if (link.path) {
|
|
44
|
+
return link.path;
|
|
45
|
+
}
|
|
46
|
+
return link.anchor ?? '';
|
|
47
|
+
}
|
|
48
|
+
function appendMarkdownExtension(pathValue) {
|
|
49
|
+
if (/\.[A-Za-z0-9_-]+$/.test(pathValue)) {
|
|
50
|
+
return pathValue;
|
|
51
|
+
}
|
|
52
|
+
return `${pathValue}.md`;
|
|
53
|
+
}
|
|
54
|
+
function buildWikiHref(link) {
|
|
55
|
+
if (!link.path) {
|
|
56
|
+
if (!link.anchor) {
|
|
57
|
+
return '#';
|
|
58
|
+
}
|
|
59
|
+
return `#${slugifyMarkdownHeading(link.anchor)}`;
|
|
60
|
+
}
|
|
61
|
+
const normalizedPath = appendMarkdownExtension(normalizePathSeparators(link.path));
|
|
62
|
+
const prefixedPath = normalizedPath.startsWith('./')
|
|
63
|
+
|| normalizedPath.startsWith('../')
|
|
64
|
+
|| normalizedPath.startsWith('/')
|
|
65
|
+
|| isWindowsAbsolutePath(normalizedPath)
|
|
66
|
+
? normalizedPath
|
|
67
|
+
: `./${normalizedPath}`;
|
|
68
|
+
const encodedPath = encodeLinkPath(prefixedPath);
|
|
69
|
+
if (!link.anchor) {
|
|
70
|
+
return encodedPath;
|
|
71
|
+
}
|
|
72
|
+
return `${encodedPath}#${slugifyMarkdownHeading(link.anchor)}`;
|
|
73
|
+
}
|
|
74
|
+
function replaceWikiLinksOutsideInlineCode(line) {
|
|
75
|
+
const segments = line.split(/(`[^`]*`)/g);
|
|
76
|
+
return segments.map((segment) => {
|
|
77
|
+
if (segment.startsWith('`') && segment.endsWith('`')) {
|
|
78
|
+
return segment;
|
|
79
|
+
}
|
|
80
|
+
return segment.replace(WIKI_LINK_PATTERN, (match) => {
|
|
81
|
+
const parsed = parseWikiLink(match);
|
|
82
|
+
if (!parsed) {
|
|
83
|
+
return match;
|
|
84
|
+
}
|
|
85
|
+
const displayText = buildWikiDisplayText(parsed);
|
|
86
|
+
const href = buildWikiHref(parsed);
|
|
87
|
+
return `[${displayText}](${href} "mcp-wiki:${encodeURIComponent(match)}")`;
|
|
88
|
+
});
|
|
89
|
+
}).join('');
|
|
90
|
+
}
|
|
91
|
+
function decodeAnchorFragment(fragment) {
|
|
92
|
+
if (!fragment || fragment.length === 0) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
return safeDecodeURIComponent(fragment);
|
|
96
|
+
}
|
|
97
|
+
function splitHref(rawHref) {
|
|
98
|
+
const hashIndex = rawHref.indexOf('#');
|
|
99
|
+
if (hashIndex === -1) {
|
|
100
|
+
return { pathPart: rawHref };
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
pathPart: rawHref.slice(0, hashIndex),
|
|
104
|
+
anchorPart: rawHref.slice(hashIndex + 1),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function getDirectoryPath(filePath) {
|
|
108
|
+
const normalized = normalizeFilePath(filePath);
|
|
109
|
+
const lastSlashIndex = normalized.lastIndexOf('/');
|
|
110
|
+
if (lastSlashIndex < 0) {
|
|
111
|
+
return '.';
|
|
112
|
+
}
|
|
113
|
+
return lastSlashIndex === 0 ? '/' : normalized.slice(0, lastSlashIndex);
|
|
114
|
+
}
|
|
115
|
+
function toDirectoryFileUrl(directoryPath) {
|
|
116
|
+
const normalized = normalizeFilePath(directoryPath);
|
|
117
|
+
const withTrailingSlash = normalized.endsWith('/') ? normalized : `${normalized}/`;
|
|
118
|
+
if (isWindowsAbsolutePath(withTrailingSlash)) {
|
|
119
|
+
return new URL(`file:///${encodeLinkPath(withTrailingSlash)}`);
|
|
120
|
+
}
|
|
121
|
+
if (withTrailingSlash.startsWith('/')) {
|
|
122
|
+
return new URL(`file://${encodeLinkPath(withTrailingSlash)}`);
|
|
123
|
+
}
|
|
124
|
+
return new URL(`file:///${encodeLinkPath(withTrailingSlash)}`);
|
|
125
|
+
}
|
|
126
|
+
function fromFileUrl(url) {
|
|
127
|
+
const decodedPath = safeDecodeURIComponent(url.pathname);
|
|
128
|
+
if (/^\/[A-Za-z]:\//.test(decodedPath)) {
|
|
129
|
+
return decodedPath.slice(1);
|
|
130
|
+
}
|
|
131
|
+
return decodedPath;
|
|
132
|
+
}
|
|
133
|
+
function isExternalHref(rawHref) {
|
|
134
|
+
return /^[A-Za-z][A-Za-z0-9+.-]*:/.test(rawHref) && !isWindowsAbsolutePath(rawHref);
|
|
135
|
+
}
|
|
136
|
+
function resolveFileTargetPath(currentPath, rawPath) {
|
|
137
|
+
const normalizedRawPath = normalizePathSeparators(safeDecodeURIComponent(rawPath));
|
|
138
|
+
if (normalizedRawPath.startsWith('/') || isWindowsAbsolutePath(normalizedRawPath)) {
|
|
139
|
+
return normalizeFilePath(normalizedRawPath);
|
|
140
|
+
}
|
|
141
|
+
const baseDirectory = getDirectoryPath(currentPath);
|
|
142
|
+
if (baseDirectory === '.' && !normalizeFilePath(currentPath).includes('/')) {
|
|
143
|
+
return normalizeFilePath(normalizedRawPath);
|
|
144
|
+
}
|
|
145
|
+
const resolvedUrl = new URL(encodeURI(normalizedRawPath), toDirectoryFileUrl(baseDirectory));
|
|
146
|
+
return normalizeFilePath(fromFileUrl(resolvedUrl));
|
|
147
|
+
}
|
|
148
|
+
export function rewriteWikiLinks(source) {
|
|
149
|
+
const lines = source.split('\n');
|
|
150
|
+
let activeFence = null;
|
|
151
|
+
return lines.map((line) => {
|
|
152
|
+
const trimmedStart = line.trimStart();
|
|
153
|
+
const fenceMatch = trimmedStart.match(FENCE_PATTERN);
|
|
154
|
+
if (fenceMatch) {
|
|
155
|
+
const marker = fenceMatch[1];
|
|
156
|
+
if (!activeFence) {
|
|
157
|
+
activeFence = marker;
|
|
158
|
+
}
|
|
159
|
+
else if (marker[0] === activeFence[0] && marker.length >= activeFence.length) {
|
|
160
|
+
activeFence = null;
|
|
161
|
+
}
|
|
162
|
+
return line;
|
|
163
|
+
}
|
|
164
|
+
if (activeFence) {
|
|
165
|
+
return line;
|
|
166
|
+
}
|
|
167
|
+
return replaceWikiLinksOutsideInlineCode(line);
|
|
168
|
+
}).join('\n');
|
|
169
|
+
}
|
|
170
|
+
export function resolveMarkdownLink(currentPath, rawHref) {
|
|
171
|
+
const wikiLink = parseWikiLink(rawHref);
|
|
172
|
+
if (wikiLink) {
|
|
173
|
+
const href = buildWikiHref(wikiLink);
|
|
174
|
+
if (href.startsWith('#')) {
|
|
175
|
+
return {
|
|
176
|
+
kind: 'anchor',
|
|
177
|
+
href: rawHref,
|
|
178
|
+
anchor: decodeAnchorFragment(href.slice(1)),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
const [pathPart, anchorPart] = href.split('#');
|
|
182
|
+
return {
|
|
183
|
+
kind: 'file',
|
|
184
|
+
href: rawHref,
|
|
185
|
+
targetPath: resolveFileTargetPath(currentPath, pathPart),
|
|
186
|
+
...(anchorPart ? { anchor: decodeAnchorFragment(anchorPart) } : {}),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
if (isExternalHref(rawHref)) {
|
|
190
|
+
return {
|
|
191
|
+
kind: 'external',
|
|
192
|
+
href: rawHref,
|
|
193
|
+
url: rawHref,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
if (rawHref.startsWith('#')) {
|
|
197
|
+
return {
|
|
198
|
+
kind: 'anchor',
|
|
199
|
+
href: rawHref,
|
|
200
|
+
anchor: decodeAnchorFragment(rawHref.slice(1)),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
const { pathPart, anchorPart } = splitHref(rawHref);
|
|
204
|
+
return {
|
|
205
|
+
kind: 'file',
|
|
206
|
+
href: rawHref,
|
|
207
|
+
targetPath: resolveFileTargetPath(currentPath, pathPart),
|
|
208
|
+
...(anchorPart ? { anchor: decodeAnchorFragment(anchorPart) } : {}),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// markdown-it is intentionally typed locally here to avoid maintaining ambient module declarations.
|
|
2
|
+
// @ts-expect-error markdown-it does not provide local TypeScript typings in this setup.
|
|
3
|
+
import MarkdownIt from 'markdown-it';
|
|
4
|
+
import { rewriteWikiLinks } from './linking.js';
|
|
5
|
+
import { createSlugTracker } from './slugify.js';
|
|
6
|
+
import { extractInlineText } from './utils.js';
|
|
7
|
+
const MarkdownItCtor = MarkdownIt;
|
|
8
|
+
const outlineParser = new MarkdownItCtor({
|
|
9
|
+
html: false,
|
|
10
|
+
linkify: true,
|
|
11
|
+
typographer: false,
|
|
12
|
+
});
|
|
13
|
+
export function extractMarkdownOutline(source) {
|
|
14
|
+
const tokens = outlineParser.parse(rewriteWikiLinks(source), {});
|
|
15
|
+
const nextSlug = createSlugTracker();
|
|
16
|
+
const outline = [];
|
|
17
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
18
|
+
const token = tokens[index];
|
|
19
|
+
if (token.type !== 'heading_open' || typeof token.tag !== 'string') {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const level = Number.parseInt(token.tag.replace(/^h/i, ''), 10);
|
|
23
|
+
if (!Number.isFinite(level)) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const inlineToken = tokens[index + 1];
|
|
27
|
+
const text = extractInlineText(inlineToken).trim();
|
|
28
|
+
if (!text) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const lineMap = Array.isArray(token.map) ? token.map : undefined;
|
|
32
|
+
outline.push({
|
|
33
|
+
id: nextSlug(text),
|
|
34
|
+
text,
|
|
35
|
+
level,
|
|
36
|
+
line: Array.isArray(lineMap) && typeof lineMap[0] === 'number' ? lineMap[0] + 1 : outline.length + 1,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return outline;
|
|
40
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MarkdownOutlineItem } from './outline.js';
|
|
2
|
+
export declare function getRenderedMarkdownCopyText(content: string): string;
|
|
3
|
+
export declare function renderMarkdownWorkspacePreview(options: {
|
|
4
|
+
content: string;
|
|
5
|
+
outline: MarkdownOutlineItem[];
|
|
6
|
+
activeHeadingId?: string | null;
|
|
7
|
+
showToc?: boolean;
|
|
8
|
+
}): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { renderMarkdown } from '../components/markdown-renderer.js';
|
|
2
|
+
import { renderMarkdownToc } from './toc.js';
|
|
3
|
+
export function getRenderedMarkdownCopyText(content) {
|
|
4
|
+
const html = renderMarkdown(content);
|
|
5
|
+
const normalizedHtml = html
|
|
6
|
+
.replace(/<\s*br\s*\/?>/gi, '\n')
|
|
7
|
+
.replace(/<\/p>/gi, '\n\n')
|
|
8
|
+
.replace(/<\/h[1-6]>/gi, '\n\n')
|
|
9
|
+
.replace(/<\/li>/gi, '\n')
|
|
10
|
+
.replace(/<li>/gi, '- ')
|
|
11
|
+
.replace(/<[^>]+>/g, '');
|
|
12
|
+
return normalizedHtml
|
|
13
|
+
.replace(/ /g, ' ')
|
|
14
|
+
.replace(/&/g, '&')
|
|
15
|
+
.replace(/</g, '<')
|
|
16
|
+
.replace(/>/g, '>')
|
|
17
|
+
.replace(/'/g, "'")
|
|
18
|
+
.replace(/"/g, '"')
|
|
19
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
20
|
+
.trim();
|
|
21
|
+
}
|
|
22
|
+
export function renderMarkdownWorkspacePreview(options) {
|
|
23
|
+
const tocHtml = options.showToc ? renderMarkdownToc(options.outline, options.activeHeadingId) : '';
|
|
24
|
+
const hasToc = tocHtml.length > 0;
|
|
25
|
+
return `
|
|
26
|
+
<div class="markdown-workspace markdown-workspace--preview${hasToc ? ' markdown-workspace--with-toc' : ''}">
|
|
27
|
+
${tocHtml}
|
|
28
|
+
<section class="markdown-workspace-main">
|
|
29
|
+
<article class="markdown markdown-doc">${renderMarkdown(options.content)}</article>
|
|
30
|
+
</section>
|
|
31
|
+
</div>
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function sanitizeSlugPart(text) {
|
|
2
|
+
const normalized = text
|
|
3
|
+
.normalize('NFKD')
|
|
4
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
5
|
+
.toLowerCase()
|
|
6
|
+
.trim()
|
|
7
|
+
.replace(/[^a-z0-9\s-]/g, ' ')
|
|
8
|
+
.replace(/\s+/g, '-')
|
|
9
|
+
.replace(/-+/g, '-')
|
|
10
|
+
.replace(/^-+|-+$/g, '');
|
|
11
|
+
return normalized.length > 0 ? normalized : 'section';
|
|
12
|
+
}
|
|
13
|
+
export function slugifyMarkdownHeading(text) {
|
|
14
|
+
return sanitizeSlugPart(text);
|
|
15
|
+
}
|
|
16
|
+
export function createSlugTracker() {
|
|
17
|
+
const counts = new Map();
|
|
18
|
+
const usedSlugs = new Set();
|
|
19
|
+
return (text) => {
|
|
20
|
+
const baseSlug = slugifyMarkdownHeading(text);
|
|
21
|
+
let nextCount = counts.get(baseSlug) ?? 1;
|
|
22
|
+
let nextSlug = nextCount === 1 ? baseSlug : `${baseSlug}-${nextCount}`;
|
|
23
|
+
while (usedSlugs.has(nextSlug)) {
|
|
24
|
+
nextCount += 1;
|
|
25
|
+
nextSlug = `${baseSlug}-${nextCount}`;
|
|
26
|
+
}
|
|
27
|
+
counts.set(baseSlug, nextCount + 1);
|
|
28
|
+
usedSlugs.add(nextSlug);
|
|
29
|
+
return nextSlug;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MarkdownOutlineItem } from './outline.js';
|
|
2
|
+
export interface MarkdownTocHandle {
|
|
3
|
+
dispose: () => void;
|
|
4
|
+
}
|
|
5
|
+
export declare function renderMarkdownToc(outline: MarkdownOutlineItem[], activeHeadingId?: string | null): string;
|
|
6
|
+
export declare function attachMarkdownToc(options: {
|
|
7
|
+
shell: HTMLElement;
|
|
8
|
+
outline: MarkdownOutlineItem[];
|
|
9
|
+
scrollContainer: HTMLElement;
|
|
10
|
+
onSelect: (headingId: string) => void;
|
|
11
|
+
}): MarkdownTocHandle | null;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
function escapeHtml(value) {
|
|
2
|
+
return value
|
|
3
|
+
.replace(/&/g, '&')
|
|
4
|
+
.replace(/</g, '<')
|
|
5
|
+
.replace(/>/g, '>')
|
|
6
|
+
.replace(/"/g, '"')
|
|
7
|
+
.replace(/'/g, ''');
|
|
8
|
+
}
|
|
9
|
+
function setActiveItem(nav, activeId) {
|
|
10
|
+
const buttons = Array.from(nav.querySelectorAll('[data-toc-id]'));
|
|
11
|
+
buttons.forEach((button) => {
|
|
12
|
+
const isActive = button.dataset.tocId === activeId;
|
|
13
|
+
button.classList.toggle('is-active', isActive);
|
|
14
|
+
button.setAttribute('aria-current', isActive ? 'location' : 'false');
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export function renderMarkdownToc(outline, activeHeadingId) {
|
|
18
|
+
if (outline.length === 0) {
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
21
|
+
const items = outline.map((item) => {
|
|
22
|
+
const activeClass = item.id === activeHeadingId ? ' is-active' : '';
|
|
23
|
+
return `<button class="markdown-toc-link${activeClass}" type="button" data-toc-id="${escapeHtml(item.id)}" data-level="${item.level}" aria-current="${item.id === activeHeadingId ? 'location' : 'false'}">${escapeHtml(item.text)}</button>`;
|
|
24
|
+
}).join('');
|
|
25
|
+
return `
|
|
26
|
+
<aside class="markdown-toc-shell" aria-label="Table of contents">
|
|
27
|
+
<div class="markdown-toc-title">Contents</div>
|
|
28
|
+
<nav class="markdown-toc-nav">${items}</nav>
|
|
29
|
+
</aside>
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
export function attachMarkdownToc(options) {
|
|
33
|
+
const nav = options.shell.querySelector('.markdown-toc-nav');
|
|
34
|
+
if (!nav) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const handleClick = (event) => {
|
|
38
|
+
const target = event.target;
|
|
39
|
+
const button = target?.closest('[data-toc-id]');
|
|
40
|
+
const headingId = button?.dataset.tocId;
|
|
41
|
+
if (!headingId) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
options.onSelect(headingId);
|
|
45
|
+
setActiveItem(nav, headingId);
|
|
46
|
+
};
|
|
47
|
+
const updateActiveHeading = () => {
|
|
48
|
+
const headings = options.outline
|
|
49
|
+
.map((item) => {
|
|
50
|
+
const element = document.getElementById(item.id);
|
|
51
|
+
return element ? { item, element } : null;
|
|
52
|
+
})
|
|
53
|
+
.filter((entry) => entry !== null);
|
|
54
|
+
if (headings.length === 0) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const scrollTop = options.scrollContainer.scrollTop;
|
|
58
|
+
const nextActive = headings.reduce((activeId, current) => {
|
|
59
|
+
if (current.element.offsetTop - scrollTop <= 96) {
|
|
60
|
+
return current.item.id;
|
|
61
|
+
}
|
|
62
|
+
return activeId;
|
|
63
|
+
}, headings[0].item.id);
|
|
64
|
+
setActiveItem(nav, nextActive);
|
|
65
|
+
};
|
|
66
|
+
nav.addEventListener('click', handleClick);
|
|
67
|
+
options.scrollContainer.addEventListener('scroll', updateActiveHeading, { passive: true });
|
|
68
|
+
updateActiveHeading();
|
|
69
|
+
return {
|
|
70
|
+
dispose: () => {
|
|
71
|
+
nav.removeEventListener('click', handleClick);
|
|
72
|
+
options.scrollContainer.removeEventListener('scroll', updateActiveHeading);
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extractInlineText(token: Record<string, unknown> | undefined): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function extractInlineText(token) {
|
|
2
|
+
if (!token) {
|
|
3
|
+
return '';
|
|
4
|
+
}
|
|
5
|
+
const children = Array.isArray(token.children) ? token.children : [];
|
|
6
|
+
if (children.length === 0) {
|
|
7
|
+
return typeof token.content === 'string' ? token.content : '';
|
|
8
|
+
}
|
|
9
|
+
return children.map((child) => {
|
|
10
|
+
if (typeof child.content === 'string') {
|
|
11
|
+
return child.content;
|
|
12
|
+
}
|
|
13
|
+
return '';
|
|
14
|
+
}).join('');
|
|
15
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ReadRange {
|
|
2
|
+
fromLine: number;
|
|
3
|
+
toLine: number;
|
|
4
|
+
totalLines: number;
|
|
5
|
+
isPartial: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function stripReadStatusLine(content: string): string;
|
|
8
|
+
export declare function parseReadRange(content: string): ReadRange | undefined;
|
|
9
|
+
export declare function getMarkdownEditAvailability(options: {
|
|
10
|
+
content: string;
|
|
11
|
+
}): {
|
|
12
|
+
canEdit: true;
|
|
13
|
+
} | {
|
|
14
|
+
canEdit: false;
|
|
15
|
+
reason: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function getMarkdownFullscreenAvailability(options: {
|
|
18
|
+
availableDisplayModes?: string[];
|
|
19
|
+
}): {
|
|
20
|
+
canFullscreen: true;
|
|
21
|
+
} | {
|
|
22
|
+
canFullscreen: false;
|
|
23
|
+
reason: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function shouldAutoLoadMarkdownOnEnterFullscreen(content: string): boolean;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export function stripReadStatusLine(content) {
|
|
2
|
+
return content.replace(/^\[Reading [^\]]+\]\r?\n(?:\r?\n)?/, '');
|
|
3
|
+
}
|
|
4
|
+
export function parseReadRange(content) {
|
|
5
|
+
const match = content.match(/^\[Reading (\d+) lines from (?:line )?(\d+|start) \(total: (\d+) lines/);
|
|
6
|
+
if (!match) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const count = Number.parseInt(match[1], 10);
|
|
10
|
+
const fromLine = match[2] === 'start' ? 1 : Number.parseInt(match[2], 10);
|
|
11
|
+
const totalLines = Number.parseInt(match[3], 10);
|
|
12
|
+
return {
|
|
13
|
+
fromLine,
|
|
14
|
+
toLine: fromLine + count - 1,
|
|
15
|
+
totalLines,
|
|
16
|
+
isPartial: count < totalLines,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function getMarkdownEditAvailability(options) {
|
|
20
|
+
const readRange = parseReadRange(options.content);
|
|
21
|
+
if (readRange?.isPartial) {
|
|
22
|
+
return {
|
|
23
|
+
canEdit: false,
|
|
24
|
+
reason: 'Load the full document before editing.',
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return { canEdit: true };
|
|
28
|
+
}
|
|
29
|
+
export function getMarkdownFullscreenAvailability(options) {
|
|
30
|
+
if (!options.availableDisplayModes?.includes('fullscreen')) {
|
|
31
|
+
return {
|
|
32
|
+
canFullscreen: false,
|
|
33
|
+
reason: 'Fullscreen editing is unavailable in this host.',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return { canFullscreen: true };
|
|
37
|
+
}
|
|
38
|
+
export function shouldAutoLoadMarkdownOnEnterFullscreen(content) {
|
|
39
|
+
return parseReadRange(content)?.isPartial === true;
|
|
40
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DocumentOutlineItem } from './document-outline.js';
|
|
2
|
+
import type { FilePreviewStructuredContent } from '../../../types.js';
|
|
3
|
+
import type { MarkdownEditorView } from './markdown/editor.js';
|
|
4
|
+
export type RenderPayload = FilePreviewStructuredContent & {
|
|
5
|
+
content: string;
|
|
6
|
+
};
|
|
7
|
+
export interface MarkdownWorkspaceState {
|
|
8
|
+
filePath: string;
|
|
9
|
+
sourceContent: string;
|
|
10
|
+
fullDocumentContent: string;
|
|
11
|
+
draftContent: string;
|
|
12
|
+
outline: DocumentOutlineItem[];
|
|
13
|
+
mode: 'edit';
|
|
14
|
+
dirty: boolean;
|
|
15
|
+
activeHeadingId: string | null;
|
|
16
|
+
pendingAnchor: string | null;
|
|
17
|
+
notice: string | null;
|
|
18
|
+
error: string | null;
|
|
19
|
+
saving: boolean;
|
|
20
|
+
loadingDocument: boolean;
|
|
21
|
+
editorView: MarkdownEditorView;
|
|
22
|
+
editorScrollTop: number;
|
|
23
|
+
saveIndicator: 'idle' | 'saving' | 'saved';
|
|
24
|
+
fileDeleted: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface RenderBodyResult {
|
|
27
|
+
html: string;
|
|
28
|
+
notice?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface FileTypeCapabilities {
|
|
31
|
+
supportsPreview: boolean;
|
|
32
|
+
canCopy: boolean;
|
|
33
|
+
canOpenInFolder: boolean;
|
|
34
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RenderPayload } from './model.js';
|
|
2
|
+
import type { MarkdownController } from './markdown/controller.js';
|
|
3
|
+
import type { HtmlPreviewMode } from './types.js';
|
|
4
|
+
export declare function attachPanelActions(options: {
|
|
5
|
+
container: HTMLElement;
|
|
6
|
+
payload: RenderPayload;
|
|
7
|
+
htmlMode: HtmlPreviewMode;
|
|
8
|
+
getIsExpanded: () => boolean;
|
|
9
|
+
callTool?: (name: string, args: Record<string, unknown>) => Promise<unknown | undefined>;
|
|
10
|
+
trackUiEvent?: (event: string, params?: Record<string, unknown>) => void;
|
|
11
|
+
getFileExtensionForAnalytics: (filePath: string) => string;
|
|
12
|
+
buildOpenInFolderCommand: (filePath: string) => string | undefined;
|
|
13
|
+
buildOpenInEditorCommand: (filePath: string) => string | undefined;
|
|
14
|
+
render: (payload?: RenderPayload, htmlMode?: HtmlPreviewMode, expandedState?: boolean) => void;
|
|
15
|
+
updateSaveStatus: (label: string, statusClass: string) => void;
|
|
16
|
+
markdownController: MarkdownController;
|
|
17
|
+
}): void;
|