Implementing #913 (#1230)

Implemented custom editors
This commit is contained in:
MrMugame
2025-03-06 15:11:17 +01:00
committed by GitHub
parent 6190a4ff06
commit e61a447d98
72 changed files with 1838 additions and 616 deletions
+3 -2
View File
@@ -23,6 +23,7 @@ import { LuaRuntimeError } from "$common/space_lua/runtime.ts";
import { encodePageRef } from "@silverbulletmd/silverbullet/lib/page_ref";
import { resolveASTReference } from "$common/space_lua.ts";
import { LuaWidget } from "./lua_widget.ts";
import type { PageMeta } from "@silverbulletmd/silverbullet/types";
export function luaDirectivePlugin(client: Client) {
return decoratorStateField((state: EditorState) => {
@@ -43,7 +44,7 @@ export function luaDirectivePlugin(client: Client) {
}
const text = state.sliceDoc(node.from + 2, node.to - 1);
const currentPageMeta = client.ui.viewState.currentPageMeta;
const currentPageMeta = client.ui.viewState.current?.meta as PageMeta;
widgets.push(
Decoration.widget({
widget: new LuaWidget(
@@ -62,7 +63,7 @@ export function luaDirectivePlugin(client: Client) {
tl.setLocal(
"currentPage",
currentPageMeta ||
{ name: client.ui.viewState.currentPage },
{ name: client.ui.viewState.current?.path },
);
const sf = LuaStackFrame.createWithGlobalEnv(
client.clientSystem.spaceLuaEnv.env,