@mintlify/cli 4.0.1448 → 4.0.1450

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.
@@ -997,6 +997,109 @@ function partitionAttrs(parsed, known, consumed = []) {
997
997
  return result;
998
998
  }
999
999
 
1000
+ // ../editor/dist/converter/parse/parse-utils.js
1001
+ import { parse as parseYaml } from "yaml";
1002
+ function extractFrontmatter(mdast) {
1003
+ const yamlNode = mdast.children.find((n) => n.type === "yaml");
1004
+ if (!yamlNode || !("value" in yamlNode))
1005
+ return {};
1006
+ try {
1007
+ const parsed = parseYaml(yamlNode.value);
1008
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
1009
+ return parsed;
1010
+ }
1011
+ } catch (_a) {
1012
+ }
1013
+ return {};
1014
+ }
1015
+ function createTextNode(value, marks2 = []) {
1016
+ if (!value)
1017
+ return { type: "text", text: "" };
1018
+ return Object.assign({ type: "text", text: value }, marks2.length > 0 && { marks: marks2 });
1019
+ }
1020
+ function extractTextFromNode(node) {
1021
+ if (!node)
1022
+ return { text: "", marks: [] };
1023
+ if (node.type === "text" || node.type === "inlineCode") {
1024
+ return { text: ("value" in node ? node.value : "") || "", marks: getMarks(node) };
1025
+ }
1026
+ if ("children" in node && Array.isArray(node.children)) {
1027
+ let text = "";
1028
+ const marks2 = getMarks(node);
1029
+ for (const child of node.children) {
1030
+ const { text: childText, marks: childMarks } = extractTextFromNode(child);
1031
+ text += childText;
1032
+ marks2.push(...childMarks);
1033
+ }
1034
+ return { text, marks: marks2 };
1035
+ }
1036
+ return { text: "", marks: [] };
1037
+ }
1038
+ function getMarks(node) {
1039
+ const marks2 = [];
1040
+ if (!node)
1041
+ return marks2;
1042
+ switch (node.type) {
1043
+ case "link":
1044
+ marks2.push({
1045
+ type: "link",
1046
+ attrs: {
1047
+ href: node.url,
1048
+ title: node.title || void 0
1049
+ }
1050
+ });
1051
+ break;
1052
+ case "inlineCode":
1053
+ marks2.push({ type: "code" });
1054
+ break;
1055
+ case "emphasis":
1056
+ marks2.push({ type: "italic" });
1057
+ break;
1058
+ case "strong":
1059
+ marks2.push({ type: "bold" });
1060
+ break;
1061
+ case "delete":
1062
+ marks2.push({ type: "strike" });
1063
+ break;
1064
+ case "mdxJsxTextElement":
1065
+ if (node.name === "u")
1066
+ marks2.push({ type: "underline" });
1067
+ else if (node.name === "sub")
1068
+ marks2.push({ type: "subscript" });
1069
+ else if (node.name === "sup")
1070
+ marks2.push({ type: "superscript" });
1071
+ break;
1072
+ }
1073
+ return marks2;
1074
+ }
1075
+ function isInlineNode(node, schema2) {
1076
+ var _a;
1077
+ return ((_a = schema2.nodes[node.type]) === null || _a === void 0 ? void 0 : _a.isInline) === true;
1078
+ }
1079
+ function normalizeBlockContent(nodes2, schema2) {
1080
+ const normalized = [];
1081
+ let pendingInlineContent = [];
1082
+ const flushPendingInlineContent = () => {
1083
+ if (pendingInlineContent.length === 0)
1084
+ return;
1085
+ normalized.push({
1086
+ type: "paragraph",
1087
+ content: pendingInlineContent
1088
+ });
1089
+ pendingInlineContent = [];
1090
+ };
1091
+ for (const node of nodes2) {
1092
+ if (isInlineNode(node, schema2)) {
1093
+ pendingInlineContent.push(node);
1094
+ continue;
1095
+ }
1096
+ flushPendingInlineContent();
1097
+ normalized.push(node);
1098
+ }
1099
+ flushPendingInlineContent();
1100
+ return normalized;
1101
+ }
1102
+
1000
1103
  // ../editor/dist/converter/parse/handlers/callout.js
1001
1104
  var CALLOUT_NON_TYPE_ATTRS = CALLOUT_ATTRS.filter((d) => d.name !== "type");
1002
1105
  function canonicalCalloutType(value) {
@@ -1240,109 +1343,6 @@ function mdxToMdast(mdx, options = {
1240
1343
  return parser().parse(preprocessCustomHeadingIds(sanitized, { preserveOriginal: true }));
1241
1344
  }
1242
1345
 
1243
- // ../editor/dist/converter/parse/parse-utils.js
1244
- import { parse as parseYaml } from "yaml";
1245
- function extractFrontmatter(mdast) {
1246
- const yamlNode = mdast.children.find((n) => n.type === "yaml");
1247
- if (!yamlNode || !("value" in yamlNode))
1248
- return {};
1249
- try {
1250
- const parsed = parseYaml(yamlNode.value);
1251
- if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
1252
- return parsed;
1253
- }
1254
- } catch (_a) {
1255
- }
1256
- return {};
1257
- }
1258
- function createTextNode(value, marks2 = []) {
1259
- if (!value)
1260
- return { type: "text", text: "" };
1261
- return Object.assign({ type: "text", text: value }, marks2.length > 0 && { marks: marks2 });
1262
- }
1263
- function extractTextFromNode(node) {
1264
- if (!node)
1265
- return { text: "", marks: [] };
1266
- if (node.type === "text" || node.type === "inlineCode") {
1267
- return { text: ("value" in node ? node.value : "") || "", marks: getMarks(node) };
1268
- }
1269
- if ("children" in node && Array.isArray(node.children)) {
1270
- let text = "";
1271
- const marks2 = getMarks(node);
1272
- for (const child of node.children) {
1273
- const { text: childText, marks: childMarks } = extractTextFromNode(child);
1274
- text += childText;
1275
- marks2.push(...childMarks);
1276
- }
1277
- return { text, marks: marks2 };
1278
- }
1279
- return { text: "", marks: [] };
1280
- }
1281
- function getMarks(node) {
1282
- const marks2 = [];
1283
- if (!node)
1284
- return marks2;
1285
- switch (node.type) {
1286
- case "link":
1287
- marks2.push({
1288
- type: "link",
1289
- attrs: {
1290
- href: node.url,
1291
- title: node.title || void 0
1292
- }
1293
- });
1294
- break;
1295
- case "inlineCode":
1296
- marks2.push({ type: "code" });
1297
- break;
1298
- case "emphasis":
1299
- marks2.push({ type: "italic" });
1300
- break;
1301
- case "strong":
1302
- marks2.push({ type: "bold" });
1303
- break;
1304
- case "delete":
1305
- marks2.push({ type: "strike" });
1306
- break;
1307
- case "mdxJsxTextElement":
1308
- if (node.name === "u")
1309
- marks2.push({ type: "underline" });
1310
- else if (node.name === "sub")
1311
- marks2.push({ type: "subscript" });
1312
- else if (node.name === "sup")
1313
- marks2.push({ type: "superscript" });
1314
- break;
1315
- }
1316
- return marks2;
1317
- }
1318
- function isInlineNode(node, schema2) {
1319
- var _a;
1320
- return ((_a = schema2.nodes[node.type]) === null || _a === void 0 ? void 0 : _a.isInline) === true;
1321
- }
1322
- function normalizeBlockContent(nodes2, schema2) {
1323
- const normalized = [];
1324
- let pendingInlineContent = [];
1325
- const flushPendingInlineContent = () => {
1326
- if (pendingInlineContent.length === 0)
1327
- return;
1328
- normalized.push({
1329
- type: "paragraph",
1330
- content: pendingInlineContent
1331
- });
1332
- pendingInlineContent = [];
1333
- };
1334
- for (const node of nodes2) {
1335
- if (isInlineNode(node, schema2)) {
1336
- pendingInlineContent.push(node);
1337
- continue;
1338
- }
1339
- flushPendingInlineContent();
1340
- normalized.push(node);
1341
- }
1342
- flushPendingInlineContent();
1343
- return normalized;
1344
- }
1345
-
1346
1346
  // ../editor/dist/converter/parse/handlers/prompt.js
1347
1347
  function handlePrompt(node, ctx, transformNode2) {
1348
1348
  var _a;
@@ -1596,7 +1596,7 @@ function handleFlowJsxInner(node, ctx, transformNode2, mapJsxChildren2) {
1596
1596
  if (node.name === BLOCK_TYPES.tree) {
1597
1597
  return handleTree(node);
1598
1598
  }
1599
- if (isCallout || Object.values(BLOCK_TYPES).includes(node.name)) {
1599
+ if (isCallout || node.name !== BLOCK_TYPES.step && Object.values(BLOCK_TYPES).includes(node.name)) {
1600
1600
  const targetType = isCallout ? BLOCK_TYPES.callout : node.name;
1601
1601
  const parsedAttrs = parseMdxAttributes(node.attributes);
1602
1602
  return {
@@ -1888,15 +1888,6 @@ function handleHtmlTable(node, ctx, transformNode2, mapJsxChildren2) {
1888
1888
  });
1889
1889
  return { type: "table", content: tableContent };
1890
1890
  }
1891
- var TABLE_BLOCK_NODE_TYPES = /* @__PURE__ */ new Set([
1892
- "paragraph",
1893
- "heading",
1894
- "bulletList",
1895
- "orderedList",
1896
- "blockquote",
1897
- BLOCK_TYPES.codeBlock,
1898
- "table"
1899
- ]);
1900
1891
  function flattenPmContent(content) {
1901
1892
  return Array.isArray(content) ? content.filter(Boolean) : [content];
1902
1893
  }
@@ -1925,14 +1916,7 @@ function convertHtmlTableCellChildren(cell, ctx, transformNode2, mapJsxChildren2
1925
1916
  const result = [];
1926
1917
  for (const child of cell.children) {
1927
1918
  if (child.type !== "mdxJsxFlowElement" && child.type !== "mdxJsxTextElement") {
1928
- const items = flattenPmContent(transformNode2(child, ctx));
1929
- if (items.length > 0) {
1930
- if (items.length === 1 && ((_a = items[0]) === null || _a === void 0 ? void 0 : _a.type) && TABLE_BLOCK_NODE_TYPES.has(items[0].type)) {
1931
- result.push(items[0]);
1932
- } else {
1933
- result.push({ type: "paragraph", content: items });
1934
- }
1935
- }
1919
+ result.push(...flattenPmContent(transformNode2(child, ctx)));
1936
1920
  continue;
1937
1921
  }
1938
1922
  if (child.name === "p") {
@@ -1943,11 +1927,11 @@ function convertHtmlTableCellChildren(cell, ctx, transformNode2, mapJsxChildren2
1943
1927
  continue;
1944
1928
  }
1945
1929
  if (child.name && /^h[1-6]$/.test(child.name)) {
1946
- const level = parseInt((_b = child.name[1]) !== null && _b !== void 0 ? _b : "1", 10);
1930
+ const level = parseInt((_a = child.name[1]) !== null && _a !== void 0 ? _a : "1", 10);
1947
1931
  const headingAttrs = parseMdxAttributes(child.attributes);
1948
1932
  result.push({
1949
1933
  type: "heading",
1950
- attrs: { level, id: (_c = headingAttrs.id) !== null && _c !== void 0 ? _c : null },
1934
+ attrs: { level, id: (_b = headingAttrs.id) !== null && _b !== void 0 ? _b : null },
1951
1935
  content: mapTableJsxElementChildren(child, ctx, transformNode2, mapJsxChildren2)
1952
1936
  });
1953
1937
  continue;
@@ -1972,7 +1956,7 @@ function convertHtmlTableCellChildren(cell, ctx, transformNode2, mapJsxChildren2
1972
1956
  }
1973
1957
  result.push(...flattenPmContent(transformNode2(child, ctx)));
1974
1958
  }
1975
- return result;
1959
+ return normalizeBlockContent(result, (_c = ctx.schema) !== null && _c !== void 0 ? _c : mintlifySchema);
1976
1960
  }
1977
1961
  function mapTableJsxElementChildren(node, ctx, transformNode2, mapJsxChildren2) {
1978
1962
  if (node.type === "mdxJsxFlowElement") {
@@ -1986,7 +1970,7 @@ function mapTableJsxElementChildren(node, ctx, transformNode2, mapJsxChildren2)
1986
1970
 
1987
1971
  // ../editor/dist/converter/parse/handlers/inline-jsx.js
1988
1972
  function handleInlineJsx(node, ctx, mapChildren2) {
1989
- var _a;
1973
+ var _a, _b;
1990
1974
  if (node.name === "Tooltip") {
1991
1975
  const attrs2 = partitionAttrs(parseMdxAttributes(node.attributes), TOOLTIP_ATTRS);
1992
1976
  const content = mapChildren2(node, ctx);
@@ -2049,14 +2033,17 @@ function handleInlineJsx(node, ctx, mapChildren2) {
2049
2033
  };
2050
2034
  }
2051
2035
  if (node.name && HTML_ELEMENTS.has(node.name)) {
2036
+ const schema2 = (_b = ctx.schema) !== null && _b !== void 0 ? _b : mintlifySchema;
2037
+ const children = mapChildren2(node, ctx);
2038
+ const hasBlock = children.some((child) => !isInlineNode(child, schema2));
2052
2039
  return {
2053
- type: BLOCK_TYPES.inlineStaticHTML,
2040
+ type: hasBlock ? BLOCK_TYPES.staticHTML : BLOCK_TYPES.inlineStaticHTML,
2054
2041
  attrs: {
2055
2042
  tagName: node.name,
2056
2043
  attributes: parseMdxAttributes(node.attributes),
2057
2044
  mdxJsxNode: node
2058
2045
  },
2059
- content: mapChildren2(node, ctx)
2046
+ content: hasBlock ? normalizeBlockContent(children, schema2) : children
2060
2047
  };
2061
2048
  }
2062
2049
  if (node.name) {
@@ -2384,14 +2371,14 @@ function buildMarkdownTableCellContent(children, ctx, transformNode2) {
2384
2371
  return children.flatMap((child) => flattenNodeContent(transformNode2(child, ctx)));
2385
2372
  }
2386
2373
  function handleParagraph(node, ctx, transformNode2, mapChildren2) {
2387
- var _a, _b, _c;
2374
+ var _a, _b, _c, _d;
2388
2375
  if (node.children.length === 1 && ((_a = node.children[0]) === null || _a === void 0 ? void 0 : _a.type) === "mdxJsxTextElement" && ((_b = node.children[0]) === null || _b === void 0 ? void 0 : _b.name)) {
2389
2376
  const result = transformNode2(node.children[0], ctx);
2390
2377
  const nodes2 = flattenNodeContent(result);
2391
- const schema2 = (_c = ctx.schema) !== null && _c !== void 0 ? _c : mintlifySchema;
2378
+ const schema3 = (_c = ctx.schema) !== null && _c !== void 0 ? _c : mintlifySchema;
2392
2379
  const allInline = nodes2.length > 0 && nodes2.every((child) => {
2393
2380
  var _a2;
2394
- return ((_a2 = schema2.nodes[child.type]) === null || _a2 === void 0 ? void 0 : _a2.isInline) === true;
2381
+ return ((_a2 = schema3.nodes[child.type]) === null || _a2 === void 0 ? void 0 : _a2.isInline) === true;
2395
2382
  });
2396
2383
  if (allInline) {
2397
2384
  return { type: "paragraph", content: nodes2 };
@@ -2402,22 +2389,22 @@ function handleParagraph(node, ctx, transformNode2, mapChildren2) {
2402
2389
  if (hasImages) {
2403
2390
  const hasTextContent = node.children.some((child) => child.type === "text" || child.type === "emphasis" || child.type === "strong" || child.type === "link" || child.type === "inlineCode" || child.type === "delete" || child.type === "mdxJsxTextElement" && child.name !== "img");
2404
2391
  if (hasTextContent) {
2405
- const content = [];
2392
+ const content2 = [];
2406
2393
  for (const child of node.children) {
2407
2394
  if (child.type === "image" || child.type === "mdxJsxTextElement" && child.name === "img") {
2408
2395
  const inlineImg = convertToInlineImage(child);
2409
2396
  if (inlineImg)
2410
- content.push(inlineImg);
2397
+ content2.push(inlineImg);
2411
2398
  } else {
2412
2399
  const result = transformNode2(child, ctx);
2413
2400
  if (Array.isArray(result)) {
2414
- content.push(...result);
2401
+ content2.push(...result);
2415
2402
  } else {
2416
- content.push(result);
2403
+ content2.push(result);
2417
2404
  }
2418
2405
  }
2419
2406
  }
2420
- return { type: "paragraph", content: content.filter(Boolean) };
2407
+ return { type: "paragraph", content: content2.filter(Boolean) };
2421
2408
  }
2422
2409
  const blocks = [];
2423
2410
  for (const child of node.children) {
@@ -2431,10 +2418,32 @@ function handleParagraph(node, ctx, transformNode2, mapChildren2) {
2431
2418
  }
2432
2419
  return blocks.length > 0 ? blocks : [];
2433
2420
  }
2434
- return {
2435
- type: "paragraph",
2436
- content: mapChildren2(node, ctx)
2437
- };
2421
+ const content = mapChildren2(node, ctx);
2422
+ const schema2 = (_d = ctx.schema) !== null && _d !== void 0 ? _d : mintlifySchema;
2423
+ if (content.every((child) => isInlineNode(child, schema2))) {
2424
+ return { type: "paragraph", content };
2425
+ }
2426
+ return splitParagraphAroundBlocks(content, schema2);
2427
+ }
2428
+ function splitParagraphAroundBlocks(content, schema2) {
2429
+ return normalizeBlockContent(mergeDarkLightImagePairs(content), schema2).map((block) => block.type === "paragraph" ? trimParagraph(block) : block).filter((block) => {
2430
+ var _a, _b;
2431
+ return block.type !== "paragraph" || ((_b = (_a = block.content) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0;
2432
+ });
2433
+ }
2434
+ function trimParagraph(paragraph) {
2435
+ var _a;
2436
+ const content = [...(_a = paragraph.content) !== null && _a !== void 0 ? _a : []];
2437
+ const first = content[0];
2438
+ if ((first === null || first === void 0 ? void 0 : first.type) === "text" && first.text) {
2439
+ content[0] = Object.assign(Object.assign({}, first), { text: first.text.replace(/^\s+/, "") });
2440
+ }
2441
+ const lastIndex = content.length - 1;
2442
+ const last = content[lastIndex];
2443
+ if ((last === null || last === void 0 ? void 0 : last.type) === "text" && last.text) {
2444
+ content[lastIndex] = Object.assign(Object.assign({}, last), { text: last.text.replace(/\s+$/, "") });
2445
+ }
2446
+ return Object.assign(Object.assign({}, paragraph), { content: content.filter((n) => n.type !== "text" || n.text !== "") });
2438
2447
  }
2439
2448
  function handleTable(node, ctx, transformNode2) {
2440
2449
  const rows = node.children;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/cli",
3
- "version": "4.0.1448",
3
+ "version": "4.0.1450",
4
4
  "description": "The Mintlify CLI",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -86,7 +86,7 @@
86
86
  "keytar": "7.9.0"
87
87
  },
88
88
  "devDependencies": {
89
- "@mintlify/editor": "0.0.338",
89
+ "@mintlify/editor": "0.0.340",
90
90
  "@mintlify/ts-config": "2.0.2",
91
91
  "@tsconfig/recommended": "1.0.2",
92
92
  "@types/detect-port": "1.3.2",
@@ -105,5 +105,5 @@
105
105
  "vitest": "2.1.9",
106
106
  "vitest-mock-process": "1.0.4"
107
107
  },
108
- "gitHead": "93b07887740dc79844de4434f86b7f994f9b06b2"
108
+ "gitHead": "49b924242ed529fabeb05bbbee126dfcf7a644eb"
109
109
  }