> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.swellsystem.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Workspace

# Workspace

The Workspace module provides wiki-style pages for documentation, notes, and linking to other app modules.

## Overview

- **Workspace** is available from the app sidebar when the workspace module is enabled for your account.
- Create **pages** (documents) and add **blocks**: paragraphs, headings, lists, to-dos, code, quotes, dividers, tables, link previews, embeds, columns, dates, synced blocks, and links to Projects, Tasks, Companies, and Contacts.
- **Inline editing**: Click any block to edit it; no need to use the pencil icon.
- **Export**: Download pages as PDF, Markdown, or HTML from the Export dropdown.
- **Share link**: Turn on "Share" to get a view-only public URL. Anyone with the link can view the page without logging in.
- **Client portal**: In Client Portal settings you can add a **Workspace Page** type. Pick a workspace page to show in the portal; optionally allow clients to edit it.

## Page Templates

When creating a new page, choose a template:

- **Blank** – Empty page
- **Meeting Notes** – Pre-structured with Attendees, Action items, Next steps
- **Project Brief** – Overview, Deliverables, to-do items

Templates are defined in `config/workspace.php` and can be extended. Blueprint-based templates (from the marketplace) are also supported when configured.

## Block Types

| Block | Description |
|-------|-------------|
| Paragraph | Basic text block |
| Heading 1–3 | Section headings |
| Bulleted / Numbered list | List items |
| To-do | Checkbox list items |
| Code | Monospace code block |
| Quote | Indented quote |
| Callout | Highlighted box (info, warning, success) with optional icon |
| Divider | Horizontal line |
| Image | Image with optional caption |
| Table | Table, Board (kanban), or Gallery view |
| Toggle | Collapsible section |
| Link preview | Bookmark with fetched metadata |
| Embed | YouTube and other embeds |
| Columns | 2–3 column layout |
| Date | Date with optional time and reminder |
| Synced block | Reuses content from another block |
| Table of contents | Auto-generated from headings |

## Table Views

Table blocks support three view modes:

- **Table** – Grid layout
- **Board** – Kanban-style columns. Choose "Group by column" to group rows. Drag cards between columns.
- **Gallery** – Grid of cards

When in Board or Table view, you can add **filters** (column contains text) and **sort** (by column, asc/desc).

## Inline Formatting

In text blocks, use Markdown:

- `**bold**` → **bold**
- `*italic*` → *italic*
- `` `code` `` → `code`
- `[text](url)` → link

## Mentions

Type `@` to mention users or pages:

- **@User** – Mentions a user (sends notification)
- **@Page** – Links to another workspace page

Both appear in the autocomplete dropdown. Type `@` with no query to see recent users and pages.

## Block Nesting

- **Indent**: Use the indent button (→) to move a block inside the previous toggle or columns block.
- **Outdent**: Use the outdent button (←) to move a block from inside a toggle/columns back to the page level.

## Keyboard Shortcuts

| Shortcut | Action |
|----------|--------|
| `/` | Block type menu |
| ⌘K / Ctrl+K | Quick switcher (search pages) |
| `?` | Full shortcuts panel |
| ↑ / ↓ | Move focus between blocks (when cursor at start/end) |
| Enter | New block below |
| Backspace | Delete empty block |

## Version History

Click **Version history** to:

- Save the current version manually
- Restore a previous version

Versions are stored per page; the last 30 are kept.

## Comments

Click **Comments** to add page-level comments. Commenters can delete their own comments; page editors can delete any.

## Public Share URL

1. Open a workspace page.
2. Click **Share** to enable sharing.
3. Click **Copy link** and send the URL (e.g. `https://your-app.com/workspace/p/abc123...`) to viewers.
4. Viewers see the page in read-only mode with no login.
5. Turn **Share** off to disable the link.

## Client Portal

1. Go to **Settings** → **Client Portal** → **Custom Pages**.
2. Create a page and set **Page Type** to **Workspace Page**.
3. Choose the **Workspace Page** to display.
4. Optionally check **Allow clients to edit this page**.
5. Add the page to the portal menu (Menu Manager).

## API

The Workspace API (under `/api/v1/workspace`) supports:

- `GET /templates` – List page templates
- `GET /pages` – List pages (tree or flat, with search)
- `POST /pages` – Create page from template (`template_key`, optional `parent_id`)
- `GET /pages/{id}` – Get page with blocks
- `PATCH /pages/{id}` – Update page (content, icon, cover)
- `GET /pages/{id}/versions` – List versions
- `POST /pages/{id}/versions/{versionId}` – Restore version
- `GET /pages/{id}/comments` – List comments
- `POST /pages/{id}/comments` – Add comment
- `POST /table/move-row` – Move table row to a different group (board view), body: `block_id`, `row_index`, `new_group_value`

Use a valid API token with tenant context. See API documentation for request/response formats.
