Release RuneStone 0.1.3 and expand plugin plans
@@ -5,7 +5,7 @@
|
|||||||
This reference preserves intended capabilities and design constraints. Some features already exist.
|
This reference preserves intended capabilities and design constraints. Some features already exist.
|
||||||
See the [roadmap](roadmap.md) for goals and milestones, and the [user guide](user-guide.md) for current behavior and limitations.
|
See the [roadmap](roadmap.md) for goals and milestones, and the [user guide](user-guide.md) for current behavior and limitations.
|
||||||
|
|
||||||
The planned design keeps the core active and adds optional features through first-party plugins. Plugin support is not implemented yet.
|
The planned design keeps the core active and adds optional features through separately packaged plugins. Plugin support is not implemented yet.
|
||||||
|
|
||||||
## Workspace and files
|
## Workspace and files
|
||||||
|
|
||||||
@@ -47,22 +47,41 @@ The planned design keeps the core active and adds optional features through firs
|
|||||||
|
|
||||||
## Plugins
|
## Plugins
|
||||||
|
|
||||||
Plugin support is pending. The plan is to ship extra features as first-party plugins with an on or off toggle. A marketplace is outside the planned scope.
|
Plugin support is pending. In-house plugins ship with RuneStone as separate packages and use the same interfaces as external plugins.
|
||||||
|
Users can enable or disable each plugin. A marketplace is outside the planned scope.
|
||||||
|
|
||||||
|
### Plugin to-do list
|
||||||
|
|
||||||
|
- [ ] Build the plugin system: package loading, version checks, permissions, settings, and enable or disable controls.
|
||||||
|
- [ ] Define shared interfaces for plugins to add commands, views, and workspace features.
|
||||||
|
- [ ] Move the terminal into a separate in-house plugin that ships with RuneStone.
|
||||||
|
- [ ] Move Excel-like table features, including formulas and spreadsheet operations, into a separate in-house plugin that ships with RuneStone.
|
||||||
|
- [ ] Add a Kanban plugin for boards, columns, and task cards.
|
||||||
|
- [ ] Add a Gantt plugin for task timelines and dependencies.
|
||||||
|
- [ ] Add a Calendar plugin for dated tasks and events.
|
||||||
|
- [ ] Add a virtual tabletop system plugin.
|
||||||
|
|
||||||
|
Keep basic Markdown table editing and rendering in the core. Users must retain access to workspace files when plugins are disabled.
|
||||||
|
Kanban, Gantt, and Calendar are separate plugins that share a task index.
|
||||||
|
Kanban boards are Markdown files. Headings are columns. Task list items are cards.
|
||||||
|
|
||||||
|
### Planned defaults
|
||||||
|
|
||||||
Planned plugins enabled by default:
|
Planned plugins enabled by default:
|
||||||
|
|
||||||
|
- Terminal. Workspace shells, sessions, and script execution.
|
||||||
|
- Tables. Excel-like formulas and spreadsheet operations.
|
||||||
- Git. Status, stage, commit, pull, push, log, and diff. Use the system `git` binary.
|
- Git. Status, stage, commit, pull, push, log, and diff. Use the system `git` binary.
|
||||||
- Sort. Per-folder order, pin, and hide. Flexplorer is a reference for behavior, not a source of code.
|
- Sort. Per-folder order, pin, and hide. Flexplorer is a reference for behavior, not a source of code.
|
||||||
|
|
||||||
Planned plugins disabled by default:
|
Planned plugins disabled by default:
|
||||||
|
|
||||||
- Projects. Kanban is the first view. Calendar and Gantt share the same task index.
|
- Kanban, Gantt, and Calendar. Separate views for task organization and schedules.
|
||||||
|
- Virtual tabletop. Tools for tabletop play within the workspace.
|
||||||
- Graph. Draw wiki-link edges from the file index.
|
- Graph. Draw wiki-link edges from the file index.
|
||||||
- Canvas. Store `.canvas` files in JSON Canvas 1.0.
|
- Canvas. Store `.canvas` files in JSON Canvas 1.0.
|
||||||
- Browser. Open a page in an in-app webview. Block ads with EasyList and EasyPrivacy.
|
- Browser. Open a page in an in-app webview. Block ads with EasyList and EasyPrivacy.
|
||||||
|
|
||||||
Kanban boards are Markdown files. Headings are columns. Task list items are cards.
|
|
||||||
|
|
||||||
## Later work
|
## Later work
|
||||||
|
|
||||||
- Background Git for people who do not want to run Git by hand. Timed commit, pull, and push. A history limit is not designed yet.
|
- Background Git for people who do not want to run Git by hand. Timed commit, pull, and push. A history limit is not designed yet.
|
||||||
@@ -73,7 +92,7 @@ Kanban boards are Markdown files. Headings are columns. Task list items are card
|
|||||||
|
|
||||||
## Out of scope
|
## Out of scope
|
||||||
|
|
||||||
- A plugin marketplace or third-party loader
|
- A plugin marketplace
|
||||||
- Obsidian or VS Code plugin compatibility
|
- Obsidian or VS Code plugin compatibility
|
||||||
- Cloud sync, live collaboration, or mobile
|
- Cloud sync, live collaboration, or mobile
|
||||||
- A debugger or a full IDE
|
- A debugger or a full IDE
|
||||||
@@ -84,4 +103,4 @@ Kanban boards are Markdown files. Headings are columns. Task list items are card
|
|||||||
Dark is the primary theme.
|
Dark is the primary theme.
|
||||||
|
|
||||||
Privileged operations belong in Rust: disk access, file watching, search, Git, terminal sessions, and adblock matching.
|
Privileged operations belong in Rust: disk access, file watching, search, Git, terminal sessions, and adblock matching.
|
||||||
Git and adblock matching belong to planned plugins.
|
Git, terminal sessions, spreadsheet operations, and adblock matching belong to planned plugins.
|
||||||
|
|||||||
@@ -44,10 +44,10 @@ and identify a reported code problem within the workspace.
|
|||||||
|
|
||||||
**Objective:** Support different ways of working while keeping the core editor simple.
|
**Objective:** Support different ways of working while keeping the core editor simple.
|
||||||
|
|
||||||
Plugin support is pending. A first-party plugin foundation would let users choose
|
Plugin support is pending. Separately packaged plugins would let users choose tools for planning, tabletop play, and other workflows.
|
||||||
optional tools for version history, organization, planning, and visual exploration.
|
The terminal and Excel-like table features would ship as in-house plugins through the same plugin system.
|
||||||
|
|
||||||
**Milestone:** A user can enable a first-party plugin, use it with workspace files,
|
**Milestone:** A user can enable a packaged plugin, use it with workspace files,
|
||||||
and disable it while retaining access to those files in the core editor.
|
and disable it while retaining access to those files in the core editor.
|
||||||
|
|
||||||
## Why this order?
|
## Why this order?
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="640" height="640" viewBox="0 0 640 640" role="img" aria-labelledby="title desc">
|
||||||
|
<title id="title">RuneStone</title>
|
||||||
|
<desc id="desc">A rounded gray stone with offset side curves and a blue carved R.</desc>
|
||||||
|
<defs>
|
||||||
|
<path id="stone-outline" d="M 294 54 C 315 51 334 53 350 65 C 394 95 423 162 440 237 C 453 296 458 349 461 393 C 463 416 483 423 489 445 C 498 472 481 494 466 521 C 443 564 401 592 347 592 L 272 592 C 224 592 194 562 177 525 C 164 497 159 464 154 435 C 152 418 142 402 143 382 C 143 360 157 344 162 321 C 178 250 195 187 225 129 C 245 92 266 59 294 54 Z"/>
|
||||||
|
<clipPath id="stone-clip"><use href="#stone-outline"/></clipPath>
|
||||||
|
<path id="rune-line" d="M 280 480 V 192 L 376 280 L 288 352 L 416 476"/>
|
||||||
|
</defs>
|
||||||
|
<g id="stone">
|
||||||
|
<use id="stone-deep-shadow" href="#stone-outline" fill="#24282D"/>
|
||||||
|
<g clip-path="url(#stone-clip)">
|
||||||
|
<path id="stone-shadow" fill="#40464C" d="M 278 50 C 312 44 336 53 350 72 C 391 111 414 175 431 247 C 443 305 446 361 450 404 C 453 426 472 438 478 458 C 482 482 462 506 448 528 C 421 563 381 578 332 578 L 274 578 C 231 576 205 550 188 515 C 174 487 169 455 163 427 C 160 408 150 393 153 374 C 156 355 167 338 172 317 C 191 234 211 175 238 121 Z"/>
|
||||||
|
<path id="stone-base" fill="#5A6268" d="M 272 52 L 329 53 C 348 73 358 98 371 120 C 396 161 416 209 424 259 C 429 281 422 298 418 314 C 413 337 420 367 424 392 C 427 414 439 435 441 455 C 443 478 424 495 408 513 C 384 541 351 559 310 560 L 279 560 C 244 557 217 538 199 509 C 183 483 173 449 168 422 C 163 406 151 391 151 375 C 152 358 164 341 168 320 C 184 251 205 178 230 128 Z"/>
|
||||||
|
<path id="stone-light" fill="#788087" d="M 271 54 L 318 53 C 337 68 346 87 355 106 C 364 125 369 144 366 160 C 346 169 323 163 305 181 C 283 204 266 234 257 269 C 246 308 232 331 224 358 C 217 382 209 407 193 436 C 175 422 161 402 151 386 C 147 377 151 366 155 355 C 175 285 189 221 213 165 C 228 125 249 82 271 54 Z"/>
|
||||||
|
<path id="stone-highlight" fill="#A2A7AA" d="M 273 56 C 293 52 314 53 332 58 L 338 74 C 324 84 308 83 299 99 C 282 124 268 151 252 173 C 235 199 229 227 215 252 C 203 277 193 299 185 322 C 179 337 166 346 159 353 C 177 281 192 221 216 165 C 231 127 251 82 273 56 Z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g id="rune" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<use id="rune-shadow" href="#rune-line" stroke="#31546A" stroke-width="32"/>
|
||||||
|
<use id="rune-base" href="#rune-line" transform="translate(4 4)" stroke="#5688A3" stroke-width="20"/>
|
||||||
|
<use id="rune-highlight" href="#rune-line" transform="translate(8 8)" stroke="#8AB8CC" stroke-width="8"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 843 B |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "runestone",
|
"name": "runestone",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"description": "Desktop editor for a local workspace",
|
"description": "Desktop editor for a local workspace",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import assert from "node:assert/strict";
|
||||||
|
import test from "node:test";
|
||||||
|
import { markdown, markdownLanguage } from "@codemirror/lang-markdown";
|
||||||
|
import { noteFormats } from "../src/lib/editor/noteFormats.ts";
|
||||||
|
import { renderMarkdownHtml } from "../src/lib/workspace/noteHtml.ts";
|
||||||
|
|
||||||
|
const parser = markdown({ base: markdownLanguage, extensions: [noteFormats] }).language.parser;
|
||||||
|
const render = (source: string) => renderMarkdownHtml(source, new Map());
|
||||||
|
function mathNodes(source: string) {
|
||||||
|
const nodes: string[] = [];
|
||||||
|
parser.parse(source).iterate({ enter(node) {
|
||||||
|
if (node.name === "NoteMath") nodes.push(source.slice(node.from, node.to));
|
||||||
|
} });
|
||||||
|
return nodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
test("dollar amounts stay literal in writing, reading, and table cells", () => {
|
||||||
|
for (const source of [
|
||||||
|
"$10", "$10 and $20", "$1,234.56 plus $78.90", "$10-$20", "$0.25-$.50",
|
||||||
|
"US$10 / CA$20", "$ 10 and $ 20", "$-10 and $-20", "($10) and ($20)",
|
||||||
|
"$10\n$20", "$10\r\n$20", "$10 **income**, $20 **cost**",
|
||||||
|
]) {
|
||||||
|
assert.deepEqual(mathNodes(source), [], source);
|
||||||
|
const html = render(source);
|
||||||
|
assert.doesNotMatch(html, /md-inline-math/, source);
|
||||||
|
assert.equal((html.match(/\$/g) || []).length, (source.match(/\$/g) || []).length, source);
|
||||||
|
assert.doesNotMatch(render(`| Amounts |\n| --- |\n| ${source.replace(/\r?\n/g, "<br>")} |`), /md-inline-math/, source);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("inline math still works next to dollar amounts", () => {
|
||||||
|
for (const expression of ["$x^2$", "$2 + 2$", "$x + y$", String.raw`$\frac{1}{2}$`, String.raw`$x + \$5$`]) {
|
||||||
|
const source = `$10 and $20, then ${expression}, then $30 and $40.`;
|
||||||
|
assert.deepEqual(mathNodes(source), [expression], source);
|
||||||
|
assert.equal((render(source).match(/md-inline-math/g) || []).length, 1, source);
|
||||||
|
assert.match(render(source), /\$10 and \$20/);
|
||||||
|
assert.match(render(source), /\$30 and \$40/);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("escaped, incomplete, spaced, multiline, and double delimiters do not create inline math", () => {
|
||||||
|
for (const source of [String.raw`\$x\$`, "$x", "$ x$", "$x $", "$x\ny$", "$$x$$", "$$\nx\n$$", "`$x$`", "```\n$x$\n```", "$x$2"]) {
|
||||||
|
assert.deepEqual(mathNodes(source), [], source);
|
||||||
|
assert.doesNotMatch(render(source), /md-inline-math/, source);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("highlight and comment formats keep their existing behavior", () => {
|
||||||
|
const source = "==**highlight**== %%comment%%";
|
||||||
|
const tree = parser.parse(source).toString();
|
||||||
|
assert.match(tree, /NoteHighlight/);
|
||||||
|
assert.match(tree, /StrongEmphasis/);
|
||||||
|
assert.match(tree, /NoteComment/);
|
||||||
|
assert.match(render(source), /<mark><strong>highlight<\/strong><\/mark>/);
|
||||||
|
assert.match(render(source), /md-inline-comment/);
|
||||||
|
});
|
||||||
@@ -74,10 +74,7 @@ async function quickOpen(name) {
|
|||||||
await page.keyboard.press("Control+p");
|
await page.keyboard.press("Control+p");
|
||||||
await page.getByRole("textbox", { name: "Find a file" }).fill(name);
|
await page.getByRole("textbox", { name: "Find a file" }).fill(name);
|
||||||
await page.getByRole("dialog").getByRole("button").filter({ hasText: name }).first().click();
|
await page.getByRole("dialog").getByRole("button").filter({ hasText: name }).first().click();
|
||||||
if (await page.getByRole("button", { name: "Switch to IDE layout (Ctrl E)", exact: true }).count()) {
|
await page.locator('.live-writer .cm-content').waitFor();
|
||||||
await page.getByRole("button", { name: "Switch to IDE layout (Ctrl E)", exact: true }).click();
|
|
||||||
}
|
|
||||||
await page.locator(".monaco-editor textarea").waitFor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const source = '# Navigation\n\nBefore.\n\n| Name | Value | Formula |\n| --- | --- | --- |\n| Alpha | 12 | =B2*2 |\n| Beta | | tail |\n| Two<br>lines | short | end |\n\nAfter.\n';
|
const source = '# Navigation\n\nBefore.\n\n| Name | Value | Formula |\n| --- | --- | --- |\n| Alpha | 12 | =B2*2 |\n| Beta | | tail |\n| Two<br>lines | short | end |\n\nAfter.\n';
|
||||||
@@ -129,7 +126,6 @@ try {
|
|||||||
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: ['navigation.md'] });
|
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: ['navigation.md'] });
|
||||||
}, source);
|
}, source);
|
||||||
await quickOpen('navigation.md');
|
await quickOpen('navigation.md');
|
||||||
await page.getByRole('button', { name: 'Switch to writing layout (Ctrl E)', exact: true }).click();
|
|
||||||
await table.waitFor();
|
await table.waitFor();
|
||||||
|
|
||||||
// Reproduce the reported right-arrow escape, including formula destinations.
|
// Reproduce the reported right-arrow escape, including formula destinations.
|
||||||
@@ -290,6 +286,36 @@ try {
|
|||||||
assert.equal(await edit.count(), 0);
|
assert.equal(await edit.count(), 0);
|
||||||
assert.equal(await page.locator('.live-writer .cm-content').evaluate(el => el === document.activeElement), true);
|
assert.equal(await page.locator('.live-writer .cm-content').evaluate(el => el === document.activeElement), true);
|
||||||
|
|
||||||
|
// A line break in a tall table keeps the caret and viewport in the active cell.
|
||||||
|
const tallSource = '# Tall table\n\nBefore.\n\n| Name | Value |\n| --- | --- |\n' +
|
||||||
|
Array.from({ length: 45 }, (_, i) => `| Row ${i + 1} | |`).join('\n') + '\n\nAfter.\n';
|
||||||
|
await page.evaluate(text => {
|
||||||
|
window.__TEST__.files.set('line-breaks.md', text);
|
||||||
|
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: ['line-breaks.md'] });
|
||||||
|
}, tallSource);
|
||||||
|
await quickOpen('line-breaks.md');
|
||||||
|
await table.waitFor();
|
||||||
|
for (const [r, c, key] of [[1, 0, 'Shift+Enter'], [20, 0, 'Shift+Enter'], [21, 0, 'Enter'], [20, 0, 'Shift+Enter'], [20, 1, 'Shift+Enter'], [0, 0, 'Shift+Enter']]) {
|
||||||
|
await at(r, c);
|
||||||
|
const before = await page.locator('.live-writer .cm-scroller').evaluate(el => el.scrollTop);
|
||||||
|
await page.keyboard.press(key);
|
||||||
|
await expectCell(r, c);
|
||||||
|
const after = await page.locator('.live-writer .cm-scroller').evaluate(el => el.scrollTop);
|
||||||
|
assert.ok(Math.abs(after - before) < 50, `${key} in row ${r}: scroll moved from ${before} to ${after}`);
|
||||||
|
await page.keyboard.type('Next line');
|
||||||
|
await expectCell(r, c);
|
||||||
|
assert.match(await edit.innerHTML(), /<br>Next line/);
|
||||||
|
}
|
||||||
|
await page.keyboard.press('Escape');
|
||||||
|
await page.keyboard.press('Control+s');
|
||||||
|
await page.waitForFunction(() => {
|
||||||
|
const source = window.__TEST__.files.get('line-breaks.md');
|
||||||
|
return source.includes('| Name<br>Next line | Value |') &&
|
||||||
|
source.includes('| Row 1<br>Next line | |') &&
|
||||||
|
source.includes('| Row 21<br>Next line | |') &&
|
||||||
|
/\| Row 20<br>Next line<br>Next line \| <br>Next line\s*\|/.test(source);
|
||||||
|
});
|
||||||
|
|
||||||
// A table at the document boundary still offers somewhere to type outside it.
|
// A table at the document boundary still offers somewhere to type outside it.
|
||||||
const loneTable = '| Name |\n| --- |\n| Value |';
|
const loneTable = '| Name |\n| --- |\n| Value |';
|
||||||
for (const [key, after] of [['ArrowLeft', false], ['ArrowUp', false], ['ArrowRight', true], ['ArrowDown', true]]) {
|
for (const [key, after] of [['ArrowLeft', false], ['ArrowUp', false], ['ArrowRight', true], ['ArrowDown', true]]) {
|
||||||
@@ -299,7 +325,6 @@ try {
|
|||||||
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: [name] });
|
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: [name] });
|
||||||
}, { name, text: loneTable });
|
}, { name, text: loneTable });
|
||||||
await quickOpen(name);
|
await quickOpen(name);
|
||||||
await page.getByRole('button', { name: 'Switch to writing layout (Ctrl E)', exact: true }).click();
|
|
||||||
await table.waitFor();
|
await table.waitFor();
|
||||||
await at(after ? 1 : 0, 0, after ? 'End' : 'Home');
|
await at(after ? 1 : 0, 0, after ? 'End' : 'Home');
|
||||||
await page.keyboard.press(key);
|
await page.keyboard.press(key);
|
||||||
@@ -317,7 +342,7 @@ try {
|
|||||||
await page.waitForFunction(({ name, expected }) => window.__TEST__.files.get(name) === expected, { name, expected });
|
await page.waitForFunction(({ name, expected }) => window.__TEST__.files.get(name) === expected, { name, expected });
|
||||||
}
|
}
|
||||||
assert.deepEqual(errors, []);
|
assert.deepEqual(errors, []);
|
||||||
console.log('PASS: arrows, caret positions, row wrapping, empty/formula/header cells, entry/exit in all directions, goal columns, document boundaries, text selection, word movement, multiline/wrapped text, save, undo/redo, Tab and Escape');
|
console.log('PASS: arrows, caret positions, row wrapping, empty/formula/header cells, entry/exit in all directions, goal columns, document boundaries, text selection, word movement, multiline/wrapped text, line breaks and scrolling in tall tables, save, undo/redo, Tab and Escape');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await page.screenshot({ path: '.audit/table-navigation-failure.png' });
|
await page.screenshot({ path: '.audit/table-navigation-failure.png' });
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@@ -3032,7 +3032,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "runestone"
|
name = "runestone"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.23.1",
|
"base64 0.23.1",
|
||||||
"dunce",
|
"dunce",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "runestone"
|
name = "runestone"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
description = "Writing workspace plus script editor"
|
description = "Writing workspace plus script editor"
|
||||||
authors = ["you"]
|
authors = ["you"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 567 B After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 536 B After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 777 B After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1020 B After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 848 B After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 21 KiB |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "RuneStone",
|
"productName": "RuneStone",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"identifier": "com.runestone.app",
|
"identifier": "com.runestone.app",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "pnpm dev",
|
"beforeDevCommand": "pnpm dev",
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
<html lang="en" data-theme="dark">
|
<html lang="en" data-theme="dark">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
<link rel="icon" type="image/png" sizes="64x64" href="%sveltekit.assets%/favicon.png" />
|
||||||
|
<link rel="icon" type="image/svg+xml" sizes="any" href="%sveltekit.assets%/runestone.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<title>RuneStone</title>
|
<title>RuneStone</title>
|
||||||
%sveltekit.head%
|
%sveltekit.head%
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
import { untrack } from "svelte";
|
import { untrack } from "svelte";
|
||||||
import { Compartment, EditorState } from "@codemirror/state";
|
import { Compartment, EditorState } from "@codemirror/state";
|
||||||
import { EditorView, drawSelection, keymap } from "@codemirror/view";
|
import { EditorView, drawSelection, keymap } from "@codemirror/view";
|
||||||
import { defaultKeymap, history, historyField, historyKeymap, isolateHistory } from "@codemirror/commands";
|
import { defaultKeymap, history, historyField, historyKeymap, indentWithTab, isolateHistory } from "@codemirror/commands";
|
||||||
import { markdown, markdownLanguage } from "@codemirror/lang-markdown";
|
import { markdown, markdownLanguage } from "@codemirror/lang-markdown";
|
||||||
|
import { noteFormats } from "./noteFormats";
|
||||||
import { searchKeymap } from "@codemirror/search";
|
import { searchKeymap } from "@codemirror/search";
|
||||||
import { writerSearch } from "./writerSearch";
|
import { writerSearch } from "./writerSearch";
|
||||||
import type { OpenBuffer } from "$lib/workspace/types";
|
import type { OpenBuffer } from "$lib/workspace/types";
|
||||||
@@ -135,26 +136,7 @@
|
|||||||
model.pushStackElement();
|
model.pushStackElement();
|
||||||
const extensions = [
|
const extensions = [
|
||||||
EditorState.lineSeparator.of(model.getEOL()),
|
EditorState.lineSeparator.of(model.getEOL()),
|
||||||
markdown({ base: markdownLanguage, extensions: [{
|
markdown({ base: markdownLanguage, extensions: [noteFormats] }),
|
||||||
defineNodes: ["NoteHighlight", "NoteMath", "NoteComment", "NoteFormatMark"],
|
|
||||||
parseInline: [{ name: "NoteFormats", before: "Emphasis", parse(context, next, position) {
|
|
||||||
const marker = next === 61 ? "==" : next === 37 ? "%%" : next === 36 ? "$" : "";
|
|
||||||
if (!marker || context.slice(position, position + marker.length) !== marker) return -1;
|
|
||||||
if (marker === "$" && (context.char(position + 1) === 36 || context.char(position - 1) === 36)) return -1;
|
|
||||||
let end = position + marker.length;
|
|
||||||
for (; end < context.end; end++) {
|
|
||||||
if (context.char(end) === 92) { end++; continue; }
|
|
||||||
if (context.slice(end, end + marker.length) === marker) break;
|
|
||||||
}
|
|
||||||
if (end >= context.end || end === position + marker.length) return -1;
|
|
||||||
const kind = marker === "==" ? "NoteHighlight" : marker === "$" ? "NoteMath" : "NoteComment";
|
|
||||||
const children = marker === "==" ? context.parser.parseInline(context.slice(position + marker.length, end), position + marker.length) : [];
|
|
||||||
return context.addElement(context.elt(kind, position, end + marker.length, [
|
|
||||||
context.elt("NoteFormatMark", position, position + marker.length), ...children,
|
|
||||||
context.elt("NoteFormatMark", end, end + marker.length),
|
|
||||||
]));
|
|
||||||
} }],
|
|
||||||
}] }),
|
|
||||||
// Rich cell serialization can change delimiters away from the caret.
|
// Rich cell serialization can change delimiters away from the caret.
|
||||||
// Keep a burst of typing together even when those source edits aren't adjacent.
|
// Keep a burst of typing together even when those source edits aren't adjacent.
|
||||||
history({ joinToEvent: (transaction, adjacent) => adjacent || transaction.isUserEvent("input.type.table") }), drawSelection(),
|
history({ joinToEvent: (transaction, adjacent) => adjacent || transaction.isUserEvent("input.type.table") }), drawSelection(),
|
||||||
@@ -164,7 +146,7 @@
|
|||||||
keymap.of([{ key: "Escape", run: view => {
|
keymap.of([{ key: "Escape", run: view => {
|
||||||
if (!view.state.field(imageSource)) return false;
|
if (!view.state.field(imageSource)) return false;
|
||||||
view.dispatch({ effects: editImageSource.of(null) }); return true;
|
view.dispatch({ effects: editImageSource.of(null) }); return true;
|
||||||
} }, ...searchKeymap, ...historyKeymap, ...defaultKeymap]), EditorView.lineWrapping,
|
} }, indentWithTab, ...searchKeymap, ...historyKeymap, ...defaultKeymap]), EditorView.lineWrapping,
|
||||||
liveMarkdown(urls, untrack(() => tableActions), {
|
liveMarkdown(urls, untrack(() => tableActions), {
|
||||||
open: image => onOpenLink?.(image.dataset.mdKind === "wiki" ? "wiki" : "md", image.dataset.mdSrc || ""),
|
open: image => onOpenLink?.(image.dataset.mdKind === "wiki" ? "wiki" : "md", image.dataset.mdSrc || ""),
|
||||||
reveal: async image => {
|
reveal: async image => {
|
||||||
|
|||||||
@@ -54,9 +54,17 @@ class Checkbox extends WidgetType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Preview extends WidgetType {
|
class Preview extends WidgetType {
|
||||||
constructor(readonly html: string, readonly source: string, readonly actions: TableContextActions, readonly sourceVisible = false) { super(); }
|
constructor(readonly html: string, readonly source: string, readonly actions: TableContextActions, readonly sourceVisible = false, readonly height = { value: -1 }) { super(); }
|
||||||
|
get estimatedHeight() { return this.height.value; }
|
||||||
eq(other: Preview) { return other.html === this.html && other.source === this.source && other.sourceVisible === this.sourceVisible; }
|
eq(other: Preview) { return other.html === this.html && other.source === this.source && other.sourceVisible === this.sourceVisible; }
|
||||||
updateDOM(dom: HTMLElement) { return tableEditors.get(dom)?.source === this.source; }
|
measure(dom: HTMLElement, view: EditorView) {
|
||||||
|
view.requestMeasure({ key: this.height, read: () => dom.offsetHeight, write: height => { this.height.value = height; } });
|
||||||
|
}
|
||||||
|
updateDOM(dom: HTMLElement, view: EditorView) {
|
||||||
|
if (tableEditors.get(dom)?.source !== this.source) return false;
|
||||||
|
this.measure(dom, view);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
destroy(dom: HTMLElement) { tableEditors.get(dom)?.destroy(); imageCleanups.get(dom)?.(); }
|
destroy(dom: HTMLElement) { tableEditors.get(dom)?.destroy(); imageCleanups.get(dom)?.(); }
|
||||||
toDOM(view: EditorView) {
|
toDOM(view: EditorView) {
|
||||||
const dom = document.createElement("div");
|
const dom = document.createElement("div");
|
||||||
@@ -64,6 +72,7 @@ class Preview extends WidgetType {
|
|||||||
dom.innerHTML = this.html;
|
dom.innerHTML = this.html;
|
||||||
tableControls(dom, view, this.source, this.actions);
|
tableControls(dom, view, this.source, this.actions);
|
||||||
imageCleanups.set(dom, imageControls(dom, {}, () => { if (dom.isConnected) view.requestMeasure(); }));
|
imageCleanups.set(dom, imageControls(dom, {}, () => { if (dom.isConnected) view.requestMeasure(); }));
|
||||||
|
this.measure(dom, view);
|
||||||
dom.querySelectorAll("button.rs-fence-copy").forEach(button => button.remove());
|
dom.querySelectorAll("button.rs-fence-copy").forEach(button => button.remove());
|
||||||
dom.addEventListener("mousedown", event => {
|
dom.addEventListener("mousedown", event => {
|
||||||
if (event.target instanceof Element && event.target.closest(".writer-table, .table-footer")) return;
|
if (event.target instanceof Element && event.target.closest(".writer-table, .table-footer")) return;
|
||||||
@@ -85,7 +94,7 @@ class Preview extends WidgetType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function liveMarkdown(urls: Map<string, string>, actions: TableContextActions = {}, images: ImageContext = {}) {
|
export function liveMarkdown(urls: Map<string, string>, actions: TableContextActions = {}, images: ImageContext = {}) {
|
||||||
function build(state: EditorState): DecorationSet {
|
function build(state: EditorState, previous?: DecorationSet): DecorationSet {
|
||||||
const ranges: Range<Decoration>[] = [];
|
const ranges: Range<Decoration>[] = [];
|
||||||
const active = state.selection.ranges.map(range => ({ from: state.doc.lineAt(range.from).from, to: state.doc.lineAt(range.to).to }));
|
const active = state.selection.ranges.map(range => ({ from: state.doc.lineAt(range.from).from, to: state.doc.lineAt(range.to).to }));
|
||||||
const selected = (from: number, to: number) => active.some(range => range.from <= to && range.to >= from);
|
const selected = (from: number, to: number) => active.some(range => range.from <= to && range.to >= from);
|
||||||
@@ -123,7 +132,13 @@ export function liveMarkdown(urls: Map<string, string>, actions: TableContextAct
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
hiddenBlocks.push({ from: section.start, to: end });
|
hiddenBlocks.push({ from: section.start, to: end });
|
||||||
ranges.push(Decoration.replace({ widget: new Preview(section.html, source.slice(section.start, end), actions), block: true, atomic: true }).range(section.start, end));
|
// Keep the table height between edits and the next layout pass. A one-line
|
||||||
|
// estimate can move the scroll anchor below a tall table on a second update.
|
||||||
|
let height: { value: number } | undefined;
|
||||||
|
if (isTable) previous?.between(section.start, end, (from, to, decoration) => {
|
||||||
|
if (from === section.start && to === end && decoration.spec.widget instanceof Preview) height = decoration.spec.widget.height;
|
||||||
|
});
|
||||||
|
ranges.push(Decoration.replace({ widget: new Preview(section.html, source.slice(section.start, end), actions, false, height), block: true, atomic: true }).range(section.start, end));
|
||||||
}
|
}
|
||||||
const hidden = (from: number, to: number) => hiddenBlocks.some(block => block.from <= from && block.to >= to);
|
const hidden = (from: number, to: number) => hiddenBlocks.some(block => block.from <= from && block.to >= to);
|
||||||
const replace = (from: number, to: number) => { if (to > from) ranges.push(Decoration.replace({ atomic: true }).range(from, to)); };
|
const replace = (from: number, to: number) => { if (to > from) ranges.push(Decoration.replace({ atomic: true }).range(from, to)); };
|
||||||
@@ -188,7 +203,7 @@ export function liveMarkdown(urls: Map<string, string>, actions: TableContextAct
|
|||||||
return [imageSource, StateField.define<DecorationSet>({
|
return [imageSource, StateField.define<DecorationSet>({
|
||||||
create: build,
|
create: build,
|
||||||
update(value, transaction) {
|
update(value, transaction) {
|
||||||
return transaction.docChanged || transaction.selection || transaction.effects.some(effect => effect.is(refreshImages) || effect.is(editImageSource)) ? build(transaction.state) : value;
|
return transaction.docChanged || transaction.selection || transaction.effects.some(effect => effect.is(refreshImages) || effect.is(editImageSource)) ? build(transaction.state, value.map(transaction.changes)) : value;
|
||||||
},
|
},
|
||||||
provide: field => [EditorView.decorations.from(field), EditorView.atomicRanges.of(view => view.state.field(field).update({
|
provide: field => [EditorView.decorations.from(field), EditorView.atomicRanges.of(view => view.state.field(field).update({
|
||||||
filter: (_from, _to, decoration) => decoration.spec.atomic === true,
|
filter: (_from, _to, decoration) => decoration.spec.atomic === true,
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import type { markdown } from "@codemirror/lang-markdown";
|
||||||
|
import { inlineMathEnd } from "../workspace/inlineMath.ts";
|
||||||
|
|
||||||
|
export const noteFormats: NonNullable<NonNullable<Parameters<typeof markdown>[0]>["extensions"]> = {
|
||||||
|
defineNodes: ["NoteHighlight", "NoteMath", "NoteComment", "NoteFormatMark"],
|
||||||
|
parseInline: [{ name: "NoteFormats", before: "Emphasis", parse(context, next, position) {
|
||||||
|
const marker = next === 61 ? "==" : next === 37 ? "%%" : next === 36 ? "$" : "";
|
||||||
|
if (!marker || context.slice(position, position + marker.length) !== marker) return -1;
|
||||||
|
let end = position + marker.length;
|
||||||
|
if (marker === "$") {
|
||||||
|
if (context.char(position - 1) === 36) return -1;
|
||||||
|
const offset = inlineMathEnd(context.slice(position, context.end));
|
||||||
|
if (offset < 0) return -1;
|
||||||
|
end = position + offset;
|
||||||
|
} else {
|
||||||
|
for (; end < context.end; end++) {
|
||||||
|
if (context.char(end) === 92) { end++; continue; }
|
||||||
|
if (context.slice(end, end + marker.length) === marker) break;
|
||||||
|
}
|
||||||
|
if (end >= context.end || end === position + marker.length) return -1;
|
||||||
|
}
|
||||||
|
const kind = marker === "==" ? "NoteHighlight" : marker === "$" ? "NoteMath" : "NoteComment";
|
||||||
|
const children = marker === "==" ? context.parser.parseInline(context.slice(position + marker.length, end), position + marker.length) : [];
|
||||||
|
return context.addElement(context.elt(kind, position, end + marker.length, [
|
||||||
|
context.elt("NoteFormatMark", position, position + marker.length), ...children,
|
||||||
|
context.elt("NoteFormatMark", end, end + marker.length),
|
||||||
|
]));
|
||||||
|
} }],
|
||||||
|
};
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
export function inlineMathEnd(source: string, start = 0, limit = source.length): number {
|
||||||
|
if (source[start] !== "$" || source[start - 1] === "$" || source[start + 1] === "$" || /\s/.test(source[start + 1] || "")) return -1;
|
||||||
|
for (let end = start + 1; end < limit; end++) {
|
||||||
|
if (source[end] === "\n" || source[end] === "\r") return -1;
|
||||||
|
if (source[end] === "\\") {
|
||||||
|
if (source[end + 1] === "\n" || source[end + 1] === "\r") return -1;
|
||||||
|
end++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (source[end] !== "$") continue;
|
||||||
|
if (end === start + 1 || /\s/.test(source[end - 1]) || source[end + 1] === "$" || /^(?:\d|\.\d)/.test(source.slice(end + 1, end + 3))) return -1;
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import MarkdownIt from "markdown-it";
|
import MarkdownIt from "markdown-it";
|
||||||
import type { Token } from "markdown-it";
|
import type { Token } from "markdown-it";
|
||||||
|
import { inlineMathEnd } from "./inlineMath.ts";
|
||||||
import { evaluateTableFormulas, formulaErrors, type FormulaResult } from "../editor/tableFormulas.ts";
|
import { evaluateTableFormulas, formulaErrors, type FormulaResult } from "../editor/tableFormulas.ts";
|
||||||
|
|
||||||
const markdown = new MarkdownIt({ html: false, linkify: true, breaks: false });
|
const markdown = new MarkdownIt({ html: false, linkify: true, breaks: false });
|
||||||
@@ -8,12 +9,17 @@ export const escapeHtml = markdown.utils.escapeHtml;
|
|||||||
// Inline note formats also round-trip through the table cell editor.
|
// Inline note formats also round-trip through the table cell editor.
|
||||||
markdown.inline.ruler.before("emphasis", "note_formats", (state, silent) => {
|
markdown.inline.ruler.before("emphasis", "note_formats", (state, silent) => {
|
||||||
const marker = ["==", "%%", "$"].find(value => state.src.startsWith(value, state.pos));
|
const marker = ["==", "%%", "$"].find(value => state.src.startsWith(value, state.pos));
|
||||||
if (!marker || (marker === "$" && state.src.startsWith("$$", state.pos))) return false;
|
if (!marker) return false;
|
||||||
let end = state.pos + marker.length;
|
let end = state.pos + marker.length;
|
||||||
|
if (marker === "$") {
|
||||||
|
end = inlineMathEnd(state.src, state.pos, state.posMax);
|
||||||
|
if (end < 0) return false;
|
||||||
|
} else {
|
||||||
for (; end < state.posMax; end++) {
|
for (; end < state.posMax; end++) {
|
||||||
if (state.src[end] === "\\") { end++; continue; }
|
if (state.src[end] === "\\") { end++; continue; }
|
||||||
if (state.src.startsWith(marker, end)) break;
|
if (state.src.startsWith(marker, end)) break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (end >= state.posMax || end === state.pos + marker.length) return false;
|
if (end >= state.posMax || end === state.pos + marker.length) return false;
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
const kind = marker === "==" ? "highlight" : marker === "$" ? "math" : "comment";
|
const kind = marker === "==" ? "highlight" : marker === "$" ? "math" : "comment";
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 2.4 KiB |
@@ -0,0 +1,23 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="640" height="640" viewBox="0 0 640 640" role="img" aria-labelledby="title desc">
|
||||||
|
<title id="title">RuneStone</title>
|
||||||
|
<desc id="desc">A rounded gray stone with offset side curves and a blue carved R.</desc>
|
||||||
|
<defs>
|
||||||
|
<path id="stone-outline" d="M 294 54 C 315 51 334 53 350 65 C 394 95 423 162 440 237 C 453 296 458 349 461 393 C 463 416 483 423 489 445 C 498 472 481 494 466 521 C 443 564 401 592 347 592 L 272 592 C 224 592 194 562 177 525 C 164 497 159 464 154 435 C 152 418 142 402 143 382 C 143 360 157 344 162 321 C 178 250 195 187 225 129 C 245 92 266 59 294 54 Z"/>
|
||||||
|
<clipPath id="stone-clip"><use href="#stone-outline"/></clipPath>
|
||||||
|
<path id="rune-line" d="M 280 480 V 192 L 376 280 L 288 352 L 416 476"/>
|
||||||
|
</defs>
|
||||||
|
<g id="stone">
|
||||||
|
<use id="stone-deep-shadow" href="#stone-outline" fill="#24282D"/>
|
||||||
|
<g clip-path="url(#stone-clip)">
|
||||||
|
<path id="stone-shadow" fill="#40464C" d="M 278 50 C 312 44 336 53 350 72 C 391 111 414 175 431 247 C 443 305 446 361 450 404 C 453 426 472 438 478 458 C 482 482 462 506 448 528 C 421 563 381 578 332 578 L 274 578 C 231 576 205 550 188 515 C 174 487 169 455 163 427 C 160 408 150 393 153 374 C 156 355 167 338 172 317 C 191 234 211 175 238 121 Z"/>
|
||||||
|
<path id="stone-base" fill="#5A6268" d="M 272 52 L 329 53 C 348 73 358 98 371 120 C 396 161 416 209 424 259 C 429 281 422 298 418 314 C 413 337 420 367 424 392 C 427 414 439 435 441 455 C 443 478 424 495 408 513 C 384 541 351 559 310 560 L 279 560 C 244 557 217 538 199 509 C 183 483 173 449 168 422 C 163 406 151 391 151 375 C 152 358 164 341 168 320 C 184 251 205 178 230 128 Z"/>
|
||||||
|
<path id="stone-light" fill="#788087" d="M 271 54 L 318 53 C 337 68 346 87 355 106 C 364 125 369 144 366 160 C 346 169 323 163 305 181 C 283 204 266 234 257 269 C 246 308 232 331 224 358 C 217 382 209 407 193 436 C 175 422 161 402 151 386 C 147 377 151 366 155 355 C 175 285 189 221 213 165 C 228 125 249 82 271 54 Z"/>
|
||||||
|
<path id="stone-highlight" fill="#A2A7AA" d="M 273 56 C 293 52 314 53 332 58 L 338 74 C 324 84 308 83 299 99 C 282 124 268 151 252 173 C 235 199 229 227 215 252 C 203 277 193 299 185 322 C 179 337 166 346 159 353 C 177 281 192 221 216 165 C 231 127 251 82 273 56 Z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g id="rune" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<use id="rune-shadow" href="#rune-line" stroke="#31546A" stroke-width="32"/>
|
||||||
|
<use id="rune-base" href="#rune-line" transform="translate(4 4)" stroke="#5688A3" stroke-width="20"/>
|
||||||
|
<use id="rune-highlight" href="#rune-line" transform="translate(8 8)" stroke="#8AB8CC" stroke-width="8"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.6 KiB |