No More Collab. Fixes #449
* Fully removes real-time collaboration * URL scheme rewrite
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
export function isValidPageName(name: string): boolean {
|
||||
// Page can not be empty and not end with a file extension (e.g. "bla.md")
|
||||
return name !== "" && !/\.[a-zA-Z]+$/.test(name);
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
import { readYamlPage } from "./yaml_page.ts";
|
||||
import { notifyUser } from "./util.ts";
|
||||
import { readYamlPage } from "$sb/lib/yaml_page.ts";
|
||||
import { YAML } from "$sb/plugos-syscall/mod.ts";
|
||||
|
||||
import { space } from "$sb/silverbullet-syscall/mod.ts";
|
||||
import { editor, space } from "$sb/silverbullet-syscall/mod.ts";
|
||||
|
||||
/**
|
||||
* Convenience function to read a specific set of settings from the `SETTINGS` page as well as default values
|
||||
@@ -65,7 +64,7 @@ export async function writeSettings<T extends object>(settings: T) {
|
||||
try {
|
||||
readSettings = (await readYamlPage(SETTINGS_PAGE, ["yaml"])) || {};
|
||||
} catch {
|
||||
await notifyUser("Creating a new SETTINGS page...", "info");
|
||||
await editor.flashNotification("Creating a new SETTINGS page...", "info");
|
||||
}
|
||||
const writeSettings: any = { ...readSettings, ...settings };
|
||||
// const doc = new YAML.Document();
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
import { editor } from "$sb/silverbullet-syscall/mod.ts";
|
||||
|
||||
export async function replaceAsync(
|
||||
str: string,
|
||||
regex: RegExp,
|
||||
asyncFn: (match: string, ...args: any[]) => Promise<string>,
|
||||
) {
|
||||
const promises: Promise<string>[] = [];
|
||||
str.replace(regex, (match: string, ...args: any[]): string => {
|
||||
const promise = asyncFn(match, ...args);
|
||||
promises.push(promise);
|
||||
return "";
|
||||
});
|
||||
const data = await Promise.all(promises);
|
||||
return str.replace(regex, () => data.shift()!);
|
||||
}
|
||||
|
||||
export function isServer() {
|
||||
return (
|
||||
typeof window === "undefined" || typeof window.document === "undefined"
|
||||
); // if something defines window the same way as the browser, this will fail.
|
||||
}
|
||||
|
||||
// this helps keep if's condition as positive
|
||||
export function isBrowser() {
|
||||
return !isServer();
|
||||
}
|
||||
|
||||
export function notifyUser(message: string, type?: "info" | "error") {
|
||||
if (isBrowser()) {
|
||||
return editor.flashNotification(message, type);
|
||||
}
|
||||
const log = type === "error" ? console.error : console.log;
|
||||
log(message); // we should end up sending the message to the user, users dont read logs.
|
||||
return;
|
||||
}
|
||||
Reference in New Issue
Block a user