SilverBullet pivot to become an offline-first PWA (#403)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { ClickEvent } from "../../plug-api/app_event.ts";
|
||||
import type { Extension } from "../deps.ts";
|
||||
import { Editor } from "../editor.tsx";
|
||||
import type { Editor } from "../editor.tsx";
|
||||
import { blockquotePlugin } from "./block_quote.ts";
|
||||
import { admonitionPlugin } from "./admonition.ts";
|
||||
import { directivePlugin } from "./directive.ts";
|
||||
@@ -16,7 +16,7 @@ import { fencedCodePlugin } from "./fenced_code.ts";
|
||||
|
||||
export function cleanModePlugins(editor: Editor) {
|
||||
return [
|
||||
linkPlugin(editor),
|
||||
linkPlugin(),
|
||||
directivePlugin(),
|
||||
blockquotePlugin(),
|
||||
admonitionPlugin(editor),
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { EditorView, ViewPlugin, ViewUpdate } from "../deps.ts";
|
||||
import { safeRun } from "../../plugos/util.ts";
|
||||
import { maximumAttachmentSize } from "../../common/types.ts";
|
||||
import { Editor } from "../editor.tsx";
|
||||
|
||||
@@ -11,6 +10,7 @@ import {
|
||||
tables,
|
||||
taskListItems,
|
||||
} from "https://cdn.skypack.dev/@joplin/turndown-plugin-gfm@1.0.45";
|
||||
import { safeRun } from "../../common/util.ts";
|
||||
const turndownService = new TurndownService({
|
||||
hr: "---",
|
||||
codeBlockStyle: "fenced",
|
||||
@@ -138,6 +138,7 @@ export function attachmentExtension(editor: Editor) {
|
||||
|
||||
async function processFileTransfer(payload: File[]) {
|
||||
const data = await payload[0].arrayBuffer();
|
||||
// data.byteLength > maximumAttachmentSize;
|
||||
await saveFile(data!, payload[0].name, payload[0].type);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,10 +72,6 @@ class IFrameWidget extends WidgetType {
|
||||
html: widgetContent.html,
|
||||
script: widgetContent.script,
|
||||
});
|
||||
// iframe.contentWindow!.onunload = () => {
|
||||
// // Unsubscribing from events
|
||||
// globalThis.removeEventListener("message", messageListener);
|
||||
// };
|
||||
} else if (widgetContent.url) {
|
||||
iframe.contentWindow!.location.href = widgetContent.url;
|
||||
if (widgetContent.height) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from "../deps.ts";
|
||||
import { decoratorStateField } from "./util.ts";
|
||||
|
||||
import type { Space } from "../../common/spaces/space.ts";
|
||||
import type { Space } from "../space.ts";
|
||||
|
||||
class InlineImageWidget extends WidgetType {
|
||||
constructor(
|
||||
@@ -27,12 +27,8 @@ class InlineImageWidget extends WidgetType {
|
||||
if (this.url.startsWith("http")) {
|
||||
img.src = this.url;
|
||||
} else {
|
||||
// Load the image as a dataURL and inject it into the img's src attribute
|
||||
this.space.readAttachment(decodeURIComponent(this.url), "dataurl").then(
|
||||
({ data }) => {
|
||||
img.src = data as string;
|
||||
},
|
||||
);
|
||||
// This is an attachment image, rewrite the URL a little
|
||||
img.src = `/.fs/${decodeURIComponent(this.url)}`;
|
||||
}
|
||||
|
||||
img.alt = this.title;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { Decoration, syntaxTree } from "../deps.ts";
|
||||
import { Editor } from "../editor.tsx";
|
||||
import {
|
||||
decoratorStateField,
|
||||
invisibleDecoration,
|
||||
isCursorInRange,
|
||||
} from "./util.ts";
|
||||
|
||||
export function linkPlugin(editor: Editor) {
|
||||
export function linkPlugin() {
|
||||
return decoratorStateField((state) => {
|
||||
const widgets: any[] = [];
|
||||
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
import {
|
||||
Decoration,
|
||||
EditorState,
|
||||
EditorView,
|
||||
syntaxTree,
|
||||
WidgetType,
|
||||
} from "../deps.ts";
|
||||
import { Decoration, EditorState, syntaxTree, WidgetType } from "../deps.ts";
|
||||
import {
|
||||
decoratorStateField,
|
||||
invisibleDecoration,
|
||||
@@ -15,7 +9,6 @@ import { renderMarkdownToHtml } from "../../plugs/markdown/markdown_render.ts";
|
||||
import { ParseTree } from "$sb/lib/tree.ts";
|
||||
import { lezerToParseTree } from "../../common/markdown_parser/parse_tree.ts";
|
||||
import type { Editor } from "../editor.tsx";
|
||||
import { urlToPathname } from "../../plugos/util.ts";
|
||||
|
||||
class TableViewWidget extends WidgetType {
|
||||
constructor(
|
||||
|
||||
@@ -28,7 +28,7 @@ export function cleanWikiLinkPlugin(editor: Editor) {
|
||||
const [_fullMatch, page, pipePart, alias] = match;
|
||||
|
||||
const allPages = editor.space.listPages();
|
||||
let pageExists = false;
|
||||
let pageExists = !editor.fullSyncCompleted;
|
||||
let cleanPage = page;
|
||||
if (page.includes("@")) {
|
||||
cleanPage = page.split("@")[0];
|
||||
@@ -77,7 +77,7 @@ export function cleanWikiLinkPlugin(editor: Editor) {
|
||||
{
|
||||
text: linkText,
|
||||
title: pageExists ? `Navigate to ${page}` : `Create ${page}`,
|
||||
href: `/${page.replaceAll(" ", "_")}`,
|
||||
href: `/${page}`,
|
||||
cssClass: pageExists
|
||||
? "sb-wiki-link-page"
|
||||
: "sb-wiki-link-page-missing",
|
||||
|
||||
Reference in New Issue
Block a user