Add workspace links, restore tabs, and update project guides
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
import { defaultKeymap, indentWithTab, isolateHistory } from "@codemirror/commands";
|
||||
import { writerHistory, historyKeymap } from "./writerHistory";
|
||||
import { markdown, markdownLanguage } from "@codemirror/lang-markdown";
|
||||
import { foldedRanges, unfoldEffect } from "@codemirror/language";
|
||||
import { noteFormats } from "./noteFormats";
|
||||
import { closeSearchPanel, findNext, findPrevious, openSearchPanel, searchKeymap } from "@codemirror/search";
|
||||
import { htmlToMarkdown } from "$lib/workspace/htmlToMarkdown";
|
||||
@@ -409,7 +410,9 @@
|
||||
if (!view || line == null) return;
|
||||
untrack(() => {
|
||||
const anchor = view.state.doc.line(Math.min(view.state.doc.lines, Math.max(1, line))).from;
|
||||
view.dispatch({ selection: { anchor }, effects: EditorView.scrollIntoView(anchor, { y: "center" }) });
|
||||
const effects = [EditorView.scrollIntoView(anchor, { y: "center" })];
|
||||
foldedRanges(view.state).between(anchor, anchor, (from, to) => { effects.push(unfoldEffect.of({ from, to })); });
|
||||
view.dispatch({ selection: { anchor }, effects });
|
||||
view.focus();
|
||||
});
|
||||
});
|
||||
@@ -461,7 +464,7 @@
|
||||
.live-writer :global(.writer-checkbox) { display: inline-block; position: static; width: 15px; height: 15px; margin: 0 .55em 0 0; vertical-align: -.1em; accent-color: var(--rs-accent); cursor: pointer; }
|
||||
/* Keep child margins inside the measured widget; collapsed margins otherwise
|
||||
shift mouse hit-testing to the next line after a table or other preview. */
|
||||
.live-writer :global(.writer-preview) { display: flow-root; max-width: none; margin: 0; }
|
||||
.live-writer :global(.writer-preview) { display: flow-root; max-width: none; margin: 0; white-space: normal; }
|
||||
.live-writer :global(.writer-preview > :last-child) { margin-bottom: 0; }
|
||||
.live-writer :global(.writer-preview img) { max-width: 100%; }
|
||||
.live-writer :global(.writer-table) { position: relative; width: fit-content; max-width: 100%; margin: 1.4em 0 0; padding: 26px; }
|
||||
|
||||
@@ -121,6 +121,19 @@ class Preview extends WidgetType {
|
||||
previewFormulas.set(dom, this.formulas);
|
||||
dom.className = "reading writer-preview";
|
||||
dom.innerHTML = this.html;
|
||||
// Widgets handle their own events, so CodeMirror's link handler cannot run.
|
||||
dom.addEventListener("mousedown", event => {
|
||||
if (event.button !== 0 || (!event.ctrlKey && !event.metaKey)) return;
|
||||
const link = event.target instanceof Element ? event.target.closest<HTMLElement>("[data-href], a[href]") : null;
|
||||
if (!link) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
void this.actions.linkActions?.().open?.({ kind: link.dataset.kind === "wiki" ? "wiki" : "md", target: link.dataset.href ?? link.getAttribute("href") ?? "" });
|
||||
}, { capture: true });
|
||||
// Cancel native anchor navigation even when an ordinary click reveals source.
|
||||
dom.addEventListener("click", event => {
|
||||
if (event.target instanceof Element && event.target.closest("a[href], [data-href]")) event.preventDefault();
|
||||
}, { capture: true });
|
||||
tableControls(dom, view, this.source, this.actions);
|
||||
imageCleanups.set(dom, imageControls(dom, {}, () => { if (dom.isConnected) view.requestMeasure(); }));
|
||||
this.measure(dom, view);
|
||||
|
||||
Reference in New Issue
Block a user