Update the browser, editor, settings, and installer
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { pluginHost } from "$lib/plugins/registry";
|
||||
import { useSpellingMenu } from "./spellingMenu";
|
||||
import { spellingWord } from "./spellingWord";
|
||||
import { untrack } from "svelte";
|
||||
import { Compartment, EditorState, EditorSelection, Transaction } from "@codemirror/state";
|
||||
import { EditorView, drawSelection, keymap } from "@codemirror/view";
|
||||
@@ -17,6 +18,7 @@
|
||||
import { markdownImages } from "$lib/workspace/noteHtml";
|
||||
import { isRemoteImage, resolveImageRel, imageFiles, hasFileDrag, imageInsertion, workspaceImageLink } from "$lib/workspace/media";
|
||||
import { registerImageDropTarget } from "./workspaceImageDrop";
|
||||
import { workspaceFileLink } from "./workspaceFileLink";
|
||||
import { editorSession } from "./sessions";
|
||||
import { registerSelection } from "./selection";
|
||||
import { liveMarkdown, refreshImages } from "./liveMarkdown";
|
||||
@@ -28,6 +30,8 @@
|
||||
import { tableNavigation } from "./tableNavigation";
|
||||
import { completionExtension } from "$lib/completion/codemirror";
|
||||
import { documentLinkAt } from "./documentLinks";
|
||||
import { headingFolding } from "./headingFolding";
|
||||
import "./headingFolding.css";
|
||||
|
||||
type Props = {
|
||||
buffer: OpenBuffer;
|
||||
@@ -125,7 +129,7 @@
|
||||
const id = Symbol(), path = buffer.relPath;
|
||||
view.dispatch({ effects: trackImageDrop.of({ id, from: range.from, to: range.to }) });
|
||||
try {
|
||||
const snippets: string[] = linkedPath ? [workspaceImageLink(path, linkedPath)] : [];
|
||||
const snippets: string[] = linkedPath ? [workspaceFileLink(path, linkedPath)] : [];
|
||||
for (const file of files) {
|
||||
if (editor !== view) return;
|
||||
const snippet = await onInsertImage?.(file);
|
||||
@@ -168,6 +172,7 @@
|
||||
const extensions = [
|
||||
completionExtension(current.id),
|
||||
markdown({ base: markdownLanguage, extensions: [noteFormats] }),
|
||||
headingFolding,
|
||||
writerHistory.of({
|
||||
undo: () => {
|
||||
clearTimeout(historyTimer);
|
||||
@@ -237,7 +242,7 @@
|
||||
EditorView.domEventHandlers({
|
||||
contextmenu(event, view) {
|
||||
if (event.target instanceof Element && event.target.closest(".writer-table")) return false;
|
||||
if (useSpellingMenu(event, view.state.selection.main.empty)) { menu?.close(false); return false; }
|
||||
if (event.target instanceof HTMLElement && spellingWord(event.target.closest<HTMLElement>('[contenteditable="true"]') ?? event.target, event.clientX, event.clientY) && useSpellingMenu(event, view.state.selection.main.empty)) { menu?.close(false); return false; }
|
||||
event.preventDefault();
|
||||
const position = view.posAtCoords({ x: event.clientX, y: event.clientY });
|
||||
const selection = view.state.selection.main;
|
||||
@@ -394,8 +399,9 @@
|
||||
.live-writer :global(.cm-editor.cm-focused) { outline: none; }
|
||||
.live-writer :global(.cm-scroller) { overflow: auto; font: var(--rs-font-weight) var(--rs-prose-size)/var(--rs-prose-line) var(--rs-font-prose); scrollbar-gutter: stable; }
|
||||
.live-writer :global(.cm-content) { max-width: 868px; width: 100%; margin: 0 auto; padding: clamp(24px, 4vw, 56px) clamp(22px, 4vw, 64px) 35vh; caret-color: var(--rs-text-strong); }
|
||||
.live-writer :global(.cm-line) { padding: 0; position: relative; }
|
||||
.live-writer :global(.cm-line) { padding-inline: 0; position: relative; }
|
||||
.live-writer :global(.cm-line:hover)::before { content: ""; position: absolute; left: -14px; top: 2px; bottom: 2px; width: 3px; border-radius: var(--rs-control-radius); background: var(--rs-text-dim); opacity: .5; pointer-events: none; }
|
||||
.live-writer :global(.writer-heading:hover)::before { display: none; }
|
||||
.live-writer :global(.cm-panels) { background: var(--rs-bg-elevated); color: var(--rs-text); }
|
||||
.live-writer :global(.cm-cursor) { border-left-color: var(--rs-text-strong); }
|
||||
.live-writer :global(.cm-selectionBackground), .live-writer :global(.cm-focused .cm-selectionBackground) { background: var(--rs-bg-active); }
|
||||
|
||||
Reference in New Issue
Block a user