@tinacms/mdx 0.0.0-cef656e-20250119001929 → 0.0.0-d28d795-20250427004334
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.mjs +88 -112
- package/dist/index.d.ts +1 -10
- package/dist/index.js +91 -115
- package/dist/index.mjs +88 -112
- package/dist/next/stringify/pre-processing.d.ts +0 -2
- package/dist/next/tests/markdown-basic-marks-strikethrough/field.d.ts +2 -0
- package/dist/next/tests/util.d.ts +0 -6
- package/dist/parse/acorn.d.ts +1 -1
- package/dist/parse/index.d.ts +1 -3
- package/dist/parse/mdx.d.ts +2 -2
- package/dist/parse/plate.d.ts +1 -1
- package/dist/parse/remarkToPlate.d.ts +1 -1
- package/dist/stringify/acorn.d.ts +3 -3
- package/dist/stringify/index.d.ts +4 -4
- package/package.json +6 -11
- package/dist/next/tests/mdx-local-variables/field.d.ts +0 -2
- /package/dist/next/tests/{mdx-local-variables → markdown-basic-marks-strikethrough}/index.test.d.ts +0 -0
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(), {
|
|
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(
|
|
25509
|
+
value += tracker.move(
|
|
25510
|
+
containerFlow(node2, context, tracker.current())
|
|
25511
|
+
);
|
|
25508
25512
|
value += tracker.move("\n");
|
|
25509
25513
|
}
|
|
25510
25514
|
} else {
|
|
@@ -40024,22 +40028,10 @@ var Xh = Q({ "src/language-js/parse/acorn-and-espree.js"(a, u) {
|
|
|
40024
40028
|
var mc = Xh();
|
|
40025
40029
|
|
|
40026
40030
|
// src/stringify/acorn.ts
|
|
40027
|
-
|
|
40028
|
-
|
|
40029
|
-
let result = "";
|
|
40030
|
-
for (let i = 0; i < 6; i++) {
|
|
40031
|
-
const randomIndex = Math.floor(Math.random() * characters.length);
|
|
40032
|
-
result += characters[randomIndex];
|
|
40033
|
-
}
|
|
40034
|
-
return result;
|
|
40035
|
-
}
|
|
40036
|
-
function isMultiline(input) {
|
|
40037
|
-
return input.includes("\n") || input.includes("\r");
|
|
40038
|
-
}
|
|
40039
|
-
var stringifyPropsInline = (element, field, imageCallback, context) => {
|
|
40040
|
-
return stringifyProps(element, field, true, imageCallback, context || {});
|
|
40031
|
+
var stringifyPropsInline = (element, field, imageCallback) => {
|
|
40032
|
+
return stringifyProps(element, field, true, imageCallback);
|
|
40041
40033
|
};
|
|
40042
|
-
function stringifyProps(element, parentField, flatten2, imageCallback
|
|
40034
|
+
function stringifyProps(element, parentField, flatten2, imageCallback) {
|
|
40043
40035
|
const attributes2 = [];
|
|
40044
40036
|
const children = [];
|
|
40045
40037
|
let template;
|
|
@@ -40063,16 +40055,6 @@ function stringifyProps(element, parentField, flatten2, imageCallback, context)
|
|
|
40063
40055
|
if (template.fields.find((f) => f.name === "children")) {
|
|
40064
40056
|
directiveType = "block";
|
|
40065
40057
|
}
|
|
40066
|
-
const embedCodes = {};
|
|
40067
|
-
for (const [embedKey, value] of Object.entries(element.props)) {
|
|
40068
|
-
if (embedKey.startsWith("_tinaEmbeds")) {
|
|
40069
|
-
const key = embedKey.replace("_tinaEmbeds.", "");
|
|
40070
|
-
embedCodes[key] = value;
|
|
40071
|
-
}
|
|
40072
|
-
}
|
|
40073
|
-
for (const key of Object.keys(embedCodes)) {
|
|
40074
|
-
delete element.props[`_tinaEmbeds.${key}`];
|
|
40075
|
-
}
|
|
40076
40058
|
useDirective = !!template.match;
|
|
40077
40059
|
Object.entries(element.props).forEach(([name2, value]) => {
|
|
40078
40060
|
if (typeof template === "string") {
|
|
@@ -40123,22 +40105,11 @@ function stringifyProps(element, parentField, flatten2, imageCallback, context)
|
|
|
40123
40105
|
}
|
|
40124
40106
|
} else {
|
|
40125
40107
|
if (typeof value === "string") {
|
|
40126
|
-
|
|
40127
|
-
|
|
40128
|
-
|
|
40129
|
-
|
|
40130
|
-
|
|
40131
|
-
type: "mdxJsxAttribute",
|
|
40132
|
-
name: name2,
|
|
40133
|
-
value: `_tinaEmbeds.${code3}`
|
|
40134
|
-
});
|
|
40135
|
-
} else {
|
|
40136
|
-
attributes2.push({
|
|
40137
|
-
type: "mdxJsxAttribute",
|
|
40138
|
-
name: name2,
|
|
40139
|
-
value
|
|
40140
|
-
});
|
|
40141
|
-
}
|
|
40108
|
+
attributes2.push({
|
|
40109
|
+
type: "mdxJsxAttribute",
|
|
40110
|
+
name: name2,
|
|
40111
|
+
value
|
|
40112
|
+
});
|
|
40142
40113
|
} else {
|
|
40143
40114
|
throw new Error(
|
|
40144
40115
|
`Expected string for attribute on field ${field.name}`
|
|
@@ -40224,23 +40195,39 @@ function stringifyProps(element, parentField, flatten2, imageCallback, context)
|
|
|
40224
40195
|
(value2) => value2.type === "root" && Array.isArray(value2.children),
|
|
40225
40196
|
`Nested rich-text element is not a valid shape for field ${field.name}`
|
|
40226
40197
|
);
|
|
40227
|
-
const code3 = value.embedCode || generateRandom6LetterString();
|
|
40228
40198
|
if (field.name === "children") {
|
|
40229
|
-
const root2 = rootElement(value, field, imageCallback
|
|
40199
|
+
const root2 = rootElement(value, field, imageCallback);
|
|
40230
40200
|
root2.children.forEach((child) => {
|
|
40231
40201
|
children.push(child);
|
|
40232
40202
|
});
|
|
40233
40203
|
return;
|
|
40234
40204
|
} else {
|
|
40235
40205
|
const stringValue = stringifyMDX(value, field, imageCallback);
|
|
40236
|
-
|
|
40237
|
-
|
|
40206
|
+
if (stringValue) {
|
|
40207
|
+
val = stringValue.trim().split("\n").map((str) => ` ${str.trim()}`).join(joiner);
|
|
40208
|
+
}
|
|
40209
|
+
}
|
|
40210
|
+
if (flatten2) {
|
|
40211
|
+
attributes2.push({
|
|
40212
|
+
type: "mdxJsxAttribute",
|
|
40213
|
+
name: name2,
|
|
40214
|
+
value: {
|
|
40215
|
+
type: "mdxJsxAttributeValueExpression",
|
|
40216
|
+
value: `<>${val.trim()}</>`
|
|
40217
|
+
}
|
|
40218
|
+
});
|
|
40219
|
+
} else {
|
|
40220
|
+
attributes2.push({
|
|
40221
|
+
type: "mdxJsxAttribute",
|
|
40222
|
+
name: name2,
|
|
40223
|
+
value: {
|
|
40224
|
+
type: "mdxJsxAttributeValueExpression",
|
|
40225
|
+
value: `<>
|
|
40226
|
+
${val}
|
|
40227
|
+
</>`
|
|
40228
|
+
}
|
|
40229
|
+
});
|
|
40238
40230
|
}
|
|
40239
|
-
attributes2.push({
|
|
40240
|
-
type: "mdxJsxAttribute",
|
|
40241
|
-
name: name2,
|
|
40242
|
-
value: `_tinaEmbeds.${code3}`
|
|
40243
|
-
});
|
|
40244
40231
|
}
|
|
40245
40232
|
break;
|
|
40246
40233
|
default:
|
|
@@ -40505,7 +40492,7 @@ var eat2 = (c, field, imageCallback) => {
|
|
|
40505
40492
|
}
|
|
40506
40493
|
if (markToProcess === "inlineCode") {
|
|
40507
40494
|
if (nonMatchingSiblingIndex) {
|
|
40508
|
-
throw new Error(
|
|
40495
|
+
throw new Error("Marks inside inline code are not supported");
|
|
40509
40496
|
}
|
|
40510
40497
|
const node2 = {
|
|
40511
40498
|
type: markToProcess,
|
|
@@ -40540,7 +40527,8 @@ var cleanNode = (node2, mark) => {
|
|
|
40540
40527
|
const markToClear = {
|
|
40541
40528
|
strong: "bold",
|
|
40542
40529
|
emphasis: "italic",
|
|
40543
|
-
inlineCode: "code"
|
|
40530
|
+
inlineCode: "code",
|
|
40531
|
+
delete: "strikethrough"
|
|
40544
40532
|
}[mark];
|
|
40545
40533
|
Object.entries(node2).map(([key, value]) => {
|
|
40546
40534
|
if (key !== markToClear) {
|
|
@@ -40677,7 +40665,7 @@ ${match.start} /${match.name || template.name} ${match.end}`;
|
|
|
40677
40665
|
}
|
|
40678
40666
|
|
|
40679
40667
|
// src/stringify/index.ts
|
|
40680
|
-
var stringifyMDX = (value, field, imageCallback
|
|
40668
|
+
var stringifyMDX = (value, field, imageCallback) => {
|
|
40681
40669
|
if (field.parser?.type === "markdown") {
|
|
40682
40670
|
return stringifyMDX2(value, field, imageCallback);
|
|
40683
40671
|
}
|
|
@@ -40692,7 +40680,7 @@ var stringifyMDX = (value, field, imageCallback, context = {}) => {
|
|
|
40692
40680
|
return value.children[0].value;
|
|
40693
40681
|
}
|
|
40694
40682
|
}
|
|
40695
|
-
const tree = rootElement(value, field, imageCallback
|
|
40683
|
+
const tree = rootElement(value, field, imageCallback);
|
|
40696
40684
|
const res = toTinaMarkdown2(tree, field);
|
|
40697
40685
|
const templatesWithMatchers = field.templates?.filter(
|
|
40698
40686
|
(template) => template.match
|
|
@@ -40753,10 +40741,10 @@ var toTinaMarkdown2 = (tree, field) => {
|
|
|
40753
40741
|
handlers
|
|
40754
40742
|
});
|
|
40755
40743
|
};
|
|
40756
|
-
var rootElement = (content3, field, imageCallback
|
|
40744
|
+
var rootElement = (content3, field, imageCallback) => {
|
|
40757
40745
|
const children = [];
|
|
40758
40746
|
content3.children?.forEach((child) => {
|
|
40759
|
-
const value = blockElement(child, field, imageCallback
|
|
40747
|
+
const value = blockElement(child, field, imageCallback);
|
|
40760
40748
|
if (value) {
|
|
40761
40749
|
children.push(value);
|
|
40762
40750
|
}
|
|
@@ -40766,7 +40754,7 @@ var rootElement = (content3, field, imageCallback, context) => {
|
|
|
40766
40754
|
children
|
|
40767
40755
|
};
|
|
40768
40756
|
};
|
|
40769
|
-
var blockElement = (content3, field, imageCallback
|
|
40757
|
+
var blockElement = (content3, field, imageCallback) => {
|
|
40770
40758
|
switch (content3.type) {
|
|
40771
40759
|
case "h1":
|
|
40772
40760
|
case "h2":
|
|
@@ -40828,7 +40816,7 @@ var blockElement = (content3, field, imageCallback, context) => {
|
|
|
40828
40816
|
})
|
|
40829
40817
|
};
|
|
40830
40818
|
}
|
|
40831
|
-
const { children, attributes: attributes2, useDirective, directiveType } = stringifyProps(content3, field, false, imageCallback
|
|
40819
|
+
const { children, attributes: attributes2, useDirective, directiveType } = stringifyProps(content3, field, false, imageCallback);
|
|
40832
40820
|
if (useDirective) {
|
|
40833
40821
|
const name2 = content3.name;
|
|
40834
40822
|
if (!name2) {
|
|
@@ -40998,6 +40986,9 @@ var getMarks = (content3) => {
|
|
|
40998
40986
|
if (content3.code) {
|
|
40999
40987
|
marks.push("inlineCode");
|
|
41000
40988
|
}
|
|
40989
|
+
if (content3.strikethrough) {
|
|
40990
|
+
marks.push("delete");
|
|
40991
|
+
}
|
|
41001
40992
|
return marks;
|
|
41002
40993
|
};
|
|
41003
40994
|
|
|
@@ -41442,7 +41433,8 @@ var cleanNode2 = (node2, mark) => {
|
|
|
41442
41433
|
const markToClear = {
|
|
41443
41434
|
strong: "bold",
|
|
41444
41435
|
emphasis: "italic",
|
|
41445
|
-
inlineCode: "code"
|
|
41436
|
+
inlineCode: "code",
|
|
41437
|
+
delete: "strikethrough"
|
|
41446
41438
|
}[mark];
|
|
41447
41439
|
Object.entries(node2).map(([key, value]) => {
|
|
41448
41440
|
if (key !== markToClear) {
|
|
@@ -43918,7 +43910,9 @@ function mdxJsx2(options = {}) {
|
|
|
43918
43910
|
{ locations: true }
|
|
43919
43911
|
);
|
|
43920
43912
|
} else if (options.acornOptions || options.addResult) {
|
|
43921
|
-
throw new Error(
|
|
43913
|
+
throw new Error(
|
|
43914
|
+
"Expected an `acorn` instance passed in as `options.acorn`"
|
|
43915
|
+
);
|
|
43922
43916
|
}
|
|
43923
43917
|
const patterns = options.patterns || [];
|
|
43924
43918
|
const flowRules = {};
|
|
@@ -43995,7 +43989,7 @@ function compact(tree) {
|
|
|
43995
43989
|
var import_lodash = __toESM(require_lodash());
|
|
43996
43990
|
|
|
43997
43991
|
// src/parse/acorn.ts
|
|
43998
|
-
var extractAttributes = (attributes2, fields, imageCallback
|
|
43992
|
+
var extractAttributes = (attributes2, fields, imageCallback) => {
|
|
43999
43993
|
const properties = {};
|
|
44000
43994
|
attributes2?.forEach((attribute) => {
|
|
44001
43995
|
assertType(attribute, "mdxJsxAttribute");
|
|
@@ -44009,9 +44003,7 @@ var extractAttributes = (attributes2, fields, imageCallback, context) => {
|
|
|
44009
44003
|
properties[attribute.name] = extractAttribute(
|
|
44010
44004
|
attribute,
|
|
44011
44005
|
field,
|
|
44012
|
-
imageCallback
|
|
44013
|
-
context,
|
|
44014
|
-
(name2, value) => properties[name2] = value
|
|
44006
|
+
imageCallback
|
|
44015
44007
|
);
|
|
44016
44008
|
} catch (e) {
|
|
44017
44009
|
if (e instanceof Error) {
|
|
@@ -44024,7 +44016,7 @@ var extractAttributes = (attributes2, fields, imageCallback, context) => {
|
|
|
44024
44016
|
});
|
|
44025
44017
|
return properties;
|
|
44026
44018
|
};
|
|
44027
|
-
var extractAttribute = (attribute, field, imageCallback
|
|
44019
|
+
var extractAttribute = (attribute, field, imageCallback) => {
|
|
44028
44020
|
switch (field.type) {
|
|
44029
44021
|
case "boolean":
|
|
44030
44022
|
case "number":
|
|
@@ -44034,7 +44026,7 @@ var extractAttribute = (attribute, field, imageCallback, context, addProperty) =
|
|
|
44034
44026
|
if (field.list) {
|
|
44035
44027
|
return extractScalar(extractExpression(attribute), field);
|
|
44036
44028
|
} else {
|
|
44037
|
-
return extractString(attribute, field
|
|
44029
|
+
return extractString(attribute, field);
|
|
44038
44030
|
}
|
|
44039
44031
|
case "image":
|
|
44040
44032
|
if (field.list) {
|
|
@@ -44044,35 +44036,18 @@ var extractAttribute = (attribute, field, imageCallback, context, addProperty) =
|
|
|
44044
44036
|
);
|
|
44045
44037
|
return values2.split(",").map((value) => imageCallback(value));
|
|
44046
44038
|
} else {
|
|
44047
|
-
const value = extractString(attribute, field
|
|
44039
|
+
const value = extractString(attribute, field);
|
|
44048
44040
|
return imageCallback(value);
|
|
44049
44041
|
}
|
|
44050
44042
|
case "reference":
|
|
44051
44043
|
if (field.list) {
|
|
44052
44044
|
return extractScalar(extractExpression(attribute), field);
|
|
44053
44045
|
} else {
|
|
44054
|
-
return extractString(attribute, field
|
|
44046
|
+
return extractString(attribute, field);
|
|
44055
44047
|
}
|
|
44056
44048
|
case "object":
|
|
44057
44049
|
return extractObject(extractExpression(attribute), field, imageCallback);
|
|
44058
44050
|
case "rich-text":
|
|
44059
|
-
if (attribute.type === "mdxJsxAttribute") {
|
|
44060
|
-
if (typeof attribute.value === "string") {
|
|
44061
|
-
if (attribute.value.startsWith("_tinaEmbeds")) {
|
|
44062
|
-
const embedValue = context?._tinaEmbeds;
|
|
44063
|
-
const key = attribute.value.split(".")[1];
|
|
44064
|
-
if (typeof key !== "string") {
|
|
44065
|
-
throw new Error(`Unable to extract key from embed value`);
|
|
44066
|
-
}
|
|
44067
|
-
const value = embedValue[key];
|
|
44068
|
-
if (typeof value === "string") {
|
|
44069
|
-
const ast = parseMDX(value, field, imageCallback, context);
|
|
44070
|
-
ast.embedCode = attribute.value.split(".")[1];
|
|
44071
|
-
return ast;
|
|
44072
|
-
}
|
|
44073
|
-
}
|
|
44074
|
-
}
|
|
44075
|
-
}
|
|
44076
44051
|
const JSXString = extractRaw(attribute);
|
|
44077
44052
|
if (JSXString) {
|
|
44078
44053
|
return parseMDX(JSXString, field, imageCallback);
|
|
@@ -44178,21 +44153,9 @@ var extractStatement = (attribute) => {
|
|
|
44178
44153
|
}
|
|
44179
44154
|
throw new Error(`Unable to extract body from expression`);
|
|
44180
44155
|
};
|
|
44181
|
-
var extractString = (attribute, field
|
|
44156
|
+
var extractString = (attribute, field) => {
|
|
44182
44157
|
if (attribute.type === "mdxJsxAttribute") {
|
|
44183
44158
|
if (typeof attribute.value === "string") {
|
|
44184
|
-
if (attribute.value.startsWith("_tinaEmbeds")) {
|
|
44185
|
-
const embedValue = context?._tinaEmbeds;
|
|
44186
|
-
const key = attribute.value.split(".")[1];
|
|
44187
|
-
if (typeof key !== "string") {
|
|
44188
|
-
throw new Error(`Unable to extract key from embed value`);
|
|
44189
|
-
}
|
|
44190
|
-
const value = embedValue[key];
|
|
44191
|
-
if (typeof value === "string") {
|
|
44192
|
-
addProperty?.(`_tinaEmbeds.${attribute.name}`, key);
|
|
44193
|
-
return value;
|
|
44194
|
-
}
|
|
44195
|
-
}
|
|
44196
44159
|
return attribute.value;
|
|
44197
44160
|
}
|
|
44198
44161
|
}
|
|
@@ -44317,7 +44280,7 @@ function source(value, file) {
|
|
|
44317
44280
|
}
|
|
44318
44281
|
|
|
44319
44282
|
// src/parse/mdx.ts
|
|
44320
|
-
function mdxJsxElement(node2, field, imageCallback
|
|
44283
|
+
function mdxJsxElement(node2, field, imageCallback) {
|
|
44321
44284
|
try {
|
|
44322
44285
|
const template = field.templates?.find((template2) => {
|
|
44323
44286
|
const templateName = typeof template2 === "string" ? template2 : template2.name;
|
|
@@ -44337,8 +44300,7 @@ function mdxJsxElement(node2, field, imageCallback, context) {
|
|
|
44337
44300
|
const props = extractAttributes(
|
|
44338
44301
|
node2.attributes,
|
|
44339
44302
|
template.fields,
|
|
44340
|
-
imageCallback
|
|
44341
|
-
context
|
|
44303
|
+
imageCallback
|
|
44342
44304
|
);
|
|
44343
44305
|
const childField = template.fields.find(
|
|
44344
44306
|
(field2) => field2.name === "children"
|
|
@@ -44406,7 +44368,7 @@ var directiveElement = (node2, field, imageCallback, raw) => {
|
|
|
44406
44368
|
};
|
|
44407
44369
|
|
|
44408
44370
|
// src/parse/remarkToPlate.ts
|
|
44409
|
-
var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess
|
|
44371
|
+
var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess) => {
|
|
44410
44372
|
const mdxJsxElement2 = skipMDXProcess ? (node2) => node2 : mdxJsxElement;
|
|
44411
44373
|
const content3 = (content4) => {
|
|
44412
44374
|
switch (content4.type) {
|
|
@@ -44457,7 +44419,7 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess, context)
|
|
|
44457
44419
|
case "paragraph":
|
|
44458
44420
|
return paragraph2(content4);
|
|
44459
44421
|
case "mdxJsxFlowElement":
|
|
44460
|
-
return mdxJsxElement2(content4, field, imageCallback
|
|
44422
|
+
return mdxJsxElement2(content4, field, imageCallback);
|
|
44461
44423
|
case "thematicBreak":
|
|
44462
44424
|
return {
|
|
44463
44425
|
type: "hr",
|
|
@@ -44553,8 +44515,7 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess, context)
|
|
|
44553
44515
|
mdxJsxElement2(
|
|
44554
44516
|
{ ...child, type: "mdxJsxTextElement" },
|
|
44555
44517
|
field,
|
|
44556
|
-
imageCallback
|
|
44557
|
-
context
|
|
44518
|
+
imageCallback
|
|
44558
44519
|
)
|
|
44559
44520
|
]
|
|
44560
44521
|
};
|
|
@@ -44667,7 +44628,7 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess, context)
|
|
|
44667
44628
|
const staticPhrasingContent = (content4) => {
|
|
44668
44629
|
switch (content4.type) {
|
|
44669
44630
|
case "mdxJsxTextElement":
|
|
44670
|
-
return mdxJsxElement2(content4, field, imageCallback
|
|
44631
|
+
return mdxJsxElement2(content4, field, imageCallback);
|
|
44671
44632
|
case "text":
|
|
44672
44633
|
return text7(content4);
|
|
44673
44634
|
case "inlineCode":
|
|
@@ -44687,12 +44648,14 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess, context)
|
|
|
44687
44648
|
switch (content4.type) {
|
|
44688
44649
|
case "text":
|
|
44689
44650
|
return text7(content4);
|
|
44651
|
+
case "delete":
|
|
44652
|
+
return phrashingMark(content4);
|
|
44690
44653
|
case "link":
|
|
44691
44654
|
return link2(content4);
|
|
44692
44655
|
case "image":
|
|
44693
44656
|
return image2(content4);
|
|
44694
44657
|
case "mdxJsxTextElement":
|
|
44695
|
-
return mdxJsxElement2(content4, field, imageCallback
|
|
44658
|
+
return mdxJsxElement2(content4, field, imageCallback);
|
|
44696
44659
|
case "emphasis":
|
|
44697
44660
|
return phrashingMark(content4);
|
|
44698
44661
|
case "strong":
|
|
@@ -44712,7 +44675,9 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess, context)
|
|
|
44712
44675
|
content4.position
|
|
44713
44676
|
);
|
|
44714
44677
|
default:
|
|
44715
|
-
throw new Error(
|
|
44678
|
+
throw new Error(
|
|
44679
|
+
`PhrasingContent: ${content4.type} is not yet supported`
|
|
44680
|
+
);
|
|
44716
44681
|
}
|
|
44717
44682
|
};
|
|
44718
44683
|
const breakContent = () => {
|
|
@@ -44751,6 +44716,17 @@ var remarkToSlate = (root2, field, imageCallback, raw, skipMDXProcess, context)
|
|
|
44751
44716
|
});
|
|
44752
44717
|
break;
|
|
44753
44718
|
}
|
|
44719
|
+
case "delete": {
|
|
44720
|
+
const children = (0, import_lodash.default)(
|
|
44721
|
+
node2.children.map(
|
|
44722
|
+
(child) => phrashingMark(child, [...marks, "strikethrough"])
|
|
44723
|
+
)
|
|
44724
|
+
);
|
|
44725
|
+
children.forEach((child) => {
|
|
44726
|
+
accum.push(child);
|
|
44727
|
+
});
|
|
44728
|
+
break;
|
|
44729
|
+
}
|
|
44754
44730
|
case "strong": {
|
|
44755
44731
|
const children = (0, import_lodash.default)(
|
|
44756
44732
|
node2.children.map((child) => phrashingMark(child, [...marks, "bold"]))
|
|
@@ -44954,7 +44930,7 @@ var mdxToAst = (value) => {
|
|
|
44954
44930
|
return remark().use(remarkMdx).use(remarkGfm).parse(value);
|
|
44955
44931
|
};
|
|
44956
44932
|
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";
|
|
44957
|
-
var parseMDX = (value, field, imageCallback
|
|
44933
|
+
var parseMDX = (value, field, imageCallback) => {
|
|
44958
44934
|
if (!value) {
|
|
44959
44935
|
return { type: "root", children: [] };
|
|
44960
44936
|
}
|
|
@@ -44979,7 +44955,7 @@ var parseMDX = (value, field, imageCallback, context) => {
|
|
|
44979
44955
|
});
|
|
44980
44956
|
tree = mdxToAst(preprocessedString);
|
|
44981
44957
|
if (tree) {
|
|
44982
|
-
return remarkToSlate(tree, field, imageCallback, value
|
|
44958
|
+
return remarkToSlate(tree, field, imageCallback, value);
|
|
44983
44959
|
} else {
|
|
44984
44960
|
return { type: "root", children: [] };
|
|
44985
44961
|
}
|
|
@@ -5,5 +5,3 @@ import type { RootElement } from '../../parse/plate';
|
|
|
5
5
|
export declare const preProcess: (tree: RootElement, field: RichTextField, imageCallback: (url: string) => string) => Md.Root;
|
|
6
6
|
export declare const rootElement: (content: Plate.RootElement, field: RichTextField, imageCallback: (url: string) => string) => Md.Root;
|
|
7
7
|
export declare const blockElement: (content: Plate.BlockElement, field: RichTextField, imageCallback: (url: string) => string) => Md.Content | null;
|
|
8
|
-
export type Marks = 'strong' | 'emphasis' | 'inlineCode';
|
|
9
|
-
export declare const getMarks: (content: Plate.InlineElement) => Marks[];
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
export declare function removePosition(tree: any): any;
|
|
2
2
|
export declare const print: (tree: object) => string;
|
|
3
3
|
export declare const nodePath: (dir: string) => string;
|
|
4
|
-
export declare const contextPath: (dir: string) => string;
|
|
5
|
-
export declare const frontmatterContext: (contextMarkdown: string) => {
|
|
6
|
-
_tinaEmbeds?: Record<string, string> | null | undefined;
|
|
7
|
-
};
|
|
8
|
-
export declare const frontmatterString: (context: object) => string;
|
|
9
4
|
export declare const mdPath: (dir: string) => string;
|
|
10
|
-
export declare const mdContextPath: (dir: string) => string;
|
package/dist/parse/acorn.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { MdxJsxAttribute, MdxJsxExpressionAttribute } from 'mdast-util-mdx-jsx';
|
|
2
2
|
import type { TinaField } from '@tinacms/schema-tools';
|
|
3
|
-
export declare const extractAttributes: (attributes: (MdxJsxAttribute | MdxJsxExpressionAttribute)[], fields: TinaField[], imageCallback: (image: string) => string
|
|
3
|
+
export declare const extractAttributes: (attributes: (MdxJsxAttribute | MdxJsxExpressionAttribute)[], fields: TinaField[], imageCallback: (image: string) => string) => Record<string, unknown>;
|
|
4
4
|
export declare const trimFragments: (string: string) => string;
|
package/dist/parse/index.d.ts
CHANGED
|
@@ -59,8 +59,6 @@ export declare const markdownToAst: (value: string, field: RichTextType) => impo
|
|
|
59
59
|
export declare const mdxToAst: (value: string) => import("mdast").Root;
|
|
60
60
|
export declare const 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";
|
|
61
61
|
export declare const MDX_PARSE_ERROR_MSG_HTML = "TinaCMS supports a stricter version of markdown and a subset of MDX. <a href=\"https://tina.io/docs/editing/mdx/#differences-from-other-mdx-implementations\" target=\"_blank\" rel=\"noopener noreferrer\">Learn More</a>";
|
|
62
|
-
export declare const parseMDX: (value: string, field: RichTextType, imageCallback: (s: string) => string
|
|
63
|
-
_tinaEmbeds?: Record<string, string> | null | undefined;
|
|
64
|
-
}) => Plate.RootElement;
|
|
62
|
+
export declare const parseMDX: (value: string, field: RichTextType, imageCallback: (s: string) => string) => Plate.RootElement;
|
|
65
63
|
export declare const invalidMarkdown: (e: RichTextParseError, value: string) => Plate.RootElement;
|
|
66
64
|
export declare const replaceAll: (string: string, target: string, value: string) => string;
|
package/dist/parse/mdx.d.ts
CHANGED
|
@@ -8,6 +8,6 @@ import type { RichTextType } from '@tinacms/schema-tools';
|
|
|
8
8
|
import type * as Plate from './plate';
|
|
9
9
|
import { ContainerDirective } from 'mdast-util-directive';
|
|
10
10
|
import { LeafDirective } from 'mdast-util-directive/lib';
|
|
11
|
-
export declare function mdxJsxElement(node: MdxJsxTextElement, field: RichTextType, imageCallback: (url: string) => string
|
|
12
|
-
export declare function mdxJsxElement(node: MdxJsxFlowElement, field: RichTextType, imageCallback: (url: string) => string
|
|
11
|
+
export declare function mdxJsxElement(node: MdxJsxTextElement, field: RichTextType, imageCallback: (url: string) => string): Plate.MdxInlineElement;
|
|
12
|
+
export declare function mdxJsxElement(node: MdxJsxFlowElement, field: RichTextType, imageCallback: (url: string) => string): Plate.MdxBlockElement;
|
|
13
13
|
export declare const directiveElement: (node: ContainerDirective | LeafDirective, field: RichTextType, imageCallback: (url: string) => string, raw?: string) => Plate.BlockElement | Plate.ParagraphElement;
|
package/dist/parse/plate.d.ts
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
export type RootElement = {
|
|
10
10
|
type: 'root';
|
|
11
11
|
children: BlockElement[];
|
|
12
|
-
embedCode?: string;
|
|
13
12
|
};
|
|
14
13
|
/**
|
|
15
14
|
* @group BlockElement
|
|
@@ -182,6 +181,7 @@ export type TextElement = {
|
|
|
182
181
|
bold?: boolean;
|
|
183
182
|
italic?: boolean;
|
|
184
183
|
code?: boolean;
|
|
184
|
+
strikethrough?: boolean;
|
|
185
185
|
};
|
|
186
186
|
/**
|
|
187
187
|
* @remarks
|
|
@@ -23,7 +23,7 @@ declare module 'mdast' {
|
|
|
23
23
|
mdxJsxFlowElement: MdxJsxFlowElement;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
export declare const remarkToSlate: (root: Md.Root | MdxJsxFlowElement | MdxJsxTextElement | ContainerDirective, field: RichTextType, imageCallback: (url: string) => string, raw?: string, skipMDXProcess?: boolean
|
|
26
|
+
export declare const remarkToSlate: (root: Md.Root | MdxJsxFlowElement | MdxJsxTextElement | ContainerDirective, field: RichTextType, imageCallback: (url: string) => string, raw?: string, skipMDXProcess?: boolean) => Plate.RootElement;
|
|
27
27
|
export declare class RichTextParseError extends Error {
|
|
28
28
|
position?: Plate.Position;
|
|
29
29
|
constructor(message: string, position?: Plate.Position);
|
|
@@ -2,17 +2,17 @@ import type { RichTextField } from '@tinacms/schema-tools';
|
|
|
2
2
|
import type { MdxJsxAttribute } from 'mdast-util-mdx-jsx';
|
|
3
3
|
import * as Plate from '../parse/plate';
|
|
4
4
|
import type * as Md from 'mdast';
|
|
5
|
-
export declare const stringifyPropsInline: (element: Plate.MdxInlineElement, field: RichTextField, imageCallback: (url: string) => string
|
|
5
|
+
export declare const stringifyPropsInline: (element: Plate.MdxInlineElement, field: RichTextField, imageCallback: (url: string) => string) => {
|
|
6
6
|
attributes: MdxJsxAttribute[];
|
|
7
7
|
children: Md.PhrasingContent[];
|
|
8
8
|
};
|
|
9
|
-
export declare function stringifyProps(element: Plate.MdxInlineElement, parentField: RichTextField, flatten: boolean, imageCallback: (url: string) => string
|
|
9
|
+
export declare function stringifyProps(element: Plate.MdxInlineElement, parentField: RichTextField, flatten: boolean, imageCallback: (url: string) => string): {
|
|
10
10
|
attributes: MdxJsxAttribute[];
|
|
11
11
|
children: Md.PhrasingContent[];
|
|
12
12
|
useDirective: boolean;
|
|
13
13
|
directiveType: string;
|
|
14
14
|
};
|
|
15
|
-
export declare function stringifyProps(element: Plate.MdxBlockElement, parentField: RichTextField, flatten: boolean, imageCallback: (url: string) => string
|
|
15
|
+
export declare function stringifyProps(element: Plate.MdxBlockElement, parentField: RichTextField, flatten: boolean, imageCallback: (url: string) => string): {
|
|
16
16
|
attributes: MdxJsxAttribute[];
|
|
17
17
|
children: Md.BlockContent[];
|
|
18
18
|
useDirective: boolean;
|
|
@@ -21,7 +21,7 @@ declare module 'mdast' {
|
|
|
21
21
|
mdxJsxFlowElement: MdxJsxFlowElement;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
export declare const stringifyMDX: (value: Plate.RootElement, field: RichTextType, imageCallback: (url: string) => string
|
|
24
|
+
export declare const stringifyMDX: (value: Plate.RootElement, field: RichTextType, imageCallback: (url: string) => string) => string | undefined;
|
|
25
25
|
export type Pattern = {
|
|
26
26
|
start: string;
|
|
27
27
|
end: string;
|
|
@@ -30,7 +30,7 @@ export type Pattern = {
|
|
|
30
30
|
type: 'block' | 'leaf';
|
|
31
31
|
};
|
|
32
32
|
export declare const toTinaMarkdown: (tree: Md.Root, field: RichTextType) => string;
|
|
33
|
-
export declare const rootElement: (content: Plate.RootElement, field: RichTextType, imageCallback: (url: string) => string
|
|
34
|
-
export declare const blockElement: (content: Plate.BlockElement, field: RichTextType, imageCallback: (url: string) => string
|
|
35
|
-
export type Marks = 'strong' | 'emphasis' | 'inlineCode';
|
|
33
|
+
export declare const rootElement: (content: Plate.RootElement, field: RichTextType, imageCallback: (url: string) => string) => Md.Root;
|
|
34
|
+
export declare const blockElement: (content: Plate.BlockElement, field: RichTextType, imageCallback: (url: string) => string) => Md.Content | null;
|
|
35
|
+
export type Marks = 'strong' | 'emphasis' | 'inlineCode' | 'delete';
|
|
36
36
|
export declare const getMarks: (content: Plate.InlineElement) => Marks[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/mdx",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-d28d795-20250427004334",
|
|
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": "
|
|
59
|
+
"@tinacms/schema-tools": "0.0.0-d28d795-20250427004334"
|
|
60
60
|
},
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"registry": "https://registry.npmjs.org"
|
|
@@ -67,25 +67,20 @@
|
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/estree": "1.0.0",
|
|
70
|
-
"@types/js-yaml": "^4.0.9",
|
|
71
70
|
"@types/lodash.flatten": "^4.4.9",
|
|
72
71
|
"@types/mdast": "^3.0.15",
|
|
73
|
-
"@types/node": "^22.
|
|
72
|
+
"@types/node": "^22.13.1",
|
|
74
73
|
"@types/prettier": "^2.7.3",
|
|
75
74
|
"@types/unist": "^2.0.11",
|
|
76
75
|
"c8": "^7.14.0",
|
|
77
76
|
"concat-md": "^0.5.1",
|
|
78
77
|
"jest-file-snapshot": "^0.5.0",
|
|
79
|
-
"js-yaml": "^4.1.0",
|
|
80
|
-
"mdast-util-frontmatter": "1.0.1",
|
|
81
|
-
"micromark-extension-frontmatter": "1.1.0",
|
|
82
78
|
"ts-node": "^10.9.2",
|
|
83
79
|
"typedoc-plugin-markdown": "^3.17.1",
|
|
84
|
-
"typescript": "^5.
|
|
85
|
-
"vite": "^4.5.
|
|
80
|
+
"typescript": "^5.7.3",
|
|
81
|
+
"vite": "^4.5.9",
|
|
86
82
|
"vitest": "^0.32.4",
|
|
87
|
-
"
|
|
88
|
-
"@tinacms/scripts": "1.3.1"
|
|
83
|
+
"@tinacms/scripts": "1.3.4"
|
|
89
84
|
},
|
|
90
85
|
"scripts": {
|
|
91
86
|
"types": "tsc",
|
/package/dist/next/tests/{mdx-local-variables → markdown-basic-marks-strikethrough}/index.test.d.ts
RENAMED
|
File without changes
|