@tinacms/mdx 0.61.15 → 0.61.17
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.js +85 -29
- package/dist/parse/acorn.d.ts +1 -0
- package/dist/parse/acorn.test.d.ts +1 -0
- package/dist/tests/autotest/autoformat mdx with deeply nested rich-text elements.test.d.ts +1 -0
- package/dist/tests/autotest/mdx with deeply nested rich-text elements.test.d.ts +1 -0
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -6670,7 +6670,7 @@ var require_doc = __commonJS({
|
|
|
6670
6670
|
if (parts.length === 0) {
|
|
6671
6671
|
break;
|
|
6672
6672
|
}
|
|
6673
|
-
const [content3,
|
|
6673
|
+
const [content3, whitespace2] = parts;
|
|
6674
6674
|
const contentFlatCmd = [ind, MODE_FLAT, content3];
|
|
6675
6675
|
const contentBreakCmd = [ind, MODE_BREAK, content3];
|
|
6676
6676
|
const contentFits = fits(contentFlatCmd, [], rem, options, lineSuffix.length > 0, true);
|
|
@@ -6682,8 +6682,8 @@ var require_doc = __commonJS({
|
|
|
6682
6682
|
}
|
|
6683
6683
|
break;
|
|
6684
6684
|
}
|
|
6685
|
-
const whitespaceFlatCmd = [ind, MODE_FLAT,
|
|
6686
|
-
const whitespaceBreakCmd = [ind, MODE_BREAK,
|
|
6685
|
+
const whitespaceFlatCmd = [ind, MODE_FLAT, whitespace2];
|
|
6686
|
+
const whitespaceBreakCmd = [ind, MODE_BREAK, whitespace2];
|
|
6687
6687
|
if (parts.length === 2) {
|
|
6688
6688
|
if (contentFits) {
|
|
6689
6689
|
cmds.push(whitespaceFlatCmd, contentFlatCmd);
|
|
@@ -6695,7 +6695,7 @@ var require_doc = __commonJS({
|
|
|
6695
6695
|
parts.splice(0, 2);
|
|
6696
6696
|
const remainingCmd = [ind, mode, fill(parts)];
|
|
6697
6697
|
const secondContent = parts[0];
|
|
6698
|
-
const firstAndSecondContentFlatCmd = [ind, MODE_FLAT, [content3,
|
|
6698
|
+
const firstAndSecondContentFlatCmd = [ind, MODE_FLAT, [content3, whitespace2, secondContent]];
|
|
6699
6699
|
const firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], rem, options, lineSuffix.length > 0, true);
|
|
6700
6700
|
if (firstAndSecondContentFits) {
|
|
6701
6701
|
cmds.push(remainingCmd, whitespaceFlatCmd, contentFlatCmd);
|
|
@@ -197710,7 +197710,7 @@ var require_prettier = __commonJS({
|
|
|
197710
197710
|
const {
|
|
197711
197711
|
logger = console,
|
|
197712
197712
|
descriptor = defaults_1.defaultDescriptor,
|
|
197713
|
-
unknown:
|
|
197713
|
+
unknown: unknown3 = defaults_1.defaultUnknownHandler,
|
|
197714
197714
|
invalid: invalid2 = defaults_1.defaultInvalidHandler,
|
|
197715
197715
|
deprecated = defaults_1.defaultDeprecatedHandler
|
|
197716
197716
|
} = opts || {};
|
|
@@ -197727,7 +197727,7 @@ var require_prettier = __commonJS({
|
|
|
197727
197727
|
normalizeRedirectResult: utils_1.normalizeRedirectResult,
|
|
197728
197728
|
normalizeValidateResult: utils_1.normalizeValidateResult
|
|
197729
197729
|
};
|
|
197730
|
-
this._unknownHandler =
|
|
197730
|
+
this._unknownHandler = unknown3;
|
|
197731
197731
|
this._invalidHandler = invalid2;
|
|
197732
197732
|
this._deprecatedHandler = deprecated;
|
|
197733
197733
|
this.cleanHistory();
|
|
@@ -197926,7 +197926,7 @@ var require_prettier = __commonJS({
|
|
|
197926
197926
|
colorsModule = null,
|
|
197927
197927
|
levenshteinDistance = null
|
|
197928
197928
|
} = {}) {
|
|
197929
|
-
const
|
|
197929
|
+
const unknown3 = !passThrough ? (key, value, options2) => {
|
|
197930
197930
|
const _options2$schemas = options2.schemas, {
|
|
197931
197931
|
_
|
|
197932
197932
|
} = _options2$schemas, schemas2 = _objectWithoutProperties(_options2$schemas, _excluded2);
|
|
@@ -197946,7 +197946,7 @@ var require_prettier = __commonJS({
|
|
|
197946
197946
|
});
|
|
197947
197947
|
const normalizer = new vnopts.Normalizer(schemas, {
|
|
197948
197948
|
logger,
|
|
197949
|
-
unknown:
|
|
197949
|
+
unknown: unknown3,
|
|
197950
197950
|
descriptor
|
|
197951
197951
|
});
|
|
197952
197952
|
const shouldSuppressDuplicateDeprecationWarnings = logger !== false;
|
|
@@ -210126,7 +210126,7 @@ ${fromBody}`;
|
|
|
210126
210126
|
const regex = makeRegex(pattern, ignoreCase);
|
|
210127
210127
|
return new IgnoreRule(origin, pattern, negative, regex);
|
|
210128
210128
|
};
|
|
210129
|
-
var
|
|
210129
|
+
var throwError = (message, Ctor) => {
|
|
210130
210130
|
throw new Ctor(message);
|
|
210131
210131
|
};
|
|
210132
210132
|
var checkPath = (path, originalPath, doThrow) => {
|
|
@@ -210207,7 +210207,7 @@ ${fromBody}`;
|
|
|
210207
210207
|
}
|
|
210208
210208
|
_test(originalPath, cache, checkUnignored, slices) {
|
|
210209
210209
|
const path = originalPath && checkPath.convert(originalPath);
|
|
210210
|
-
checkPath(path, originalPath, this._allowRelativePaths ? RETURN_FALSE :
|
|
210210
|
+
checkPath(path, originalPath, this._allowRelativePaths ? RETURN_FALSE : throwError);
|
|
210211
210211
|
return this._t(path, cache, checkUnignored, slices);
|
|
210212
210212
|
}
|
|
210213
210213
|
_t(path, cache, checkUnignored, slices) {
|
|
@@ -243985,6 +243985,49 @@ function remarkMdx(options = {}) {
|
|
|
243985
243985
|
}
|
|
243986
243986
|
}
|
|
243987
243987
|
|
|
243988
|
+
// ../../../node_modules/.pnpm/hast-util-whitespace@2.0.0/node_modules/hast-util-whitespace/index.js
|
|
243989
|
+
function whitespace(thing) {
|
|
243990
|
+
var value = thing && typeof thing === "object" && thing.type === "text" ? thing.value || "" : thing;
|
|
243991
|
+
return typeof value === "string" && value.replace(/[ \t\n\f\r]/g, "") === "";
|
|
243992
|
+
}
|
|
243993
|
+
|
|
243994
|
+
// ../../../node_modules/.pnpm/remark-unwrap-images@3.0.1/node_modules/remark-unwrap-images/index.js
|
|
243995
|
+
var unknown2 = 1;
|
|
243996
|
+
var containsImage = 2;
|
|
243997
|
+
var containsOther = 3;
|
|
243998
|
+
function remarkUnwrapImages() {
|
|
243999
|
+
return (tree) => {
|
|
244000
|
+
visit(tree, "paragraph", (node, index2, parent) => {
|
|
244001
|
+
if (parent && typeof index2 === "number" && applicable(node) === containsImage) {
|
|
244002
|
+
parent.children.splice(index2, 1, ...node.children);
|
|
244003
|
+
return [SKIP, index2];
|
|
244004
|
+
}
|
|
244005
|
+
});
|
|
244006
|
+
};
|
|
244007
|
+
}
|
|
244008
|
+
function applicable(node, inLink) {
|
|
244009
|
+
let image2 = unknown2;
|
|
244010
|
+
let index2 = -1;
|
|
244011
|
+
while (++index2 < node.children.length) {
|
|
244012
|
+
const child = node.children[index2];
|
|
244013
|
+
if (whitespace(child)) {
|
|
244014
|
+
} else if (child.type === "image" || child.type === "imageReference") {
|
|
244015
|
+
image2 = containsImage;
|
|
244016
|
+
} else if (!inLink && (child.type === "link" || child.type === "linkReference")) {
|
|
244017
|
+
const linkResult = applicable(child, true);
|
|
244018
|
+
if (linkResult === containsOther) {
|
|
244019
|
+
return containsOther;
|
|
244020
|
+
}
|
|
244021
|
+
if (linkResult === containsImage) {
|
|
244022
|
+
image2 = containsImage;
|
|
244023
|
+
}
|
|
244024
|
+
} else {
|
|
244025
|
+
return containsOther;
|
|
244026
|
+
}
|
|
244027
|
+
}
|
|
244028
|
+
return image2;
|
|
244029
|
+
}
|
|
244030
|
+
|
|
243988
244031
|
// ../../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js
|
|
243989
244032
|
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
243990
244033
|
var freeGlobal_default = freeGlobal;
|
|
@@ -244164,7 +244207,7 @@ var extractAttribute = (attribute, field, imageCallback) => {
|
|
|
244164
244207
|
case "object":
|
|
244165
244208
|
return extractObject(extractExpression(attribute), field);
|
|
244166
244209
|
case "rich-text":
|
|
244167
|
-
const JSXString =
|
|
244210
|
+
const JSXString = extractRaw(attribute);
|
|
244168
244211
|
if (JSXString) {
|
|
244169
244212
|
return parseMDX(JSXString, field, imageCallback);
|
|
244170
244213
|
} else {
|
|
@@ -244217,22 +244260,6 @@ var getField = (objectField, name) => {
|
|
|
244217
244260
|
return objectField.fields.find((f) => f.name === name);
|
|
244218
244261
|
}
|
|
244219
244262
|
};
|
|
244220
|
-
var extractJSXFragment = (attribute, baseAttribute, field) => {
|
|
244221
|
-
if (field.list) {
|
|
244222
|
-
} else {
|
|
244223
|
-
if (attribute.expression.type === "JSXFragment") {
|
|
244224
|
-
assertHasType(attribute.expression);
|
|
244225
|
-
if (attribute.expression.children[0]) {
|
|
244226
|
-
const firstChild = attribute.expression.children[0];
|
|
244227
|
-
if (attribute.expression.children[0].type === "JSXText") {
|
|
244228
|
-
const child = firstChild;
|
|
244229
|
-
return child.value.trim();
|
|
244230
|
-
}
|
|
244231
|
-
}
|
|
244232
|
-
}
|
|
244233
|
-
}
|
|
244234
|
-
throwError(field);
|
|
244235
|
-
};
|
|
244236
244263
|
var extractKeyValue = (property, parentField) => {
|
|
244237
244264
|
assertType(property.key, "Identifier");
|
|
244238
244265
|
const key = property.key.name;
|
|
@@ -244281,6 +244308,13 @@ var extractExpression = (attribute) => {
|
|
|
244281
244308
|
assertType(attribute.value, "mdxJsxAttributeValueExpression");
|
|
244282
244309
|
return extractStatement(attribute.value);
|
|
244283
244310
|
};
|
|
244311
|
+
var extractRaw = (attribute) => {
|
|
244312
|
+
assertType(attribute, "mdxJsxAttribute");
|
|
244313
|
+
assertHasType(attribute.value);
|
|
244314
|
+
assertType(attribute.value, "mdxJsxAttributeValueExpression");
|
|
244315
|
+
const rawValue = attribute.value.value;
|
|
244316
|
+
return trimFragments(rawValue);
|
|
244317
|
+
};
|
|
244284
244318
|
function assertType(val, type) {
|
|
244285
244319
|
if (val.type !== type) {
|
|
244286
244320
|
throw new Error(`Expected type to be ${type} but received ${val.type}. ${MDX_PARSE_ERROR_MSG}`);
|
|
@@ -244294,8 +244328,27 @@ function assertHasType(val) {
|
|
|
244294
244328
|
}
|
|
244295
244329
|
throw new Error(`Expect value to be an object with property "type"`);
|
|
244296
244330
|
}
|
|
244297
|
-
var
|
|
244298
|
-
|
|
244331
|
+
var trimFragments = (string3) => {
|
|
244332
|
+
const rawArr = string3.split("\n");
|
|
244333
|
+
let openingFragmentIndex = null;
|
|
244334
|
+
let closingFragmentIndex = null;
|
|
244335
|
+
rawArr.forEach((item, index2) => {
|
|
244336
|
+
if (item.trim() === "<>") {
|
|
244337
|
+
if (!openingFragmentIndex) {
|
|
244338
|
+
openingFragmentIndex = index2 + 1;
|
|
244339
|
+
}
|
|
244340
|
+
}
|
|
244341
|
+
});
|
|
244342
|
+
rawArr.reverse().forEach((item, index2) => {
|
|
244343
|
+
if (item.trim() === "</>") {
|
|
244344
|
+
const length = rawArr.length - 1;
|
|
244345
|
+
if (!closingFragmentIndex) {
|
|
244346
|
+
closingFragmentIndex = length - index2;
|
|
244347
|
+
}
|
|
244348
|
+
}
|
|
244349
|
+
});
|
|
244350
|
+
const value = rawArr.reverse().slice(openingFragmentIndex || 0, closingFragmentIndex || rawArr.length - 1).join("\n");
|
|
244351
|
+
return value;
|
|
244299
244352
|
};
|
|
244300
244353
|
|
|
244301
244354
|
// src/parse/mdx.ts
|
|
@@ -244386,6 +244439,8 @@ var remarkToSlate = (root3, field, imageCallback) => {
|
|
|
244386
244439
|
return code2(content4);
|
|
244387
244440
|
case "paragraph":
|
|
244388
244441
|
return paragraph2(content4);
|
|
244442
|
+
case "image":
|
|
244443
|
+
return image2(content4);
|
|
244389
244444
|
case "mdxJsxFlowElement":
|
|
244390
244445
|
return mdxJsxElement(content4, field, imageCallback);
|
|
244391
244446
|
case "thematicBreak":
|
|
@@ -244690,6 +244745,7 @@ var markdownToAst = (value, field) => {
|
|
|
244690
244745
|
if (!tree) {
|
|
244691
244746
|
throw new Error("Error parsing markdown");
|
|
244692
244747
|
}
|
|
244748
|
+
remarkUnwrapImages({})(tree);
|
|
244693
244749
|
return tree;
|
|
244694
244750
|
} catch (e) {
|
|
244695
244751
|
throw new RichTextParseError(e, e.position);
|
package/dist/parse/acorn.d.ts
CHANGED
|
@@ -18,3 +18,4 @@ limitations under the License.
|
|
|
18
18
|
import type { MdxJsxAttribute, MdxJsxExpressionAttribute } from 'mdast-util-mdx-jsx';
|
|
19
19
|
import type { TinaFieldBase } from '@tinacms/schema-tools';
|
|
20
20
|
export declare const extractAttributes: (attributes: (MdxJsxAttribute | MdxJsxExpressionAttribute)[], fields: TinaFieldBase[], imageCallback: (image: string) => string) => Record<string, unknown>;
|
|
21
|
+
export declare const trimFragments: (string: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/mdx",
|
|
3
|
-
"version": "0.61.
|
|
3
|
+
"version": "0.61.17",
|
|
4
4
|
"typings": "dist/index.d.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
]
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@tinacms/schema-tools": "0.2.
|
|
22
|
+
"@tinacms/schema-tools": "0.2.2",
|
|
23
23
|
"acorn": "^8.7.1",
|
|
24
24
|
"lodash-es": "^4.17.21",
|
|
25
25
|
"mdast-util-mdx-jsx": "^2.0.1",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"prettier": "^2.7.1",
|
|
28
28
|
"remark": "^14.0.2",
|
|
29
29
|
"remark-mdx": "^2.1.2",
|
|
30
|
+
"remark-unwrap-images": "^3.0.1",
|
|
30
31
|
"unist-util-visit": "^4.1.0",
|
|
31
32
|
"vfile": "^4.2.0"
|
|
32
33
|
},
|