This commit is contained in:
+8
-8
@@ -1,10 +1,10 @@
|
||||
export const PAGES_CHANGED = 'computer:pages-changed'
|
||||
export const PAGES_CHANGED = 'superbrain:pages-changed'
|
||||
|
||||
export const notifyPagesChanged = () => window.dispatchEvent(new Event(PAGES_CHANGED))
|
||||
|
||||
// Notion-style breadcrumbs: the pages workspace announces which page is open
|
||||
// so the top bar can show "computer / Pages / <title>" without refetching.
|
||||
export const ACTIVE_PAGE_CHANGED = 'computer:active-page-changed'
|
||||
// so the top bar can show "superbrain / Pages / <title>" without refetching.
|
||||
export const ACTIVE_PAGE_CHANGED = 'superbrain:active-page-changed'
|
||||
|
||||
export const notifyActivePage = (title: string | null) =>
|
||||
window.dispatchEvent(new CustomEvent<string | null>(ACTIVE_PAGE_CHANGED, { detail: title }))
|
||||
@@ -20,15 +20,15 @@ export type PageSummary = {
|
||||
|
||||
// Connected pages (phase 3): the same link forms the editor understands,
|
||||
// shared by the page client, sidebar and Markdown preview. Page links use
|
||||
// `computer:page/<id>`; /pages?id=<id> is accepted for hand-written links.
|
||||
// `superbrain:page/<id>`; /pages?id=<id> is accepted for hand-written links.
|
||||
export function internalPageId(href: string): string | null {
|
||||
const value = href.trim().replace(/^<|>$/g, '')
|
||||
let raw = ''
|
||||
if (value.startsWith('computer://page/')) raw = value.slice('computer://page/'.length)
|
||||
else if (value.startsWith('computer:page/')) raw = value.slice('computer:page/'.length)
|
||||
if (value.startsWith('superbrain://page/')) raw = value.slice('superbrain://page/'.length)
|
||||
else if (value.startsWith('superbrain:page/')) raw = value.slice('superbrain:page/'.length)
|
||||
else if (value.startsWith('page/')) raw = value.slice('page/'.length)
|
||||
else if (value.startsWith('/pages/')) raw = value.slice('/pages/'.length)
|
||||
else if (value.startsWith('/pages?') || value.startsWith('computer:page?id=') || value.startsWith('computer://page?id=')) {
|
||||
else if (value.startsWith('/pages?') || value.startsWith('superbrain:page?id=') || value.startsWith('superbrain://page?id=')) {
|
||||
try {
|
||||
const id = new URL(value, 'http://localhost').searchParams.get('id')
|
||||
raw = id ?? ''
|
||||
@@ -39,7 +39,7 @@ export function internalPageId(href: string): string | null {
|
||||
}
|
||||
|
||||
export const pageLinkMarkdown = (page: Pick<PageSummary, 'id' | 'title'>) =>
|
||||
`[${page.title.replace(/[\[\]\n]/g, ' ')}](computer:page/${page.id})`
|
||||
`[${page.title.replace(/[\[\]\n]/g, ' ')}](superbrain:page/${page.id})`
|
||||
|
||||
export type PageEmbedMarker = { collectionId: string; viewId: string | null }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user