Fixes #640
This commit is contained in:
@@ -28,7 +28,7 @@ export function cleanModePlugins(client: Client) {
|
||||
// TODO: Move this logic elsewhere?
|
||||
onCheckboxClick: (pos) => {
|
||||
const clickEvent: ClickEvent = {
|
||||
page: client.currentPage!,
|
||||
page: client.currentPage,
|
||||
altKey: false,
|
||||
ctrlKey: false,
|
||||
metaKey: false,
|
||||
|
||||
@@ -55,7 +55,7 @@ export function cleanCommandLinkPlugin(editor: Client) {
|
||||
}
|
||||
// Dispatch click event to navigate there without moving the cursor
|
||||
const clickEvent: ClickEvent = {
|
||||
page: editor.currentPage!,
|
||||
page: editor.currentPage,
|
||||
ctrlKey: e.ctrlKey,
|
||||
metaKey: e.metaKey,
|
||||
altKey: e.altKey,
|
||||
|
||||
@@ -215,7 +215,7 @@ export function attachmentExtension(editor: Client) {
|
||||
return;
|
||||
}
|
||||
await editor.space.writeAttachment(
|
||||
resolve(folderName(editor.currentPage!), finalFileName),
|
||||
resolve(folderName(editor.currentPage), finalFileName),
|
||||
new Uint8Array(data),
|
||||
);
|
||||
let attachmentMarkdown = `[${finalFileName}](${encodeURI(finalFileName)})`;
|
||||
|
||||
@@ -22,7 +22,7 @@ export class IFrameWidget extends WidgetType {
|
||||
const iframe = createWidgetSandboxIFrame(
|
||||
this.client,
|
||||
this.bodyText,
|
||||
this.codeWidgetCallback(this.bodyText, this.client.currentPage!),
|
||||
this.codeWidgetCallback(this.bodyText, this.client.currentPage),
|
||||
(message) => {
|
||||
switch (message.type) {
|
||||
case "blur":
|
||||
@@ -33,7 +33,7 @@ export class IFrameWidget extends WidgetType {
|
||||
|
||||
break;
|
||||
case "reload":
|
||||
this.codeWidgetCallback(this.bodyText, this.client.currentPage!)
|
||||
this.codeWidgetCallback(this.bodyText, this.client.currentPage)
|
||||
.then(
|
||||
(widgetContent: WidgetContent | null) => {
|
||||
if (widgetContent === null) {
|
||||
|
||||
@@ -33,7 +33,7 @@ class InlineImageWidget extends WidgetType {
|
||||
toDOM() {
|
||||
const img = document.createElement("img");
|
||||
let url = this.url;
|
||||
url = resolvePath(this.client.currentPage!, url, true);
|
||||
url = resolvePath(this.client.currentPage, url, true);
|
||||
// console.log("Creating DOM", this.url);
|
||||
const cachedImageHeight = this.client.getCachedWidgetHeight(
|
||||
`image:${this.url}`,
|
||||
@@ -79,7 +79,7 @@ export function inlineImagesPlugin(client: Client) {
|
||||
const title = imageRexexResult.groups.title;
|
||||
|
||||
if (url.indexOf("://") === -1 && !url.startsWith("/")) {
|
||||
url = resolveAttachmentPath(client.currentPage!, decodeURI(url));
|
||||
url = resolveAttachmentPath(client.currentPage, decodeURI(url));
|
||||
}
|
||||
widgets.push(
|
||||
Decoration.widget({
|
||||
|
||||
@@ -37,7 +37,7 @@ export function linkPlugin(client: Client) {
|
||||
|
||||
if (!cleanLink.includes("://")) {
|
||||
cleanLink = resolveAttachmentPath(
|
||||
client.currentPage!,
|
||||
client.currentPage,
|
||||
decodeURI(cleanLink),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ export function plugLinter(client: Client) {
|
||||
view.state.sliceDoc(),
|
||||
);
|
||||
const results = (await client.dispatchAppEvent("editor:lint", {
|
||||
name: client.currentPage!,
|
||||
name: client.currentPage,
|
||||
tree: tree,
|
||||
} as LintEvent)).flat();
|
||||
return results;
|
||||
|
||||
@@ -48,7 +48,7 @@ export class MarkdownWidget extends WidgetType {
|
||||
) {
|
||||
const widgetContent = await this.codeWidgetCallback(
|
||||
this.bodyText,
|
||||
this.client.currentPage!,
|
||||
this.client.currentPage,
|
||||
);
|
||||
activeWidgets.add(this);
|
||||
if (!widgetContent) {
|
||||
@@ -79,7 +79,7 @@ export class MarkdownWidget extends WidgetType {
|
||||
translateUrls: (url) => {
|
||||
if (!url.includes("://")) {
|
||||
url = resolveAttachmentPath(
|
||||
this.client.currentPage!,
|
||||
this.client.currentPage,
|
||||
decodeURI(url),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class TableViewWidget extends WidgetType {
|
||||
annotationPositions: true,
|
||||
translateUrls: (url) => {
|
||||
if (!url.includes("://")) {
|
||||
url = resolveAttachmentPath(this.client.currentPage!, decodeURI(url));
|
||||
url = resolveAttachmentPath(this.client.currentPage, decodeURI(url));
|
||||
}
|
||||
|
||||
return url;
|
||||
|
||||
+10
-11
@@ -9,7 +9,7 @@ import {
|
||||
LinkWidget,
|
||||
} from "./util.ts";
|
||||
import { resolvePath } from "$sb/lib/resolve.ts";
|
||||
import { parsePageRef } from "$sb/lib/page.ts";
|
||||
import { encodePageRef, parsePageRef } from "$sb/lib/page.ts";
|
||||
|
||||
/**
|
||||
* Plugin to hide path prefix when the cursor is not inside.
|
||||
@@ -30,10 +30,9 @@ export function cleanWikiLinkPlugin(client: Client) {
|
||||
const [_fullMatch, page, pipePart, alias] = match;
|
||||
|
||||
let pageExists = !client.fullSyncCompleted;
|
||||
let cleanPage = page;
|
||||
cleanPage = parsePageRef(page).page;
|
||||
cleanPage = resolvePath(client.currentPage!, cleanPage);
|
||||
const lowerCasePageName = cleanPage.toLowerCase();
|
||||
const pageRef = parsePageRef(page);
|
||||
pageRef.page = resolvePath(client.currentPage, pageRef.page);
|
||||
const lowerCasePageName = pageRef.page.toLowerCase();
|
||||
for (const pageName of client.allKnownPages) {
|
||||
if (pageName.toLowerCase() === lowerCasePageName) {
|
||||
pageExists = true;
|
||||
@@ -41,8 +40,8 @@ export function cleanWikiLinkPlugin(client: Client) {
|
||||
}
|
||||
}
|
||||
if (
|
||||
cleanPage === "" ||
|
||||
client.plugSpaceRemotePrimitives.isLikelyHandled(cleanPage)
|
||||
pageRef.page === "" ||
|
||||
client.plugSpaceRemotePrimitives.isLikelyHandled(pageRef.page)
|
||||
) {
|
||||
// Empty page name with local @anchor use or a link to a page that dynamically generated by a plug
|
||||
pageExists = true;
|
||||
@@ -81,9 +80,9 @@ export function cleanWikiLinkPlugin(client: Client) {
|
||||
{
|
||||
text: linkText,
|
||||
title: pageExists
|
||||
? `Navigate to ${cleanPage}`
|
||||
: `Create ${cleanPage}`,
|
||||
href: `/${cleanPage}`,
|
||||
? `Navigate to ${encodePageRef(pageRef)}`
|
||||
: `Create ${pageRef.page}`,
|
||||
href: `/${encodePageRef(pageRef)}`,
|
||||
cssClass: pageExists
|
||||
? "sb-wiki-link-page"
|
||||
: "sb-wiki-link-page-missing",
|
||||
@@ -96,7 +95,7 @@ export function cleanWikiLinkPlugin(client: Client) {
|
||||
}
|
||||
// Dispatch click event to navigate there without moving the cursor
|
||||
const clickEvent: ClickEvent = {
|
||||
page: client.currentPage!,
|
||||
page: client.currentPage,
|
||||
ctrlKey: e.ctrlKey,
|
||||
metaKey: e.metaKey,
|
||||
altKey: e.altKey,
|
||||
|
||||
Reference in New Issue
Block a user