@seed-hypermedia/client 0.0.40 → 0.0.42
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-2E3HWHST.mjs → chunk-XHVG24AF.mjs} +13 -1
- package/dist/comment.d.ts +15 -0
- package/dist/editor-types.d.ts +2 -0
- package/dist/hm-types.d.ts +63 -16
- package/dist/hm-types.mjs +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +82 -13
- package/package.json +1 -1
- package/src/index.ts +7 -1
|
@@ -28,7 +28,12 @@ var unpackedHmIdSchema = z.object({
|
|
|
28
28
|
targetDocPath: z.array(z.string()).nullable().optional()
|
|
29
29
|
});
|
|
30
30
|
var HMBlockChildrenTypeSchema = z.union([z.literal("Group"), z.literal("Ordered"), z.literal("Unordered"), z.literal("Blockquote"), z.literal("Grid")]).nullable();
|
|
31
|
-
var HMEmbedViewSchema = z.union([
|
|
31
|
+
var HMEmbedViewSchema = z.union([
|
|
32
|
+
z.literal("Content"),
|
|
33
|
+
z.literal("Card"),
|
|
34
|
+
z.literal("Comments"),
|
|
35
|
+
z.literal("Link")
|
|
36
|
+
]);
|
|
32
37
|
var HMQueryStyleSchema = z.union([z.literal("Card"), z.literal("List")]);
|
|
33
38
|
var baseAnnotationProperties = {
|
|
34
39
|
starts: z.array(z.number()),
|
|
@@ -538,11 +543,16 @@ var HMAccountContactsRequestSchema = z.object({
|
|
|
538
543
|
// account UID
|
|
539
544
|
output: z.array(HMContactRecordSchema)
|
|
540
545
|
});
|
|
546
|
+
var QuotingRangeSchema = z.object({
|
|
547
|
+
start: z.number(),
|
|
548
|
+
end: z.number()
|
|
549
|
+
});
|
|
541
550
|
var HMCommentDraftSchema = z.object({
|
|
542
551
|
blocks: z.array(HMBlockNodeSchema),
|
|
543
552
|
targetDocId: z.string().optional(),
|
|
544
553
|
replyCommentId: z.string().optional(),
|
|
545
554
|
quotingBlockId: z.string().optional(),
|
|
555
|
+
quotingRange: QuotingRangeSchema.optional(),
|
|
546
556
|
context: z.enum(["accessory", "feed", "document-content"]).optional(),
|
|
547
557
|
lastUpdateTime: z.number().optional()
|
|
548
558
|
});
|
|
@@ -551,6 +561,7 @@ var HMListedCommentDraftSchema = z.object({
|
|
|
551
561
|
targetDocId: z.string(),
|
|
552
562
|
replyCommentId: z.string().optional(),
|
|
553
563
|
quotingBlockId: z.string().optional(),
|
|
564
|
+
quotingRange: QuotingRangeSchema.optional(),
|
|
554
565
|
context: z.enum(["accessory", "feed", "document-content"]).optional(),
|
|
555
566
|
lastUpdateTime: z.number()
|
|
556
567
|
});
|
|
@@ -1348,6 +1359,7 @@ export {
|
|
|
1348
1359
|
HMContactSubscribeSchema,
|
|
1349
1360
|
HMContactRecordSchema,
|
|
1350
1361
|
HMAccountContactsRequestSchema,
|
|
1362
|
+
QuotingRangeSchema,
|
|
1351
1363
|
HMCommentDraftSchema,
|
|
1352
1364
|
HMListedCommentDraftSchema,
|
|
1353
1365
|
HMHostConfigSchema,
|
package/dist/comment.d.ts
CHANGED
|
@@ -13,11 +13,26 @@ type PrepareAttachments = (binaries: Uint8Array[]) => Promise<{
|
|
|
13
13
|
blobs: CommentAttachmentBlob[];
|
|
14
14
|
resultCIDs: string[];
|
|
15
15
|
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Target of a quoted block fragment in a comment. The optional `range`
|
|
18
|
+
* holds zero-based Unicode codepoint offsets within the block's text.
|
|
19
|
+
* When `range` is omitted, the comment quotes the whole block.
|
|
20
|
+
*/
|
|
21
|
+
export type QuotingTarget = {
|
|
22
|
+
blockId: string;
|
|
23
|
+
range?: {
|
|
24
|
+
start: number;
|
|
25
|
+
end: number;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
16
28
|
type CreateCommentBaseInput = {
|
|
17
29
|
docId: UnpackedHypermediaId;
|
|
18
30
|
docVersion: string;
|
|
19
31
|
replyCommentVersion?: string | null;
|
|
20
32
|
rootReplyCommentVersion?: string | null;
|
|
33
|
+
/** Structured quote target (preferred). */
|
|
34
|
+
quoting?: QuotingTarget;
|
|
35
|
+
/** Deprecated: pass `quoting: {blockId}` instead. Still honored for back-compat. */
|
|
21
36
|
quotingBlockId?: string;
|
|
22
37
|
visibility?: 'Private' | '';
|
|
23
38
|
};
|
package/dist/editor-types.d.ts
CHANGED
|
@@ -147,6 +147,8 @@ export interface EditorInlineStyles {
|
|
|
147
147
|
range?: boolean;
|
|
148
148
|
textColor?: string;
|
|
149
149
|
backgroundColor?: string;
|
|
150
|
+
textSize?: string;
|
|
151
|
+
textFamily?: string;
|
|
150
152
|
}
|
|
151
153
|
export type EditorAnnotationType = 'bold' | 'italic' | 'underline' | 'strike' | 'code' | 'link' | 'inline-embed' | 'range';
|
|
152
154
|
export type EditorBlockType = EditorBlock['type'];
|
package/dist/hm-types.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ export declare const unpackedHmIdSchema: z.ZodObject<{
|
|
|
77
77
|
export type UnpackedHypermediaId = z.infer<typeof unpackedHmIdSchema>;
|
|
78
78
|
export declare const HMBlockChildrenTypeSchema: z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>;
|
|
79
79
|
export type HMBlockChildrenType = z.infer<typeof HMBlockChildrenTypeSchema>;
|
|
80
|
-
export declare const HMEmbedViewSchema: z.ZodUnion<[z.ZodLiteral<"Content">, z.ZodLiteral<"Card">, z.ZodLiteral<"Comments">]>;
|
|
80
|
+
export declare const HMEmbedViewSchema: z.ZodUnion<[z.ZodLiteral<"Content">, z.ZodLiteral<"Card">, z.ZodLiteral<"Comments">, z.ZodLiteral<"Link">]>;
|
|
81
81
|
export type HMEmbedView = z.infer<typeof HMEmbedViewSchema>;
|
|
82
82
|
export declare const HMQueryStyleSchema: z.ZodUnion<[z.ZodLiteral<"Card">, z.ZodLiteral<"List">]>;
|
|
83
83
|
export type HMQueryStyle = z.infer<typeof HMQueryStyleSchema>;
|
|
@@ -2510,17 +2510,17 @@ export declare const HMBlockButtonSchema: z.ZodObject<{
|
|
|
2510
2510
|
export declare const HMBlockEmbedSchema: z.ZodObject<{
|
|
2511
2511
|
link: z.ZodString;
|
|
2512
2512
|
attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
2513
|
-
view: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"Content">, z.ZodLiteral<"Card">, z.ZodLiteral<"Comments">]>>;
|
|
2513
|
+
view: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"Content">, z.ZodLiteral<"Card">, z.ZodLiteral<"Comments">, z.ZodLiteral<"Link">]>>;
|
|
2514
2514
|
childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
|
|
2515
2515
|
columnCount: z.ZodOptional<z.ZodNumber>;
|
|
2516
2516
|
}, "strip", z.ZodTypeAny, {
|
|
2517
2517
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
2518
2518
|
columnCount?: number | undefined;
|
|
2519
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
2519
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
2520
2520
|
}, {
|
|
2521
2521
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
2522
2522
|
columnCount?: number | undefined;
|
|
2523
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
2523
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
2524
2524
|
}>>>;
|
|
2525
2525
|
id: z.ZodString;
|
|
2526
2526
|
revision: z.ZodOptional<z.ZodString>;
|
|
@@ -2534,7 +2534,7 @@ export declare const HMBlockEmbedSchema: z.ZodObject<{
|
|
|
2534
2534
|
attributes: {
|
|
2535
2535
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
2536
2536
|
columnCount?: number | undefined;
|
|
2537
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
2537
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
2538
2538
|
};
|
|
2539
2539
|
text?: "" | undefined;
|
|
2540
2540
|
annotations?: never[] | undefined;
|
|
@@ -2546,7 +2546,7 @@ export declare const HMBlockEmbedSchema: z.ZodObject<{
|
|
|
2546
2546
|
attributes?: {
|
|
2547
2547
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
2548
2548
|
columnCount?: number | undefined;
|
|
2549
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
2549
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
2550
2550
|
} | undefined;
|
|
2551
2551
|
text?: "" | undefined;
|
|
2552
2552
|
annotations?: never[] | undefined;
|
|
@@ -7403,17 +7403,17 @@ export declare const HMBlockKnownSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
|
|
|
7403
7403
|
}>, z.ZodObject<{
|
|
7404
7404
|
link: z.ZodString;
|
|
7405
7405
|
attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
7406
|
-
view: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"Content">, z.ZodLiteral<"Card">, z.ZodLiteral<"Comments">]>>;
|
|
7406
|
+
view: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"Content">, z.ZodLiteral<"Card">, z.ZodLiteral<"Comments">, z.ZodLiteral<"Link">]>>;
|
|
7407
7407
|
childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
|
|
7408
7408
|
columnCount: z.ZodOptional<z.ZodNumber>;
|
|
7409
7409
|
}, "strip", z.ZodTypeAny, {
|
|
7410
7410
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
7411
7411
|
columnCount?: number | undefined;
|
|
7412
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
7412
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
7413
7413
|
}, {
|
|
7414
7414
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
7415
7415
|
columnCount?: number | undefined;
|
|
7416
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
7416
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
7417
7417
|
}>>>;
|
|
7418
7418
|
id: z.ZodString;
|
|
7419
7419
|
revision: z.ZodOptional<z.ZodString>;
|
|
@@ -7427,7 +7427,7 @@ export declare const HMBlockKnownSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
|
|
|
7427
7427
|
attributes: {
|
|
7428
7428
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
7429
7429
|
columnCount?: number | undefined;
|
|
7430
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
7430
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
7431
7431
|
};
|
|
7432
7432
|
text?: "" | undefined;
|
|
7433
7433
|
annotations?: never[] | undefined;
|
|
@@ -7439,7 +7439,7 @@ export declare const HMBlockKnownSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
|
|
|
7439
7439
|
attributes?: {
|
|
7440
7440
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
7441
7441
|
columnCount?: number | undefined;
|
|
7442
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
7442
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
7443
7443
|
} | undefined;
|
|
7444
7444
|
text?: "" | undefined;
|
|
7445
7445
|
annotations?: never[] | undefined;
|
|
@@ -9310,17 +9310,17 @@ export declare const HMBlockSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type",
|
|
|
9310
9310
|
}>, z.ZodObject<{
|
|
9311
9311
|
link: z.ZodString;
|
|
9312
9312
|
attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
9313
|
-
view: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"Content">, z.ZodLiteral<"Card">, z.ZodLiteral<"Comments">]>>;
|
|
9313
|
+
view: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"Content">, z.ZodLiteral<"Card">, z.ZodLiteral<"Comments">, z.ZodLiteral<"Link">]>>;
|
|
9314
9314
|
childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
|
|
9315
9315
|
columnCount: z.ZodOptional<z.ZodNumber>;
|
|
9316
9316
|
}, "strip", z.ZodTypeAny, {
|
|
9317
9317
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
9318
9318
|
columnCount?: number | undefined;
|
|
9319
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
9319
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
9320
9320
|
}, {
|
|
9321
9321
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
9322
9322
|
columnCount?: number | undefined;
|
|
9323
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
9323
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
9324
9324
|
}>>>;
|
|
9325
9325
|
id: z.ZodString;
|
|
9326
9326
|
revision: z.ZodOptional<z.ZodString>;
|
|
@@ -9334,7 +9334,7 @@ export declare const HMBlockSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type",
|
|
|
9334
9334
|
attributes: {
|
|
9335
9335
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
9336
9336
|
columnCount?: number | undefined;
|
|
9337
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
9337
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
9338
9338
|
};
|
|
9339
9339
|
text?: "" | undefined;
|
|
9340
9340
|
annotations?: never[] | undefined;
|
|
@@ -9346,7 +9346,7 @@ export declare const HMBlockSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type",
|
|
|
9346
9346
|
attributes?: {
|
|
9347
9347
|
childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
|
|
9348
9348
|
columnCount?: number | undefined;
|
|
9349
|
-
view?: "Content" | "Card" | "Comments" | undefined;
|
|
9349
|
+
view?: "Content" | "Card" | "Comments" | "Link" | undefined;
|
|
9350
9350
|
} | undefined;
|
|
9351
9351
|
text?: "" | undefined;
|
|
9352
9352
|
annotations?: never[] | undefined;
|
|
@@ -12868,11 +12868,32 @@ export type HMExistingDraft = {
|
|
|
12868
12868
|
id: string;
|
|
12869
12869
|
metadata?: HMMetadata;
|
|
12870
12870
|
};
|
|
12871
|
+
/** Codepoint offsets within a quoted block. */
|
|
12872
|
+
export declare const QuotingRangeSchema: z.ZodObject<{
|
|
12873
|
+
start: z.ZodNumber;
|
|
12874
|
+
end: z.ZodNumber;
|
|
12875
|
+
}, "strip", z.ZodTypeAny, {
|
|
12876
|
+
start: number;
|
|
12877
|
+
end: number;
|
|
12878
|
+
}, {
|
|
12879
|
+
start: number;
|
|
12880
|
+
end: number;
|
|
12881
|
+
}>;
|
|
12871
12882
|
export declare const HMCommentDraftSchema: z.ZodObject<{
|
|
12872
12883
|
blocks: z.ZodArray<z.ZodType<HMBlockNode, z.ZodTypeDef, HMBlockNode>, "many">;
|
|
12873
12884
|
targetDocId: z.ZodOptional<z.ZodString>;
|
|
12874
12885
|
replyCommentId: z.ZodOptional<z.ZodString>;
|
|
12875
12886
|
quotingBlockId: z.ZodOptional<z.ZodString>;
|
|
12887
|
+
quotingRange: z.ZodOptional<z.ZodObject<{
|
|
12888
|
+
start: z.ZodNumber;
|
|
12889
|
+
end: z.ZodNumber;
|
|
12890
|
+
}, "strip", z.ZodTypeAny, {
|
|
12891
|
+
start: number;
|
|
12892
|
+
end: number;
|
|
12893
|
+
}, {
|
|
12894
|
+
start: number;
|
|
12895
|
+
end: number;
|
|
12896
|
+
}>>;
|
|
12876
12897
|
context: z.ZodOptional<z.ZodEnum<["accessory", "feed", "document-content"]>>;
|
|
12877
12898
|
lastUpdateTime: z.ZodOptional<z.ZodNumber>;
|
|
12878
12899
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -12880,6 +12901,10 @@ export declare const HMCommentDraftSchema: z.ZodObject<{
|
|
|
12880
12901
|
targetDocId?: string | undefined;
|
|
12881
12902
|
replyCommentId?: string | undefined;
|
|
12882
12903
|
quotingBlockId?: string | undefined;
|
|
12904
|
+
quotingRange?: {
|
|
12905
|
+
start: number;
|
|
12906
|
+
end: number;
|
|
12907
|
+
} | undefined;
|
|
12883
12908
|
context?: "accessory" | "feed" | "document-content" | undefined;
|
|
12884
12909
|
lastUpdateTime?: number | undefined;
|
|
12885
12910
|
}, {
|
|
@@ -12887,6 +12912,10 @@ export declare const HMCommentDraftSchema: z.ZodObject<{
|
|
|
12887
12912
|
targetDocId?: string | undefined;
|
|
12888
12913
|
replyCommentId?: string | undefined;
|
|
12889
12914
|
quotingBlockId?: string | undefined;
|
|
12915
|
+
quotingRange?: {
|
|
12916
|
+
start: number;
|
|
12917
|
+
end: number;
|
|
12918
|
+
} | undefined;
|
|
12890
12919
|
context?: "accessory" | "feed" | "document-content" | undefined;
|
|
12891
12920
|
lastUpdateTime?: number | undefined;
|
|
12892
12921
|
}>;
|
|
@@ -12896,6 +12925,16 @@ export declare const HMListedCommentDraftSchema: z.ZodObject<{
|
|
|
12896
12925
|
targetDocId: z.ZodString;
|
|
12897
12926
|
replyCommentId: z.ZodOptional<z.ZodString>;
|
|
12898
12927
|
quotingBlockId: z.ZodOptional<z.ZodString>;
|
|
12928
|
+
quotingRange: z.ZodOptional<z.ZodObject<{
|
|
12929
|
+
start: z.ZodNumber;
|
|
12930
|
+
end: z.ZodNumber;
|
|
12931
|
+
}, "strip", z.ZodTypeAny, {
|
|
12932
|
+
start: number;
|
|
12933
|
+
end: number;
|
|
12934
|
+
}, {
|
|
12935
|
+
start: number;
|
|
12936
|
+
end: number;
|
|
12937
|
+
}>>;
|
|
12899
12938
|
context: z.ZodOptional<z.ZodEnum<["accessory", "feed", "document-content"]>>;
|
|
12900
12939
|
lastUpdateTime: z.ZodNumber;
|
|
12901
12940
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -12904,6 +12943,10 @@ export declare const HMListedCommentDraftSchema: z.ZodObject<{
|
|
|
12904
12943
|
lastUpdateTime: number;
|
|
12905
12944
|
replyCommentId?: string | undefined;
|
|
12906
12945
|
quotingBlockId?: string | undefined;
|
|
12946
|
+
quotingRange?: {
|
|
12947
|
+
start: number;
|
|
12948
|
+
end: number;
|
|
12949
|
+
} | undefined;
|
|
12907
12950
|
context?: "accessory" | "feed" | "document-content" | undefined;
|
|
12908
12951
|
}, {
|
|
12909
12952
|
id: string;
|
|
@@ -12911,6 +12954,10 @@ export declare const HMListedCommentDraftSchema: z.ZodObject<{
|
|
|
12911
12954
|
lastUpdateTime: number;
|
|
12912
12955
|
replyCommentId?: string | undefined;
|
|
12913
12956
|
quotingBlockId?: string | undefined;
|
|
12957
|
+
quotingRange?: {
|
|
12958
|
+
start: number;
|
|
12959
|
+
end: number;
|
|
12960
|
+
} | undefined;
|
|
12914
12961
|
context?: "accessory" | "feed" | "document-content" | undefined;
|
|
12915
12962
|
}>;
|
|
12916
12963
|
export type HMListedCommentDraft = z.infer<typeof HMListedCommentDraftSchema>;
|
package/dist/hm-types.mjs
CHANGED
|
@@ -154,6 +154,7 @@ import {
|
|
|
154
154
|
ItalicAnnotationSchema,
|
|
155
155
|
LinkAnnotationSchema,
|
|
156
156
|
ParsedFragmentSchema,
|
|
157
|
+
QuotingRangeSchema,
|
|
157
158
|
StrikeAnnotationSchema,
|
|
158
159
|
TextColorAnnotationSchema,
|
|
159
160
|
TextFamilyAnnotationSchema,
|
|
@@ -176,7 +177,7 @@ import {
|
|
|
176
177
|
toNumber,
|
|
177
178
|
unpackHmId,
|
|
178
179
|
unpackedHmIdSchema
|
|
179
|
-
} from "./chunk-
|
|
180
|
+
} from "./chunk-XHVG24AF.mjs";
|
|
180
181
|
export {
|
|
181
182
|
BackgroundColorAnnotationSchema,
|
|
182
183
|
BlockRangeSchema,
|
|
@@ -333,6 +334,7 @@ export {
|
|
|
333
334
|
ItalicAnnotationSchema,
|
|
334
335
|
LinkAnnotationSchema,
|
|
335
336
|
ParsedFragmentSchema,
|
|
337
|
+
QuotingRangeSchema,
|
|
336
338
|
StrikeAnnotationSchema,
|
|
337
339
|
TextColorAnnotationSchema,
|
|
338
340
|
TextFamilyAnnotationSchema,
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type { CreateChangeOpsInput, CreateDocumentChangeFromOpsInput, CreateDocu
|
|
|
5
5
|
export { createSeedClient } from './client';
|
|
6
6
|
export type { PublishDocumentInput, SeedClient, SeedClientOptions } from './client';
|
|
7
7
|
export { commentRecordIdFromBlob, createComment, deleteComment, updateComment } from './comment';
|
|
8
|
-
export type { CommentAttachmentBlob, CreateCommentInput, DeleteCommentInput, UpdateCommentInput } from './comment';
|
|
8
|
+
export type { CommentAttachmentBlob, CreateCommentInput, DeleteCommentInput, QuotingTarget, UpdateCommentInput, } from './comment';
|
|
9
9
|
export { contactRecordIdFromBlob, createContact, deleteContact, updateContact } from './contact';
|
|
10
10
|
export type { CreateContactInput, CreateContactResult, DeleteContactInput, UpdateContactInput } from './contact';
|
|
11
11
|
export { SeedClientError, SeedNetworkError, SeedValidationError } from './errors';
|
package/dist/index.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
serializeBlockRange,
|
|
18
18
|
toNumber,
|
|
19
19
|
unpackHmId
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-XHVG24AF.mjs";
|
|
21
21
|
|
|
22
22
|
// src/capability.ts
|
|
23
23
|
import { encode as cborEncode2 } from "@ipld/dag-cbor";
|
|
@@ -659,6 +659,16 @@ function isEmptyBlockNode(node) {
|
|
|
659
659
|
if (block.type !== "Paragraph" && block.type !== "Heading") return false;
|
|
660
660
|
return !block.text || block.text.trim() === "";
|
|
661
661
|
}
|
|
662
|
+
function resolveQuotingTarget(input) {
|
|
663
|
+
if (input.quoting) {
|
|
664
|
+
if (input.quoting.range && input.quoting.range.start === input.quoting.range.end) {
|
|
665
|
+
return { blockId: input.quoting.blockId };
|
|
666
|
+
}
|
|
667
|
+
return input.quoting;
|
|
668
|
+
}
|
|
669
|
+
if (input.quotingBlockId) return { blockId: input.quotingBlockId };
|
|
670
|
+
return void 0;
|
|
671
|
+
}
|
|
662
672
|
function annotationsToPublishable(annotations) {
|
|
663
673
|
validateExclusiveAnnotations(annotations);
|
|
664
674
|
return annotations.map((annotation) => {
|
|
@@ -892,7 +902,15 @@ function generateBlockId(length = 8) {
|
|
|
892
902
|
return result;
|
|
893
903
|
}
|
|
894
904
|
function wrapQuotedContent(content, input) {
|
|
895
|
-
|
|
905
|
+
const quoting = resolveQuotingTarget(input);
|
|
906
|
+
if (!quoting) return content;
|
|
907
|
+
const link = packHmId({
|
|
908
|
+
...input.docId,
|
|
909
|
+
blockRef: quoting.blockId,
|
|
910
|
+
blockRange: quoting.range ?? null,
|
|
911
|
+
version: input.docVersion,
|
|
912
|
+
latest: false
|
|
913
|
+
});
|
|
896
914
|
return [
|
|
897
915
|
{
|
|
898
916
|
block: {
|
|
@@ -904,11 +922,7 @@ function wrapQuotedContent(content, input) {
|
|
|
904
922
|
view: "Content"
|
|
905
923
|
},
|
|
906
924
|
annotations: [],
|
|
907
|
-
link
|
|
908
|
-
...input.docId,
|
|
909
|
-
blockRef: input.quotingBlockId,
|
|
910
|
-
version: input.docVersion
|
|
911
|
-
})
|
|
925
|
+
link
|
|
912
926
|
},
|
|
913
927
|
children: content
|
|
914
928
|
}
|
|
@@ -3607,7 +3621,7 @@ function editorBlockToHMBlock(editorBlock) {
|
|
|
3607
3621
|
const blockType = toHMBlockType(editorBlock.type);
|
|
3608
3622
|
if (!blockType) throw new Error("Unsupported block type " + editorBlock.type);
|
|
3609
3623
|
let block = {
|
|
3610
|
-
id: editorBlock.id,
|
|
3624
|
+
id: normalizeEditorBlockId(editorBlock.id),
|
|
3611
3625
|
type: blockType,
|
|
3612
3626
|
attributes: {},
|
|
3613
3627
|
text: "",
|
|
@@ -3822,6 +3836,17 @@ function flattenLeaves(content) {
|
|
|
3822
3836
|
}
|
|
3823
3837
|
return result;
|
|
3824
3838
|
}
|
|
3839
|
+
function normalizeEditorBlockId(id) {
|
|
3840
|
+
return id && id !== "empty" ? id : generateBlockId6();
|
|
3841
|
+
}
|
|
3842
|
+
function generateBlockId6(length = 8) {
|
|
3843
|
+
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
3844
|
+
let result = "";
|
|
3845
|
+
for (let i = 0; i < length; i++) {
|
|
3846
|
+
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
3847
|
+
}
|
|
3848
|
+
return result;
|
|
3849
|
+
}
|
|
3825
3850
|
|
|
3826
3851
|
// src/hmblock-to-editorblock.ts
|
|
3827
3852
|
function toEditorBlockType(hmBlockType) {
|
|
@@ -3943,6 +3968,27 @@ function hmBlockToEditorBlock(block) {
|
|
|
3943
3968
|
return out;
|
|
3944
3969
|
}
|
|
3945
3970
|
while (i < blockText.length) {
|
|
3971
|
+
const inlineEmbed = findInlineEmbedStartingAt(pos);
|
|
3972
|
+
if (inlineEmbed) {
|
|
3973
|
+
if (leaf) {
|
|
3974
|
+
finishLeaf(textStart, i);
|
|
3975
|
+
leaf = null;
|
|
3976
|
+
}
|
|
3977
|
+
if (inlineBlockContent) {
|
|
3978
|
+
leaves.push(inlineBlockContent);
|
|
3979
|
+
inlineBlockContent = null;
|
|
3980
|
+
}
|
|
3981
|
+
leaves.push({
|
|
3982
|
+
type: "inline-embed",
|
|
3983
|
+
styles: {},
|
|
3984
|
+
link: inlineEmbed.link
|
|
3985
|
+
});
|
|
3986
|
+
skipToCodepoint(inlineEmbed.end);
|
|
3987
|
+
textStart = i;
|
|
3988
|
+
leafAnnotations.clear();
|
|
3989
|
+
if (i >= blockText.length) return out;
|
|
3990
|
+
continue;
|
|
3991
|
+
}
|
|
3946
3992
|
let ul = 1;
|
|
3947
3993
|
let annotationsChanged = trackPosAnnotations(pos);
|
|
3948
3994
|
let surrogate = isSurrogate(blockText, i);
|
|
@@ -4007,7 +4053,7 @@ function hmBlockToEditorBlock(block) {
|
|
|
4007
4053
|
i += codeUnits;
|
|
4008
4054
|
}
|
|
4009
4055
|
function startLeaf(posAnnotations) {
|
|
4010
|
-
var _a2, _b2
|
|
4056
|
+
var _a2, _b2;
|
|
4011
4057
|
const newLeaf = {
|
|
4012
4058
|
type: "text",
|
|
4013
4059
|
text: "",
|
|
@@ -4034,28 +4080,30 @@ function hmBlockToEditorBlock(block) {
|
|
|
4034
4080
|
newLeaf.styles[styleKey] = true;
|
|
4035
4081
|
}
|
|
4036
4082
|
if (annotationData.type === "TextColor") {
|
|
4037
|
-
const
|
|
4083
|
+
const attrs = annotationData.attributes;
|
|
4084
|
+
const color = (attrs == null ? void 0 : attrs.value) ?? (attrs == null ? void 0 : attrs.color);
|
|
4038
4085
|
if (typeof color === "string" && color) {
|
|
4039
4086
|
;
|
|
4040
4087
|
newLeaf.styles.textColor = color;
|
|
4041
4088
|
}
|
|
4042
4089
|
}
|
|
4043
4090
|
if (annotationData.type === "BackgroundColor") {
|
|
4044
|
-
const
|
|
4091
|
+
const attrs = annotationData.attributes;
|
|
4092
|
+
const color = (attrs == null ? void 0 : attrs.value) ?? (attrs == null ? void 0 : attrs.color);
|
|
4045
4093
|
if (typeof color === "string" && color) {
|
|
4046
4094
|
;
|
|
4047
4095
|
newLeaf.styles.backgroundColor = color;
|
|
4048
4096
|
}
|
|
4049
4097
|
}
|
|
4050
4098
|
if (annotationData.type === "TextSize") {
|
|
4051
|
-
const size = (
|
|
4099
|
+
const size = (_a2 = annotationData.attributes) == null ? void 0 : _a2.value;
|
|
4052
4100
|
if (typeof size === "string" && size) {
|
|
4053
4101
|
;
|
|
4054
4102
|
newLeaf.styles.textSize = size;
|
|
4055
4103
|
}
|
|
4056
4104
|
}
|
|
4057
4105
|
if (annotationData.type === "TextFamily") {
|
|
4058
|
-
const family = (
|
|
4106
|
+
const family = (_b2 = annotationData.attributes) == null ? void 0 : _b2.value;
|
|
4059
4107
|
if (typeof family === "string" && family) {
|
|
4060
4108
|
;
|
|
4061
4109
|
newLeaf.styles.textFamily = family;
|
|
@@ -4159,6 +4207,27 @@ function hmBlockToEditorBlock(block) {
|
|
|
4159
4207
|
});
|
|
4160
4208
|
return annotationsChanged;
|
|
4161
4209
|
}
|
|
4210
|
+
function findInlineEmbedStartingAt(pos2) {
|
|
4211
|
+
var _a2, _b2;
|
|
4212
|
+
const blockAnnotations = block.annotations;
|
|
4213
|
+
if (!blockAnnotations) return null;
|
|
4214
|
+
for (const annotation of blockAnnotations) {
|
|
4215
|
+
const annotationData = annotation;
|
|
4216
|
+
if (annotationData.type !== "Embed") continue;
|
|
4217
|
+
const spanIndex = ((_a2 = annotationData.starts) == null ? void 0 : _a2.findIndex((start) => start === pos2)) ?? -1;
|
|
4218
|
+
if (spanIndex === -1) continue;
|
|
4219
|
+
const end = (_b2 = annotationData.ends) == null ? void 0 : _b2[spanIndex];
|
|
4220
|
+
if (typeof end !== "number" || end <= pos2) continue;
|
|
4221
|
+
return { link: annotationData.link || "", end };
|
|
4222
|
+
}
|
|
4223
|
+
return null;
|
|
4224
|
+
}
|
|
4225
|
+
function skipToCodepoint(end) {
|
|
4226
|
+
while (pos < end && i < blockText.length) {
|
|
4227
|
+
i += isSurrogate(blockText, i) ? 2 : 1;
|
|
4228
|
+
pos++;
|
|
4229
|
+
}
|
|
4230
|
+
}
|
|
4162
4231
|
}
|
|
4163
4232
|
function annotationContains(annotation, pos) {
|
|
4164
4233
|
let low = 0;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -19,7 +19,13 @@ export type {
|
|
|
19
19
|
export {createSeedClient} from './client'
|
|
20
20
|
export type {PublishDocumentInput, SeedClient, SeedClientOptions} from './client'
|
|
21
21
|
export {commentRecordIdFromBlob, createComment, deleteComment, updateComment} from './comment'
|
|
22
|
-
export type {
|
|
22
|
+
export type {
|
|
23
|
+
CommentAttachmentBlob,
|
|
24
|
+
CreateCommentInput,
|
|
25
|
+
DeleteCommentInput,
|
|
26
|
+
QuotingTarget,
|
|
27
|
+
UpdateCommentInput,
|
|
28
|
+
} from './comment'
|
|
23
29
|
export {contactRecordIdFromBlob, createContact, deleteContact, updateContact} from './contact'
|
|
24
30
|
export type {CreateContactInput, CreateContactResult, DeleteContactInput, UpdateContactInput} from './contact'
|
|
25
31
|
export {SeedClientError, SeedNetworkError, SeedValidationError} from './errors'
|