@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
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* - Block ID preservation via <!-- id:XXXXXXXX --> HTML comments
|
|
14
14
|
* - `title:` as backward-compatible alias for `name:` in frontmatter
|
|
15
15
|
*/
|
|
16
|
-
import type { HMMetadata } from './hm-types';
|
|
16
|
+
import type { HMBlockNode, HMMetadata } from './hm-types';
|
|
17
17
|
import type { DocumentOperation } from './change';
|
|
18
18
|
export type Annotation = {
|
|
19
19
|
type: string;
|
|
@@ -74,6 +74,15 @@ export declare function parseMarkdown(markdown: string): {
|
|
|
74
74
|
tree: BlockNode[];
|
|
75
75
|
metadata: HMMetadata;
|
|
76
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Convert the markdown parser's BlockNode tree into HMBlockNode tree.
|
|
79
|
+
*
|
|
80
|
+
* Maps flat SeedBlock properties (childrenType, language) into the
|
|
81
|
+
* HMBlock attributes object, and annotations into the HMAnnotation shape.
|
|
82
|
+
* The resulting tree can be fed into `hmBlocksToEditorContent()` to get
|
|
83
|
+
* BlockNote editor blocks.
|
|
84
|
+
*/
|
|
85
|
+
export declare function markdownBlockNodesToHMBlockNodes(nodes: BlockNode[]): HMBlockNode[];
|
|
77
86
|
/**
|
|
78
87
|
* Flattens a block tree into Seed document operations.
|
|
79
88
|
*
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { HMAnnotations } from './hm-types';
|
|
2
|
+
/**
|
|
3
|
+
* Mutable annotation shape used during construction.
|
|
4
|
+
* Structurally compatible with HMAnnotation but uses plain objects
|
|
5
|
+
* instead of protobuf classes.
|
|
6
|
+
*/
|
|
7
|
+
export interface MutableAnnotation {
|
|
8
|
+
type: string;
|
|
9
|
+
link?: string;
|
|
10
|
+
attributes?: Record<string, unknown>;
|
|
11
|
+
starts: number[];
|
|
12
|
+
ends: number[];
|
|
13
|
+
}
|
|
14
|
+
/** Minimal annotation shape required by span-position helpers. */
|
|
15
|
+
export interface SpanAnnotation {
|
|
16
|
+
starts: number[];
|
|
17
|
+
ends: number[];
|
|
18
|
+
}
|
|
19
|
+
export declare class AnnotationSet {
|
|
20
|
+
annotations: Map<string, MutableAnnotation>;
|
|
21
|
+
constructor();
|
|
22
|
+
addSpan(type: string, attributes: {
|
|
23
|
+
[key: string]: string;
|
|
24
|
+
} | null, start: number, end: number): void;
|
|
25
|
+
_annotationId(type: string, attributes: {
|
|
26
|
+
[key: string]: string;
|
|
27
|
+
} | null): string;
|
|
28
|
+
list(): HMAnnotations;
|
|
29
|
+
}
|
|
30
|
+
/** Append a span to an annotation, merging with the previous span if adjacent. */
|
|
31
|
+
export declare function addSpanToAnnotation(annotation: SpanAnnotation, start: number, end: number): void;
|
|
32
|
+
/** Push a span to an annotation without checking adjacency. */
|
|
33
|
+
export declare function pushSpanToAnnotation(annotation: SpanAnnotation, start: number, end: number): void;
|
|
34
|
+
/** @deprecated Import from `@seed-hypermedia/client/hm-types` instead. */
|
|
35
|
+
export { codePointLength, isSurrogate } from './hm-types';
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -54,9 +54,15 @@ export type {HMRequest, HMSigner, UnpackedHypermediaId} from './hm-types'
|
|
|
54
54
|
export {fileToIpfsBlobs, filesToIpfsBlobs, resolveFileLinksInBlocks, hasFileLinks} from './file-to-ipfs'
|
|
55
55
|
export type {CollectedBlob} from './file-to-ipfs'
|
|
56
56
|
|
|
57
|
-
export {
|
|
57
|
+
export {
|
|
58
|
+
parseMarkdown,
|
|
59
|
+
flattenToOperations,
|
|
60
|
+
parseInlineFormatting,
|
|
61
|
+
parseFrontmatter,
|
|
62
|
+
markdownBlockNodesToHMBlockNodes,
|
|
63
|
+
} from './markdown-to-blocks'
|
|
58
64
|
export type {BlockNode, SeedBlock, Annotation} from './markdown-to-blocks'
|
|
59
|
-
export {blocksToMarkdown, emitFrontmatter} from './blocks-to-markdown'
|
|
65
|
+
export {blocksToMarkdown, emitFrontmatter, slugify, draftFilename, parseDraftFilename} from './blocks-to-markdown'
|
|
60
66
|
export type {BlocksToMarkdownOptions} from './blocks-to-markdown'
|
|
61
67
|
|
|
62
68
|
export {createBlocksMap, matchBlockIds, computeReplaceOps, hmBlockNodeToBlockNode} from './block-diff'
|
|
@@ -72,3 +78,36 @@ export {
|
|
|
72
78
|
export type {AutoLinkChildToParentOptions} from './auto-link'
|
|
73
79
|
export {resolveDocumentState} from './document-state'
|
|
74
80
|
export type {DocumentState} from './document-state'
|
|
81
|
+
|
|
82
|
+
export {editorBlockToHMBlock, editorBlocksToHMBlockNodes} from './editorblock-to-hmblock'
|
|
83
|
+
export {hmBlocksToEditorContent, hmBlockToEditorBlock, annotationContains} from './hmblock-to-editorblock'
|
|
84
|
+
export {AnnotationSet, addSpanToAnnotation, pushSpanToAnnotation} from './unicode'
|
|
85
|
+
export type {MutableAnnotation, SpanAnnotation} from './unicode'
|
|
86
|
+
export type {
|
|
87
|
+
EditorBlock,
|
|
88
|
+
EditorBaseBlock,
|
|
89
|
+
EditorBlockProps,
|
|
90
|
+
EditorBlockType,
|
|
91
|
+
EditorParagraphBlock,
|
|
92
|
+
EditorHeadingBlock,
|
|
93
|
+
EditorCodeBlock,
|
|
94
|
+
EditorImageBlock,
|
|
95
|
+
EditorVideoBlock,
|
|
96
|
+
EditorFileBlock,
|
|
97
|
+
EditorButtonBlock,
|
|
98
|
+
EditorEmbedBlock,
|
|
99
|
+
EditorWebEmbedBlock,
|
|
100
|
+
EditorMathBlock,
|
|
101
|
+
EditorNostrBlock,
|
|
102
|
+
EditorQueryBlock,
|
|
103
|
+
EditorUnknownBlock,
|
|
104
|
+
EditorText,
|
|
105
|
+
EditorLink,
|
|
106
|
+
EditorInlineEmbed,
|
|
107
|
+
EditorInlineStyles,
|
|
108
|
+
EditorAnnotationType,
|
|
109
|
+
HMInlineContent,
|
|
110
|
+
MediaBlockProps,
|
|
111
|
+
DraftMediaRef,
|
|
112
|
+
SearchResult,
|
|
113
|
+
} from './editor-types'
|