1
0

Don't mark plug-space links as non-existent in the editor

This commit is contained in:
Zef Hemel 2023-07-12 11:06:59 +02:00
parent 1818bfad00
commit b615ccdff7
2 changed files with 11 additions and 6 deletions

View File

@ -40,8 +40,11 @@ export function cleanWikiLinkPlugin(editor: Editor) {
break; break;
} }
} }
if (cleanPage === "" || cleanPage.startsWith("💭")) { if (
// Empty page name, or local @anchor use 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; pageExists = true;
} }

View File

@ -166,8 +166,10 @@ export class Editor {
editorView?: EditorView; editorView?: EditorView;
viewState: AppViewState = initialViewState; viewState: AppViewState = initialViewState;
viewDispatch: (action: Action) => void = () => {}; viewDispatch: (action: Action) => void = () => {};
space: Space; space: Space;
remoteSpacePrimitives: HttpSpacePrimitives; remoteSpacePrimitives: HttpSpacePrimitives;
plugSpaceRemotePrimitives: PlugSpacePrimitives;
pageNavigator?: PathPageNavigator; pageNavigator?: PathPageNavigator;
eventHook: EventHook; eventHook: EventHook;
@ -235,7 +237,7 @@ export class Editor {
true, true,
); );
const plugSpaceRemotePrimitives = new PlugSpacePrimitives( this.plugSpaceRemotePrimitives = new PlugSpacePrimitives(
this.remoteSpacePrimitives, this.remoteSpacePrimitives,
namespaceHook, namespaceHook,
); );
@ -250,7 +252,7 @@ export class Editor {
`${dbPrefix}_space`, `${dbPrefix}_space`,
globalThis.indexedDB, globalThis.indexedDB,
), ),
plugSpaceRemotePrimitives, this.plugSpaceRemotePrimitives,
), ),
this.eventHook, this.eventHook,
), ),
@ -272,14 +274,14 @@ export class Editor {
this.syncService = new SyncService( this.syncService = new SyncService(
localSpacePrimitives, localSpacePrimitives,
plugSpaceRemotePrimitives, this.plugSpaceRemotePrimitives,
this.kvStore, this.kvStore,
this.eventHook, this.eventHook,
(path) => { (path) => {
// TODO: At some point we should remove the data.db exception here // TODO: At some point we should remove the data.db exception here
return path !== "data.db" && return path !== "data.db" &&
// Exclude all plug space primitives paths // Exclude all plug space primitives paths
!plugSpaceRemotePrimitives.isLikelyHandled(path) || !this.plugSpaceRemotePrimitives.isLikelyHandled(path) ||
// Except federated ones // Except federated ones
path.startsWith("!"); path.startsWith("!");
}, },