@uiw/react-md-editor 3.13.0 → 3.14.0

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
@@ -1367,196 +1367,6 @@ encode.componentChars = "-_.!~*'()";
1367
1367
  module.exports = encode;
1368
1368
 
1369
1369
 
1370
- /***/ }),
1371
-
1372
- /***/ 770:
1373
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1374
-
1375
- "use strict";
1376
-
1377
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1378
- exports.compile = void 0;
1379
- var boolbase_1 = __webpack_require__(407);
1380
- /**
1381
- * Returns a function that checks if an elements index matches the given rule
1382
- * highly optimized to return the fastest solution.
1383
- *
1384
- * @param parsed A tuple [a, b], as returned by `parse`.
1385
- * @returns A highly optimized function that returns whether an index matches the nth-check.
1386
- * @example
1387
- * const check = nthCheck.compile([2, 3]);
1388
- *
1389
- * check(0); // `false`
1390
- * check(1); // `false`
1391
- * check(2); // `true`
1392
- * check(3); // `false`
1393
- * check(4); // `true`
1394
- * check(5); // `false`
1395
- * check(6); // `true`
1396
- */
1397
- function compile(parsed) {
1398
- var a = parsed[0];
1399
- // Subtract 1 from `b`, to convert from one- to zero-indexed.
1400
- var b = parsed[1] - 1;
1401
- /*
1402
- * When `b <= 0`, `a * n` won't be lead to any matches for `a < 0`.
1403
- * Besides, the specification states that no elements are
1404
- * matched when `a` and `b` are 0.
1405
- *
1406
- * `b < 0` here as we subtracted 1 from `b` above.
1407
- */
1408
- if (b < 0 && a <= 0)
1409
- return boolbase_1.falseFunc;
1410
- // When `a` is in the range -1..1, it matches any element (so only `b` is checked).
1411
- if (a === -1)
1412
- return function (index) { return index <= b; };
1413
- if (a === 0)
1414
- return function (index) { return index === b; };
1415
- // When `b <= 0` and `a === 1`, they match any element.
1416
- if (a === 1)
1417
- return b < 0 ? boolbase_1.trueFunc : function (index) { return index >= b; };
1418
- /*
1419
- * Otherwise, modulo can be used to check if there is a match.
1420
- *
1421
- * Modulo doesn't care about the sign, so let's use `a`s absolute value.
1422
- */
1423
- var absA = Math.abs(a);
1424
- // Get `b mod a`, + a if this is negative.
1425
- var bMod = ((b % absA) + absA) % absA;
1426
- return a > 1
1427
- ? function (index) { return index >= b && index % absA === bMod; }
1428
- : function (index) { return index <= b && index % absA === bMod; };
1429
- }
1430
- exports.compile = compile;
1431
-
1432
-
1433
- /***/ }),
1434
-
1435
- /***/ 483:
1436
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1437
-
1438
- "use strict";
1439
- var __webpack_unused_export__;
1440
-
1441
- __webpack_unused_export__ = ({ value: true });
1442
- __webpack_unused_export__ = __webpack_unused_export__ = void 0;
1443
- var parse_1 = __webpack_require__(711);
1444
- __webpack_unused_export__ = ({ enumerable: true, get: function () { return parse_1.parse; } });
1445
- var compile_1 = __webpack_require__(770);
1446
- __webpack_unused_export__ = ({ enumerable: true, get: function () { return compile_1.compile; } });
1447
- /**
1448
- * Parses and compiles a formula to a highly optimized function.
1449
- * Combination of `parse` and `compile`.
1450
- *
1451
- * If the formula doesn't match any elements,
1452
- * it returns [`boolbase`](https://github.com/fb55/boolbase)'s `falseFunc`.
1453
- * Otherwise, a function accepting an _index_ is returned, which returns
1454
- * whether or not the passed _index_ matches the formula.
1455
- *
1456
- * Note: The nth-rule starts counting at `1`, the returned function at `0`.
1457
- *
1458
- * @param formula The formula to compile.
1459
- * @example
1460
- * const check = nthCheck("2n+3");
1461
- *
1462
- * check(0); // `false`
1463
- * check(1); // `false`
1464
- * check(2); // `true`
1465
- * check(3); // `false`
1466
- * check(4); // `true`
1467
- * check(5); // `false`
1468
- * check(6); // `true`
1469
- */
1470
- function nthCheck(formula) {
1471
- return (0, compile_1.compile)((0, parse_1.parse)(formula));
1472
- }
1473
- exports.ZP = nthCheck;
1474
-
1475
-
1476
- /***/ }),
1477
-
1478
- /***/ 711:
1479
- /***/ ((__unused_webpack_module, exports) => {
1480
-
1481
- "use strict";
1482
-
1483
- // Following http://www.w3.org/TR/css3-selectors/#nth-child-pseudo
1484
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1485
- exports.parse = void 0;
1486
- // Whitespace as per https://www.w3.org/TR/selectors-3/#lex is " \t\r\n\f"
1487
- var whitespace = new Set([9, 10, 12, 13, 32]);
1488
- var ZERO = "0".charCodeAt(0);
1489
- var NINE = "9".charCodeAt(0);
1490
- /**
1491
- * Parses an expression.
1492
- *
1493
- * @throws An `Error` if parsing fails.
1494
- * @returns An array containing the integer step size and the integer offset of the nth rule.
1495
- * @example nthCheck.parse("2n+3"); // returns [2, 3]
1496
- */
1497
- function parse(formula) {
1498
- formula = formula.trim().toLowerCase();
1499
- if (formula === "even") {
1500
- return [2, 0];
1501
- }
1502
- else if (formula === "odd") {
1503
- return [2, 1];
1504
- }
1505
- // Parse [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]?
1506
- var idx = 0;
1507
- var a = 0;
1508
- var sign = readSign();
1509
- var number = readNumber();
1510
- if (idx < formula.length && formula.charAt(idx) === "n") {
1511
- idx++;
1512
- a = sign * (number !== null && number !== void 0 ? number : 1);
1513
- skipWhitespace();
1514
- if (idx < formula.length) {
1515
- sign = readSign();
1516
- skipWhitespace();
1517
- number = readNumber();
1518
- }
1519
- else {
1520
- sign = number = 0;
1521
- }
1522
- }
1523
- // Throw if there is anything else
1524
- if (number === null || idx < formula.length) {
1525
- throw new Error("n-th rule couldn't be parsed ('" + formula + "')");
1526
- }
1527
- return [a, sign * number];
1528
- function readSign() {
1529
- if (formula.charAt(idx) === "-") {
1530
- idx++;
1531
- return -1;
1532
- }
1533
- if (formula.charAt(idx) === "+") {
1534
- idx++;
1535
- }
1536
- return 1;
1537
- }
1538
- function readNumber() {
1539
- var start = idx;
1540
- var value = 0;
1541
- while (idx < formula.length &&
1542
- formula.charCodeAt(idx) >= ZERO &&
1543
- formula.charCodeAt(idx) <= NINE) {
1544
- value = value * 10 + (formula.charCodeAt(idx) - ZERO);
1545
- idx++;
1546
- }
1547
- // Return `null` if we didn't read anything.
1548
- return idx === start ? null : value;
1549
- }
1550
- function skipWhitespace() {
1551
- while (idx < formula.length &&
1552
- whitespace.has(formula.charCodeAt(idx))) {
1553
- idx++;
1554
- }
1555
- }
1556
- }
1557
- exports.parse = parse;
1558
-
1559
-
1560
1370
  /***/ }),
1561
1371
 
1562
1372
  /***/ 977:
@@ -10084,7 +9894,7 @@ var external_root_React_commonjs2_react_commonjs_react_amd_react_ = __webpack_re
10084
9894
  var external_root_React_commonjs2_react_commonjs_react_amd_react_default = /*#__PURE__*/__webpack_require__.n(external_root_React_commonjs2_react_commonjs_react_amd_react_);
10085
9895
  ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
10086
9896
  function _extends() {
10087
- _extends = Object.assign || function (target) {
9897
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
10088
9898
  for (var i = 1; i < arguments.length; i++) {
10089
9899
  var source = arguments[i];
10090
9900
 
@@ -10097,7 +9907,6 @@ function _extends() {
10097
9907
 
10098
9908
  return target;
10099
9909
  };
10100
-
10101
9910
  return _extends.apply(this, arguments);
10102
9911
  }
10103
9912
  // EXTERNAL MODULE: ./node_modules/is-buffer/index.js
@@ -15652,7 +15461,7 @@ function tokenizeSetextUnderline(effects, ok, nok) {
15652
15461
  * to detect whether the HTML-like syntax is seen as HTML (flow) or not.
15653
15462
  *
15654
15463
  * This is copied from:
15655
- * <https://spec.commonmark.org/0.29/#html-blocks>.
15464
+ * <https://spec.commonmark.org/0.30/#html-blocks>.
15656
15465
  */
15657
15466
  const htmlBlockNames = [
15658
15467
  'address',
@@ -15705,7 +15514,6 @@ const htmlBlockNames = [
15705
15514
  'p',
15706
15515
  'param',
15707
15516
  'section',
15708
- 'source',
15709
15517
  'summary',
15710
15518
  'table',
15711
15519
  'tbody',
@@ -15725,11 +15533,9 @@ const htmlBlockNames = [
15725
15533
  * list is found (condition 1).
15726
15534
  *
15727
15535
  * This module is copied from:
15728
- * <https://spec.commonmark.org/0.29/#html-blocks>.
15536
+ * <https://spec.commonmark.org/0.30/#html-blocks>.
15729
15537
  *
15730
- * Note that `textarea` is not available in `CommonMark@0.29` but has been
15731
- * merged to the primary branch and is slated to be released in the next release
15732
- * of CommonMark.
15538
+ * Note that `textarea` was added in `CommonMark@0.30`.
15733
15539
  */
15734
15540
  const htmlRawNames = ['pre', 'script', 'style', 'textarea']
15735
15541
 
@@ -26574,17 +26380,182 @@ function escapeStringRegexp(string) {
26574
26380
  .replace(/-/g, '\\x2d');
26575
26381
  }
26576
26382
 
26577
- ;// CONCATENATED MODULE: ./node_modules/mdast-util-find-and-replace/index.js
26383
+ ;// CONCATENATED MODULE: ./node_modules/mdast-util-find-and-replace/node_modules/unist-util-visit-parents/color.browser.js
26578
26384
  /**
26579
- * @typedef Options Configuration.
26580
- * @property {Test} [ignore] `unist-util-is` test used to assert parents
26385
+ * @param {string} d
26386
+ * @returns {string}
26387
+ */
26388
+ function unist_util_visit_parents_color_browser_color(d) {
26389
+ return d
26390
+ }
26391
+
26392
+ ;// CONCATENATED MODULE: ./node_modules/mdast-util-find-and-replace/node_modules/unist-util-visit-parents/index.js
26393
+ /**
26394
+ * @typedef {import('unist').Node} Node
26395
+ * @typedef {import('unist').Parent} Parent
26396
+ * @typedef {import('unist-util-is').Test} Test
26397
+ * @typedef {import('./complex-types').Action} Action
26398
+ * @typedef {import('./complex-types').Index} Index
26399
+ * @typedef {import('./complex-types').ActionTuple} ActionTuple
26400
+ * @typedef {import('./complex-types').VisitorResult} VisitorResult
26401
+ * @typedef {import('./complex-types').Visitor} Visitor
26402
+ */
26403
+
26404
+
26405
+
26406
+
26407
+ /**
26408
+ * Continue traversing as normal
26409
+ */
26410
+ const node_modules_unist_util_visit_parents_CONTINUE = true
26411
+ /**
26412
+ * Do not traverse this node’s children
26413
+ */
26414
+ const node_modules_unist_util_visit_parents_SKIP = 'skip'
26415
+ /**
26416
+ * Stop traversing immediately
26417
+ */
26418
+ const node_modules_unist_util_visit_parents_EXIT = false
26419
+
26420
+ /**
26421
+ * Visit children of tree which pass a test
26422
+ *
26423
+ * @param tree Abstract syntax tree to walk
26424
+ * @param test Test node, optional
26425
+ * @param visitor Function to run for each node
26426
+ * @param reverse Visit the tree in reverse order, defaults to false
26427
+ */
26428
+ const node_modules_unist_util_visit_parents_visitParents =
26429
+ /**
26430
+ * @type {(
26431
+ * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: import('./complex-types').BuildVisitor<Tree, Check>, reverse?: boolean) => void) &
26432
+ * (<Tree extends Node>(tree: Tree, visitor: import('./complex-types').BuildVisitor<Tree>, reverse?: boolean) => void)
26433
+ * )}
26434
+ */
26435
+ (
26436
+ /**
26437
+ * @param {Node} tree
26438
+ * @param {Test} test
26439
+ * @param {import('./complex-types').Visitor<Node>} visitor
26440
+ * @param {boolean} [reverse]
26441
+ */
26442
+ function (tree, test, visitor, reverse) {
26443
+ if (typeof test === 'function' && typeof visitor !== 'function') {
26444
+ reverse = visitor
26445
+ // @ts-expect-error no visitor given, so `visitor` is test.
26446
+ visitor = test
26447
+ test = null
26448
+ }
26449
+
26450
+ const is = convert(test)
26451
+ const step = reverse ? -1 : 1
26452
+
26453
+ factory(tree, null, [])()
26454
+
26455
+ /**
26456
+ * @param {Node} node
26457
+ * @param {number?} index
26458
+ * @param {Array.<Parent>} parents
26459
+ */
26460
+ function factory(node, index, parents) {
26461
+ /** @type {Object.<string, unknown>} */
26462
+ // @ts-expect-error: hush
26463
+ const value = typeof node === 'object' && node !== null ? node : {}
26464
+ /** @type {string|undefined} */
26465
+ let name
26466
+
26467
+ if (typeof value.type === 'string') {
26468
+ name =
26469
+ typeof value.tagName === 'string'
26470
+ ? value.tagName
26471
+ : typeof value.name === 'string'
26472
+ ? value.name
26473
+ : undefined
26474
+
26475
+ Object.defineProperty(visit, 'name', {
26476
+ value:
26477
+ 'node (' +
26478
+ unist_util_visit_parents_color_browser_color(value.type + (name ? '<' + name + '>' : '')) +
26479
+ ')'
26480
+ })
26481
+ }
26482
+
26483
+ return visit
26484
+
26485
+ function visit() {
26486
+ /** @type {ActionTuple} */
26487
+ let result = []
26488
+ /** @type {ActionTuple} */
26489
+ let subresult
26490
+ /** @type {number} */
26491
+ let offset
26492
+ /** @type {Array.<Parent>} */
26493
+ let grandparents
26494
+
26495
+ if (!test || is(node, index, parents[parents.length - 1] || null)) {
26496
+ result = node_modules_unist_util_visit_parents_toResult(visitor(node, parents))
26497
+
26498
+ if (result[0] === node_modules_unist_util_visit_parents_EXIT) {
26499
+ return result
26500
+ }
26501
+ }
26502
+
26503
+ // @ts-expect-error looks like a parent.
26504
+ if (node.children && result[0] !== node_modules_unist_util_visit_parents_SKIP) {
26505
+ // @ts-expect-error looks like a parent.
26506
+ offset = (reverse ? node.children.length : -1) + step
26507
+ // @ts-expect-error looks like a parent.
26508
+ grandparents = parents.concat(node)
26509
+
26510
+ // @ts-expect-error looks like a parent.
26511
+ while (offset > -1 && offset < node.children.length) {
26512
+ // @ts-expect-error looks like a parent.
26513
+ subresult = factory(node.children[offset], offset, grandparents)()
26514
+
26515
+ if (subresult[0] === node_modules_unist_util_visit_parents_EXIT) {
26516
+ return subresult
26517
+ }
26518
+
26519
+ offset =
26520
+ typeof subresult[1] === 'number' ? subresult[1] : offset + step
26521
+ }
26522
+ }
26523
+
26524
+ return result
26525
+ }
26526
+ }
26527
+ }
26528
+ )
26529
+
26530
+ /**
26531
+ * @param {VisitorResult} value
26532
+ * @returns {ActionTuple}
26533
+ */
26534
+ function node_modules_unist_util_visit_parents_toResult(value) {
26535
+ if (Array.isArray(value)) {
26536
+ return value
26537
+ }
26538
+
26539
+ if (typeof value === 'number') {
26540
+ return [node_modules_unist_util_visit_parents_CONTINUE, value]
26541
+ }
26542
+
26543
+ return [value]
26544
+ }
26545
+
26546
+ ;// CONCATENATED MODULE: ./node_modules/mdast-util-find-and-replace/lib/index.js
26547
+ /**
26548
+ * @typedef Options
26549
+ * Configuration (optional).
26550
+ * @property {Test} [ignore]
26551
+ * `unist-util-is` test used to assert parents
26581
26552
  *
26582
26553
  * @typedef {import('mdast').Root} Root
26583
26554
  * @typedef {import('mdast').Content} Content
26584
26555
  * @typedef {import('mdast').PhrasingContent} PhrasingContent
26585
26556
  * @typedef {import('mdast').Text} Text
26586
26557
  * @typedef {Content|Root} Node
26587
- * @typedef {Extract<Node, import('mdast').Parent>} Parent
26558
+ * @typedef {Exclude<Extract<Node, import('mdast').Parent>, Root>} Parent
26588
26559
  *
26589
26560
  * @typedef {import('unist-util-visit-parents').Test} Test
26590
26561
  * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult
@@ -26592,29 +26563,30 @@ function escapeStringRegexp(string) {
26592
26563
  * @typedef RegExpMatchObject
26593
26564
  * @property {number} index
26594
26565
  * @property {string} input
26566
+ * @property {[Root, ...Array<Parent>, Text]} stack
26595
26567
  *
26596
26568
  * @typedef {string|RegExp} Find
26597
26569
  * @typedef {string|ReplaceFunction} Replace
26598
26570
  *
26599
26571
  * @typedef {[Find, Replace]} FindAndReplaceTuple
26600
- * @typedef {Object.<string, Replace>} FindAndReplaceSchema
26601
- * @typedef {Array.<FindAndReplaceTuple>} FindAndReplaceList
26572
+ * @typedef {Record<string, Replace>} FindAndReplaceSchema
26573
+ * @typedef {Array<FindAndReplaceTuple>} FindAndReplaceList
26602
26574
  *
26603
26575
  * @typedef {[RegExp, ReplaceFunction]} Pair
26604
- * @typedef {Array.<Pair>} Pairs
26576
+ * @typedef {Array<Pair>} Pairs
26605
26577
  */
26606
26578
 
26607
26579
  /**
26608
26580
  * @callback ReplaceFunction
26609
26581
  * @param {...any} parameters
26610
- * @returns {Array.<PhrasingContent>|PhrasingContent|string|false|undefined|null}
26582
+ * @returns {Array<PhrasingContent>|PhrasingContent|string|false|undefined|null}
26611
26583
  */
26612
26584
 
26613
26585
 
26614
26586
 
26615
26587
 
26616
26588
 
26617
- const mdast_util_find_and_replace_own = {}.hasOwnProperty
26589
+ const mdast_util_find_and_replace_lib_own = {}.hasOwnProperty
26618
26590
 
26619
26591
  /**
26620
26592
  * @param tree mdast tree
@@ -26665,12 +26637,12 @@ const findAndReplace =
26665
26637
  let pairIndex = -1
26666
26638
 
26667
26639
  while (++pairIndex < pairs.length) {
26668
- unist_util_visit_parents_visitParents(tree, 'text', visitor)
26640
+ node_modules_unist_util_visit_parents_visitParents(tree, 'text', visitor)
26669
26641
  }
26670
26642
 
26671
26643
  return tree
26672
26644
 
26673
- /** @type {import('unist-util-visit-parents').Visitor<Text>} */
26645
+ /** @type {import('unist-util-visit-parents/complex-types').BuildVisitor<Root, 'text'>} */
26674
26646
  function visitor(node, parents) {
26675
26647
  let index = -1
26676
26648
  /** @type {Parent|undefined} */
@@ -26694,22 +26666,24 @@ const findAndReplace =
26694
26666
  }
26695
26667
 
26696
26668
  if (grandparent) {
26697
- return handler(node, grandparent)
26669
+ // @ts-expect-error: stack is fine.
26670
+ return handler(node, parents)
26698
26671
  }
26699
26672
  }
26700
26673
 
26701
26674
  /**
26702
26675
  * @param {Text} node
26703
- * @param {Parent} parent
26676
+ * @param {[Root, ...Array<Parent>]} parents
26704
26677
  * @returns {VisitorResult}
26705
26678
  */
26706
- function handler(node, parent) {
26679
+ function handler(node, parents) {
26680
+ const parent = parents[parents.length - 1]
26707
26681
  const find = pairs[pairIndex][0]
26708
26682
  const replace = pairs[pairIndex][1]
26709
26683
  let start = 0
26710
26684
  // @ts-expect-error: TS is wrong, some of these children can be text.
26711
- let index = parent.children.indexOf(node)
26712
- /** @type {Array.<PhrasingContent>} */
26685
+ const index = parent.children.indexOf(node)
26686
+ /** @type {Array<PhrasingContent>} */
26713
26687
  let nodes = []
26714
26688
  /** @type {number|undefined} */
26715
26689
  let position
@@ -26720,17 +26694,21 @@ const findAndReplace =
26720
26694
 
26721
26695
  while (match) {
26722
26696
  position = match.index
26723
- // @ts-expect-error this is perfectly fine, typescript.
26724
- let value = replace(...match, {
26697
+ /** @type {RegExpMatchObject} */
26698
+ const matchObject = {
26725
26699
  index: match.index,
26726
- input: match.input
26727
- })
26700
+ input: match.input,
26701
+ stack: [...parents, node]
26702
+ }
26703
+ let value = replace(...match, matchObject)
26728
26704
 
26729
26705
  if (typeof value === 'string') {
26730
26706
  value = value.length > 0 ? {type: 'text', value} : undefined
26731
26707
  }
26732
26708
 
26733
- if (value !== false) {
26709
+ if (value === false) {
26710
+ position = undefined
26711
+ } else {
26734
26712
  if (start !== position) {
26735
26713
  nodes.push({
26736
26714
  type: 'text',
@@ -26756,7 +26734,6 @@ const findAndReplace =
26756
26734
 
26757
26735
  if (position === undefined) {
26758
26736
  nodes = [node]
26759
- index--
26760
26737
  } else {
26761
26738
  if (start < node.value.length) {
26762
26739
  nodes.push({type: 'text', value: node.value.slice(start)})
@@ -26765,7 +26742,7 @@ const findAndReplace =
26765
26742
  parent.children.splice(index, 1, ...nodes)
26766
26743
  }
26767
26744
 
26768
- return index + nodes.length + 1
26745
+ return index + nodes.length
26769
26746
  }
26770
26747
  }
26771
26748
  )
@@ -26796,7 +26773,7 @@ function toPairs(schema) {
26796
26773
  let key
26797
26774
 
26798
26775
  for (key in schema) {
26799
- if (mdast_util_find_and_replace_own.call(schema, key)) {
26776
+ if (mdast_util_find_and_replace_lib_own.call(schema, key)) {
26800
26777
  result.push([toExpression(key), toFunction(schema[key])])
26801
26778
  }
26802
26779
  }
@@ -57812,7 +57789,7 @@ const util_element = convertElement()
57812
57789
  * @typedef {import('./types.js').HastNode} HastNode
57813
57790
  * @typedef {import('./types.js').ElementChild} ElementChild
57814
57791
  * @typedef {import('./types.js').Direction} Direction
57815
- * @typedef {import('unist-util-visit').Visitor<ElementChild>} Visitor
57792
+ * @typedef {import('unist-util-visit/complex-types').Visitor<ElementChild>} Visitor
57816
57793
  */
57817
57794
 
57818
57795
 
@@ -58088,9 +58065,9 @@ function indexedSearch(query, parent, state, from, firstElementOnly) {
58088
58065
  const children = parent.children
58089
58066
  let elements = 0
58090
58067
  let index = -1
58091
- /** @type {Object.<string, number>} */
58068
+ /** @type {Record<string, number>} */
58092
58069
  const types = {}
58093
- /** @type {Array.<Function>} */
58070
+ /** @type {Array<Function>} */
58094
58071
  const delayed = []
58095
58072
 
58096
58073
  // Start looking at `from`
@@ -59212,7 +59189,7 @@ function normalizeValue(value, info) {
59212
59189
  * @returns {boolean}
59213
59190
  */
59214
59191
  function className(query, element) {
59215
- /** @type {Array.<string>} */
59192
+ /** @type {Array<string>} */
59216
59193
  // @ts-expect-error Assume array.
59217
59194
  const value = element.properties.className || []
59218
59195
  let index = -1
@@ -59323,7 +59300,7 @@ const type = zwitch('type', {
59323
59300
  * @param {Selectors|RuleSet|Rule} query
59324
59301
  * @param {HastNode|undefined} node
59325
59302
  * @param {SelectState} state
59326
- * @returns {Array.<Element>}
59303
+ * @returns {Array<Element>}
59327
59304
  */
59328
59305
  function any_any(query, node, state) {
59329
59306
  // @ts-expect-error zwitch types are off.
@@ -59334,7 +59311,7 @@ function any_any(query, node, state) {
59334
59311
  * @param {Selectors} query
59335
59312
  * @param {HastNode} node
59336
59313
  * @param {SelectState} state
59337
- * @returns {Array.<Element>}
59314
+ * @returns {Array<Element>}
59338
59315
  */
59339
59316
  function selectors(query, node, state) {
59340
59317
  const collector = new Collector(state.one)
@@ -59351,7 +59328,7 @@ function selectors(query, node, state) {
59351
59328
  * @param {RuleSet} query
59352
59329
  * @param {HastNode} node
59353
59330
  * @param {SelectState} state
59354
- * @returns {Array.<Element>}
59331
+ * @returns {Array<Element>}
59355
59332
  */
59356
59333
  function ruleSet(query, node, state) {
59357
59334
  return rule(query.rule, node, state)
@@ -59361,7 +59338,7 @@ function ruleSet(query, node, state) {
59361
59338
  * @param {Rule} query
59362
59339
  * @param {HastNode} tree
59363
59340
  * @param {SelectState} state
59364
- * @returns {Array.<Element>}
59341
+ * @returns {Array<Element>}
59365
59342
  */
59366
59343
  function rule(query, tree, state) {
59367
59344
  const collector = new Collector(state.one)
@@ -59448,7 +59425,7 @@ class Collector {
59448
59425
  * @param {boolean|undefined} [one]
59449
59426
  */
59450
59427
  constructor(one) {
59451
- /** @type {Array.<Element>} */
59428
+ /** @type {Array<Element>} */
59452
59429
  this.result = []
59453
59430
  /** @type {boolean|undefined} */
59454
59431
  this.one = one
@@ -59459,7 +59436,7 @@ class Collector {
59459
59436
  /**
59460
59437
  * Append nodes to array, filtering out duplicates.
59461
59438
  *
59462
- * @param {Array.<Element>} elements
59439
+ * @param {Array<Element>} elements
59463
59440
  */
59464
59441
  collectAll(elements) {
59465
59442
  let index = -1
@@ -59488,8 +59465,260 @@ class Collector {
59488
59465
 
59489
59466
  // EXTERNAL MODULE: ./node_modules/css-selector-parser/lib/index.js
59490
59467
  var css_selector_parser_lib = __webpack_require__(733);
59491
- // EXTERNAL MODULE: ./node_modules/nth-check/lib/index.js
59492
- var nth_check_lib = __webpack_require__(483);
59468
+ ;// CONCATENATED MODULE: ./node_modules/nth-check/lib/esm/parse.js
59469
+ // Following http://www.w3.org/TR/css3-selectors/#nth-child-pseudo
59470
+ // Whitespace as per https://www.w3.org/TR/selectors-3/#lex is " \t\r\n\f"
59471
+ const parse_whitespace = new Set([9, 10, 12, 13, 32]);
59472
+ const ZERO = "0".charCodeAt(0);
59473
+ const NINE = "9".charCodeAt(0);
59474
+ /**
59475
+ * Parses an expression.
59476
+ *
59477
+ * @throws An `Error` if parsing fails.
59478
+ * @returns An array containing the integer step size and the integer offset of the nth rule.
59479
+ * @example nthCheck.parse("2n+3"); // returns [2, 3]
59480
+ */
59481
+ function esm_parse_parse(formula) {
59482
+ formula = formula.trim().toLowerCase();
59483
+ if (formula === "even") {
59484
+ return [2, 0];
59485
+ }
59486
+ else if (formula === "odd") {
59487
+ return [2, 1];
59488
+ }
59489
+ // Parse [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]?
59490
+ let idx = 0;
59491
+ let a = 0;
59492
+ let sign = readSign();
59493
+ let number = readNumber();
59494
+ if (idx < formula.length && formula.charAt(idx) === "n") {
59495
+ idx++;
59496
+ a = sign * (number !== null && number !== void 0 ? number : 1);
59497
+ skipWhitespace();
59498
+ if (idx < formula.length) {
59499
+ sign = readSign();
59500
+ skipWhitespace();
59501
+ number = readNumber();
59502
+ }
59503
+ else {
59504
+ sign = number = 0;
59505
+ }
59506
+ }
59507
+ // Throw if there is anything else
59508
+ if (number === null || idx < formula.length) {
59509
+ throw new Error(`n-th rule couldn't be parsed ('${formula}')`);
59510
+ }
59511
+ return [a, sign * number];
59512
+ function readSign() {
59513
+ if (formula.charAt(idx) === "-") {
59514
+ idx++;
59515
+ return -1;
59516
+ }
59517
+ if (formula.charAt(idx) === "+") {
59518
+ idx++;
59519
+ }
59520
+ return 1;
59521
+ }
59522
+ function readNumber() {
59523
+ const start = idx;
59524
+ let value = 0;
59525
+ while (idx < formula.length &&
59526
+ formula.charCodeAt(idx) >= ZERO &&
59527
+ formula.charCodeAt(idx) <= NINE) {
59528
+ value = value * 10 + (formula.charCodeAt(idx) - ZERO);
59529
+ idx++;
59530
+ }
59531
+ // Return `null` if we didn't read anything.
59532
+ return idx === start ? null : value;
59533
+ }
59534
+ function skipWhitespace() {
59535
+ while (idx < formula.length &&
59536
+ parse_whitespace.has(formula.charCodeAt(idx))) {
59537
+ idx++;
59538
+ }
59539
+ }
59540
+ }
59541
+ //# sourceMappingURL=parse.js.map
59542
+ // EXTERNAL MODULE: ./node_modules/boolbase/index.js
59543
+ var boolbase = __webpack_require__(407);
59544
+ ;// CONCATENATED MODULE: ./node_modules/nth-check/lib/esm/compile.js
59545
+
59546
+ /**
59547
+ * Returns a function that checks if an elements index matches the given rule
59548
+ * highly optimized to return the fastest solution.
59549
+ *
59550
+ * @param parsed A tuple [a, b], as returned by `parse`.
59551
+ * @returns A highly optimized function that returns whether an index matches the nth-check.
59552
+ * @example
59553
+ *
59554
+ * ```js
59555
+ * const check = nthCheck.compile([2, 3]);
59556
+ *
59557
+ * check(0); // `false`
59558
+ * check(1); // `false`
59559
+ * check(2); // `true`
59560
+ * check(3); // `false`
59561
+ * check(4); // `true`
59562
+ * check(5); // `false`
59563
+ * check(6); // `true`
59564
+ * ```
59565
+ */
59566
+ function compile(parsed) {
59567
+ const a = parsed[0];
59568
+ // Subtract 1 from `b`, to convert from one- to zero-indexed.
59569
+ const b = parsed[1] - 1;
59570
+ /*
59571
+ * When `b <= 0`, `a * n` won't be lead to any matches for `a < 0`.
59572
+ * Besides, the specification states that no elements are
59573
+ * matched when `a` and `b` are 0.
59574
+ *
59575
+ * `b < 0` here as we subtracted 1 from `b` above.
59576
+ */
59577
+ if (b < 0 && a <= 0)
59578
+ return boolbase.falseFunc;
59579
+ // When `a` is in the range -1..1, it matches any element (so only `b` is checked).
59580
+ if (a === -1)
59581
+ return (index) => index <= b;
59582
+ if (a === 0)
59583
+ return (index) => index === b;
59584
+ // When `b <= 0` and `a === 1`, they match any element.
59585
+ if (a === 1)
59586
+ return b < 0 ? boolbase.trueFunc : (index) => index >= b;
59587
+ /*
59588
+ * Otherwise, modulo can be used to check if there is a match.
59589
+ *
59590
+ * Modulo doesn't care about the sign, so let's use `a`s absolute value.
59591
+ */
59592
+ const absA = Math.abs(a);
59593
+ // Get `b mod a`, + a if this is negative.
59594
+ const bMod = ((b % absA) + absA) % absA;
59595
+ return a > 1
59596
+ ? (index) => index >= b && index % absA === bMod
59597
+ : (index) => index <= b && index % absA === bMod;
59598
+ }
59599
+ /**
59600
+ * Returns a function that produces a monotonously increasing sequence of indices.
59601
+ *
59602
+ * If the sequence has an end, the returned function will return `null` after
59603
+ * the last index in the sequence.
59604
+ *
59605
+ * @param parsed A tuple [a, b], as returned by `parse`.
59606
+ * @returns A function that produces a sequence of indices.
59607
+ * @example <caption>Always increasing (2n+3)</caption>
59608
+ *
59609
+ * ```js
59610
+ * const gen = nthCheck.generate([2, 3])
59611
+ *
59612
+ * gen() // `1`
59613
+ * gen() // `3`
59614
+ * gen() // `5`
59615
+ * gen() // `8`
59616
+ * gen() // `11`
59617
+ * ```
59618
+ *
59619
+ * @example <caption>With end value (-2n+10)</caption>
59620
+ *
59621
+ * ```js
59622
+ *
59623
+ * const gen = nthCheck.generate([-2, 5]);
59624
+ *
59625
+ * gen() // 0
59626
+ * gen() // 2
59627
+ * gen() // 4
59628
+ * gen() // null
59629
+ * ```
59630
+ */
59631
+ function compile_generate(parsed) {
59632
+ const a = parsed[0];
59633
+ // Subtract 1 from `b`, to convert from one- to zero-indexed.
59634
+ let b = parsed[1] - 1;
59635
+ let n = 0;
59636
+ // Make sure to always return an increasing sequence
59637
+ if (a < 0) {
59638
+ const aPos = -a;
59639
+ // Get `b mod a`
59640
+ const minValue = ((b % aPos) + aPos) % aPos;
59641
+ return () => {
59642
+ const val = minValue + aPos * n++;
59643
+ return val > b ? null : val;
59644
+ };
59645
+ }
59646
+ if (a === 0)
59647
+ return b < 0
59648
+ ? // There are no result — always return `null`
59649
+ () => null
59650
+ : // Return `b` exactly once
59651
+ () => (n++ === 0 ? b : null);
59652
+ if (b < 0) {
59653
+ b += a * Math.ceil(-b / a);
59654
+ }
59655
+ return () => a * n++ + b;
59656
+ }
59657
+ //# sourceMappingURL=compile.js.map
59658
+ ;// CONCATENATED MODULE: ./node_modules/nth-check/lib/esm/index.js
59659
+
59660
+
59661
+
59662
+ /**
59663
+ * Parses and compiles a formula to a highly optimized function.
59664
+ * Combination of {@link parse} and {@link compile}.
59665
+ *
59666
+ * If the formula doesn't match any elements,
59667
+ * it returns [`boolbase`](https://github.com/fb55/boolbase)'s `falseFunc`.
59668
+ * Otherwise, a function accepting an _index_ is returned, which returns
59669
+ * whether or not the passed _index_ matches the formula.
59670
+ *
59671
+ * Note: The nth-rule starts counting at `1`, the returned function at `0`.
59672
+ *
59673
+ * @param formula The formula to compile.
59674
+ * @example
59675
+ * const check = nthCheck("2n+3");
59676
+ *
59677
+ * check(0); // `false`
59678
+ * check(1); // `false`
59679
+ * check(2); // `true`
59680
+ * check(3); // `false`
59681
+ * check(4); // `true`
59682
+ * check(5); // `false`
59683
+ * check(6); // `true`
59684
+ */
59685
+ function nthCheck(formula) {
59686
+ return compile(esm_parse_parse(formula));
59687
+ }
59688
+ /**
59689
+ * Parses and compiles a formula to a generator that produces a sequence of indices.
59690
+ * Combination of {@link parse} and {@link generate}.
59691
+ *
59692
+ * @param formula The formula to compile.
59693
+ * @returns A function that produces a sequence of indices.
59694
+ * @example <caption>Always increasing</caption>
59695
+ *
59696
+ * ```js
59697
+ * const gen = nthCheck.sequence('2n+3')
59698
+ *
59699
+ * gen() // `1`
59700
+ * gen() // `3`
59701
+ * gen() // `5`
59702
+ * gen() // `8`
59703
+ * gen() // `11`
59704
+ * ```
59705
+ *
59706
+ * @example <caption>With end value</caption>
59707
+ *
59708
+ * ```js
59709
+ *
59710
+ * const gen = nthCheck.sequence('-2n+5');
59711
+ *
59712
+ * gen() // 0
59713
+ * gen() // 2
59714
+ * gen() // 4
59715
+ * gen() // null
59716
+ * ```
59717
+ */
59718
+ function sequence(formula) {
59719
+ return generate(parse(formula));
59720
+ }
59721
+ //# sourceMappingURL=index.js.map
59493
59722
  ;// CONCATENATED MODULE: ./node_modules/hast-util-select/lib/parse.js
59494
59723
  /**
59495
59724
  * @typedef {import('./types.js').Selector} Selector
@@ -59506,7 +59735,7 @@ var nth_check_lib = __webpack_require__(483);
59506
59735
 
59507
59736
  /** @type {import('nth-check').default} */
59508
59737
  // @ts-expect-error
59509
- const nthCheck = nth_check_lib/* default */.ZP
59738
+ const parse_nthCheck = nthCheck["default"] || nthCheck
59510
59739
 
59511
59740
  const nth = new Set([
59512
59741
  'nth-child',
@@ -59518,7 +59747,7 @@ const nth = new Set([
59518
59747
  const parse_parser = new css_selector_parser_lib/* CssSelectorParser */.N()
59519
59748
 
59520
59749
  // @ts-expect-error: hush.
59521
- const compile = zwitch('type', {handlers: {selectors: parse_selectors, ruleSet: parse_ruleSet, rule: parse_rule}})
59750
+ const parse_compile = zwitch('type', {handlers: {selectors: parse_selectors, ruleSet: parse_ruleSet, rule: parse_rule}})
59522
59751
 
59523
59752
  parse_parser.registerAttrEqualityMods('~', '|', '^', '$', '*')
59524
59753
  parse_parser.registerSelectorPseudos('any', 'matches', 'not', 'has')
@@ -59534,7 +59763,7 @@ function lib_parse_parse(selector) {
59534
59763
  }
59535
59764
 
59536
59765
  // @ts-expect-error types are wrong.
59537
- return compile(parse_parser.parse(selector))
59766
+ return parse_compile(parse_parser.parse(selector))
59538
59767
  }
59539
59768
 
59540
59769
  /**
@@ -59545,7 +59774,7 @@ function parse_selectors(query) {
59545
59774
  let index = -1
59546
59775
 
59547
59776
  while (++index < query.selectors.length) {
59548
- compile(query.selectors[index])
59777
+ parse_compile(query.selectors[index])
59549
59778
  }
59550
59779
 
59551
59780
  return query
@@ -59572,13 +59801,13 @@ function parse_rule(query) {
59572
59801
 
59573
59802
  if (nth.has(pseudo.name)) {
59574
59803
  // @ts-expect-error Patch a non-primitive type.
59575
- pseudo.value = nthCheck(pseudo.value)
59804
+ pseudo.value = parse_nthCheck(pseudo.value)
59576
59805
  // @ts-expect-error Patch a non-primitive type.
59577
59806
  pseudo.valueType = 'function'
59578
59807
  }
59579
59808
  }
59580
59809
 
59581
- compile(query.rule)
59810
+ parse_compile(query.rule)
59582
59811
 
59583
59812
  return query
59584
59813
  }
@@ -59619,7 +59848,7 @@ function hast_util_select_select(selector, node, space) {
59619
59848
  * @param {string} selector
59620
59849
  * @param {HastNode} [node]
59621
59850
  * @param {Space} [space]
59622
- * @returns {Array.<Element>}
59851
+ * @returns {Array<Element>}
59623
59852
  */
59624
59853
  function selectAll(selector, node, space) {
59625
59854
  return any_any(lib_parse_parse(selector), node, {space})
@@ -62037,14 +62266,14 @@ var DragBar_DragBar=function DragBar(props){var _ref=props||{},prefixCls=_ref.pr
62037
62266
  // extracted by mini-css-extract-plugin
62038
62267
  /* harmony default export */ const src = ({});
62039
62268
  ;// CONCATENATED MODULE: ./src/Editor.tsx
62040
- var Editor_excluded=["prefixCls","className","value","commands","commandsFilter","extraCommands","height","toolbarHeight","enableScroll","visiableDragbar","highlightEnable","preview","fullscreen","overflow","previewOptions","textareaProps","maxHeight","minHeight","autoFocus","tabSize","defaultTabEnable","onChange","onHeightChange","hideToolbar","toolbarBottom","renderTextarea"];function setGroupPopFalse(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};Object.keys(data).forEach(function(keyname){data[keyname]=false;});return data;}var InternalMDEditor=function InternalMDEditor(props,ref){var _ref=props||{},_ref$prefixCls=_ref.prefixCls,prefixCls=_ref$prefixCls===void 0?'w-md-editor':_ref$prefixCls,className=_ref.className,propsValue=_ref.value,_ref$commands=_ref.commands,commands=_ref$commands===void 0?commands_getCommands():_ref$commands,commandsFilter=_ref.commandsFilter,_ref$extraCommands=_ref.extraCommands,extraCommands=_ref$extraCommands===void 0?getExtraCommands():_ref$extraCommands,_ref$height=_ref.height,height=_ref$height===void 0?200:_ref$height,_ref$toolbarHeight=_ref.toolbarHeight,toolbarHeight=_ref$toolbarHeight===void 0?29:_ref$toolbarHeight,_ref$enableScroll=_ref.enableScroll,enableScroll=_ref$enableScroll===void 0?true:_ref$enableScroll,_ref$visiableDragbar=_ref.visiableDragbar,visiableDragbar=_ref$visiableDragbar===void 0?true:_ref$visiableDragbar,_ref$highlightEnable=_ref.highlightEnable,highlightEnable=_ref$highlightEnable===void 0?true:_ref$highlightEnable,_ref$preview=_ref.preview,previewType=_ref$preview===void 0?'live':_ref$preview,_ref$fullscreen=_ref.fullscreen,fullscreen=_ref$fullscreen===void 0?false:_ref$fullscreen,_ref$overflow=_ref.overflow,overflow=_ref$overflow===void 0?true:_ref$overflow,_ref$previewOptions=_ref.previewOptions,previewOptions=_ref$previewOptions===void 0?{}:_ref$previewOptions,textareaProps=_ref.textareaProps,_ref$maxHeight=_ref.maxHeight,maxHeight=_ref$maxHeight===void 0?1200:_ref$maxHeight,_ref$minHeight=_ref.minHeight,minHeight=_ref$minHeight===void 0?100:_ref$minHeight,autoFocus=_ref.autoFocus,_ref$tabSize=_ref.tabSize,tabSize=_ref$tabSize===void 0?2:_ref$tabSize,_ref$defaultTabEnable=_ref.defaultTabEnable,defaultTabEnable=_ref$defaultTabEnable===void 0?false:_ref$defaultTabEnable,_onChange=_ref.onChange,onHeightChange=_ref.onHeightChange,hideToolbar=_ref.hideToolbar,_ref$toolbarBottom=_ref.toolbarBottom,toolbarBottom=_ref$toolbarBottom===void 0?false:_ref$toolbarBottom,renderTextarea=_ref.renderTextarea,other=_objectWithoutProperties(_ref,Editor_excluded);var cmds=commands.map(function(item){return commandsFilter?commandsFilter(item,false):item;}).filter(Boolean);var extraCmds=extraCommands.map(function(item){return commandsFilter?commandsFilter(item,true):item;}).filter(Boolean);var _useReducer=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useReducer)(reducer,{markdown:propsValue,preview:previewType,height:height,highlightEnable:highlightEnable,tabSize:tabSize,defaultTabEnable:defaultTabEnable,scrollTop:0,scrollTopPreview:0,commands:cmds,extraCommands:extraCmds,fullscreen:fullscreen,barPopup:{}}),_useReducer2=_slicedToArray(_useReducer,2),state=_useReducer2[0],dispatch=_useReducer2[1];var container=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var previewRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var enableScrollRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(enableScroll);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(ref,function(){return _objectSpread2({},state);});(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return enableScrollRef.current=enableScroll;},[enableScroll]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){var stateInit={};if(container.current){stateInit.container=container.current||undefined;}stateInit.markdown=propsValue||'';stateInit.barPopup={};if(dispatch){dispatch(_objectSpread2(_objectSpread2({},state),stateInit));}// eslint-disable-next-line react-hooks/exhaustive-deps
62269
+ var Editor_excluded=["prefixCls","className","value","commands","commandsFilter","extraCommands","height","toolbarHeight","enableScroll","visibleDragbar","highlightEnable","preview","fullscreen","overflow","previewOptions","textareaProps","maxHeight","minHeight","autoFocus","tabSize","defaultTabEnable","onChange","onHeightChange","hideToolbar","toolbarBottom","renderTextarea"];function setGroupPopFalse(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};Object.keys(data).forEach(function(keyname){data[keyname]=false;});return data;}var InternalMDEditor=function InternalMDEditor(props,ref){var _ref=props||{},_ref$prefixCls=_ref.prefixCls,prefixCls=_ref$prefixCls===void 0?'w-md-editor':_ref$prefixCls,className=_ref.className,propsValue=_ref.value,_ref$commands=_ref.commands,commands=_ref$commands===void 0?commands_getCommands():_ref$commands,commandsFilter=_ref.commandsFilter,_ref$extraCommands=_ref.extraCommands,extraCommands=_ref$extraCommands===void 0?getExtraCommands():_ref$extraCommands,_ref$height=_ref.height,height=_ref$height===void 0?200:_ref$height,_ref$toolbarHeight=_ref.toolbarHeight,toolbarHeight=_ref$toolbarHeight===void 0?29:_ref$toolbarHeight,_ref$enableScroll=_ref.enableScroll,enableScroll=_ref$enableScroll===void 0?true:_ref$enableScroll,_ref$visibleDragbar=_ref.visibleDragbar,visibleDragbar=_ref$visibleDragbar===void 0?true:_ref$visibleDragbar,_ref$highlightEnable=_ref.highlightEnable,highlightEnable=_ref$highlightEnable===void 0?true:_ref$highlightEnable,_ref$preview=_ref.preview,previewType=_ref$preview===void 0?'live':_ref$preview,_ref$fullscreen=_ref.fullscreen,fullscreen=_ref$fullscreen===void 0?false:_ref$fullscreen,_ref$overflow=_ref.overflow,overflow=_ref$overflow===void 0?true:_ref$overflow,_ref$previewOptions=_ref.previewOptions,previewOptions=_ref$previewOptions===void 0?{}:_ref$previewOptions,textareaProps=_ref.textareaProps,_ref$maxHeight=_ref.maxHeight,maxHeight=_ref$maxHeight===void 0?1200:_ref$maxHeight,_ref$minHeight=_ref.minHeight,minHeight=_ref$minHeight===void 0?100:_ref$minHeight,autoFocus=_ref.autoFocus,_ref$tabSize=_ref.tabSize,tabSize=_ref$tabSize===void 0?2:_ref$tabSize,_ref$defaultTabEnable=_ref.defaultTabEnable,defaultTabEnable=_ref$defaultTabEnable===void 0?false:_ref$defaultTabEnable,_onChange=_ref.onChange,onHeightChange=_ref.onHeightChange,hideToolbar=_ref.hideToolbar,_ref$toolbarBottom=_ref.toolbarBottom,toolbarBottom=_ref$toolbarBottom===void 0?false:_ref$toolbarBottom,renderTextarea=_ref.renderTextarea,other=_objectWithoutProperties(_ref,Editor_excluded);var cmds=commands.map(function(item){return commandsFilter?commandsFilter(item,false):item;}).filter(Boolean);var extraCmds=extraCommands.map(function(item){return commandsFilter?commandsFilter(item,true):item;}).filter(Boolean);var _useReducer=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useReducer)(reducer,{markdown:propsValue,preview:previewType,height:height,highlightEnable:highlightEnable,tabSize:tabSize,defaultTabEnable:defaultTabEnable,scrollTop:0,scrollTopPreview:0,commands:cmds,extraCommands:extraCmds,fullscreen:fullscreen,barPopup:{}}),_useReducer2=_slicedToArray(_useReducer,2),state=_useReducer2[0],dispatch=_useReducer2[1];var container=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var previewRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var enableScrollRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(enableScroll);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(ref,function(){return _objectSpread2({},state);});(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return enableScrollRef.current=enableScroll;},[enableScroll]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){var stateInit={};if(container.current){stateInit.container=container.current||undefined;}stateInit.markdown=propsValue||'';stateInit.barPopup={};if(dispatch){dispatch(_objectSpread2(_objectSpread2({},state),stateInit));}// eslint-disable-next-line react-hooks/exhaustive-deps
62041
62270
  },[]);var cls=[className,'wmde-markdown-var',prefixCls,state.preview?"".concat(prefixCls,"-show-").concat(state.preview):null,state.fullscreen?"".concat(prefixCls,"-fullscreen"):null].filter(Boolean).join(' ').trim();(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return propsValue!==state.markdown&&dispatch({markdown:propsValue||''});},[propsValue,state.markdown]);// eslint-disable-next-line react-hooks/exhaustive-deps
62042
62271
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return previewType!==state.preview&&dispatch({preview:previewType});},[previewType]);// eslint-disable-next-line react-hooks/exhaustive-deps
62043
62272
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return tabSize!==state.tabSize&&dispatch({tabSize:tabSize});},[tabSize]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return highlightEnable!==state.highlightEnable&&dispatch({highlightEnable:highlightEnable});},// eslint-disable-next-line react-hooks/exhaustive-deps
62044
62273
  [highlightEnable]);// eslint-disable-next-line react-hooks/exhaustive-deps
62045
62274
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return autoFocus!==state.autoFocus&&dispatch({autoFocus:autoFocus});},[autoFocus]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return fullscreen!==state.fullscreen&&dispatch({fullscreen:fullscreen});},// eslint-disable-next-line react-hooks/exhaustive-deps
62046
62275
  [fullscreen]);// eslint-disable-next-line react-hooks/exhaustive-deps
62047
- (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return height!==state.height&&dispatch({height:height});},[height]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return height!==state.height&&onHeightChange&&onHeightChange(state.height,height,state);},[height,onHeightChange,state]);var textareaDomRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)();var active=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)('preview');var initScroll=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){textareaDomRef.current=state.textareaWarp;if(state.textareaWarp){state.textareaWarp.addEventListener('mouseover',function(){active.current='text';});state.textareaWarp.addEventListener('mouseleave',function(){active.current='preview';});}},[state.textareaWarp]);var handleScroll=function handleScroll(e,type){if(!enableScrollRef.current)return;var textareaDom=textareaDomRef.current;var previewDom=previewRef.current?previewRef.current.mdp.current:undefined;if(!initScroll.current){active.current=type;initScroll.current=true;}if(textareaDom&&previewDom){var scale=(textareaDom.scrollHeight-textareaDom.offsetHeight)/(previewDom.scrollHeight-previewDom.offsetHeight);if(e.target===textareaDom&&active.current==='text'){previewDom.scrollTop=textareaDom.scrollTop/scale;}if(e.target===previewDom&&active.current==='preview'){textareaDom.scrollTop=previewDom.scrollTop*scale;}var scrollTop=0;if(active.current==='text'){scrollTop=textareaDom.scrollTop||0;}else if(active.current==='preview'){scrollTop=previewDom.scrollTop||0;}dispatch({scrollTop:scrollTop});}};var mdPreview=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return/*#__PURE__*/(0,jsx_runtime.jsx)(esm,_objectSpread2(_objectSpread2({},previewOptions),{},{onScroll:function onScroll(e){return handleScroll(e,'preview');},ref:previewRef,source:state.markdown||'',className:"".concat(prefixCls,"-preview ").concat(previewOptions.className||'')}));},[prefixCls,previewOptions,state.markdown]);return/*#__PURE__*/(0,jsx_runtime.jsx)(EditorContext.Provider,{value:_objectSpread2(_objectSpread2({},state),{},{dispatch:dispatch}),children:/*#__PURE__*/(0,jsx_runtime.jsxs)("div",_objectSpread2(_objectSpread2({ref:container,className:cls},other),{},{onClick:function onClick(){dispatch({barPopup:_objectSpread2({},setGroupPopFalse(state.barPopup))});},style:_objectSpread2(_objectSpread2({},other.style),{},{height:state.fullscreen?'100%':hideToolbar?Number(state.height)-toolbarHeight:state.height}),children:[!hideToolbar&&!toolbarBottom&&/*#__PURE__*/(0,jsx_runtime.jsx)(Toolbar_Toolbar,{prefixCls:prefixCls,height:toolbarHeight,overflow:overflow,toolbarBottom:toolbarBottom}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{className:"".concat(prefixCls,"-content"),style:{height:state.fullscreen?"calc(100% - ".concat(toolbarHeight,"px)"):Number(state.height)-toolbarHeight},children:[/(edit|live)/.test(state.preview||'')&&/*#__PURE__*/(0,jsx_runtime.jsx)(TextArea_TextArea,_objectSpread2(_objectSpread2({className:"".concat(prefixCls,"-input"),prefixCls:prefixCls,autoFocus:autoFocus},textareaProps),{},{onChange:function onChange(evn){_onChange&&_onChange(evn.target.value,evn,state);if(textareaProps&&textareaProps.onChange){textareaProps.onChange(evn);}},renderTextarea:renderTextarea,onScroll:function onScroll(e){return handleScroll(e,'text');}})),/(live|preview)/.test(state.preview||'')&&mdPreview]}),visiableDragbar&&!state.fullscreen&&/*#__PURE__*/(0,jsx_runtime.jsx)(components_DragBar,{prefixCls:prefixCls,height:state.height,maxHeight:maxHeight,minHeight:minHeight,onChange:function onChange(newHeight){dispatch({height:newHeight});}}),!hideToolbar&&toolbarBottom&&/*#__PURE__*/(0,jsx_runtime.jsx)(Toolbar_Toolbar,{prefixCls:prefixCls,height:toolbarHeight,overflow:overflow,toolbarBottom:toolbarBottom})]}))});};var mdEditor=/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().forwardRef(InternalMDEditor);mdEditor.Markdown=esm;/* harmony default export */ const Editor = (mdEditor);
62276
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return height!==state.height&&dispatch({height:height});},[height]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return height!==state.height&&onHeightChange&&onHeightChange(state.height,height,state);},[height,onHeightChange,state]);var textareaDomRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)();var active=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)('preview');var initScroll=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){textareaDomRef.current=state.textareaWarp;if(state.textareaWarp){state.textareaWarp.addEventListener('mouseover',function(){active.current='text';});state.textareaWarp.addEventListener('mouseleave',function(){active.current='preview';});}},[state.textareaWarp]);var handleScroll=function handleScroll(e,type){if(!enableScrollRef.current)return;var textareaDom=textareaDomRef.current;var previewDom=previewRef.current?previewRef.current.mdp.current:undefined;if(!initScroll.current){active.current=type;initScroll.current=true;}if(textareaDom&&previewDom){var scale=(textareaDom.scrollHeight-textareaDom.offsetHeight)/(previewDom.scrollHeight-previewDom.offsetHeight);if(e.target===textareaDom&&active.current==='text'){previewDom.scrollTop=textareaDom.scrollTop/scale;}if(e.target===previewDom&&active.current==='preview'){textareaDom.scrollTop=previewDom.scrollTop*scale;}var scrollTop=0;if(active.current==='text'){scrollTop=textareaDom.scrollTop||0;}else if(active.current==='preview'){scrollTop=previewDom.scrollTop||0;}dispatch({scrollTop:scrollTop});}};var mdPreview=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return/*#__PURE__*/(0,jsx_runtime.jsx)(esm,_objectSpread2(_objectSpread2({},previewOptions),{},{onScroll:function onScroll(e){return handleScroll(e,'preview');},ref:previewRef,source:state.markdown||'',className:"".concat(prefixCls,"-preview ").concat(previewOptions.className||'')}));},[prefixCls,previewOptions,state.markdown]);return/*#__PURE__*/(0,jsx_runtime.jsx)(EditorContext.Provider,{value:_objectSpread2(_objectSpread2({},state),{},{dispatch:dispatch}),children:/*#__PURE__*/(0,jsx_runtime.jsxs)("div",_objectSpread2(_objectSpread2({ref:container,className:cls},other),{},{onClick:function onClick(){dispatch({barPopup:_objectSpread2({},setGroupPopFalse(state.barPopup))});},style:_objectSpread2(_objectSpread2({},other.style),{},{height:state.fullscreen?'100%':hideToolbar?Number(state.height)-toolbarHeight:state.height}),children:[!hideToolbar&&!toolbarBottom&&/*#__PURE__*/(0,jsx_runtime.jsx)(Toolbar_Toolbar,{prefixCls:prefixCls,height:toolbarHeight,overflow:overflow,toolbarBottom:toolbarBottom}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{className:"".concat(prefixCls,"-content"),style:{height:state.fullscreen?"calc(100% - ".concat(toolbarHeight,"px)"):Number(state.height)-toolbarHeight},children:[/(edit|live)/.test(state.preview||'')&&/*#__PURE__*/(0,jsx_runtime.jsx)(TextArea_TextArea,_objectSpread2(_objectSpread2({className:"".concat(prefixCls,"-input"),prefixCls:prefixCls,autoFocus:autoFocus},textareaProps),{},{onChange:function onChange(evn){_onChange&&_onChange(evn.target.value,evn,state);if(textareaProps&&textareaProps.onChange){textareaProps.onChange(evn);}},renderTextarea:renderTextarea,onScroll:function onScroll(e){return handleScroll(e,'text');}})),/(live|preview)/.test(state.preview||'')&&mdPreview]}),visibleDragbar&&!state.fullscreen&&/*#__PURE__*/(0,jsx_runtime.jsx)(components_DragBar,{prefixCls:prefixCls,height:state.height,maxHeight:maxHeight,minHeight:minHeight,onChange:function onChange(newHeight){dispatch({height:newHeight});}}),!hideToolbar&&toolbarBottom&&/*#__PURE__*/(0,jsx_runtime.jsx)(Toolbar_Toolbar,{prefixCls:prefixCls,height:toolbarHeight,overflow:overflow,toolbarBottom:toolbarBottom})]}))});};var mdEditor=/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().forwardRef(InternalMDEditor);mdEditor.Markdown=esm;/* harmony default export */ const Editor = (mdEditor);
62048
62277
  ;// CONCATENATED MODULE: ./src/index.tsx
62049
62278
  /* harmony default export */ const src_0 = (Editor);
62050
62279
  })();