Fixes #193: Allowing plug overrides

This commit is contained in:
Zef Hemel
2023-08-20 19:54:31 +02:00
parent 136682ebd3
commit 2a10d50094
9 changed files with 146 additions and 40 deletions
+6 -1
View File
@@ -35,6 +35,7 @@ import { OpenPages } from "./open_pages.ts";
import { MainUI } from "./editor_ui.tsx";
import { DexieMQ } from "../plugos/lib/mq.dexie.ts";
import { cleanPageRef } from "$sb/lib/resolve.ts";
import { expandPropertyNames } from "$sb/lib/json.ts";
const frontMatterRegex = /^---\n(([^\n]|\n)*?)---\n/;
const autoSaveInterval = 1000;
@@ -389,7 +390,11 @@ export class Client {
console.info("No SETTINGS page, falling back to default", e);
settingsText = '```yaml\nindexPage: "[[index]]"\n```\n';
}
const settings = parseYamlSettings(settingsText!) as BuiltinSettings;
let settings = parseYamlSettings(settingsText!) as BuiltinSettings;
settings = expandPropertyNames(settings);
console.log("Settings", settings);
if (!settings.indexPage) {
settings.indexPage = "[[index]]";
+2
View File
@@ -96,6 +96,7 @@ export class ClientSystem {
const plug = await this.system.load(
new URL(`/${fileName}`, location.href),
createSandbox,
this.editor.settings.plugOverrides,
);
if ((plug.manifest! as Manifest).syntax) {
// If there are syntax extensions, rebuild the markdown parser immediately
@@ -154,6 +155,7 @@ export class ClientSystem {
await this.system.load(
new URL(plugName, location.origin),
createSandbox,
this.editor.settings.plugOverrides,
);
} catch (e: any) {
console.error("Could not load plug", plugName, "error:", e.message);
+1 -1
View File
@@ -10,7 +10,7 @@ import { FunctionalComponent } from "https://esm.sh/v99/preact@10.11.3/src/index
import { FeatherProps } from "https://esm.sh/v99/preact-feather@4.2.1/dist/types";
import { MiniEditor } from "./mini_editor.tsx";
import { fuzzySearchAndSort } from "./fuse_search.ts";
import { deepEqual } from "../../common/util.ts";
import { deepEqual } from "$sb/lib/json.ts";
export function FilterList({
placeholder,
+3 -1
View File
@@ -1,3 +1,4 @@
import { Manifest } from "../common/manifest.ts";
import { AppCommand } from "./hooks/command.ts";
export type PageMeta = {
@@ -33,9 +34,10 @@ export type PanelMode = number;
export type BuiltinSettings = {
indexPage: string;
customStyles?: string;
plugOverrides?: Record<string, Partial<Manifest>>;
// Format: compatible with docker ignore
spaceIgnore?: string;
customStyles?: string;
};
export type PanelConfig = {