@seed-hypermedia/client 0.0.97 → 0.0.98
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/dist/{chunk-Y3HCUNXC.mjs → chunk-6YBRBK6F.mjs} +15 -6
- package/dist/{chunk-QVRJGK77.mjs → chunk-K5NYTWBJ.mjs} +30 -1
- package/dist/comment.mjs +1 -1
- package/dist/hm-types.d.ts +3 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +4 -2
- package/dist/markdown-to-blocks.d.ts +10 -0
- package/dist/markdown-to-blocks.mjs +3 -1
- package/package.json +1 -1
|
@@ -43,7 +43,7 @@ function resolveQuotingTarget(input) {
|
|
|
43
43
|
function annotationsToPublishable(annotations) {
|
|
44
44
|
validateExclusiveAnnotations(annotations);
|
|
45
45
|
return annotations.map((annotation) => {
|
|
46
|
-
var _a, _b, _c, _d;
|
|
46
|
+
var _a, _b, _c, _d, _e;
|
|
47
47
|
const { type, starts, ends } = annotation;
|
|
48
48
|
if (type === "Bold") return { type: "Bold", starts, ends };
|
|
49
49
|
if (type === "Italic") return { type: "Italic", starts, ends };
|
|
@@ -51,20 +51,29 @@ function annotationsToPublishable(annotations) {
|
|
|
51
51
|
if (type === "Strike") return { type: "Strike", starts, ends };
|
|
52
52
|
if (type === "Code") return { type: "Code", starts, ends };
|
|
53
53
|
if (type === "Link") return { type: "Link", starts, ends, link: annotation.link || "" };
|
|
54
|
-
if (type === "Embed")
|
|
54
|
+
if (type === "Embed") {
|
|
55
|
+
const mentionKind = (_a = annotation.attributes) == null ? void 0 : _a.mentionKind;
|
|
56
|
+
return {
|
|
57
|
+
type: "Embed",
|
|
58
|
+
starts,
|
|
59
|
+
ends,
|
|
60
|
+
link: annotation.link || "",
|
|
61
|
+
...mentionKind === "account" || mentionKind === "document" ? { attributes: { mentionKind } } : {}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
55
64
|
if (type === "TextColor")
|
|
56
|
-
return { type: "TextColor", starts, ends, attributes: { value: ((
|
|
65
|
+
return { type: "TextColor", starts, ends, attributes: { value: ((_b = annotation.attributes) == null ? void 0 : _b.value) || "" } };
|
|
57
66
|
if (type === "BackgroundColor")
|
|
58
67
|
return {
|
|
59
68
|
type: "BackgroundColor",
|
|
60
69
|
starts,
|
|
61
70
|
ends,
|
|
62
|
-
attributes: { value: ((
|
|
71
|
+
attributes: { value: ((_c = annotation.attributes) == null ? void 0 : _c.value) || "" }
|
|
63
72
|
};
|
|
64
73
|
if (type === "TextSize")
|
|
65
|
-
return { type: "TextSize", starts, ends, attributes: { value: ((
|
|
74
|
+
return { type: "TextSize", starts, ends, attributes: { value: ((_d = annotation.attributes) == null ? void 0 : _d.value) || "" } };
|
|
66
75
|
if (type === "TextFamily")
|
|
67
|
-
return { type: "TextFamily", starts, ends, attributes: { value: ((
|
|
76
|
+
return { type: "TextFamily", starts, ends, attributes: { value: ((_e = annotation.attributes) == null ? void 0 : _e.value) || "" } };
|
|
68
77
|
throw new Error(`Unsupported annotation type: ${type}`);
|
|
69
78
|
});
|
|
70
79
|
}
|
|
@@ -134,8 +134,16 @@ function parseInlineFormatting(raw) {
|
|
|
134
134
|
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:\S*$/.test(inner) && !/[\s<>]/.test(inner)) {
|
|
135
135
|
const start = text.length;
|
|
136
136
|
if (inner.startsWith("hm://")) {
|
|
137
|
+
if (text.endsWith("@")) text = text.slice(0, -1);
|
|
138
|
+
const mentionStart = text.length;
|
|
137
139
|
text += "\uFFFC";
|
|
138
|
-
annotations.push({
|
|
140
|
+
annotations.push({
|
|
141
|
+
type: "Embed",
|
|
142
|
+
starts: [mentionStart],
|
|
143
|
+
ends: [text.length],
|
|
144
|
+
link: inner,
|
|
145
|
+
...hmAccountMentionUid(inner) ? { attributes: { mentionKind: "account" } } : {}
|
|
146
|
+
});
|
|
139
147
|
} else {
|
|
140
148
|
text += inner;
|
|
141
149
|
annotations.push({ type: "Link", starts: [start], ends: [text.length], link: inner });
|
|
@@ -157,6 +165,19 @@ function parseInlineFormatting(raw) {
|
|
|
157
165
|
if (ch === "[") {
|
|
158
166
|
const link = readLink(raw, i);
|
|
159
167
|
if (link) {
|
|
168
|
+
if (isMentionLabel(link.label) && /^hm:\/\//.test(link.url.trim())) {
|
|
169
|
+
const start2 = text.length;
|
|
170
|
+
text += "\uFFFC";
|
|
171
|
+
annotations.push({
|
|
172
|
+
type: "Embed",
|
|
173
|
+
starts: [start2],
|
|
174
|
+
ends: [text.length],
|
|
175
|
+
link: link.url.trim(),
|
|
176
|
+
attributes: { mentionKind: hmAccountMentionUid(link.url) ? "account" : "document" }
|
|
177
|
+
});
|
|
178
|
+
i = link.end;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
160
181
|
const parsed = parseInlineFormatting(link.label);
|
|
161
182
|
const start = text.length;
|
|
162
183
|
appendParsed(parsed);
|
|
@@ -202,6 +223,13 @@ function findBacktickRun(s, from, n) {
|
|
|
202
223
|
}
|
|
203
224
|
return -1;
|
|
204
225
|
}
|
|
226
|
+
function hmAccountMentionUid(url) {
|
|
227
|
+
const match = /^hm:\/\/([A-Za-z0-9]+)(?:\/(?::profile\/?)?)?$/.exec(url.trim());
|
|
228
|
+
return match ? match[1] : null;
|
|
229
|
+
}
|
|
230
|
+
function isMentionLabel(label) {
|
|
231
|
+
return /^\s*@/.test(label);
|
|
232
|
+
}
|
|
205
233
|
function readLink(s, open) {
|
|
206
234
|
let depth = 0;
|
|
207
235
|
let i = open;
|
|
@@ -864,6 +892,7 @@ function flattenToOperations(tree, parentId = "") {
|
|
|
864
892
|
|
|
865
893
|
export {
|
|
866
894
|
parseInlineFormatting,
|
|
895
|
+
hmAccountMentionUid,
|
|
867
896
|
mergeAdjacentAnnotations,
|
|
868
897
|
parseFrontmatter,
|
|
869
898
|
parseMarkdown,
|
package/dist/comment.mjs
CHANGED
package/dist/hm-types.d.ts
CHANGED
|
@@ -2740,6 +2740,9 @@ export type HMPublishableAnnotation = {
|
|
|
2740
2740
|
starts: number[];
|
|
2741
2741
|
ends: number[];
|
|
2742
2742
|
link: string;
|
|
2743
|
+
attributes?: {
|
|
2744
|
+
mentionKind?: 'account' | 'document';
|
|
2745
|
+
};
|
|
2743
2746
|
} | {
|
|
2744
2747
|
type: 'TextColor' | 'BackgroundColor' | 'TextSize' | 'TextFamily';
|
|
2745
2748
|
starts: number[];
|
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export { resolveIdWithClient } from './resource-read';
|
|
|
31
31
|
export type { ResolveIdWithClientOptions, ResolvedIdWithClient } from './resource-read';
|
|
32
32
|
export { fileToIpfsBlobs, filesToIpfsBlobs, resolveFileLinksInBlocks, hasFileLinks } from './file-to-ipfs';
|
|
33
33
|
export type { CollectedBlob } from './file-to-ipfs';
|
|
34
|
-
export { parseMarkdown, flattenToOperations, parseInlineFormatting, parseFrontmatter, markdownBlockNodesToHMBlockNodes, } from './markdown-to-blocks';
|
|
34
|
+
export { parseMarkdown, flattenToOperations, parseInlineFormatting, parseFrontmatter, markdownBlockNodesToHMBlockNodes, hmAccountMentionUid, } from './markdown-to-blocks';
|
|
35
35
|
export type { BlockNode, SeedBlock, Annotation } from './markdown-to-blocks';
|
|
36
36
|
export { blocksToMarkdown, emitFrontmatter, slugify, draftFilename, parseDraftFilename, documentToResolvedMarkdown, commentToResolvedMarkdown, contentToResolvedMarkdown, } from './blocks-to-markdown';
|
|
37
37
|
export type { ResolvedMarkdownOptions } from './blocks-to-markdown';
|
package/dist/index.mjs
CHANGED
|
@@ -11,11 +11,12 @@ import {
|
|
|
11
11
|
} from "./chunk-EY6RQVAP.mjs";
|
|
12
12
|
import {
|
|
13
13
|
flattenToOperations,
|
|
14
|
+
hmAccountMentionUid,
|
|
14
15
|
markdownBlockNodesToHMBlockNodes,
|
|
15
16
|
parseFrontmatter,
|
|
16
17
|
parseInlineFormatting,
|
|
17
18
|
parseMarkdown
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-K5NYTWBJ.mjs";
|
|
19
20
|
import {
|
|
20
21
|
pdfToBlocks
|
|
21
22
|
} from "./chunk-AUY42GMB.mjs";
|
|
@@ -61,7 +62,7 @@ import {
|
|
|
61
62
|
deleteComment,
|
|
62
63
|
trimTrailingEmptyBlocks,
|
|
63
64
|
updateComment
|
|
64
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-6YBRBK6F.mjs";
|
|
65
66
|
import {
|
|
66
67
|
AnnotationSet,
|
|
67
68
|
addSpanToAnnotation,
|
|
@@ -202,6 +203,7 @@ export {
|
|
|
202
203
|
followToDocument,
|
|
203
204
|
getHMQueryString,
|
|
204
205
|
hasFileLinks,
|
|
206
|
+
hmAccountMentionUid,
|
|
205
207
|
hmBlockNodeToBlockNode,
|
|
206
208
|
hmBlockToEditorBlock,
|
|
207
209
|
hmBlocksToEditorContent,
|
|
@@ -41,6 +41,16 @@ type InlineParseResult = {
|
|
|
41
41
|
* exactly; mis-nested hand-written input degrades gracefully.
|
|
42
42
|
*/
|
|
43
43
|
export declare function parseInlineFormatting(raw: string): InlineParseResult;
|
|
44
|
+
/**
|
|
45
|
+
* Read a `[label](url)` starting at `open` (the `[`). Brackets balance,
|
|
46
|
+
* escapes and code spans are skipped, the url may be `<…>`-wrapped.
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* The account uid an `hm://` URL mentions, when it names an account itself: `hm://UID` (the
|
|
50
|
+
* account root) or `hm://UID/:profile`. A URL with any other path names a document, not a person,
|
|
51
|
+
* and returns null. Query strings and fragments are not accepted on a mention.
|
|
52
|
+
*/
|
|
53
|
+
export declare function hmAccountMentionUid(url: string): string | null;
|
|
44
54
|
/**
|
|
45
55
|
* Merge annotations of the same kind whose ranges touch or overlap into one
|
|
46
56
|
* contiguous range, and order the result deterministically. The emitter
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
flattenToOperations,
|
|
3
|
+
hmAccountMentionUid,
|
|
3
4
|
markdownBlockNodesToHMBlockNodes,
|
|
4
5
|
mergeAdjacentAnnotations,
|
|
5
6
|
parseFrontmatter,
|
|
6
7
|
parseInlineFormatting,
|
|
7
8
|
parseMarkdown
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-K5NYTWBJ.mjs";
|
|
9
10
|
import "./chunk-7P6ASYW6.mjs";
|
|
10
11
|
export {
|
|
11
12
|
flattenToOperations,
|
|
13
|
+
hmAccountMentionUid,
|
|
12
14
|
markdownBlockNodesToHMBlockNodes,
|
|
13
15
|
mergeAdjacentAnnotations,
|
|
14
16
|
parseFrontmatter,
|