@seed-hypermedia/client 0.0.2 → 0.0.4
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/blocks-to-markdown.d.ts +27 -0
- package/dist/{chunk-PPK3SKPV.mjs → chunk-YIND2WNJ.mjs} +8 -3
- package/dist/editor-types.d.ts +157 -0
- package/dist/editorblock-to-hmblock.d.ts +12 -0
- package/dist/hm-types.d.ts +421 -163
- package/dist/hm-types.mjs +1 -1
- package/dist/hmblock-to-editorblock.d.ts +23 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.mjs +689 -1
- package/dist/markdown-to-blocks.d.ts +10 -1
- package/dist/unicode.d.ts +35 -0
- package/package.json +1 -1
- package/src/index.ts +41 -2
|
@@ -31,3 +31,30 @@ export declare function emitFrontmatter(metadata: HMMetadata): string;
|
|
|
31
31
|
* as placeholder links (not resolved).
|
|
32
32
|
*/
|
|
33
33
|
export declare function blocksToMarkdown(doc: HMDocument, options?: BlocksToMarkdownOptions): string;
|
|
34
|
+
/**
|
|
35
|
+
* Convert a title string into a URL-safe slug.
|
|
36
|
+
*
|
|
37
|
+
* - Lowercases the string
|
|
38
|
+
* - Replaces non-alphanumeric characters with hyphens
|
|
39
|
+
* - Trims leading/trailing hyphens
|
|
40
|
+
* - Truncates to 60 characters
|
|
41
|
+
*/
|
|
42
|
+
export declare function slugify(title: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Build a draft filename from a slug and nanoid.
|
|
45
|
+
* Format: `<slug>_<nanoid>.md` — human-readable + collision-safe.
|
|
46
|
+
* If the slug is empty, the filename is just `<nanoid>.md`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function draftFilename(slug: string, id: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Extract the draft ID (nanoid) from a draft filename.
|
|
51
|
+
*
|
|
52
|
+
* Handles both formats:
|
|
53
|
+
* - `<slug>_<nanoid>.md` → returns the nanoid part
|
|
54
|
+
* - `<nanoid>.md` → returns the nanoid (legacy/no-slug)
|
|
55
|
+
* - `<nanoid>.json` → returns the nanoid (legacy JSON)
|
|
56
|
+
*/
|
|
57
|
+
export declare function parseDraftFilename(filename: string): {
|
|
58
|
+
id: string;
|
|
59
|
+
ext: string;
|
|
60
|
+
};
|
|
@@ -21,7 +21,7 @@ var unpackedHmIdSchema = z.object({
|
|
|
21
21
|
targetDocUid: z.string().nullable().optional(),
|
|
22
22
|
targetDocPath: z.array(z.string()).nullable().optional()
|
|
23
23
|
});
|
|
24
|
-
var HMBlockChildrenTypeSchema = z.union([z.literal("Group"), z.literal("Ordered"), z.literal("Unordered"), z.literal("Blockquote")]).nullable();
|
|
24
|
+
var HMBlockChildrenTypeSchema = z.union([z.literal("Group"), z.literal("Ordered"), z.literal("Unordered"), z.literal("Blockquote"), z.literal("Grid")]).nullable();
|
|
25
25
|
var HMEmbedViewSchema = z.union([z.literal("Content"), z.literal("Card"), z.literal("Comments")]);
|
|
26
26
|
var HMQueryStyleSchema = z.union([z.literal("Card"), z.literal("List")]);
|
|
27
27
|
var baseAnnotationProperties = {
|
|
@@ -93,7 +93,8 @@ var textBlockProperties = {
|
|
|
93
93
|
annotations: HMAnnotationsSchema
|
|
94
94
|
};
|
|
95
95
|
var parentBlockAttributes = {
|
|
96
|
-
childrenType: HMBlockChildrenTypeSchema.optional()
|
|
96
|
+
childrenType: HMBlockChildrenTypeSchema.optional(),
|
|
97
|
+
columnCount: z.number().optional()
|
|
97
98
|
};
|
|
98
99
|
var HMBlockParagraphSchema = z.object({
|
|
99
100
|
type: z.literal("Paragraph"),
|
|
@@ -603,7 +604,11 @@ var HMDraftMetaBaseSchema = z.object({
|
|
|
603
604
|
editUid: z.string().optional(),
|
|
604
605
|
editPath: z.array(z.string()).optional(),
|
|
605
606
|
metadata: HMDocumentMetadataSchema,
|
|
606
|
-
visibility: HMResourceVisibilitySchema.optional().default("PUBLIC")
|
|
607
|
+
visibility: HMResourceVisibilitySchema.optional().default("PUBLIC"),
|
|
608
|
+
// deps and navigation live in the index entry for .md drafts
|
|
609
|
+
// (for .json drafts they come from the content file for backwards compat)
|
|
610
|
+
deps: z.array(z.string().min(1)).default([]),
|
|
611
|
+
navigation: z.array(HMNavigationItemSchema).optional()
|
|
607
612
|
});
|
|
608
613
|
var draftLocationRefinement = (data) => data.editUid || data.locationUid;
|
|
609
614
|
var HMDraftMetaSchema = HMDraftMetaBaseSchema.refine(draftLocationRefinement, {
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { HMBlockChildrenType } from './hm-types';
|
|
2
|
+
export type EditorBlock = EditorParagraphBlock | EditorHeadingBlock | EditorCodeBlock | EditorImageBlock | EditorVideoBlock | EditorFileBlock | EditorButtonBlock | EditorEmbedBlock | EditorWebEmbedBlock | EditorMathBlock | EditorNostrBlock | EditorQueryBlock | EditorUnknownBlock;
|
|
3
|
+
export type HMInlineContent = EditorText | EditorInlineEmbed | EditorLink;
|
|
4
|
+
export interface EditorBaseBlock {
|
|
5
|
+
id: string;
|
|
6
|
+
props: EditorBlockProps;
|
|
7
|
+
children: Array<EditorBlock>;
|
|
8
|
+
}
|
|
9
|
+
export interface EditorBlockProps {
|
|
10
|
+
childrenType?: HMBlockChildrenType;
|
|
11
|
+
columnCount?: string;
|
|
12
|
+
listLevel?: string;
|
|
13
|
+
level?: number | string;
|
|
14
|
+
ref?: string;
|
|
15
|
+
revision?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface EditorParagraphBlock extends EditorBaseBlock {
|
|
18
|
+
type: 'paragraph';
|
|
19
|
+
content: Array<HMInlineContent>;
|
|
20
|
+
}
|
|
21
|
+
export interface EditorHeadingBlock extends EditorBaseBlock {
|
|
22
|
+
type: 'heading';
|
|
23
|
+
content: Array<HMInlineContent>;
|
|
24
|
+
}
|
|
25
|
+
export interface EditorCodeBlock extends EditorBaseBlock {
|
|
26
|
+
type: 'code-block';
|
|
27
|
+
content: Array<HMInlineContent>;
|
|
28
|
+
props: EditorBlockProps & {
|
|
29
|
+
language?: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface DraftMediaRef {
|
|
33
|
+
draftId: string;
|
|
34
|
+
mediaId: string;
|
|
35
|
+
name: string;
|
|
36
|
+
mime: string;
|
|
37
|
+
size: number;
|
|
38
|
+
}
|
|
39
|
+
export interface MediaBlockProps extends EditorBlockProps {
|
|
40
|
+
url?: string;
|
|
41
|
+
src?: string;
|
|
42
|
+
displaySrc?: string;
|
|
43
|
+
fileBinary?: Uint8Array | number[];
|
|
44
|
+
mediaRef?: DraftMediaRef;
|
|
45
|
+
name?: string;
|
|
46
|
+
width?: string;
|
|
47
|
+
defaultOpen?: string;
|
|
48
|
+
size?: string;
|
|
49
|
+
alignment?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface EditorImageBlock extends EditorBaseBlock {
|
|
52
|
+
type: 'image';
|
|
53
|
+
props: MediaBlockProps;
|
|
54
|
+
content: Array<HMInlineContent>;
|
|
55
|
+
}
|
|
56
|
+
export interface EditorVideoBlock extends EditorBaseBlock {
|
|
57
|
+
type: 'video';
|
|
58
|
+
props: MediaBlockProps;
|
|
59
|
+
content: Array<HMInlineContent>;
|
|
60
|
+
}
|
|
61
|
+
export interface EditorFileBlock extends EditorBaseBlock {
|
|
62
|
+
type: 'file';
|
|
63
|
+
props: MediaBlockProps;
|
|
64
|
+
content: Array<HMInlineContent>;
|
|
65
|
+
}
|
|
66
|
+
export interface EditorButtonBlock extends EditorBaseBlock {
|
|
67
|
+
type: 'button';
|
|
68
|
+
props: MediaBlockProps;
|
|
69
|
+
content: Array<HMInlineContent>;
|
|
70
|
+
}
|
|
71
|
+
export interface EditorEmbedBlock extends EditorBaseBlock {
|
|
72
|
+
type: 'embed';
|
|
73
|
+
props: EditorBlockProps & {
|
|
74
|
+
view: 'Content' | 'Card';
|
|
75
|
+
url: string;
|
|
76
|
+
};
|
|
77
|
+
content: Array<HMInlineContent>;
|
|
78
|
+
}
|
|
79
|
+
export interface EditorMathBlock extends EditorBaseBlock {
|
|
80
|
+
type: 'math';
|
|
81
|
+
content: Array<HMInlineContent>;
|
|
82
|
+
}
|
|
83
|
+
export type EditorWebEmbedBlock = EditorBaseBlock & {
|
|
84
|
+
type: 'web-embed';
|
|
85
|
+
props: EditorBlockProps & {
|
|
86
|
+
url?: string;
|
|
87
|
+
};
|
|
88
|
+
content: Array<HMInlineContent>;
|
|
89
|
+
};
|
|
90
|
+
export type EditorNostrBlock = EditorBaseBlock & {
|
|
91
|
+
type: 'nostr';
|
|
92
|
+
props: EditorBlockProps & {
|
|
93
|
+
name?: string;
|
|
94
|
+
url?: string;
|
|
95
|
+
text?: string;
|
|
96
|
+
size?: string;
|
|
97
|
+
};
|
|
98
|
+
content: Array<HMInlineContent>;
|
|
99
|
+
};
|
|
100
|
+
export type EditorQueryBlock = EditorBaseBlock & {
|
|
101
|
+
type: 'query';
|
|
102
|
+
props: EditorBlockProps & {
|
|
103
|
+
style: 'Card' | 'List';
|
|
104
|
+
columnCount?: '1' | '2' | '3';
|
|
105
|
+
queryLimit?: string;
|
|
106
|
+
queryIncludes?: string;
|
|
107
|
+
querySort?: string;
|
|
108
|
+
banner?: 'true' | 'false';
|
|
109
|
+
};
|
|
110
|
+
content: Array<HMInlineContent>;
|
|
111
|
+
};
|
|
112
|
+
export type EditorUnknownBlock = EditorBaseBlock & {
|
|
113
|
+
type: 'unknown';
|
|
114
|
+
props: EditorBlockProps & {
|
|
115
|
+
originalType: string;
|
|
116
|
+
originalData: string;
|
|
117
|
+
};
|
|
118
|
+
content: Array<HMInlineContent>;
|
|
119
|
+
};
|
|
120
|
+
export interface EditorText {
|
|
121
|
+
type: 'text';
|
|
122
|
+
text: string;
|
|
123
|
+
styles: EditorInlineStyles;
|
|
124
|
+
}
|
|
125
|
+
export interface EditorLink {
|
|
126
|
+
type: 'link';
|
|
127
|
+
href: string;
|
|
128
|
+
content: Array<HMInlineContent>;
|
|
129
|
+
}
|
|
130
|
+
export interface EditorInlineEmbed {
|
|
131
|
+
type: 'inline-embed';
|
|
132
|
+
link: string;
|
|
133
|
+
styles: EditorInlineStyles | {};
|
|
134
|
+
}
|
|
135
|
+
export interface EditorInlineStyles {
|
|
136
|
+
bold?: boolean;
|
|
137
|
+
italic?: boolean;
|
|
138
|
+
underline?: boolean;
|
|
139
|
+
strike?: boolean;
|
|
140
|
+
code?: boolean;
|
|
141
|
+
math?: boolean;
|
|
142
|
+
range?: boolean;
|
|
143
|
+
}
|
|
144
|
+
export type EditorAnnotationType = 'bold' | 'italic' | 'underline' | 'strike' | 'code' | 'link' | 'inline-embed' | 'range';
|
|
145
|
+
export type EditorBlockType = EditorBlock['type'];
|
|
146
|
+
export type SearchResult = {
|
|
147
|
+
key: string;
|
|
148
|
+
title: string;
|
|
149
|
+
subtitle?: string;
|
|
150
|
+
icon?: string;
|
|
151
|
+
path?: string[] | null;
|
|
152
|
+
versionTime?: string;
|
|
153
|
+
searchQuery?: string;
|
|
154
|
+
onSelect?: () => void | Promise<void>;
|
|
155
|
+
onFocus: () => void;
|
|
156
|
+
onMouseEnter: () => void;
|
|
157
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EditorBlock } from './editor-types';
|
|
2
|
+
import { HMBlock, HMBlockNode } from './hm-types';
|
|
3
|
+
/** Convert a single BlockNote EditorBlock into an HMBlock. */
|
|
4
|
+
export declare function editorBlockToHMBlock(editorBlock: EditorBlock): HMBlock;
|
|
5
|
+
/**
|
|
6
|
+
* Convert an array of BlockNote EditorBlocks into an HMBlockNode tree.
|
|
7
|
+
*
|
|
8
|
+
* This is the tree-level wrapper around `editorBlockToHMBlock` that recursively
|
|
9
|
+
* converts children. Useful when serializing editor content to the HM block format
|
|
10
|
+
* (e.g. for saving drafts as markdown or publishing documents).
|
|
11
|
+
*/
|
|
12
|
+
export declare function editorBlocksToHMBlockNodes(editorBlocks: EditorBlock[]): HMBlockNode[];
|