Fix the table cell arrow race and remove the TipTap Writer
Phase 4a. The ProseMirror focus handler starts a 20 ms timer that writes the ProseMirror selection back to the DOM. Under load, the timer ran after a native arrow move and before ProseMirror read the selectionchange event, so one move was lost. The cell editor now moves the DOM selection with Selection.modify and reads the result in the same key event. This covers plain and Shift arrows and word moves. Other shortcuts stay with the browser. - Workbench.svelte no longer filters access events. Rust already drops them. - Delete the unused TipTap Writer: WriterHost.svelte, writerMenu.ts, writerMarks.ts, headingMarks.ts, and their two unit tests. - Remove the 8 TipTap packages that only the Writer used, and its entry in docs/menu-surfaces.json. With a 4x CPU slowdown, 11 of 60 runs failed before the fix and 0 of 120 after it. pnpm check, pnpm test, and the smoke suite pass.
This commit is contained in:
@@ -1,286 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import { untrack } from "svelte";
|
||||
import type { OpenBuffer } from "$lib/workspace/types";
|
||||
import { workspaceReadDataUrl } from "$lib/workspace/api";
|
||||
import { markdownBlocks } from "$lib/workspace/markdownBlocks";
|
||||
import { findMarkdownImages, isRemoteImage, resolveImageRel } from "$lib/workspace/media";
|
||||
import { renderMarkdownHtml } from "$lib/workspace/noteHtml";
|
||||
import { htmlToMarkdown } from "$lib/workspace/htmlToMarkdown";
|
||||
import ContextMenu from "$lib/layout/ContextMenu.svelte";
|
||||
import type { MenuItem } from "$lib/layout/menuTypes";
|
||||
import { writerContextItems } from "./writerMenu";
|
||||
import { useSpellingMenu } from "./spellingMenu";
|
||||
|
||||
type Props = {
|
||||
buffer: OpenBuffer;
|
||||
onChange: (value: string) => void;
|
||||
onInsertImage?: (file: File) => Promise<string | null>;
|
||||
onOpenLink?: (kind: "md" | "wiki", target: string) => void;
|
||||
};
|
||||
|
||||
type OpenMenu = { x: number; y: number; items: MenuItem[] } | null;
|
||||
|
||||
let { buffer, onChange, onInsertImage, onOpenLink }: Props = $props();
|
||||
|
||||
let host: HTMLDivElement | undefined = $state();
|
||||
let editor: import("@tiptap/core").Editor | undefined;
|
||||
let ready = $state(0);
|
||||
let applying = false;
|
||||
let skipUpdate = true;
|
||||
let menu = $state<OpenMenu>(null);
|
||||
|
||||
function imageFiles(data: DataTransfer | null): File[] {
|
||||
if (!data) {
|
||||
return [];
|
||||
}
|
||||
return [...data.files].filter((file) => file.type.startsWith("image/"));
|
||||
}
|
||||
|
||||
async function loadUrls(noteRel: string, contents: string): Promise<Map<string, string>> {
|
||||
const urls = new Map<string, string>();
|
||||
for (const block of markdownBlocks(contents)) {
|
||||
if (block.type !== "text") {
|
||||
continue;
|
||||
}
|
||||
for (const image of findMarkdownImages(block.line)) {
|
||||
if (urls.has(image.src)) {
|
||||
continue;
|
||||
}
|
||||
if (isRemoteImage(image.src)) {
|
||||
urls.set(image.src, image.src.trim());
|
||||
continue;
|
||||
}
|
||||
const primary = resolveImageRel(noteRel, image.src);
|
||||
const base = image.src.replaceAll("\\", "/").split("/").pop() ?? image.src;
|
||||
try {
|
||||
urls.set(image.src, await workspaceReadDataUrl(primary));
|
||||
} catch {
|
||||
try {
|
||||
urls.set(image.src, await workspaceReadDataUrl(base));
|
||||
} catch {
|
||||
urls.set(image.src, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
const el = host;
|
||||
if (!el) {
|
||||
return;
|
||||
}
|
||||
let cancelled = false;
|
||||
void Promise.all([
|
||||
import("@tiptap/core"),
|
||||
import("@tiptap/starter-kit"),
|
||||
import("@tiptap/extension-image"),
|
||||
import("@tiptap/extension-link"),
|
||||
import("@tiptap/extension-table"),
|
||||
import("@tiptap/extension-superscript"),
|
||||
import("@tiptap/extension-subscript"),
|
||||
import("@tiptap/extension-task-list"),
|
||||
import("@tiptap/extension-task-item"),
|
||||
import("@tiptap/extension-highlight"),
|
||||
import("./headingMarks"),
|
||||
import("./writerMarks"),
|
||||
]).then(async ([core, starter, imageMod, linkMod, tableMod, supMod, subMod, taskListMod, taskItemMod, highlightMod, marks, extra]) => {
|
||||
if (cancelled || !el.isConnected) {
|
||||
return;
|
||||
}
|
||||
const path = untrack(() => buffer.relPath);
|
||||
const value = untrack(() => buffer.contents ?? "");
|
||||
const urls = await loadUrls(path, value);
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
applying = true;
|
||||
const html = renderMarkdownHtml(value, urls) || "<p></p>";
|
||||
const Image = imageMod.default.extend({
|
||||
addAttributes() {
|
||||
return {
|
||||
...this.parent?.(),
|
||||
"data-md-src": { default: null },
|
||||
"data-md-kind": { default: "md" },
|
||||
};
|
||||
},
|
||||
});
|
||||
const Link = linkMod.default.extend({
|
||||
addAttributes() {
|
||||
return {
|
||||
...this.parent?.(),
|
||||
"data-kind": { default: "md" },
|
||||
class: { default: null },
|
||||
};
|
||||
},
|
||||
});
|
||||
const view = new core.Editor({
|
||||
element: el,
|
||||
extensions: [
|
||||
starter.default.configure({ heading: { levels: [1, 2, 3, 4, 5, 6] } }),
|
||||
Image.configure({ inline: false, allowBase64: true }),
|
||||
Link.configure({ openOnClick: false, autolink: false }),
|
||||
tableMod.TableKit.configure({ table: { resizable: false } }),
|
||||
supMod.default,
|
||||
subMod.default,
|
||||
taskListMod.default,
|
||||
taskItemMod.default.configure({ nested: false }),
|
||||
highlightMod.default.configure({ multicolor: false }),
|
||||
extra.MathMark,
|
||||
extra.CommentMark,
|
||||
marks.HeadingMarks,
|
||||
],
|
||||
content: html,
|
||||
editorProps: {
|
||||
attributes: { class: "reading writer-doc", spellcheck: "true" },
|
||||
handleDOMEvents: {
|
||||
contextmenu: (pmView, event) => {
|
||||
if (useSpellingMenu(event, pmView.state.selection.empty)) { menu = null; return false; }
|
||||
event.preventDefault();
|
||||
if (!editor) {
|
||||
return true;
|
||||
}
|
||||
const hit = pmView.posAtCoords({ left: event.clientX, top: event.clientY });
|
||||
if (hit) {
|
||||
const { from, to } = editor.state.selection;
|
||||
if (from === to || hit.pos < from || hit.pos > to) {
|
||||
editor.chain().setTextSelection(hit.pos).run();
|
||||
}
|
||||
}
|
||||
menu = {
|
||||
x: event.clientX,
|
||||
y: event.clientY,
|
||||
items: writerContextItems(editor),
|
||||
};
|
||||
return true;
|
||||
},
|
||||
},
|
||||
handleClick: (_view, _pos, event) => {
|
||||
const node = event.target instanceof Element ? event.target.closest("a") : null;
|
||||
if (!node) {
|
||||
return false;
|
||||
}
|
||||
const href = node.getAttribute("href") ?? "";
|
||||
const kind = node.getAttribute("data-kind");
|
||||
if (kind === "wiki") {
|
||||
event.preventDefault();
|
||||
onOpenLink?.("wiki", href);
|
||||
return true;
|
||||
}
|
||||
if (kind === "md" && !/^https?:\/\//i.test(href)) {
|
||||
event.preventDefault();
|
||||
onOpenLink?.("md", href);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
},
|
||||
onCreate: () => {
|
||||
applying = false;
|
||||
queueMicrotask(() => {
|
||||
skipUpdate = false;
|
||||
});
|
||||
},
|
||||
onUpdate: ({ editor: current }) => {
|
||||
if (applying || skipUpdate) {
|
||||
return;
|
||||
}
|
||||
onChange(htmlToMarkdown(current.getHTML()));
|
||||
},
|
||||
});
|
||||
editor = view;
|
||||
ready += 1;
|
||||
view.commands.focus("end");
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
editor?.destroy();
|
||||
editor = undefined;
|
||||
};
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
void ready;
|
||||
const contents = buffer.contents;
|
||||
const view = editor;
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
if (view.isFocused) {
|
||||
return;
|
||||
}
|
||||
const current = htmlToMarkdown(view.getHTML());
|
||||
if (contents === current) {
|
||||
return;
|
||||
}
|
||||
applying = true;
|
||||
void loadUrls(buffer.relPath, contents).then((urls) => {
|
||||
if (editor !== view) {
|
||||
return;
|
||||
}
|
||||
view.commands.setContent(renderMarkdownHtml(contents, urls) || "<p></p>");
|
||||
applying = false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="writer-host"
|
||||
role="application"
|
||||
aria-label={$t("Writer")}
|
||||
bind:this={host}
|
||||
ondragover={(event) => {
|
||||
if (imageFiles(event.dataTransfer).length > 0) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}}
|
||||
ondrop={(event) => {
|
||||
const files = imageFiles(event.dataTransfer);
|
||||
if (files.length === 0 || !onInsertImage) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
void (async () => {
|
||||
for (const file of files) {
|
||||
const snippet = await onInsertImage(file);
|
||||
const rel = snippet ? /\(([^)]+)\)/.exec(snippet)?.[1] : null;
|
||||
if (!rel || !editor) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
const src = await workspaceReadDataUrl(rel);
|
||||
editor.commands.insertContent(
|
||||
`<img src="${src}" alt="${file.name}" data-md-src="${rel}" data-md-kind="md" />`,
|
||||
);
|
||||
} catch {
|
||||
editor.commands.insertContent(snippet);
|
||||
}
|
||||
}
|
||||
})();
|
||||
}}
|
||||
></div>
|
||||
|
||||
{#if menu}
|
||||
<ContextMenu
|
||||
x={menu.x}
|
||||
y={menu.y}
|
||||
items={menu.items}
|
||||
onClose={() => (menu = null)}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.writer-host {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.writer-host :global(.tiptap),
|
||||
.writer-host :global(.ProseMirror) {
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
@@ -1,90 +0,0 @@
|
||||
import { Extension } from "@tiptap/core";
|
||||
import type { Node as PmNode } from "@tiptap/pm/model";
|
||||
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
||||
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
||||
|
||||
export function headingMarkText(level: number): string {
|
||||
const n = Math.min(6, Math.max(1, Math.floor(level)));
|
||||
return "#".repeat(n);
|
||||
}
|
||||
|
||||
export function fenceOpenText(lang: string): string {
|
||||
const name = lang.trim();
|
||||
return name ? `\`\`\`${name}` : "```";
|
||||
}
|
||||
|
||||
export function findInlineCodeRange(doc: PmNode, pos: number): { from: number; to: number } | null {
|
||||
const $pos = doc.resolve(pos);
|
||||
const type = doc.type.schema.marks.code;
|
||||
if (!type || !$pos.parent.inlineContent) {
|
||||
return null;
|
||||
}
|
||||
const parentStart = $pos.start();
|
||||
let runFrom = -1;
|
||||
let runTo = -1;
|
||||
let hit: { from: number; to: number } | null = null;
|
||||
$pos.parent.forEach((child, offset) => {
|
||||
const from = parentStart + offset;
|
||||
const to = from + child.nodeSize;
|
||||
if (type.isInSet(child.marks)) {
|
||||
if (runFrom === -1) {
|
||||
runFrom = from;
|
||||
}
|
||||
runTo = to;
|
||||
return;
|
||||
}
|
||||
if (runFrom !== -1 && pos >= runFrom && pos <= runTo) {
|
||||
hit = { from: runFrom, to: runTo };
|
||||
}
|
||||
runFrom = -1;
|
||||
runTo = -1;
|
||||
});
|
||||
if (hit) {
|
||||
return hit;
|
||||
}
|
||||
if (runFrom !== -1 && pos >= runFrom && pos <= runTo) {
|
||||
return { from: runFrom, to: runTo };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export const HeadingMarks = Extension.create({
|
||||
name: "headingMarks",
|
||||
addProseMirrorPlugins() {
|
||||
return [
|
||||
new Plugin({
|
||||
key: new PluginKey("headingMarks"),
|
||||
props: {
|
||||
decorations(state) {
|
||||
const { $from } = state.selection;
|
||||
if ($from.parent.type.name === "codeBlock") {
|
||||
const lang = String($from.parent.attrs.language ?? "");
|
||||
return DecorationSet.create(state.doc, [
|
||||
Decoration.node($from.before(), $from.after(), {
|
||||
class: "is-editing",
|
||||
"data-fence-open": fenceOpenText(lang),
|
||||
}),
|
||||
]);
|
||||
}
|
||||
if ($from.parent.type.name === "heading") {
|
||||
const level = Number($from.parent.attrs.level ?? 1);
|
||||
return DecorationSet.create(state.doc, [
|
||||
Decoration.node($from.before(), $from.after(), {
|
||||
class: "is-editing",
|
||||
"data-heading-marks": headingMarkText(level),
|
||||
}),
|
||||
]);
|
||||
}
|
||||
const range = findInlineCodeRange(state.doc, $from.pos);
|
||||
if (!range) {
|
||||
return DecorationSet.empty;
|
||||
}
|
||||
return DecorationSet.create(state.doc, [
|
||||
Decoration.inline(range.from, range.to, { class: "is-editing-ticks" }),
|
||||
]);
|
||||
},
|
||||
},
|
||||
}),
|
||||
];
|
||||
},
|
||||
});
|
||||
@@ -220,19 +220,40 @@ export function tableControls(root: HTMLElement, view: EditorView, initialSource
|
||||
// Native cursor movement can precede ProseMirror's selectionchange
|
||||
// observer (especially during key repeat). Test the visible caret.
|
||||
const native = document.getSelection();
|
||||
if (native?.anchorNode && native.focusNode && _editorView.dom.contains(native.anchorNode) && _editorView.dom.contains(native.focusNode)) {
|
||||
const readNative = (scroll = false) => {
|
||||
if (!native?.anchorNode || !native.focusNode || !_editorView.dom.contains(native.anchorNode) || !_editorView.dom.contains(native.focusNode)) return;
|
||||
const anchor = _editorView.posAtDOM(native.anchorNode, native.anchorOffset);
|
||||
const head = _editorView.posAtDOM(native.focusNode, native.focusOffset);
|
||||
if (anchor !== _editorView.state.selection.anchor || head !== _editorView.state.selection.head) editor!.commands.setTextSelection({ from: anchor, to: head });
|
||||
}
|
||||
if (event.shiftKey || event.ctrlKey || event.metaKey || event.altKey || !_editorView.state.selection.empty) return false;
|
||||
if (anchor === _editorView.state.selection.anchor && head === _editorView.state.selection.head) return;
|
||||
const chain = editor!.chain().setTextSelection({ from: anchor, to: head });
|
||||
(scroll ? chain.scrollIntoView() : chain).run();
|
||||
};
|
||||
readNative();
|
||||
// ProseMirror reads a native move on the next selectionchange. Its
|
||||
// delayed focus check can run first and restore the old selection,
|
||||
// so the move is lost under load. Move the DOM selection here and
|
||||
// read the result at once. Other shortcuts stay with the browser.
|
||||
const mac = navigator.platform.includes("Mac");
|
||||
const vertical = event.key === "ArrowUp" || event.key === "ArrowDown";
|
||||
const word = mac ? event.altKey : event.ctrlKey;
|
||||
const moveNative = () => {
|
||||
if (!native || event.metaKey || (mac ? event.ctrlKey : event.altKey) || (vertical && word)) return false;
|
||||
native.modify(
|
||||
event.shiftKey ? "extend" : "move",
|
||||
vertical ? (event.key === "ArrowUp" ? "backward" : "forward") : event.key === "ArrowLeft" ? "left" : "right",
|
||||
vertical ? "line" : word ? "word" : "character",
|
||||
);
|
||||
readNative(true);
|
||||
return true;
|
||||
};
|
||||
if (event.shiftKey || event.ctrlKey || event.metaKey || event.altKey || !_editorView.state.selection.empty) return moveNative();
|
||||
const direction = event.key === "ArrowLeft" ? "left" : event.key === "ArrowRight" ? "right" : event.key === "ArrowUp" ? "up" : "down";
|
||||
const horizontal = direction === "left" || direction === "right";
|
||||
const backwards = direction === "left" || direction === "up";
|
||||
const { $head } = _editorView.state.selection;
|
||||
// Pasted rich text can have several paragraphs within one cell.
|
||||
if ($head.depth && (backwards ? $head.before(1) > 0 : $head.after(1) < _editorView.state.doc.content.size)) return false;
|
||||
if (!_editorView.endOfTextblock(direction)) return false;
|
||||
if ($head.depth && (backwards ? $head.before(1) > 0 : $head.after(1) < _editorView.state.doc.content.size)) return moveNative();
|
||||
if (!_editorView.endOfTextblock(direction)) return moveNative();
|
||||
event.preventDefault();
|
||||
const cells = [...table!.querySelectorAll<HTMLTableCellElement>("th, td")];
|
||||
const next = horizontal
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
import { Mark } from "@tiptap/core";
|
||||
|
||||
export const MathMark = Mark.create({
|
||||
name: "math",
|
||||
parseHTML() {
|
||||
return [{ tag: "span[data-math]" }];
|
||||
},
|
||||
renderHTML() {
|
||||
return ["span", { "data-math": "1", class: "md-math" }, 0];
|
||||
},
|
||||
});
|
||||
|
||||
export const CommentMark = Mark.create({
|
||||
name: "comment",
|
||||
parseHTML() {
|
||||
return [{ tag: "span[data-comment]" }];
|
||||
},
|
||||
renderHTML() {
|
||||
return ["span", { "data-comment": "1", class: "md-comment" }, 0];
|
||||
},
|
||||
});
|
||||
@@ -1,144 +0,0 @@
|
||||
import { tr } from '../i18n/index.ts';
|
||||
import type { Editor } from "@tiptap/core";
|
||||
import type { MenuItem } from "../layout/menuTypes";
|
||||
|
||||
function selectedText(editor: Editor): string {
|
||||
const { from, to } = editor.state.selection;
|
||||
return editor.state.doc.textBetween(from, to, "\n");
|
||||
}
|
||||
|
||||
async function writeClipboard(text: string): Promise<boolean> {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export async function cutSelection(editor: Editor): Promise<void> {
|
||||
const text = selectedText(editor);
|
||||
if (text && !(await writeClipboard(text))) {
|
||||
return;
|
||||
}
|
||||
editor.chain().focus().deleteSelection().run();
|
||||
}
|
||||
|
||||
export async function copySelection(editor: Editor): Promise<void> {
|
||||
const text = selectedText(editor);
|
||||
if (text) {
|
||||
await writeClipboard(text);
|
||||
}
|
||||
}
|
||||
|
||||
export async function pasteClipboard(editor: Editor): Promise<void> {
|
||||
let text = "";
|
||||
try {
|
||||
text = await navigator.clipboard.readText();
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
editor.chain().focus().run();
|
||||
editor.view.dispatch(editor.state.tr.insertText(text));
|
||||
}
|
||||
|
||||
export function writerContextItems(editor: Editor): MenuItem[] {
|
||||
const inTable = editor.isActive("table");
|
||||
return [
|
||||
{ kind: "action", label: tr("Cut"), run: () => void cutSelection(editor) },
|
||||
{ kind: "action", label: tr("Copy"), run: () => void copySelection(editor) },
|
||||
{ kind: "action", label: tr("Paste"), run: () => void pasteClipboard(editor) },
|
||||
{ kind: "sep" },
|
||||
{
|
||||
kind: "group",
|
||||
label: tr("Style"),
|
||||
items: [
|
||||
{ kind: "action", label: tr("Heading {level}", { level: 1 }), run: () => editor.chain().focus().toggleHeading({ level: 1 }).run() },
|
||||
{ kind: "action", label: tr("Heading {level}", { level: 2 }), run: () => editor.chain().focus().toggleHeading({ level: 2 }).run() },
|
||||
{ kind: "action", label: tr("Heading {level}", { level: 3 }), run: () => editor.chain().focus().toggleHeading({ level: 3 }).run() },
|
||||
{ kind: "action", label: tr("Heading {level}", { level: 4 }), run: () => editor.chain().focus().toggleHeading({ level: 4 }).run() },
|
||||
{ kind: "action", label: tr("Heading {level}", { level: 5 }), run: () => editor.chain().focus().toggleHeading({ level: 5 }).run() },
|
||||
{ kind: "action", label: tr("Heading {level}", { level: 6 }), run: () => editor.chain().focus().toggleHeading({ level: 6 }).run() },
|
||||
{ kind: "action", label: tr("Body"), run: () => editor.chain().focus().setParagraph().run() },
|
||||
{ kind: "action", label: tr("Quote"), run: () => editor.chain().focus().toggleBlockquote().run() },
|
||||
{ kind: "sep" },
|
||||
{ kind: "action", label: tr("Bullet list"), run: () => editor.chain().focus().toggleBulletList().run() },
|
||||
{ kind: "action", label: tr("Numbered list"), run: () => editor.chain().focus().toggleOrderedList().run() },
|
||||
{ kind: "action", label: tr("Task list"), run: () => editor.chain().focus().toggleTaskList().run() },
|
||||
],
|
||||
},
|
||||
{
|
||||
kind: "group",
|
||||
label: tr("Format"),
|
||||
items: [
|
||||
{ kind: "action", label: tr("Bold"), run: () => editor.chain().focus().toggleBold().run() },
|
||||
{ kind: "action", label: tr("Italic"), run: () => editor.chain().focus().toggleItalic().run() },
|
||||
{ kind: "action", label: tr("Strikethrough"), run: () => editor.chain().focus().toggleStrike().run() },
|
||||
{ kind: "action", label: tr("Highlight"), run: () => editor.chain().focus().toggleHighlight().run() },
|
||||
{ kind: "action", label: tr("Code"), run: () => editor.chain().focus().toggleCode().run() },
|
||||
{ kind: "action", label: tr("Math"), run: () => editor.chain().focus().toggleMark("math").run() },
|
||||
{ kind: "action", label: tr("Comment"), run: () => editor.chain().focus().toggleMark("comment").run() },
|
||||
{ kind: "sep" },
|
||||
{ kind: "action", label: tr("Clear formatting"), run: () => editor.chain().focus().unsetAllMarks().run() },
|
||||
],
|
||||
},
|
||||
{
|
||||
kind: "group",
|
||||
label: tr("Table"),
|
||||
items: [
|
||||
{
|
||||
kind: "action",
|
||||
label: tr("Insert table"),
|
||||
run: () => editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run(),
|
||||
},
|
||||
{ kind: "sep" },
|
||||
{
|
||||
kind: "action",
|
||||
label: tr("Add row above"),
|
||||
disabled: !inTable,
|
||||
run: () => editor.chain().focus().addRowBefore().run(),
|
||||
},
|
||||
{
|
||||
kind: "action",
|
||||
label: tr("Add row below"),
|
||||
disabled: !inTable,
|
||||
run: () => editor.chain().focus().addRowAfter().run(),
|
||||
},
|
||||
{
|
||||
kind: "action",
|
||||
label: tr("Delete row"),
|
||||
disabled: !inTable,
|
||||
run: () => editor.chain().focus().deleteRow().run(),
|
||||
},
|
||||
{ kind: "sep" },
|
||||
{
|
||||
kind: "action",
|
||||
label: tr("Add column left"),
|
||||
disabled: !inTable,
|
||||
run: () => editor.chain().focus().addColumnBefore().run(),
|
||||
},
|
||||
{
|
||||
kind: "action",
|
||||
label: tr("Add column right"),
|
||||
disabled: !inTable,
|
||||
run: () => editor.chain().focus().addColumnAfter().run(),
|
||||
},
|
||||
{
|
||||
kind: "action",
|
||||
label: tr("Delete column"),
|
||||
disabled: !inTable,
|
||||
run: () => editor.chain().focus().deleteColumn().run(),
|
||||
},
|
||||
{
|
||||
kind: "action",
|
||||
label: tr("Delete table"),
|
||||
disabled: !inTable,
|
||||
run: () => editor.chain().focus().deleteTable().run(),
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -1206,7 +1206,7 @@
|
||||
let refreshTimer: ReturnType<typeof setTimeout>;
|
||||
const register = (off: () => void) => { if (disposed) off(); else unlisteners.push(off); };
|
||||
void onWorkspaceEvent((event) => {
|
||||
if (event.root !== workspace?.root || event.kind === "access") return;
|
||||
if (event.root !== workspace?.root) return;
|
||||
if (event.paths.every(path => path.startsWith(".runestone/") || path.split("/").pop()?.startsWith(".runestone-save-"))) return;
|
||||
clearTimeout(refreshTimer);
|
||||
refreshTimer = setTimeout(() => {
|
||||
|
||||
Reference in New Issue
Block a user