forked from mirror/crumbs-original
Compare commits
@@ -46,7 +46,18 @@ jobs:
|
|||||||
cache: pnpm
|
cache: pnpm
|
||||||
|
|
||||||
- run: pnpm install --frozen-lockfile
|
- run: pnpm install --frozen-lockfile
|
||||||
- run: pnpm test:unit
|
- run: pnpm test:unit:coverage
|
||||||
|
|
||||||
|
- name: Coverage summary
|
||||||
|
if: always()
|
||||||
|
run: bash scripts/coverage-summary.sh "Unit Test Coverage" coverage/unit/coverage-summary.json
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: unit-coverage
|
||||||
|
path: coverage/unit/
|
||||||
|
retention-days: 14
|
||||||
|
|
||||||
e2e-tests:
|
e2e-tests:
|
||||||
name: E2E Tests
|
name: E2E Tests
|
||||||
@@ -80,9 +91,25 @@ jobs:
|
|||||||
if: steps.playwright-cache.outputs.cache-hit == 'true'
|
if: steps.playwright-cache.outputs.cache-hit == 'true'
|
||||||
run: npx playwright install-deps chromium
|
run: npx playwright install-deps chromium
|
||||||
|
|
||||||
|
- name: Build (with coverage instrumentation)
|
||||||
|
run: pnpm build
|
||||||
|
env:
|
||||||
|
DATABASE_URL: ./data/test-crumbs.db
|
||||||
|
NODE_ENV: test
|
||||||
|
VITE_COVERAGE: 'true'
|
||||||
|
|
||||||
- run: pnpm test:e2e
|
- run: pnpm test:e2e
|
||||||
env:
|
env:
|
||||||
CI: true
|
CI: true
|
||||||
|
VITE_COVERAGE: 'true'
|
||||||
|
|
||||||
|
- name: Merge E2E coverage
|
||||||
|
if: always()
|
||||||
|
run: npx nyc report
|
||||||
|
|
||||||
|
- name: Coverage summary
|
||||||
|
if: always()
|
||||||
|
run: bash scripts/coverage-summary.sh "E2E Test Coverage" coverage/e2e/coverage-summary.json
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
if: always()
|
if: always()
|
||||||
@@ -91,7 +118,14 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
playwright-report/
|
playwright-report/
|
||||||
test-results/
|
test-results/
|
||||||
retention-days: 30
|
retention-days: 7
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: e2e-coverage
|
||||||
|
path: coverage/e2e/
|
||||||
|
retention-days: 14
|
||||||
|
|
||||||
docker-build:
|
docker-build:
|
||||||
name: Docker Build
|
name: Docker Build
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ vite.config.ts.timestamp-*
|
|||||||
/test-results
|
/test-results
|
||||||
/playwright-report
|
/playwright-report
|
||||||
|
|
||||||
|
# Coverage
|
||||||
|
/coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
# Claude Code
|
# Claude Code
|
||||||
/.claude/
|
/.claude/
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"report-dir": "coverage/e2e",
|
||||||
|
"temp-dir": "coverage/e2e/raw",
|
||||||
|
"reporter": ["text", "html", "lcov", "json-summary"],
|
||||||
|
"include": ["src/**"],
|
||||||
|
"exclude": ["node_modules", "tests"]
|
||||||
|
}
|
||||||
@@ -98,6 +98,10 @@ tests/
|
|||||||
unit/ # Vitest unit tests
|
unit/ # Vitest unit tests
|
||||||
e2e/ # Playwright e2e tests (Gherkin-style)
|
e2e/ # Playwright e2e tests (Gherkin-style)
|
||||||
helpers/fixtures.ts # Shared authenticatedPage fixture
|
helpers/fixtures.ts # Shared authenticatedPage fixture
|
||||||
|
website/ # Static landing page (crumbs.bretzel.app)
|
||||||
|
index.html # Landing page with feature cards, screenshots, deploy section
|
||||||
|
styles.css # Landing page styles (retro parchment theme)
|
||||||
|
assets/ # Favicon, screenshots
|
||||||
```
|
```
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
.PHONY: help dev build preview check test test-unit test-e2e lint \
|
.PHONY: help dev build preview check test test-unit test-e2e \
|
||||||
|
test-unit-coverage test-e2e-coverage lint \
|
||||||
db-push db-generate db-migrate db-studio docs-api \
|
db-push db-generate db-migrate db-studio docs-api \
|
||||||
install docker-build docker-up docker-down docker-logs clean \
|
install docker-build docker-up docker-down docker-logs clean \
|
||||||
release release-patch release-minor release-major
|
release release-patch release-minor release-major
|
||||||
@@ -27,6 +28,12 @@ test-unit: ## Run unit tests only
|
|||||||
test-e2e: ## Run e2e tests only
|
test-e2e: ## Run e2e tests only
|
||||||
pnpm test:e2e
|
pnpm test:e2e
|
||||||
|
|
||||||
|
test-unit-coverage: ## Run unit tests with coverage
|
||||||
|
pnpm test:unit:coverage
|
||||||
|
|
||||||
|
test-e2e-coverage: ## Run e2e tests with coverage
|
||||||
|
VITE_COVERAGE=true pnpm build && pnpm test:e2e && npx nyc report
|
||||||
|
|
||||||
lint: ## Run linter
|
lint: ## Run linter
|
||||||
pnpm lint
|
pnpm lint
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
crumbs:
|
crumbs:
|
||||||
image: ghcr.io/bretzel-app/crumbs:0.12.1
|
image: ghcr.io/bretzel-app/crumbs:0.16.1
|
||||||
container_name: crumbs
|
container_name: crumbs
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
|
|||||||
+1
-1
@@ -25,8 +25,8 @@
|
|||||||
- Ordered lists (`1. item`)
|
- Ordered lists (`1. item`)
|
||||||
- Code blocks (triple backtick)
|
- Code blocks (triple backtick)
|
||||||
- Inline code (single backtick)
|
- Inline code (single backtick)
|
||||||
- Tables
|
|
||||||
- Links — insert, edit, and remove with URL input
|
- Links — insert, edit, and remove with URL input
|
||||||
|
- Tables (insert, add/delete rows and columns)
|
||||||
- Dividers (horizontal rules)
|
- Dividers (horizontal rules)
|
||||||
- Text alignment (left, center, right, justify)
|
- Text alignment (left, center, right, justify)
|
||||||
- Line breaks
|
- Line breaks
|
||||||
|
|||||||
+11
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "crumbs",
|
"name": "crumbs",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.13.0",
|
"version": "0.17.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "Bretzel (https://bretzel.app)",
|
"author": "Bretzel (https://bretzel.app)",
|
||||||
@@ -19,7 +19,10 @@
|
|||||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||||
"test:unit": "vitest run",
|
"test:unit": "vitest run",
|
||||||
"test:unit:watch": "vitest",
|
"test:unit:watch": "vitest",
|
||||||
|
"test:unit:coverage": "vitest run --coverage",
|
||||||
"test:e2e": "playwright test",
|
"test:e2e": "playwright test",
|
||||||
|
"test:e2e:coverage": "VITE_COVERAGE=true pnpm build && pnpm test:e2e && nyc report",
|
||||||
|
"coverage:merge-e2e": "nyc merge coverage/e2e/raw coverage/e2e/merged.json && nyc report",
|
||||||
"test": "pnpm test:unit && pnpm test:e2e",
|
"test": "pnpm test:unit && pnpm test:e2e",
|
||||||
"db:push": "drizzle-kit push",
|
"db:push": "drizzle-kit push",
|
||||||
"db:generate": "drizzle-kit generate",
|
"db:generate": "drizzle-kit generate",
|
||||||
@@ -34,6 +37,10 @@
|
|||||||
"@tiptap/core": "^3.20.1",
|
"@tiptap/core": "^3.20.1",
|
||||||
"@tiptap/extension-link": "^3.20.1",
|
"@tiptap/extension-link": "^3.20.1",
|
||||||
"@tiptap/extension-placeholder": "^3.20.1",
|
"@tiptap/extension-placeholder": "^3.20.1",
|
||||||
|
"@tiptap/extension-table": "^3.20.1",
|
||||||
|
"@tiptap/extension-table-cell": "^3.20.1",
|
||||||
|
"@tiptap/extension-table-header": "^3.20.1",
|
||||||
|
"@tiptap/extension-table-row": "^3.20.1",
|
||||||
"@tiptap/extension-task-item": "^3.20.1",
|
"@tiptap/extension-task-item": "^3.20.1",
|
||||||
"@tiptap/extension-task-list": "^3.20.1",
|
"@tiptap/extension-task-list": "^3.20.1",
|
||||||
"@tiptap/extension-text-align": "^3.20.1",
|
"@tiptap/extension-text-align": "^3.20.1",
|
||||||
@@ -64,13 +71,16 @@
|
|||||||
"@types/uuid": "^10.0.0",
|
"@types/uuid": "^10.0.0",
|
||||||
"@types/zxcvbn": "^4.4.5",
|
"@types/zxcvbn": "^4.4.5",
|
||||||
"@vite-pwa/sveltekit": "^1.1.0",
|
"@vite-pwa/sveltekit": "^1.1.0",
|
||||||
|
"@vitest/coverage-v8": "^3.2.4",
|
||||||
"drizzle-kit": "^0.31.9",
|
"drizzle-kit": "^0.31.9",
|
||||||
|
"nyc": "^18.0.0",
|
||||||
"svelte": "^5.53.7",
|
"svelte": "^5.53.7",
|
||||||
"svelte-check": "^4.4.4",
|
"svelte-check": "^4.4.4",
|
||||||
"tailwindcss": "^4.2.1",
|
"tailwindcss": "^4.2.1",
|
||||||
"tsx": "^4.21.0",
|
"tsx": "^4.21.0",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"vite": "^7.3.1",
|
"vite": "^7.3.1",
|
||||||
|
"vite-plugin-istanbul": "^7.2.1",
|
||||||
"vitest": "^3.2.4",
|
"vitest": "^3.2.4",
|
||||||
"yaml": "^2.8.2"
|
"yaml": "^2.8.2"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ export default defineConfig({
|
|||||||
testDir: './tests/e2e',
|
testDir: './tests/e2e',
|
||||||
fullyParallel: true,
|
fullyParallel: true,
|
||||||
forbidOnly: !!process.env.CI,
|
forbidOnly: !!process.env.CI,
|
||||||
retries: process.env.CI ? 2 : 0,
|
retries: 0,
|
||||||
|
workers: process.env.CI ? 4 : undefined,
|
||||||
reporter: 'html',
|
reporter: 'html',
|
||||||
globalSetup: './tests/e2e/global-setup.ts',
|
globalSetup: './tests/e2e/global-setup.ts',
|
||||||
use: {
|
use: {
|
||||||
@@ -27,7 +28,7 @@ export default defineConfig({
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
webServer: {
|
webServer: {
|
||||||
command: 'pnpm build && pnpm preview --port 4173',
|
command: 'pnpm preview --port 4173',
|
||||||
port: 4173,
|
port: 4173,
|
||||||
reuseExistingServer: !process.env.CI,
|
reuseExistingServer: !process.env.CI,
|
||||||
timeout: 120_000,
|
timeout: 120_000,
|
||||||
|
|||||||
Generated
+975
File diff suppressed because it is too large
Load Diff
Executable
+37
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Writes a coverage summary table to $GITHUB_STEP_SUMMARY (or stdout if not in CI).
|
||||||
|
# Usage: scripts/coverage-summary.sh <title> <json-summary-path>
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
TITLE="${1:?Usage: coverage-summary.sh <title> <json-summary-path>}"
|
||||||
|
JSON="${2:?Usage: coverage-summary.sh <title> <json-summary-path>}"
|
||||||
|
|
||||||
|
if [ ! -f "$JSON" ]; then
|
||||||
|
echo "Coverage summary not found: $JSON" >&2
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Resolve to absolute path for require()
|
||||||
|
ABS_JSON="$(cd "$(dirname "$JSON")" && pwd)/$(basename "$JSON")"
|
||||||
|
|
||||||
|
# Extract totals with node (available in CI, no jq dependency)
|
||||||
|
read -r stmts branches funcs lines < <(node -e "
|
||||||
|
const s = require('$ABS_JSON').total;
|
||||||
|
console.log(s.statements.pct, s.branches.pct, s.functions.pct, s.lines.pct);
|
||||||
|
")
|
||||||
|
|
||||||
|
TABLE="## $TITLE
|
||||||
|
|
||||||
|
| Metric | Coverage |
|
||||||
|
|--------|----------|
|
||||||
|
| Statements | ${stmts}% |
|
||||||
|
| Branches | ${branches}% |
|
||||||
|
| Functions | ${funcs}% |
|
||||||
|
| Lines | ${lines}% |
|
||||||
|
"
|
||||||
|
|
||||||
|
if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then
|
||||||
|
echo "$TABLE" >> "$GITHUB_STEP_SUMMARY"
|
||||||
|
else
|
||||||
|
echo "$TABLE"
|
||||||
|
fi
|
||||||
+104
@@ -72,3 +72,107 @@ body::before {
|
|||||||
.prose :where(a):not(:where([class~="not-prose"] *)):hover {
|
.prose :where(a):not(:where([class~="not-prose"] *)):hover {
|
||||||
color: var(--primary-hover);
|
color: var(--primary-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Table styles for TipTap editor */
|
||||||
|
.tiptap table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
width: 100%;
|
||||||
|
margin: 0.5rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tiptap th,
|
||||||
|
.tiptap td {
|
||||||
|
border: 1px solid var(--border-subtle);
|
||||||
|
padding: 0.375rem 0.625rem;
|
||||||
|
text-align: left;
|
||||||
|
vertical-align: top;
|
||||||
|
min-width: 4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tiptap th {
|
||||||
|
font-weight: 600;
|
||||||
|
background-color: color-mix(in srgb, var(--bg-base) 60%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tiptap td p,
|
||||||
|
.tiptap th p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tiptap .selectedCell {
|
||||||
|
background-color: color-mix(in srgb, var(--primary) 12%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Task list styles — shared between TipTap editor and markdown-it preview */
|
||||||
|
|
||||||
|
/* TipTap: ul[data-type="taskList"] | markdown-it: ul.task-list */
|
||||||
|
.tiptap ul[data-type="taskList"],
|
||||||
|
.prose ul.task-list {
|
||||||
|
list-style: none;
|
||||||
|
padding-left: 0;
|
||||||
|
margin: 0.25rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tiptap ul[data-type="taskList"] li,
|
||||||
|
.prose ul.task-list li {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.375rem;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tiptap ul[data-type="taskList"] li::marker,
|
||||||
|
.prose ul.task-list li::marker {
|
||||||
|
content: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TipTap: checkbox is inside a label */
|
||||||
|
.tiptap ul[data-type="taskList"] li label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Shared checkbox styles */
|
||||||
|
.tiptap ul[data-type="taskList"] li label input[type="checkbox"],
|
||||||
|
.prose ul.task-list .task-checkbox {
|
||||||
|
cursor: pointer;
|
||||||
|
margin: 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TipTap: text content is in a div>p */
|
||||||
|
.tiptap ul[data-type="taskList"] li > div {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tiptap ul[data-type="taskList"] li > div p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Checked item styling */
|
||||||
|
.tiptap ul[data-type="taskList"] li[data-checked="true"] > div {
|
||||||
|
text-decoration: line-through;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Override prose spacing for task lists */
|
||||||
|
.prose ul[data-type="taskList"],
|
||||||
|
.prose ul.task-list {
|
||||||
|
padding-left: 0;
|
||||||
|
margin-top: 0.25rem;
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose ul[data-type="taskList"] li,
|
||||||
|
.prose ul.task-list li {
|
||||||
|
padding-left: 0;
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose ul.task-list li p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|||||||
+4
-9
@@ -22,18 +22,12 @@ export const handle: Handle = async ({ event, resolve }) => {
|
|||||||
return resolve(event);
|
return resolve(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MCP endpoint: authenticate via Bearer token (API key)
|
// API routes: authenticate via Bearer token if present
|
||||||
if (pathname.startsWith('/api/mcp')) {
|
if (pathname.startsWith('/api/')) {
|
||||||
const authHeader = event.request.headers.get('authorization');
|
const authHeader = event.request.headers.get('authorization');
|
||||||
const token = authHeader?.startsWith('Bearer ') ? authHeader.slice(7) : null;
|
const token = authHeader?.startsWith('Bearer ') ? authHeader.slice(7) : null;
|
||||||
|
|
||||||
if (!token) {
|
if (token) {
|
||||||
return new Response(JSON.stringify({ error: 'Unauthorized' }), {
|
|
||||||
status: 401,
|
|
||||||
headers: { 'Content-Type': 'application/json' }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const { valid, userId } = validateApiKey(token);
|
const { valid, userId } = validateApiKey(token);
|
||||||
if (!valid || !userId) {
|
if (!valid || !userId) {
|
||||||
return new Response(JSON.stringify({ error: 'Unauthorized' }), {
|
return new Response(JSON.stringify({ error: 'Unauthorized' }), {
|
||||||
@@ -53,6 +47,7 @@ export const handle: Handle = async ({ event, resolve }) => {
|
|||||||
event.locals.user = user;
|
event.locals.user = user;
|
||||||
return resolve(event);
|
return resolve(event);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if setup is complete
|
// Check if setup is complete
|
||||||
const setupDone = await isSetupComplete();
|
const setupDone = await isSetupComplete();
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
{#if showPopover}
|
{#if showPopover}
|
||||||
<div
|
<div
|
||||||
class="absolute left-0 bottom-full z-20 mb-1 min-w-[160px] rounded-sm border border-[var(--border-subtle)] bg-[var(--bg-surface)] p-2 shadow-[var(--card-shadow)] animate-[fade-in_150ms_ease-out]"
|
class="absolute right-0 bottom-full z-20 mb-1 min-w-[160px] rounded-sm border border-[var(--border-subtle)] bg-[var(--bg-surface)] p-2 shadow-[var(--card-shadow)] animate-[fade-in_150ms_ease-out]"
|
||||||
data-testid="collaborator-popover"
|
data-testid="collaborator-popover"
|
||||||
>
|
>
|
||||||
<p class="mb-1 text-xs font-semibold text-[var(--text-muted)]">Shared with</p>
|
<p class="mb-1 text-xs font-semibold text-[var(--text-muted)]">Shared with</p>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
Heading,
|
Heading,
|
||||||
List,
|
List,
|
||||||
ListOrdered,
|
ListOrdered,
|
||||||
|
ListChecks,
|
||||||
TextQuote,
|
TextQuote,
|
||||||
CodeXml,
|
CodeXml,
|
||||||
Bold,
|
Bold,
|
||||||
@@ -23,7 +24,10 @@
|
|||||||
AlignJustify,
|
AlignJustify,
|
||||||
Minus,
|
Minus,
|
||||||
ChevronDown,
|
ChevronDown,
|
||||||
Ellipsis
|
Table2,
|
||||||
|
BetweenHorizontalEnd,
|
||||||
|
BetweenVerticalEnd,
|
||||||
|
RemoveFormatting
|
||||||
} from 'lucide-svelte';
|
} from 'lucide-svelte';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -35,6 +39,9 @@
|
|||||||
|
|
||||||
function canUndo() { void tick; return editor?.can().chain().focus().undo().run() ?? false; }
|
function canUndo() { void tick; return editor?.can().chain().focus().undo().run() ?? false; }
|
||||||
function canRedo() { void tick; return editor?.can().chain().focus().redo().run() ?? false; }
|
function canRedo() { void tick; return editor?.can().chain().focus().redo().run() ?? false; }
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
function isActive(nameOrAttrs: any, attrs?: Record<string, any>): boolean { void tick; return editor?.isActive(nameOrAttrs, attrs) ?? false; }
|
||||||
|
function getAttrs(type: string) { void tick; return editor?.getAttributes(type) ?? {}; }
|
||||||
|
|
||||||
let openDropdown: string | null = $state(null);
|
let openDropdown: string | null = $state(null);
|
||||||
let linkUrl: string = $state('');
|
let linkUrl: string = $state('');
|
||||||
@@ -110,13 +117,35 @@
|
|||||||
<svelte:document onpointerdown={handlePointerDown} onkeydown={handleKeydown} />
|
<svelte:document onpointerdown={handlePointerDown} onkeydown={handleKeydown} />
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="flex items-center gap-0.5 border-b border-[var(--border-subtle)] px-2 py-1"
|
class="flex flex-wrap items-center gap-0.5 border-b border-[var(--border-subtle)] px-2 py-1"
|
||||||
data-testid="formatting-toolbar"
|
data-testid="formatting-toolbar"
|
||||||
>
|
>
|
||||||
|
<!-- Undo/Redo -->
|
||||||
|
<button
|
||||||
|
onclick={() => editor?.chain().focus().undo().run()}
|
||||||
|
disabled={!canUndo()}
|
||||||
|
class={btnClass(false, !canUndo())}
|
||||||
|
title="Undo"
|
||||||
|
data-testid="format-undo"
|
||||||
|
>
|
||||||
|
<Undo2 size={iconSize} />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onclick={() => editor?.chain().focus().redo().run()}
|
||||||
|
disabled={!canRedo()}
|
||||||
|
class={btnClass(false, !canRedo())}
|
||||||
|
title="Redo"
|
||||||
|
data-testid="format-redo"
|
||||||
|
>
|
||||||
|
<Redo2 size={iconSize} />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="mx-1 h-4 w-px shrink-0 bg-[var(--border-subtle)]"></div>
|
||||||
|
|
||||||
<!-- Inline -->
|
<!-- Inline -->
|
||||||
<button
|
<button
|
||||||
onclick={() => editor?.chain().focus().toggleBold().run()}
|
onclick={() => editor?.chain().focus().toggleBold().run()}
|
||||||
class={btnClass(editor?.isActive('bold') ?? false)}
|
class={btnClass(isActive('bold'))}
|
||||||
title="Bold (Ctrl+B)"
|
title="Bold (Ctrl+B)"
|
||||||
data-testid="format-bold"
|
data-testid="format-bold"
|
||||||
>
|
>
|
||||||
@@ -124,7 +153,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onclick={() => editor?.chain().focus().toggleItalic().run()}
|
onclick={() => editor?.chain().focus().toggleItalic().run()}
|
||||||
class={btnClass(editor?.isActive('italic') ?? false)}
|
class={btnClass(isActive('italic'))}
|
||||||
title="Italic (Ctrl+I)"
|
title="Italic (Ctrl+I)"
|
||||||
data-testid="format-italic"
|
data-testid="format-italic"
|
||||||
>
|
>
|
||||||
@@ -132,7 +161,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onclick={() => editor?.chain().focus().toggleStrike().run()}
|
onclick={() => editor?.chain().focus().toggleStrike().run()}
|
||||||
class={btnClass(editor?.isActive('strike') ?? false)}
|
class={btnClass(isActive('strike'))}
|
||||||
title="Strikethrough (Ctrl+Shift+X)"
|
title="Strikethrough (Ctrl+Shift+X)"
|
||||||
data-testid="format-strikethrough"
|
data-testid="format-strikethrough"
|
||||||
>
|
>
|
||||||
@@ -140,7 +169,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onclick={() => editor?.chain().focus().toggleUnderline().run()}
|
onclick={() => editor?.chain().focus().toggleUnderline().run()}
|
||||||
class={btnClass(editor?.isActive('underline') ?? false)}
|
class={btnClass(isActive('underline'))}
|
||||||
title="Underline (Ctrl+U)"
|
title="Underline (Ctrl+U)"
|
||||||
data-testid="format-underline"
|
data-testid="format-underline"
|
||||||
>
|
>
|
||||||
@@ -153,7 +182,7 @@
|
|||||||
<div class="relative" data-dropdown="heading">
|
<div class="relative" data-dropdown="heading">
|
||||||
<button
|
<button
|
||||||
onclick={() => toggleDropdown('heading')}
|
onclick={() => toggleDropdown('heading')}
|
||||||
class={dropdownBtnClass(editor?.isActive('heading') ?? false)}
|
class={dropdownBtnClass(isActive('heading'))}
|
||||||
title="Heading"
|
title="Heading"
|
||||||
data-testid="format-heading"
|
data-testid="format-heading"
|
||||||
>
|
>
|
||||||
@@ -164,7 +193,7 @@
|
|||||||
<div class="absolute left-0 bottom-full z-50 mb-1 min-w-[150px] rounded-sm border border-[var(--border)] bg-[var(--bg-surface)] py-1">
|
<div class="absolute left-0 bottom-full z-50 mb-1 min-w-[150px] rounded-sm border border-[var(--border)] bg-[var(--bg-surface)] py-1">
|
||||||
<button
|
<button
|
||||||
onclick={() => { editor?.chain().focus().toggleHeading({ level: 1 }).run(); closeDropdowns(); }}
|
onclick={() => { editor?.chain().focus().toggleHeading({ level: 1 }).run(); closeDropdowns(); }}
|
||||||
class={dropdownItemClass(editor?.isActive('heading', { level: 1 }) ?? false)}
|
class={dropdownItemClass(isActive('heading', { level: 1 }))}
|
||||||
data-testid="format-h1"
|
data-testid="format-h1"
|
||||||
>
|
>
|
||||||
<span class="w-6 text-xs font-semibold text-[var(--text-muted)]">H1</span>
|
<span class="w-6 text-xs font-semibold text-[var(--text-muted)]">H1</span>
|
||||||
@@ -172,7 +201,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onclick={() => { editor?.chain().focus().toggleHeading({ level: 2 }).run(); closeDropdowns(); }}
|
onclick={() => { editor?.chain().focus().toggleHeading({ level: 2 }).run(); closeDropdowns(); }}
|
||||||
class={dropdownItemClass(editor?.isActive('heading', { level: 2 }) ?? false)}
|
class={dropdownItemClass(isActive('heading', { level: 2 }))}
|
||||||
data-testid="format-h2"
|
data-testid="format-h2"
|
||||||
>
|
>
|
||||||
<span class="w-6 text-xs font-semibold text-[var(--text-muted)]">H2</span>
|
<span class="w-6 text-xs font-semibold text-[var(--text-muted)]">H2</span>
|
||||||
@@ -180,7 +209,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onclick={() => { editor?.chain().focus().toggleHeading({ level: 3 }).run(); closeDropdowns(); }}
|
onclick={() => { editor?.chain().focus().toggleHeading({ level: 3 }).run(); closeDropdowns(); }}
|
||||||
class={dropdownItemClass(editor?.isActive('heading', { level: 3 }) ?? false)}
|
class={dropdownItemClass(isActive('heading', { level: 3 }))}
|
||||||
data-testid="format-h3"
|
data-testid="format-h3"
|
||||||
>
|
>
|
||||||
<span class="w-6 text-xs font-semibold text-[var(--text-muted)]">H3</span>
|
<span class="w-6 text-xs font-semibold text-[var(--text-muted)]">H3</span>
|
||||||
@@ -194,7 +223,7 @@
|
|||||||
<div class="relative" data-dropdown="list">
|
<div class="relative" data-dropdown="list">
|
||||||
<button
|
<button
|
||||||
onclick={() => toggleDropdown('list')}
|
onclick={() => toggleDropdown('list')}
|
||||||
class={dropdownBtnClass((editor?.isActive('bulletList') || editor?.isActive('orderedList')) ?? false)}
|
class={dropdownBtnClass(isActive('bulletList') || isActive('orderedList') || isActive('taskList'))}
|
||||||
title="Lists"
|
title="Lists"
|
||||||
data-testid="format-list"
|
data-testid="format-list"
|
||||||
>
|
>
|
||||||
@@ -205,7 +234,7 @@
|
|||||||
<div class="absolute left-0 bottom-full z-50 mb-1 min-w-[170px] rounded-sm border border-[var(--border)] bg-[var(--bg-surface)] py-1">
|
<div class="absolute left-0 bottom-full z-50 mb-1 min-w-[170px] rounded-sm border border-[var(--border)] bg-[var(--bg-surface)] py-1">
|
||||||
<button
|
<button
|
||||||
onclick={() => { editor?.chain().focus().toggleBulletList().run(); closeDropdowns(); }}
|
onclick={() => { editor?.chain().focus().toggleBulletList().run(); closeDropdowns(); }}
|
||||||
class={dropdownItemClass(editor?.isActive('bulletList') ?? false)}
|
class={dropdownItemClass(isActive('bulletList'))}
|
||||||
data-testid="format-bullet-list"
|
data-testid="format-bullet-list"
|
||||||
>
|
>
|
||||||
<List size={iconSize} />
|
<List size={iconSize} />
|
||||||
@@ -213,12 +242,20 @@
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onclick={() => { editor?.chain().focus().toggleOrderedList().run(); closeDropdowns(); }}
|
onclick={() => { editor?.chain().focus().toggleOrderedList().run(); closeDropdowns(); }}
|
||||||
class={dropdownItemClass(editor?.isActive('orderedList') ?? false)}
|
class={dropdownItemClass(isActive('orderedList'))}
|
||||||
data-testid="format-ordered-list"
|
data-testid="format-ordered-list"
|
||||||
>
|
>
|
||||||
<ListOrdered size={iconSize} />
|
<ListOrdered size={iconSize} />
|
||||||
<span>Ordered list</span>
|
<span>Ordered list</span>
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
onclick={() => { editor?.chain().focus().toggleTaskList().run(); closeDropdowns(); }}
|
||||||
|
class={dropdownItemClass(isActive('taskList'))}
|
||||||
|
data-testid="format-task-list"
|
||||||
|
>
|
||||||
|
<ListChecks size={iconSize} />
|
||||||
|
<span>Task list</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@@ -227,7 +264,7 @@
|
|||||||
<div class="relative" data-dropdown="link">
|
<div class="relative" data-dropdown="link">
|
||||||
<button
|
<button
|
||||||
onclick={() => toggleDropdown('link')}
|
onclick={() => toggleDropdown('link')}
|
||||||
class={btnClass(editor?.isActive('link') ?? false)}
|
class={btnClass(isActive('link'))}
|
||||||
title="Insert link (Ctrl+K)"
|
title="Insert link (Ctrl+K)"
|
||||||
data-testid="format-link"
|
data-testid="format-link"
|
||||||
>
|
>
|
||||||
@@ -259,7 +296,7 @@
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onclick={openLink}
|
onclick={openLink}
|
||||||
disabled={!editor?.getAttributes('link').href}
|
disabled={!getAttrs('link').href}
|
||||||
class="rounded p-1 text-[var(--text-muted)] hover:bg-[var(--border)]/5 hover:text-[var(--text)] disabled:opacity-30"
|
class="rounded p-1 text-[var(--text-muted)] hover:bg-[var(--border)]/5 hover:text-[var(--text)] disabled:opacity-30"
|
||||||
title="Open link"
|
title="Open link"
|
||||||
data-testid="format-link-open"
|
data-testid="format-link-open"
|
||||||
@@ -269,7 +306,7 @@
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onclick={removeLink}
|
onclick={removeLink}
|
||||||
disabled={!editor?.isActive('link')}
|
disabled={!isActive('link')}
|
||||||
class="rounded p-1 text-[var(--text-muted)] hover:bg-[var(--border)]/5 hover:text-red-500 disabled:opacity-30"
|
class="rounded p-1 text-[var(--text-muted)] hover:bg-[var(--border)]/5 hover:text-red-500 disabled:opacity-30"
|
||||||
title="Remove link"
|
title="Remove link"
|
||||||
data-testid="format-unlink"
|
data-testid="format-unlink"
|
||||||
@@ -281,99 +318,123 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mx-1 h-4 w-px shrink-0 bg-[var(--border-subtle)]"></div>
|
<!-- Table dropdown -->
|
||||||
|
<div class="relative" data-dropdown="table">
|
||||||
<!-- More dropdown -->
|
|
||||||
<div class="relative" data-dropdown="more">
|
|
||||||
<button
|
<button
|
||||||
onclick={() => toggleDropdown('more')}
|
onclick={() => toggleDropdown('table')}
|
||||||
class={dropdownBtnClass(false)}
|
class={dropdownBtnClass(isActive('table'))}
|
||||||
title="More options"
|
title="Table"
|
||||||
data-testid="format-more"
|
data-testid="format-table"
|
||||||
>
|
>
|
||||||
<Ellipsis size={iconSize} />
|
<Table2 size={iconSize} />
|
||||||
|
<ChevronDown size={chevronSize} />
|
||||||
</button>
|
</button>
|
||||||
{#if openDropdown === 'more'}
|
{#if openDropdown === 'table'}
|
||||||
<div class="absolute right-0 bottom-full z-50 mb-1 min-w-[170px] rounded-sm border border-[var(--border)] bg-[var(--bg-surface)] py-1">
|
<div class="absolute left-0 bottom-full z-50 mb-1 min-w-[190px] rounded-sm border border-[var(--border)] bg-[var(--bg-surface)] py-1">
|
||||||
<button
|
<button
|
||||||
onclick={() => { editor?.chain().focus().undo().run(); closeDropdowns(); }}
|
onclick={() => { editor?.chain().focus().insertTable({ rows: 3, cols: 3 }).run(); closeDropdowns(); }}
|
||||||
disabled={!canUndo()}
|
|
||||||
class={dropdownItemClass()}
|
class={dropdownItemClass()}
|
||||||
data-testid="format-undo"
|
data-testid="format-table-insert"
|
||||||
>
|
>
|
||||||
<Undo2 size={iconSize} />
|
<Table2 size={iconSize} />
|
||||||
<span>Undo</span>
|
<span>Insert table</span>
|
||||||
|
</button>
|
||||||
|
{#if isActive('table')}
|
||||||
|
<div class="my-1 h-px bg-[var(--border-subtle)]"></div>
|
||||||
|
<button
|
||||||
|
onclick={() => { editor?.chain().focus().addRowAfter().run(); closeDropdowns(); }}
|
||||||
|
class={dropdownItemClass()}
|
||||||
|
data-testid="format-table-add-row"
|
||||||
|
>
|
||||||
|
<BetweenHorizontalEnd size={iconSize} />
|
||||||
|
<span>Add row</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onclick={() => { editor?.chain().focus().redo().run(); closeDropdowns(); }}
|
onclick={() => { editor?.chain().focus().addColumnAfter().run(); closeDropdowns(); }}
|
||||||
disabled={!canRedo()}
|
|
||||||
class={dropdownItemClass()}
|
class={dropdownItemClass()}
|
||||||
data-testid="format-redo"
|
data-testid="format-table-add-col"
|
||||||
>
|
>
|
||||||
<Redo2 size={iconSize} />
|
<BetweenVerticalEnd size={iconSize} />
|
||||||
<span>Redo</span>
|
<span>Add column</span>
|
||||||
</button>
|
</button>
|
||||||
<div class="my-1 h-px bg-[var(--border-subtle)]"></div>
|
<div class="my-1 h-px bg-[var(--border-subtle)]"></div>
|
||||||
<button
|
<button
|
||||||
onclick={() => { editor?.chain().focus().toggleCode().run(); closeDropdowns(); }}
|
onclick={() => { editor?.chain().focus().deleteRow().run(); closeDropdowns(); }}
|
||||||
class={dropdownItemClass(editor?.isActive('code') ?? false)}
|
|
||||||
data-testid="format-code"
|
|
||||||
>
|
|
||||||
<Code size={iconSize} />
|
|
||||||
<span>Inline code</span>
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onclick={() => { editor?.chain().focus().toggleBlockquote().run(); closeDropdowns(); }}
|
|
||||||
class={dropdownItemClass(editor?.isActive('blockquote') ?? false)}
|
|
||||||
data-testid="format-blockquote"
|
|
||||||
>
|
|
||||||
<TextQuote size={iconSize} />
|
|
||||||
<span>Blockquote</span>
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onclick={() => { editor?.chain().focus().toggleCodeBlock().run(); closeDropdowns(); }}
|
|
||||||
class={dropdownItemClass(editor?.isActive('codeBlock') ?? false)}
|
|
||||||
data-testid="format-code-block"
|
|
||||||
>
|
|
||||||
<CodeXml size={iconSize} />
|
|
||||||
<span>Code block</span>
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onclick={() => { editor?.chain().focus().setHorizontalRule().run(); closeDropdowns(); }}
|
|
||||||
class={dropdownItemClass()}
|
class={dropdownItemClass()}
|
||||||
data-testid="format-hr"
|
data-testid="format-table-delete-row"
|
||||||
>
|
>
|
||||||
<Minus size={iconSize} />
|
<Minus size={iconSize} />
|
||||||
<span>Divider</span>
|
<span>Delete row</span>
|
||||||
</button>
|
</button>
|
||||||
<div class="my-1 h-px bg-[var(--border-subtle)]"></div>
|
<button
|
||||||
|
onclick={() => { editor?.chain().focus().deleteColumn().run(); closeDropdowns(); }}
|
||||||
|
class={dropdownItemClass()}
|
||||||
|
data-testid="format-table-delete-col"
|
||||||
|
>
|
||||||
|
<Minus size={iconSize} />
|
||||||
|
<span>Delete column</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onclick={() => { editor?.chain().focus().deleteTable().run(); closeDropdowns(); }}
|
||||||
|
class={`${dropdownItemClass()} text-[var(--destructive)]`}
|
||||||
|
data-testid="format-table-delete"
|
||||||
|
>
|
||||||
|
<RemoveFormatting size={iconSize} />
|
||||||
|
<span>Delete table</span>
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Alignment dropdown -->
|
||||||
|
<div class="relative" data-dropdown="align">
|
||||||
|
<button
|
||||||
|
onclick={() => toggleDropdown('align')}
|
||||||
|
class={dropdownBtnClass(isActive({ textAlign: 'center' }) || isActive({ textAlign: 'right' }) || isActive({ textAlign: 'justify' }))}
|
||||||
|
title="Text alignment"
|
||||||
|
data-testid="format-align"
|
||||||
|
>
|
||||||
|
{#if isActive({ textAlign: 'center' })}
|
||||||
|
<AlignCenter size={iconSize} />
|
||||||
|
{:else if isActive({ textAlign: 'right' })}
|
||||||
|
<AlignRight size={iconSize} />
|
||||||
|
{:else if isActive({ textAlign: 'justify' })}
|
||||||
|
<AlignJustify size={iconSize} />
|
||||||
|
{:else}
|
||||||
|
<AlignLeft size={iconSize} />
|
||||||
|
{/if}
|
||||||
|
<ChevronDown size={chevronSize} />
|
||||||
|
</button>
|
||||||
|
{#if openDropdown === 'align'}
|
||||||
|
<div class="absolute right-0 bottom-full z-50 mb-1 min-w-[160px] rounded-sm border border-[var(--border)] bg-[var(--bg-surface)] py-1">
|
||||||
<button
|
<button
|
||||||
onclick={() => { editor?.chain().focus().setTextAlign('left').run(); closeDropdowns(); }}
|
onclick={() => { editor?.chain().focus().setTextAlign('left').run(); closeDropdowns(); }}
|
||||||
class={dropdownItemClass(editor?.isActive({ textAlign: 'left' }) ?? false)}
|
class={dropdownItemClass(isActive({ textAlign: 'left' }))}
|
||||||
data-testid="format-align-left"
|
data-testid="format-align-left"
|
||||||
>
|
>
|
||||||
<AlignLeft size={iconSize} />
|
<AlignLeft size={iconSize} />
|
||||||
<span>Align left</span>
|
<span>Left</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onclick={() => { editor?.chain().focus().setTextAlign('center').run(); closeDropdowns(); }}
|
onclick={() => { editor?.chain().focus().setTextAlign('center').run(); closeDropdowns(); }}
|
||||||
class={dropdownItemClass(editor?.isActive({ textAlign: 'center' }) ?? false)}
|
class={dropdownItemClass(isActive({ textAlign: 'center' }))}
|
||||||
data-testid="format-align-center"
|
data-testid="format-align-center"
|
||||||
>
|
>
|
||||||
<AlignCenter size={iconSize} />
|
<AlignCenter size={iconSize} />
|
||||||
<span>Align center</span>
|
<span>Center</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onclick={() => { editor?.chain().focus().setTextAlign('right').run(); closeDropdowns(); }}
|
onclick={() => { editor?.chain().focus().setTextAlign('right').run(); closeDropdowns(); }}
|
||||||
class={dropdownItemClass(editor?.isActive({ textAlign: 'right' }) ?? false)}
|
class={dropdownItemClass(isActive({ textAlign: 'right' }))}
|
||||||
data-testid="format-align-right"
|
data-testid="format-align-right"
|
||||||
>
|
>
|
||||||
<AlignRight size={iconSize} />
|
<AlignRight size={iconSize} />
|
||||||
<span>Align right</span>
|
<span>Right</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onclick={() => { editor?.chain().focus().setTextAlign('justify').run(); closeDropdowns(); }}
|
onclick={() => { editor?.chain().focus().setTextAlign('justify').run(); closeDropdowns(); }}
|
||||||
class={dropdownItemClass(editor?.isActive({ textAlign: 'justify' }) ?? false)}
|
class={dropdownItemClass(isActive({ textAlign: 'justify' }))}
|
||||||
data-testid="format-align-justify"
|
data-testid="format-align-justify"
|
||||||
>
|
>
|
||||||
<AlignJustify size={iconSize} />
|
<AlignJustify size={iconSize} />
|
||||||
@@ -382,4 +443,40 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mx-1 h-4 w-px shrink-0 bg-[var(--border-subtle)]"></div>
|
||||||
|
|
||||||
|
<!-- Block-level formatting -->
|
||||||
|
<button
|
||||||
|
onclick={() => editor?.chain().focus().toggleCode().run()}
|
||||||
|
class={btnClass(isActive('code'))}
|
||||||
|
title="Inline code"
|
||||||
|
data-testid="format-code"
|
||||||
|
>
|
||||||
|
<Code size={iconSize} />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onclick={() => editor?.chain().focus().toggleBlockquote().run()}
|
||||||
|
class={btnClass(isActive('blockquote'))}
|
||||||
|
title="Blockquote"
|
||||||
|
data-testid="format-blockquote"
|
||||||
|
>
|
||||||
|
<TextQuote size={iconSize} />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onclick={() => editor?.chain().focus().toggleCodeBlock().run()}
|
||||||
|
class={btnClass(isActive('codeBlock'))}
|
||||||
|
title="Code block"
|
||||||
|
data-testid="format-code-block"
|
||||||
|
>
|
||||||
|
<CodeXml size={iconSize} />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onclick={() => editor?.chain().focus().setHorizontalRule().run()}
|
||||||
|
class={btnClass()}
|
||||||
|
title="Divider"
|
||||||
|
data-testid="format-hr"
|
||||||
|
>
|
||||||
|
<Minus size={iconSize} />
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -237,24 +237,3 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<style>
|
|
||||||
article :global(.prose li:has(.task-checkbox)) {
|
|
||||||
list-style: none;
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
gap: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
article :global(.prose li:has(.task-checkbox))::before {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
article :global(.prose li:has(.task-checkbox))::marker {
|
|
||||||
content: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
article :global(.task-checkbox) {
|
|
||||||
margin-top: 0.15rem;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -201,7 +201,7 @@
|
|||||||
>
|
>
|
||||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
<div
|
<div
|
||||||
class="mx-4 flex w-full max-w-xl flex-col rounded-sm border border-[var(--border)] shadow-[var(--card-shadow)] animate-[pop-in_150ms_ease-out]"
|
class="mx-4 flex w-full max-w-xl md:max-w-2xl flex-col overflow-hidden rounded-sm border border-[var(--border)] shadow-[var(--card-shadow)] animate-[pop-in_150ms_ease-out]"
|
||||||
style={bgStyle}
|
style={bgStyle}
|
||||||
onclick={(e) => e.stopPropagation()}
|
onclick={(e) => e.stopPropagation()}
|
||||||
onkeydown={(e) => { e.stopPropagation(); handleKeydown(e); }}
|
onkeydown={(e) => { e.stopPropagation(); handleKeydown(e); }}
|
||||||
|
|||||||
@@ -6,6 +6,12 @@
|
|||||||
import Underline from '@tiptap/extension-underline';
|
import Underline from '@tiptap/extension-underline';
|
||||||
import TextAlign from '@tiptap/extension-text-align';
|
import TextAlign from '@tiptap/extension-text-align';
|
||||||
import Placeholder from '@tiptap/extension-placeholder';
|
import Placeholder from '@tiptap/extension-placeholder';
|
||||||
|
import { Table } from '@tiptap/extension-table';
|
||||||
|
import { TableRow } from '@tiptap/extension-table-row';
|
||||||
|
import { TableHeader } from '@tiptap/extension-table-header';
|
||||||
|
import { TableCell } from '@tiptap/extension-table-cell';
|
||||||
|
import TaskList from '@tiptap/extension-task-list';
|
||||||
|
import TaskItem from '@tiptap/extension-task-item';
|
||||||
import { Markdown } from 'tiptap-markdown';
|
import { Markdown } from 'tiptap-markdown';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -30,6 +36,12 @@
|
|||||||
Underline,
|
Underline,
|
||||||
TextAlign.configure({ types: ['heading', 'paragraph'] }),
|
TextAlign.configure({ types: ['heading', 'paragraph'] }),
|
||||||
Placeholder.configure({ placeholder }),
|
Placeholder.configure({ placeholder }),
|
||||||
|
Table.configure({ resizable: false }),
|
||||||
|
TableRow,
|
||||||
|
TableHeader,
|
||||||
|
TableCell,
|
||||||
|
TaskList,
|
||||||
|
TaskItem.configure({ nested: true }),
|
||||||
Markdown
|
Markdown
|
||||||
],
|
],
|
||||||
content,
|
content,
|
||||||
|
|||||||
@@ -24,6 +24,17 @@ md.core.ruler.after('inline', 'task-lists', (state) => {
|
|||||||
const token = new state.Token('html_inline', '', 0);
|
const token = new state.Token('html_inline', '', 0);
|
||||||
token.content = checkbox;
|
token.content = checkbox;
|
||||||
tokens[i].children!.unshift(token);
|
tokens[i].children!.unshift(token);
|
||||||
|
|
||||||
|
// Add task-list class to parent <ul> (once)
|
||||||
|
for (let j = i - 1; j >= 0; j--) {
|
||||||
|
if (tokens[j].type === 'bullet_list_open') {
|
||||||
|
const cls = tokens[j].attrGet('class') ?? '';
|
||||||
|
if (!cls.includes('task-list')) {
|
||||||
|
tokens[j].attrJoin('class', 'task-list');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
class="flex items-center gap-2 rounded-sm px-3 py-2 text-sm whitespace-nowrap transition-colors {pathname === '/settings/mcp' ? 'bg-[var(--primary)]/15 text-[var(--primary)] font-medium' : 'text-[var(--text)] hover:bg-[var(--bg-base)]'}"
|
class="flex items-center gap-2 rounded-sm px-3 py-2 text-sm whitespace-nowrap transition-colors {pathname === '/settings/mcp' ? 'bg-[var(--primary)]/15 text-[var(--primary)] font-medium' : 'text-[var(--text)] hover:bg-[var(--bg-base)]'}"
|
||||||
>
|
>
|
||||||
<Cpu size={16} />
|
<Cpu size={16} />
|
||||||
MCP Server
|
API
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{#if data.user?.role === 'admin'}
|
{#if data.user?.role === 'admin'}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ ${mcpJsonConfig}`);
|
|||||||
<h2 class="text-lg font-semibold text-[var(--text)]">API Keys</h2>
|
<h2 class="text-lg font-semibold text-[var(--text)]">API Keys</h2>
|
||||||
</div>
|
</div>
|
||||||
<p class="mb-4 text-xs text-[var(--text-muted)]">
|
<p class="mb-4 text-xs text-[var(--text-muted)]">
|
||||||
API keys allow external tools (like Claude Code) to access your notes via the MCP protocol.
|
API keys allow external tools to access your notes via the MCP protocol and the REST API.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<!-- Create Key Form -->
|
<!-- Create Key Form -->
|
||||||
@@ -229,9 +229,19 @@ ${mcpJsonConfig}`);
|
|||||||
{/if}
|
{/if}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<!-- REST API Example -->
|
||||||
|
<section class="mb-6 rounded-sm border border-[var(--border-subtle)] bg-[var(--bg-surface)] p-6 shadow-[var(--card-shadow)]">
|
||||||
|
<h2 class="mb-4 text-lg font-semibold text-[var(--text)]">REST API</h2>
|
||||||
|
<p class="mb-3 text-xs text-[var(--text-muted)]">
|
||||||
|
Use your API key to authenticate requests to any <code class="rounded-sm bg-[var(--bg-base)] px-1 py-0.5">/api/*</code> endpoint:
|
||||||
|
</p>
|
||||||
|
<pre class="overflow-x-auto rounded-sm bg-[var(--bg-base)] p-3 text-xs text-[var(--text)]">curl -H "Authorization: Bearer {activeApiKey}" \
|
||||||
|
{baseUrl}/api/notes</pre>
|
||||||
|
</section>
|
||||||
|
|
||||||
<!-- MCP Config Help -->
|
<!-- MCP Config Help -->
|
||||||
<section class="rounded-sm border border-[var(--border-subtle)] bg-[var(--bg-surface)] p-6 shadow-[var(--card-shadow)]">
|
<section class="rounded-sm border border-[var(--border-subtle)] bg-[var(--bg-surface)] p-6 shadow-[var(--card-shadow)]">
|
||||||
<h2 class="mb-4 text-lg font-semibold text-[var(--text)]">Client Configuration</h2>
|
<h2 class="mb-4 text-lg font-semibold text-[var(--text)]">MCP Client Configuration</h2>
|
||||||
<p class="mb-3 text-xs text-[var(--text-muted)]">
|
<p class="mb-3 text-xs text-[var(--text-muted)]">
|
||||||
Add this to your <code class="rounded-sm bg-[var(--bg-base)] px-1 py-0.5">.claude/settings.json</code> (Claude Code):
|
Add this to your <code class="rounded-sm bg-[var(--bg-base)] px-1 py-0.5">.claude/settings.json</code> (Claude Code):
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { writeFileSync, mkdirSync } from 'fs';
|
||||||
|
import { join } from 'path';
|
||||||
|
import type { Page } from '@playwright/test';
|
||||||
|
|
||||||
|
const COVERAGE_DIR = join(process.cwd(), 'coverage', 'e2e', 'raw');
|
||||||
|
|
||||||
|
let counter = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collect Istanbul coverage data from the browser page.
|
||||||
|
* The vite-plugin-istanbul injects `window.__coverage__` when COVERAGE=true.
|
||||||
|
*/
|
||||||
|
export async function collectCoverage(page: Page, testTitle: string) {
|
||||||
|
if (process.env.VITE_COVERAGE !== 'true') return;
|
||||||
|
|
||||||
|
const coverage = await page.evaluate(() => (window as any).__coverage__);
|
||||||
|
if (!coverage) return;
|
||||||
|
|
||||||
|
mkdirSync(COVERAGE_DIR, { recursive: true });
|
||||||
|
|
||||||
|
const safeName = testTitle.replace(/[^a-zA-Z0-9-_]/g, '_');
|
||||||
|
const filename = `coverage-${safeName}-${counter++}-${Date.now()}.json`;
|
||||||
|
writeFileSync(join(COVERAGE_DIR, filename), JSON.stringify(coverage));
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { test as base, expect, type Page, type Locator } from '@playwright/test';
|
import { test as base, expect, type Page, type Locator } from '@playwright/test';
|
||||||
|
import { collectCoverage } from './coverage';
|
||||||
|
|
||||||
const TEST_EMAIL = 'admin@test.com';
|
const TEST_EMAIL = 'admin@test.com';
|
||||||
const TEST_PASSWORD = 'testpassword123';
|
const TEST_PASSWORD = 'testpassword123';
|
||||||
@@ -13,10 +14,12 @@ export function noteCard(page: Page, title: string): Locator {
|
|||||||
* Extended test fixture that handles setup/auth.
|
* Extended test fixture that handles setup/auth.
|
||||||
*/
|
*/
|
||||||
export const test = base.extend<{ authenticatedPage: Page }>({
|
export const test = base.extend<{ authenticatedPage: Page }>({
|
||||||
authenticatedPage: async ({ page }, use) => {
|
authenticatedPage: async ({ page }, use, testInfo) => {
|
||||||
// Setup: create user and login
|
// Setup: create user and login
|
||||||
await setupAndLogin(page);
|
await setupAndLogin(page);
|
||||||
await use(page);
|
await use(page);
|
||||||
|
// Teardown: collect coverage data from the browser
|
||||||
|
await collectCoverage(page, testInfo.title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -57,10 +57,10 @@ test.describe('Settings — API Key Management', () => {
|
|||||||
// Given the user is on the settings page
|
// Given the user is on the settings page
|
||||||
await page.goto('/settings');
|
await page.goto('/settings');
|
||||||
|
|
||||||
// When the user clicks the MCP Server nav link
|
// When the user clicks the API nav link
|
||||||
await page.getByRole('link', { name: 'MCP Server' }).click();
|
await page.getByRole('link', { name: 'API' }).click();
|
||||||
|
|
||||||
// Then the MCP settings page is shown
|
// Then the API settings page is shown
|
||||||
await expect(page).toHaveURL('/settings/mcp');
|
await expect(page).toHaveURL('/settings/mcp');
|
||||||
await expect(page.getByRole('heading', { name: 'API Keys' })).toBeVisible();
|
await expect(page.getByRole('heading', { name: 'API Keys' })).toBeVisible();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { sveltekit } from '@sveltejs/kit/vite';
|
import { sveltekit } from '@sveltejs/kit/vite';
|
||||||
import { SvelteKitPWA } from '@vite-pwa/sveltekit';
|
import { SvelteKitPWA } from '@vite-pwa/sveltekit';
|
||||||
import tailwindcss from '@tailwindcss/vite';
|
import tailwindcss from '@tailwindcss/vite';
|
||||||
|
import istanbul from 'vite-plugin-istanbul';
|
||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
@@ -10,6 +11,17 @@ export default defineConfig({
|
|||||||
plugins: [
|
plugins: [
|
||||||
tailwindcss(),
|
tailwindcss(),
|
||||||
sveltekit(),
|
sveltekit(),
|
||||||
|
...(process.env.VITE_COVERAGE === 'true'
|
||||||
|
? [
|
||||||
|
istanbul({
|
||||||
|
include: 'src/**/*',
|
||||||
|
exclude: ['node_modules', 'tests/', '**/*.test.ts'],
|
||||||
|
extension: ['.ts', '.svelte'],
|
||||||
|
requireEnv: true,
|
||||||
|
forceBuildInstrument: true
|
||||||
|
})
|
||||||
|
]
|
||||||
|
: []),
|
||||||
SvelteKitPWA({
|
SvelteKitPWA({
|
||||||
registerType: 'autoUpdate',
|
registerType: 'autoUpdate',
|
||||||
manifest: {
|
manifest: {
|
||||||
|
|||||||
+8
-1
@@ -9,6 +9,13 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
test: {
|
test: {
|
||||||
include: ['src/**/*.test.ts'],
|
include: ['src/**/*.test.ts'],
|
||||||
environment: 'node'
|
environment: 'node',
|
||||||
|
coverage: {
|
||||||
|
provider: 'v8',
|
||||||
|
reporter: ['text', 'html', 'lcov', 'json-summary'],
|
||||||
|
reportsDirectory: './coverage/unit',
|
||||||
|
include: ['src/lib/**/*.ts'],
|
||||||
|
exclude: ['src/lib/**/*.test.ts', 'src/lib/types/**']
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+3
-3
@@ -145,8 +145,8 @@
|
|||||||
<div class="feature-icon">
|
<div class="feature-icon">
|
||||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="4" width="16" height="16" rx="2"/><path d="M9 9h6v6H9z"/><path d="M15 2v2"/><path d="M15 20v2"/><path d="M2 15h2"/><path d="M2 9h2"/><path d="M20 15h2"/><path d="M20 9h2"/><path d="M9 2v2"/><path d="M9 20v2"/></svg>
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="4" width="16" height="16" rx="2"/><path d="M9 9h6v6H9z"/><path d="M15 2v2"/><path d="M15 20v2"/><path d="M2 15h2"/><path d="M2 9h2"/><path d="M20 15h2"/><path d="M20 9h2"/><path d="M9 2v2"/><path d="M9 20v2"/></svg>
|
||||||
</div>
|
</div>
|
||||||
<h3>MCP Server</h3>
|
<h3>API & MCP</h3>
|
||||||
<p>Built-in AI integration. Connect Claude, Cursor, or any MCP client to read and write your notes.</p>
|
<p>Full REST API with token auth. Integrate with n8n, Zapier, or scripts. Built-in MCP server for AI tools like Claude and Cursor.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Multi-User -->
|
<!-- Multi-User -->
|
||||||
@@ -253,7 +253,7 @@
|
|||||||
<li><a href="https://github.com/bretzel-app/crumbs/blob/main/docs/DEPLOYMENT.md" target="_blank" rel="noopener">Docs</a></li>
|
<li><a href="https://github.com/bretzel-app/crumbs/blob/main/docs/DEPLOYMENT.md" target="_blank" rel="noopener">Docs</a></li>
|
||||||
<li><a href="https://github.com/bretzel-app/crumbs/blob/main/LICENSE" target="_blank" rel="noopener">License</a></li>
|
<li><a href="https://github.com/bretzel-app/crumbs/blob/main/LICENSE" target="_blank" rel="noopener">License</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<span class="footer-version">v0.13.0</span>
|
<span class="footer-version">v0.17.0</span>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user