@tinacms/mdx 1.6.1 → 1.6.3

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.
@@ -23382,7 +23382,9 @@ function mdxJsxFromMarkdown2({ patterns }) {
23382
23382
  if (attribute.name === "") {
23383
23383
  attribute.name = "_value";
23384
23384
  }
23385
- attribute.value = parseEntities(this.resume(), { nonTerminated: false });
23385
+ attribute.value = parseEntities(this.resume(), {
23386
+ nonTerminated: false
23387
+ });
23386
23388
  }
23387
23389
  }
23388
23390
  };
@@ -23634,7 +23636,9 @@ var mdxJsxToMarkdown2 = function(options) {
23634
23636
  if (!emptyChildren) {
23635
23637
  tracker.shift(2);
23636
23638
  value += tracker.move("\n");
23637
- value += tracker.move(containerFlow(node2, context, tracker.current()));
23639
+ value += tracker.move(
23640
+ containerFlow(node2, context, tracker.current())
23641
+ );
23638
23642
  value += tracker.move("\n");
23639
23643
  }
23640
23644
  } else {
@@ -42036,7 +42040,9 @@ function mdxJsx2(options = {}) {
42036
42040
  { locations: true }
42037
42041
  );
42038
42042
  } else if (options.acornOptions || options.addResult) {
42039
- throw new Error("Expected an `acorn` instance passed in as `options.acorn`");
42043
+ throw new Error(
42044
+ "Expected an `acorn` instance passed in as `options.acorn`"
42045
+ );
42040
42046
  }
42041
42047
  const patterns = options.patterns || [];
42042
42048
  const flowRules = {};
@@ -42799,7 +42805,9 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess) => {
42799
42805
  content4.position
42800
42806
  );
42801
42807
  default:
42802
- throw new Error(`PhrasingContent: ${content4.type} is not yet supported`);
42808
+ throw new Error(
42809
+ `PhrasingContent: ${content4.type} is not yet supported`
42810
+ );
42803
42811
  }
42804
42812
  };
42805
42813
  const breakContent = () => {
package/dist/index.js CHANGED
@@ -25144,9 +25144,8 @@ function mdxJsxFromMarkdown2({ patterns }) {
25144
25144
  this.buffer();
25145
25145
  };
25146
25146
  const data2 = function(token) {
25147
- var _a3, _b, _c, _d2, _e, _f;
25148
- (_c = (_b = (_a3 = this.config) == null ? void 0 : _a3.enter) == null ? void 0 : _b.data) == null ? void 0 : _c.call(this, token);
25149
- (_f = (_e = (_d2 = this.config) == null ? void 0 : _d2.exit) == null ? void 0 : _e.data) == null ? void 0 : _f.call(this, token);
25147
+ this.config?.enter?.data?.call(this, token);
25148
+ this.config?.exit?.data?.call(this, token);
25150
25149
  };
25151
25150
  const enterMdxJsxTag = function(token) {
25152
25151
  const tag = {
@@ -25164,7 +25163,7 @@ function mdxJsxFromMarkdown2({ patterns }) {
25164
25163
  const enterMdxJsxTagClosingMarker = function(token) {
25165
25164
  const stack = this.getData("mdxJsxTagStack");
25166
25165
  const tag = this.getData("mdxJsxTag");
25167
- if ((stack == null ? void 0 : stack.length) === 0) {
25166
+ if (stack?.length === 0) {
25168
25167
  if (tag) {
25169
25168
  tag.shouldFallback = true;
25170
25169
  }
@@ -25175,7 +25174,7 @@ function mdxJsxFromMarkdown2({ patterns }) {
25175
25174
  };
25176
25175
  const enterMdxJsxTagSelfClosingMarker = function(token) {
25177
25176
  const tag = this.getData("mdxJsxTag");
25178
- if (tag == null ? void 0 : tag.close) {
25177
+ if (tag?.close) {
25179
25178
  throw new VFileMessage(
25180
25179
  "Unexpected self-closing slash `/` in closing tag, expected the end of the tag",
25181
25180
  { start: token.start, end: token.end },
@@ -25261,7 +25260,9 @@ function mdxJsxFromMarkdown2({ patterns }) {
25261
25260
  if (attribute.name === "") {
25262
25261
  attribute.name = "_value";
25263
25262
  }
25264
- attribute.value = parseEntities(this.resume(), { nonTerminated: false });
25263
+ attribute.value = parseEntities(this.resume(), {
25264
+ nonTerminated: false
25265
+ });
25265
25266
  }
25266
25267
  }
25267
25268
  };
@@ -25305,7 +25306,7 @@ function mdxJsxFromMarkdown2({ patterns }) {
25305
25306
  stack.pop();
25306
25307
  } else {
25307
25308
  const pattern = patterns.find((pattern2) => pattern2.name === tag.name);
25308
- const tagName = (pattern == null ? void 0 : pattern.templateName) || tag.name;
25309
+ const tagName = pattern?.templateName || tag.name;
25309
25310
  this.enter(
25310
25311
  {
25311
25312
  type: token.type === "mdxJsxTextTag" ? "mdxJsxTextElement" : "mdxJsxFlowElement",
@@ -25435,12 +25436,11 @@ var mdxJsxToMarkdown2 = function(options) {
25435
25436
  );
25436
25437
  }
25437
25438
  const mdxElement = function(node2, _, context, safeOptions) {
25438
- var _a3, _b;
25439
25439
  const pattern = patterns.find((p) => p.templateName === node2.name);
25440
25440
  if (!pattern) {
25441
25441
  return "";
25442
25442
  }
25443
- const patternName = pattern.name || (pattern == null ? void 0 : pattern.templateName);
25443
+ const patternName = pattern.name || pattern?.templateName;
25444
25444
  const tracker = track(safeOptions);
25445
25445
  const selfClosing = pattern.leaf;
25446
25446
  const exit3 = context.enter(node2.type);
@@ -25454,10 +25454,10 @@ var mdxJsxToMarkdown2 = function(options) {
25454
25454
  while (++index2 < node2.attributes.length) {
25455
25455
  const attribute = node2.attributes[index2];
25456
25456
  let result;
25457
- if ((attribute == null ? void 0 : attribute.type) === "mdxJsxExpressionAttribute") {
25457
+ if (attribute?.type === "mdxJsxExpressionAttribute") {
25458
25458
  result = "{" + (attribute.value || "") + "}";
25459
25459
  } else {
25460
- if (!(attribute == null ? void 0 : attribute.name)) {
25460
+ if (!attribute?.name) {
25461
25461
  throw new Error("Cannot serialize attribute w/o name");
25462
25462
  }
25463
25463
  const value2 = attribute.value;
@@ -25510,11 +25510,13 @@ var mdxJsxToMarkdown2 = function(options) {
25510
25510
  value += tracker.move(" " + pattern.end);
25511
25511
  if (node2.children) {
25512
25512
  if (node2.type === "mdxJsxFlowElement") {
25513
- const emptyChildren = node2.children.length === 1 && ((_a3 = node2.children[0]) == null ? void 0 : _a3.type) === "paragraph" && ((_b = node2.children[0].children[0]) == null ? void 0 : _b.type) === "text" && node2.children[0].children[0].value === "";
25513
+ const emptyChildren = node2.children.length === 1 && node2.children[0]?.type === "paragraph" && node2.children[0].children[0]?.type === "text" && node2.children[0].children[0].value === "";
25514
25514
  if (!emptyChildren) {
25515
25515
  tracker.shift(2);
25516
25516
  value += tracker.move("\n");
25517
- value += tracker.move(containerFlow(node2, context, tracker.current()));
25517
+ value += tracker.move(
25518
+ containerFlow(node2, context, tracker.current())
25519
+ );
25518
25520
  value += tracker.move("\n");
25519
25521
  }
25520
25522
  } else {
@@ -25563,7 +25565,7 @@ var getFieldPatterns = (field) => {
25563
25565
  const patterns = [];
25564
25566
  const templates = [];
25565
25567
  hoistAllTemplates(field, templates);
25566
- templates == null ? void 0 : templates.forEach((template) => {
25568
+ templates?.forEach((template) => {
25567
25569
  if (typeof template === "string") {
25568
25570
  throw new Error("Global templates not supported");
25569
25571
  }
@@ -25581,8 +25583,7 @@ var getFieldPatterns = (field) => {
25581
25583
  return patterns;
25582
25584
  };
25583
25585
  var hoistAllTemplates = (field, templates = []) => {
25584
- var _a3;
25585
- (_a3 = field.templates) == null ? void 0 : _a3.forEach((template) => {
25586
+ field.templates?.forEach((template) => {
25586
25587
  if (typeof template === "string") {
25587
25588
  throw new Error("Global templates not supported");
25588
25589
  }
@@ -25601,14 +25602,13 @@ var toTinaMarkdown = (tree, field) => {
25601
25602
  const patterns = getFieldPatterns(field);
25602
25603
  const handlers = {};
25603
25604
  handlers["text"] = (node2, parent, context, safeOptions) => {
25604
- var _a3;
25605
25605
  context.unsafe = context.unsafe.filter((unsafeItem) => {
25606
25606
  if (unsafeItem.character === " " && unsafeItem.inConstruct === "phrasing") {
25607
25607
  return false;
25608
25608
  }
25609
25609
  return true;
25610
25610
  });
25611
- if (((_a3 = field.parser) == null ? void 0 : _a3.type) === "markdown") {
25611
+ if (field.parser?.type === "markdown") {
25612
25612
  if (field.parser.skipEscaping === "all") {
25613
25613
  return node2.value;
25614
25614
  }
@@ -40040,22 +40040,20 @@ var stringifyPropsInline = (element, field, imageCallback) => {
40040
40040
  return stringifyProps(element, field, true, imageCallback);
40041
40041
  };
40042
40042
  function stringifyProps(element, parentField, flatten2, imageCallback) {
40043
- var _a3, _b;
40044
40043
  const attributes2 = [];
40045
40044
  const children = [];
40046
40045
  let template;
40047
40046
  let useDirective = false;
40048
40047
  let directiveType = "leaf";
40049
- template = (_a3 = parentField.templates) == null ? void 0 : _a3.find((template2) => {
40048
+ template = parentField.templates?.find((template2) => {
40050
40049
  if (typeof template2 === "string") {
40051
40050
  throw new Error("Global templates not supported");
40052
40051
  }
40053
40052
  return template2.name === element.name;
40054
40053
  });
40055
40054
  if (!template) {
40056
- template = (_b = parentField.templates) == null ? void 0 : _b.find((template2) => {
40057
- var _a4;
40058
- const templateName = (_a4 = template2 == null ? void 0 : template2.match) == null ? void 0 : _a4.name;
40055
+ template = parentField.templates?.find((template2) => {
40056
+ const templateName = template2?.match?.name;
40059
40057
  return templateName === element.name;
40060
40058
  });
40061
40059
  }
@@ -40067,11 +40065,10 @@ function stringifyProps(element, parentField, flatten2, imageCallback) {
40067
40065
  }
40068
40066
  useDirective = !!template.match;
40069
40067
  Object.entries(element.props).forEach(([name2, value]) => {
40070
- var _a4;
40071
40068
  if (typeof template === "string") {
40072
40069
  throw new Error(`Unable to find template for JSX element ${name2}`);
40073
40070
  }
40074
- const field = (_a4 = template == null ? void 0 : template.fields) == null ? void 0 : _a4.find((field2) => field2.name === name2);
40071
+ const field = template?.fields?.find((field2) => field2.name === name2);
40075
40072
  if (!field) {
40076
40073
  if (name2 === "children") {
40077
40074
  return;
@@ -40351,11 +40348,11 @@ var matches = (a, b) => {
40351
40348
  };
40352
40349
  var replaceLinksWithTextNodes = (content3) => {
40353
40350
  const newItems = [];
40354
- content3 == null ? void 0 : content3.forEach((item) => {
40351
+ content3?.forEach((item) => {
40355
40352
  if (item.type === "a") {
40356
40353
  if (item.children.length === 1) {
40357
40354
  const firstChild = item.children[0];
40358
- if ((firstChild == null ? void 0 : firstChild.type) === "text") {
40355
+ if (firstChild?.type === "text") {
40359
40356
  newItems.push({
40360
40357
  ...firstChild,
40361
40358
  linkifyTextNode: (a) => {
@@ -40429,13 +40426,12 @@ var text5 = (content3) => {
40429
40426
  };
40430
40427
  };
40431
40428
  var eat2 = (c, field, imageCallback) => {
40432
- var _a3, _b;
40433
40429
  const content3 = replaceLinksWithTextNodes(c);
40434
40430
  const first = content3[0];
40435
40431
  if (!first) {
40436
40432
  return [];
40437
40433
  }
40438
- if (first && (first == null ? void 0 : first.type) !== "text") {
40434
+ if (first && first?.type !== "text") {
40439
40435
  if (first.type === "a") {
40440
40436
  return [
40441
40437
  {
@@ -40511,7 +40507,7 @@ var eat2 = (c, field, imageCallback) => {
40511
40507
  value: first.text
40512
40508
  };
40513
40509
  return [
40514
- (_b = (_a3 = first.linkifyTextNode) == null ? void 0 : _a3.call(first, node2)) != null ? _b : node2,
40510
+ first.linkifyTextNode?.(node2) ?? node2,
40515
40511
  ...eat2(content3.slice(nonMatchingSiblingIndex + 1), field, imageCallback)
40516
40512
  ];
40517
40513
  }
@@ -40678,8 +40674,7 @@ ${match.start} /${match.name || template.name} ${match.end}`;
40678
40674
 
40679
40675
  // src/stringify/index.ts
40680
40676
  var stringifyMDX = (value, field, imageCallback) => {
40681
- var _a3, _b;
40682
- if (((_a3 = field.parser) == null ? void 0 : _a3.type) === "markdown") {
40677
+ if (field.parser?.type === "markdown") {
40683
40678
  return stringifyMDX2(value, field, imageCallback);
40684
40679
  }
40685
40680
  if (!value) {
@@ -40688,18 +40683,18 @@ var stringifyMDX = (value, field, imageCallback) => {
40688
40683
  if (typeof value === "string") {
40689
40684
  throw new Error("Expected an object to stringify, but received a string");
40690
40685
  }
40691
- if (value == null ? void 0 : value.children[0]) {
40692
- if ((value == null ? void 0 : value.children[0].type) === "invalid_markdown") {
40686
+ if (value?.children[0]) {
40687
+ if (value?.children[0].type === "invalid_markdown") {
40693
40688
  return value.children[0].value;
40694
40689
  }
40695
40690
  }
40696
40691
  const tree = rootElement(value, field, imageCallback);
40697
40692
  const res = toTinaMarkdown2(tree, field);
40698
- const templatesWithMatchers = (_b = field.templates) == null ? void 0 : _b.filter(
40693
+ const templatesWithMatchers = field.templates?.filter(
40699
40694
  (template) => template.match
40700
40695
  );
40701
40696
  let preprocessedString = res;
40702
- templatesWithMatchers == null ? void 0 : templatesWithMatchers.forEach((template) => {
40697
+ templatesWithMatchers?.forEach((template) => {
40703
40698
  if (typeof template === "string") {
40704
40699
  throw new Error("Global templates are not supported");
40705
40700
  }
@@ -40710,9 +40705,8 @@ var stringifyMDX = (value, field, imageCallback) => {
40710
40705
  return preprocessedString;
40711
40706
  };
40712
40707
  var toTinaMarkdown2 = (tree, field) => {
40713
- var _a3;
40714
40708
  const patterns = [];
40715
- (_a3 = field.templates) == null ? void 0 : _a3.forEach((template) => {
40709
+ field.templates?.forEach((template) => {
40716
40710
  if (typeof template === "string") {
40717
40711
  return;
40718
40712
  }
@@ -40724,14 +40718,13 @@ var toTinaMarkdown2 = (tree, field) => {
40724
40718
  });
40725
40719
  const handlers = {};
40726
40720
  handlers["text"] = (node2, parent, context, safeOptions) => {
40727
- var _a4;
40728
40721
  context.unsafe = context.unsafe.filter((unsafeItem) => {
40729
40722
  if (unsafeItem.character === " " && unsafeItem.inConstruct === "phrasing") {
40730
40723
  return false;
40731
40724
  }
40732
40725
  return true;
40733
40726
  });
40734
- if (((_a4 = field.parser) == null ? void 0 : _a4.type) === "markdown") {
40727
+ if (field.parser?.type === "markdown") {
40735
40728
  if (field.parser.skipEscaping === "all") {
40736
40729
  return node2.value;
40737
40730
  }
@@ -40757,9 +40750,8 @@ var toTinaMarkdown2 = (tree, field) => {
40757
40750
  });
40758
40751
  };
40759
40752
  var rootElement = (content3, field, imageCallback) => {
40760
- var _a3;
40761
40753
  const children = [];
40762
- (_a3 = content3.children) == null ? void 0 : _a3.forEach((child) => {
40754
+ content3.children?.forEach((child) => {
40763
40755
  const value = blockElement(child, field, imageCallback);
40764
40756
  if (value) {
40765
40757
  children.push(value);
@@ -40818,11 +40810,10 @@ var blockElement = (content3, field, imageCallback) => {
40818
40810
  const tr2 = {
40819
40811
  type: "tableRow",
40820
40812
  children: tableRow.tableCells.map(({ value }) => {
40821
- var _a3, _b;
40822
40813
  return {
40823
40814
  type: "tableCell",
40824
40815
  children: eat2(
40825
- ((_b = (_a3 = value == null ? void 0 : value.children) == null ? void 0 : _a3.at(0)) == null ? void 0 : _b.children) || [],
40816
+ value?.children?.at(0)?.children || [],
40826
40817
  field,
40827
40818
  imageCallback
40828
40819
  )
@@ -40842,7 +40833,7 @@ var blockElement = (content3, field, imageCallback) => {
40842
40833
  );
40843
40834
  }
40844
40835
  const directiveAttributes = {};
40845
- attributes2 == null ? void 0 : attributes2.forEach((att) => {
40836
+ attributes2?.forEach((att) => {
40846
40837
  if (att.value && typeof att.value === "string") {
40847
40838
  directiveAttributes[att.name] = att.value;
40848
40839
  }
@@ -40917,16 +40908,15 @@ var blockElement = (content3, field, imageCallback) => {
40917
40908
  const table = content3.props;
40918
40909
  return {
40919
40910
  type: "table",
40920
- align: table == null ? void 0 : table.align,
40911
+ align: table?.align,
40921
40912
  children: content3.children.map((tableRow) => {
40922
40913
  return {
40923
40914
  type: "tableRow",
40924
40915
  children: tableRow.children.map((tableCell) => {
40925
- var _a3, _b;
40926
40916
  return {
40927
40917
  type: "tableCell",
40928
40918
  children: eat2(
40929
- ((_b = (_a3 = tableCell.children) == null ? void 0 : _a3.at(0)) == null ? void 0 : _b.children) || [],
40919
+ tableCell.children?.at(0)?.children || [],
40930
40920
  field,
40931
40921
  imageCallback
40932
40922
  )
@@ -41015,22 +41005,20 @@ var stringifyPropsInline2 = (element, field, imageCallback) => {
41015
41005
  return stringifyProps2(element, field, true, imageCallback);
41016
41006
  };
41017
41007
  function stringifyProps2(element, parentField, flatten2, imageCallback) {
41018
- var _a3, _b;
41019
41008
  const attributes2 = [];
41020
41009
  const children = [];
41021
41010
  let template;
41022
41011
  let useDirective = false;
41023
41012
  let directiveType = "leaf";
41024
- template = (_a3 = parentField.templates) == null ? void 0 : _a3.find((template2) => {
41013
+ template = parentField.templates?.find((template2) => {
41025
41014
  if (typeof template2 === "string") {
41026
41015
  throw new Error("Global templates not supported");
41027
41016
  }
41028
41017
  return template2.name === element.name;
41029
41018
  });
41030
41019
  if (!template) {
41031
- template = (_b = parentField.templates) == null ? void 0 : _b.find((template2) => {
41032
- var _a4;
41033
- const templateName = (_a4 = template2 == null ? void 0 : template2.match) == null ? void 0 : _a4.name;
41020
+ template = parentField.templates?.find((template2) => {
41021
+ const templateName = template2?.match?.name;
41034
41022
  return templateName === element.name;
41035
41023
  });
41036
41024
  }
@@ -41042,11 +41030,10 @@ function stringifyProps2(element, parentField, flatten2, imageCallback) {
41042
41030
  }
41043
41031
  useDirective = !!template.match;
41044
41032
  Object.entries(element.props).forEach(([name2, value]) => {
41045
- var _a4;
41046
41033
  if (typeof template === "string") {
41047
41034
  throw new Error(`Unable to find template for JSX element ${name2}`);
41048
41035
  }
41049
- const field = (_a4 = template == null ? void 0 : template.fields) == null ? void 0 : _a4.find((field2) => field2.name === name2);
41036
+ const field = template?.fields?.find((field2) => field2.name === name2);
41050
41037
  if (!field) {
41051
41038
  if (name2 === "children") {
41052
41039
  return;
@@ -41260,11 +41247,11 @@ var matches2 = (a, b) => {
41260
41247
  };
41261
41248
  var replaceLinksWithTextNodes2 = (content3) => {
41262
41249
  const newItems = [];
41263
- content3 == null ? void 0 : content3.forEach((item) => {
41250
+ content3?.forEach((item) => {
41264
41251
  if (item.type === "a") {
41265
41252
  if (item.children.length === 1) {
41266
41253
  const firstChild = item.children[0];
41267
- if ((firstChild == null ? void 0 : firstChild.type) === "text") {
41254
+ if (firstChild?.type === "text") {
41268
41255
  newItems.push({
41269
41256
  ...firstChild,
41270
41257
  linkifyTextNode: (a) => {
@@ -41345,13 +41332,12 @@ var text6 = (content3) => {
41345
41332
  };
41346
41333
  };
41347
41334
  var eat3 = (c, field, imageCallback) => {
41348
- var _a3, _b;
41349
41335
  const content3 = replaceLinksWithTextNodes2(c);
41350
41336
  const first = content3[0];
41351
41337
  if (!first) {
41352
41338
  return [];
41353
41339
  }
41354
- if (first && (first == null ? void 0 : first.type) !== "text") {
41340
+ if (first && first?.type !== "text") {
41355
41341
  if (first.type === "a") {
41356
41342
  return [
41357
41343
  {
@@ -41427,7 +41413,7 @@ var eat3 = (c, field, imageCallback) => {
41427
41413
  value: first.text
41428
41414
  };
41429
41415
  return [
41430
- (_b = (_a3 = first.linkifyTextNode) == null ? void 0 : _a3.call(first, node2)) != null ? _b : node2,
41416
+ first.linkifyTextNode?.(node2) ?? node2,
41431
41417
  ...eat3(content3.slice(nonMatchingSiblingIndex + 1), field, imageCallback)
41432
41418
  ];
41433
41419
  }
@@ -41475,9 +41461,8 @@ var preProcess = (tree, field, imageCallback) => {
41475
41461
  return ast;
41476
41462
  };
41477
41463
  var rootElement2 = (content3, field, imageCallback) => {
41478
- var _a3;
41479
41464
  const children = [];
41480
- (_a3 = content3.children) == null ? void 0 : _a3.forEach((child) => {
41465
+ content3.children?.forEach((child) => {
41481
41466
  const value = blockElement2(child, field, imageCallback);
41482
41467
  if (value) {
41483
41468
  children.push(value);
@@ -41536,11 +41521,10 @@ var blockElement2 = (content3, field, imageCallback) => {
41536
41521
  const tr2 = {
41537
41522
  type: "tableRow",
41538
41523
  children: tableRow.tableCells.map(({ value }) => {
41539
- var _a3, _b;
41540
41524
  return {
41541
41525
  type: "tableCell",
41542
41526
  children: eat3(
41543
- ((_b = (_a3 = value == null ? void 0 : value.children) == null ? void 0 : _a3.at(0)) == null ? void 0 : _b.children) || [],
41527
+ value?.children?.at(0)?.children || [],
41544
41528
  field,
41545
41529
  imageCallback
41546
41530
  )
@@ -41604,16 +41588,15 @@ var blockElement2 = (content3, field, imageCallback) => {
41604
41588
  const table = content3.props;
41605
41589
  return {
41606
41590
  type: "table",
41607
- align: table == null ? void 0 : table.align,
41591
+ align: table?.align,
41608
41592
  children: content3.children.map((tableRow) => {
41609
41593
  return {
41610
41594
  type: "tableRow",
41611
41595
  children: tableRow.children.map((tableCell) => {
41612
- var _a3, _b;
41613
41596
  return {
41614
41597
  type: "tableCell",
41615
41598
  children: eat3(
41616
- ((_b = (_a3 = tableCell.children) == null ? void 0 : _a3.at(0)) == null ? void 0 : _b.children) || [],
41599
+ tableCell.children?.at(0)?.children || [],
41617
41600
  field,
41618
41601
  imageCallback
41619
41602
  )
@@ -43935,14 +43918,15 @@ function mdxJsx2(options = {}) {
43935
43918
  { locations: true }
43936
43919
  );
43937
43920
  } else if (options.acornOptions || options.addResult) {
43938
- throw new Error("Expected an `acorn` instance passed in as `options.acorn`");
43921
+ throw new Error(
43922
+ "Expected an `acorn` instance passed in as `options.acorn`"
43923
+ );
43939
43924
  }
43940
43925
  const patterns = options.patterns || [];
43941
43926
  const flowRules = {};
43942
43927
  const textRules = {};
43943
43928
  patterns.forEach((pattern) => {
43944
- var _a3;
43945
- const firstCharacter = (_a3 = findCode(pattern.start[0])) == null ? void 0 : _a3.toString();
43929
+ const firstCharacter = findCode(pattern.start[0])?.toString();
43946
43930
  if (!firstCharacter) {
43947
43931
  return;
43948
43932
  }
@@ -44015,7 +43999,7 @@ var import_lodash = __toESM(require_lodash());
44015
43999
  // src/parse/acorn.ts
44016
44000
  var extractAttributes = (attributes2, fields, imageCallback) => {
44017
44001
  const properties = {};
44018
- attributes2 == null ? void 0 : attributes2.forEach((attribute) => {
44002
+ attributes2?.forEach((attribute) => {
44019
44003
  assertType(attribute, "mdxJsxAttribute");
44020
44004
  const field = fields.find((field2) => field2.name === attribute.name);
44021
44005
  if (!field) {
@@ -44109,9 +44093,8 @@ var extractObject = (attribute, field, imageCallback) => {
44109
44093
  }
44110
44094
  };
44111
44095
  var extractObjectExpression = (expression, field, imageCallback) => {
44112
- var _a3;
44113
44096
  const properties = {};
44114
- (_a3 = expression.properties) == null ? void 0 : _a3.forEach((property) => {
44097
+ expression.properties?.forEach((property) => {
44115
44098
  assertType(property, "Property");
44116
44099
  const { key, value } = extractKeyValue(property, field, imageCallback);
44117
44100
  properties[key] = value;
@@ -44130,7 +44113,7 @@ var extractKeyValue = (property, parentField, imageCallback) => {
44130
44113
  assertType(property.key, "Identifier");
44131
44114
  const key = property.key.name;
44132
44115
  const field = getField(parentField, key);
44133
- if ((field == null ? void 0 : field.type) === "object") {
44116
+ if (field?.type === "object") {
44134
44117
  if (field.list) {
44135
44118
  assertType(property.value, "ArrayExpression");
44136
44119
  const value = property.value.elements.map((element) => {
@@ -44148,7 +44131,7 @@ var extractKeyValue = (property, parentField, imageCallback) => {
44148
44131
  );
44149
44132
  return { key, value };
44150
44133
  }
44151
- } else if (field == null ? void 0 : field.list) {
44134
+ } else if (field?.list) {
44152
44135
  assertType(property.value, "ArrayExpression");
44153
44136
  const value = property.value.elements.map((element) => {
44154
44137
  assertHasType(element);
@@ -44156,7 +44139,7 @@ var extractKeyValue = (property, parentField, imageCallback) => {
44156
44139
  return element.value;
44157
44140
  });
44158
44141
  return { key, value };
44159
- } else if ((field == null ? void 0 : field.type) === "rich-text") {
44142
+ } else if (field?.type === "rich-text") {
44160
44143
  assertType(property.value, "Literal");
44161
44144
  const raw = property.value.value;
44162
44145
  if (typeof raw === "string") {
@@ -44169,8 +44152,7 @@ var extractKeyValue = (property, parentField, imageCallback) => {
44169
44152
  }
44170
44153
  };
44171
44154
  var extractStatement = (attribute) => {
44172
- var _a3, _b;
44173
- const body = (_b = (_a3 = attribute.data) == null ? void 0 : _a3.estree) == null ? void 0 : _b.body;
44155
+ const body = attribute.data?.estree?.body;
44174
44156
  if (body) {
44175
44157
  if (body[0]) {
44176
44158
  assertType(body[0], "ExpressionStatement");
@@ -44307,9 +44289,8 @@ function source(value, file) {
44307
44289
 
44308
44290
  // src/parse/mdx.ts
44309
44291
  function mdxJsxElement(node2, field, imageCallback) {
44310
- var _a3;
44311
44292
  try {
44312
- const template = (_a3 = field.templates) == null ? void 0 : _a3.find((template2) => {
44293
+ const template = field.templates?.find((template2) => {
44313
44294
  const templateName = typeof template2 === "string" ? template2 : template2.name;
44314
44295
  return templateName === node2.name;
44315
44296
  });
@@ -44354,9 +44335,8 @@ function mdxJsxElement(node2, field, imageCallback) {
44354
44335
  }
44355
44336
  }
44356
44337
  var directiveElement = (node2, field, imageCallback, raw) => {
44357
- var _a3, _b;
44358
44338
  let template;
44359
- template = (_a3 = field.templates) == null ? void 0 : _a3.find((template2) => {
44339
+ template = field.templates?.find((template2) => {
44360
44340
  const templateName = typeof template2 === "string" ? template2 : template2.name;
44361
44341
  return templateName === node2.name;
44362
44342
  });
@@ -44364,9 +44344,8 @@ var directiveElement = (node2, field, imageCallback, raw) => {
44364
44344
  throw new Error("Global templates not yet supported");
44365
44345
  }
44366
44346
  if (!template) {
44367
- template = (_b = field.templates) == null ? void 0 : _b.find((template2) => {
44368
- var _a4;
44369
- const templateName = (_a4 = template2 == null ? void 0 : template2.match) == null ? void 0 : _a4.name;
44347
+ template = field.templates?.find((template2) => {
44348
+ const templateName = template2?.match?.name;
44370
44349
  return templateName === node2.name;
44371
44350
  });
44372
44351
  }
@@ -44400,7 +44379,6 @@ var directiveElement = (node2, field, imageCallback, raw) => {
44400
44379
  var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess) => {
44401
44380
  const mdxJsxElement2 = skipMDXProcess ? (node2) => node2 : mdxJsxElement;
44402
44381
  const content3 = (content4) => {
44403
- var _a3;
44404
44382
  switch (content4.type) {
44405
44383
  case "table": {
44406
44384
  return {
@@ -44426,7 +44404,7 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess) => {
44426
44404
  };
44427
44405
  }),
44428
44406
  props: {
44429
- align: (_a3 = content4.align) == null ? void 0 : _a3.filter((item) => !!item)
44407
+ align: content4.align?.filter((item) => !!item)
44430
44408
  }
44431
44409
  };
44432
44410
  }
@@ -44705,7 +44683,9 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess) => {
44705
44683
  content4.position
44706
44684
  );
44707
44685
  default:
44708
- throw new Error(`PhrasingContent: ${content4.type} is not yet supported`);
44686
+ throw new Error(
44687
+ `PhrasingContent: ${content4.type} is not yet supported`
44688
+ );
44709
44689
  }
44710
44690
  };
44711
44691
  const breakContent = () => {
@@ -44798,7 +44778,7 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess) => {
44798
44778
  throw new RichTextParseError(
44799
44779
  `Unexpected inline element of type ${node2.type}`,
44800
44780
  // @ts-ignore
44801
- node2 == null ? void 0 : node2.position
44781
+ node2?.position
44802
44782
  );
44803
44783
  }
44804
44784
  return accum;
@@ -44959,20 +44939,19 @@ var mdxToAst = (value) => {
44959
44939
  };
44960
44940
  var MDX_PARSE_ERROR_MSG = "TinaCMS supports a stricter version of markdown and a subset of MDX. https://tina.io/docs/editing/mdx/#differences-from-other-mdx-implementations";
44961
44941
  var parseMDX = (value, field, imageCallback) => {
44962
- var _a3, _b;
44963
44942
  if (!value) {
44964
44943
  return { type: "root", children: [] };
44965
44944
  }
44966
44945
  let tree;
44967
44946
  try {
44968
- if (((_a3 = field.parser) == null ? void 0 : _a3.type) === "markdown") {
44947
+ if (field.parser?.type === "markdown") {
44969
44948
  return parseMDX2(value, field, imageCallback);
44970
44949
  }
44971
44950
  let preprocessedString = value;
44972
- const templatesWithMatchers = (_b = field.templates) == null ? void 0 : _b.filter(
44951
+ const templatesWithMatchers = field.templates?.filter(
44973
44952
  (template) => template.match
44974
44953
  );
44975
- templatesWithMatchers == null ? void 0 : templatesWithMatchers.forEach((template) => {
44954
+ templatesWithMatchers?.forEach((template) => {
44976
44955
  if (typeof template === "string") {
44977
44956
  throw new Error("Global templates are not supported");
44978
44957
  }
package/dist/index.mjs CHANGED
@@ -25252,7 +25252,9 @@ function mdxJsxFromMarkdown2({ patterns }) {
25252
25252
  if (attribute.name === "") {
25253
25253
  attribute.name = "_value";
25254
25254
  }
25255
- attribute.value = parseEntities(this.resume(), { nonTerminated: false });
25255
+ attribute.value = parseEntities(this.resume(), {
25256
+ nonTerminated: false
25257
+ });
25256
25258
  }
25257
25259
  }
25258
25260
  };
@@ -25504,7 +25506,9 @@ var mdxJsxToMarkdown2 = function(options) {
25504
25506
  if (!emptyChildren) {
25505
25507
  tracker.shift(2);
25506
25508
  value += tracker.move("\n");
25507
- value += tracker.move(containerFlow(node2, context, tracker.current()));
25509
+ value += tracker.move(
25510
+ containerFlow(node2, context, tracker.current())
25511
+ );
25508
25512
  value += tracker.move("\n");
25509
25513
  }
25510
25514
  } else {
@@ -43906,7 +43910,9 @@ function mdxJsx2(options = {}) {
43906
43910
  { locations: true }
43907
43911
  );
43908
43912
  } else if (options.acornOptions || options.addResult) {
43909
- throw new Error("Expected an `acorn` instance passed in as `options.acorn`");
43913
+ throw new Error(
43914
+ "Expected an `acorn` instance passed in as `options.acorn`"
43915
+ );
43910
43916
  }
43911
43917
  const patterns = options.patterns || [];
43912
43918
  const flowRules = {};
@@ -44669,7 +44675,9 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess) => {
44669
44675
  content4.position
44670
44676
  );
44671
44677
  default:
44672
- throw new Error(`PhrasingContent: ${content4.type} is not yet supported`);
44678
+ throw new Error(
44679
+ `PhrasingContent: ${content4.type} is not yet supported`
44680
+ );
44673
44681
  }
44674
44682
  };
44675
44683
  const breakContent = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/mdx",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
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.7.2"
59
+ "@tinacms/schema-tools": "1.7.4"
60
60
  },
61
61
  "publishConfig": {
62
62
  "registry": "https://registry.npmjs.org"
@@ -80,7 +80,7 @@
80
80
  "typescript": "^5.7.3",
81
81
  "vite": "^4.5.9",
82
82
  "vitest": "^0.32.4",
83
- "@tinacms/scripts": "1.3.3"
83
+ "@tinacms/scripts": "1.3.5"
84
84
  },
85
85
  "scripts": {
86
86
  "types": "tsc",