@tinacms/mdx 1.4.4 → 1.5.0

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.
@@ -38861,6 +38861,12 @@ var blockElement = (content3, field, imageCallback) => {
38861
38861
  type: "paragraph",
38862
38862
  children: eat2(content3.children, field, imageCallback)
38863
38863
  };
38864
+ case "mermaid":
38865
+ return {
38866
+ type: "code",
38867
+ lang: "mermaid",
38868
+ value: content3.value
38869
+ };
38864
38870
  case "code_block":
38865
38871
  return {
38866
38872
  type: "code",
@@ -38869,11 +38875,11 @@ var blockElement = (content3, field, imageCallback) => {
38869
38875
  };
38870
38876
  case "mdxJsxFlowElement":
38871
38877
  if (content3.name === "table") {
38872
- const table = content3.props;
38878
+ const table2 = content3.props;
38873
38879
  return {
38874
38880
  type: "table",
38875
- align: table.align,
38876
- children: table.tableRows.map((tableRow) => {
38881
+ align: table2.align,
38882
+ children: table2.tableRows.map((tableRow) => {
38877
38883
  const tr2 = {
38878
38884
  type: "tableRow",
38879
38885
  children: tableRow.tableCells.map(({ value }) => {
@@ -38969,6 +38975,27 @@ var blockElement = (content3, field, imageCallback) => {
38969
38975
  }
38970
38976
  ]
38971
38977
  };
38978
+ case "table":
38979
+ const table = content3.props;
38980
+ return {
38981
+ type: "table",
38982
+ align: table?.align,
38983
+ children: content3.children.map((tableRow) => {
38984
+ return {
38985
+ type: "tableRow",
38986
+ children: tableRow.children.map((tableCell) => {
38987
+ return {
38988
+ type: "tableCell",
38989
+ children: eat2(
38990
+ tableCell.children?.at(0)?.children || [],
38991
+ field,
38992
+ imageCallback
38993
+ )
38994
+ };
38995
+ })
38996
+ };
38997
+ })
38998
+ };
38972
38999
  default:
38973
39000
  throw new Error(`BlockElement: ${content3.type} is not yet supported`);
38974
39001
  }
@@ -39531,6 +39558,12 @@ var blockElement2 = (content3, field, imageCallback) => {
39531
39558
  type: "paragraph",
39532
39559
  children: eat3(content3.children, field, imageCallback)
39533
39560
  };
39561
+ case "mermaid":
39562
+ return {
39563
+ type: "code",
39564
+ lang: "mermaid",
39565
+ value: content3.value
39566
+ };
39534
39567
  case "code_block":
39535
39568
  return {
39536
39569
  type: "code",
@@ -39539,11 +39572,11 @@ var blockElement2 = (content3, field, imageCallback) => {
39539
39572
  };
39540
39573
  case "mdxJsxFlowElement":
39541
39574
  if (content3.name === "table") {
39542
- const table = content3.props;
39575
+ const table2 = content3.props;
39543
39576
  return {
39544
39577
  type: "table",
39545
- align: table.align,
39546
- children: table.tableRows.map((tableRow) => {
39578
+ align: table2.align,
39579
+ children: table2.tableRows.map((tableRow) => {
39547
39580
  const tr2 = {
39548
39581
  type: "tableRow",
39549
39582
  children: tableRow.tableCells.map(({ value }) => {
@@ -39610,6 +39643,27 @@ var blockElement2 = (content3, field, imageCallback) => {
39610
39643
  }
39611
39644
  ]
39612
39645
  };
39646
+ case "table":
39647
+ const table = content3.props;
39648
+ return {
39649
+ type: "table",
39650
+ align: table?.align,
39651
+ children: content3.children.map((tableRow) => {
39652
+ return {
39653
+ type: "tableRow",
39654
+ children: tableRow.children.map((tableCell) => {
39655
+ return {
39656
+ type: "tableCell",
39657
+ children: eat3(
39658
+ tableCell.children?.at(0)?.children || [],
39659
+ field,
39660
+ imageCallback
39661
+ )
39662
+ };
39663
+ })
39664
+ };
39665
+ })
39666
+ };
39613
39667
  default:
39614
39668
  throw new Error(`BlockElement: ${content3.type} is not yet supported`);
39615
39669
  }
@@ -42043,32 +42097,29 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess) => {
42043
42097
  switch (content4.type) {
42044
42098
  case "table": {
42045
42099
  return {
42046
- type: "mdxJsxFlowElement",
42047
- children: [{ type: "text", text: "" }],
42048
- name: "table",
42049
- props: {
42050
- align: content4.align?.filter((item) => !!item),
42051
- tableRows: content4.children.map((child) => {
42052
- return {
42053
- tableCells: child.children.map((child2) => {
42054
- return {
42055
- value: {
42056
- type: "root",
42057
- children: [
42058
- {
42059
- type: "p",
42060
- children: (0, import_lodash.default)(
42061
- child2.children.map(
42062
- (child3) => phrasingContent(child3)
42063
- )
42064
- )
42065
- }
42066
- ]
42100
+ type: "table",
42101
+ children: content4.children.map((tableRow) => {
42102
+ return {
42103
+ type: "tr",
42104
+ children: tableRow.children.map((tableCell) => {
42105
+ return {
42106
+ type: "td",
42107
+ children: [
42108
+ {
42109
+ type: "p",
42110
+ children: (0, import_lodash.default)(
42111
+ tableCell.children.map(
42112
+ (child) => phrasingContent(child)
42113
+ )
42114
+ )
42067
42115
  }
42068
- };
42069
- })
42070
- };
42071
- })
42116
+ ]
42117
+ };
42118
+ })
42119
+ };
42120
+ }),
42121
+ props: {
42122
+ align: content4.align?.filter((item) => !!item)
42072
42123
  }
42073
42124
  };
42074
42125
  }
@@ -42087,7 +42138,7 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess) => {
42087
42138
  case "heading":
42088
42139
  return heading2(content4);
42089
42140
  case "code":
42090
- return code3(content4);
42141
+ return parseCode(content4);
42091
42142
  case "paragraph":
42092
42143
  return paragraph2(content4);
42093
42144
  case "mdxJsxFlowElement":
@@ -42234,6 +42285,19 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess) => {
42234
42285
  );
42235
42286
  }
42236
42287
  };
42288
+ const parseCode = (content4) => {
42289
+ if (content4.lang === "mermaid") {
42290
+ return mermaid(content4);
42291
+ }
42292
+ return code3(content4);
42293
+ };
42294
+ const mermaid = (content4) => {
42295
+ return {
42296
+ type: "mermaid",
42297
+ value: content4.value,
42298
+ children: [{ type: "text", text: "" }]
42299
+ };
42300
+ };
42237
42301
  const code3 = (content4) => {
42238
42302
  const extra = {};
42239
42303
  if (content4.lang)
package/dist/index.js CHANGED
@@ -40750,6 +40750,12 @@ var blockElement = (content3, field, imageCallback) => {
40750
40750
  type: "paragraph",
40751
40751
  children: eat2(content3.children, field, imageCallback)
40752
40752
  };
40753
+ case "mermaid":
40754
+ return {
40755
+ type: "code",
40756
+ lang: "mermaid",
40757
+ value: content3.value
40758
+ };
40753
40759
  case "code_block":
40754
40760
  return {
40755
40761
  type: "code",
@@ -40758,11 +40764,11 @@ var blockElement = (content3, field, imageCallback) => {
40758
40764
  };
40759
40765
  case "mdxJsxFlowElement":
40760
40766
  if (content3.name === "table") {
40761
- const table = content3.props;
40767
+ const table2 = content3.props;
40762
40768
  return {
40763
40769
  type: "table",
40764
- align: table.align,
40765
- children: table.tableRows.map((tableRow) => {
40770
+ align: table2.align,
40771
+ children: table2.tableRows.map((tableRow) => {
40766
40772
  const tr2 = {
40767
40773
  type: "tableRow",
40768
40774
  children: tableRow.tableCells.map(({ value }) => {
@@ -40859,6 +40865,28 @@ var blockElement = (content3, field, imageCallback) => {
40859
40865
  }
40860
40866
  ]
40861
40867
  };
40868
+ case "table":
40869
+ const table = content3.props;
40870
+ return {
40871
+ type: "table",
40872
+ align: table == null ? void 0 : table.align,
40873
+ children: content3.children.map((tableRow) => {
40874
+ return {
40875
+ type: "tableRow",
40876
+ children: tableRow.children.map((tableCell) => {
40877
+ var _a3, _b;
40878
+ return {
40879
+ type: "tableCell",
40880
+ children: eat2(
40881
+ ((_b = (_a3 = tableCell.children) == null ? void 0 : _a3.at(0)) == null ? void 0 : _b.children) || [],
40882
+ field,
40883
+ imageCallback
40884
+ )
40885
+ };
40886
+ })
40887
+ };
40888
+ })
40889
+ };
40862
40890
  default:
40863
40891
  throw new Error(`BlockElement: ${content3.type} is not yet supported`);
40864
40892
  }
@@ -41426,6 +41454,12 @@ var blockElement2 = (content3, field, imageCallback) => {
41426
41454
  type: "paragraph",
41427
41455
  children: eat3(content3.children, field, imageCallback)
41428
41456
  };
41457
+ case "mermaid":
41458
+ return {
41459
+ type: "code",
41460
+ lang: "mermaid",
41461
+ value: content3.value
41462
+ };
41429
41463
  case "code_block":
41430
41464
  return {
41431
41465
  type: "code",
@@ -41434,11 +41468,11 @@ var blockElement2 = (content3, field, imageCallback) => {
41434
41468
  };
41435
41469
  case "mdxJsxFlowElement":
41436
41470
  if (content3.name === "table") {
41437
- const table = content3.props;
41471
+ const table2 = content3.props;
41438
41472
  return {
41439
41473
  type: "table",
41440
- align: table.align,
41441
- children: table.tableRows.map((tableRow) => {
41474
+ align: table2.align,
41475
+ children: table2.tableRows.map((tableRow) => {
41442
41476
  const tr2 = {
41443
41477
  type: "tableRow",
41444
41478
  children: tableRow.tableCells.map(({ value }) => {
@@ -41506,6 +41540,28 @@ var blockElement2 = (content3, field, imageCallback) => {
41506
41540
  }
41507
41541
  ]
41508
41542
  };
41543
+ case "table":
41544
+ const table = content3.props;
41545
+ return {
41546
+ type: "table",
41547
+ align: table == null ? void 0 : table.align,
41548
+ children: content3.children.map((tableRow) => {
41549
+ return {
41550
+ type: "tableRow",
41551
+ children: tableRow.children.map((tableCell) => {
41552
+ var _a3, _b;
41553
+ return {
41554
+ type: "tableCell",
41555
+ children: eat3(
41556
+ ((_b = (_a3 = tableCell.children) == null ? void 0 : _a3.at(0)) == null ? void 0 : _b.children) || [],
41557
+ field,
41558
+ imageCallback
41559
+ )
41560
+ };
41561
+ })
41562
+ };
41563
+ })
41564
+ };
41509
41565
  default:
41510
41566
  throw new Error(`BlockElement: ${content3.type} is not yet supported`);
41511
41567
  }
@@ -43946,32 +44002,29 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess) => {
43946
44002
  switch (content4.type) {
43947
44003
  case "table": {
43948
44004
  return {
43949
- type: "mdxJsxFlowElement",
43950
- children: [{ type: "text", text: "" }],
43951
- name: "table",
43952
- props: {
43953
- align: (_a3 = content4.align) == null ? void 0 : _a3.filter((item) => !!item),
43954
- tableRows: content4.children.map((child) => {
43955
- return {
43956
- tableCells: child.children.map((child2) => {
43957
- return {
43958
- value: {
43959
- type: "root",
43960
- children: [
43961
- {
43962
- type: "p",
43963
- children: (0, import_lodash.default)(
43964
- child2.children.map(
43965
- (child3) => phrasingContent(child3)
43966
- )
43967
- )
43968
- }
43969
- ]
44005
+ type: "table",
44006
+ children: content4.children.map((tableRow) => {
44007
+ return {
44008
+ type: "tr",
44009
+ children: tableRow.children.map((tableCell) => {
44010
+ return {
44011
+ type: "td",
44012
+ children: [
44013
+ {
44014
+ type: "p",
44015
+ children: (0, import_lodash.default)(
44016
+ tableCell.children.map(
44017
+ (child) => phrasingContent(child)
44018
+ )
44019
+ )
43970
44020
  }
43971
- };
43972
- })
43973
- };
43974
- })
44021
+ ]
44022
+ };
44023
+ })
44024
+ };
44025
+ }),
44026
+ props: {
44027
+ align: (_a3 = content4.align) == null ? void 0 : _a3.filter((item) => !!item)
43975
44028
  }
43976
44029
  };
43977
44030
  }
@@ -43990,7 +44043,7 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess) => {
43990
44043
  case "heading":
43991
44044
  return heading2(content4);
43992
44045
  case "code":
43993
- return code3(content4);
44046
+ return parseCode(content4);
43994
44047
  case "paragraph":
43995
44048
  return paragraph2(content4);
43996
44049
  case "mdxJsxFlowElement":
@@ -44137,6 +44190,19 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess) => {
44137
44190
  );
44138
44191
  }
44139
44192
  };
44193
+ const parseCode = (content4) => {
44194
+ if (content4.lang === "mermaid") {
44195
+ return mermaid(content4);
44196
+ }
44197
+ return code3(content4);
44198
+ };
44199
+ const mermaid = (content4) => {
44200
+ return {
44201
+ type: "mermaid",
44202
+ value: content4.value,
44203
+ children: [{ type: "text", text: "" }]
44204
+ };
44205
+ };
44140
44206
  const code3 = (content4) => {
44141
44207
  const extra = {};
44142
44208
  if (content4.lang)
package/dist/index.mjs CHANGED
@@ -40733,6 +40733,12 @@ var blockElement = (content3, field, imageCallback) => {
40733
40733
  type: "paragraph",
40734
40734
  children: eat2(content3.children, field, imageCallback)
40735
40735
  };
40736
+ case "mermaid":
40737
+ return {
40738
+ type: "code",
40739
+ lang: "mermaid",
40740
+ value: content3.value
40741
+ };
40736
40742
  case "code_block":
40737
40743
  return {
40738
40744
  type: "code",
@@ -40741,11 +40747,11 @@ var blockElement = (content3, field, imageCallback) => {
40741
40747
  };
40742
40748
  case "mdxJsxFlowElement":
40743
40749
  if (content3.name === "table") {
40744
- const table = content3.props;
40750
+ const table2 = content3.props;
40745
40751
  return {
40746
40752
  type: "table",
40747
- align: table.align,
40748
- children: table.tableRows.map((tableRow) => {
40753
+ align: table2.align,
40754
+ children: table2.tableRows.map((tableRow) => {
40749
40755
  const tr2 = {
40750
40756
  type: "tableRow",
40751
40757
  children: tableRow.tableCells.map(({ value }) => {
@@ -40841,6 +40847,27 @@ var blockElement = (content3, field, imageCallback) => {
40841
40847
  }
40842
40848
  ]
40843
40849
  };
40850
+ case "table":
40851
+ const table = content3.props;
40852
+ return {
40853
+ type: "table",
40854
+ align: table?.align,
40855
+ children: content3.children.map((tableRow) => {
40856
+ return {
40857
+ type: "tableRow",
40858
+ children: tableRow.children.map((tableCell) => {
40859
+ return {
40860
+ type: "tableCell",
40861
+ children: eat2(
40862
+ tableCell.children?.at(0)?.children || [],
40863
+ field,
40864
+ imageCallback
40865
+ )
40866
+ };
40867
+ })
40868
+ };
40869
+ })
40870
+ };
40844
40871
  default:
40845
40872
  throw new Error(`BlockElement: ${content3.type} is not yet supported`);
40846
40873
  }
@@ -41403,6 +41430,12 @@ var blockElement2 = (content3, field, imageCallback) => {
41403
41430
  type: "paragraph",
41404
41431
  children: eat3(content3.children, field, imageCallback)
41405
41432
  };
41433
+ case "mermaid":
41434
+ return {
41435
+ type: "code",
41436
+ lang: "mermaid",
41437
+ value: content3.value
41438
+ };
41406
41439
  case "code_block":
41407
41440
  return {
41408
41441
  type: "code",
@@ -41411,11 +41444,11 @@ var blockElement2 = (content3, field, imageCallback) => {
41411
41444
  };
41412
41445
  case "mdxJsxFlowElement":
41413
41446
  if (content3.name === "table") {
41414
- const table = content3.props;
41447
+ const table2 = content3.props;
41415
41448
  return {
41416
41449
  type: "table",
41417
- align: table.align,
41418
- children: table.tableRows.map((tableRow) => {
41450
+ align: table2.align,
41451
+ children: table2.tableRows.map((tableRow) => {
41419
41452
  const tr2 = {
41420
41453
  type: "tableRow",
41421
41454
  children: tableRow.tableCells.map(({ value }) => {
@@ -41482,6 +41515,27 @@ var blockElement2 = (content3, field, imageCallback) => {
41482
41515
  }
41483
41516
  ]
41484
41517
  };
41518
+ case "table":
41519
+ const table = content3.props;
41520
+ return {
41521
+ type: "table",
41522
+ align: table?.align,
41523
+ children: content3.children.map((tableRow) => {
41524
+ return {
41525
+ type: "tableRow",
41526
+ children: tableRow.children.map((tableCell) => {
41527
+ return {
41528
+ type: "tableCell",
41529
+ children: eat3(
41530
+ tableCell.children?.at(0)?.children || [],
41531
+ field,
41532
+ imageCallback
41533
+ )
41534
+ };
41535
+ })
41536
+ };
41537
+ })
41538
+ };
41485
41539
  default:
41486
41540
  throw new Error(`BlockElement: ${content3.type} is not yet supported`);
41487
41541
  }
@@ -43915,32 +43969,29 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess) => {
43915
43969
  switch (content4.type) {
43916
43970
  case "table": {
43917
43971
  return {
43918
- type: "mdxJsxFlowElement",
43919
- children: [{ type: "text", text: "" }],
43920
- name: "table",
43921
- props: {
43922
- align: content4.align?.filter((item) => !!item),
43923
- tableRows: content4.children.map((child) => {
43924
- return {
43925
- tableCells: child.children.map((child2) => {
43926
- return {
43927
- value: {
43928
- type: "root",
43929
- children: [
43930
- {
43931
- type: "p",
43932
- children: (0, import_lodash.default)(
43933
- child2.children.map(
43934
- (child3) => phrasingContent(child3)
43935
- )
43936
- )
43937
- }
43938
- ]
43972
+ type: "table",
43973
+ children: content4.children.map((tableRow) => {
43974
+ return {
43975
+ type: "tr",
43976
+ children: tableRow.children.map((tableCell) => {
43977
+ return {
43978
+ type: "td",
43979
+ children: [
43980
+ {
43981
+ type: "p",
43982
+ children: (0, import_lodash.default)(
43983
+ tableCell.children.map(
43984
+ (child) => phrasingContent(child)
43985
+ )
43986
+ )
43939
43987
  }
43940
- };
43941
- })
43942
- };
43943
- })
43988
+ ]
43989
+ };
43990
+ })
43991
+ };
43992
+ }),
43993
+ props: {
43994
+ align: content4.align?.filter((item) => !!item)
43944
43995
  }
43945
43996
  };
43946
43997
  }
@@ -43959,7 +44010,7 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess) => {
43959
44010
  case "heading":
43960
44011
  return heading2(content4);
43961
44012
  case "code":
43962
- return code3(content4);
44013
+ return parseCode(content4);
43963
44014
  case "paragraph":
43964
44015
  return paragraph2(content4);
43965
44016
  case "mdxJsxFlowElement":
@@ -44106,6 +44157,19 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess) => {
44106
44157
  );
44107
44158
  }
44108
44159
  };
44160
+ const parseCode = (content4) => {
44161
+ if (content4.lang === "mermaid") {
44162
+ return mermaid(content4);
44163
+ }
44164
+ return code3(content4);
44165
+ };
44166
+ const mermaid = (content4) => {
44167
+ return {
44168
+ type: "mermaid",
44169
+ value: content4.value,
44170
+ children: [{ type: "text", text: "" }]
44171
+ };
44172
+ };
44109
44173
  const code3 = (content4) => {
44110
44174
  const extra = {};
44111
44175
  if (content4.lang)
@@ -0,0 +1,2 @@
1
+ import type { RichTextField } from '@tinacms/schema-tools';
2
+ export declare const field: RichTextField;
@@ -0,0 +1 @@
1
+ export {};
@@ -121,7 +121,37 @@ export type ParagraphElement = {
121
121
  /**
122
122
  * @group BlockElement
123
123
  */
124
- export type BlockElement = BlockquoteElement | CodeBlockElement | HeadingElement | HrElement | HTMLElement | ImageElement | InvalidMarkdownElement | ListItemElement | MdxBlockElement | ParagraphElement | OrderedListElement | UnorderedListElement;
124
+ export type TableCellElement = {
125
+ type: 'td';
126
+ children: ParagraphElement[];
127
+ };
128
+ /**
129
+ * @group BlockElement
130
+ */
131
+ export type TableRowElement = {
132
+ type: 'tr';
133
+ children: TableCellElement[];
134
+ };
135
+ /**
136
+ * @group BlockElement
137
+ */
138
+ export type TableElement = {
139
+ type: 'table';
140
+ children: TableRowElement[];
141
+ props: Record<string, unknown>;
142
+ };
143
+ /**
144
+ * @group MermaidElement
145
+ */
146
+ export type MermaidElement = {
147
+ type: 'mermaid';
148
+ value: string;
149
+ children: [EmptyTextElement];
150
+ };
151
+ /**
152
+ * @group BlockElement
153
+ */
154
+ export type BlockElement = BlockquoteElement | CodeBlockElement | HeadingElement | HrElement | HTMLElement | ImageElement | InvalidMarkdownElement | ListItemElement | MdxBlockElement | ParagraphElement | MermaidElement | OrderedListElement | UnorderedListElement | TableCellElement | TableRowElement | TableElement;
125
155
  /**
126
156
  * @group InlineElement
127
157
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/mdx",
3
- "version": "1.4.4",
3
+ "version": "1.5.0",
4
4
  "typings": "dist/index.d.ts",
5
5
  "main": "dist/index.js",
6
6
  "browser": "dist/index.browser.mjs",
@@ -56,7 +56,7 @@
56
56
  "unist-util-visit": "4.1.2",
57
57
  "uvu": "0.5.6",
58
58
  "vfile-message": "3.1.4",
59
- "@tinacms/schema-tools": "1.6.4"
59
+ "@tinacms/schema-tools": "1.6.6"
60
60
  },
61
61
  "publishConfig": {
62
62
  "registry": "https://registry.npmjs.org"
@@ -80,7 +80,7 @@
80
80
  "typescript": "^5.6.2",
81
81
  "vite": "^4.5.5",
82
82
  "vitest": "^0.32.4",
83
- "@tinacms/scripts": "1.2.3"
83
+ "@tinacms/scripts": "1.3.0"
84
84
  },
85
85
  "scripts": {
86
86
  "types": "tsc",