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}
+
+ {/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}
-
-
-
+
+
+
+