Markdown Editor with Chat
A lightweight, self-contained markdown editor that serves files from a local directory with optional OpenClaw gateway chat integration.
Features
- - Filesystem-based: Point to any directory containing markdown files
- No database: Files are the source of truth
- Folder navigation: Browse nested directories
- Live preview: See rendered markdown as you type
- Optional chat: Connect to OpenClaw gateway for AI assistance
- Zero external dependencies: Pure Node.js, self-contained HTML
Quick Start
CODEBLOCK0
Then open http://localhost:3333 in your browser.
CLI Arguments
| Argument | Short | Required | Default | Description |
|---|
| INLINECODE0 | INLINECODE1 | Yes* | - | Directory containing markdown files |
| INLINECODE2 |
-p | No | 3333 | Server port |
|
--host |
-h | No | 127.0.0.1 | Server host (localhost only by default) |
|
--help | | No | | Show help message |
*Required unless MARKDOWN_DIR env var is set.
Environment Variables (fallback)
| Variable | Required | Default | Description |
|---|
| INLINECODE8 | Yes* | - | Directory containing markdown files |
| INLINECODE9 |
No | 3333 | Server port |
|
HOST | No | 127.0.0.1 | Server host |
|
OPENCLAW_GATEWAY_URL | No | - | Gateway URL for chat feature |
|
OPENCLAW_GATEWAY_TOKEN | No | - | Gateway auth token |
CLI arguments take precedence over environment variables.
Security
- - Localhost only by default: Server binds to 127.0.0.1, rejects public IPs
- Same-origin only: No CORS headers, browser enforces same-origin policy
- Path traversal protection: Cannot access files outside MARKDOWN_DIR
- No credentials in code: All secrets via environment variables
- Gateway proxy: Tokens never exposed to browser
This is a local development tool. The API is intentionally simple (no auth) because it's designed for localhost use on directories you control.
API Endpoints
- -
GET / - Serves the editor UI - INLINECODE14 - List files and folders
- INLINECODE15 - Get file content
- INLINECODE16 - Save file content
- INLINECODE17 - Create new file
- INLINECODE18 - Proxy chat to gateway (if configured)
Use Cases
- - Browse and edit OpenClaw pearls
- Personal markdown wiki
- Note-taking with AI assistance
- Documentation browser
带聊天的Markdown编辑器
一款轻量级、自包含的Markdown编辑器,可从本地目录提供文件服务,并可选集成OpenClaw网关聊天功能。
功能特性
- - 基于文件系统:指向任意包含Markdown文件的目录
- 无需数据库:文件即数据源
- 文件夹导航:浏览嵌套目录结构
- 实时预览:输入时即可查看渲染后的Markdown效果
- 可选聊天:连接OpenClaw网关获取AI辅助
- 零外部依赖:纯Node.js实现,自包含HTML
快速开始
bash
使用命令行参数启动(推荐)
node scripts/server.mjs --folder /path/to/markdown --port 3333
或使用简写形式
node scripts/server.mjs -f /path/to/markdown -p 3333
启用网关聊天(通过环境变量)
export OPENCLAW
GATEWAYURL=http://127.0.0.1:18789
export OPENCLAW
GATEWAYTOKEN=your-token
node scripts/server.mjs -f /path/to/markdown
然后在浏览器中打开 http://localhost:3333。
命令行参数
| 参数 | 简写 | 必需 | 默认值 | 说明 |
|---|
| --folder | -f | 是* | - | 包含Markdown文件的目录 |
| --port |
-p | 否 | 3333 | 服务器端口 |
| --host | -h | 否 | 127.0.0.1 | 服务器主机(默认仅限本地访问) |
| --help | | 否 | | 显示帮助信息 |
*除非已设置MARKDOWN_DIR环境变量。
环境变量(备用方案)
| 变量 | 必需 | 默认值 | 说明 |
|---|
| MARKDOWN_DIR | 是* | - | 包含Markdown文件的目录 |
| PORT |
否 | 3333 | 服务器端口 |
| HOST | 否 | 127.0.0.1 | 服务器主机 |
| OPENCLAW
GATEWAYURL | 否 | - | 聊天功能的网关URL |
| OPENCLAW
GATEWAYTOKEN | 否 | - | 网关认证令牌 |
命令行参数优先级高于环境变量。
安全性
- - 默认仅限本地访问:服务器绑定到127.0.0.1,拒绝公网IP
- 仅限同源访问:无CORS头,浏览器强制执行同源策略
- 路径遍历防护:无法访问MARKDOWN_DIR之外的文件
- 代码中不包含凭据:所有密钥通过环境变量传入
- 网关代理:令牌不会暴露给浏览器
这是一个本地开发工具。API设计有意保持简单(无认证),因为它专为本地使用且操作您控制的目录而设计。
API端点
- - GET / - 提供编辑器界面
- GET /api/files - 列出文件和文件夹
- GET /api/files/:path - 获取文件内容
- PUT /api/files/:path - 保存文件内容
- POST /api/files/:path - 创建新文件
- POST /api/chat - 代理聊天请求到网关(如已配置)
使用场景
- - 浏览和编辑OpenClaw珍珠
- 个人Markdown维基
- 带AI辅助的笔记记录
- 文档浏览器