Release RuneStone 0.1.4 with installable plugins and settings
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { pluginHost } from "$lib/plugins/registry";
|
||||
import { untrack } from "svelte";
|
||||
import { Compartment, EditorState } from "@codemirror/state";
|
||||
import { EditorView, drawSelection, keymap } from "@codemirror/view";
|
||||
@@ -33,8 +34,10 @@
|
||||
focusLine?: number | null;
|
||||
tableActions?: TableContextActions;
|
||||
shouldFocusOnMount?: () => boolean;
|
||||
focusTitle?: boolean;
|
||||
onTitleFocused?: () => void;
|
||||
};
|
||||
let { buffer, onChange, onRenameTitle, onOpenLink, onInsertImage, focusLine = null, tableActions = {}, shouldFocusOnMount = () => true }: Props = $props();
|
||||
let { buffer, onChange, onRenameTitle, onOpenLink, onInsertImage, focusLine = null, tableActions = {}, shouldFocusOnMount = () => true, focusTitle = false, onTitleFocused }: Props = $props();
|
||||
let host: HTMLDivElement | undefined = $state();
|
||||
let editor = $state.raw<EditorView>();
|
||||
let error = $state("");
|
||||
@@ -234,7 +237,7 @@
|
||||
selectAll() { view.dispatch({ selection: { anchor: 0, head: view.state.doc.length } }); view.focus(); },
|
||||
focus() { view.focus(); },
|
||||
}, untrack(() => tableActions), message => { error = message; });
|
||||
if (shouldFocusOnMount()) view.focus();
|
||||
if (!focusTitle && shouldFocusOnMount()) view.focus();
|
||||
}).catch(reason => { if (!cancelled) error = String(reason); });
|
||||
return () => {
|
||||
cancelled = true;
|
||||
@@ -251,12 +254,25 @@
|
||||
};
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
void $pluginHost;
|
||||
editor?.dispatch({ effects: refreshImages.of() });
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
const name = markdownTitle(buffer.relPath);
|
||||
const view = editor;
|
||||
if (view) view.dispatch({ effects: title.reconfigure(noteTitle(name, onRenameTitle ? renameTitle : undefined)) });
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (!focusTitle || !editor) return;
|
||||
const button = editor.dom.querySelector<HTMLButtonElement>(".note-title-button");
|
||||
if (!button) return;
|
||||
button.click();
|
||||
onTitleFocused?.();
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
const value = buffer.contents;
|
||||
const path = buffer.relPath;
|
||||
|
||||
Reference in New Issue
Block a user