all tests pass but only if md-delim display: inline
This commit is contained in:
+14
-103
@@ -1,106 +1,17 @@
|
||||
/**
|
||||
* Development server with livereload.
|
||||
*
|
||||
* Serves the test page and ribbit dist files. Watches src/ for
|
||||
* changes, rebuilds automatically, and notifies connected browsers
|
||||
* to reload via a simple EventSource stream.
|
||||
*
|
||||
* Run: npm run dev
|
||||
*/
|
||||
const { createServer } = require('./server');
|
||||
const { execSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
var liveServer = require("live-server");
|
||||
|
||||
const PORT = 8080;
|
||||
const WATCH_DIRS = [
|
||||
path.join(__dirname, '..', '..', 'src'),
|
||||
path.join(__dirname, '..', '..', 'test', 'integration'),
|
||||
];
|
||||
const DEBOUNCE_MS = 300;
|
||||
var params = {
|
||||
port: 5023,
|
||||
host: "0.0.0.0",
|
||||
open: true,
|
||||
root: "test/integration",
|
||||
mount: [
|
||||
['/static', 'dist/ribbit'],
|
||||
['/test', 'test/integration'],
|
||||
],
|
||||
logLevel: 2, // 0 = errors only, 1 = some, 2 = lots
|
||||
};
|
||||
|
||||
const server = createServer(PORT);
|
||||
const reloadClients = [];
|
||||
|
||||
// Patch the server to add the livereload endpoint
|
||||
const originalServer = require('http').createServer;
|
||||
const httpServer = server._server || (() => {
|
||||
// Access the internal server by starting and intercepting
|
||||
let captured = null;
|
||||
const origListen = require('http').Server.prototype.listen;
|
||||
require('http').Server.prototype.listen = function (...args) {
|
||||
captured = this;
|
||||
return origListen.apply(this, args);
|
||||
};
|
||||
server.start();
|
||||
require('http').Server.prototype.listen = origListen;
|
||||
return captured;
|
||||
})();
|
||||
|
||||
// Simpler approach: create a standalone livereload server
|
||||
const reloadServer = require('http').createServer((request, response) => {
|
||||
response.writeHead(200, {
|
||||
'Content-Type': 'text/event-stream',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Connection': 'keep-alive',
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
});
|
||||
reloadClients.push(response);
|
||||
request.on('close', () => {
|
||||
const index = reloadClients.indexOf(response);
|
||||
if (index >= 0) {
|
||||
reloadClients.splice(index, 1);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function notifyReload() {
|
||||
for (const client of reloadClients) {
|
||||
client.write('data: reload\n\n');
|
||||
}
|
||||
}
|
||||
|
||||
function rebuild() {
|
||||
try {
|
||||
console.log('\n🔨 Rebuilding...');
|
||||
execSync('npm run build:js && npm run build:css', {
|
||||
cwd: path.join(__dirname, '..', '..'),
|
||||
stdio: 'pipe',
|
||||
});
|
||||
console.log('✅ Build complete');
|
||||
notifyReload();
|
||||
} catch (error) {
|
||||
console.error('❌ Build failed:', error.stderr?.toString().slice(0, 500));
|
||||
}
|
||||
}
|
||||
|
||||
let debounceTimer = null;
|
||||
function onFileChange(filename) {
|
||||
if (debounceTimer) {
|
||||
clearTimeout(debounceTimer);
|
||||
}
|
||||
console.log(`📝 Changed: ${filename}`);
|
||||
debounceTimer = setTimeout(rebuild, DEBOUNCE_MS);
|
||||
}
|
||||
|
||||
// Watch source directories
|
||||
for (const directory of WATCH_DIRS) {
|
||||
if (fs.existsSync(directory)) {
|
||||
fs.watch(directory, { recursive: true }, (eventType, filename) => {
|
||||
if (filename && !filename.includes('node_modules')) {
|
||||
onFileChange(filename);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
server.start().then(() => {
|
||||
reloadServer.listen(PORT + 1, () => {
|
||||
console.log(`\n🐸 Ribbit dev server`);
|
||||
console.log(` Editor: http://localhost:${PORT}`);
|
||||
console.log(` Livereload: http://localhost:${PORT + 1} (EventSource)`);
|
||||
console.log(` Watching: src/, test/integration/`);
|
||||
console.log(`\n Add this to the page to enable livereload:`);
|
||||
console.log(` <script>new EventSource('http://localhost:${PORT + 1}').onmessage = () => location.reload()</script>\n`);
|
||||
});
|
||||
});
|
||||
console.log(`\n🐸 Ribbit dev server running on http://localhost:${params['port']}`);
|
||||
liveServer.start(params);
|
||||
|
||||
+11
-29
@@ -3,36 +3,23 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Ribbit Integration Test Page</title>
|
||||
<link rel="stylesheet" href="/ribbit/themes/ribbit-default/theme.css">
|
||||
<style>
|
||||
body { font-family: sans-serif; margin: 20px; }
|
||||
#ribbit { border: 1px solid #ccc; padding: 20px; min-height: 200px; }
|
||||
.ribbit-toolbar { background: #f5f5f5; border: 1px solid #ccc; padding: 4px; margin-bottom: 8px; }
|
||||
.ribbit-toolbar ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; }
|
||||
.ribbit-toolbar button { padding: 4px 8px; border: 1px solid #ddd; border-radius: 3px; background: white; cursor: pointer; font-size: 12px; }
|
||||
.ribbit-toolbar button.active { background: #d0d0ff; }
|
||||
.ribbit-toolbar button.disabled { opacity: 0.3; }
|
||||
.ribbit-toolbar .spacer { width: 12px; }
|
||||
.ribbit-dropdown { position: absolute; background: white; border: 1px solid #ccc; padding: 4px; }
|
||||
.ribbit-dropdown button { display: block; width: 100%; }
|
||||
</style>
|
||||
<link rel="stylesheet" href="/static/themes/ribbit-default/theme.css">
|
||||
</head>
|
||||
<body>
|
||||
<article id="ribbit">**bold** and *italic* and `code`
|
||||
<main>
|
||||
<article id="ribbit">
|
||||
|
||||
## Heading
|
||||
| Type | To Get |
|
||||
|------|--------|
|
||||
| `*emphasis*` | *emphasis* |
|
||||
| `**bold**` | **bold** |
|
||||
| `abel](/link/address)` | [link label](/link/address) |
|
||||
| ``inline`` | `inline` |
|
||||
|
||||
- list item 1
|
||||
- list item 2
|
||||
|
||||
> a blockquote
|
||||
|
||||
| A | B |
|
||||
|---|---|
|
||||
| 1 | 2 |
|
||||
</article>
|
||||
</main>
|
||||
|
||||
<script src="/ribbit/ribbit.js"></script>
|
||||
<script src="/static/ribbit.js"></script>
|
||||
<script>
|
||||
const editor = new ribbit.Editor({
|
||||
on: {
|
||||
@@ -42,10 +29,5 @@
|
||||
editor.run();
|
||||
window.__ribbitEditor = editor;
|
||||
</script>
|
||||
<script>
|
||||
// Livereload — connects to dev server's EventSource endpoint.
|
||||
// Silently fails if the dev server isn't running.
|
||||
try { new EventSource('http://localhost:8081').onmessage = () => location.reload(); } catch(e) {}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+625
-560
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user