Improve editor, plugin updates, and window transfers for 0.1.41

This commit is contained in:
Knotty Wyvern
2026-10-21 10:42:44 -07:00
parent 68e86ab6eb
commit 42dd0fa711
56 changed files with 2313 additions and 221 deletions
+20 -1
View File
@@ -9,7 +9,8 @@
import { writerHistory, historyKeymap } from "./writerHistory";
import { markdown, markdownLanguage } from "@codemirror/lang-markdown";
import { noteFormats } from "./noteFormats";
import { searchKeymap } from "@codemirror/search";
import { closeSearchPanel, findNext, findPrevious, openSearchPanel, searchKeymap } from "@codemirror/search";
import { htmlToMarkdown } from "$lib/workspace/htmlToMarkdown";
import { writerSearch } from "./writerSearch";
import type { OpenBuffer } from "$lib/workspace/types";
import { workspaceReadDataUrl, workspaceReveal } from "$lib/workspace/api";
@@ -52,6 +53,13 @@
let host: HTMLDivElement | undefined = $state();
let editor = $state.raw<EditorView>();
export function focus() { editor?.focus(); }
export function openFind(replace = false) {
if (!editor) return;
openSearchPanel(editor);
editor.dom.querySelector<HTMLInputElement>(replace ? 'input[name="replace"]' : 'input[name="search"]')?.select();
}
export function closeFind() { if (editor) closeSearchPanel(editor); }
export function nextMatch(backward = false) { if (editor) (backward ? findPrevious : findNext)(editor); }
let error = $state("");
let model: import("monaco-editor").editor.ITextModel | undefined;
let ModelSelection: typeof import("monaco-editor").Selection;
@@ -272,6 +280,17 @@
return true;
},
paste(event, view) {
const html = event.clipboardData?.getData("text/html") || "";
if (/<table[\s>]/i.test(html)) {
const markdown = htmlToMarkdown(html).replace(/\r\n?/g, "\n").trim();
if (markdown) {
event.preventDefault(); event.stopPropagation();
const { from, to } = view.state.selection.main;
const insert = imageInsertion(view.state.doc.toString(), from, to, [markdown]);
view.dispatch({ changes: { from, to, insert }, selection: { anchor: from + insert.length }, userEvent: "input.paste", annotations: isolateHistory.of("full") });
return true;
}
}
if (!onInsertImage || !imageFiles(event.clipboardData).length) return false;
void insertImages(event, view); return true;
},