diff --git a/plugs/markdown/markdown_render.ts b/plugs/markdown/markdown_render.ts index 313b1bd..d8f7f0f 100644 --- a/plugs/markdown/markdown_render.ts +++ b/plugs/markdown/markdown_render.ts @@ -245,10 +245,11 @@ function render( if (aliasNode) { linkText = aliasNode.children![0].text!; } + const [pageName] = ref.split(/[@$]/); return { name: "a", attrs: { - href: `/${ref.replace("@", "#")}`, + href: `/${pageName}`, class: "wiki-link", "data-ref": ref, }, diff --git a/server/http_server.ts b/server/http_server.ts index 4ac2587..80e8e56 100644 --- a/server/http_server.ts +++ b/server/http_server.ts @@ -183,7 +183,6 @@ export class HttpServer { if (!this.clientAssetBundle.has(assetName)) { return next(); } - console.log("Asset name", assetName); if ( this.clientAssetBundle.has(assetName) && req.header("If-Modified-Since") === @@ -205,7 +204,6 @@ export class HttpServer { utcDateString(this.clientAssetBundle.getMtime(assetName)), ); } - // console.log("Serving it now", assetName); if (req.method === "GET") { if (assetName === "service_worker.js") { diff --git a/web/cm_plugins/markdown_widget.ts b/web/cm_plugins/markdown_widget.ts index 16eca17..3f579a5 100644 --- a/web/cm_plugins/markdown_widget.ts +++ b/web/cm_plugins/markdown_widget.ts @@ -141,6 +141,10 @@ export class MarkdownWidget extends WidgetType { const el = el_ as HTMLElement; // Override default click behavior with a local navigate (faster) el.addEventListener("click", (e) => { + if (e.ctrlKey || e.metaKey) { + // Don't do anything special for ctrl/meta clicks + return; + } e.preventDefault(); e.stopPropagation(); const [pageName, pos] = el.dataset.ref!.split(/[$@]/); diff --git a/web/cm_plugins/util.ts b/web/cm_plugins/util.ts index c59c11d..4404425 100644 --- a/web/cm_plugins/util.ts +++ b/web/cm_plugins/util.ts @@ -31,6 +31,9 @@ export class LinkWidget extends WidgetType { // Mouse handling anchor.addEventListener("mousedown", (e) => { + if (e.button !== 0) { + return; + } e.preventDefault(); e.stopPropagation(); this.options.callback(e); diff --git a/web/editor_state.ts b/web/editor_state.ts index ca17ae4..cd8ec84 100644 --- a/web/editor_state.ts +++ b/web/editor_state.ts @@ -298,11 +298,14 @@ export function createEditorState( }, mousedown: (event: MouseEvent, view: EditorView) => { + const pos = view.posAtCoords(event); + if (event.button !== 0) { + return; + } + if (!pos) { + return; + } safeRun(async () => { - const pos = view.posAtCoords(event); - if (!pos) { - return; - } const potentialClickEvent: ClickEvent = { page: pageName, ctrlKey: event.ctrlKey,