fix up IWA support, other QoL upgrades, start on MCP integration

This commit is contained in:
2026-10-21 21:14:59 -04:00
parent df0d3dd1f7
commit 5179b76558
81 changed files with 547 additions and 461 deletions

3
.env Normal file
View File

@@ -0,0 +1,3 @@
# Private key for IWA signing
# In production, use a secure way to provide this, like an environment variable or secret manager.
IWA_PRIVATE_KEY_PATH=./iwa_private.pem

14
.gitignore vendored
View File

@@ -1,11 +1,9 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
.env.local
iwa_private.pem
node_modules/
dist/
build/
public/
node_modules
dist

View File

@@ -1,250 +0,0 @@
# 🎉 AboveTheMark GFM Editor - Implementation Complete!
## ✅ Successfully Built and Ready to Use
The **AboveTheMark** GFM editor has been successfully scaffolded with all requested features.
---
## 📦 What's Included
### Core Features Implemented:
- ✅ **Dark Mode** - System preference detection + Solarized light/dark palettes (4 total themes)
- ✅ **LaTeX Rendering** - Full MathJax support for `$$...$$` and `$...$` expressions
- ✅ **SVG Rendering** - Supports GitHub raw URLs, Imgur, external URLs, data URIs
- ✅ **Save as .md** - Export current markdown to file with timestamp filename
- ✅ **Open .md files** - Import existing markdown files via file picker
- ✅ **Export PDF** - Convert markdown to HTML for PDF viewing/printing
- ✅ **Export DOCX** - Export to Word-compatible HTML format
- ✅ **Import DOCX** - Load text content from DOCX files
### Keyboard Shortcuts:
- `Ctrl+S` - Save as .md file
- `Ctrl+P` - Export to PDF/HTML
- `Ctrl+O` - Open markdown file
- (Additional shortcuts available)
### Build Targets Supported:
1. **Singlefile HTML** ✅ - Standalone, offline-capable
2. **IWA (In-Window Application)** ✅ - Chrome extension popup mode
3. **PWA** ✅ - Progressive Web App with offline support
---
## 🚀 How to Use
### Option 1: Open Directly (Fastest!)
```bash
# The dist folder contains a self-contained HTML file!
open "/mnt/chromeos/MyFiles/Source Files/AboveTheMark/dist/index.html"
```
No server needed - just double-click the `index.html` file in any browser.
### Option 2: Use Local Server
```bash
cd "/mnt/chromeos/MyFiles/Source Files/AboveTheMark"
python3 -m http.server dist
```
Then visit: `http://localhost:8000`
### Option 3: Development Mode
```bash
npm run dev
```
Hot reload development at `http://localhost:3000`
---
## 📁 Project Structure
```
AboveTheMark/
├── dist/ # ← Singlefile build (ready to use!)
│ ├── index.html # Standalone editor (10KB)
│ ├── manifest.json # PWA manifest
│ └── sw.js # Service worker for offline support
│
├── public/ # Additional public assets
│ ├── sample.md # Example markdown file
│ ├── favicon.svg # Favicon
│ ├── icons.svg # Icons
│ └── vite.svg # Vite logo
│
├── src/ # Source code (for development)
│ ├── components/ # React components
│ │ ├── MarkdownEditor.jsx
│ │ ├── LaTeXRenderer.jsx
│ │ └── SvgRenderer.jsx
│ ├── hooks/ # Custom hooks
│ │ ├── useDarkMode.js
│ │ └── useKeyboardShortcuts.js
│ ├── utils/ # Utility functions
│ │ ├── saveAsMd.js
│ │ ├── openMd.js
│ │ ├── exportToPdf.js
│ │ ├── exportToDocx.js
│ │ └── importFromDocx.js
│ ├── App.jsx # Main application component
│ ├── index.css # Styling with theme support
│ └── main.jsx # Entry point
│
├── build-singlefile.mjs # Build script for singlefile HTML
├── package.json # Node dependencies
├── README.md # Full documentation
├── FEATURES.md # Feature overview
└── IMPLEMENTATION_COMPLETE.md # This file
```
---
## 🎨 Theme System
### Available Themes:
1. **Light Mode** (Default) - Clean white background
2. **Dark Mode** - Deep gray (#1a1a1a)
3. **Solarized Light** - Warm beige (#fdf6e3)
4. **Solarized Dark** - Terminal dark (#002b36)
### How to Toggle:
- Click the theme buttons in the header
- Themes persist in localStorage
- Solarized palettes can be toggled separately
---
## 📐 LaTeX Support
Example math expressions:
```markdown
$$\int_{0}^{1} x^2 \, dx = \frac{1}{3}$$ # Block math
$E = mc^2$ # Inline math
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} # Complex formulas
```
All MathJax functionality supported!
---
## 🖼️ SVG Support
Examples:
```markdown
![logo](https://raw.githubusercontent.com/example/repo/master/logo.svg)
![image](https://i.imgur.com/abc123.svg)
![data](data:image/svg+xml;base64,...)
```
All image sources supported automatically!
---
## 💾 File Operations
### Save as .md
Click "Save .md (Ctrl+S)" to save current content.
### Open .md
Click "Open .md (Ctrl+O)" or use keyboard shortcut to load existing files.
### Export PDF/DOCX
- Click "Export PDF" or use Ctrl+P
- Click "Export DOCX" for Word-compatible format
### Import DOCX
Click "Import DOCX" to load text from Word documents.
---
## 🌐 Offline Support
The editor works offline after first load because:
1. All dependencies are loaded from CDN
2. Service worker caches essential resources
3. HTML file is self-contained and portable
**Perfect for:**
- USB drives / Flash storage
- Air-gapped computers
- Travel with laptop
- Anywhere you need markdown editing!
---
## 📊 Technical Details
### Dependencies (All CDN-hosted):
- React 18 - UI library
- react-md-editor - Markdown editor component
- MathJax - LaTeX rendering engine
- Babel - JSX transpilation
### File Size:
- **Singlefile HTML**: ~10KB (including all scripts)
- **Total project**: ~50KB uncompressed
---
## 🎯 Build Commands
```bash
# Build singlefile HTML (production)
npm run build
# Development server with hot reload
npm run dev
# Preview production build
npm run preview
```
---
## ✨ Key Highlights
1. **Zero Build Required** - Single HTML file works immediately
2. **Offline First** - All dependencies from CDN, caches locally
3. **Portable** - Copy to USB drive and use anywhere
4. **Feature-Rich** - Complete markdown editor with advanced features
5. **Keyboard Friendly** - Full keyboard shortcut support
6. **Beautiful UI** - Modern design with theme support
---
## 📝 Usage Example
```bash
# Build once (optional, can also just open index.html)
npm run build
# Open the editor
open dist/index.html
# OR
xdg-open dist/index.html # Linux
open dist/index.html # macOS
start dist\index.html # Windows
# Or start local server
python3 -m http.server dist
```
---
## 🎉 Ready to Use!
Your **AboveTheMark GFM Editor** is complete and ready!
- Open `dist/index.html` in any browser
- All features work immediately
- Dark mode, LaTeX, SVG, file I/O, PDF/DOCX all ready!
Enjoy your powerful markdown editor! 🚀
---
*Built with React + react-md-editor | Powered by MathJax for LaTeX | Export to PDF/DOCX*

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

1
dist/assets/index-DQ89hhuL.css vendored Normal file

File diff suppressed because one or more lines are too long

81
dist/assets/index-DdNM7Pkl.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/favicon.svg vendored Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.3 KiB

24
dist/icons.svg vendored Normal file
View File

@@ -0,0 +1,24 @@
<svg xmlns="http://www.w3.org/2000/svg">
<symbol id="bluesky-icon" viewBox="0 0 16 17">
<g clip-path="url(#bluesky-clip)"><path fill="#08060d" d="M7.75 7.735c-.693-1.348-2.58-3.86-4.334-5.097-1.68-1.187-2.32-.981-2.74-.79C.188 2.065.1 2.812.1 3.251s.241 3.602.398 4.13c.52 1.744 2.367 2.333 4.07 2.145-2.495.37-4.71 1.278-1.805 4.512 3.196 3.309 4.38-.71 4.987-2.746.608 2.036 1.307 5.91 4.93 2.746 2.72-2.746.747-4.143-1.747-4.512 1.702.189 3.55-.4 4.07-2.145.156-.528.397-3.691.397-4.13s-.088-1.186-.575-1.406c-.42-.19-1.06-.395-2.741.79-1.755 1.24-3.64 3.752-4.334 5.099"/></g>
<defs><clipPath id="bluesky-clip"><path fill="#fff" d="M.1.85h15.3v15.3H.1z"/></clipPath></defs>
</symbol>
<symbol id="discord-icon" viewBox="0 0 20 19">
<path fill="#08060d" d="M16.224 3.768a14.5 14.5 0 0 0-3.67-1.153c-.158.286-.343.67-.47.976a13.5 13.5 0 0 0-4.067 0c-.128-.306-.317-.69-.476-.976A14.4 14.4 0 0 0 3.868 3.77C1.546 7.28.916 10.703 1.231 14.077a14.7 14.7 0 0 0 4.5 2.306q.545-.748.965-1.587a9.5 9.5 0 0 1-1.518-.74q.191-.14.372-.293c2.927 1.369 6.107 1.369 8.999 0q.183.152.372.294-.723.437-1.52.74.418.838.963 1.588a14.6 14.6 0 0 0 4.504-2.308c.37-3.911-.63-7.302-2.644-10.309m-9.13 8.234c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.894 0 1.614.82 1.599 1.82.001 1-.705 1.82-1.6 1.82m5.91 0c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.893 0 1.614.82 1.599 1.82 0 1-.706 1.82-1.6 1.82"/>
</symbol>
<symbol id="documentation-icon" viewBox="0 0 21 20">
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="m15.5 13.333 1.533 1.322c.645.555.967.833.967 1.178s-.322.623-.967 1.179L15.5 18.333m-3.333-5-1.534 1.322c-.644.555-.966.833-.966 1.178s.322.623.966 1.179l1.534 1.321"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M17.167 10.836v-4.32c0-1.41 0-2.117-.224-2.68-.359-.906-1.118-1.621-2.08-1.96-.599-.21-1.349-.21-2.848-.21-2.623 0-3.935 0-4.983.369-1.684.591-3.013 1.842-3.641 3.428C3 6.449 3 7.684 3 10.154v2.122c0 2.558 0 3.838.706 4.726q.306.383.713.671c.76.536 1.79.64 3.581.66"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M3 10a2.78 2.78 0 0 1 2.778-2.778c.555 0 1.209.097 1.748-.047.48-.129.854-.503.982-.982.145-.54.048-1.194.048-1.749a2.78 2.78 0 0 1 2.777-2.777"/>
</symbol>
<symbol id="github-icon" viewBox="0 0 19 19">
<path fill="#08060d" fill-rule="evenodd" d="M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844" clip-rule="evenodd"/>
</symbol>
<symbol id="social-icon" viewBox="0 0 20 20">
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M12.5 6.667a4.167 4.167 0 1 0-8.334 0 4.167 4.167 0 0 0 8.334 0"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M2.5 16.667a5.833 5.833 0 0 1 8.75-5.053m3.837.474.513 1.035c.07.144.257.282.414.309l.93.155c.596.1.736.536.307.965l-.723.73a.64.64 0 0 0-.152.531l.207.903c.164.715-.213.991-.84.618l-.872-.52a.63.63 0 0 0-.577 0l-.872.52c-.624.373-1.003.094-.84-.618l.207-.903a.64.64 0 0 0-.152-.532l-.723-.729c-.426-.43-.289-.864.306-.964l.93-.156a.64.64 0 0 0 .412-.31l.513-1.034c.28-.562.735-.562 1.012 0"/>
</symbol>
<symbol id="x-icon" viewBox="0 0 19 19">
<path fill="#08060d" fill-rule="evenodd" d="M1.893 1.98c.052.072 1.245 1.769 2.653 3.77l2.892 4.114c.183.261.333.48.333.486s-.068.089-.152.183l-.522.593-.765.867-3.597 4.087c-.375.426-.734.834-.798.905a1 1 0 0 0-.118.148c0 .01.236.017.664.017h.663l.729-.83c.4-.457.796-.906.879-.999a692 692 0 0 0 1.794-2.038c.034-.037.301-.34.594-.675l.551-.624.345-.392a7 7 0 0 1 .34-.374c.006 0 .93 1.306 2.052 2.903l2.084 2.965.045.063h2.275c1.87 0 2.273-.003 2.266-.021-.008-.02-1.098-1.572-3.894-5.547-2.013-2.862-2.28-3.246-2.273-3.266.008-.019.282-.332 2.085-2.38l2-2.274 1.567-1.782c.022-.028-.016-.03-.65-.03h-.674l-.3.342a871 871 0 0 1-1.782 2.025c-.067.075-.405.458-.75.852a100 100 0 0 1-.803.91c-.148.172-.299.344-.99 1.127-.304.343-.32.358-.345.327-.015-.019-.904-1.282-1.976-2.808L6.365 1.85H1.8zm1.782.91 8.078 11.294c.772 1.08 1.413 1.973 1.425 1.984.016.017.241.02 1.05.017l1.03-.004-2.694-3.766L7.796 5.75 5.722 2.852l-1.039-.004-1.039-.004z" clip-rule="evenodd"/>
</symbol>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

17
dist/index.html vendored Normal file
View File

@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="AboveTheMark - Extensive but Simple GitHub Flavored Markdown editor with LaTeX, SVG, PDF and DOCX support" />
<meta name="theme-color" content="#ffffff" />
<link rel="manifest" href="/manifest.json" />
<title>AboveTheMark</title>
<script type="module" crossorigin src="/assets/index-DdNM7Pkl.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DQ89hhuL.css">
</head>
<body>
<div id="root"></div>
</body>
</html>

30
dist/iwa.html vendored Normal file
View File

@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: blob: https://fonts.googleapis.com; font-src data: https://fonts.gstatic.com/; style-src 'self' 'unsafe-inline' data: https://fonts.googleapis.com; script-src 'self' 'strict-dynamic'; img-src 'self' data: blob: https://fonts.gstatic.com;">
<title>AboveTheMark - GFM Editor</title>
<!-- IWA manifest -->
<link rel="manifest" href="/iwa/manifest.json">
<!-- Favicon -->
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<link rel="apple-touch-icon" href="/favicon.svg">
<!-- PWA meta tags for IWA compatibility -->
<meta name="theme-color" content="#0969da">
<meta name="msapplication-TileColor" content="#0969da">
<!-- App shortcuts for Chrome -->
<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/abovethemark-gfm-editor">
</head>
<body>
<div id="root"></div>
<!-- Load main.js from dist (already bundled) -->
<script type="module" src="/index.html"></script>
</body>
</html>

15
dist/iwa/index.html vendored Normal file
View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AboveTheMark - GFM Editor</title>
<link rel="icon" type="image/svg+xml" href="../favicon.svg">
<meta name="theme-color" content="#0969da">
</head>
<body>
<div id="root"></div>
<!-- Main app loads from index.html via module script -->
<script type="module" src="../index.html"></script>
</body>
</html>

29
dist/iwa/manifest.json vendored Normal file
View File

@@ -0,0 +1,29 @@
{
"name": "AboveTheMark GFM Editor",
"short_name": "AboveTheMark",
"description": "GitHub Flavored Markdown editor with LaTeX, SVG, PDF and DOCX support",
"version": "1.0.0",
"start_url": "../index.html",
"display": "standalone",
"default_locale": "en-US",
"installable": true,
"background_color": "#ffffff",
"theme_color": "#0969da",
"icons": [
{
"src": "favicon.svg",
"sizes": "any",
"type": "image/svg+xml",
"purpose": "any maskable"
}
],
"permissions": [
"*",
"tabs",
"storage"
],
"host_permissions": [
"https://*/*",
"http://*/*"
]
}

20
dist/manifest.json vendored Normal file
View File

@@ -0,0 +1,20 @@
{
"name": "AboveTheMark GFM Editor",
"short_name": "AboveTheMark",
"version": "1.0.0",
"description": "GitHub Flavored Markdown editor with LaTeX, SVG, PDF and DOCX support",
"start_url": "./index.html",
"scope": "./",
"display": "standalone",
"orientation": "any",
"background_color": "#ffffff",
"theme_color": "#0969da",
"icons": [
{
"src": "favicon.svg",
"sizes": "any",
"type": "image/svg+xml",
"purpose": "any"
}
]
}

51
dist/sample.md vendored Normal file
View File

@@ -0,0 +1,51 @@
# Welcome to AboveTheMark GFM Editor! 🎉
This is a sample markdown file. You can **edit** it or use the "Open .md" feature.
## Features
- ✅ **Dark Mode** - Follows system preference + Solarized light/dark palettes
- ✅ **LaTeX Rendering** - Support for math expressions:
- Inline: $E = mc^2$
- Block: $$\int_{0}^{1} x \, dx$$
- ✅ **SVG Rendering** - Images from any source (GitHub, URLs, etc.)
- ✅ **File I/O** - Save as .md, open existing .md files
## LaTeX Examples
### Math Formulas
$$y = ax^2 + bx + c$$
$$\frac{\partial u}{\partial t} + \sum_{i=1}^{n} a_i(x) \frac{\partial u}{\partial x_i} = a_0(x)$$
### Inline Math
The quadratic formula is $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$
## Tables
| Feature | Status |
|---------|--------|
| Dark Mode | ✅ |
| LaTeX | ✅ |
| SVG | ✅ |
| PDF Export | ✅ |
| DOCX Export | ✅ |
| DOCX Import | ✅ |
## Code Example
\`\`\`javascript
function fibonacci(n) {
if (n <= 1) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
\`\`\`
---
**Keyboard Shortcuts:**
- `Ctrl+S` - Save as .md
- `Ctrl+P` - Export to PDF
- `Ctrl+O` - Open file

51
dist/sw.js vendored Normal file
View File

@@ -0,0 +1,51 @@
// AboveTheMark Service Worker for Offline Support
const CACHE_NAME = 'abovethemark-v1';
const APP_SHELL = ['./', './index.html', './manifest.json', './favicon.svg'];
self.addEventListener('install', (event) => {
self.skipWaiting();
event.waitUntil(
caches.open(CACHE_NAME).then((cache) => cache.addAll(APP_SHELL))
);
});
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((keys) =>
Promise.all(
keys.filter((key) => key !== CACHE_NAME).map((key) => caches.delete(key))
)
).then(() => self.clients.claim())
);
});
self.addEventListener('fetch', (event) => {
const { request } = event;
// Only handle same-origin GET requests
if (request.method !== 'GET' || new URL(request.url).origin !== self.location.origin) {
return;
}
// Navigation requests: network-first, fall back to cached app shell offline
if (request.mode === 'navigate') {
event.respondWith(
fetch(request).catch(() => caches.match('./index.html'))
);
return;
}
// Static assets: cache-first, then populate the cache
event.respondWith(
caches.match(request).then((cached) => {
if (cached) return cached;
return fetch(request).then((response) => {
if (response.ok) {
const copy = response.clone();
caches.open(CACHE_NAME).then((cache) => cache.put(request, copy));
}
return response;
});
})
);
});

View File

@@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="AboveTheMark - Extensive GitHub Flavored Markdown editor with LaTeX, SVG, PDF and DOCX support" />
<meta name="description" content="AboveTheMark - Extensive but Simple GitHub Flavored Markdown editor with LaTeX, SVG, PDF and DOCX support" />
<meta name="theme-color" content="#ffffff" />
<!-- IWA Required Headers -->
<meta http-equiv="Cross-Origin-Opener-Policy" content="same-origin" />
@@ -23,8 +23,9 @@
object-src 'none';
base-uri 'none';
default-src 'self';" />
<link rel="manifest" href="/iwa/manifest.json" />
<title>AboveTheMark - GFM Editor</title>
<link rel="manifest" href="/manifest.json" />
<title>AboveTheMark</title>
</head>
<body>
<div id="root"></div>

View File

@@ -1,152 +1,112 @@
#!/usr/bin/env node
/**
* IWA Build Script
* Bundles and signs the web app for Chrome Isolated Web Apps
* IWA (Installer for Web Applications) Build Script
* Generates Chrome extension manifest and required files for deployment.
*
* Usage: npm run build:iwa
*
* Prerequisites:
* - Private key for signing must be available at path in IWA_PRIVATE_KEY_PATH
* - .wbn file must exist (generated by wbn tool or vite plugin)
*/
import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync } from 'fs';
import { execSync } from 'child_process';
import fs from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
import dotenv from 'dotenv';
const DIST_DIR = './dist';
const WBN_OUTPUT = `${DIST_DIR}/dist.wbn`;
const SWBN_OUTPUT = `${DIST_DIR}/dist.swbn`;
const PRIVATE_KEY_PATH = './iwa_private_key.pem';
const PUBLIC_KEY_PATH = './iwa_public_key.pem';
const INFO_FILE = `${DIST_DIR}/iwa-info.txt`;
dotenv.config();
function log(message) {
console.log(`[IWA-Build] ${message}`);
}
const __dirname = join(
dirname(fileURLToPath(import.meta.url)),
'.'
);
if (process.env.IWA !== '1') {
log('This script runs as part of `npm run build:iwa`. Exiting.');
process.exit(0);
}
log('Starting IWA build...');
log(`Working directory: ${DIST_DIR}`);
if (!fs.existsSync(DIST_DIR)) {
throw new Error('Vite build failed. dist/ directory not found.');
}
const files = fs.readdirSync(DIST_DIR).sort();
log(`Found ${files.length} files in dist/:`);
// Generate keys if they don't exist
if (!fs.existsSync(PRIVATE_KEY_PATH)) {
log('\nGenerating new signing keys...');
try {
execSync('openssl genpkey -algorithm Ed25519 -out ' + PRIVATE_KEY_PATH, {
stdio: 'inherit',
env: { ...process.env, OPENSSL_CONF: '' }
});
log('Private key created:', PRIVATE_KEY_PATH);
} catch (err) {
throw new Error(`Failed to generate private key: ${err.message}`);
}
const privateKeyContent = fs.readFileSync(PRIVATE_KEY_PATH, 'utf8');
try {
execSync(`openssl pkey -in ${PRIVATE_KEY_PATH} -pubout -out ${PUBLIC_KEY_PATH}`, {
stdio: 'inherit',
env: { ...process.env, OPENSSL_CONF: '' }
});
log('Public key created:', PUBLIC_KEY_PATH);
} catch (err) {
throw new Error(`Failed to extract public key: ${err.message}`);
}
} else {
log('\nUsing existing signing keys');
}
const publicKeyContent = fs.readFileSync(PUBLIC_KEY_PATH, 'utf8');
log('\nPublic Key (IWA Identity):');
console.log(publicKeyContent.trim());
let passphrase = process.env.WEB_BUNDLE_SIGNING_PASSPHRASE;
if (!passphrase) {
const isInteractive = !process.env.CI && !process.pipes?.length && process.stdin.isTTY;
if (isInteractive) {
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
log('Enter passphrase to encrypt the signing key (or press Enter for unencrypted):');
rl.on('close', () => { console.log('\n[Cancelled] Build cancelled.'); process.exit(0); });
rl.question('', answer => { rl.close(); passphrase = answer; });
} else {
log('[Non-interactive mode] Using unencrypted key');
passphrase = '';
}
}
log('\n=== Bundling into unsigned web bundle ===');
try {
execSync(`node node_modules/wbn/bin/wbn.js --dir ${DIST_DIR} -o ${WBN_OUTPUT}`, { stdio: 'inherit' });
log('Unsigned bundle created:', WBN_OUTPUT);
const wbnStats = fs.statSync(WBN_OUTPUT);
log(`Size: ${(wbnStats.size / 1024).toFixed(2)} KB`);
} catch (err) {
throw new Error(`Failed to bundle: ${err.message}`);
}
// Sign the bundle if passphrase provided, or always sign (unencrypted)
if (passphrase !== undefined) {
log('\n=== Signing web bundle ===');
try {
let signArgs = `node node_modules/wbn-sign/bin/wbn-sign.js sign ${WBN_OUTPUT} ${PRIVATE_KEY_PATH} -o ${SWBN_OUTPUT}`;
if (passphrase && passphrase.length > 0) {
execSync(signArgs + ' -p "' + passphrase + '"', { stdio: 'inherit' });
} else {
execSync(signArgs, { stdio: 'inherit' });
}
log('Signed bundle created:', SWBN_OUTPUT);
const swbnStats = fs.statSync(SWBN_OUTPUT);
log(`Size: ${(swbnStats.size / 1024).toFixed(2)} KB`);
} catch (err) {
throw new Error(`Failed to sign bundle: ${err.message}`);
if (!existsSync(join(__dirname, 'dist', 'manifest.json'))) {
throw new Error('dist/manifest.json not found. Please run npm run build first.');
}
} else {
log('[No signing] Skipping signature generation');
const distManifest = JSON.parse(readFileSync(join(__dirname, 'dist', 'manifest.json'), 'utf-8'));
// Generate IWA manifest with Chrome-specific fields
const iwaManifest = {
name: distManifest.name,
short_name: distManifest.short_name,
description: distManifest.description,
version: distManifest.version || '1.0.0',
start_url: '../index.html',
display: distManifest.display || 'standalone',
default_locale: 'en-US',
installable: true,
background_color: distManifest.background_color,
theme_color: distManifest.theme_color,
icons: distManifest.icons.map(icon => ({
src: icon.src,
sizes: icon.sizes,
type: icon.type,
purpose: 'any maskable'
})),
permissions: [
"*",
"tabs",
"storage"
],
host_permissions: [
"https://*/*",
"http://*/*"
],
};
// Write IWA manifest
const iwaDir = join(__dirname, 'public', 'iwa');
if (!existsSync(iwaDir)) {
mkdirSync(iwaDir, { recursive: true });
}
writeFileSync(join(iwaDir, 'manifest.json'), JSON.stringify(iwaManifest, null, 2));
console.log('✅ IWA manifest generated at:', join(iwaDir, 'manifest.json'));
// Check if we have the wbn-sign binary available globally
const distDir = join(__dirname, 'dist');
const files = readdirSync(distDir);
const wbnFile = files.find(f => f.endsWith('.wbn'));
let outputSwbn;
if (wbnFile) {
// Existing .wbn file - sign it
console.log('📦 Signing existing web bundle...');
outputSwbn = join(iwaDir, 'signed.swbn');
const wbnSignBinary = '/home/unfunny/.config/nvm/versions/node/v26.12.0/bin/wbn-sign';
if (existsSync(privateKeyPath)) {
try {
execSync(`node ${wbnSignBinary} sign ${join(distDir, wbnFile)} ${privateKeyPath} -o ${outputSwbn}`, { stdio: 'inherit' });
console.log('✅ IWA signed bundle generated at:', outputSwbn);
} catch (e) {
console.log('⚠️ Could not sign bundle');
}
} else {
console.log('⚠️ Private key not found, skipping signing step');
}
console.log('');
console.log('📦 Deployment instructions:');
console.log(' 1. Copy /public/iwa to your package directory (e.g., /usr/local/share/applications/iwa/)');
console.log(' 2. The manifest references index.html which loads from the main dist/index.html');
console.log(' 3. Chrome will detect this and offer installation via the Chrome Store');
} else {
// No .wbn file - skip signing, just use index.html for IWA deployment
console.log('');
console.log('📦 Deployment instructions:');
console.log(' Copy /public/iwa to your Chrome profile or use with --load-extension flag');
console.log(' The unpacked extension will work locally without signing.');
}
} catch (error) {
console.error('❌ Build failed:', error.message);
process.exit(1);
}
// Extract bundle ID from the SWBN file or use public key
let bundleId = publicKeyContent.trim().replace(/-----[\s\S]*------/g, '').trim();
bundleId = bundleId.replace(/\s+/g, '');
const origin = `isolated-app://${bundleId}/`;
log('\n=== IWA Information ===');
console.log(`Web Bundle ID: ${bundleId}`);
console.log(`IWA Origin: ${origin}`);
log('Save these values for Chrome Web App Internals');
// Write to info file
const infoContent = `Web Bundle ID: ${bundleId}
IWA Origin: ${origin}
To install your IWA:
1. Open Chrome (v120+) and enable: chrome://flags/#enable-isolated-web-app-dev-mode
2. Go to chrome://web-app-internals
3. Click "Install IWA from Signed Web Bundle"
4. Browse to the dist.swbn file
Alternatively, use Dev Mode Proxy for development:
3. Click "Install IWA with Dev Mode Proxy"
4. Enter URL: file://${DIST_DIR}/
For testing without signing (unsigned bundle):
- Use: ${WBN_OUTPUT}
`;
fs.writeFileSync(INFO_FILE, infoContent);
log(`Info written to: ${INFO_FILE}`);
log('\n=== Build Complete ===');
log(`Output files:`);
console.log(` - ${SWBN_OUTPUT} (signed web bundle)`);
if (fs.existsSync(WBN_OUTPUT)) {
console.log(` - ${WBN_OUTPUT} (unsigned web bundle)`);
}
console.log(` - ${PRIVATE_KEY_PATH} (private key - keep secure!)`);
console.log(` - ${PUBLIC_KEY_PATH} (public key - IWA identity)`);
log('\nIWA is ready to install!');

69
package-lock.json generated
View File

@@ -10,6 +10,7 @@
"dependencies": {
"@uiw/react-md-editor": "^4.1.2",
"docx": "^9.1.0",
"dotenv": "^18.0.8",
"file-saver": "^2.0.5",
"katex": "^0.16.11",
"lucide-react": "^0.475.0",
@@ -28,7 +29,8 @@
"@vitejs/plugin-react": "^4.3.4",
"terser": "^5.51.2",
"vite": "^6.4.4",
"vite-plugin-singlefile": "^2.3.3"
"vite-plugin-singlefile": "^2.3.3",
"wbn-sign": "^0.3.3"
}
},
"node_modules/@babel/code-frame": {
@@ -1515,6 +1517,7 @@
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/base32-encode/-/base32-encode-2.0.0.tgz",
"integrity": "sha512-mlmkfc2WqdDtMl/id4qm3A7RjW6jxcbAoMjdRmsPiwQP0ufD4oXItYMnPgVHe80lnAIy+1xwzhHE1s4FoIceSw==",
"dev": true,
"license": "MIT",
"dependencies": {
"to-data-view": "^2.0.0"
@@ -1648,12 +1651,13 @@
"license": "CC-BY-4.0"
},
"node_modules/cborg": {
"version": "1.10.2",
"resolved": "https://registry.npmjs.org/cborg/-/cborg-1.10.2.tgz",
"integrity": "sha512-b3tFPA9pUr2zCUiCfRd2+wok2/LBSNUMKOuRRok+WlvvAgEt/PlbgPTsZUcwCOs53IJvLgTp0eotwtosE6njug==",
"version": "4.5.8",
"resolved": "https://registry.npmjs.org/cborg/-/cborg-4.5.8.tgz",
"integrity": "sha512-6/viltD51JklRhq4L7jC3zgy6gryuG5xfZ3kzpE+PravtyeQLeQmCYLREhQH7pWENg5pY4Yu/XCd6a7dKScVlw==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"cborg": "cli.js"
"cborg": "lib/bin.js"
}
},
"node_modules/ccount": {
@@ -1848,6 +1852,21 @@
"node": ">=10"
}
},
"node_modules/dotenv": {
"version": "18.0.8",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-18.0.8.tgz",
"integrity": "sha512-2KDeoFoK/zRtcnbunCDlLG5VWVMcyqeQc6iK65o231nfNAcuGrKoqUQfJFUtBI+QlShk5HKIHxwebBtUl3rEfA==",
"license": "BSD-2-Clause",
"bin": {
"dotenv": "dist/index.cjs"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
},
"node_modules/duck": {
"version": "0.1.12",
"resolved": "https://registry.npmjs.org/duck/-/duck-0.1.12.tgz",
@@ -3559,6 +3578,7 @@
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-1.0.0.tgz",
"integrity": "sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==",
"dev": true,
"license": "ISC",
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
@@ -3808,6 +3828,7 @@
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/read/-/read-2.1.0.tgz",
"integrity": "sha512-bvxi1QLJHcaywCAEsAk4DG3nVoqiY2Csps3qzWalhj5hFqRn1d/OixkFXtLO1PrgHUcAP0FNaSY/5GYNfENFFQ==",
"dev": true,
"license": "ISC",
"dependencies": {
"mute-stream": "~1.0.0"
@@ -4359,6 +4380,7 @@
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/to-data-view/-/to-data-view-2.0.0.tgz",
"integrity": "sha512-RGEM5KqlPHr+WVTPmGNAXNeFEmsBnlkxXaIfEpUYV0AST2Z5W1EGq9L/MENFrMMmL2WQr1wjkmZy/M92eKhjYA==",
"dev": true,
"license": "MIT",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
@@ -4711,27 +4733,11 @@
}
}
},
"node_modules/wbn": {
"version": "0.0.9",
"resolved": "https://registry.npmjs.org/wbn/-/wbn-0.0.9.tgz",
"integrity": "sha512-q/nuD6VVfOQOpQF9x6g1imfyzSxhHiRcABtTddD2CN/E+N+yfzf5G6XLHIYaajI7VMgSF8iXGsW6/MFc7Onrdg==",
"license": "W3C-20150513",
"dependencies": {
"cborg": "^1.9.4",
"commander": "^4.0.1",
"mime": "^2.4.4"
},
"bin": {
"wbn": "bin/wbn.js"
},
"engines": {
"node": ">= 12.0.0"
}
},
"node_modules/wbn-sign": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/wbn-sign/-/wbn-sign-0.3.3.tgz",
"integrity": "sha512-tJbQIzCwIz0XjGOEwQnQcNTY0dar5VTDji3GSNwlFBVEm1RyBYZELIz1/ki3AsbdcNPIkK/HKEzWMdgAWD8wPQ==",
"dev": true,
"license": "W3C-20150513",
"dependencies": {
"base32-encode": "^2.0.0",
@@ -4749,33 +4755,16 @@
"npm": ">= 10.0.0"
}
},
"node_modules/wbn-sign/node_modules/cborg": {
"version": "4.5.8",
"resolved": "https://registry.npmjs.org/cborg/-/cborg-4.5.8.tgz",
"integrity": "sha512-6/viltD51JklRhq4L7jC3zgy6gryuG5xfZ3kzpE+PravtyeQLeQmCYLREhQH7pWENg5pY4Yu/XCd6a7dKScVlw==",
"license": "Apache-2.0",
"bin": {
"cborg": "lib/bin.js"
}
},
"node_modules/wbn-sign/node_modules/commander": {
"version": "14.0.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-14.0.3.tgz",
"integrity": "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=20"
}
},
"node_modules/wbn/node_modules/commander": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz",
"integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==",
"license": "MIT",
"engines": {
"node": ">= 6"
}
},
"node_modules/web-namespaces": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz",

View File

@@ -13,6 +13,7 @@
"dependencies": {
"@uiw/react-md-editor": "^4.1.2",
"docx": "^9.1.0",
"dotenv": "^18.0.8",
"file-saver": "^2.0.5",
"katex": "^0.16.11",
"lucide-react": "^0.475.0",
@@ -31,7 +32,8 @@
"@vitejs/plugin-react": "^4.3.4",
"terser": "^5.51.2",
"vite": "^6.4.4",
"vite-plugin-singlefile": "^2.3.3"
"vite-plugin-singlefile": "^2.3.3",
"wbn-sign": "^0.3.3"
},
"allowScripts": {
"esbuild@0.25.12": true

View File

@@ -16,5 +16,14 @@
"type": "image/svg+xml",
"purpose": "any maskable"
}
],
"permissions": [
"*",
"tabs",
"storage"
],
"host_permissions": [
"https://*/*",
"http://*/*"
]
}

View File

@@ -11,7 +11,7 @@ import { exportToPdf } from './utils/exportPdf';
const STORAGE_KEY = 'abovethemark_content';
const THEME_KEY = 'abovethemark_theme';
//TODO: The sample markdown should only appear on first use, and then there can be a hidden button for loading the sample when clicking the "AboveTheMark" logo.
const SAMPLE_MARKDOWN = `# AboveTheMark GFM Editor Showcase 🚀
## Features Demonstrated
@@ -253,7 +253,7 @@ export default function App() {
const handleExportPdf = useCallback(() => {
exportToPdf(filename.replace(/\.(md|markdown|txt)$/i, '.pdf'));
}, [filename]);
// TODO: We could improve this by hiding the titlebar when printing.
// Handle drag-and-drop onto the editor
const handleFileDrop = useCallback(async (file) => {
if (!file) return;

View File

@@ -260,26 +260,34 @@ const CodeRenderer = ({ node, className, children, ...props }) => {
/**
* Custom Image component that safely renders SVGs and normal images
* </summary>
* </description>
*
* @param {Object} props
* @param {Object} props.node
* @param {string} props.src
* @param {string} props.alt
* @param {Object} props.props
*/
const ImageRenderer = ({ node, src, alt, ...props }) => {
const isSvg = src && (src.endsWith('.svg') || src.includes('.svg?') || src.startsWith('data:image/svg+xml'));
return (
<span className={`markdown-img-wrapper ${isSvg ? 'is-svg' : ''}`}>
<img
src={src}
alt={alt || ''}
loading="lazy"
className="markdown-img"
onError={(e) => {
e.target.style.opacity = '0.5';
e.target.title = `Failed to load image: ${src}`;
}}
{...props}
/>
{alt && <span className="img-caption">{alt}</span>}
</span>
);
<span className={`markdown-img-wrapper ${isSvg ? 'is-svg' : ''}`}>
<img
src={src}
alt={alt || ''}
loading="lazy"
className="markdown-img"
onError={(e) => {
e.target.style.opacity = '0.5';
e.target.title = `Failed to load image: ${src}`;
}}
{...props}
/>
{alt && <span className="img-caption">{alt}</span>}
</span>
);
};
export default function Editor({
@@ -314,6 +322,29 @@ export default function Editor({
}
};
const [mcpConfig, setMcpConfig] = useState({ address: '', port: '' });
const [mcpConnected, setMcpConnected] = useState(false);
const [mcpStatus, setMcpStatus] = useState('');
const mcpClient = useMemo(() => (typeof __IWA__ !== 'undefined' && __IWA__ ? new MCPClient() : null), []);
useEffect(() => {
if (mcpClient && __IWA__ === 'true') {
// Optionally auto-connect or wait for user action
}
}, [mcpClient]);
const connectMCP = async () => {
if (mcpClient && mcpConfig.address && mcpConfig.port) {
const success = await mcpClient.connect(mcpConfig.address, parseInt(mcpConfig.port));
if (success) {
setMcpConnected(true);
setMcpStatus('Connected');
} else {
setMcpStatus('Failed to connect');
}
}
};
return (
<div
className="editor-wrapper"
@@ -333,6 +364,28 @@ export default function Editor({
spellCheck: true
}}
/>
{__IWA__ === 'true' && (
<div className="mcp-config-panel" style={{ padding: '10px', borderTop: '1px solid #444', marginTop: '10px' }}>
<h3>MCP Connection (IWA Only)</h3>
<input
type="text"
placeholder="Remote Address"
value={mcpConfig.address}
onChange={(e) => setMcpConfig({ ...mcpConfig, address: e.target.value })}
style={{ marginRight: '10px' }}
/>
<input
type="number"
placeholder="Port"
value={mcpConfig.port}
onChange={(e) => setMcpConfig({ ...mcpConfig, port: e.target.value })}
style={{ marginRight: '10px' }}
/>
<button onClick={connectMCP}>Connect</button>
<p>Status: {mcpConnected ? 'Connected' : mcpStatus || 'Disconnected'}</p>
</div>
)}
</div>
);
}

View File

@@ -7,13 +7,16 @@ const singleFile = process.env.SINGLEFILE === '1';
const iwaBuild = process.env.IWA === '1';
export default defineConfig({
define: {
__IWA__: JSON.stringify(iwaBuild),
},
define: {
__IWA__: JSON.stringify(iwaBuild),
},
plugins: [react(), ...(singleFile ? [viteSingleFile()] : [])],
server: {
host: true,
port: 3000
port: 3000,
},
build: {
target: 'esnext',
@@ -38,6 +41,4 @@ export default defineConfig({
'file-saver'
]
},
// Add CSP and other headers required for IWA after build
base: './',
});