@seed-hypermedia/client 0.0.54 → 0.0.56

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.
@@ -137,7 +137,12 @@ var HMBlockParagraphSchema = z.object({
137
137
  type: z.literal("Paragraph"),
138
138
  ...blockBaseProperties,
139
139
  ...textBlockProperties,
140
- attributes: z.object(parentBlockAttributes).optional().default({})
140
+ attributes: z.object({
141
+ ...parentBlockAttributes,
142
+ // Present if this Paragraph is a cell inside a TableRow. References a TableColumn
143
+ // block by id.
144
+ columnId: z.string().optional()
145
+ }).optional().default({})
141
146
  }).strict();
142
147
  var HMBlockHeadingSchema = z.object({
143
148
  type: z.literal("Heading"),
@@ -417,6 +422,28 @@ var HMQuerySchema = z.object({
417
422
  z.coerce.number().optional()
418
423
  )
419
424
  });
425
+ var HMBlockTableSchema = z.object({
426
+ type: z.literal("Table"),
427
+ ...blockBaseProperties,
428
+ attributes: z.object(parentBlockAttributes).optional().default({})
429
+ }).strict();
430
+ var HMBlockTableRowSchema = z.object({
431
+ type: z.literal("TableRow"),
432
+ ...blockBaseProperties,
433
+ attributes: z.object({
434
+ ...parentBlockAttributes,
435
+ isHeader: z.boolean().optional()
436
+ }).optional().default({})
437
+ }).strict();
438
+ var HMBlockTableColumnSchema = z.object({
439
+ type: z.literal("TableColumn"),
440
+ ...blockBaseProperties,
441
+ attributes: z.object({
442
+ ...parentBlockAttributes,
443
+ width: z.number().optional(),
444
+ isHeader: z.boolean().optional()
445
+ }).optional().default({})
446
+ }).strict();
420
447
  var HMBlockQuerySchema = z.object({
421
448
  type: z.literal("Query"),
422
449
  ...blockBaseProperties,
@@ -450,6 +477,9 @@ var HMBlockKnownSchema = z.discriminatedUnion("type", [
450
477
  HMBlockEmbedSchema,
451
478
  HMBlockWebEmbedSchema,
452
479
  HMBlockNostrSchema,
480
+ HMBlockTableSchema,
481
+ HMBlockTableRowSchema,
482
+ HMBlockTableColumnSchema,
453
483
  HMBlockQuerySchema,
454
484
  HMBlockGroupSchema,
455
485
  HMBlockLinkSchema
@@ -1339,6 +1369,9 @@ export {
1339
1369
  HMQueryInclusionSchema,
1340
1370
  HMQuerySortSchema,
1341
1371
  HMQuerySchema,
1372
+ HMBlockTableSchema,
1373
+ HMBlockTableRowSchema,
1374
+ HMBlockTableColumnSchema,
1342
1375
  HMBlockQuerySchema,
1343
1376
  HMBlockGroupSchema,
1344
1377
  HMBlockLinkSchema,
@@ -1,5 +1,5 @@
1
1
  import type { HMBlockChildrenType } from './hm-types';
2
- export type EditorBlock = EditorParagraphBlock | EditorHeadingBlock | EditorCodeBlock | EditorImageBlock | EditorVideoBlock | EditorFileBlock | EditorButtonBlock | EditorEmbedBlock | EditorWebEmbedBlock | EditorMathBlock | EditorNostrBlock | EditorQueryBlock | EditorUnknownBlock;
2
+ export type EditorBlock = EditorParagraphBlock | EditorHeadingBlock | EditorCodeBlock | EditorImageBlock | EditorVideoBlock | EditorFileBlock | EditorButtonBlock | EditorEmbedBlock | EditorWebEmbedBlock | EditorMathBlock | EditorNostrBlock | EditorQueryBlock | EditorTableBlock | EditorTableRowBlock | EditorTableColumnBlock | EditorUnknownBlock;
3
3
  export type HMInlineContent = EditorText | EditorInlineEmbed | EditorLink;
4
4
  export interface EditorBaseBlock {
5
5
  id: string;
@@ -13,6 +13,7 @@ export interface EditorBlockProps {
13
13
  level?: number | string;
14
14
  ref?: string;
15
15
  revision?: string;
16
+ columnId?: string;
16
17
  }
17
18
  export interface EditorParagraphBlock extends EditorBaseBlock {
18
19
  type: 'paragraph';
@@ -114,6 +115,25 @@ export type EditorQueryBlock = EditorBaseBlock & {
114
115
  };
115
116
  content: Array<HMInlineContent>;
116
117
  };
118
+ export interface EditorTableBlock extends EditorBaseBlock {
119
+ type: 'table';
120
+ content: Array<HMInlineContent>;
121
+ }
122
+ export interface EditorTableRowBlock extends EditorBaseBlock {
123
+ type: 'tableRow';
124
+ props: EditorBlockProps & {
125
+ isHeader?: boolean;
126
+ };
127
+ content: Array<HMInlineContent>;
128
+ }
129
+ export interface EditorTableColumnBlock extends EditorBaseBlock {
130
+ type: 'tableColumn';
131
+ props: EditorBlockProps & {
132
+ width?: string;
133
+ isHeader?: boolean;
134
+ };
135
+ content: Array<HMInlineContent>;
136
+ }
117
137
  export type EditorUnknownBlock = EditorBaseBlock & {
118
138
  type: 'unknown';
119
139
  props: EditorBlockProps & {
@@ -8,5 +8,9 @@ export declare function editorBlockToHMBlock(editorBlock: EditorBlock): HMBlock;
8
8
  * This is the tree-level wrapper around `editorBlockToHMBlock` that recursively
9
9
  * converts children. Useful when serializing editor content to the HM block format
10
10
  * (e.g. for saving drafts as markdown or publishing documents).
11
+ *
12
+ * parentEditorType is the editor type of the surrounding block. Used
13
+ * to drop orphan table row and column blocks that ended up outside a
14
+ * table parent.
11
15
  */
12
- export declare function editorBlocksToHMBlockNodes(editorBlocks: EditorBlock[]): HMBlockNode[];
16
+ export declare function editorBlocksToHMBlockNodes(editorBlocks: EditorBlock[], parentEditorType?: string): HMBlockNode[];
@@ -878,12 +878,15 @@ export declare const HMAnnotationsSchema: z.ZodOptional<z.ZodArray<z.ZodDiscrimi
878
878
  export type HMAnnotations = z.infer<typeof HMAnnotationsSchema>;
879
879
  export declare const HMBlockParagraphSchema: z.ZodObject<{
880
880
  attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
881
+ columnId: z.ZodOptional<z.ZodString>;
881
882
  childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
882
883
  columnCount: z.ZodOptional<z.ZodNumber>;
883
884
  }, "strip", z.ZodTypeAny, {
885
+ columnId?: string | undefined;
884
886
  childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
885
887
  columnCount?: number | undefined;
886
888
  }, {
889
+ columnId?: string | undefined;
887
890
  childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
888
891
  columnCount?: number | undefined;
889
892
  }>>>;
@@ -1153,6 +1156,7 @@ export declare const HMBlockParagraphSchema: z.ZodObject<{
1153
1156
  type: "Paragraph";
1154
1157
  id: string;
1155
1158
  attributes: {
1159
+ columnId?: string | undefined;
1156
1160
  childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
1157
1161
  columnCount?: number | undefined;
1158
1162
  };
@@ -1245,6 +1249,7 @@ export declare const HMBlockParagraphSchema: z.ZodObject<{
1245
1249
  id: string;
1246
1250
  link?: "" | undefined;
1247
1251
  attributes?: {
1252
+ columnId?: string | undefined;
1248
1253
  childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
1249
1254
  columnCount?: number | undefined;
1250
1255
  } | undefined;
@@ -5665,6 +5670,141 @@ export declare const HMQuerySchema: z.ZodObject<{
5665
5670
  }>;
5666
5671
  export type HMQuery = z.infer<typeof HMQuerySchema>;
5667
5672
  export type HMTimestamp = z.infer<typeof HMTimestampSchema>;
5673
+ export declare const HMBlockTableSchema: z.ZodObject<{
5674
+ attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
5675
+ childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
5676
+ columnCount: z.ZodOptional<z.ZodNumber>;
5677
+ }, "strip", z.ZodTypeAny, {
5678
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
5679
+ columnCount?: number | undefined;
5680
+ }, {
5681
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
5682
+ columnCount?: number | undefined;
5683
+ }>>>;
5684
+ id: z.ZodString;
5685
+ revision: z.ZodOptional<z.ZodString>;
5686
+ annotations: z.ZodOptional<z.ZodArray<z.ZodNever, "many">>;
5687
+ text: z.ZodOptional<z.ZodLiteral<"">>;
5688
+ link: z.ZodOptional<z.ZodLiteral<"">>;
5689
+ type: z.ZodLiteral<"Table">;
5690
+ }, "strict", z.ZodTypeAny, {
5691
+ type: "Table";
5692
+ id: string;
5693
+ attributes: {
5694
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
5695
+ columnCount?: number | undefined;
5696
+ };
5697
+ link?: "" | undefined;
5698
+ text?: "" | undefined;
5699
+ annotations?: never[] | undefined;
5700
+ revision?: string | undefined;
5701
+ }, {
5702
+ type: "Table";
5703
+ id: string;
5704
+ link?: "" | undefined;
5705
+ attributes?: {
5706
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
5707
+ columnCount?: number | undefined;
5708
+ } | undefined;
5709
+ text?: "" | undefined;
5710
+ annotations?: never[] | undefined;
5711
+ revision?: string | undefined;
5712
+ }>;
5713
+ export declare const HMBlockTableRowSchema: z.ZodObject<{
5714
+ attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
5715
+ isHeader: z.ZodOptional<z.ZodBoolean>;
5716
+ childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
5717
+ columnCount: z.ZodOptional<z.ZodNumber>;
5718
+ }, "strip", z.ZodTypeAny, {
5719
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
5720
+ columnCount?: number | undefined;
5721
+ isHeader?: boolean | undefined;
5722
+ }, {
5723
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
5724
+ columnCount?: number | undefined;
5725
+ isHeader?: boolean | undefined;
5726
+ }>>>;
5727
+ id: z.ZodString;
5728
+ revision: z.ZodOptional<z.ZodString>;
5729
+ annotations: z.ZodOptional<z.ZodArray<z.ZodNever, "many">>;
5730
+ text: z.ZodOptional<z.ZodLiteral<"">>;
5731
+ link: z.ZodOptional<z.ZodLiteral<"">>;
5732
+ type: z.ZodLiteral<"TableRow">;
5733
+ }, "strict", z.ZodTypeAny, {
5734
+ type: "TableRow";
5735
+ id: string;
5736
+ attributes: {
5737
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
5738
+ columnCount?: number | undefined;
5739
+ isHeader?: boolean | undefined;
5740
+ };
5741
+ link?: "" | undefined;
5742
+ text?: "" | undefined;
5743
+ annotations?: never[] | undefined;
5744
+ revision?: string | undefined;
5745
+ }, {
5746
+ type: "TableRow";
5747
+ id: string;
5748
+ link?: "" | undefined;
5749
+ attributes?: {
5750
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
5751
+ columnCount?: number | undefined;
5752
+ isHeader?: boolean | undefined;
5753
+ } | undefined;
5754
+ text?: "" | undefined;
5755
+ annotations?: never[] | undefined;
5756
+ revision?: string | undefined;
5757
+ }>;
5758
+ export declare const HMBlockTableColumnSchema: z.ZodObject<{
5759
+ attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
5760
+ width: z.ZodOptional<z.ZodNumber>;
5761
+ isHeader: z.ZodOptional<z.ZodBoolean>;
5762
+ childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
5763
+ columnCount: z.ZodOptional<z.ZodNumber>;
5764
+ }, "strip", z.ZodTypeAny, {
5765
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
5766
+ columnCount?: number | undefined;
5767
+ width?: number | undefined;
5768
+ isHeader?: boolean | undefined;
5769
+ }, {
5770
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
5771
+ columnCount?: number | undefined;
5772
+ width?: number | undefined;
5773
+ isHeader?: boolean | undefined;
5774
+ }>>>;
5775
+ id: z.ZodString;
5776
+ revision: z.ZodOptional<z.ZodString>;
5777
+ annotations: z.ZodOptional<z.ZodArray<z.ZodNever, "many">>;
5778
+ text: z.ZodOptional<z.ZodLiteral<"">>;
5779
+ link: z.ZodOptional<z.ZodLiteral<"">>;
5780
+ type: z.ZodLiteral<"TableColumn">;
5781
+ }, "strict", z.ZodTypeAny, {
5782
+ type: "TableColumn";
5783
+ id: string;
5784
+ attributes: {
5785
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
5786
+ columnCount?: number | undefined;
5787
+ width?: number | undefined;
5788
+ isHeader?: boolean | undefined;
5789
+ };
5790
+ link?: "" | undefined;
5791
+ text?: "" | undefined;
5792
+ annotations?: never[] | undefined;
5793
+ revision?: string | undefined;
5794
+ }, {
5795
+ type: "TableColumn";
5796
+ id: string;
5797
+ link?: "" | undefined;
5798
+ attributes?: {
5799
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
5800
+ columnCount?: number | undefined;
5801
+ width?: number | undefined;
5802
+ isHeader?: boolean | undefined;
5803
+ } | undefined;
5804
+ text?: "" | undefined;
5805
+ annotations?: never[] | undefined;
5806
+ revision?: string | undefined;
5807
+ }>;
5668
5808
  export declare const HMBlockQuerySchema: z.ZodObject<{
5669
5809
  attributes: z.ZodObject<{
5670
5810
  style: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"Card">, z.ZodLiteral<"List">]>>>;
@@ -5839,12 +5979,15 @@ export declare const HMBlockLinkSchema: z.ZodObject<{
5839
5979
  }>;
5840
5980
  export declare const HMBlockKnownSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
5841
5981
  attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
5982
+ columnId: z.ZodOptional<z.ZodString>;
5842
5983
  childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
5843
5984
  columnCount: z.ZodOptional<z.ZodNumber>;
5844
5985
  }, "strip", z.ZodTypeAny, {
5986
+ columnId?: string | undefined;
5845
5987
  childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
5846
5988
  columnCount?: number | undefined;
5847
5989
  }, {
5990
+ columnId?: string | undefined;
5848
5991
  childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
5849
5992
  columnCount?: number | undefined;
5850
5993
  }>>>;
@@ -6114,6 +6257,7 @@ export declare const HMBlockKnownSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
6114
6257
  type: "Paragraph";
6115
6258
  id: string;
6116
6259
  attributes: {
6260
+ columnId?: string | undefined;
6117
6261
  childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
6118
6262
  columnCount?: number | undefined;
6119
6263
  };
@@ -6206,6 +6350,7 @@ export declare const HMBlockKnownSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
6206
6350
  id: string;
6207
6351
  link?: "" | undefined;
6208
6352
  attributes?: {
6353
+ columnId?: string | undefined;
6209
6354
  childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
6210
6355
  columnCount?: number | undefined;
6211
6356
  } | undefined;
@@ -7549,6 +7694,138 @@ export declare const HMBlockKnownSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
7549
7694
  text?: "" | undefined;
7550
7695
  annotations?: never[] | undefined;
7551
7696
  revision?: string | undefined;
7697
+ }>, z.ZodObject<{
7698
+ attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
7699
+ childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
7700
+ columnCount: z.ZodOptional<z.ZodNumber>;
7701
+ }, "strip", z.ZodTypeAny, {
7702
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
7703
+ columnCount?: number | undefined;
7704
+ }, {
7705
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
7706
+ columnCount?: number | undefined;
7707
+ }>>>;
7708
+ id: z.ZodString;
7709
+ revision: z.ZodOptional<z.ZodString>;
7710
+ annotations: z.ZodOptional<z.ZodArray<z.ZodNever, "many">>;
7711
+ text: z.ZodOptional<z.ZodLiteral<"">>;
7712
+ link: z.ZodOptional<z.ZodLiteral<"">>;
7713
+ type: z.ZodLiteral<"Table">;
7714
+ }, "strict", z.ZodTypeAny, {
7715
+ type: "Table";
7716
+ id: string;
7717
+ attributes: {
7718
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
7719
+ columnCount?: number | undefined;
7720
+ };
7721
+ link?: "" | undefined;
7722
+ text?: "" | undefined;
7723
+ annotations?: never[] | undefined;
7724
+ revision?: string | undefined;
7725
+ }, {
7726
+ type: "Table";
7727
+ id: string;
7728
+ link?: "" | undefined;
7729
+ attributes?: {
7730
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
7731
+ columnCount?: number | undefined;
7732
+ } | undefined;
7733
+ text?: "" | undefined;
7734
+ annotations?: never[] | undefined;
7735
+ revision?: string | undefined;
7736
+ }>, z.ZodObject<{
7737
+ attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
7738
+ isHeader: z.ZodOptional<z.ZodBoolean>;
7739
+ childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
7740
+ columnCount: z.ZodOptional<z.ZodNumber>;
7741
+ }, "strip", z.ZodTypeAny, {
7742
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
7743
+ columnCount?: number | undefined;
7744
+ isHeader?: boolean | undefined;
7745
+ }, {
7746
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
7747
+ columnCount?: number | undefined;
7748
+ isHeader?: boolean | undefined;
7749
+ }>>>;
7750
+ id: z.ZodString;
7751
+ revision: z.ZodOptional<z.ZodString>;
7752
+ annotations: z.ZodOptional<z.ZodArray<z.ZodNever, "many">>;
7753
+ text: z.ZodOptional<z.ZodLiteral<"">>;
7754
+ link: z.ZodOptional<z.ZodLiteral<"">>;
7755
+ type: z.ZodLiteral<"TableRow">;
7756
+ }, "strict", z.ZodTypeAny, {
7757
+ type: "TableRow";
7758
+ id: string;
7759
+ attributes: {
7760
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
7761
+ columnCount?: number | undefined;
7762
+ isHeader?: boolean | undefined;
7763
+ };
7764
+ link?: "" | undefined;
7765
+ text?: "" | undefined;
7766
+ annotations?: never[] | undefined;
7767
+ revision?: string | undefined;
7768
+ }, {
7769
+ type: "TableRow";
7770
+ id: string;
7771
+ link?: "" | undefined;
7772
+ attributes?: {
7773
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
7774
+ columnCount?: number | undefined;
7775
+ isHeader?: boolean | undefined;
7776
+ } | undefined;
7777
+ text?: "" | undefined;
7778
+ annotations?: never[] | undefined;
7779
+ revision?: string | undefined;
7780
+ }>, z.ZodObject<{
7781
+ attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
7782
+ width: z.ZodOptional<z.ZodNumber>;
7783
+ isHeader: z.ZodOptional<z.ZodBoolean>;
7784
+ childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
7785
+ columnCount: z.ZodOptional<z.ZodNumber>;
7786
+ }, "strip", z.ZodTypeAny, {
7787
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
7788
+ columnCount?: number | undefined;
7789
+ width?: number | undefined;
7790
+ isHeader?: boolean | undefined;
7791
+ }, {
7792
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
7793
+ columnCount?: number | undefined;
7794
+ width?: number | undefined;
7795
+ isHeader?: boolean | undefined;
7796
+ }>>>;
7797
+ id: z.ZodString;
7798
+ revision: z.ZodOptional<z.ZodString>;
7799
+ annotations: z.ZodOptional<z.ZodArray<z.ZodNever, "many">>;
7800
+ text: z.ZodOptional<z.ZodLiteral<"">>;
7801
+ link: z.ZodOptional<z.ZodLiteral<"">>;
7802
+ type: z.ZodLiteral<"TableColumn">;
7803
+ }, "strict", z.ZodTypeAny, {
7804
+ type: "TableColumn";
7805
+ id: string;
7806
+ attributes: {
7807
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
7808
+ columnCount?: number | undefined;
7809
+ width?: number | undefined;
7810
+ isHeader?: boolean | undefined;
7811
+ };
7812
+ link?: "" | undefined;
7813
+ text?: "" | undefined;
7814
+ annotations?: never[] | undefined;
7815
+ revision?: string | undefined;
7816
+ }, {
7817
+ type: "TableColumn";
7818
+ id: string;
7819
+ link?: "" | undefined;
7820
+ attributes?: {
7821
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
7822
+ columnCount?: number | undefined;
7823
+ width?: number | undefined;
7824
+ isHeader?: boolean | undefined;
7825
+ } | undefined;
7826
+ text?: "" | undefined;
7827
+ annotations?: never[] | undefined;
7828
+ revision?: string | undefined;
7552
7829
  }>, z.ZodObject<{
7553
7830
  attributes: z.ZodObject<{
7554
7831
  style: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"Card">, z.ZodLiteral<"List">]>>>;
@@ -7746,12 +8023,15 @@ export declare const HMBlockUnknownSchema: z.ZodObject<{
7746
8023
  }, z.ZodTypeAny, "passthrough">>;
7747
8024
  export declare const HMBlockSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
7748
8025
  attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
8026
+ columnId: z.ZodOptional<z.ZodString>;
7749
8027
  childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
7750
8028
  columnCount: z.ZodOptional<z.ZodNumber>;
7751
8029
  }, "strip", z.ZodTypeAny, {
8030
+ columnId?: string | undefined;
7752
8031
  childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
7753
8032
  columnCount?: number | undefined;
7754
8033
  }, {
8034
+ columnId?: string | undefined;
7755
8035
  childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
7756
8036
  columnCount?: number | undefined;
7757
8037
  }>>>;
@@ -8021,6 +8301,7 @@ export declare const HMBlockSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type",
8021
8301
  type: "Paragraph";
8022
8302
  id: string;
8023
8303
  attributes: {
8304
+ columnId?: string | undefined;
8024
8305
  childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
8025
8306
  columnCount?: number | undefined;
8026
8307
  };
@@ -8113,6 +8394,7 @@ export declare const HMBlockSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type",
8113
8394
  id: string;
8114
8395
  link?: "" | undefined;
8115
8396
  attributes?: {
8397
+ columnId?: string | undefined;
8116
8398
  childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
8117
8399
  columnCount?: number | undefined;
8118
8400
  } | undefined;
@@ -9456,6 +9738,138 @@ export declare const HMBlockSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type",
9456
9738
  text?: "" | undefined;
9457
9739
  annotations?: never[] | undefined;
9458
9740
  revision?: string | undefined;
9741
+ }>, z.ZodObject<{
9742
+ attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
9743
+ childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
9744
+ columnCount: z.ZodOptional<z.ZodNumber>;
9745
+ }, "strip", z.ZodTypeAny, {
9746
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
9747
+ columnCount?: number | undefined;
9748
+ }, {
9749
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
9750
+ columnCount?: number | undefined;
9751
+ }>>>;
9752
+ id: z.ZodString;
9753
+ revision: z.ZodOptional<z.ZodString>;
9754
+ annotations: z.ZodOptional<z.ZodArray<z.ZodNever, "many">>;
9755
+ text: z.ZodOptional<z.ZodLiteral<"">>;
9756
+ link: z.ZodOptional<z.ZodLiteral<"">>;
9757
+ type: z.ZodLiteral<"Table">;
9758
+ }, "strict", z.ZodTypeAny, {
9759
+ type: "Table";
9760
+ id: string;
9761
+ attributes: {
9762
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
9763
+ columnCount?: number | undefined;
9764
+ };
9765
+ link?: "" | undefined;
9766
+ text?: "" | undefined;
9767
+ annotations?: never[] | undefined;
9768
+ revision?: string | undefined;
9769
+ }, {
9770
+ type: "Table";
9771
+ id: string;
9772
+ link?: "" | undefined;
9773
+ attributes?: {
9774
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
9775
+ columnCount?: number | undefined;
9776
+ } | undefined;
9777
+ text?: "" | undefined;
9778
+ annotations?: never[] | undefined;
9779
+ revision?: string | undefined;
9780
+ }>, z.ZodObject<{
9781
+ attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
9782
+ isHeader: z.ZodOptional<z.ZodBoolean>;
9783
+ childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
9784
+ columnCount: z.ZodOptional<z.ZodNumber>;
9785
+ }, "strip", z.ZodTypeAny, {
9786
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
9787
+ columnCount?: number | undefined;
9788
+ isHeader?: boolean | undefined;
9789
+ }, {
9790
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
9791
+ columnCount?: number | undefined;
9792
+ isHeader?: boolean | undefined;
9793
+ }>>>;
9794
+ id: z.ZodString;
9795
+ revision: z.ZodOptional<z.ZodString>;
9796
+ annotations: z.ZodOptional<z.ZodArray<z.ZodNever, "many">>;
9797
+ text: z.ZodOptional<z.ZodLiteral<"">>;
9798
+ link: z.ZodOptional<z.ZodLiteral<"">>;
9799
+ type: z.ZodLiteral<"TableRow">;
9800
+ }, "strict", z.ZodTypeAny, {
9801
+ type: "TableRow";
9802
+ id: string;
9803
+ attributes: {
9804
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
9805
+ columnCount?: number | undefined;
9806
+ isHeader?: boolean | undefined;
9807
+ };
9808
+ link?: "" | undefined;
9809
+ text?: "" | undefined;
9810
+ annotations?: never[] | undefined;
9811
+ revision?: string | undefined;
9812
+ }, {
9813
+ type: "TableRow";
9814
+ id: string;
9815
+ link?: "" | undefined;
9816
+ attributes?: {
9817
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
9818
+ columnCount?: number | undefined;
9819
+ isHeader?: boolean | undefined;
9820
+ } | undefined;
9821
+ text?: "" | undefined;
9822
+ annotations?: never[] | undefined;
9823
+ revision?: string | undefined;
9824
+ }>, z.ZodObject<{
9825
+ attributes: z.ZodDefault<z.ZodOptional<z.ZodObject<{
9826
+ width: z.ZodOptional<z.ZodNumber>;
9827
+ isHeader: z.ZodOptional<z.ZodBoolean>;
9828
+ childrenType: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"Group">, z.ZodLiteral<"Ordered">, z.ZodLiteral<"Unordered">, z.ZodLiteral<"Blockquote">, z.ZodLiteral<"Grid">]>>>;
9829
+ columnCount: z.ZodOptional<z.ZodNumber>;
9830
+ }, "strip", z.ZodTypeAny, {
9831
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
9832
+ columnCount?: number | undefined;
9833
+ width?: number | undefined;
9834
+ isHeader?: boolean | undefined;
9835
+ }, {
9836
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
9837
+ columnCount?: number | undefined;
9838
+ width?: number | undefined;
9839
+ isHeader?: boolean | undefined;
9840
+ }>>>;
9841
+ id: z.ZodString;
9842
+ revision: z.ZodOptional<z.ZodString>;
9843
+ annotations: z.ZodOptional<z.ZodArray<z.ZodNever, "many">>;
9844
+ text: z.ZodOptional<z.ZodLiteral<"">>;
9845
+ link: z.ZodOptional<z.ZodLiteral<"">>;
9846
+ type: z.ZodLiteral<"TableColumn">;
9847
+ }, "strict", z.ZodTypeAny, {
9848
+ type: "TableColumn";
9849
+ id: string;
9850
+ attributes: {
9851
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
9852
+ columnCount?: number | undefined;
9853
+ width?: number | undefined;
9854
+ isHeader?: boolean | undefined;
9855
+ };
9856
+ link?: "" | undefined;
9857
+ text?: "" | undefined;
9858
+ annotations?: never[] | undefined;
9859
+ revision?: string | undefined;
9860
+ }, {
9861
+ type: "TableColumn";
9862
+ id: string;
9863
+ link?: "" | undefined;
9864
+ attributes?: {
9865
+ childrenType?: "Group" | "Ordered" | "Unordered" | "Blockquote" | "Grid" | null | undefined;
9866
+ columnCount?: number | undefined;
9867
+ width?: number | undefined;
9868
+ isHeader?: boolean | undefined;
9869
+ } | undefined;
9870
+ text?: "" | undefined;
9871
+ annotations?: never[] | undefined;
9872
+ revision?: string | undefined;
9459
9873
  }>, z.ZodObject<{
9460
9874
  attributes: z.ZodObject<{
9461
9875
  style: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"Card">, z.ZodLiteral<"List">]>>>;
@@ -9665,6 +10079,9 @@ export type HMBlockWebEmbed = z.infer<typeof HMBlockWebEmbedSchema>;
9665
10079
  export type HMBlockQuery = z.infer<typeof HMBlockQuerySchema>;
9666
10080
  export type HMBlock = z.infer<typeof HMBlockKnownSchema>;
9667
10081
  export type HMBlockNostr = z.infer<typeof HMBlockNostrSchema>;
10082
+ export type HMBlockTable = z.infer<typeof HMBlockTableSchema>;
10083
+ export type HMBlockTableRow = z.infer<typeof HMBlockTableRowSchema>;
10084
+ export type HMBlockTableColumn = z.infer<typeof HMBlockTableColumnSchema>;
9668
10085
  export declare const HMDocumentSchema: z.ZodObject<{
9669
10086
  content: z.ZodDefault<z.ZodArray<z.ZodType<HMBlockNode, z.ZodTypeDef, HMBlockNode>, "many">>;
9670
10087
  version: z.ZodDefault<z.ZodString>;
package/dist/hm-types.mjs CHANGED
@@ -30,6 +30,9 @@ import {
30
30
  HMBlockParagraphSchema,
31
31
  HMBlockQuerySchema,
32
32
  HMBlockSchema,
33
+ HMBlockTableColumnSchema,
34
+ HMBlockTableRowSchema,
35
+ HMBlockTableSchema,
33
36
  HMBlockUnknownSchema,
34
37
  HMBlockVideoSchema,
35
38
  HMBlockWebEmbedSchema,
@@ -176,7 +179,7 @@ import {
176
179
  toNumber,
177
180
  unpackHmId,
178
181
  unpackedHmIdSchema
179
- } from "./chunk-AQLH2QY4.mjs";
182
+ } from "./chunk-64F47WK6.mjs";
180
183
  export {
181
184
  BackgroundColorAnnotationSchema,
182
185
  BlockRangeSchema,
@@ -209,6 +212,9 @@ export {
209
212
  HMBlockParagraphSchema,
210
213
  HMBlockQuerySchema,
211
214
  HMBlockSchema,
215
+ HMBlockTableColumnSchema,
216
+ HMBlockTableRowSchema,
217
+ HMBlockTableSchema,
212
218
  HMBlockUnknownSchema,
213
219
  HMBlockVideoSchema,
214
220
  HMBlockWebEmbedSchema,
@@ -1,14 +1,18 @@
1
1
  import type { EditorBlock } from './editor-types';
2
- import { type HMBlock, type HMBlockChildrenType, type HMBlockNode } from './hm-types';
2
+ import { type HMBlock, type HMBlockChildrenType, type HMBlockNode, type HMBlockType } from './hm-types';
3
3
  import type { SpanAnnotation } from './unicode';
4
4
  type ServerToEditorRecursiveOpts = {
5
5
  level?: number;
6
6
  };
7
- /** Convert an array of HMBlockNode trees into BlockNote EditorBlock arrays. */
7
+ /** Convert an array of HMBlockNode trees into BlockNote EditorBlock arrays.
8
+ *
9
+ * parentType is the BlockNode type of the surrounding block. Used to drop
10
+ * orphan table row and column blocks that ended up outside a table parent. */
8
11
  export declare function hmBlocksToEditorContent(blocks: HMBlockNode[], opts?: ServerToEditorRecursiveOpts & {
9
12
  childrenType?: HMBlockChildrenType;
10
13
  listLevel?: string;
11
14
  start?: string;
15
+ parentType?: HMBlockType;
12
16
  }): Array<EditorBlock>;
13
17
  /** Convert a single HMBlock into a BlockNote EditorBlock. */
14
18
  export declare function hmBlockToEditorBlock(block: HMBlock): EditorBlock;
package/dist/index.mjs CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  serializeBlockRange,
18
18
  toNumber,
19
19
  unpackHmId
20
- } from "./chunk-AQLH2QY4.mjs";
20
+ } from "./chunk-64F47WK6.mjs";
21
21
 
22
22
  // src/capability.ts
23
23
  import { encode as cborEncode2 } from "@ipld/dag-cbor";
@@ -2771,7 +2771,7 @@ function tokenize(markdown) {
2771
2771
  }
2772
2772
  if (line.trim().startsWith("```")) {
2773
2773
  const fenceContent = line.trim().slice(3).trim();
2774
- const { text: language, id } = stripBlockId(fenceContent);
2774
+ const { text: language, id: id2 } = stripBlockId(fenceContent);
2775
2775
  const codeLines = [];
2776
2776
  i++;
2777
2777
  while (i < lines.length && !lines[i].trim().startsWith("```")) {
@@ -2779,13 +2779,13 @@ function tokenize(markdown) {
2779
2779
  i++;
2780
2780
  }
2781
2781
  i++;
2782
- blocks.push({ kind: "code", language, text: codeLines.join("\n"), id });
2782
+ blocks.push({ kind: "code", language, text: codeLines.join("\n"), id: id2 });
2783
2783
  pendingContainerId = void 0;
2784
2784
  continue;
2785
2785
  }
2786
2786
  if (line.trim().startsWith("$$")) {
2787
2787
  const fenceContent = line.trim().slice(2).trim();
2788
- const { id } = stripBlockId(fenceContent);
2788
+ const { id: id2 } = stripBlockId(fenceContent);
2789
2789
  const mathLines = [];
2790
2790
  i++;
2791
2791
  while (i < lines.length && !lines[i].trim().startsWith("$$")) {
@@ -2793,14 +2793,14 @@ function tokenize(markdown) {
2793
2793
  i++;
2794
2794
  }
2795
2795
  i++;
2796
- blocks.push({ kind: "math", text: mathLines.join("\n"), id });
2796
+ blocks.push({ kind: "math", text: mathLines.join("\n"), id: id2 });
2797
2797
  pendingContainerId = void 0;
2798
2798
  continue;
2799
2799
  }
2800
- const headingMatch = line.match(/^(#{1,6})\s+(.+)$/);
2800
+ const headingMatch = line.trim().match(/^(#{1,6})\s+(.+)$/);
2801
2801
  if (headingMatch) {
2802
- const { text, id } = stripBlockId(headingMatch[2]);
2803
- blocks.push({ kind: "heading", level: headingMatch[1].length, text, id });
2802
+ const { text, id: id2 } = stripBlockId(headingMatch[2]);
2803
+ blocks.push({ kind: "heading", level: headingMatch[1].length, text, id: id2 });
2804
2804
  i++;
2805
2805
  pendingContainerId = void 0;
2806
2806
  continue;
@@ -2809,11 +2809,11 @@ function tokenize(markdown) {
2809
2809
  if (imageMatch) {
2810
2810
  let url = imageMatch[2];
2811
2811
  const trailing = imageMatch[3] || "";
2812
- const { id } = stripBlockId(trailing);
2812
+ const { id: id2 } = stripBlockId(trailing);
2813
2813
  if (url && !url.match(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//)) {
2814
2814
  url = `file://${url}`;
2815
2815
  }
2816
- blocks.push({ kind: "image", alt: imageMatch[1], url, id });
2816
+ blocks.push({ kind: "image", alt: imageMatch[1], url, id: id2 });
2817
2817
  i++;
2818
2818
  pendingContainerId = void 0;
2819
2819
  continue;
@@ -2832,8 +2832,8 @@ function tokenize(markdown) {
2832
2832
  const items = [];
2833
2833
  while (i < lines.length && /^[-*+]\s+/.test(lines[i].trim())) {
2834
2834
  const raw = lines[i].trim().replace(/^[-*+]\s+/, "");
2835
- const { text, id } = stripBlockId(raw);
2836
- items.push({ text, id });
2835
+ const { text, id: id2 } = stripBlockId(raw);
2836
+ items.push({ text, id: id2 });
2837
2837
  i++;
2838
2838
  }
2839
2839
  blocks.push({ kind: "ul", items, containerId: pendingContainerId });
@@ -2844,8 +2844,8 @@ function tokenize(markdown) {
2844
2844
  const items = [];
2845
2845
  while (i < lines.length && /^\d+\.\s+/.test(lines[i].trim())) {
2846
2846
  const raw = lines[i].trim().replace(/^\d+\.\s+/, "");
2847
- const { text, id } = stripBlockId(raw);
2848
- items.push({ text, id });
2847
+ const { text, id: id2 } = stripBlockId(raw);
2848
+ items.push({ text, id: id2 });
2849
2849
  i++;
2850
2850
  }
2851
2851
  blocks.push({ kind: "ol", items, containerId: pendingContainerId });
@@ -2857,13 +2857,15 @@ function tokenize(markdown) {
2857
2857
  paraLines.push(lines[i]);
2858
2858
  i++;
2859
2859
  }
2860
- if (paraLines.length > 0) {
2861
- const firstLine = paraLines[0];
2862
- const { text: cleanFirst, id } = stripBlockId(firstLine);
2863
- paraLines[0] = cleanFirst;
2864
- blocks.push({ kind: "paragraph", text: paraLines.join("\n"), id });
2865
- pendingContainerId = void 0;
2860
+ if (paraLines.length === 0) {
2861
+ paraLines.push(line);
2862
+ i++;
2866
2863
  }
2864
+ const firstLine = paraLines[0];
2865
+ const { text: cleanFirst, id } = stripBlockId(firstLine);
2866
+ paraLines[0] = cleanFirst;
2867
+ blocks.push({ kind: "paragraph", text: paraLines.join("\n"), id });
2868
+ pendingContainerId = void 0;
2867
2869
  }
2868
2870
  return blocks;
2869
2871
  }
@@ -4098,6 +4100,9 @@ function toHMBlockType(editorBlockType) {
4098
4100
  if (editorBlockType === "embed") return "Embed";
4099
4101
  if (editorBlockType === "web-embed") return "WebEmbed";
4100
4102
  if (editorBlockType === "query") return "Query";
4103
+ if (editorBlockType === "table") return "Table";
4104
+ if (editorBlockType === "tableRow") return "TableRow";
4105
+ if (editorBlockType === "tableColumn") return "TableColumn";
4101
4106
  return void 0;
4102
4107
  }
4103
4108
  function toImageWidthNumber(width) {
@@ -4277,6 +4282,30 @@ function editorBlockToHMBlock(editorBlock) {
4277
4282
  if (editorBlock.props.url) blockEmbed.link = editorBlock.props.url;
4278
4283
  if (editorBlock.props.view) blockEmbed.attributes.view = editorBlock.props.view;
4279
4284
  }
4285
+ const blockParagraph = block.type === "Paragraph" ? block : void 0;
4286
+ if (blockParagraph && editorBlock.type == "paragraph") {
4287
+ if (editorBlock.props.columnId) {
4288
+ blockParagraph.attributes.columnId = editorBlock.props.columnId;
4289
+ }
4290
+ }
4291
+ const blockTable = block.type === "Table" ? block : void 0;
4292
+ if (blockTable && editorBlock.type == "table") {
4293
+ blockTable.text = "";
4294
+ }
4295
+ const blockTableRow = block.type === "TableRow" ? block : void 0;
4296
+ if (blockTableRow && editorBlock.type == "tableRow") {
4297
+ blockTableRow.text = "";
4298
+ if (editorBlock.props.isHeader) blockTableRow.attributes.isHeader = true;
4299
+ }
4300
+ const blockTableColumn = block.type === "TableColumn" ? block : void 0;
4301
+ if (blockTableColumn && editorBlock.type == "tableColumn") {
4302
+ blockTableColumn.text = "";
4303
+ if (editorBlock.props.width != null && editorBlock.props.width !== "") {
4304
+ const width = toNumber(editorBlock.props.width);
4305
+ if (width) blockTableColumn.attributes.width = width;
4306
+ }
4307
+ if (editorBlock.props.isHeader) blockTableColumn.attributes.isHeader = true;
4308
+ }
4280
4309
  const blockQuery = block.type === "Query" ? block : void 0;
4281
4310
  if (blockQuery && editorBlock.type == "query") {
4282
4311
  blockQuery.attributes.style = editorBlock.props.style;
@@ -4299,16 +4328,34 @@ function editorBlockToHMBlock(editorBlock) {
4299
4328
  console.error("Failed to validate block for writing", block, failedParse.error);
4300
4329
  throw new Error("Failed to validate block for writing " + JSON.stringify(failedParse.error));
4301
4330
  }
4302
- function editorBlocksToHMBlockNodes(editorBlocks) {
4303
- return editorBlocks.map((block) => {
4304
- var _a, _b;
4331
+ function editorBlocksToHMBlockNodes(editorBlocks, parentEditorType) {
4332
+ const parentIsTable = parentEditorType === "table";
4333
+ let rowIdx = 0;
4334
+ let colIdx = 0;
4335
+ return editorBlocks.filter((block) => {
4336
+ if ((block.type === "tableRow" || block.type === "tableColumn") && !parentIsTable) {
4337
+ console.warn(
4338
+ `[editorBlocksToHMBlockNodes] dropping orphan ${block.type} block (parent type: ${parentEditorType ?? "root"})`,
4339
+ block.id
4340
+ );
4341
+ return false;
4342
+ }
4343
+ return true;
4344
+ }).map((block) => {
4345
+ var _a, _b, _c;
4346
+ let positionIdx;
4347
+ if (parentIsTable) {
4348
+ if (block.type === "tableRow") positionIdx = rowIdx++;
4349
+ else if (block.type === "tableColumn") positionIdx = colIdx++;
4350
+ }
4351
+ let hmNode;
4305
4352
  try {
4306
- return {
4353
+ hmNode = {
4307
4354
  block: editorBlockToHMBlock(block),
4308
- children: ((_a = block.children) == null ? void 0 : _a.length) ? editorBlocksToHMBlockNodes(block.children) : void 0
4355
+ children: ((_a = block.children) == null ? void 0 : _a.length) ? editorBlocksToHMBlockNodes(block.children, block.type) : void 0
4309
4356
  };
4310
4357
  } catch {
4311
- return {
4358
+ hmNode = {
4312
4359
  block: {
4313
4360
  id: block.id || "unknown",
4314
4361
  type: "Paragraph",
@@ -4316,9 +4363,16 @@ function editorBlocksToHMBlockNodes(editorBlocks) {
4316
4363
  annotations: [],
4317
4364
  attributes: {}
4318
4365
  },
4319
- children: ((_b = block.children) == null ? void 0 : _b.length) ? editorBlocksToHMBlockNodes(block.children) : void 0
4366
+ children: ((_b = block.children) == null ? void 0 : _b.length) ? editorBlocksToHMBlockNodes(block.children, block.type) : void 0
4320
4367
  };
4321
4368
  }
4369
+ if (positionIdx !== void 0 && positionIdx > 0) {
4370
+ const attrs = (_c = hmNode.block) == null ? void 0 : _c.attributes;
4371
+ if (attrs && "isHeader" in attrs) {
4372
+ delete attrs.isHeader;
4373
+ }
4374
+ }
4375
+ return hmNode;
4322
4376
  }).filter(Boolean);
4323
4377
  }
4324
4378
  function flattenLeaves(content) {
@@ -4374,28 +4428,58 @@ function toEditorBlockType(hmBlockType) {
4374
4428
  if (hmBlockType === "Embed") return "embed";
4375
4429
  if (hmBlockType === "WebEmbed") return "web-embed";
4376
4430
  if (hmBlockType === "Query") return "query";
4431
+ if (hmBlockType === "Table") return "table";
4432
+ if (hmBlockType === "TableRow") return "tableRow";
4433
+ if (hmBlockType === "TableColumn") return "tableColumn";
4377
4434
  return "unknown";
4378
4435
  }
4379
4436
  function hmBlocksToEditorContent(blocks, opts = { level: 1 }) {
4380
4437
  const childRecursiveOpts = {
4381
4438
  level: opts.level || 0
4382
4439
  };
4383
- return blocks.map((hmBlock) => {
4384
- var _a, _b, _c;
4440
+ const parentIsTable = opts.parentType === "Table";
4441
+ let rowIdx = 0;
4442
+ let colIdx = 0;
4443
+ return blocks.filter((hmBlock) => {
4444
+ var _a, _b;
4445
+ const t = (_a = hmBlock.block) == null ? void 0 : _a.type;
4446
+ if ((t === "TableRow" || t === "TableColumn") && !parentIsTable) {
4447
+ console.warn(
4448
+ `[hmBlocksToEditorContent] dropping orphan ${t} block (parent type: ${opts.parentType ?? "root"})`,
4449
+ (_b = hmBlock.block) == null ? void 0 : _b.id
4450
+ );
4451
+ return false;
4452
+ }
4453
+ return true;
4454
+ }).map((hmBlock) => {
4455
+ var _a, _b, _c, _d, _e;
4456
+ let positionIdx;
4457
+ if (parentIsTable) {
4458
+ const t = (_a = hmBlock.block) == null ? void 0 : _a.type;
4459
+ if (t === "TableRow") positionIdx = rowIdx++;
4460
+ else if (t === "TableColumn") positionIdx = colIdx++;
4461
+ }
4385
4462
  let res = hmBlock.block ? hmBlockToEditorBlock(hmBlock.block) : null;
4386
- if (res && ((_a = hmBlock.children) == null ? void 0 : _a.length)) {
4387
- const childrenType = (_c = ((_b = hmBlock.block) == null ? void 0 : _b.attributes) || {}) == null ? void 0 : _c.childrenType;
4463
+ if (res && positionIdx !== void 0 && positionIdx > 0) {
4464
+ const props = res.props;
4465
+ if (props && "isHeader" in props) {
4466
+ delete props.isHeader;
4467
+ }
4468
+ }
4469
+ if (res && ((_b = hmBlock.children) == null ? void 0 : _b.length)) {
4470
+ const childrenType = (_d = ((_c = hmBlock.block) == null ? void 0 : _c.attributes) || {}) == null ? void 0 : _d.childrenType;
4388
4471
  const validChildrenType = childrenType === "Group" || childrenType === "Ordered" || childrenType === "Unordered" || childrenType === "Blockquote" || childrenType === "Grid" ? childrenType : "Group";
4389
4472
  res.children = hmBlocksToEditorContent(hmBlock.children, {
4390
4473
  level: childRecursiveOpts.level ? childRecursiveOpts.level + 1 : 1,
4391
- childrenType: validChildrenType
4474
+ childrenType: validChildrenType,
4475
+ parentType: (_e = hmBlock.block) == null ? void 0 : _e.type
4392
4476
  });
4393
4477
  }
4394
4478
  return res;
4395
4479
  }).filter((block) => block !== null);
4396
4480
  }
4397
4481
  function hmBlockToEditorBlock(block) {
4398
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4482
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
4399
4483
  const blockType = toEditorBlockType(block.type);
4400
4484
  if (blockType === "unknown") {
4401
4485
  return {
@@ -4458,14 +4542,40 @@ function hmBlockToEditorBlock(block) {
4458
4542
  });
4459
4543
  }
4460
4544
  }
4545
+ if (block.type === "Paragraph") {
4546
+ const columnId = (_a = block.attributes) == null ? void 0 : _a.columnId;
4547
+ if (typeof columnId === "string" && columnId) {
4548
+ ;
4549
+ out.props.columnId = columnId;
4550
+ }
4551
+ }
4552
+ if (block.type === "TableColumn") {
4553
+ const width = (_b = block.attributes) == null ? void 0 : _b.width;
4554
+ if (typeof width === "number") {
4555
+ ;
4556
+ out.props.width = String(width);
4557
+ }
4558
+ const isHeader = (_c = block.attributes) == null ? void 0 : _c.isHeader;
4559
+ if (isHeader === true) {
4560
+ ;
4561
+ out.props.isHeader = true;
4562
+ }
4563
+ }
4564
+ if (block.type === "TableRow") {
4565
+ const isHeader = (_d = block.attributes) == null ? void 0 : _d.isHeader;
4566
+ if (isHeader === true) {
4567
+ ;
4568
+ out.props.isHeader = true;
4569
+ }
4570
+ }
4461
4571
  if (block.type === "Query") {
4462
4572
  const queryProps = out.props;
4463
- queryProps.style = (_a = block.attributes) == null ? void 0 : _a.style;
4464
- queryProps.columnCount = String(((_b = block.attributes) == null ? void 0 : _b.columnCount) || "");
4465
- queryProps.queryIncludes = JSON.stringify(((_d = (_c = block.attributes) == null ? void 0 : _c.query) == null ? void 0 : _d.includes) || []);
4466
- queryProps.querySort = JSON.stringify(((_f = (_e = block.attributes) == null ? void 0 : _e.query) == null ? void 0 : _f.sort) || {});
4467
- queryProps.banner = ((_g = block.attributes) == null ? void 0 : _g.banner) ? "true" : "false";
4468
- queryProps.queryLimit = String(((_i = (_h = block.attributes) == null ? void 0 : _h.query) == null ? void 0 : _i.limit) || "");
4573
+ queryProps.style = (_e = block.attributes) == null ? void 0 : _e.style;
4574
+ queryProps.columnCount = String(((_f = block.attributes) == null ? void 0 : _f.columnCount) || "");
4575
+ queryProps.queryIncludes = JSON.stringify(((_h = (_g = block.attributes) == null ? void 0 : _g.query) == null ? void 0 : _h.includes) || []);
4576
+ queryProps.querySort = JSON.stringify(((_j = (_i = block.attributes) == null ? void 0 : _i.query) == null ? void 0 : _j.sort) || {});
4577
+ queryProps.banner = ((_k = block.attributes) == null ? void 0 : _k.banner) ? "true" : "false";
4578
+ queryProps.queryLimit = String(((_m = (_l = block.attributes) == null ? void 0 : _l.query) == null ? void 0 : _m.limit) || "");
4469
4579
  }
4470
4580
  const blockText = block.text || "";
4471
4581
  const leaves = out.content;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-hypermedia/client",
3
- "version": "0.0.54",
3
+ "version": "0.0.56",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/seed-hypermedia/seed",