@uiw/react-md-editor 4.0.0 → 4.0.2

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/mdeditor.js CHANGED
@@ -266,7 +266,7 @@ var TYPE_DECLARATION = 'declaration';
266
266
  * @throws {TypeError}
267
267
  * @throws {Error}
268
268
  */
269
- module.exports = function(style, options) {
269
+ module.exports = function (style, options) {
270
270
  if (typeof style !== 'string') {
271
271
  throw new TypeError('First argument must be a string');
272
272
  }
@@ -300,7 +300,7 @@ module.exports = function(style, options) {
300
300
  */
301
301
  function position() {
302
302
  var start = { line: lineno, column: column };
303
- return function(node) {
303
+ return function (node) {
304
304
  node.position = new Position(start);
305
305
  whitespace();
306
306
  return node;
@@ -573,53 +573,54 @@ if (true) {
573
573
 
574
574
  /***/ }),
575
575
 
576
- /***/ 862:
577
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
576
+ /***/ 209:
577
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
578
578
 
579
- var parse = __webpack_require__(812);
579
+ "use strict";
580
580
 
581
+ var __importDefault = (this && this.__importDefault) || function (mod) {
582
+ return (mod && mod.__esModule) ? mod : { "default": mod };
583
+ };
584
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
585
+ var inline_style_parser_1 = __importDefault(__webpack_require__(812));
581
586
  /**
582
587
  * Parses inline style to object.
583
588
  *
584
- * @example
585
- * // returns { 'line-height': '42' }
586
- * StyleToObject('line-height: 42;');
589
+ * @param style - Inline style.
590
+ * @param iterator - Iterator.
591
+ * @returns - Style object or null.
587
592
  *
588
- * @param {String} style - The inline style.
589
- * @param {Function} [iterator] - The iterator function.
590
- * @return {null|Object}
593
+ * @example Parsing inline style to object:
594
+ *
595
+ * ```js
596
+ * import parse from 'style-to-object';
597
+ * parse('line-height: 42;'); // { 'line-height': '42' }
598
+ * ```
591
599
  */
592
600
  function StyleToObject(style, iterator) {
593
- var output = null;
594
- if (!style || typeof style !== 'string') {
595
- return output;
596
- }
597
-
598
- var declaration;
599
- var declarations = parse(style);
600
- var hasIterator = typeof iterator === 'function';
601
- var property;
602
- var value;
603
-
604
- for (var i = 0, len = declarations.length; i < len; i++) {
605
- declaration = declarations[i];
606
- property = declaration.property;
607
- value = declaration.value;
608
-
609
- if (hasIterator) {
610
- iterator(property, value, declaration);
611
- } else if (value) {
612
- output || (output = {});
613
- output[property] = value;
614
- }
615
- }
616
-
617
- return output;
601
+ var styleObject = null;
602
+ if (!style || typeof style !== 'string') {
603
+ return styleObject;
604
+ }
605
+ var declarations = (0, inline_style_parser_1.default)(style);
606
+ var hasIterator = typeof iterator === 'function';
607
+ declarations.forEach(function (declaration) {
608
+ if (declaration.type !== 'declaration') {
609
+ return;
610
+ }
611
+ var property = declaration.property, value = declaration.value;
612
+ if (hasIterator) {
613
+ iterator(property, value, declaration);
614
+ }
615
+ else if (value) {
616
+ styleObject = styleObject || {};
617
+ styleObject[property] = value;
618
+ }
619
+ });
620
+ return styleObject;
618
621
  }
619
-
620
- module.exports = StyleToObject;
621
- module.exports["default"] = StyleToObject; // ESM support
622
-
622
+ exports["default"] = StyleToObject;
623
+ //# sourceMappingURL=index.js.map
623
624
 
624
625
  /***/ }),
625
626
 
@@ -850,27 +851,27 @@ function _typeof(o) {
850
851
  }
851
852
  ;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
852
853
 
853
- function _toPrimitive(input, hint) {
854
- if (_typeof(input) !== "object" || input === null) return input;
855
- var prim = input[Symbol.toPrimitive];
856
- if (prim !== undefined) {
857
- var res = prim.call(input, hint || "default");
858
- if (_typeof(res) !== "object") return res;
854
+ function toPrimitive(t, r) {
855
+ if ("object" != _typeof(t) || !t) return t;
856
+ var e = t[Symbol.toPrimitive];
857
+ if (void 0 !== e) {
858
+ var i = e.call(t, r || "default");
859
+ if ("object" != _typeof(i)) return i;
859
860
  throw new TypeError("@@toPrimitive must return a primitive value.");
860
861
  }
861
- return (hint === "string" ? String : Number)(input);
862
+ return ("string" === r ? String : Number)(t);
862
863
  }
863
864
  ;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
864
865
 
865
866
 
866
- function _toPropertyKey(arg) {
867
- var key = _toPrimitive(arg, "string");
868
- return _typeof(key) === "symbol" ? key : String(key);
867
+ function toPropertyKey(t) {
868
+ var i = toPrimitive(t, "string");
869
+ return "symbol" == _typeof(i) ? i : String(i);
869
870
  }
870
871
  ;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/defineProperty.js
871
872
 
872
873
  function _defineProperty(obj, key, value) {
873
- key = _toPropertyKey(key);
874
+ key = toPropertyKey(key);
874
875
  if (key in obj) {
875
876
  Object.defineProperty(obj, key, {
876
877
  value: value,
@@ -1101,6 +1102,69 @@ function stringify(values, options) {
1101
1102
  .trim()
1102
1103
  }
1103
1104
 
1105
+ ;// CONCATENATED MODULE: ../node_modules/estree-util-is-identifier-name/lib/index.js
1106
+ /**
1107
+ * @typedef Options
1108
+ * Configuration.
1109
+ * @property {boolean | null | undefined} [jsx=false]
1110
+ * Support JSX identifiers (default: `false`).
1111
+ */
1112
+
1113
+ const startRe = /[$_\p{ID_Start}]/u
1114
+ const contRe = /[$_\u{200C}\u{200D}\p{ID_Continue}]/u
1115
+ const contReJsx = /[-$_\u{200C}\u{200D}\p{ID_Continue}]/u
1116
+ const nameRe = /^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u
1117
+ const nameReJsx = /^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u
1118
+
1119
+ /** @type {Options} */
1120
+ const emptyOptions = {}
1121
+
1122
+ /**
1123
+ * Checks if the given code point can start an identifier.
1124
+ *
1125
+ * @param {number | undefined} code
1126
+ * Code point to check.
1127
+ * @returns {boolean}
1128
+ * Whether `code` can start an identifier.
1129
+ */
1130
+ // Note: `undefined` is supported so you can pass the result from `''.codePointAt`.
1131
+ function start(code) {
1132
+ return code ? startRe.test(String.fromCodePoint(code)) : false
1133
+ }
1134
+
1135
+ /**
1136
+ * Checks if the given code point can continue an identifier.
1137
+ *
1138
+ * @param {number | undefined} code
1139
+ * Code point to check.
1140
+ * @param {Options | null | undefined} [options]
1141
+ * Configuration (optional).
1142
+ * @returns {boolean}
1143
+ * Whether `code` can continue an identifier.
1144
+ */
1145
+ // Note: `undefined` is supported so you can pass the result from `''.codePointAt`.
1146
+ function cont(code, options) {
1147
+ const settings = options || emptyOptions
1148
+ const re = settings.jsx ? contReJsx : contRe
1149
+ return code ? re.test(String.fromCodePoint(code)) : false
1150
+ }
1151
+
1152
+ /**
1153
+ * Checks if the given value is a valid identifier name.
1154
+ *
1155
+ * @param {string} name
1156
+ * Identifier to check.
1157
+ * @param {Options | null | undefined} [options]
1158
+ * Configuration (optional).
1159
+ * @returns {boolean}
1160
+ * Whether `name` can be an identifier.
1161
+ */
1162
+ function lib_name(name, options) {
1163
+ const settings = options || emptyOptions
1164
+ const re = settings.jsx ? nameReJsx : nameRe
1165
+ return re.test(name)
1166
+ }
1167
+
1104
1168
  ;// CONCATENATED MODULE: ../node_modules/hast-util-whitespace/lib/index.js
1105
1169
  /**
1106
1170
  * @typedef {import('hast').Nodes} Nodes
@@ -2500,12 +2564,13 @@ function space_separated_tokens_stringify(values) {
2500
2564
  return values.join(' ').trim()
2501
2565
  }
2502
2566
 
2503
- // EXTERNAL MODULE: ../node_modules/style-to-object/index.js
2504
- var style_to_object = __webpack_require__(862);
2505
- ;// CONCATENATED MODULE: ../node_modules/style-to-object/index.mjs
2567
+ // EXTERNAL MODULE: ../node_modules/style-to-object/cjs/index.js
2568
+ var cjs = __webpack_require__(209);
2569
+ ;// CONCATENATED MODULE: ../node_modules/style-to-object/esm/index.mjs
2506
2570
 
2507
2571
 
2508
- /* harmony default export */ const node_modules_style_to_object = (style_to_object);
2572
+ // ensure compatibility with rollup umd build
2573
+ /* harmony default export */ const esm = (cjs["default"] || cjs);
2509
2574
 
2510
2575
  ;// CONCATENATED MODULE: ../node_modules/unist-util-position/lib/index.js
2511
2576
  /**
@@ -3011,13 +3076,36 @@ VFileMessage.prototype.ruleId = undefined
3011
3076
  VFileMessage.prototype.source = undefined
3012
3077
 
3013
3078
  ;// CONCATENATED MODULE: ../node_modules/hast-util-to-jsx-runtime/lib/index.js
3079
+ // Register MDX nodes in mdast:
3080
+ /// <reference types="mdast-util-mdx-expression" />
3081
+ /// <reference types="mdast-util-mdx-jsx" />
3082
+ /// <reference types="mdast-util-mdxjs-esm" />
3083
+
3014
3084
  /**
3085
+ * @typedef {import('estree').Identifier} Identifier
3086
+ * @typedef {import('estree').Literal} Literal
3087
+ * @typedef {import('estree').MemberExpression} MemberExpression
3088
+ * @typedef {import('estree').Expression} Expression
3089
+ * @typedef {import('estree').Program} Program
3090
+ *
3015
3091
  * @typedef {import('hast').Element} Element
3016
3092
  * @typedef {import('hast').Nodes} Nodes
3017
3093
  * @typedef {import('hast').Parents} Parents
3094
+ * @typedef {import('hast').Root} Root
3095
+ * @typedef {import('hast').Text} Text
3096
+ *
3097
+ * @typedef {import('mdast-util-mdx-expression').MdxFlowExpressionHast} MdxFlowExpression
3098
+ * @typedef {import('mdast-util-mdx-expression').MdxTextExpressionHast} MdxTextExpression
3099
+ *
3100
+ * @typedef {import('mdast-util-mdx-jsx').MdxJsxFlowElementHast} MdxJsxFlowElement
3101
+ * @typedef {import('mdast-util-mdx-jsx').MdxJsxTextElementHast} MdxJsxTextElement
3102
+ *
3103
+ * @typedef {import('mdast-util-mdxjs-esm').MdxjsEsmHast} MdxjsEsm
3018
3104
  *
3019
3105
  * @typedef {import('property-information').Schema} Schema
3020
3106
  *
3107
+ * @typedef {import('unist').Position} Position
3108
+ *
3021
3109
  * @typedef {import('./components.js').Components} Components
3022
3110
  */
3023
3111
 
@@ -3038,12 +3126,40 @@ VFileMessage.prototype.source = undefined
3038
3126
  * @returns {JSX.Element}
3039
3127
  * Result.
3040
3128
  *
3129
+ * @callback CreateEvaluater
3130
+ * Create an evaluator that turns ESTree ASTs from embedded MDX into values.
3131
+ * @returns {Evaluater}
3132
+ * Evaluater.
3133
+ *
3041
3134
  * @typedef {'html' | 'react'} ElementAttributeNameCase
3042
3135
  * Casing to use for attribute names.
3043
3136
  *
3044
3137
  * HTML casing is for example `class`, `stroke-linecap`, `xml:lang`.
3045
3138
  * React casing is for example `className`, `strokeLinecap`, `xmlLang`.
3046
3139
  *
3140
+ * @callback EvaluateExpression
3141
+ * Turn an MDX expression into a value.
3142
+ * @param {Expression} expression
3143
+ * ESTree expression.
3144
+ * @returns {unknown}
3145
+ * Result of expression.
3146
+ *
3147
+ * @callback EvaluateProgram
3148
+ * Turn an MDX program (export/import statements) into a value.
3149
+ * @param {Program} expression
3150
+ * ESTree program.
3151
+ * @returns {unknown}
3152
+ * Result of program;
3153
+ * should likely be `undefined` as ESM changes the scope but doesn’t yield
3154
+ * something.
3155
+ *
3156
+ * @typedef Evaluater
3157
+ * Evaluator that turns ESTree ASTs from embedded MDX into values.
3158
+ * @property {EvaluateExpression} evaluateExpression
3159
+ * Evaluate an expression.
3160
+ * @property {EvaluateProgram} evaluateProgram
3161
+ * Evaluate a program.
3162
+ *
3047
3163
  * @typedef {[string, Value]} Field
3048
3164
  * Property field.
3049
3165
  *
@@ -3059,7 +3175,7 @@ VFileMessage.prototype.source = undefined
3059
3175
  * @param {string | undefined} [key]
3060
3176
  * Dynamicly generated key to use.
3061
3177
  * @returns {JSX.Element}
3062
- * An element from your framework.
3178
+ * Element from your framework.
3063
3179
  *
3064
3180
  * @callback JsxDev
3065
3181
  * Create a development element.
@@ -3077,15 +3193,17 @@ VFileMessage.prototype.source = undefined
3077
3193
  * @param {undefined} self
3078
3194
  * Nothing (this is used by frameworks that have components, we don’t).
3079
3195
  * @returns {JSX.Element}
3080
- * An element from your framework.
3196
+ * Element from your framework.
3081
3197
  *
3082
- * @typedef {{children?: Array<Child> | Child, node?: Element | undefined, [prop: string]: Array<Child> | Child | Element | Value | undefined}} Props
3198
+ * @typedef {{children?: Array<Child> | Child, node?: Element | MdxJsxFlowElement | MdxJsxTextElement | undefined, [prop: string]: Array<Child> | Child | Element | MdxJsxFlowElement | MdxJsxTextElement | Value | undefined}} Props
3083
3199
  * Properties and children.
3084
3200
  *
3085
3201
  * @typedef RegularFields
3086
3202
  * Configuration.
3087
3203
  * @property {Partial<Components> | null | undefined} [components]
3088
3204
  * Components to use (optional).
3205
+ * @property {CreateEvaluater | null | undefined} [createEvaluater]
3206
+ * Create an evaluator that turns ESTree ASTs into values (optional).
3089
3207
  * @property {ElementAttributeNameCase | null | undefined} [elementAttributeNameCase='react']
3090
3208
  * Specify casing to use for attribute names (default: `'react'`).
3091
3209
  * @property {string | null | undefined} [filePath]
@@ -3184,6 +3302,8 @@ VFileMessage.prototype.source = undefined
3184
3302
  * Create something in development or production.
3185
3303
  * @property {ElementAttributeNameCase} elementAttributeNameCase
3186
3304
  * Casing to use for attribute names.
3305
+ * @property {Evaluater | undefined} evaluater
3306
+ * Evaluator that turns ESTree ASTs into values.
3187
3307
  * @property {string | undefined} filePath
3188
3308
  * File path.
3189
3309
  * @property {boolean} ignoreInvalidStyle
@@ -3231,6 +3351,8 @@ VFileMessage.prototype.source = undefined
3231
3351
 
3232
3352
 
3233
3353
 
3354
+
3355
+
3234
3356
  const lib_own = {}.hasOwnProperty
3235
3357
 
3236
3358
  /** @type {Map<string, number>} */
@@ -3254,6 +3376,8 @@ const tableElements = new Set(['table', 'tbody', 'thead', 'tfoot', 'tr'])
3254
3376
 
3255
3377
  const tableCellElement = new Set(['td', 'th'])
3256
3378
 
3379
+ const docs = 'https://github.com/syntax-tree/hast-util-to-jsx-runtime'
3380
+
3257
3381
  /**
3258
3382
  * Transform a hast tree to preact, react, solid, svelte, vue, etc.,
3259
3383
  * with an automatic JSX runtime.
@@ -3302,6 +3426,7 @@ function toJsxRuntime(tree, options) {
3302
3426
  components: options.components || {},
3303
3427
  create,
3304
3428
  elementAttributeNameCase: options.elementAttributeNameCase || 'react',
3429
+ evaluater: options.createEvaluater ? options.createEvaluater() : undefined,
3305
3430
  filePath,
3306
3431
  ignoreInvalidStyle: options.ignoreInvalidStyle || false,
3307
3432
  passKeys: options.passKeys !== false,
@@ -3340,67 +3465,233 @@ function toJsxRuntime(tree, options) {
3340
3465
  * Child, optional.
3341
3466
  */
3342
3467
  function one(state, node, key) {
3343
- if (node.type === 'element' || node.type === 'root') {
3344
- const parentSchema = state.schema
3345
- let schema = parentSchema
3468
+ if (node.type === 'element') {
3469
+ return lib_element(state, node, key)
3470
+ }
3346
3471
 
3347
- if (
3348
- node.type === 'element' &&
3349
- node.tagName.toLowerCase() === 'svg' &&
3350
- parentSchema.space === 'html'
3351
- ) {
3352
- schema = property_information_svg
3353
- state.schema = schema
3354
- }
3472
+ if (node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression') {
3473
+ return mdxExpression(state, node)
3474
+ }
3355
3475
 
3356
- state.ancestors.push(node)
3476
+ if (node.type === 'mdxJsxFlowElement' || node.type === 'mdxJsxTextElement') {
3477
+ return mdxJsxElement(state, node, key)
3478
+ }
3357
3479
 
3358
- let children = createChildren(state, node)
3359
- const props = createProperties(state, state.ancestors)
3360
- let type = state.Fragment
3480
+ if (node.type === 'mdxjsEsm') {
3481
+ return mdxEsm(state, node)
3482
+ }
3361
3483
 
3362
- state.ancestors.pop()
3484
+ if (node.type === 'root') {
3485
+ return root(state, node, key)
3486
+ }
3363
3487
 
3364
- if (node.type === 'element') {
3365
- if (children && tableElements.has(node.tagName)) {
3366
- children = children.filter(function (child) {
3367
- return typeof child === 'string' ? !whitespace(child) : true
3368
- })
3369
- }
3488
+ if (node.type === 'text') {
3489
+ return lib_text(state, node)
3490
+ }
3491
+ }
3370
3492
 
3371
- if (lib_own.call(state.components, node.tagName)) {
3372
- const key = /** @type {keyof JSX.IntrinsicElements} */ (node.tagName)
3373
- type = state.components[key]
3493
+ /**
3494
+ * Handle element.
3495
+ *
3496
+ * @param {State} state
3497
+ * Info passed around.
3498
+ * @param {Element} node
3499
+ * Current node.
3500
+ * @param {string | undefined} key
3501
+ * Key.
3502
+ * @returns {Child | undefined}
3503
+ * Child, optional.
3504
+ */
3505
+ function lib_element(state, node, key) {
3506
+ const parentSchema = state.schema
3507
+ let schema = parentSchema
3374
3508
 
3375
- // If this is swapped out for a component:
3376
- if (
3377
- typeof type !== 'string' &&
3378
- type !== state.Fragment &&
3379
- state.passNode
3380
- ) {
3381
- props.node = node
3382
- }
3383
- } else {
3384
- type = node.tagName
3385
- }
3386
- }
3509
+ if (node.tagName.toLowerCase() === 'svg' && parentSchema.space === 'html') {
3510
+ schema = property_information_svg
3511
+ state.schema = schema
3512
+ }
3387
3513
 
3388
- if (children.length > 0) {
3389
- const value = children.length > 1 ? children : children[0]
3514
+ state.ancestors.push(node)
3390
3515
 
3391
- if (value) {
3392
- props.children = value
3393
- }
3394
- }
3516
+ const type = findComponentFromName(state, node.tagName, false)
3517
+ const props = createElementProps(state, node)
3518
+ let children = createChildren(state, node)
3519
+
3520
+ if (tableElements.has(node.tagName)) {
3521
+ children = children.filter(function (child) {
3522
+ return typeof child === 'string' ? !whitespace(child) : true
3523
+ })
3524
+ }
3525
+
3526
+ addNode(state, props, type, node)
3527
+ addChildren(props, children)
3395
3528
 
3396
- // Restore parent schema.
3397
- state.schema = parentSchema
3529
+ // Restore.
3530
+ state.ancestors.pop()
3531
+ state.schema = parentSchema
3398
3532
 
3399
- return state.create(node, type, props, key)
3533
+ return state.create(node, type, props, key)
3534
+ }
3535
+
3536
+ /**
3537
+ * Handle MDX expression.
3538
+ *
3539
+ * @param {State} state
3540
+ * Info passed around.
3541
+ * @param {MdxFlowExpression | MdxTextExpression} node
3542
+ * Current node.
3543
+ * @returns {Child | undefined}
3544
+ * Child, optional.
3545
+ */
3546
+ function mdxExpression(state, node) {
3547
+ if (node.data && node.data.estree && state.evaluater) {
3548
+ const program = node.data.estree
3549
+ const expression = program.body[0]
3550
+ ok(expression.type === 'ExpressionStatement')
3551
+
3552
+ // Assume result is a child.
3553
+ return /** @type {Child | undefined} */ (
3554
+ state.evaluater.evaluateExpression(expression.expression)
3555
+ )
3400
3556
  }
3401
3557
 
3402
- if (node.type === 'text') {
3403
- return node.value
3558
+ crashEstree(state, node.position)
3559
+ }
3560
+
3561
+ /**
3562
+ * Handle MDX ESM.
3563
+ *
3564
+ * @param {State} state
3565
+ * Info passed around.
3566
+ * @param {MdxjsEsm} node
3567
+ * Current node.
3568
+ * @returns {Child | undefined}
3569
+ * Child, optional.
3570
+ */
3571
+ function mdxEsm(state, node) {
3572
+ if (node.data && node.data.estree && state.evaluater) {
3573
+ // Assume result is a child.
3574
+ return /** @type {Child | undefined} */ (
3575
+ state.evaluater.evaluateProgram(node.data.estree)
3576
+ )
3577
+ }
3578
+
3579
+ crashEstree(state, node.position)
3580
+ }
3581
+
3582
+ /**
3583
+ * Handle MDX JSX.
3584
+ *
3585
+ * @param {State} state
3586
+ * Info passed around.
3587
+ * @param {MdxJsxFlowElement | MdxJsxTextElement} node
3588
+ * Current node.
3589
+ * @param {string | undefined} key
3590
+ * Key.
3591
+ * @returns {Child | undefined}
3592
+ * Child, optional.
3593
+ */
3594
+ function mdxJsxElement(state, node, key) {
3595
+ const parentSchema = state.schema
3596
+ let schema = parentSchema
3597
+
3598
+ if (node.name === 'svg' && parentSchema.space === 'html') {
3599
+ schema = property_information_svg
3600
+ state.schema = schema
3601
+ }
3602
+
3603
+ state.ancestors.push(node)
3604
+
3605
+ const type =
3606
+ node.name === null
3607
+ ? state.Fragment
3608
+ : findComponentFromName(state, node.name, true)
3609
+ const props = createJsxElementProps(state, node)
3610
+ const children = createChildren(state, node)
3611
+
3612
+ addNode(state, props, type, node)
3613
+ addChildren(props, children)
3614
+
3615
+ // Restore.
3616
+ state.ancestors.pop()
3617
+ state.schema = parentSchema
3618
+
3619
+ return state.create(node, type, props, key)
3620
+ }
3621
+
3622
+ /**
3623
+ * Handle root.
3624
+ *
3625
+ * @param {State} state
3626
+ * Info passed around.
3627
+ * @param {Root} node
3628
+ * Current node.
3629
+ * @param {string | undefined} key
3630
+ * Key.
3631
+ * @returns {Child | undefined}
3632
+ * Child, optional.
3633
+ */
3634
+ function root(state, node, key) {
3635
+ /** @type {Props} */
3636
+ const props = {}
3637
+
3638
+ addChildren(props, createChildren(state, node))
3639
+
3640
+ return state.create(node, state.Fragment, props, key)
3641
+ }
3642
+
3643
+ /**
3644
+ * Handle text.
3645
+ *
3646
+ * @param {State} _
3647
+ * Info passed around.
3648
+ * @param {Text} node
3649
+ * Current node.
3650
+ * @returns {Child | undefined}
3651
+ * Child, optional.
3652
+ */
3653
+ function lib_text(_, node) {
3654
+ return node.value
3655
+ }
3656
+
3657
+ /**
3658
+ * Add `node` to props.
3659
+ *
3660
+ * @param {State} state
3661
+ * Info passed around.
3662
+ * @param {Props} props
3663
+ * Props.
3664
+ * @param {unknown} type
3665
+ * Type.
3666
+ * @param {Element | MdxJsxFlowElement | MdxJsxTextElement} node
3667
+ * Node.
3668
+ * @returns {undefined}
3669
+ * Nothing.
3670
+ */
3671
+ function addNode(state, props, type, node) {
3672
+ // If this is swapped out for a component:
3673
+ if (typeof type !== 'string' && type !== state.Fragment && state.passNode) {
3674
+ props.node = node
3675
+ }
3676
+ }
3677
+
3678
+ /**
3679
+ * Add children to props.
3680
+ *
3681
+ * @param {Props} props
3682
+ * Props.
3683
+ * @param {Array<Child>} children
3684
+ * Children.
3685
+ * @returns {undefined}
3686
+ * Nothing.
3687
+ */
3688
+ function addChildren(props, children) {
3689
+ if (children.length > 0) {
3690
+ const value = children.length > 1 ? children : children[0]
3691
+
3692
+ if (value) {
3693
+ props.children = value
3694
+ }
3404
3695
  }
3405
3696
  }
3406
3697
 
@@ -3456,108 +3747,169 @@ function developmentCreate(filePath, jsxDEV) {
3456
3747
  }
3457
3748
 
3458
3749
  /**
3459
- * Create children.
3750
+ * Create props from an element.
3460
3751
  *
3461
3752
  * @param {State} state
3462
3753
  * Info passed around.
3463
- * @param {Parents} node
3754
+ * @param {Element} node
3464
3755
  * Current element.
3465
- * @returns {Array<Child>}
3466
- * Children.
3756
+ * @returns {Props}
3757
+ * Props.
3467
3758
  */
3468
- function createChildren(state, node) {
3469
- /** @type {Array<Child>} */
3470
- const children = []
3471
- let index = -1
3472
- /** @type {Map<string, number>} */
3473
- // Note: test this when Solid doesn’t want to merge my upcoming PR.
3474
- /* c8 ignore next */
3475
- const countsByTagName = state.passKeys ? new Map() : emptyMap
3759
+ function createElementProps(state, node) {
3760
+ /** @type {Props} */
3761
+ const props = {}
3762
+ /** @type {string | undefined} */
3763
+ let alignValue
3764
+ /** @type {string} */
3765
+ let prop
3476
3766
 
3477
- while (++index < node.children.length) {
3478
- const child = node.children[index]
3479
- /** @type {string | undefined} */
3480
- let key
3767
+ for (prop in node.properties) {
3768
+ if (prop !== 'children' && lib_own.call(node.properties, prop)) {
3769
+ const result = createProperty(state, prop, node.properties[prop])
3770
+
3771
+ if (result) {
3772
+ const [key, value] = result
3481
3773
 
3482
- if (state.passKeys && child.type === 'element') {
3483
- const count = countsByTagName.get(child.tagName) || 0
3484
- key = child.tagName + '-' + count
3485
- countsByTagName.set(child.tagName, count + 1)
3774
+ if (
3775
+ state.tableCellAlignToStyle &&
3776
+ key === 'align' &&
3777
+ typeof value === 'string' &&
3778
+ tableCellElement.has(node.tagName)
3779
+ ) {
3780
+ alignValue = value
3781
+ } else {
3782
+ props[key] = value
3783
+ }
3784
+ }
3486
3785
  }
3786
+ }
3487
3787
 
3488
- const result = one(state, child, key)
3489
- if (result !== undefined) children.push(result)
3788
+ if (alignValue) {
3789
+ // Assume style is an object.
3790
+ const style = /** @type {Style} */ (props.style || (props.style = {}))
3791
+ style[state.stylePropertyNameCase === 'css' ? 'text-align' : 'textAlign'] =
3792
+ alignValue
3490
3793
  }
3491
3794
 
3492
- return children
3795
+ return props
3493
3796
  }
3494
3797
 
3495
3798
  /**
3496
- * Handle properties.
3799
+ * Create props from a JSX element.
3497
3800
  *
3498
3801
  * @param {State} state
3499
3802
  * Info passed around.
3500
- * @param {Array<Parents>} ancestors
3501
- * Stack of parents.
3803
+ * @param {MdxJsxFlowElement | MdxJsxTextElement} node
3804
+ * Current JSX element.
3502
3805
  * @returns {Props}
3503
- * Props for runtime.
3806
+ * Props.
3504
3807
  */
3505
- function createProperties(state, ancestors) {
3506
- const node = ancestors[ancestors.length - 1]
3808
+ function createJsxElementProps(state, node) {
3507
3809
  /** @type {Props} */
3508
3810
  const props = {}
3509
- /** @type {string} */
3510
- let prop
3511
-
3512
- if ('properties' in node && node.properties) {
3513
- /** @type {string | undefined} */
3514
- let alignValue
3515
3811
 
3516
- for (prop in node.properties) {
3517
- if (prop !== 'children' && lib_own.call(node.properties, prop)) {
3518
- const result = createProperty(
3519
- state,
3520
- ancestors,
3521
- prop,
3522
- node.properties[prop]
3812
+ for (const attribute of node.attributes) {
3813
+ if (attribute.type === 'mdxJsxExpressionAttribute') {
3814
+ if (attribute.data && attribute.data.estree && state.evaluater) {
3815
+ const program = attribute.data.estree
3816
+ const expression = program.body[0]
3817
+ ok(expression.type === 'ExpressionStatement')
3818
+ const objectExpression = expression.expression
3819
+ ok(objectExpression.type === 'ObjectExpression')
3820
+ const property = objectExpression.properties[0]
3821
+ ok(property.type === 'SpreadElement')
3822
+
3823
+ Object.assign(
3824
+ props,
3825
+ state.evaluater.evaluateExpression(property.argument)
3523
3826
  )
3827
+ } else {
3828
+ crashEstree(state, node.position)
3829
+ }
3830
+ } else {
3831
+ // For JSX, the author is responsible of passing in the correct values.
3832
+ const name = attribute.name
3833
+ /** @type {unknown} */
3834
+ let value
3524
3835
 
3525
- if (result) {
3526
- const [key, value] = result
3527
-
3528
- if (
3529
- state.tableCellAlignToStyle &&
3530
- key === 'align' &&
3531
- typeof value === 'string' &&
3532
- tableCellElement.has(node.tagName)
3533
- ) {
3534
- alignValue = value
3535
- } else {
3536
- props[key] = value
3537
- }
3836
+ if (attribute.value && typeof attribute.value === 'object') {
3837
+ if (
3838
+ attribute.value.data &&
3839
+ attribute.value.data.estree &&
3840
+ state.evaluater
3841
+ ) {
3842
+ const program = attribute.value.data.estree
3843
+ const expression = program.body[0]
3844
+ ok(expression.type === 'ExpressionStatement')
3845
+ value = state.evaluater.evaluateExpression(expression.expression)
3846
+ } else {
3847
+ crashEstree(state, node.position)
3538
3848
  }
3849
+ } else {
3850
+ value = attribute.value === null ? true : attribute.value
3539
3851
  }
3540
- }
3541
3852
 
3542
- if (alignValue) {
3543
- // Assume style is an object.
3544
- const style = /** @type {Style} */ (props.style || (props.style = {}))
3545
- style[
3546
- state.stylePropertyNameCase === 'css' ? 'text-align' : 'textAlign'
3547
- ] = alignValue
3853
+ // Assume a prop.
3854
+ props[name] = /** @type {Props[keyof Props]} */ (value)
3548
3855
  }
3549
3856
  }
3550
3857
 
3551
3858
  return props
3552
3859
  }
3553
3860
 
3861
+ /**
3862
+ * Create children.
3863
+ *
3864
+ * @param {State} state
3865
+ * Info passed around.
3866
+ * @param {Parents} node
3867
+ * Current element.
3868
+ * @returns {Array<Child>}
3869
+ * Children.
3870
+ */
3871
+ function createChildren(state, node) {
3872
+ /** @type {Array<Child>} */
3873
+ const children = []
3874
+ let index = -1
3875
+ /** @type {Map<string, number>} */
3876
+ // Note: test this when Solid doesn’t want to merge my upcoming PR.
3877
+ /* c8 ignore next */
3878
+ const countsByName = state.passKeys ? new Map() : emptyMap
3879
+
3880
+ while (++index < node.children.length) {
3881
+ const child = node.children[index]
3882
+ /** @type {string | undefined} */
3883
+ let key
3884
+
3885
+ if (state.passKeys) {
3886
+ const name =
3887
+ child.type === 'element'
3888
+ ? child.tagName
3889
+ : child.type === 'mdxJsxFlowElement' ||
3890
+ child.type === 'mdxJsxTextElement'
3891
+ ? child.name
3892
+ : undefined
3893
+
3894
+ if (name) {
3895
+ const count = countsByName.get(name) || 0
3896
+ key = name + '-' + count
3897
+ countsByName.set(name, count + 1)
3898
+ }
3899
+ }
3900
+
3901
+ const result = one(state, child, key)
3902
+ if (result !== undefined) children.push(result)
3903
+ }
3904
+
3905
+ return children
3906
+ }
3907
+
3554
3908
  /**
3555
3909
  * Handle a property.
3556
3910
  *
3557
3911
  * @param {State} state
3558
3912
  * Info passed around.
3559
- * @param {Array<Parents>} ancestors
3560
- * Stack of parents.
3561
3913
  * @param {string} prop
3562
3914
  * Key.
3563
3915
  * @param {Array<number | string> | boolean | number | string | null | undefined} value
@@ -3565,7 +3917,7 @@ function createProperties(state, ancestors) {
3565
3917
  * @returns {Field | undefined}
3566
3918
  * Field for runtime, optional.
3567
3919
  */
3568
- function createProperty(state, ancestors, prop, value) {
3920
+ function createProperty(state, prop, value) {
3569
3921
  const info = find(state.schema, prop)
3570
3922
 
3571
3923
  // Ignore nullish and `NaN` values.
@@ -3586,9 +3938,7 @@ function createProperty(state, ancestors, prop, value) {
3586
3938
  // React only accepts `style` as object.
3587
3939
  if (info.property === 'style') {
3588
3940
  let styleObject =
3589
- typeof value === 'object'
3590
- ? value
3591
- : parseStyle(state, ancestors, String(value))
3941
+ typeof value === 'object' ? value : parseStyle(state, String(value))
3592
3942
 
3593
3943
  if (state.stylePropertyNameCase === 'css') {
3594
3944
  styleObject = transformStylesToCssCasing(styleObject)
@@ -3610,8 +3960,6 @@ function createProperty(state, ancestors, prop, value) {
3610
3960
  *
3611
3961
  * @param {State} state
3612
3962
  * Info passed around.
3613
- * @param {Array<Nodes>} ancestors
3614
- * Stack of nodes.
3615
3963
  * @param {string} value
3616
3964
  * CSS declarations.
3617
3965
  * @returns {Style}
@@ -3619,24 +3967,24 @@ function createProperty(state, ancestors, prop, value) {
3619
3967
  * @throws
3620
3968
  * Throws `VFileMessage` when CSS cannot be parsed.
3621
3969
  */
3622
- function parseStyle(state, ancestors, value) {
3970
+ function parseStyle(state, value) {
3623
3971
  /** @type {Style} */
3624
3972
  const result = {}
3625
3973
 
3626
3974
  try {
3627
- node_modules_style_to_object(value, replacer)
3975
+ // @ts-expect-error: `style-to-object` types are broken.
3976
+ esm(value, replacer)
3628
3977
  } catch (error) {
3629
3978
  if (!state.ignoreInvalidStyle) {
3630
3979
  const cause = /** @type {Error} */ (error)
3631
3980
  const message = new VFileMessage('Cannot parse `style` attribute', {
3632
- ancestors,
3981
+ ancestors: state.ancestors,
3633
3982
  cause,
3634
- source: 'hast-util-to-jsx-runtime',
3635
- ruleId: 'style'
3983
+ ruleId: 'style',
3984
+ source: 'hast-util-to-jsx-runtime'
3636
3985
  })
3637
3986
  message.file = state.filePath || undefined
3638
- message.url =
3639
- 'https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-parse-style-attribute'
3987
+ message.url = docs + '#cannot-parse-style-attribute'
3640
3988
 
3641
3989
  throw message
3642
3990
  }
@@ -3667,6 +4015,92 @@ function parseStyle(state, ancestors, value) {
3667
4015
  }
3668
4016
  }
3669
4017
 
4018
+ /**
4019
+ * Create a JSX name from a string.
4020
+ *
4021
+ * @param {State} state
4022
+ * To do.
4023
+ * @param {string} name
4024
+ * Name.
4025
+ * @param {boolean} allowExpression
4026
+ * Allow member expressions and identifiers.
4027
+ * @returns {unknown}
4028
+ * To do.
4029
+ */
4030
+ function findComponentFromName(state, name, allowExpression) {
4031
+ /** @type {Identifier | Literal | MemberExpression} */
4032
+ let result
4033
+
4034
+ if (!allowExpression) {
4035
+ result = {type: 'Literal', value: name}
4036
+ } else if (name.includes('.')) {
4037
+ const identifiers = name.split('.')
4038
+ let index = -1
4039
+ /** @type {Identifier | Literal | MemberExpression | undefined} */
4040
+ let node
4041
+
4042
+ while (++index < identifiers.length) {
4043
+ /** @type {Identifier | Literal} */
4044
+ const prop = lib_name(identifiers[index])
4045
+ ? {type: 'Identifier', name: identifiers[index]}
4046
+ : {type: 'Literal', value: identifiers[index]}
4047
+ node = node
4048
+ ? {
4049
+ type: 'MemberExpression',
4050
+ object: node,
4051
+ property: prop,
4052
+ computed: Boolean(index && prop.type === 'Literal'),
4053
+ optional: false
4054
+ }
4055
+ : prop
4056
+ }
4057
+
4058
+ ok(node, 'always a result')
4059
+ result = node
4060
+ } else {
4061
+ result =
4062
+ lib_name(name) && !/^[a-z]/.test(name)
4063
+ ? {type: 'Identifier', name}
4064
+ : {type: 'Literal', value: name}
4065
+ }
4066
+
4067
+ // Only literals can be passed in `components` currently.
4068
+ // No identifiers / member expressions.
4069
+ if (result.type === 'Literal') {
4070
+ const name = /** @type {keyof JSX.IntrinsicElements} */ (result.value)
4071
+
4072
+ return lib_own.call(state.components, name) ? state.components[name] : name
4073
+ }
4074
+
4075
+ // Assume component.
4076
+ if (state.evaluater) {
4077
+ return state.evaluater.evaluateExpression(result)
4078
+ }
4079
+
4080
+ crashEstree(state)
4081
+ }
4082
+
4083
+ /**
4084
+ * @param {State} state
4085
+ * @param {Position | undefined} [place]
4086
+ * @returns {never}
4087
+ */
4088
+ function crashEstree(state, place) {
4089
+ const message = new VFileMessage(
4090
+ 'Cannot handle MDX estrees without `createEvaluater`',
4091
+ {
4092
+ ancestors: state.ancestors,
4093
+ place,
4094
+ ruleId: 'mdx-estree',
4095
+ source: 'hast-util-to-jsx-runtime'
4096
+ }
4097
+ )
4098
+ message.file = state.filePath || undefined
4099
+ message.url = docs + '#cannot-handle-mdx-estrees-without-createevaluater'
4100
+
4101
+ throw message
4102
+ }
4103
+
3670
4104
  /**
3671
4105
  * Transform a DOM casing style object to a CSS casing style object.
3672
4106
  *
@@ -3775,7 +4209,7 @@ var jsx_runtime = __webpack_require__(246);
3775
4209
  */
3776
4210
 
3777
4211
  /** @type {Options} */
3778
- const emptyOptions = {}
4212
+ const lib_emptyOptions = {}
3779
4213
 
3780
4214
  /**
3781
4215
  * Get the text content of a node or list of nodes.
@@ -3791,7 +4225,7 @@ const emptyOptions = {}
3791
4225
  * Serialized `value`.
3792
4226
  */
3793
4227
  function lib_toString(value, options) {
3794
- const settings = options || emptyOptions
4228
+ const settings = options || lib_emptyOptions
3795
4229
  const includeImageAlt =
3796
4230
  typeof settings.includeImageAlt === 'boolean'
3797
4231
  ? settings.includeImageAlt
@@ -14430,7 +14864,7 @@ const serializer = (strict, json, $, _) => {
14430
14864
  * fallback to the polyfill if present.
14431
14865
  * @returns {Record[]}
14432
14866
  */
14433
- /* harmony default export */ const esm = (typeof structuredClone === "function" ?
14867
+ /* harmony default export */ const structured_clone_esm = (typeof structuredClone === "function" ?
14434
14868
  /* c8 ignore start */
14435
14869
  (any, options) => (
14436
14870
  options && ('json' in options || 'lossy' in options) ?
@@ -15042,7 +15476,7 @@ function footer(state) {
15042
15476
  type: 'element',
15043
15477
  tagName: footnoteLabelTagName,
15044
15478
  properties: {
15045
- ...esm(footnoteLabelProperties),
15479
+ ...structured_clone_esm(footnoteLabelProperties),
15046
15480
  id: 'footnote-label'
15047
15481
  },
15048
15482
  children: [{type: 'text', value: footnoteLabel}]
@@ -16889,7 +17323,7 @@ function paragraph(state, node) {
16889
17323
  * @returns {HastParents}
16890
17324
  * hast node.
16891
17325
  */
16892
- function root(state, node) {
17326
+ function root_root(state, node) {
16893
17327
  /** @type {HastRoot} */
16894
17328
  const result = {type: 'root', children: state.wrap(state.all(node))}
16895
17329
  state.patch(node, result)
@@ -17274,7 +17708,7 @@ const handlers_handlers = {
17274
17708
  list: list_list,
17275
17709
  paragraph: paragraph,
17276
17710
  // @ts-expect-error: root is different, but hard to type.
17277
- root: root,
17711
+ root: root_root,
17278
17712
  strong: strong,
17279
17713
  table: table,
17280
17714
  tableCell: tableCell,
@@ -17548,7 +17982,7 @@ function createState(tree, options) {
17548
17982
  if (state.options.passThrough && state.options.passThrough.includes(type)) {
17549
17983
  if ('children' in node) {
17550
17984
  const {children, ...shallow} = node
17551
- const result = esm(shallow)
17985
+ const result = structured_clone_esm(shallow)
17552
17986
  // @ts-expect-error: TS doesn’t understand…
17553
17987
  result.children = state.all(node)
17554
17988
  // @ts-expect-error: TS doesn’t understand…
@@ -17556,7 +17990,7 @@ function createState(tree, options) {
17556
17990
  }
17557
17991
 
17558
17992
  // @ts-expect-error: it’s custom.
17559
- return esm(node)
17993
+ return structured_clone_esm(node)
17560
17994
  }
17561
17995
 
17562
17996
  const unknown = state.options.unknownHandler || defaultUnknownHandler
@@ -17666,7 +18100,7 @@ function applyData(from, to) {
17666
18100
  }
17667
18101
 
17668
18102
  if (result.type === 'element' && hProperties) {
17669
- Object.assign(result.properties, esm(hProperties))
18103
+ Object.assign(result.properties, structured_clone_esm(hProperties))
17670
18104
  }
17671
18105
 
17672
18106
  if (
@@ -23200,7 +23634,7 @@ function emphasisPeek(_, _1, state) {
23200
23634
  */
23201
23635
 
23202
23636
  /** @type {Options} */
23203
- const lib_emptyOptions = {}
23637
+ const mdast_util_to_string_lib_emptyOptions = {}
23204
23638
 
23205
23639
  /**
23206
23640
  * Get the text content of a node or list of nodes.
@@ -23216,7 +23650,7 @@ const lib_emptyOptions = {}
23216
23650
  * Serialized `value`.
23217
23651
  */
23218
23652
  function mdast_util_to_string_lib_toString(value, options) {
23219
- const settings = options || lib_emptyOptions
23653
+ const settings = options || mdast_util_to_string_lib_emptyOptions
23220
23654
  const includeImageAlt =
23221
23655
  typeof settings.includeImageAlt === 'boolean'
23222
23656
  ? settings.includeImageAlt
@@ -24276,7 +24710,7 @@ const phrasing =
24276
24710
  * @param {Info} info
24277
24711
  * @returns {string}
24278
24712
  */
24279
- function root_root(node, _, state, info) {
24713
+ function handle_root_root(node, _, state, info) {
24280
24714
  // Note: `html` nodes are ambiguous.
24281
24715
  const hasPhrasing = node.children.some(function (d) {
24282
24716
  return phrasing(d)
@@ -24467,7 +24901,7 @@ const handle = {
24467
24901
  list: handle_list_list,
24468
24902
  listItem: list_item_listItem,
24469
24903
  paragraph: paragraph_paragraph,
24470
- root: root_root,
24904
+ root: handle_root_root,
24471
24905
  strong: strong_strong,
24472
24906
  text: handle_text_text,
24473
24907
  thematicBreak: handle_thematic_break_thematicBreak
@@ -30810,7 +31244,7 @@ function hast_util_from_parse5_lib_one(state, node) {
30810
31244
  // Element.
30811
31245
  default: {
30812
31246
  const reference = /** @type {P5Element} */ (node)
30813
- result = lib_element(state, reference)
31247
+ result = hast_util_from_parse5_lib_element(state, reference)
30814
31248
  return result
30815
31249
  }
30816
31250
  }
@@ -30850,7 +31284,7 @@ function hast_util_from_parse5_lib_all(state, nodes) {
30850
31284
  * @returns {Element}
30851
31285
  * hast node.
30852
31286
  */
30853
- function lib_element(state, node) {
31287
+ function hast_util_from_parse5_lib_element(state, node) {
30854
31288
  const schema = state.schema
30855
31289
 
30856
31290
  state.schema = node.namespaceURI === webNamespaces.svg ? property_information_svg : property_information_html
@@ -31187,7 +31621,7 @@ const hast_util_to_parse5_lib_emptyOptions = {}
31187
31621
 
31188
31622
  const hast_util_to_parse5_lib_own = {}.hasOwnProperty
31189
31623
 
31190
- const hast_util_to_parse5_lib_one = zwitch('type', {handlers: {root: lib_root, element: hast_util_to_parse5_lib_element, text: lib_text, comment, doctype}})
31624
+ const hast_util_to_parse5_lib_one = zwitch('type', {handlers: {root: lib_root, element: hast_util_to_parse5_lib_element, text: hast_util_to_parse5_lib_text, comment, doctype}})
31191
31625
 
31192
31626
  /**
31193
31627
  * Transform a hast tree to a `parse5` AST.
@@ -31268,7 +31702,7 @@ function doctype(node) {
31268
31702
  * @returns {Parse5Text}
31269
31703
  * Parse5 node.
31270
31704
  */
31271
- function lib_text(node) {
31705
+ function hast_util_to_parse5_lib_text(node) {
31272
31706
  /** @type {Parse5Text} */
31273
31707
  const result = {
31274
31708
  nodeName: '#text',
@@ -41029,8 +41463,8 @@ function createParse5Location(node) {
41029
41463
  */
41030
41464
  function cloneWithoutChildren(node) {
41031
41465
  return 'children' in node
41032
- ? esm({...node, children: []})
41033
- : esm(node)
41466
+ ? structured_clone_esm({...node, children: []})
41467
+ : structured_clone_esm(node)
41034
41468
  }
41035
41469
 
41036
41470
  ;// CONCATENATED MODULE: ../node_modules/rehype-raw/lib/index.js
@@ -41116,7 +41550,7 @@ function useCopied(container) {
41116
41550
  ;// CONCATENATED MODULE: ../node_modules/@uiw/react-markdown-preview/esm/preview.js
41117
41551
 
41118
41552
 
41119
- var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "skipHtml", "onScroll", "onMouseOver", "pluginsFilter", "rehypeRewrite", "wrapperElement", "warpperElement"];
41553
+ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "skipHtml", "onScroll", "onMouseOver", "pluginsFilter", "rehypeRewrite", "wrapperElement", "warpperElement", "urlTransform"];
41120
41554
 
41121
41555
 
41122
41556
 
@@ -41124,7 +41558,11 @@ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "sk
41124
41558
 
41125
41559
 
41126
41560
 
41561
+ /**
41562
+ * https://github.com/uiwjs/react-md-editor/issues/607
41563
+ */
41127
41564
 
41565
+ var preview_defaultUrlTransform = url => url;
41128
41566
  /* harmony default export */ const preview = (/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().forwardRef((props, ref) => {
41129
41567
  var {
41130
41568
  prefixCls = 'wmde-markdown wmde-markdown-color',
@@ -41137,7 +41575,8 @@ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "sk
41137
41575
  onMouseOver,
41138
41576
  pluginsFilter,
41139
41577
  wrapperElement = {},
41140
- warpperElement = {}
41578
+ warpperElement = {},
41579
+ urlTransform
41141
41580
  } = props,
41142
41581
  other = _objectWithoutPropertiesLoose(props, _excluded);
41143
41582
  var mdp = external_root_React_commonjs2_react_commonjs_react_amd_react_default().useRef(null);
@@ -41169,6 +41608,7 @@ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "sk
41169
41608
  style: style,
41170
41609
  children: /*#__PURE__*/(0,jsx_runtime.jsx)(Markdown, _extends({}, customProps, other, {
41171
41610
  skipHtml: skipHtml,
41611
+ urlTransform: urlTransform || preview_defaultUrlTransform,
41172
41612
  rehypePlugins: pluginsFilter ? pluginsFilter('rehype', rehypePlugins) : rehypePlugins,
41173
41613
  remarkPlugins: pluginsFilter ? pluginsFilter('remark', remarkPlugins) : remarkPlugins,
41174
41614
  children: source || ''
@@ -70096,15 +70536,20 @@ var cssSyntaxDefinitions = {
70096
70536
 
70097
70537
  ;// CONCATENATED MODULE: ../node_modules/css-selector-parser/dist/mjs/utils.js
70098
70538
  function isIdentStart(c) {
70099
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c === '-' || c === '_' || c === '\\';
70539
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c === '-' || c === '_' || c === '\\' || c >= '\u00a0';
70100
70540
  }
70101
70541
  function isIdent(c) {
70102
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c === '-' || c === '_';
70542
+ return ((c >= 'a' && c <= 'z') ||
70543
+ (c >= 'A' && c <= 'Z') ||
70544
+ (c >= '0' && c <= '9') ||
70545
+ c === '-' ||
70546
+ c === '_' ||
70547
+ c >= '\u00a0');
70103
70548
  }
70104
70549
  function isHex(c) {
70105
70550
  return (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') || (c >= '0' && c <= '9');
70106
70551
  }
70107
- var identSpecialChars = {
70552
+ var identEscapeChars = {
70108
70553
  '!': true,
70109
70554
  '"': true,
70110
70555
  '#': true,
@@ -70135,19 +70580,12 @@ var identSpecialChars = {
70135
70580
  '}': true,
70136
70581
  '~': true
70137
70582
  };
70138
- var strReplacementsRev = {
70139
- '\n': '\\n',
70140
- '\r': '\\r',
70141
- '\t': '\\t',
70142
- '\f': '\\f',
70143
- '\v': '\\v'
70144
- };
70145
- var stringEscapeChars = {
70146
- n: '\n',
70147
- r: '\r',
70148
- t: '\t',
70149
- f: '\f',
70150
- '\\': '\\'
70583
+ var stringRenderEscapeChars = {
70584
+ '\n': true,
70585
+ '\r': true,
70586
+ '\t': true,
70587
+ '\f': true,
70588
+ '\v': true
70151
70589
  };
70152
70590
  var whitespaceChars = {
70153
70591
  ' ': true,
@@ -70172,21 +70610,25 @@ var digitsChars = {
70172
70610
  8: true,
70173
70611
  9: true
70174
70612
  };
70613
+ var maxHexLength = 6;
70175
70614
  function utils_escapeIdentifier(s) {
70176
70615
  var len = s.length;
70177
70616
  var result = '';
70178
70617
  var i = 0;
70179
70618
  while (i < len) {
70180
70619
  var chr = s.charAt(i);
70181
- if (identSpecialChars[chr]) {
70620
+ if (identEscapeChars[chr] || (chr === '-' && i === 1 && s.charAt(0) === '-')) {
70182
70621
  result += '\\' + chr;
70183
70622
  }
70184
70623
  else {
70185
- if (!(chr === '_' ||
70186
- chr === '-' ||
70624
+ if (chr === '-' ||
70625
+ chr === '_' ||
70187
70626
  (chr >= 'A' && chr <= 'Z') ||
70188
70627
  (chr >= 'a' && chr <= 'z') ||
70189
- (i !== 0 && chr >= '0' && chr <= '9'))) {
70628
+ (chr >= '0' && chr <= '9' && i !== 0 && !(i === 1 && s.charAt(0) === '-'))) {
70629
+ result += chr;
70630
+ }
70631
+ else {
70190
70632
  var charCode = chr.charCodeAt(0);
70191
70633
  if ((charCode & 0xf800) === 0xd800) {
70192
70634
  var extraCharCode = s.charCodeAt(i++);
@@ -70197,19 +70639,15 @@ function utils_escapeIdentifier(s) {
70197
70639
  }
70198
70640
  result += '\\' + charCode.toString(16) + ' ';
70199
70641
  }
70200
- else {
70201
- result += chr;
70202
- }
70203
70642
  }
70204
70643
  i++;
70205
70644
  }
70206
70645
  return result.trim();
70207
70646
  }
70208
- function utils_escapeStr(s) {
70647
+ function utils_escapeString(s) {
70209
70648
  var len = s.length;
70210
70649
  var result = '';
70211
70650
  var i = 0;
70212
- var replacement;
70213
70651
  while (i < len) {
70214
70652
  var chr = s.charAt(i);
70215
70653
  if (chr === '"') {
@@ -70218,8 +70656,8 @@ function utils_escapeStr(s) {
70218
70656
  else if (chr === '\\') {
70219
70657
  chr = '\\\\';
70220
70658
  }
70221
- else if ((replacement = strReplacementsRev[chr]) !== undefined) {
70222
- chr = replacement;
70659
+ else if (stringRenderEscapeChars[chr]) {
70660
+ chr = '\\' + chr.charCodeAt(0).toString(16) + (i === len - 1 ? '' : ' ');
70223
70661
  }
70224
70662
  result += chr;
70225
70663
  i++;
@@ -70360,16 +70798,22 @@ function createParser(options) {
70360
70798
  }
70361
70799
  }
70362
70800
  }
70801
+ /**
70802
+ * @see https://www.w3.org/TR/css-syntax/#hex-digit-diagram
70803
+ */
70363
70804
  function parseHex() {
70364
70805
  var hex = readAndNext();
70365
- while (isHex(chr)) {
70806
+ var count = 1;
70807
+ while (isHex(chr) && count < maxHexLength) {
70366
70808
  hex += readAndNext();
70809
+ count++;
70367
70810
  }
70368
- if (is(' ')) {
70369
- next();
70370
- }
70811
+ skipSingleWhitespace();
70371
70812
  return String.fromCharCode(parseInt(hex, 16));
70372
70813
  }
70814
+ /**
70815
+ * @see https://www.w3.org/TR/css-syntax/#string-token-diagram
70816
+ */
70373
70817
  function parseString(quote) {
70374
70818
  var result = '';
70375
70819
  pass(quote);
@@ -70380,33 +70824,53 @@ function createParser(options) {
70380
70824
  }
70381
70825
  else if (is('\\')) {
70382
70826
  next();
70383
- var esc = void 0;
70384
70827
  if (is(quote)) {
70385
70828
  result += quote;
70829
+ next();
70830
+ }
70831
+ else if (chr === '\n' || chr === '\f') {
70832
+ next();
70386
70833
  }
70387
- else if ((esc = stringEscapeChars[chr]) !== undefined) {
70388
- result += esc;
70834
+ else if (chr === '\r') {
70835
+ next();
70836
+ if (is('\n')) {
70837
+ next();
70838
+ }
70389
70839
  }
70390
70840
  else if (isHex(chr)) {
70391
70841
  result += parseHex();
70392
- continue;
70393
70842
  }
70394
70843
  else {
70395
70844
  result += chr;
70845
+ next();
70396
70846
  }
70397
70847
  }
70398
70848
  else {
70399
70849
  result += chr;
70850
+ next();
70400
70851
  }
70401
- next();
70402
70852
  }
70403
70853
  return result;
70404
70854
  }
70855
+ /**
70856
+ * @see https://www.w3.org/TR/css-syntax/#ident-token-diagram
70857
+ */
70405
70858
  function parseIdentifier() {
70406
70859
  if (!isIdentStart(chr)) {
70407
70860
  return null;
70408
70861
  }
70409
70862
  var result = '';
70863
+ while (is('-')) {
70864
+ result += chr;
70865
+ next();
70866
+ }
70867
+ if (strict && result.length >= 2) {
70868
+ // Checking this only for strict mode since browsers work fine with these identifiers.
70869
+ fail('Identifiers cannot start with two hyphens with strict mode on.');
70870
+ }
70871
+ if (digitsChars[chr]) {
70872
+ fail('Identifiers cannot start with hyphens followed by digits.');
70873
+ }
70410
70874
  while (pos < l) {
70411
70875
  if (isIdent(chr)) {
70412
70876
  result += readAndNext();
@@ -70422,7 +70886,7 @@ function createParser(options) {
70422
70886
  }
70423
70887
  }
70424
70888
  else {
70425
- return result;
70889
+ break;
70426
70890
  }
70427
70891
  }
70428
70892
  return result;
@@ -70452,6 +70916,18 @@ function createParser(options) {
70452
70916
  }
70453
70917
  return result.trim();
70454
70918
  }
70919
+ function skipSingleWhitespace() {
70920
+ if (chr === ' ' || chr === '\t' || chr === '\f' || chr === '\n') {
70921
+ next();
70922
+ return;
70923
+ }
70924
+ if (chr === '\r') {
70925
+ next();
70926
+ }
70927
+ if (chr === '\n') {
70928
+ next();
70929
+ }
70930
+ }
70455
70931
  function skipWhitespace() {
70456
70932
  while (whitespaceChars[chr]) {
70457
70933
  next();
@@ -71012,7 +71488,7 @@ function render(entity) {
71012
71488
  if (operator && value) {
71013
71489
  result += operator;
71014
71490
  if (value.type === 'String') {
71015
- result += escapeStr(value.value);
71491
+ result += escapeString(value.value);
71016
71492
  }
71017
71493
  else if (value.type === 'Substitution') {
71018
71494
  result += renderSubstitution(value);
@@ -74247,7 +74723,7 @@ function rehypeAutolinkHeadings(options) {
74247
74723
  */
74248
74724
  function clone(thing) {
74249
74725
  // Cast because it’s mutable now.
74250
- return /** @type {Cloneable<T>} */ (esm(thing))
74726
+ return /** @type {Cloneable<T>} */ (structured_clone_esm(thing))
74251
74727
  }
74252
74728
 
74253
74729
  /**
@@ -76788,7 +77264,7 @@ function raw_raw(node, index, parent, state) {
76788
77264
  * @returns {string}
76789
77265
  * Serialized node.
76790
77266
  */
76791
- function handle_root_root(node, _1, _2, state) {
77267
+ function lib_handle_root_root(node, _1, _2, state) {
76792
77268
  return state.all(node)
76793
77269
  }
76794
77270
 
@@ -76814,7 +77290,7 @@ function handle_root_root(node, _1, _2, state) {
76814
77290
  const handle_handle = zwitch('type', {
76815
77291
  invalid,
76816
77292
  unknown: handle_unknown,
76817
- handlers: {comment: comment_comment, doctype: doctype_doctype, element: element_element, raw: raw_raw, root: handle_root_root, text: lib_handle_text_text}
77293
+ handlers: {comment: comment_comment, doctype: doctype_doctype, element: element_element, raw: raw_raw, root: lib_handle_root_root, text: lib_handle_text_text}
76818
77294
  })
76819
77295
 
76820
77296
  /**
@@ -77197,7 +77673,7 @@ function _defineProperties(target, props) {
77197
77673
  descriptor.enumerable = descriptor.enumerable || false;
77198
77674
  descriptor.configurable = true;
77199
77675
  if ("value" in descriptor) descriptor.writable = true;
77200
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
77676
+ Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);
77201
77677
  }
77202
77678
  }
77203
77679
  function _createClass(Constructor, protoProps, staticProps) {