diff --git a/src/App.svelte b/src/App.svelte index f2ad86e..78ae5cb 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -19,6 +19,7 @@ import { sendTab } from '$lib/send.svelte'; import type { TreeNode } from '$lib/types'; import { onDeepLink } from '$lib/deeplink'; + import { openDocs } from '$lib/help'; let ready = $state(false); @@ -51,6 +52,11 @@ function onKey(e: KeyboardEvent) { const mod = e.ctrlKey || e.metaKey; + if (e.key === 'F1') { + e.preventDefault(); + openDocs(); + return; + } if (!mod) { if (e.key === 'F2' || e.key === 'Escape') return; return; @@ -130,7 +136,11 @@ { id: 'a:import', label: 'Import from Postman, Bruno, Insomnia, OpenAPI or cURL…', group: 'Actions', onselect: () => dialogs.importer() }, { id: 'a:layout', label: 'Toggle response below / beside', group: 'Actions', onselect: () => ws.setLayout(ws.layout === 'columns' ? 'rows' : 'columns') }, { id: 'a:mask', label: ws.maskSecrets ? 'Show secrets' : 'Mask secrets', group: 'Actions', onselect: () => ws.setMask(!ws.maskSecrets) }, - { id: 'a:settings', label: 'Settings', group: 'Actions', onselect: () => ws.openSpecial('settings', null, null, 'Settings') } + { id: 'a:settings', label: 'Settings', group: 'Actions', onselect: () => ws.openSpecial('settings', null, null, 'Settings') }, + { id: 'a:docs', label: 'Documentation', group: 'Help', hint: 'F1', keywords: ['help', 'docs', 'manual'], onselect: () => openDocs() }, + { id: 'a:docs-oauth', label: 'Documentation: OAuth 2.0 and OpenID Connect', group: 'Help', onselect: () => openDocs('oauth-2-0-and-openid-connect') }, + { id: 'a:docs-format', label: 'Documentation: collection format', group: 'Help', onselect: () => openDocs('collection-format') }, + { id: 'a:docs-keys', label: 'Documentation: keyboard shortcuts', group: 'Help', onselect: () => openDocs('keyboard-shortcuts') } ); if (ws.focusCol) { const col = ws.focusCol; diff --git a/src/app.css b/src/app.css index 5798101..2f31d5d 100644 --- a/src/app.css +++ b/src/app.css @@ -45,7 +45,7 @@ --ck-warning: #9a5b00; --ck-font-sans: 'Space Grotesk', system-ui, sans-serif; --ck-font-mono: 'JetBrains Mono', ui-monospace, monospace; - --ck-radius-scale: 0.75; + --ck-radius-scale: 0.5; } .dark, diff --git a/src/lib/help.ts b/src/lib/help.ts new file mode 100644 index 0000000..985388a --- /dev/null +++ b/src/lib/help.ts @@ -0,0 +1,7 @@ +import { openUrl } from '@tauri-apps/plugin-opener'; + + + +export function openDocs(page = 'introduction') { + openUrl(`https://docs.joshicodes.de/b/knock/${page}`).catch(() => {}); +} diff --git a/src/lib/json/JsonForm.svelte b/src/lib/json/JsonForm.svelte index 22c7338..e60e40a 100644 --- a/src/lib/json/JsonForm.svelte +++ b/src/lib/json/JsonForm.svelte @@ -1,5 +1,5 @@ @@ -221,8 +233,7 @@ role="treeitem" aria-selected="false" tabindex="-1" - class="group relative flex min-h-[30px] items-center gap-1 pr-2 hover:bg-hover/40 {dropTarget?.id === n.id ? (dropTarget.after ? 'shadow-[inset_0_-2px_0_var(--knock-cyan)]' : 'shadow-[inset_0_2px_0_var(--knock-cyan)]') : ''}" - style:padding-left="{6 + r.depth * 18}px" + class="group relative flex min-h-[30px] items-center gap-1.5 pr-2 hover:bg-hover/40 {dropTarget?.id === n.id ? (dropTarget.after ? 'shadow-[inset_0_-2px_0_var(--knock-cyan)]' : 'shadow-[inset_0_2px_0_var(--knock-cyan)]') : ''}" use:focusKey={n.id} oncontextmenu={() => (menuRow = r)} ondragover={(e) => { @@ -235,41 +246,40 @@ e.preventDefault(); onDrop(r); }} - > - {#if r.parent} - (drag = r)} - ondragend={() => { - drag = null; - dropTarget = null; - }}> - {:else} - - {/if} - {#if isContainer} - - {:else} - - {/if} - - -
+ > + +
+ {#if r.parent} + (drag = r)} + ondragend={() => { + drag = null; + dropTarget = null; + }}> + {:else} + + {/if} + {#if isContainer} + + {:else} + + {/if} {#if r.entry} - + + {#snippet trigger(attrs)} + + {/snippet} + {#each KINDS as k} + setKind(r, k)}> + {#snippet icon()}{GLYPH[k].g}{/snippet} + {k} + + {/each} +
@@ -394,7 +411,7 @@ {/if} -
+
{#if isContainer}
{#if isContainer && !collapsed.has(n.id) && n.kind === 'object' && ctx && suggestions(r).length} -
+
Schema: {#each suggestions(r) as key} {@const req = ctx.resolve(r.schema)?.required?.includes(key)} diff --git a/src/lib/state/workspace.svelte.ts b/src/lib/state/workspace.svelte.ts index dc61e10..0b714a1 100644 --- a/src/lib/state/workspace.svelte.ts +++ b/src/lib/state/workspace.svelte.ts @@ -108,7 +108,10 @@ class Workspace { // ------------------------------------------------------------ collections async restore() { + // Read everything first: opening a collection saves the (still empty) tab list. const open: string[] = load('knock.open', []); + const savedTabs: { kind: TabKind; col: string | null; id: string | null }[] = load('knock.tabs', []); + const active = load('knock.activeTab', null); for (const root of open) { try { this.upsert(await api.collectionOpen(root)); @@ -116,12 +119,11 @@ class Workspace { /* folder moved or deleted; it simply is not reopened */ } } - const savedTabs: { kind: TabKind; col: string | null; id: string | null }[] = load('knock.tabs', []); for (const t of savedTabs) { if (t.kind === 'request' && t.col && t.id) await this.openRequest(t.col, t.id, false); } - const active = load('knock.activeTab', null); if (active && this.tabs.some((t) => t.key === active)) this.activeKey = active; + this.persistOpen(); } persistOpen() { diff --git a/src/lib/ui/Icon.svelte b/src/lib/ui/Icon.svelte index 46c4e24..670c730 100644 --- a/src/lib/ui/Icon.svelte +++ b/src/lib/ui/Icon.svelte @@ -41,7 +41,8 @@ filter: 'M2.5 3h11L9 8.5V13l-2-1V8.5z', bolt: 'M9 1.5L3.5 9H8l-1 5.5L12.5 7H8z', wrap: 'M2.5 4h11M2.5 8h9a2 2 0 0 1 0 4H9M10.5 10.5 9 12l1.5 1.5M2.5 12h4', - door: 'M4 14V2.5h8V14M2.5 14h11M9.5 8.5h.01' + door: 'M4 14V2.5h8V14M2.5 14h11M9.5 8.5h.01', + help: 'M8 14.5a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13zM6.2 6.2a1.9 1.9 0 0 1 3.6.8c0 1.3-1.8 1.6-1.8 2.8M8 11.6h.01' }; interface Props { diff --git a/src/lib/views/Titlebar.svelte b/src/lib/views/Titlebar.svelte index 8b31897..8ae1437 100644 --- a/src/lib/views/Titlebar.svelte +++ b/src/lib/views/Titlebar.svelte @@ -4,7 +4,7 @@ import Mark from '$lib/ui/Mark.svelte'; import EnvSwitcher from './EnvSwitcher.svelte'; import { ws } from '$lib/state/workspace.svelte'; - import { Kbd } from '@joshicodes/cock'; + import { openDocs } from '$lib/help'; const win = getCurrentWindow(); let maximized = $state(false); @@ -38,16 +38,17 @@ {/if}
-
- -
+
+ +
+ - {/each} -
- - {#if recent.length} -
-
Recent
- {#each recent as r} -
- - -
- {/each} +
+
+ +
+
- {/if} +
+

Nobody has knocked yet.

+

Pick an API and see what comes back. Collections are folders of YAML files; they live in your repository, not in a cloud.

+
+
-
- {#each [['Ctrl Enter', 'Send'], ['Ctrl S', 'Save'], ['Ctrl K', 'Find anything'], ['Ctrl P', 'Filter requests'], ['Ctrl E', 'Switch environment'], ['Ctrl L', 'Focus URL'], ['Ctrl Shift J', 'JSON form / code']] as [k, v]} - {k}{v} - {/each} +
+
    + {#each actions as a} +
  • + +
  • + {/each} +
+ + {#if recent.length} +
+
Recent
+
    + {#each recent as r} + {@const p = parts(r)} +
  • + + +
  • + {/each} +
+
+ {/if} + +

+ {#each [['Ctrl Enter', 'send'], ['Ctrl S', 'save'], ['Ctrl K', 'find'], ['Ctrl E', 'environment'], ['Ctrl Shift J', 'JSON form/code']] as [k, v]} + {k} {v} + {/each} + +

diff --git a/src/lib/views/auth/OAuthConfig.svelte b/src/lib/views/auth/OAuthConfig.svelte index c4b46c0..5e54aa9 100644 --- a/src/lib/views/auth/OAuthConfig.svelte +++ b/src/lib/views/auth/OAuthConfig.svelte @@ -164,7 +164,7 @@
{#if grant === 'authorization_code'} -
+
Redirect URI diff --git a/src/lib/views/request/RequestView.svelte b/src/lib/views/request/RequestView.svelte index 3558aea..820b69c 100644 --- a/src/lib/views/request/RequestView.svelte +++ b/src/lib/views/request/RequestView.svelte @@ -45,7 +45,7 @@
{/if} {#if tab.diskChanged} -
+
This file changed on disk while you had unsaved edits. @@ -53,7 +53,7 @@
{/if} {#if tab.draft?.settings && !tab.draft.settings.verify_tls} -
+
TLS verification is off for this request
{/if} diff --git a/src/lib/views/request/UrlBar.svelte b/src/lib/views/request/UrlBar.svelte index 1379139..9df105a 100644 --- a/src/lib/views/request/UrlBar.svelte +++ b/src/lib/views/request/UrlBar.svelte @@ -1,5 +1,6 @@