@crossworks/content-core 0.300.65 → 0.300.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/markdown-refs.ts +14 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crossworks/content-core",
|
|
3
|
-
"version": "0.300.
|
|
3
|
+
"version": "0.300.66",
|
|
4
4
|
"description": "Browser-safe content logic — markdown, blocks, pages, tables, formulas — shared by the server and any client. Zero server deps by design: nothing here may reach @mantle/db, node-only APIs, or the network (the jackdaw-repo-split P0 boundary).",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./app-nav": "./src/app-nav.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"./tree": "./src/tree.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@mantle/client-types": "npm:@crossworks/client-types@0.300.
|
|
36
|
+
"@mantle/client-types": "npm:@crossworks/client-types@0.300.66",
|
|
37
37
|
"marked": "^18.1.0",
|
|
38
38
|
"mathjs": "15.2.0"
|
|
39
39
|
},
|
package/src/markdown-refs.ts
CHANGED
|
@@ -91,13 +91,22 @@ export function inlineMediaImageIds(source: string | undefined | null): Set<stri
|
|
|
91
91
|
return ids;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/** The node type each scheme requires (`mention:node:` takes any node, so it
|
|
95
|
+
* has none): the one place the scheme names a kind (A10 #12). */
|
|
96
|
+
const SCHEME_NODE_TYPE = {
|
|
97
|
+
media: 'file',
|
|
98
|
+
page: 'page',
|
|
99
|
+
draw: 'draw',
|
|
100
|
+
folder: 'branch',
|
|
101
|
+
} as const;
|
|
102
|
+
|
|
94
103
|
/** A reference-link target found in a markdown source: which scheme it used,
|
|
95
104
|
* the id it points at, and the node type that scheme requires (unset ⇒ any
|
|
96
105
|
* node). `nodeType` is what makes a wrong-type reference reportable. */
|
|
97
106
|
export type MarkdownRef = {
|
|
98
107
|
scheme: 'media' | 'page' | 'mention' | 'draw' | 'folder';
|
|
99
108
|
id: string;
|
|
100
|
-
nodeType?:
|
|
109
|
+
nodeType?: (typeof SCHEME_NODE_TYPE)[keyof typeof SCHEME_NODE_TYPE];
|
|
101
110
|
};
|
|
102
111
|
|
|
103
112
|
/** Any markdown link or image, capturing the href. */
|
|
@@ -122,15 +131,15 @@ export function markdownRefs(source: string | undefined | null): MarkdownRef[] {
|
|
|
122
131
|
if (!href) continue;
|
|
123
132
|
let ref: MarkdownRef | null = null;
|
|
124
133
|
const media = MEDIA_HREF.exec(href);
|
|
125
|
-
if (media?.[1]) ref = { scheme: 'media', id: media[1], nodeType:
|
|
134
|
+
if (media?.[1]) ref = { scheme: 'media', id: media[1], nodeType: SCHEME_NODE_TYPE.media };
|
|
126
135
|
const page = PAGE_HREF.exec(href);
|
|
127
|
-
if (page?.[1]) ref = { scheme: 'page', id: page[1], nodeType:
|
|
136
|
+
if (page?.[1]) ref = { scheme: 'page', id: page[1], nodeType: SCHEME_NODE_TYPE.page };
|
|
128
137
|
const draw = DRAW_HREF.exec(href);
|
|
129
|
-
if (draw?.[1]) ref = { scheme: 'draw', id: draw[1], nodeType:
|
|
138
|
+
if (draw?.[1]) ref = { scheme: 'draw', id: draw[1], nodeType: SCHEME_NODE_TYPE.draw };
|
|
130
139
|
// A Folder index names a folder row; `folder:here` names none.
|
|
131
140
|
const folder = FOLDER_HREF.exec(href);
|
|
132
141
|
if (folder?.[1] && folder[1] !== FOLDER_HERE) {
|
|
133
|
-
ref = { scheme: 'folder', id: folder[1], nodeType:
|
|
142
|
+
ref = { scheme: 'folder', id: folder[1], nodeType: SCHEME_NODE_TYPE.folder };
|
|
134
143
|
}
|
|
135
144
|
const mention = MENTION_HREF.exec(href);
|
|
136
145
|
// Bare `mention:<id>` defaults to an entity — skip; only `mention:node:` is
|