1
0

Preparing for an initial release

This commit is contained in:
Zef Hemel
2022-06-28 14:14:15 +02:00
parent be92bf2311
commit 16fcd91d6c
73 changed files with 3205 additions and 20734 deletions
+9 -8
View File
@@ -6,22 +6,23 @@ import { HttpSpacePrimitives } from "@silverbulletmd/common/spaces/http_space_pr
safeRun(async () => {
// let localSpace = new Space(new IndexedDBSpacePrimitives("pages"), true);
// localSpace.watch();
let token: string | undefined = localStorage.getItem("token") || undefined;
let password: string | undefined =
localStorage.getItem("password") || undefined;
let httpPrimitives = new HttpSpacePrimitives("", token);
let httpPrimitives = new HttpSpacePrimitives("", password);
while (true) {
try {
await httpPrimitives.getPageMeta("start");
await httpPrimitives.getPageMeta("index");
break;
} catch (e: any) {
if (e.message === "Unauthorized") {
token = prompt("Token: ") || undefined;
if (!token) {
alert("Sorry, that's it then");
password = prompt("Password: ") || undefined;
if (!password) {
alert("Sorry, need a password");
return;
}
localStorage.setItem("token", token!);
httpPrimitives = new HttpSpacePrimitives("", token);
localStorage.setItem("password", password!);
httpPrimitives = new HttpSpacePrimitives("", password);
}
}
}
+60
View File
@@ -0,0 +1,60 @@
import { EditorSelection, StateCommand, Transaction } from "@codemirror/state";
import { Text } from "@codemirror/state";
export function insertMarker(marker: string): StateCommand {
return ({ state, dispatch }) => {
const changes = state.changeByRange((range) => {
const isBoldBefore =
state.sliceDoc(range.from - marker.length, range.from) === marker;
const isBoldAfter =
state.sliceDoc(range.to, range.to + marker.length) === marker;
const changes = [];
changes.push(
isBoldBefore
? {
from: range.from - marker.length,
to: range.from,
insert: Text.of([""]),
}
: {
from: range.from,
insert: Text.of([marker]),
}
);
changes.push(
isBoldAfter
? {
from: range.to,
to: range.to + marker.length,
insert: Text.of([""]),
}
: {
from: range.to,
insert: Text.of([marker]),
}
);
const extendBefore = isBoldBefore ? -marker.length : marker.length;
const extendAfter = isBoldAfter ? -marker.length : marker.length;
return {
changes,
range: EditorSelection.range(
range.from + extendBefore,
range.to + extendAfter
),
};
});
dispatch(
state.update(changes, {
scrollIntoView: true,
annotations: Transaction.userEvent.of("input"),
})
);
return true;
};
}
+1 -1
View File
@@ -221,7 +221,7 @@ export class Editor {
});
if (this.pageNavigator.getCurrentPage() === "") {
await this.pageNavigator.navigate("start");
await this.pageNavigator.navigate("index");
}
await this.reloadPlugs();
}
+6 -2
View File
@@ -4,7 +4,7 @@
"name": "Zef Hemel",
"email": "zef@zef.me"
},
"version": "0.0.2",
"version": "0.0.7",
"license": "MIT",
"scripts": {
"watch": "rm -rf .parcel-cache && parcel watch",
@@ -41,12 +41,16 @@
"@jest/globals": "^27.5.1",
"@lezer/highlight": "1.0.0",
"@lezer/markdown": "1.0.0",
"@silverbulletmd/common": "^0.0.7",
"@silverbulletmd/plugs": "^0.0.7",
"@silverbulletmd/web": "^0.0.7",
"fake-indexeddb": "^3.1.7",
"fuzzysort": "^1.9.0",
"jest": "^27.5.1",
"knex": "^1.0.4",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react-dom": "^17.0.2",
"server": "^1.0.37"
},
"devDependencies": {
"@parcel/packager-raw-url": "2.5.0",
+2 -2
View File
@@ -21,9 +21,9 @@ export function spaceSyscalls(editor: Editor): SysCallMapping {
return await editor.space.writePage(name, text);
},
"space.deletePage": async (ctx, name: string) => {
// If we're deleting the current page, navigate to the start page
// If we're deleting the current page, navigate to the index page
if (editor.currentPage === name) {
await editor.navigate("start");
await editor.navigate("index");
}
// Remove page from open pages in editor
editor.openPages.delete(name);