diff --git a/docs/product-scope.md b/docs/product-scope.md
index 48d1bd8..82b605f 100644
--- a/docs/product-scope.md
+++ b/docs/product-scope.md
@@ -5,7 +5,7 @@
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.
-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
@@ -47,22 +47,41 @@ The planned design keeps the core active and adds optional features through firs
## 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:
+- 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.
- Sort. Per-folder order, pin, and hide. Flexplorer is a reference for behavior, not a source of code.
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.
- Canvas. Store `.canvas` files in JSON Canvas 1.0.
- 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
- 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
-- A plugin marketplace or third-party loader
+- A plugin marketplace
- Obsidian or VS Code plugin compatibility
- Cloud sync, live collaboration, or mobile
- 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.
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.
diff --git a/docs/roadmap.md b/docs/roadmap.md
index f09092e..1ca9db1 100644
--- a/docs/roadmap.md
+++ b/docs/roadmap.md
@@ -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.
-Plugin support is pending. A first-party plugin foundation would let users choose
-optional tools for version history, organization, planning, and visual exploration.
+Plugin support is pending. Separately packaged plugins would let users choose tools for planning, tabletop play, and other workflows.
+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.
## Why this order?
diff --git a/output/brand/runestone-vector-v1.svg b/output/brand/runestone-vector-v1.svg
new file mode 100644
index 0000000..65910d3
--- /dev/null
+++ b/output/brand/runestone-vector-v1.svg
@@ -0,0 +1,23 @@
+
diff --git a/output/brand/vector-v1-preview/640x640.png b/output/brand/vector-v1-preview/640x640.png
new file mode 100644
index 0000000..f3f755c
Binary files /dev/null and b/output/brand/vector-v1-preview/640x640.png differ
diff --git a/output/imagegen/runestone-pixel-v1-640.png b/output/imagegen/runestone-pixel-v1-640.png
new file mode 100644
index 0000000..c938710
Binary files /dev/null and b/output/imagegen/runestone-pixel-v1-640.png differ
diff --git a/output/imagegen/runestone-pixel-v1-80.png b/output/imagegen/runestone-pixel-v1-80.png
new file mode 100644
index 0000000..6d5168f
Binary files /dev/null and b/output/imagegen/runestone-pixel-v1-80.png differ
diff --git a/output/imagegen/runestone-pixel-v2-640.png b/output/imagegen/runestone-pixel-v2-640.png
new file mode 100644
index 0000000..bb2f044
Binary files /dev/null and b/output/imagegen/runestone-pixel-v2-640.png differ
diff --git a/output/imagegen/runestone-pixel-v2-80.png b/output/imagegen/runestone-pixel-v2-80.png
new file mode 100644
index 0000000..cc30652
Binary files /dev/null and b/output/imagegen/runestone-pixel-v2-80.png differ
diff --git a/output/imagegen/runestone-pixel-v3-640.png b/output/imagegen/runestone-pixel-v3-640.png
new file mode 100644
index 0000000..3d5bda8
Binary files /dev/null and b/output/imagegen/runestone-pixel-v3-640.png differ
diff --git a/output/imagegen/runestone-pixel-v3-80.png b/output/imagegen/runestone-pixel-v3-80.png
new file mode 100644
index 0000000..e3decd3
Binary files /dev/null and b/output/imagegen/runestone-pixel-v3-80.png differ
diff --git a/output/imagegen/runestone-pixel-v4-640.png b/output/imagegen/runestone-pixel-v4-640.png
new file mode 100644
index 0000000..f83cacd
Binary files /dev/null and b/output/imagegen/runestone-pixel-v4-640.png differ
diff --git a/output/imagegen/runestone-pixel-v4-80.png b/output/imagegen/runestone-pixel-v4-80.png
new file mode 100644
index 0000000..a5816a8
Binary files /dev/null and b/output/imagegen/runestone-pixel-v4-80.png differ
diff --git a/output/imagegen/runestone-pixel-v5-640.png b/output/imagegen/runestone-pixel-v5-640.png
new file mode 100644
index 0000000..d614be9
Binary files /dev/null and b/output/imagegen/runestone-pixel-v5-640.png differ
diff --git a/output/imagegen/runestone-pixel-v5-80.png b/output/imagegen/runestone-pixel-v5-80.png
new file mode 100644
index 0000000..7a1daaa
Binary files /dev/null and b/output/imagegen/runestone-pixel-v5-80.png differ
diff --git a/package.json b/package.json
index 0935cbc..438f7ae 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "runestone",
- "version": "0.1.2",
+ "version": "0.1.3",
"description": "Desktop editor for a local workspace",
"type": "module",
"scripts": {
diff --git a/scripts/inlineMath.spec.ts b/scripts/inlineMath.spec.ts
new file mode 100644
index 0000000..100f500
--- /dev/null
+++ b/scripts/inlineMath.spec.ts
@@ -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, "
")} |`), /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), /highlight<\/strong><\/mark>/);
+ assert.match(render(source), /md-inline-comment/);
+});
diff --git a/scripts/tableNavigation.smoke.mjs b/scripts/tableNavigation.smoke.mjs
index 79708e1..55ff3c1 100644
--- a/scripts/tableNavigation.smoke.mjs
+++ b/scripts/tableNavigation.smoke.mjs
@@ -74,10 +74,7 @@ async function quickOpen(name) {
await page.keyboard.press("Control+p");
await page.getByRole("textbox", { name: "Find a file" }).fill(name);
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.getByRole("button", { name: "Switch to IDE layout (Ctrl E)", exact: true }).click();
- }
- await page.locator(".monaco-editor textarea").waitFor();
+ await page.locator('.live-writer .cm-content').waitFor();
}
const source = '# Navigation\n\nBefore.\n\n| Name | Value | Formula |\n| --- | --- | --- |\n| Alpha | 12 | =B2*2 |\n| Beta | | tail |\n| Two
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'] });
}, source);
await quickOpen('navigation.md');
- await page.getByRole('button', { name: 'Switch to writing layout (Ctrl E)', exact: true }).click();
await table.waitFor();
// Reproduce the reported right-arrow escape, including formula destinations.
@@ -290,6 +286,36 @@ try {
assert.equal(await edit.count(), 0);
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(), /
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
Next line | Value |') &&
+ source.includes('| Row 1
Next line | |') &&
+ source.includes('| Row 21
Next line | |') &&
+ /\| Row 20
Next line
Next line \|
Next line\s*\|/.test(source);
+ });
+
// A table at the document boundary still offers somewhere to type outside it.
const loneTable = '| Name |\n| --- |\n| Value |';
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] });
}, { name, text: loneTable });
await quickOpen(name);
- await page.getByRole('button', { name: 'Switch to writing layout (Ctrl E)', exact: true }).click();
await table.waitFor();
await at(after ? 1 : 0, 0, after ? 'End' : 'Home');
await page.keyboard.press(key);
@@ -317,7 +342,7 @@ try {
await page.waitForFunction(({ name, expected }) => window.__TEST__.files.get(name) === expected, { name, expected });
}
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) {
await page.screenshot({ path: '.audit/table-navigation-failure.png' });
throw error;
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index d601cbd..c4cb1c5 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -3032,7 +3032,7 @@ dependencies = [
[[package]]
name = "runestone"
-version = "0.1.2"
+version = "0.1.3"
dependencies = [
"base64 0.23.1",
"dunce",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 7ed94b5..31d8a11 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "runestone"
-version = "0.1.2"
+version = "0.1.3"
description = "Writing workspace plus script editor"
authors = ["you"]
edition = "2021"
diff --git a/src-tauri/icons/128x128.png b/src-tauri/icons/128x128.png
index 24045aa..e736384 100644
Binary files a/src-tauri/icons/128x128.png and b/src-tauri/icons/128x128.png differ
diff --git a/src-tauri/icons/128x128@2x.png b/src-tauri/icons/128x128@2x.png
index 4a537e1..1054319 100644
Binary files a/src-tauri/icons/128x128@2x.png and b/src-tauri/icons/128x128@2x.png differ
diff --git a/src-tauri/icons/32x32.png b/src-tauri/icons/32x32.png
index 9c0ad67..26b4d86 100644
Binary files a/src-tauri/icons/32x32.png and b/src-tauri/icons/32x32.png differ
diff --git a/src-tauri/icons/Square107x107Logo.png b/src-tauri/icons/Square107x107Logo.png
index 8266f1b..a6a5413 100644
Binary files a/src-tauri/icons/Square107x107Logo.png and b/src-tauri/icons/Square107x107Logo.png differ
diff --git a/src-tauri/icons/Square142x142Logo.png b/src-tauri/icons/Square142x142Logo.png
index 6037658..d1e477b 100644
Binary files a/src-tauri/icons/Square142x142Logo.png and b/src-tauri/icons/Square142x142Logo.png differ
diff --git a/src-tauri/icons/Square150x150Logo.png b/src-tauri/icons/Square150x150Logo.png
index 06102e1..e5633fd 100644
Binary files a/src-tauri/icons/Square150x150Logo.png and b/src-tauri/icons/Square150x150Logo.png differ
diff --git a/src-tauri/icons/Square284x284Logo.png b/src-tauri/icons/Square284x284Logo.png
index 37bec18..32c7103 100644
Binary files a/src-tauri/icons/Square284x284Logo.png and b/src-tauri/icons/Square284x284Logo.png differ
diff --git a/src-tauri/icons/Square30x30Logo.png b/src-tauri/icons/Square30x30Logo.png
index bcfb4b7..ff175b6 100644
Binary files a/src-tauri/icons/Square30x30Logo.png and b/src-tauri/icons/Square30x30Logo.png differ
diff --git a/src-tauri/icons/Square310x310Logo.png b/src-tauri/icons/Square310x310Logo.png
index 45eabe5..16688e0 100644
Binary files a/src-tauri/icons/Square310x310Logo.png and b/src-tauri/icons/Square310x310Logo.png differ
diff --git a/src-tauri/icons/Square44x44Logo.png b/src-tauri/icons/Square44x44Logo.png
index d10c199..18a5b2e 100644
Binary files a/src-tauri/icons/Square44x44Logo.png and b/src-tauri/icons/Square44x44Logo.png differ
diff --git a/src-tauri/icons/Square71x71Logo.png b/src-tauri/icons/Square71x71Logo.png
index b17590f..d2e9478 100644
Binary files a/src-tauri/icons/Square71x71Logo.png and b/src-tauri/icons/Square71x71Logo.png differ
diff --git a/src-tauri/icons/Square89x89Logo.png b/src-tauri/icons/Square89x89Logo.png
index fadd836..c594128 100644
Binary files a/src-tauri/icons/Square89x89Logo.png and b/src-tauri/icons/Square89x89Logo.png differ
diff --git a/src-tauri/icons/StoreLogo.png b/src-tauri/icons/StoreLogo.png
index 5ac2347..336ae3a 100644
Binary files a/src-tauri/icons/StoreLogo.png and b/src-tauri/icons/StoreLogo.png differ
diff --git a/src-tauri/icons/icon.icns b/src-tauri/icons/icon.icns
index 12a5bce..e0655fb 100644
Binary files a/src-tauri/icons/icon.icns and b/src-tauri/icons/icon.icns differ
diff --git a/src-tauri/icons/icon.ico b/src-tauri/icons/icon.ico
index 06c23c8..8234c1c 100644
Binary files a/src-tauri/icons/icon.ico and b/src-tauri/icons/icon.ico differ
diff --git a/src-tauri/icons/icon.png b/src-tauri/icons/icon.png
index 8b1c465..c247659 100644
Binary files a/src-tauri/icons/icon.png and b/src-tauri/icons/icon.png differ
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index adb5f94..c372aa2 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "RuneStone",
- "version": "0.1.2",
+ "version": "0.1.3",
"identifier": "com.runestone.app",
"build": {
"beforeDevCommand": "pnpm dev",
diff --git a/src/app.html b/src/app.html
index ecd6c5a..072a0e9 100644
--- a/src/app.html
+++ b/src/app.html
@@ -2,7 +2,8 @@
-
+
+
RuneStone
%sveltekit.head%
diff --git a/src/lib/editor/LiveWriter.svelte b/src/lib/editor/LiveWriter.svelte
index 7e8f597..fca0808 100644
--- a/src/lib/editor/LiveWriter.svelte
+++ b/src/lib/editor/LiveWriter.svelte
@@ -2,8 +2,9 @@
import { untrack } from "svelte";
import { Compartment, EditorState } from "@codemirror/state";
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 { noteFormats } from "./noteFormats";
import { searchKeymap } from "@codemirror/search";
import { writerSearch } from "./writerSearch";
import type { OpenBuffer } from "$lib/workspace/types";
@@ -135,26 +136,7 @@
model.pushStackElement();
const extensions = [
EditorState.lineSeparator.of(model.getEOL()),
- markdown({ base: markdownLanguage, 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;
- 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),
- ]));
- } }],
- }] }),
+ markdown({ base: markdownLanguage, extensions: [noteFormats] }),
// Rich cell serialization can change delimiters away from the caret.
// 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(),
@@ -164,7 +146,7 @@
keymap.of([{ key: "Escape", run: view => {
if (!view.state.field(imageSource)) return false;
view.dispatch({ effects: editImageSource.of(null) }); return true;
- } }, ...searchKeymap, ...historyKeymap, ...defaultKeymap]), EditorView.lineWrapping,
+ } }, indentWithTab, ...searchKeymap, ...historyKeymap, ...defaultKeymap]), EditorView.lineWrapping,
liveMarkdown(urls, untrack(() => tableActions), {
open: image => onOpenLink?.(image.dataset.mdKind === "wiki" ? "wiki" : "md", image.dataset.mdSrc || ""),
reveal: async image => {
diff --git a/src/lib/editor/liveMarkdown.ts b/src/lib/editor/liveMarkdown.ts
index 00ffe71..9723719 100644
--- a/src/lib/editor/liveMarkdown.ts
+++ b/src/lib/editor/liveMarkdown.ts
@@ -54,9 +54,17 @@ class Checkbox 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; }
- 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)?.(); }
toDOM(view: EditorView) {
const dom = document.createElement("div");
@@ -64,6 +72,7 @@ class Preview extends WidgetType {
dom.innerHTML = this.html;
tableControls(dom, view, this.source, this.actions);
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.addEventListener("mousedown", event => {
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, actions: TableContextActions = {}, images: ImageContext = {}) {
- function build(state: EditorState): DecorationSet {
+ function build(state: EditorState, previous?: DecorationSet): DecorationSet {
const ranges: Range[] = [];
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);
@@ -123,7 +132,13 @@ export function liveMarkdown(urls: Map, actions: TableContextAct
continue;
}
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 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, actions: TableContextAct
return [imageSource, StateField.define({
create: build,
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({
filter: (_from, _to, decoration) => decoration.spec.atomic === true,
diff --git a/src/lib/editor/noteFormats.ts b/src/lib/editor/noteFormats.ts
new file mode 100644
index 0000000..a7e9d3f
--- /dev/null
+++ b/src/lib/editor/noteFormats.ts
@@ -0,0 +1,29 @@
+import type { markdown } from "@codemirror/lang-markdown";
+import { inlineMathEnd } from "../workspace/inlineMath.ts";
+
+export const noteFormats: NonNullable[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),
+ ]));
+ } }],
+};
diff --git a/src/lib/workspace/inlineMath.ts b/src/lib/workspace/inlineMath.ts
new file mode 100644
index 0000000..75d7d52
--- /dev/null
+++ b/src/lib/workspace/inlineMath.ts
@@ -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;
+}
diff --git a/src/lib/workspace/noteHtml.ts b/src/lib/workspace/noteHtml.ts
index 761fa5c..b376bbd 100644
--- a/src/lib/workspace/noteHtml.ts
+++ b/src/lib/workspace/noteHtml.ts
@@ -1,5 +1,6 @@
import MarkdownIt from "markdown-it";
import type { Token } from "markdown-it";
+import { inlineMathEnd } from "./inlineMath.ts";
import { evaluateTableFormulas, formulaErrors, type FormulaResult } from "../editor/tableFormulas.ts";
const markdown = new MarkdownIt({ html: false, linkify: true, breaks: false });
@@ -8,11 +9,16 @@ export const escapeHtml = markdown.utils.escapeHtml;
// Inline note formats also round-trip through the table cell editor.
markdown.inline.ruler.before("emphasis", "note_formats", (state, silent) => {
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;
- for (; end < state.posMax; end++) {
- if (state.src[end] === "\\") { end++; continue; }
- if (state.src.startsWith(marker, end)) break;
+ if (marker === "$") {
+ end = inlineMathEnd(state.src, state.pos, state.posMax);
+ if (end < 0) return false;
+ } else {
+ for (; end < state.posMax; end++) {
+ if (state.src[end] === "\\") { end++; continue; }
+ if (state.src.startsWith(marker, end)) break;
+ }
}
if (end >= state.posMax || end === state.pos + marker.length) return false;
if (!silent) {
diff --git a/static/favicon.png b/static/favicon.png
index 825b9e6..5fedaf5 100644
Binary files a/static/favicon.png and b/static/favicon.png differ
diff --git a/static/runestone.svg b/static/runestone.svg
new file mode 100644
index 0000000..65910d3
--- /dev/null
+++ b/static/runestone.svg
@@ -0,0 +1,23 @@
+