From b615ccdff7fcdd27c0ca5226b3ae47c2313e147c Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Wed, 12 Jul 2023 11:06:59 +0200 Subject: [PATCH] Don't mark plug-space links as non-existent in the editor --- web/cm_plugins/wiki_link.ts | 7 +++++-- web/editor.tsx | 10 ++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/web/cm_plugins/wiki_link.ts b/web/cm_plugins/wiki_link.ts index 83af63ee..97fcfeb8 100644 --- a/web/cm_plugins/wiki_link.ts +++ b/web/cm_plugins/wiki_link.ts @@ -40,8 +40,11 @@ export function cleanWikiLinkPlugin(editor: Editor) { break; } } - if (cleanPage === "" || cleanPage.startsWith("💭")) { - // Empty page name, or local @anchor use + if ( + cleanPage === "" || + editor.plugSpaceRemotePrimitives.isLikelyHandled(cleanPage) + ) { + // Empty page name with local @anchor use or a link to a page that dynamically generated by a plug pageExists = true; } diff --git a/web/editor.tsx b/web/editor.tsx index 9bf0f9ed..dcd72be5 100644 --- a/web/editor.tsx +++ b/web/editor.tsx @@ -166,8 +166,10 @@ export class Editor { editorView?: EditorView; viewState: AppViewState = initialViewState; viewDispatch: (action: Action) => void = () => {}; + space: Space; remoteSpacePrimitives: HttpSpacePrimitives; + plugSpaceRemotePrimitives: PlugSpacePrimitives; pageNavigator?: PathPageNavigator; eventHook: EventHook; @@ -235,7 +237,7 @@ export class Editor { true, ); - const plugSpaceRemotePrimitives = new PlugSpacePrimitives( + this.plugSpaceRemotePrimitives = new PlugSpacePrimitives( this.remoteSpacePrimitives, namespaceHook, ); @@ -250,7 +252,7 @@ export class Editor { `${dbPrefix}_space`, globalThis.indexedDB, ), - plugSpaceRemotePrimitives, + this.plugSpaceRemotePrimitives, ), this.eventHook, ), @@ -272,14 +274,14 @@ export class Editor { this.syncService = new SyncService( localSpacePrimitives, - plugSpaceRemotePrimitives, + this.plugSpaceRemotePrimitives, this.kvStore, this.eventHook, (path) => { // TODO: At some point we should remove the data.db exception here return path !== "data.db" && // Exclude all plug space primitives paths - !plugSpaceRemotePrimitives.isLikelyHandled(path) || + !this.plugSpaceRemotePrimitives.isLikelyHandled(path) || // Except federated ones path.startsWith("!"); },