@uiw/react-md-editor 3.12.3 → 3.14.1

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.
Files changed (49) hide show
  1. package/README.md +9 -7
  2. package/dist/mdeditor.css +5 -10
  3. package/dist/mdeditor.js +1316 -1617
  4. package/dist/mdeditor.min.css +1 -1
  5. package/dist/mdeditor.min.js +1 -1
  6. package/dist/mdeditor.min.js.LICENSE.txt +0 -9
  7. package/esm/Editor.d.ts +8 -2
  8. package/esm/Editor.js +12 -5
  9. package/esm/Editor.js.map +4 -2
  10. package/esm/components/Toolbar/index.css +5 -0
  11. package/esm/components/Toolbar/index.d.ts +1 -0
  12. package/esm/components/Toolbar/index.js +3 -1
  13. package/esm/components/Toolbar/index.js.map +5 -3
  14. package/esm/components/Toolbar/index.less +5 -0
  15. package/lib/Context.js.map +1 -1
  16. package/lib/Editor.d.ts +8 -2
  17. package/lib/Editor.js +14 -6
  18. package/lib/Editor.js.map +11 -2
  19. package/lib/commands/bold.js.map +2 -1
  20. package/lib/commands/code.js.map +4 -1
  21. package/lib/commands/comment.js.map +2 -1
  22. package/lib/commands/image.js.map +2 -1
  23. package/lib/commands/index.js.map +2 -1
  24. package/lib/commands/italic.js.map +2 -1
  25. package/lib/commands/link.js.map +2 -1
  26. package/lib/commands/list.js.map +4 -1
  27. package/lib/commands/quote.js.map +4 -1
  28. package/lib/commands/strikeThrough.js.map +2 -1
  29. package/lib/commands/title1.js.map +2 -1
  30. package/lib/commands/title2.js.map +2 -1
  31. package/lib/commands/title3.js.map +2 -1
  32. package/lib/commands/title4.js.map +2 -1
  33. package/lib/commands/title5.js.map +2 -1
  34. package/lib/commands/title6.js.map +2 -1
  35. package/lib/components/DragBar/index.js.map +5 -2
  36. package/lib/components/TextArea/Markdown.js.map +5 -1
  37. package/lib/components/TextArea/Textarea.js.map +5 -1
  38. package/lib/components/TextArea/handleKeyDown.js.map +3 -1
  39. package/lib/components/TextArea/index.js.map +3 -2
  40. package/lib/components/Toolbar/Child.js.map +3 -1
  41. package/lib/components/Toolbar/index.d.ts +1 -0
  42. package/lib/components/Toolbar/index.js +3 -1
  43. package/lib/components/Toolbar/index.js.map +8 -3
  44. package/lib/components/Toolbar/index.less +5 -0
  45. package/markdown-editor.css +5 -0
  46. package/package.json +2 -2
  47. package/src/Editor.tsx +17 -5
  48. package/src/components/Toolbar/index.less +5 -0
  49. package/src/components/Toolbar/index.tsx +4 -2
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:
@@ -9504,1276 +9314,6 @@ Mixin.install = function(host, Ctor, opts) {
9504
9314
  module.exports = Mixin;
9505
9315
 
9506
9316
 
9507
- /***/ }),
9508
-
9509
- /***/ 975:
9510
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
9511
-
9512
- /// <reference lib="WebWorker"/>
9513
-
9514
- var _self = (typeof window !== 'undefined')
9515
- ? window // if in browser
9516
- : (
9517
- (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
9518
- ? self // if in worker
9519
- : {} // if in node js
9520
- );
9521
-
9522
- /**
9523
- * Prism: Lightweight, robust, elegant syntax highlighting
9524
- *
9525
- * @license MIT <https://opensource.org/licenses/MIT>
9526
- * @author Lea Verou <https://lea.verou.me>
9527
- * @namespace
9528
- * @public
9529
- */
9530
- var Prism = (function (_self) {
9531
-
9532
- // Private helper vars
9533
- var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
9534
- var uniqueId = 0;
9535
-
9536
- // The grammar object for plaintext
9537
- var plainTextGrammar = {};
9538
-
9539
-
9540
- var _ = {
9541
- /**
9542
- * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
9543
- * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
9544
- * additional languages or plugins yourself.
9545
- *
9546
- * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
9547
- *
9548
- * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
9549
- * empty Prism object into the global scope before loading the Prism script like this:
9550
- *
9551
- * ```js
9552
- * window.Prism = window.Prism || {};
9553
- * Prism.manual = true;
9554
- * // add a new <script> to load Prism's script
9555
- * ```
9556
- *
9557
- * @default false
9558
- * @type {boolean}
9559
- * @memberof Prism
9560
- * @public
9561
- */
9562
- manual: _self.Prism && _self.Prism.manual,
9563
- /**
9564
- * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
9565
- * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
9566
- * own worker, you don't want it to do this.
9567
- *
9568
- * By setting this value to `true`, Prism will not add its own listeners to the worker.
9569
- *
9570
- * You obviously have to change this value before Prism executes. To do this, you can add an
9571
- * empty Prism object into the global scope before loading the Prism script like this:
9572
- *
9573
- * ```js
9574
- * window.Prism = window.Prism || {};
9575
- * Prism.disableWorkerMessageHandler = true;
9576
- * // Load Prism's script
9577
- * ```
9578
- *
9579
- * @default false
9580
- * @type {boolean}
9581
- * @memberof Prism
9582
- * @public
9583
- */
9584
- disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
9585
-
9586
- /**
9587
- * A namespace for utility methods.
9588
- *
9589
- * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
9590
- * change or disappear at any time.
9591
- *
9592
- * @namespace
9593
- * @memberof Prism
9594
- */
9595
- util: {
9596
- encode: function encode(tokens) {
9597
- if (tokens instanceof Token) {
9598
- return new Token(tokens.type, encode(tokens.content), tokens.alias);
9599
- } else if (Array.isArray(tokens)) {
9600
- return tokens.map(encode);
9601
- } else {
9602
- return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
9603
- }
9604
- },
9605
-
9606
- /**
9607
- * Returns the name of the type of the given value.
9608
- *
9609
- * @param {any} o
9610
- * @returns {string}
9611
- * @example
9612
- * type(null) === 'Null'
9613
- * type(undefined) === 'Undefined'
9614
- * type(123) === 'Number'
9615
- * type('foo') === 'String'
9616
- * type(true) === 'Boolean'
9617
- * type([1, 2]) === 'Array'
9618
- * type({}) === 'Object'
9619
- * type(String) === 'Function'
9620
- * type(/abc+/) === 'RegExp'
9621
- */
9622
- type: function (o) {
9623
- return Object.prototype.toString.call(o).slice(8, -1);
9624
- },
9625
-
9626
- /**
9627
- * Returns a unique number for the given object. Later calls will still return the same number.
9628
- *
9629
- * @param {Object} obj
9630
- * @returns {number}
9631
- */
9632
- objId: function (obj) {
9633
- if (!obj['__id']) {
9634
- Object.defineProperty(obj, '__id', { value: ++uniqueId });
9635
- }
9636
- return obj['__id'];
9637
- },
9638
-
9639
- /**
9640
- * Creates a deep clone of the given object.
9641
- *
9642
- * The main intended use of this function is to clone language definitions.
9643
- *
9644
- * @param {T} o
9645
- * @param {Record<number, any>} [visited]
9646
- * @returns {T}
9647
- * @template T
9648
- */
9649
- clone: function deepClone(o, visited) {
9650
- visited = visited || {};
9651
-
9652
- var clone; var id;
9653
- switch (_.util.type(o)) {
9654
- case 'Object':
9655
- id = _.util.objId(o);
9656
- if (visited[id]) {
9657
- return visited[id];
9658
- }
9659
- clone = /** @type {Record<string, any>} */ ({});
9660
- visited[id] = clone;
9661
-
9662
- for (var key in o) {
9663
- if (o.hasOwnProperty(key)) {
9664
- clone[key] = deepClone(o[key], visited);
9665
- }
9666
- }
9667
-
9668
- return /** @type {any} */ (clone);
9669
-
9670
- case 'Array':
9671
- id = _.util.objId(o);
9672
- if (visited[id]) {
9673
- return visited[id];
9674
- }
9675
- clone = [];
9676
- visited[id] = clone;
9677
-
9678
- (/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
9679
- clone[i] = deepClone(v, visited);
9680
- });
9681
-
9682
- return /** @type {any} */ (clone);
9683
-
9684
- default:
9685
- return o;
9686
- }
9687
- },
9688
-
9689
- /**
9690
- * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
9691
- *
9692
- * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
9693
- *
9694
- * @param {Element} element
9695
- * @returns {string}
9696
- */
9697
- getLanguage: function (element) {
9698
- while (element) {
9699
- var m = lang.exec(element.className);
9700
- if (m) {
9701
- return m[1].toLowerCase();
9702
- }
9703
- element = element.parentElement;
9704
- }
9705
- return 'none';
9706
- },
9707
-
9708
- /**
9709
- * Sets the Prism `language-xxxx` class of the given element.
9710
- *
9711
- * @param {Element} element
9712
- * @param {string} language
9713
- * @returns {void}
9714
- */
9715
- setLanguage: function (element, language) {
9716
- // remove all `language-xxxx` classes
9717
- // (this might leave behind a leading space)
9718
- element.className = element.className.replace(RegExp(lang, 'gi'), '');
9719
-
9720
- // add the new `language-xxxx` class
9721
- // (using `classList` will automatically clean up spaces for us)
9722
- element.classList.add('language-' + language);
9723
- },
9724
-
9725
- /**
9726
- * Returns the script element that is currently executing.
9727
- *
9728
- * This does __not__ work for line script element.
9729
- *
9730
- * @returns {HTMLScriptElement | null}
9731
- */
9732
- currentScript: function () {
9733
- if (typeof document === 'undefined') {
9734
- return null;
9735
- }
9736
- if ('currentScript' in document && 1 < 2 /* hack to trip TS' flow analysis */) {
9737
- return /** @type {any} */ (document.currentScript);
9738
- }
9739
-
9740
- // IE11 workaround
9741
- // we'll get the src of the current script by parsing IE11's error stack trace
9742
- // this will not work for inline scripts
9743
-
9744
- try {
9745
- throw new Error();
9746
- } catch (err) {
9747
- // Get file src url from stack. Specifically works with the format of stack traces in IE.
9748
- // A stack will look like this:
9749
- //
9750
- // Error
9751
- // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
9752
- // at Global code (http://localhost/components/prism-core.js:606:1)
9753
-
9754
- var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
9755
- if (src) {
9756
- var scripts = document.getElementsByTagName('script');
9757
- for (var i in scripts) {
9758
- if (scripts[i].src == src) {
9759
- return scripts[i];
9760
- }
9761
- }
9762
- }
9763
- return null;
9764
- }
9765
- },
9766
-
9767
- /**
9768
- * Returns whether a given class is active for `element`.
9769
- *
9770
- * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
9771
- * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
9772
- * given class is just the given class with a `no-` prefix.
9773
- *
9774
- * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
9775
- * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
9776
- * ancestors have the given class or the negated version of it, then the default activation will be returned.
9777
- *
9778
- * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
9779
- * version of it, the class is considered active.
9780
- *
9781
- * @param {Element} element
9782
- * @param {string} className
9783
- * @param {boolean} [defaultActivation=false]
9784
- * @returns {boolean}
9785
- */
9786
- isActive: function (element, className, defaultActivation) {
9787
- var no = 'no-' + className;
9788
-
9789
- while (element) {
9790
- var classList = element.classList;
9791
- if (classList.contains(className)) {
9792
- return true;
9793
- }
9794
- if (classList.contains(no)) {
9795
- return false;
9796
- }
9797
- element = element.parentElement;
9798
- }
9799
- return !!defaultActivation;
9800
- }
9801
- },
9802
-
9803
- /**
9804
- * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
9805
- *
9806
- * @namespace
9807
- * @memberof Prism
9808
- * @public
9809
- */
9810
- languages: {
9811
- /**
9812
- * The grammar for plain, unformatted text.
9813
- */
9814
- plain: plainTextGrammar,
9815
- plaintext: plainTextGrammar,
9816
- text: plainTextGrammar,
9817
- txt: plainTextGrammar,
9818
-
9819
- /**
9820
- * Creates a deep copy of the language with the given id and appends the given tokens.
9821
- *
9822
- * If a token in `redef` also appears in the copied language, then the existing token in the copied language
9823
- * will be overwritten at its original position.
9824
- *
9825
- * ## Best practices
9826
- *
9827
- * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
9828
- * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
9829
- * understand the language definition because, normally, the order of tokens matters in Prism grammars.
9830
- *
9831
- * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
9832
- * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
9833
- *
9834
- * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
9835
- * @param {Grammar} redef The new tokens to append.
9836
- * @returns {Grammar} The new language created.
9837
- * @public
9838
- * @example
9839
- * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
9840
- * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
9841
- * // at its original position
9842
- * 'comment': { ... },
9843
- * // CSS doesn't have a 'color' token, so this token will be appended
9844
- * 'color': /\b(?:red|green|blue)\b/
9845
- * });
9846
- */
9847
- extend: function (id, redef) {
9848
- var lang = _.util.clone(_.languages[id]);
9849
-
9850
- for (var key in redef) {
9851
- lang[key] = redef[key];
9852
- }
9853
-
9854
- return lang;
9855
- },
9856
-
9857
- /**
9858
- * Inserts tokens _before_ another token in a language definition or any other grammar.
9859
- *
9860
- * ## Usage
9861
- *
9862
- * This helper method makes it easy to modify existing languages. For example, the CSS language definition
9863
- * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
9864
- * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
9865
- * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
9866
- * this:
9867
- *
9868
- * ```js
9869
- * Prism.languages.markup.style = {
9870
- * // token
9871
- * };
9872
- * ```
9873
- *
9874
- * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
9875
- * before existing tokens. For the CSS example above, you would use it like this:
9876
- *
9877
- * ```js
9878
- * Prism.languages.insertBefore('markup', 'cdata', {
9879
- * 'style': {
9880
- * // token
9881
- * }
9882
- * });
9883
- * ```
9884
- *
9885
- * ## Special cases
9886
- *
9887
- * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
9888
- * will be ignored.
9889
- *
9890
- * This behavior can be used to insert tokens after `before`:
9891
- *
9892
- * ```js
9893
- * Prism.languages.insertBefore('markup', 'comment', {
9894
- * 'comment': Prism.languages.markup.comment,
9895
- * // tokens after 'comment'
9896
- * });
9897
- * ```
9898
- *
9899
- * ## Limitations
9900
- *
9901
- * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
9902
- * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
9903
- * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
9904
- * deleting properties which is necessary to insert at arbitrary positions.
9905
- *
9906
- * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
9907
- * Instead, it will create a new object and replace all references to the target object with the new one. This
9908
- * can be done without temporarily deleting properties, so the iteration order is well-defined.
9909
- *
9910
- * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
9911
- * you hold the target object in a variable, then the value of the variable will not change.
9912
- *
9913
- * ```js
9914
- * var oldMarkup = Prism.languages.markup;
9915
- * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
9916
- *
9917
- * assert(oldMarkup !== Prism.languages.markup);
9918
- * assert(newMarkup === Prism.languages.markup);
9919
- * ```
9920
- *
9921
- * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
9922
- * object to be modified.
9923
- * @param {string} before The key to insert before.
9924
- * @param {Grammar} insert An object containing the key-value pairs to be inserted.
9925
- * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
9926
- * object to be modified.
9927
- *
9928
- * Defaults to `Prism.languages`.
9929
- * @returns {Grammar} The new grammar object.
9930
- * @public
9931
- */
9932
- insertBefore: function (inside, before, insert, root) {
9933
- root = root || /** @type {any} */ (_.languages);
9934
- var grammar = root[inside];
9935
- /** @type {Grammar} */
9936
- var ret = {};
9937
-
9938
- for (var token in grammar) {
9939
- if (grammar.hasOwnProperty(token)) {
9940
-
9941
- if (token == before) {
9942
- for (var newToken in insert) {
9943
- if (insert.hasOwnProperty(newToken)) {
9944
- ret[newToken] = insert[newToken];
9945
- }
9946
- }
9947
- }
9948
-
9949
- // Do not insert token which also occur in insert. See #1525
9950
- if (!insert.hasOwnProperty(token)) {
9951
- ret[token] = grammar[token];
9952
- }
9953
- }
9954
- }
9955
-
9956
- var old = root[inside];
9957
- root[inside] = ret;
9958
-
9959
- // Update references in other language definitions
9960
- _.languages.DFS(_.languages, function (key, value) {
9961
- if (value === old && key != inside) {
9962
- this[key] = ret;
9963
- }
9964
- });
9965
-
9966
- return ret;
9967
- },
9968
-
9969
- // Traverse a language definition with Depth First Search
9970
- DFS: function DFS(o, callback, type, visited) {
9971
- visited = visited || {};
9972
-
9973
- var objId = _.util.objId;
9974
-
9975
- for (var i in o) {
9976
- if (o.hasOwnProperty(i)) {
9977
- callback.call(o, i, o[i], type || i);
9978
-
9979
- var property = o[i];
9980
- var propertyType = _.util.type(property);
9981
-
9982
- if (propertyType === 'Object' && !visited[objId(property)]) {
9983
- visited[objId(property)] = true;
9984
- DFS(property, callback, null, visited);
9985
- } else if (propertyType === 'Array' && !visited[objId(property)]) {
9986
- visited[objId(property)] = true;
9987
- DFS(property, callback, i, visited);
9988
- }
9989
- }
9990
- }
9991
- }
9992
- },
9993
-
9994
- plugins: {},
9995
-
9996
- /**
9997
- * This is the most high-level function in Prism’s API.
9998
- * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
9999
- * each one of them.
10000
- *
10001
- * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
10002
- *
10003
- * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
10004
- * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
10005
- * @memberof Prism
10006
- * @public
10007
- */
10008
- highlightAll: function (async, callback) {
10009
- _.highlightAllUnder(document, async, callback);
10010
- },
10011
-
10012
- /**
10013
- * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
10014
- * {@link Prism.highlightElement} on each one of them.
10015
- *
10016
- * The following hooks will be run:
10017
- * 1. `before-highlightall`
10018
- * 2. `before-all-elements-highlight`
10019
- * 3. All hooks of {@link Prism.highlightElement} for each element.
10020
- *
10021
- * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
10022
- * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
10023
- * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
10024
- * @memberof Prism
10025
- * @public
10026
- */
10027
- highlightAllUnder: function (container, async, callback) {
10028
- var env = {
10029
- callback: callback,
10030
- container: container,
10031
- selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
10032
- };
10033
-
10034
- _.hooks.run('before-highlightall', env);
10035
-
10036
- env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
10037
-
10038
- _.hooks.run('before-all-elements-highlight', env);
10039
-
10040
- for (var i = 0, element; (element = env.elements[i++]);) {
10041
- _.highlightElement(element, async === true, env.callback);
10042
- }
10043
- },
10044
-
10045
- /**
10046
- * Highlights the code inside a single element.
10047
- *
10048
- * The following hooks will be run:
10049
- * 1. `before-sanity-check`
10050
- * 2. `before-highlight`
10051
- * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
10052
- * 4. `before-insert`
10053
- * 5. `after-highlight`
10054
- * 6. `complete`
10055
- *
10056
- * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
10057
- * the element's language.
10058
- *
10059
- * @param {Element} element The element containing the code.
10060
- * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
10061
- * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
10062
- * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
10063
- * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
10064
- *
10065
- * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
10066
- * asynchronous highlighting to work. You can build your own bundle on the
10067
- * [Download page](https://prismjs.com/download.html).
10068
- * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
10069
- * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
10070
- * @memberof Prism
10071
- * @public
10072
- */
10073
- highlightElement: function (element, async, callback) {
10074
- // Find language
10075
- var language = _.util.getLanguage(element);
10076
- var grammar = _.languages[language];
10077
-
10078
- // Set language on the element, if not present
10079
- _.util.setLanguage(element, language);
10080
-
10081
- // Set language on the parent, for styling
10082
- var parent = element.parentElement;
10083
- if (parent && parent.nodeName.toLowerCase() === 'pre') {
10084
- _.util.setLanguage(parent, language);
10085
- }
10086
-
10087
- var code = element.textContent;
10088
-
10089
- var env = {
10090
- element: element,
10091
- language: language,
10092
- grammar: grammar,
10093
- code: code
10094
- };
10095
-
10096
- function insertHighlightedCode(highlightedCode) {
10097
- env.highlightedCode = highlightedCode;
10098
-
10099
- _.hooks.run('before-insert', env);
10100
-
10101
- env.element.innerHTML = env.highlightedCode;
10102
-
10103
- _.hooks.run('after-highlight', env);
10104
- _.hooks.run('complete', env);
10105
- callback && callback.call(env.element);
10106
- }
10107
-
10108
- _.hooks.run('before-sanity-check', env);
10109
-
10110
- // plugins may change/add the parent/element
10111
- parent = env.element.parentElement;
10112
- if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
10113
- parent.setAttribute('tabindex', '0');
10114
- }
10115
-
10116
- if (!env.code) {
10117
- _.hooks.run('complete', env);
10118
- callback && callback.call(env.element);
10119
- return;
10120
- }
10121
-
10122
- _.hooks.run('before-highlight', env);
10123
-
10124
- if (!env.grammar) {
10125
- insertHighlightedCode(_.util.encode(env.code));
10126
- return;
10127
- }
10128
-
10129
- if (async && _self.Worker) {
10130
- var worker = new Worker(_.filename);
10131
-
10132
- worker.onmessage = function (evt) {
10133
- insertHighlightedCode(evt.data);
10134
- };
10135
-
10136
- worker.postMessage(JSON.stringify({
10137
- language: env.language,
10138
- code: env.code,
10139
- immediateClose: true
10140
- }));
10141
- } else {
10142
- insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
10143
- }
10144
- },
10145
-
10146
- /**
10147
- * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
10148
- * and the language definitions to use, and returns a string with the HTML produced.
10149
- *
10150
- * The following hooks will be run:
10151
- * 1. `before-tokenize`
10152
- * 2. `after-tokenize`
10153
- * 3. `wrap`: On each {@link Token}.
10154
- *
10155
- * @param {string} text A string with the code to be highlighted.
10156
- * @param {Grammar} grammar An object containing the tokens to use.
10157
- *
10158
- * Usually a language definition like `Prism.languages.markup`.
10159
- * @param {string} language The name of the language definition passed to `grammar`.
10160
- * @returns {string} The highlighted HTML.
10161
- * @memberof Prism
10162
- * @public
10163
- * @example
10164
- * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
10165
- */
10166
- highlight: function (text, grammar, language) {
10167
- var env = {
10168
- code: text,
10169
- grammar: grammar,
10170
- language: language
10171
- };
10172
- _.hooks.run('before-tokenize', env);
10173
- if (!env.grammar) {
10174
- throw new Error('The language "' + env.language + '" has no grammar.');
10175
- }
10176
- env.tokens = _.tokenize(env.code, env.grammar);
10177
- _.hooks.run('after-tokenize', env);
10178
- return Token.stringify(_.util.encode(env.tokens), env.language);
10179
- },
10180
-
10181
- /**
10182
- * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
10183
- * and the language definitions to use, and returns an array with the tokenized code.
10184
- *
10185
- * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
10186
- *
10187
- * This method could be useful in other contexts as well, as a very crude parser.
10188
- *
10189
- * @param {string} text A string with the code to be highlighted.
10190
- * @param {Grammar} grammar An object containing the tokens to use.
10191
- *
10192
- * Usually a language definition like `Prism.languages.markup`.
10193
- * @returns {TokenStream} An array of strings and tokens, a token stream.
10194
- * @memberof Prism
10195
- * @public
10196
- * @example
10197
- * let code = `var foo = 0;`;
10198
- * let tokens = Prism.tokenize(code, Prism.languages.javascript);
10199
- * tokens.forEach(token => {
10200
- * if (token instanceof Prism.Token && token.type === 'number') {
10201
- * console.log(`Found numeric literal: ${token.content}`);
10202
- * }
10203
- * });
10204
- */
10205
- tokenize: function (text, grammar) {
10206
- var rest = grammar.rest;
10207
- if (rest) {
10208
- for (var token in rest) {
10209
- grammar[token] = rest[token];
10210
- }
10211
-
10212
- delete grammar.rest;
10213
- }
10214
-
10215
- var tokenList = new LinkedList();
10216
- addAfter(tokenList, tokenList.head, text);
10217
-
10218
- matchGrammar(text, tokenList, grammar, tokenList.head, 0);
10219
-
10220
- return toArray(tokenList);
10221
- },
10222
-
10223
- /**
10224
- * @namespace
10225
- * @memberof Prism
10226
- * @public
10227
- */
10228
- hooks: {
10229
- all: {},
10230
-
10231
- /**
10232
- * Adds the given callback to the list of callbacks for the given hook.
10233
- *
10234
- * The callback will be invoked when the hook it is registered for is run.
10235
- * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
10236
- *
10237
- * One callback function can be registered to multiple hooks and the same hook multiple times.
10238
- *
10239
- * @param {string} name The name of the hook.
10240
- * @param {HookCallback} callback The callback function which is given environment variables.
10241
- * @public
10242
- */
10243
- add: function (name, callback) {
10244
- var hooks = _.hooks.all;
10245
-
10246
- hooks[name] = hooks[name] || [];
10247
-
10248
- hooks[name].push(callback);
10249
- },
10250
-
10251
- /**
10252
- * Runs a hook invoking all registered callbacks with the given environment variables.
10253
- *
10254
- * Callbacks will be invoked synchronously and in the order in which they were registered.
10255
- *
10256
- * @param {string} name The name of the hook.
10257
- * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
10258
- * @public
10259
- */
10260
- run: function (name, env) {
10261
- var callbacks = _.hooks.all[name];
10262
-
10263
- if (!callbacks || !callbacks.length) {
10264
- return;
10265
- }
10266
-
10267
- for (var i = 0, callback; (callback = callbacks[i++]);) {
10268
- callback(env);
10269
- }
10270
- }
10271
- },
10272
-
10273
- Token: Token
10274
- };
10275
- _self.Prism = _;
10276
-
10277
-
10278
- // Typescript note:
10279
- // The following can be used to import the Token type in JSDoc:
10280
- //
10281
- // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
10282
-
10283
- /**
10284
- * Creates a new token.
10285
- *
10286
- * @param {string} type See {@link Token#type type}
10287
- * @param {string | TokenStream} content See {@link Token#content content}
10288
- * @param {string|string[]} [alias] The alias(es) of the token.
10289
- * @param {string} [matchedStr=""] A copy of the full string this token was created from.
10290
- * @class
10291
- * @global
10292
- * @public
10293
- */
10294
- function Token(type, content, alias, matchedStr) {
10295
- /**
10296
- * The type of the token.
10297
- *
10298
- * This is usually the key of a pattern in a {@link Grammar}.
10299
- *
10300
- * @type {string}
10301
- * @see GrammarToken
10302
- * @public
10303
- */
10304
- this.type = type;
10305
- /**
10306
- * The strings or tokens contained by this token.
10307
- *
10308
- * This will be a token stream if the pattern matched also defined an `inside` grammar.
10309
- *
10310
- * @type {string | TokenStream}
10311
- * @public
10312
- */
10313
- this.content = content;
10314
- /**
10315
- * The alias(es) of the token.
10316
- *
10317
- * @type {string|string[]}
10318
- * @see GrammarToken
10319
- * @public
10320
- */
10321
- this.alias = alias;
10322
- // Copy of the full string this token was created from
10323
- this.length = (matchedStr || '').length | 0;
10324
- }
10325
-
10326
- /**
10327
- * A token stream is an array of strings and {@link Token Token} objects.
10328
- *
10329
- * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
10330
- * them.
10331
- *
10332
- * 1. No adjacent strings.
10333
- * 2. No empty strings.
10334
- *
10335
- * The only exception here is the token stream that only contains the empty string and nothing else.
10336
- *
10337
- * @typedef {Array<string | Token>} TokenStream
10338
- * @global
10339
- * @public
10340
- */
10341
-
10342
- /**
10343
- * Converts the given token or token stream to an HTML representation.
10344
- *
10345
- * The following hooks will be run:
10346
- * 1. `wrap`: On each {@link Token}.
10347
- *
10348
- * @param {string | Token | TokenStream} o The token or token stream to be converted.
10349
- * @param {string} language The name of current language.
10350
- * @returns {string} The HTML representation of the token or token stream.
10351
- * @memberof Token
10352
- * @static
10353
- */
10354
- Token.stringify = function stringify(o, language) {
10355
- if (typeof o == 'string') {
10356
- return o;
10357
- }
10358
- if (Array.isArray(o)) {
10359
- var s = '';
10360
- o.forEach(function (e) {
10361
- s += stringify(e, language);
10362
- });
10363
- return s;
10364
- }
10365
-
10366
- var env = {
10367
- type: o.type,
10368
- content: stringify(o.content, language),
10369
- tag: 'span',
10370
- classes: ['token', o.type],
10371
- attributes: {},
10372
- language: language
10373
- };
10374
-
10375
- var aliases = o.alias;
10376
- if (aliases) {
10377
- if (Array.isArray(aliases)) {
10378
- Array.prototype.push.apply(env.classes, aliases);
10379
- } else {
10380
- env.classes.push(aliases);
10381
- }
10382
- }
10383
-
10384
- _.hooks.run('wrap', env);
10385
-
10386
- var attributes = '';
10387
- for (var name in env.attributes) {
10388
- attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
10389
- }
10390
-
10391
- return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
10392
- };
10393
-
10394
- /**
10395
- * @param {RegExp} pattern
10396
- * @param {number} pos
10397
- * @param {string} text
10398
- * @param {boolean} lookbehind
10399
- * @returns {RegExpExecArray | null}
10400
- */
10401
- function matchPattern(pattern, pos, text, lookbehind) {
10402
- pattern.lastIndex = pos;
10403
- var match = pattern.exec(text);
10404
- if (match && lookbehind && match[1]) {
10405
- // change the match to remove the text matched by the Prism lookbehind group
10406
- var lookbehindLength = match[1].length;
10407
- match.index += lookbehindLength;
10408
- match[0] = match[0].slice(lookbehindLength);
10409
- }
10410
- return match;
10411
- }
10412
-
10413
- /**
10414
- * @param {string} text
10415
- * @param {LinkedList<string | Token>} tokenList
10416
- * @param {any} grammar
10417
- * @param {LinkedListNode<string | Token>} startNode
10418
- * @param {number} startPos
10419
- * @param {RematchOptions} [rematch]
10420
- * @returns {void}
10421
- * @private
10422
- *
10423
- * @typedef RematchOptions
10424
- * @property {string} cause
10425
- * @property {number} reach
10426
- */
10427
- function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
10428
- for (var token in grammar) {
10429
- if (!grammar.hasOwnProperty(token) || !grammar[token]) {
10430
- continue;
10431
- }
10432
-
10433
- var patterns = grammar[token];
10434
- patterns = Array.isArray(patterns) ? patterns : [patterns];
10435
-
10436
- for (var j = 0; j < patterns.length; ++j) {
10437
- if (rematch && rematch.cause == token + ',' + j) {
10438
- return;
10439
- }
10440
-
10441
- var patternObj = patterns[j];
10442
- var inside = patternObj.inside;
10443
- var lookbehind = !!patternObj.lookbehind;
10444
- var greedy = !!patternObj.greedy;
10445
- var alias = patternObj.alias;
10446
-
10447
- if (greedy && !patternObj.pattern.global) {
10448
- // Without the global flag, lastIndex won't work
10449
- var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
10450
- patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
10451
- }
10452
-
10453
- /** @type {RegExp} */
10454
- var pattern = patternObj.pattern || patternObj;
10455
-
10456
- for ( // iterate the token list and keep track of the current token/string position
10457
- var currentNode = startNode.next, pos = startPos;
10458
- currentNode !== tokenList.tail;
10459
- pos += currentNode.value.length, currentNode = currentNode.next
10460
- ) {
10461
-
10462
- if (rematch && pos >= rematch.reach) {
10463
- break;
10464
- }
10465
-
10466
- var str = currentNode.value;
10467
-
10468
- if (tokenList.length > text.length) {
10469
- // Something went terribly wrong, ABORT, ABORT!
10470
- return;
10471
- }
10472
-
10473
- if (str instanceof Token) {
10474
- continue;
10475
- }
10476
-
10477
- var removeCount = 1; // this is the to parameter of removeBetween
10478
- var match;
10479
-
10480
- if (greedy) {
10481
- match = matchPattern(pattern, pos, text, lookbehind);
10482
- if (!match || match.index >= text.length) {
10483
- break;
10484
- }
10485
-
10486
- var from = match.index;
10487
- var to = match.index + match[0].length;
10488
- var p = pos;
10489
-
10490
- // find the node that contains the match
10491
- p += currentNode.value.length;
10492
- while (from >= p) {
10493
- currentNode = currentNode.next;
10494
- p += currentNode.value.length;
10495
- }
10496
- // adjust pos (and p)
10497
- p -= currentNode.value.length;
10498
- pos = p;
10499
-
10500
- // the current node is a Token, then the match starts inside another Token, which is invalid
10501
- if (currentNode.value instanceof Token) {
10502
- continue;
10503
- }
10504
-
10505
- // find the last node which is affected by this match
10506
- for (
10507
- var k = currentNode;
10508
- k !== tokenList.tail && (p < to || typeof k.value === 'string');
10509
- k = k.next
10510
- ) {
10511
- removeCount++;
10512
- p += k.value.length;
10513
- }
10514
- removeCount--;
10515
-
10516
- // replace with the new match
10517
- str = text.slice(pos, p);
10518
- match.index -= pos;
10519
- } else {
10520
- match = matchPattern(pattern, 0, str, lookbehind);
10521
- if (!match) {
10522
- continue;
10523
- }
10524
- }
10525
-
10526
- // eslint-disable-next-line no-redeclare
10527
- var from = match.index;
10528
- var matchStr = match[0];
10529
- var before = str.slice(0, from);
10530
- var after = str.slice(from + matchStr.length);
10531
-
10532
- var reach = pos + str.length;
10533
- if (rematch && reach > rematch.reach) {
10534
- rematch.reach = reach;
10535
- }
10536
-
10537
- var removeFrom = currentNode.prev;
10538
-
10539
- if (before) {
10540
- removeFrom = addAfter(tokenList, removeFrom, before);
10541
- pos += before.length;
10542
- }
10543
-
10544
- removeRange(tokenList, removeFrom, removeCount);
10545
-
10546
- var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
10547
- currentNode = addAfter(tokenList, removeFrom, wrapped);
10548
-
10549
- if (after) {
10550
- addAfter(tokenList, currentNode, after);
10551
- }
10552
-
10553
- if (removeCount > 1) {
10554
- // at least one Token object was removed, so we have to do some rematching
10555
- // this can only happen if the current pattern is greedy
10556
-
10557
- /** @type {RematchOptions} */
10558
- var nestedRematch = {
10559
- cause: token + ',' + j,
10560
- reach: reach
10561
- };
10562
- matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
10563
-
10564
- // the reach might have been extended because of the rematching
10565
- if (rematch && nestedRematch.reach > rematch.reach) {
10566
- rematch.reach = nestedRematch.reach;
10567
- }
10568
- }
10569
- }
10570
- }
10571
- }
10572
- }
10573
-
10574
- /**
10575
- * @typedef LinkedListNode
10576
- * @property {T} value
10577
- * @property {LinkedListNode<T> | null} prev The previous node.
10578
- * @property {LinkedListNode<T> | null} next The next node.
10579
- * @template T
10580
- * @private
10581
- */
10582
-
10583
- /**
10584
- * @template T
10585
- * @private
10586
- */
10587
- function LinkedList() {
10588
- /** @type {LinkedListNode<T>} */
10589
- var head = { value: null, prev: null, next: null };
10590
- /** @type {LinkedListNode<T>} */
10591
- var tail = { value: null, prev: head, next: null };
10592
- head.next = tail;
10593
-
10594
- /** @type {LinkedListNode<T>} */
10595
- this.head = head;
10596
- /** @type {LinkedListNode<T>} */
10597
- this.tail = tail;
10598
- this.length = 0;
10599
- }
10600
-
10601
- /**
10602
- * Adds a new node with the given value to the list.
10603
- *
10604
- * @param {LinkedList<T>} list
10605
- * @param {LinkedListNode<T>} node
10606
- * @param {T} value
10607
- * @returns {LinkedListNode<T>} The added node.
10608
- * @template T
10609
- */
10610
- function addAfter(list, node, value) {
10611
- // assumes that node != list.tail && values.length >= 0
10612
- var next = node.next;
10613
-
10614
- var newNode = { value: value, prev: node, next: next };
10615
- node.next = newNode;
10616
- next.prev = newNode;
10617
- list.length++;
10618
-
10619
- return newNode;
10620
- }
10621
- /**
10622
- * Removes `count` nodes after the given node. The given node will not be removed.
10623
- *
10624
- * @param {LinkedList<T>} list
10625
- * @param {LinkedListNode<T>} node
10626
- * @param {number} count
10627
- * @template T
10628
- */
10629
- function removeRange(list, node, count) {
10630
- var next = node.next;
10631
- for (var i = 0; i < count && next !== list.tail; i++) {
10632
- next = next.next;
10633
- }
10634
- node.next = next;
10635
- next.prev = node;
10636
- list.length -= i;
10637
- }
10638
- /**
10639
- * @param {LinkedList<T>} list
10640
- * @returns {T[]}
10641
- * @template T
10642
- */
10643
- function toArray(list) {
10644
- var array = [];
10645
- var node = list.head.next;
10646
- while (node !== list.tail) {
10647
- array.push(node.value);
10648
- node = node.next;
10649
- }
10650
- return array;
10651
- }
10652
-
10653
-
10654
- if (!_self.document) {
10655
- if (!_self.addEventListener) {
10656
- // in Node.js
10657
- return _;
10658
- }
10659
-
10660
- if (!_.disableWorkerMessageHandler) {
10661
- // In worker
10662
- _self.addEventListener('message', function (evt) {
10663
- var message = JSON.parse(evt.data);
10664
- var lang = message.language;
10665
- var code = message.code;
10666
- var immediateClose = message.immediateClose;
10667
-
10668
- _self.postMessage(_.highlight(code, _.languages[lang], lang));
10669
- if (immediateClose) {
10670
- _self.close();
10671
- }
10672
- }, false);
10673
- }
10674
-
10675
- return _;
10676
- }
10677
-
10678
- // Get current script and highlight
10679
- var script = _.util.currentScript();
10680
-
10681
- if (script) {
10682
- _.filename = script.src;
10683
-
10684
- if (script.hasAttribute('data-manual')) {
10685
- _.manual = true;
10686
- }
10687
- }
10688
-
10689
- function highlightAutomaticallyCallback() {
10690
- if (!_.manual) {
10691
- _.highlightAll();
10692
- }
10693
- }
10694
-
10695
- if (!_.manual) {
10696
- // If the document state is "loading", then we'll use DOMContentLoaded.
10697
- // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
10698
- // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
10699
- // might take longer one animation frame to execute which can create a race condition where only some plugins have
10700
- // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
10701
- // See https://github.com/PrismJS/prism/issues/2102
10702
- var readyState = document.readyState;
10703
- if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
10704
- document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
10705
- } else {
10706
- if (window.requestAnimationFrame) {
10707
- window.requestAnimationFrame(highlightAutomaticallyCallback);
10708
- } else {
10709
- window.setTimeout(highlightAutomaticallyCallback, 16);
10710
- }
10711
- }
10712
- }
10713
-
10714
- return _;
10715
-
10716
- }(_self));
10717
-
10718
- if ( true && module.exports) {
10719
- module.exports = Prism;
10720
- }
10721
-
10722
- // hack for components to work correctly in node.js
10723
- if (typeof __webpack_require__.g !== 'undefined') {
10724
- __webpack_require__.g.Prism = Prism;
10725
- }
10726
-
10727
- // some additional documentation/types
10728
-
10729
- /**
10730
- * The expansion of a simple `RegExp` literal to support additional properties.
10731
- *
10732
- * @typedef GrammarToken
10733
- * @property {RegExp} pattern The regular expression of the token.
10734
- * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
10735
- * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
10736
- * @property {boolean} [greedy=false] Whether the token is greedy.
10737
- * @property {string|string[]} [alias] An optional alias or list of aliases.
10738
- * @property {Grammar} [inside] The nested grammar of this token.
10739
- *
10740
- * The `inside` grammar will be used to tokenize the text value of each token of this kind.
10741
- *
10742
- * This can be used to make nested and even recursive language definitions.
10743
- *
10744
- * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
10745
- * each another.
10746
- * @global
10747
- * @public
10748
- */
10749
-
10750
- /**
10751
- * @typedef Grammar
10752
- * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
10753
- * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
10754
- * @global
10755
- * @public
10756
- */
10757
-
10758
- /**
10759
- * A function which will invoked after an element was successfully highlighted.
10760
- *
10761
- * @callback HighlightCallback
10762
- * @param {Element} element The element successfully highlighted.
10763
- * @returns {void}
10764
- * @global
10765
- * @public
10766
- */
10767
-
10768
- /**
10769
- * @callback HookCallback
10770
- * @param {Object<string, any>} env The environment variables of the hook.
10771
- * @returns {void}
10772
- * @global
10773
- * @public
10774
- */
10775
-
10776
-
10777
9317
  /***/ }),
10778
9318
 
10779
9319
  /***/ 59:
@@ -11064,18 +9604,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__787__;
11064
9604
  /******/ };
11065
9605
  /******/ })();
11066
9606
  /******/
11067
- /******/ /* webpack/runtime/global */
11068
- /******/ (() => {
11069
- /******/ __webpack_require__.g = (function() {
11070
- /******/ if (typeof globalThis === 'object') return globalThis;
11071
- /******/ try {
11072
- /******/ return this || new Function('return this')();
11073
- /******/ } catch (e) {
11074
- /******/ if (typeof window === 'object') return window;
11075
- /******/ }
11076
- /******/ })();
11077
- /******/ })();
11078
- /******/
11079
9607
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
11080
9608
  /******/ (() => {
11081
9609
  /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
@@ -11366,7 +9894,7 @@ var external_root_React_commonjs2_react_commonjs_react_amd_react_ = __webpack_re
11366
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_);
11367
9895
  ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
11368
9896
  function _extends() {
11369
- _extends = Object.assign || function (target) {
9897
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
11370
9898
  for (var i = 1; i < arguments.length; i++) {
11371
9899
  var source = arguments[i];
11372
9900
 
@@ -11379,7 +9907,6 @@ function _extends() {
11379
9907
 
11380
9908
  return target;
11381
9909
  };
11382
-
11383
9910
  return _extends.apply(this, arguments);
11384
9911
  }
11385
9912
  // EXTERNAL MODULE: ./node_modules/is-buffer/index.js
@@ -16934,7 +15461,7 @@ function tokenizeSetextUnderline(effects, ok, nok) {
16934
15461
  * to detect whether the HTML-like syntax is seen as HTML (flow) or not.
16935
15462
  *
16936
15463
  * This is copied from:
16937
- * <https://spec.commonmark.org/0.29/#html-blocks>.
15464
+ * <https://spec.commonmark.org/0.30/#html-blocks>.
16938
15465
  */
16939
15466
  const htmlBlockNames = [
16940
15467
  'address',
@@ -16987,7 +15514,6 @@ const htmlBlockNames = [
16987
15514
  'p',
16988
15515
  'param',
16989
15516
  'section',
16990
- 'source',
16991
15517
  'summary',
16992
15518
  'table',
16993
15519
  'tbody',
@@ -17007,11 +15533,9 @@ const htmlBlockNames = [
17007
15533
  * list is found (condition 1).
17008
15534
  *
17009
15535
  * This module is copied from:
17010
- * <https://spec.commonmark.org/0.29/#html-blocks>.
15536
+ * <https://spec.commonmark.org/0.30/#html-blocks>.
17011
15537
  *
17012
- * Note that `textarea` is not available in `CommonMark@0.29` but has been
17013
- * merged to the primary branch and is slated to be released in the next release
17014
- * of CommonMark.
15538
+ * Note that `textarea` was added in `CommonMark@0.30`.
17015
15539
  */
17016
15540
  const htmlRawNames = ['pre', 'script', 'style', 'textarea']
17017
15541
 
@@ -27856,17 +26380,182 @@ function escapeStringRegexp(string) {
27856
26380
  .replace(/-/g, '\\x2d');
27857
26381
  }
27858
26382
 
27859
- ;// 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
26384
+ /**
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
+
27860
26420
  /**
27861
- * @typedef Options Configuration.
27862
- * @property {Test} [ignore] `unist-util-is` test used to assert parents
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
27863
26552
  *
27864
26553
  * @typedef {import('mdast').Root} Root
27865
26554
  * @typedef {import('mdast').Content} Content
27866
26555
  * @typedef {import('mdast').PhrasingContent} PhrasingContent
27867
26556
  * @typedef {import('mdast').Text} Text
27868
26557
  * @typedef {Content|Root} Node
27869
- * @typedef {Extract<Node, import('mdast').Parent>} Parent
26558
+ * @typedef {Exclude<Extract<Node, import('mdast').Parent>, Root>} Parent
27870
26559
  *
27871
26560
  * @typedef {import('unist-util-visit-parents').Test} Test
27872
26561
  * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult
@@ -27874,29 +26563,30 @@ function escapeStringRegexp(string) {
27874
26563
  * @typedef RegExpMatchObject
27875
26564
  * @property {number} index
27876
26565
  * @property {string} input
26566
+ * @property {[Root, ...Array<Parent>, Text]} stack
27877
26567
  *
27878
26568
  * @typedef {string|RegExp} Find
27879
26569
  * @typedef {string|ReplaceFunction} Replace
27880
26570
  *
27881
26571
  * @typedef {[Find, Replace]} FindAndReplaceTuple
27882
- * @typedef {Object.<string, Replace>} FindAndReplaceSchema
27883
- * @typedef {Array.<FindAndReplaceTuple>} FindAndReplaceList
26572
+ * @typedef {Record<string, Replace>} FindAndReplaceSchema
26573
+ * @typedef {Array<FindAndReplaceTuple>} FindAndReplaceList
27884
26574
  *
27885
26575
  * @typedef {[RegExp, ReplaceFunction]} Pair
27886
- * @typedef {Array.<Pair>} Pairs
26576
+ * @typedef {Array<Pair>} Pairs
27887
26577
  */
27888
26578
 
27889
26579
  /**
27890
26580
  * @callback ReplaceFunction
27891
26581
  * @param {...any} parameters
27892
- * @returns {Array.<PhrasingContent>|PhrasingContent|string|false|undefined|null}
26582
+ * @returns {Array<PhrasingContent>|PhrasingContent|string|false|undefined|null}
27893
26583
  */
27894
26584
 
27895
26585
 
27896
26586
 
27897
26587
 
27898
26588
 
27899
- const mdast_util_find_and_replace_own = {}.hasOwnProperty
26589
+ const mdast_util_find_and_replace_lib_own = {}.hasOwnProperty
27900
26590
 
27901
26591
  /**
27902
26592
  * @param tree mdast tree
@@ -27947,12 +26637,12 @@ const findAndReplace =
27947
26637
  let pairIndex = -1
27948
26638
 
27949
26639
  while (++pairIndex < pairs.length) {
27950
- unist_util_visit_parents_visitParents(tree, 'text', visitor)
26640
+ node_modules_unist_util_visit_parents_visitParents(tree, 'text', visitor)
27951
26641
  }
27952
26642
 
27953
26643
  return tree
27954
26644
 
27955
- /** @type {import('unist-util-visit-parents').Visitor<Text>} */
26645
+ /** @type {import('unist-util-visit-parents/complex-types').BuildVisitor<Root, 'text'>} */
27956
26646
  function visitor(node, parents) {
27957
26647
  let index = -1
27958
26648
  /** @type {Parent|undefined} */
@@ -27976,22 +26666,24 @@ const findAndReplace =
27976
26666
  }
27977
26667
 
27978
26668
  if (grandparent) {
27979
- return handler(node, grandparent)
26669
+ // @ts-expect-error: stack is fine.
26670
+ return handler(node, parents)
27980
26671
  }
27981
26672
  }
27982
26673
 
27983
26674
  /**
27984
26675
  * @param {Text} node
27985
- * @param {Parent} parent
26676
+ * @param {[Root, ...Array<Parent>]} parents
27986
26677
  * @returns {VisitorResult}
27987
26678
  */
27988
- function handler(node, parent) {
26679
+ function handler(node, parents) {
26680
+ const parent = parents[parents.length - 1]
27989
26681
  const find = pairs[pairIndex][0]
27990
26682
  const replace = pairs[pairIndex][1]
27991
26683
  let start = 0
27992
26684
  // @ts-expect-error: TS is wrong, some of these children can be text.
27993
- let index = parent.children.indexOf(node)
27994
- /** @type {Array.<PhrasingContent>} */
26685
+ const index = parent.children.indexOf(node)
26686
+ /** @type {Array<PhrasingContent>} */
27995
26687
  let nodes = []
27996
26688
  /** @type {number|undefined} */
27997
26689
  let position
@@ -28002,17 +26694,21 @@ const findAndReplace =
28002
26694
 
28003
26695
  while (match) {
28004
26696
  position = match.index
28005
- // @ts-expect-error this is perfectly fine, typescript.
28006
- let value = replace(...match, {
26697
+ /** @type {RegExpMatchObject} */
26698
+ const matchObject = {
28007
26699
  index: match.index,
28008
- input: match.input
28009
- })
26700
+ input: match.input,
26701
+ stack: [...parents, node]
26702
+ }
26703
+ let value = replace(...match, matchObject)
28010
26704
 
28011
26705
  if (typeof value === 'string') {
28012
26706
  value = value.length > 0 ? {type: 'text', value} : undefined
28013
26707
  }
28014
26708
 
28015
- if (value !== false) {
26709
+ if (value === false) {
26710
+ position = undefined
26711
+ } else {
28016
26712
  if (start !== position) {
28017
26713
  nodes.push({
28018
26714
  type: 'text',
@@ -28038,7 +26734,6 @@ const findAndReplace =
28038
26734
 
28039
26735
  if (position === undefined) {
28040
26736
  nodes = [node]
28041
- index--
28042
26737
  } else {
28043
26738
  if (start < node.value.length) {
28044
26739
  nodes.push({type: 'text', value: node.value.slice(start)})
@@ -28047,7 +26742,7 @@ const findAndReplace =
28047
26742
  parent.children.splice(index, 1, ...nodes)
28048
26743
  }
28049
26744
 
28050
- return index + nodes.length + 1
26745
+ return index + nodes.length
28051
26746
  }
28052
26747
  }
28053
26748
  )
@@ -28078,7 +26773,7 @@ function toPairs(schema) {
28078
26773
  let key
28079
26774
 
28080
26775
  for (key in schema) {
28081
- if (mdast_util_find_and_replace_own.call(schema, key)) {
26776
+ if (mdast_util_find_and_replace_lib_own.call(schema, key)) {
28082
26777
  result.push([toExpression(key), toFunction(schema[key])])
28083
26778
  }
28084
26779
  }
@@ -37992,8 +36687,823 @@ function disallowed(code) {
37992
36687
  )
37993
36688
  }
37994
36689
 
37995
- // EXTERNAL MODULE: ./node_modules/prismjs/components/prism-core.js
37996
- var prism_core = __webpack_require__(975);
36690
+ ;// CONCATENATED MODULE: ./node_modules/refractor/lib/prism-core.js
36691
+ // @ts-nocheck
36692
+
36693
+ // This is a slimmed down version of `prism-core.js`, to remove globals,
36694
+ // document, workers, `util.encode`, `Token.stringify`
36695
+
36696
+ // Private helper vars
36697
+ var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i
36698
+ var uniqueId = 0
36699
+
36700
+ // The grammar object for plaintext
36701
+ var plainTextGrammar = {}
36702
+
36703
+ var _ = {
36704
+ /**
36705
+ * A namespace for utility methods.
36706
+ *
36707
+ * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
36708
+ * change or disappear at any time.
36709
+ *
36710
+ * @namespace
36711
+ * @memberof Prism
36712
+ */
36713
+ util: {
36714
+ /**
36715
+ * Returns the name of the type of the given value.
36716
+ *
36717
+ * @param {any} o
36718
+ * @returns {string}
36719
+ * @example
36720
+ * type(null) === 'Null'
36721
+ * type(undefined) === 'Undefined'
36722
+ * type(123) === 'Number'
36723
+ * type('foo') === 'String'
36724
+ * type(true) === 'Boolean'
36725
+ * type([1, 2]) === 'Array'
36726
+ * type({}) === 'Object'
36727
+ * type(String) === 'Function'
36728
+ * type(/abc+/) === 'RegExp'
36729
+ */
36730
+ type: function (o) {
36731
+ return Object.prototype.toString.call(o).slice(8, -1)
36732
+ },
36733
+
36734
+ /**
36735
+ * Returns a unique number for the given object. Later calls will still return the same number.
36736
+ *
36737
+ * @param {Object} obj
36738
+ * @returns {number}
36739
+ */
36740
+ objId: function (obj) {
36741
+ if (!obj['__id']) {
36742
+ Object.defineProperty(obj, '__id', {value: ++uniqueId})
36743
+ }
36744
+ return obj['__id']
36745
+ },
36746
+
36747
+ /**
36748
+ * Creates a deep clone of the given object.
36749
+ *
36750
+ * The main intended use of this function is to clone language definitions.
36751
+ *
36752
+ * @param {T} o
36753
+ * @param {Record<number, any>} [visited]
36754
+ * @returns {T}
36755
+ * @template T
36756
+ */
36757
+ clone: function deepClone(o, visited) {
36758
+ visited = visited || {}
36759
+
36760
+ var clone
36761
+ var id
36762
+ switch (_.util.type(o)) {
36763
+ case 'Object':
36764
+ id = _.util.objId(o)
36765
+ if (visited[id]) {
36766
+ return visited[id]
36767
+ }
36768
+ clone = /** @type {Record<string, any>} */ ({})
36769
+ visited[id] = clone
36770
+
36771
+ for (var key in o) {
36772
+ if (o.hasOwnProperty(key)) {
36773
+ clone[key] = deepClone(o[key], visited)
36774
+ }
36775
+ }
36776
+
36777
+ return /** @type {any} */ (clone)
36778
+
36779
+ case 'Array':
36780
+ id = _.util.objId(o)
36781
+ if (visited[id]) {
36782
+ return visited[id]
36783
+ }
36784
+ clone = []
36785
+ visited[id] = clone
36786
+
36787
+ o.forEach(function (v, i) {
36788
+ clone[i] = deepClone(v, visited)
36789
+ })
36790
+
36791
+ return /** @type {any} */ (clone)
36792
+
36793
+ default:
36794
+ return o
36795
+ }
36796
+ }
36797
+ },
36798
+
36799
+ /**
36800
+ * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
36801
+ *
36802
+ * @namespace
36803
+ * @memberof Prism
36804
+ * @public
36805
+ */
36806
+ languages: {
36807
+ /**
36808
+ * The grammar for plain, unformatted text.
36809
+ */
36810
+ plain: plainTextGrammar,
36811
+ plaintext: plainTextGrammar,
36812
+ text: plainTextGrammar,
36813
+ txt: plainTextGrammar,
36814
+
36815
+ /**
36816
+ * Creates a deep copy of the language with the given id and appends the given tokens.
36817
+ *
36818
+ * If a token in `redef` also appears in the copied language, then the existing token in the copied language
36819
+ * will be overwritten at its original position.
36820
+ *
36821
+ * ## Best practices
36822
+ *
36823
+ * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
36824
+ * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
36825
+ * understand the language definition because, normally, the order of tokens matters in Prism grammars.
36826
+ *
36827
+ * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
36828
+ * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
36829
+ *
36830
+ * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
36831
+ * @param {Grammar} redef The new tokens to append.
36832
+ * @returns {Grammar} The new language created.
36833
+ * @public
36834
+ * @example
36835
+ * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
36836
+ * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
36837
+ * // at its original position
36838
+ * 'comment': { ... },
36839
+ * // CSS doesn't have a 'color' token, so this token will be appended
36840
+ * 'color': /\b(?:red|green|blue)\b/
36841
+ * });
36842
+ */
36843
+ extend: function (id, redef) {
36844
+ var lang = _.util.clone(_.languages[id])
36845
+
36846
+ for (var key in redef) {
36847
+ lang[key] = redef[key]
36848
+ }
36849
+
36850
+ return lang
36851
+ },
36852
+
36853
+ /**
36854
+ * Inserts tokens _before_ another token in a language definition or any other grammar.
36855
+ *
36856
+ * ## Usage
36857
+ *
36858
+ * This helper method makes it easy to modify existing languages. For example, the CSS language definition
36859
+ * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
36860
+ * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
36861
+ * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
36862
+ * this:
36863
+ *
36864
+ * ```js
36865
+ * Prism.languages.markup.style = {
36866
+ * // token
36867
+ * };
36868
+ * ```
36869
+ *
36870
+ * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
36871
+ * before existing tokens. For the CSS example above, you would use it like this:
36872
+ *
36873
+ * ```js
36874
+ * Prism.languages.insertBefore('markup', 'cdata', {
36875
+ * 'style': {
36876
+ * // token
36877
+ * }
36878
+ * });
36879
+ * ```
36880
+ *
36881
+ * ## Special cases
36882
+ *
36883
+ * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
36884
+ * will be ignored.
36885
+ *
36886
+ * This behavior can be used to insert tokens after `before`:
36887
+ *
36888
+ * ```js
36889
+ * Prism.languages.insertBefore('markup', 'comment', {
36890
+ * 'comment': Prism.languages.markup.comment,
36891
+ * // tokens after 'comment'
36892
+ * });
36893
+ * ```
36894
+ *
36895
+ * ## Limitations
36896
+ *
36897
+ * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
36898
+ * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
36899
+ * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
36900
+ * deleting properties which is necessary to insert at arbitrary positions.
36901
+ *
36902
+ * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
36903
+ * Instead, it will create a new object and replace all references to the target object with the new one. This
36904
+ * can be done without temporarily deleting properties, so the iteration order is well-defined.
36905
+ *
36906
+ * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
36907
+ * you hold the target object in a variable, then the value of the variable will not change.
36908
+ *
36909
+ * ```js
36910
+ * var oldMarkup = Prism.languages.markup;
36911
+ * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
36912
+ *
36913
+ * assert(oldMarkup !== Prism.languages.markup);
36914
+ * assert(newMarkup === Prism.languages.markup);
36915
+ * ```
36916
+ *
36917
+ * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
36918
+ * object to be modified.
36919
+ * @param {string} before The key to insert before.
36920
+ * @param {Grammar} insert An object containing the key-value pairs to be inserted.
36921
+ * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
36922
+ * object to be modified.
36923
+ *
36924
+ * Defaults to `Prism.languages`.
36925
+ * @returns {Grammar} The new grammar object.
36926
+ * @public
36927
+ */
36928
+ insertBefore: function (inside, before, insert, root) {
36929
+ root = root || /** @type {any} */ (_.languages)
36930
+ var grammar = root[inside]
36931
+ /** @type {Grammar} */
36932
+ var ret = {}
36933
+
36934
+ for (var token in grammar) {
36935
+ if (grammar.hasOwnProperty(token)) {
36936
+ if (token == before) {
36937
+ for (var newToken in insert) {
36938
+ if (insert.hasOwnProperty(newToken)) {
36939
+ ret[newToken] = insert[newToken]
36940
+ }
36941
+ }
36942
+ }
36943
+
36944
+ // Do not insert token which also occur in insert. See #1525
36945
+ if (!insert.hasOwnProperty(token)) {
36946
+ ret[token] = grammar[token]
36947
+ }
36948
+ }
36949
+ }
36950
+
36951
+ var old = root[inside]
36952
+ root[inside] = ret
36953
+
36954
+ // Update references in other language definitions
36955
+ _.languages.DFS(_.languages, function (key, value) {
36956
+ if (value === old && key != inside) {
36957
+ this[key] = ret
36958
+ }
36959
+ })
36960
+
36961
+ return ret
36962
+ },
36963
+
36964
+ // Traverse a language definition with Depth First Search
36965
+ DFS: function DFS(o, callback, type, visited) {
36966
+ visited = visited || {}
36967
+
36968
+ var objId = _.util.objId
36969
+
36970
+ for (var i in o) {
36971
+ if (o.hasOwnProperty(i)) {
36972
+ callback.call(o, i, o[i], type || i)
36973
+
36974
+ var property = o[i]
36975
+ var propertyType = _.util.type(property)
36976
+
36977
+ if (propertyType === 'Object' && !visited[objId(property)]) {
36978
+ visited[objId(property)] = true
36979
+ DFS(property, callback, null, visited)
36980
+ } else if (propertyType === 'Array' && !visited[objId(property)]) {
36981
+ visited[objId(property)] = true
36982
+ DFS(property, callback, i, visited)
36983
+ }
36984
+ }
36985
+ }
36986
+ }
36987
+ },
36988
+
36989
+ plugins: {},
36990
+
36991
+ /**
36992
+ * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
36993
+ * and the language definitions to use, and returns a string with the HTML produced.
36994
+ *
36995
+ * The following hooks will be run:
36996
+ * 1. `before-tokenize`
36997
+ * 2. `after-tokenize`
36998
+ * 3. `wrap`: On each {@link Token}.
36999
+ *
37000
+ * @param {string} text A string with the code to be highlighted.
37001
+ * @param {Grammar} grammar An object containing the tokens to use.
37002
+ *
37003
+ * Usually a language definition like `Prism.languages.markup`.
37004
+ * @param {string} language The name of the language definition passed to `grammar`.
37005
+ * @returns {string} The highlighted HTML.
37006
+ * @memberof Prism
37007
+ * @public
37008
+ * @example
37009
+ * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
37010
+ */
37011
+ highlight: function (text, grammar, language) {
37012
+ var env = {
37013
+ code: text,
37014
+ grammar: grammar,
37015
+ language: language
37016
+ }
37017
+ _.hooks.run('before-tokenize', env)
37018
+ if (!env.grammar) {
37019
+ throw new Error('The language "' + env.language + '" has no grammar.')
37020
+ }
37021
+ env.tokens = _.tokenize(env.code, env.grammar)
37022
+ _.hooks.run('after-tokenize', env)
37023
+ return Token.stringify(_.util.encode(env.tokens), env.language)
37024
+ },
37025
+
37026
+ /**
37027
+ * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
37028
+ * and the language definitions to use, and returns an array with the tokenized code.
37029
+ *
37030
+ * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
37031
+ *
37032
+ * This method could be useful in other contexts as well, as a very crude parser.
37033
+ *
37034
+ * @param {string} text A string with the code to be highlighted.
37035
+ * @param {Grammar} grammar An object containing the tokens to use.
37036
+ *
37037
+ * Usually a language definition like `Prism.languages.markup`.
37038
+ * @returns {TokenStream} An array of strings and tokens, a token stream.
37039
+ * @memberof Prism
37040
+ * @public
37041
+ * @example
37042
+ * let code = `var foo = 0;`;
37043
+ * let tokens = Prism.tokenize(code, Prism.languages.javascript);
37044
+ * tokens.forEach(token => {
37045
+ * if (token instanceof Prism.Token && token.type === 'number') {
37046
+ * console.log(`Found numeric literal: ${token.content}`);
37047
+ * }
37048
+ * });
37049
+ */
37050
+ tokenize: function (text, grammar) {
37051
+ var rest = grammar.rest
37052
+ if (rest) {
37053
+ for (var token in rest) {
37054
+ grammar[token] = rest[token]
37055
+ }
37056
+
37057
+ delete grammar.rest
37058
+ }
37059
+
37060
+ var tokenList = new LinkedList()
37061
+ addAfter(tokenList, tokenList.head, text)
37062
+
37063
+ matchGrammar(text, tokenList, grammar, tokenList.head, 0)
37064
+
37065
+ return toArray(tokenList)
37066
+ },
37067
+
37068
+ /**
37069
+ * @namespace
37070
+ * @memberof Prism
37071
+ * @public
37072
+ */
37073
+ hooks: {
37074
+ all: {},
37075
+
37076
+ /**
37077
+ * Adds the given callback to the list of callbacks for the given hook.
37078
+ *
37079
+ * The callback will be invoked when the hook it is registered for is run.
37080
+ * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
37081
+ *
37082
+ * One callback function can be registered to multiple hooks and the same hook multiple times.
37083
+ *
37084
+ * @param {string} name The name of the hook.
37085
+ * @param {HookCallback} callback The callback function which is given environment variables.
37086
+ * @public
37087
+ */
37088
+ add: function (name, callback) {
37089
+ var hooks = _.hooks.all
37090
+
37091
+ hooks[name] = hooks[name] || []
37092
+
37093
+ hooks[name].push(callback)
37094
+ },
37095
+
37096
+ /**
37097
+ * Runs a hook invoking all registered callbacks with the given environment variables.
37098
+ *
37099
+ * Callbacks will be invoked synchronously and in the order in which they were registered.
37100
+ *
37101
+ * @param {string} name The name of the hook.
37102
+ * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
37103
+ * @public
37104
+ */
37105
+ run: function (name, env) {
37106
+ var callbacks = _.hooks.all[name]
37107
+
37108
+ if (!callbacks || !callbacks.length) {
37109
+ return
37110
+ }
37111
+
37112
+ for (var i = 0, callback; (callback = callbacks[i++]); ) {
37113
+ callback(env)
37114
+ }
37115
+ }
37116
+ },
37117
+
37118
+ Token: Token
37119
+ }
37120
+
37121
+ // Typescript note:
37122
+ // The following can be used to import the Token type in JSDoc:
37123
+ //
37124
+ // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
37125
+
37126
+ /**
37127
+ * Creates a new token.
37128
+ *
37129
+ * @param {string} type See {@link Token#type type}
37130
+ * @param {string | TokenStream} content See {@link Token#content content}
37131
+ * @param {string|string[]} [alias] The alias(es) of the token.
37132
+ * @param {string} [matchedStr=""] A copy of the full string this token was created from.
37133
+ * @class
37134
+ * @global
37135
+ * @public
37136
+ */
37137
+ function Token(type, content, alias, matchedStr) {
37138
+ /**
37139
+ * The type of the token.
37140
+ *
37141
+ * This is usually the key of a pattern in a {@link Grammar}.
37142
+ *
37143
+ * @type {string}
37144
+ * @see GrammarToken
37145
+ * @public
37146
+ */
37147
+ this.type = type
37148
+ /**
37149
+ * The strings or tokens contained by this token.
37150
+ *
37151
+ * This will be a token stream if the pattern matched also defined an `inside` grammar.
37152
+ *
37153
+ * @type {string | TokenStream}
37154
+ * @public
37155
+ */
37156
+ this.content = content
37157
+ /**
37158
+ * The alias(es) of the token.
37159
+ *
37160
+ * @type {string|string[]}
37161
+ * @see GrammarToken
37162
+ * @public
37163
+ */
37164
+ this.alias = alias
37165
+ // Copy of the full string this token was created from
37166
+ this.length = (matchedStr || '').length | 0
37167
+ }
37168
+
37169
+ /**
37170
+ * A token stream is an array of strings and {@link Token Token} objects.
37171
+ *
37172
+ * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
37173
+ * them.
37174
+ *
37175
+ * 1. No adjacent strings.
37176
+ * 2. No empty strings.
37177
+ *
37178
+ * The only exception here is the token stream that only contains the empty string and nothing else.
37179
+ *
37180
+ * @typedef {Array<string | Token>} TokenStream
37181
+ * @global
37182
+ * @public
37183
+ */
37184
+
37185
+ /**
37186
+ * @param {RegExp} pattern
37187
+ * @param {number} pos
37188
+ * @param {string} text
37189
+ * @param {boolean} lookbehind
37190
+ * @returns {RegExpExecArray | null}
37191
+ */
37192
+ function matchPattern(pattern, pos, text, lookbehind) {
37193
+ pattern.lastIndex = pos
37194
+ var match = pattern.exec(text)
37195
+ if (match && lookbehind && match[1]) {
37196
+ // change the match to remove the text matched by the Prism lookbehind group
37197
+ var lookbehindLength = match[1].length
37198
+ match.index += lookbehindLength
37199
+ match[0] = match[0].slice(lookbehindLength)
37200
+ }
37201
+ return match
37202
+ }
37203
+
37204
+ /**
37205
+ * @param {string} text
37206
+ * @param {LinkedList<string | Token>} tokenList
37207
+ * @param {any} grammar
37208
+ * @param {LinkedListNode<string | Token>} startNode
37209
+ * @param {number} startPos
37210
+ * @param {RematchOptions} [rematch]
37211
+ * @returns {void}
37212
+ * @private
37213
+ *
37214
+ * @typedef RematchOptions
37215
+ * @property {string} cause
37216
+ * @property {number} reach
37217
+ */
37218
+ function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
37219
+ for (var token in grammar) {
37220
+ if (!grammar.hasOwnProperty(token) || !grammar[token]) {
37221
+ continue
37222
+ }
37223
+
37224
+ var patterns = grammar[token]
37225
+ patterns = Array.isArray(patterns) ? patterns : [patterns]
37226
+
37227
+ for (var j = 0; j < patterns.length; ++j) {
37228
+ if (rematch && rematch.cause == token + ',' + j) {
37229
+ return
37230
+ }
37231
+
37232
+ var patternObj = patterns[j]
37233
+ var inside = patternObj.inside
37234
+ var lookbehind = !!patternObj.lookbehind
37235
+ var greedy = !!patternObj.greedy
37236
+ var alias = patternObj.alias
37237
+
37238
+ if (greedy && !patternObj.pattern.global) {
37239
+ // Without the global flag, lastIndex won't work
37240
+ var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0]
37241
+ patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g')
37242
+ }
37243
+
37244
+ /** @type {RegExp} */
37245
+ var pattern = patternObj.pattern || patternObj
37246
+
37247
+ for (
37248
+ // iterate the token list and keep track of the current token/string position
37249
+ var currentNode = startNode.next, pos = startPos;
37250
+ currentNode !== tokenList.tail;
37251
+ pos += currentNode.value.length, currentNode = currentNode.next
37252
+ ) {
37253
+ if (rematch && pos >= rematch.reach) {
37254
+ break
37255
+ }
37256
+
37257
+ var str = currentNode.value
37258
+
37259
+ if (tokenList.length > text.length) {
37260
+ // Something went terribly wrong, ABORT, ABORT!
37261
+ return
37262
+ }
37263
+
37264
+ if (str instanceof Token) {
37265
+ continue
37266
+ }
37267
+
37268
+ var removeCount = 1 // this is the to parameter of removeBetween
37269
+ var match
37270
+
37271
+ if (greedy) {
37272
+ match = matchPattern(pattern, pos, text, lookbehind)
37273
+ if (!match || match.index >= text.length) {
37274
+ break
37275
+ }
37276
+
37277
+ var from = match.index
37278
+ var to = match.index + match[0].length
37279
+ var p = pos
37280
+
37281
+ // find the node that contains the match
37282
+ p += currentNode.value.length
37283
+ while (from >= p) {
37284
+ currentNode = currentNode.next
37285
+ p += currentNode.value.length
37286
+ }
37287
+ // adjust pos (and p)
37288
+ p -= currentNode.value.length
37289
+ pos = p
37290
+
37291
+ // the current node is a Token, then the match starts inside another Token, which is invalid
37292
+ if (currentNode.value instanceof Token) {
37293
+ continue
37294
+ }
37295
+
37296
+ // find the last node which is affected by this match
37297
+ for (
37298
+ var k = currentNode;
37299
+ k !== tokenList.tail && (p < to || typeof k.value === 'string');
37300
+ k = k.next
37301
+ ) {
37302
+ removeCount++
37303
+ p += k.value.length
37304
+ }
37305
+ removeCount--
37306
+
37307
+ // replace with the new match
37308
+ str = text.slice(pos, p)
37309
+ match.index -= pos
37310
+ } else {
37311
+ match = matchPattern(pattern, 0, str, lookbehind)
37312
+ if (!match) {
37313
+ continue
37314
+ }
37315
+ }
37316
+
37317
+ // eslint-disable-next-line no-redeclare
37318
+ var from = match.index
37319
+ var matchStr = match[0]
37320
+ var before = str.slice(0, from)
37321
+ var after = str.slice(from + matchStr.length)
37322
+
37323
+ var reach = pos + str.length
37324
+ if (rematch && reach > rematch.reach) {
37325
+ rematch.reach = reach
37326
+ }
37327
+
37328
+ var removeFrom = currentNode.prev
37329
+
37330
+ if (before) {
37331
+ removeFrom = addAfter(tokenList, removeFrom, before)
37332
+ pos += before.length
37333
+ }
37334
+
37335
+ removeRange(tokenList, removeFrom, removeCount)
37336
+
37337
+ var wrapped = new Token(
37338
+ token,
37339
+ inside ? _.tokenize(matchStr, inside) : matchStr,
37340
+ alias,
37341
+ matchStr
37342
+ )
37343
+ currentNode = addAfter(tokenList, removeFrom, wrapped)
37344
+
37345
+ if (after) {
37346
+ addAfter(tokenList, currentNode, after)
37347
+ }
37348
+
37349
+ if (removeCount > 1) {
37350
+ // at least one Token object was removed, so we have to do some rematching
37351
+ // this can only happen if the current pattern is greedy
37352
+
37353
+ /** @type {RematchOptions} */
37354
+ var nestedRematch = {
37355
+ cause: token + ',' + j,
37356
+ reach: reach
37357
+ }
37358
+ matchGrammar(
37359
+ text,
37360
+ tokenList,
37361
+ grammar,
37362
+ currentNode.prev,
37363
+ pos,
37364
+ nestedRematch
37365
+ )
37366
+
37367
+ // the reach might have been extended because of the rematching
37368
+ if (rematch && nestedRematch.reach > rematch.reach) {
37369
+ rematch.reach = nestedRematch.reach
37370
+ }
37371
+ }
37372
+ }
37373
+ }
37374
+ }
37375
+ }
37376
+
37377
+ /**
37378
+ * @typedef LinkedListNode
37379
+ * @property {T} value
37380
+ * @property {LinkedListNode<T> | null} prev The previous node.
37381
+ * @property {LinkedListNode<T> | null} next The next node.
37382
+ * @template T
37383
+ * @private
37384
+ */
37385
+
37386
+ /**
37387
+ * @template T
37388
+ * @private
37389
+ */
37390
+ function LinkedList() {
37391
+ /** @type {LinkedListNode<T>} */
37392
+ var head = {value: null, prev: null, next: null}
37393
+ /** @type {LinkedListNode<T>} */
37394
+ var tail = {value: null, prev: head, next: null}
37395
+ head.next = tail
37396
+
37397
+ /** @type {LinkedListNode<T>} */
37398
+ this.head = head
37399
+ /** @type {LinkedListNode<T>} */
37400
+ this.tail = tail
37401
+ this.length = 0
37402
+ }
37403
+
37404
+ /**
37405
+ * Adds a new node with the given value to the list.
37406
+ *
37407
+ * @param {LinkedList<T>} list
37408
+ * @param {LinkedListNode<T>} node
37409
+ * @param {T} value
37410
+ * @returns {LinkedListNode<T>} The added node.
37411
+ * @template T
37412
+ */
37413
+ function addAfter(list, node, value) {
37414
+ // assumes that node != list.tail && values.length >= 0
37415
+ var next = node.next
37416
+
37417
+ var newNode = {value: value, prev: node, next: next}
37418
+ node.next = newNode
37419
+ next.prev = newNode
37420
+ list.length++
37421
+
37422
+ return newNode
37423
+ }
37424
+ /**
37425
+ * Removes `count` nodes after the given node. The given node will not be removed.
37426
+ *
37427
+ * @param {LinkedList<T>} list
37428
+ * @param {LinkedListNode<T>} node
37429
+ * @param {number} count
37430
+ * @template T
37431
+ */
37432
+ function removeRange(list, node, count) {
37433
+ var next = node.next
37434
+ for (var i = 0; i < count && next !== list.tail; i++) {
37435
+ next = next.next
37436
+ }
37437
+ node.next = next
37438
+ next.prev = node
37439
+ list.length -= i
37440
+ }
37441
+ /**
37442
+ * @param {LinkedList<T>} list
37443
+ * @returns {T[]}
37444
+ * @template T
37445
+ */
37446
+ function toArray(list) {
37447
+ var array = []
37448
+ var node = list.head.next
37449
+ while (node !== list.tail) {
37450
+ array.push(node.value)
37451
+ node = node.next
37452
+ }
37453
+ return array
37454
+ }
37455
+
37456
+ const Prism = _
37457
+
37458
+ // some additional documentation/types
37459
+
37460
+ /**
37461
+ * The expansion of a simple `RegExp` literal to support additional properties.
37462
+ *
37463
+ * @typedef GrammarToken
37464
+ * @property {RegExp} pattern The regular expression of the token.
37465
+ * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
37466
+ * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
37467
+ * @property {boolean} [greedy=false] Whether the token is greedy.
37468
+ * @property {string|string[]} [alias] An optional alias or list of aliases.
37469
+ * @property {Grammar} [inside] The nested grammar of this token.
37470
+ *
37471
+ * The `inside` grammar will be used to tokenize the text value of each token of this kind.
37472
+ *
37473
+ * This can be used to make nested and even recursive language definitions.
37474
+ *
37475
+ * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
37476
+ * each another.
37477
+ * @global
37478
+ * @public
37479
+ */
37480
+
37481
+ /**
37482
+ * @typedef Grammar
37483
+ * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
37484
+ * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
37485
+ * @global
37486
+ * @public
37487
+ */
37488
+
37489
+ /**
37490
+ * A function which will invoked after an element was successfully highlighted.
37491
+ *
37492
+ * @callback HighlightCallback
37493
+ * @param {Element} element The element successfully highlighted.
37494
+ * @returns {void}
37495
+ * @global
37496
+ * @public
37497
+ */
37498
+
37499
+ /**
37500
+ * @callback HookCallback
37501
+ * @param {Object<string, any>} env The environment variables of the hook.
37502
+ * @returns {void}
37503
+ * @global
37504
+ * @public
37505
+ */
37506
+
37997
37507
  ;// CONCATENATED MODULE: ./node_modules/refractor/lib/core.js
37998
37508
  /**
37999
37509
  * @typedef _Token A hidden Prism token
@@ -38029,53 +37539,18 @@ var prism_core = __webpack_require__(975);
38029
37539
  * @property {Languages} languages
38030
37540
  */
38031
37541
 
38032
- /* eslint-disable no-undef */
38033
- // Don’t allow Prism to run on page load in browser or to start messaging from
38034
- // workers.
38035
- /* c8 ignore next 15 */
38036
- /** @type {typeof globalThis} */
38037
- const ctx =
38038
- typeof globalThis === 'object'
38039
- ? globalThis
38040
- : // @ts-expect-error
38041
- typeof self === 'object'
38042
- ? // @ts-expect-error
38043
- self
38044
- : // @ts-expect-error
38045
- typeof window === 'object'
38046
- ? // @ts-expect-error
38047
- window
38048
- : typeof global === 'object'
38049
- ? global
38050
- : {}
38051
- /* eslint-enable no-undef */
38052
-
38053
- const restore = capture()
38054
-
38055
- /* c8 ignore next 5 */
38056
- ctx.Prism = ctx.Prism || {}
38057
- ctx.Prism.manual = true
38058
- ctx.Prism.disableWorkerMessageHandler = true
38059
-
38060
- /* eslint-disable import/first */
38061
-
38062
37542
  // Load all stuff in `prism.js` itself, except for `prism-file-highlight.js`.
38063
37543
  // The wrapped non-leaky grammars are loaded instead of Prism’s originals.
38064
- ;
38065
-
38066
- // @ts-expect-error: untyped.
38067
37544
 
38068
37545
 
38069
- /* eslint-enable import/first */
38070
37546
 
38071
- restore()
38072
37547
 
38073
37548
  const lib_core_own = {}.hasOwnProperty
38074
37549
 
38075
37550
  // Inherit.
38076
37551
  function Refractor() {}
38077
37552
 
38078
- Refractor.prototype = prism_core
37553
+ Refractor.prototype = Prism
38079
37554
 
38080
37555
  /** @type {Refractor} */
38081
37556
  // @ts-expect-error: TS is wrong.
@@ -38134,7 +37609,8 @@ function highlight(value, language) {
38134
37609
 
38135
37610
  return {
38136
37611
  type: 'root',
38137
- children: prism_core.highlight.call(refractor, value, grammar, name)
37612
+ // @ts-expect-error: we hacked Prism to accept and return the things we want.
37613
+ children: Prism.highlight.call(refractor, value, grammar, name)
38138
37614
  }
38139
37615
  }
38140
37616
 
@@ -38315,36 +37791,6 @@ function core_attributes(attrs) {
38315
37791
  return attrs
38316
37792
  }
38317
37793
 
38318
- /**
38319
- * @returns {() => void}
38320
- */
38321
- function capture() {
38322
- /** @type {boolean|undefined} */
38323
- let defined = 'Prism' in ctx
38324
- /* c8 ignore next */
38325
- let current = defined ? ctx.Prism : undefined
38326
-
38327
- return restore
38328
-
38329
- /**
38330
- * @returns {void}
38331
- */
38332
- function restore() {
38333
- /* istanbul ignore else - Clean leaks after Prism. */
38334
- if (defined) {
38335
- // @ts-expect-error: hush.
38336
- ctx.Prism = current
38337
- /* c8 ignore next 4 */
38338
- } else {
38339
- // @ts-expect-error: hush.
38340
- delete ctx.Prism
38341
- }
38342
-
38343
- defined = undefined
38344
- current = undefined
38345
- }
38346
- }
38347
-
38348
37794
  ;// CONCATENATED MODULE: ./node_modules/refractor/lib/common.js
38349
37795
  /**
38350
37796
  * @typedef {import('./core.js').RefractorRoot} RefractorRoot
@@ -58343,7 +57789,7 @@ const util_element = convertElement()
58343
57789
  * @typedef {import('./types.js').HastNode} HastNode
58344
57790
  * @typedef {import('./types.js').ElementChild} ElementChild
58345
57791
  * @typedef {import('./types.js').Direction} Direction
58346
- * @typedef {import('unist-util-visit').Visitor<ElementChild>} Visitor
57792
+ * @typedef {import('unist-util-visit/complex-types').Visitor<ElementChild>} Visitor
58347
57793
  */
58348
57794
 
58349
57795
 
@@ -58619,9 +58065,9 @@ function indexedSearch(query, parent, state, from, firstElementOnly) {
58619
58065
  const children = parent.children
58620
58066
  let elements = 0
58621
58067
  let index = -1
58622
- /** @type {Object.<string, number>} */
58068
+ /** @type {Record<string, number>} */
58623
58069
  const types = {}
58624
- /** @type {Array.<Function>} */
58070
+ /** @type {Array<Function>} */
58625
58071
  const delayed = []
58626
58072
 
58627
58073
  // Start looking at `from`
@@ -58954,7 +58400,7 @@ const pseudo_handle = zwitch('name', {
58954
58400
  // @ts-expect-error: hush.
58955
58401
  has,
58956
58402
  // @ts-expect-error: hush.
58957
- lang,
58403
+ lang: pseudo_lang,
58958
58404
  // @ts-expect-error: hush.
58959
58405
  'last-child': lastChild,
58960
58406
  // @ts-expect-error: hush.
@@ -59268,7 +58714,7 @@ function firstChild(query, _1, _2, _3, state) {
59268
58714
  * @param {SelectState} state
59269
58715
  * @returns {boolean}
59270
58716
  */
59271
- function lang(query, _1, _2, _3, state) {
58717
+ function pseudo_lang(query, _1, _2, _3, state) {
59272
58718
  return (
59273
58719
  state.language !== '' &&
59274
58720
  state.language !== undefined &&
@@ -59743,7 +59189,7 @@ function normalizeValue(value, info) {
59743
59189
  * @returns {boolean}
59744
59190
  */
59745
59191
  function className(query, element) {
59746
- /** @type {Array.<string>} */
59192
+ /** @type {Array<string>} */
59747
59193
  // @ts-expect-error Assume array.
59748
59194
  const value = element.properties.className || []
59749
59195
  let index = -1
@@ -59854,7 +59300,7 @@ const type = zwitch('type', {
59854
59300
  * @param {Selectors|RuleSet|Rule} query
59855
59301
  * @param {HastNode|undefined} node
59856
59302
  * @param {SelectState} state
59857
- * @returns {Array.<Element>}
59303
+ * @returns {Array<Element>}
59858
59304
  */
59859
59305
  function any_any(query, node, state) {
59860
59306
  // @ts-expect-error zwitch types are off.
@@ -59865,7 +59311,7 @@ function any_any(query, node, state) {
59865
59311
  * @param {Selectors} query
59866
59312
  * @param {HastNode} node
59867
59313
  * @param {SelectState} state
59868
- * @returns {Array.<Element>}
59314
+ * @returns {Array<Element>}
59869
59315
  */
59870
59316
  function selectors(query, node, state) {
59871
59317
  const collector = new Collector(state.one)
@@ -59882,7 +59328,7 @@ function selectors(query, node, state) {
59882
59328
  * @param {RuleSet} query
59883
59329
  * @param {HastNode} node
59884
59330
  * @param {SelectState} state
59885
- * @returns {Array.<Element>}
59331
+ * @returns {Array<Element>}
59886
59332
  */
59887
59333
  function ruleSet(query, node, state) {
59888
59334
  return rule(query.rule, node, state)
@@ -59892,7 +59338,7 @@ function ruleSet(query, node, state) {
59892
59338
  * @param {Rule} query
59893
59339
  * @param {HastNode} tree
59894
59340
  * @param {SelectState} state
59895
- * @returns {Array.<Element>}
59341
+ * @returns {Array<Element>}
59896
59342
  */
59897
59343
  function rule(query, tree, state) {
59898
59344
  const collector = new Collector(state.one)
@@ -59979,7 +59425,7 @@ class Collector {
59979
59425
  * @param {boolean|undefined} [one]
59980
59426
  */
59981
59427
  constructor(one) {
59982
- /** @type {Array.<Element>} */
59428
+ /** @type {Array<Element>} */
59983
59429
  this.result = []
59984
59430
  /** @type {boolean|undefined} */
59985
59431
  this.one = one
@@ -59990,7 +59436,7 @@ class Collector {
59990
59436
  /**
59991
59437
  * Append nodes to array, filtering out duplicates.
59992
59438
  *
59993
- * @param {Array.<Element>} elements
59439
+ * @param {Array<Element>} elements
59994
59440
  */
59995
59441
  collectAll(elements) {
59996
59442
  let index = -1
@@ -60019,8 +59465,260 @@ class Collector {
60019
59465
 
60020
59466
  // EXTERNAL MODULE: ./node_modules/css-selector-parser/lib/index.js
60021
59467
  var css_selector_parser_lib = __webpack_require__(733);
60022
- // EXTERNAL MODULE: ./node_modules/nth-check/lib/index.js
60023
- 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
60024
59722
  ;// CONCATENATED MODULE: ./node_modules/hast-util-select/lib/parse.js
60025
59723
  /**
60026
59724
  * @typedef {import('./types.js').Selector} Selector
@@ -60037,7 +59735,7 @@ var nth_check_lib = __webpack_require__(483);
60037
59735
 
60038
59736
  /** @type {import('nth-check').default} */
60039
59737
  // @ts-expect-error
60040
- const nthCheck = nth_check_lib/* default */.ZP
59738
+ const parse_nthCheck = nthCheck["default"] || nthCheck
60041
59739
 
60042
59740
  const nth = new Set([
60043
59741
  'nth-child',
@@ -60049,7 +59747,7 @@ const nth = new Set([
60049
59747
  const parse_parser = new css_selector_parser_lib/* CssSelectorParser */.N()
60050
59748
 
60051
59749
  // @ts-expect-error: hush.
60052
- 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}})
60053
59751
 
60054
59752
  parse_parser.registerAttrEqualityMods('~', '|', '^', '$', '*')
60055
59753
  parse_parser.registerSelectorPseudos('any', 'matches', 'not', 'has')
@@ -60065,7 +59763,7 @@ function lib_parse_parse(selector) {
60065
59763
  }
60066
59764
 
60067
59765
  // @ts-expect-error types are wrong.
60068
- return compile(parse_parser.parse(selector))
59766
+ return parse_compile(parse_parser.parse(selector))
60069
59767
  }
60070
59768
 
60071
59769
  /**
@@ -60076,7 +59774,7 @@ function parse_selectors(query) {
60076
59774
  let index = -1
60077
59775
 
60078
59776
  while (++index < query.selectors.length) {
60079
- compile(query.selectors[index])
59777
+ parse_compile(query.selectors[index])
60080
59778
  }
60081
59779
 
60082
59780
  return query
@@ -60103,13 +59801,13 @@ function parse_rule(query) {
60103
59801
 
60104
59802
  if (nth.has(pseudo.name)) {
60105
59803
  // @ts-expect-error Patch a non-primitive type.
60106
- pseudo.value = nthCheck(pseudo.value)
59804
+ pseudo.value = parse_nthCheck(pseudo.value)
60107
59805
  // @ts-expect-error Patch a non-primitive type.
60108
59806
  pseudo.valueType = 'function'
60109
59807
  }
60110
59808
  }
60111
59809
 
60112
- compile(query.rule)
59810
+ parse_compile(query.rule)
60113
59811
 
60114
59812
  return query
60115
59813
  }
@@ -60150,7 +59848,7 @@ function hast_util_select_select(selector, node, space) {
60150
59848
  * @param {string} selector
60151
59849
  * @param {HastNode} [node]
60152
59850
  * @param {Space} [space]
60153
- * @returns {Array.<Element>}
59851
+ * @returns {Array<Element>}
60154
59852
  */
60155
59853
  function selectAll(selector, node, space) {
60156
59854
  return any_any(lib_parse_parse(selector), node, {space})
@@ -60321,8 +60019,7 @@ var jsx_runtime = __webpack_require__(724);
60321
60019
  ;// CONCATENATED MODULE: ./node_modules/@uiw/react-markdown-preview/esm/index.js
60322
60020
 
60323
60021
 
60324
- var _excluded = ["prefixCls", "className", "source", "style", "onScroll", "onMouseOver", "pluginsFilter", "warpperElement"];
60325
-
60022
+ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "onScroll", "onMouseOver", "pluginsFilter", "warpperElement"];
60326
60023
 
60327
60024
 
60328
60025
 
@@ -60337,30 +60034,13 @@ var _excluded = ["prefixCls", "className", "source", "style", "onScroll", "onMou
60337
60034
 
60338
60035
 
60339
60036
 
60340
- var rehypeRewriteHandle = (node, index, parent) => {
60341
- if (node.type === 'element' && parent && parent.type === 'root' && /h(1|2|3|4|5|6)/.test(node.tagName)) {
60342
- var child = node.children && node.children[0];
60343
-
60344
- if (child && child.properties && child.properties.ariaHidden === 'true') {
60345
- child.properties = _extends({
60346
- class: 'anchor'
60347
- }, child.properties);
60348
- child.children = [octiconLink];
60349
- }
60350
- }
60351
-
60352
- if (node.type === 'element' && node.tagName === 'pre') {
60353
- var code = getCodeString(node.children);
60354
- node.children.push(copyElement(code));
60355
- }
60356
- };
60357
-
60358
60037
  /* harmony default export */ const esm = (/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().forwardRef((props, ref) => {
60359
60038
  var {
60360
60039
  prefixCls = 'wmde-markdown wmde-markdown-color',
60361
60040
  className,
60362
60041
  source,
60363
60042
  style,
60043
+ disableCopy = false,
60364
60044
  onScroll,
60365
60045
  onMouseOver,
60366
60046
  pluginsFilter,
@@ -60373,6 +60053,25 @@ var rehypeRewriteHandle = (node, index, parent) => {
60373
60053
  mdp
60374
60054
  }), [mdp, props]);
60375
60055
  var cls = (prefixCls || '') + " " + (className || '');
60056
+
60057
+ var rehypeRewriteHandle = (node, index, parent) => {
60058
+ if (node.type === 'element' && parent && parent.type === 'root' && /h(1|2|3|4|5|6)/.test(node.tagName)) {
60059
+ var child = node.children && node.children[0];
60060
+
60061
+ if (child && child.properties && child.properties.ariaHidden === 'true') {
60062
+ child.properties = _extends({
60063
+ class: 'anchor'
60064
+ }, child.properties);
60065
+ child.children = [octiconLink];
60066
+ }
60067
+ }
60068
+
60069
+ if (node.type === 'element' && node.tagName === 'pre' && !disableCopy) {
60070
+ var code = getCodeString(node.children);
60071
+ node.children.push(copyElement(code));
60072
+ }
60073
+ };
60074
+
60376
60075
  var rehypePlugins = [reservedMeta, [m, {
60377
60076
  ignoreMissing: true
60378
60077
  }], rehypeRaw, rehypeSlug, rehypeAutolinkHeadings, [rehype_rewrite_lib, {
@@ -62556,7 +62255,7 @@ function Child_Child(props){var _ref=props||{},prefixCls=_ref.prefixCls,groupNam
62556
62255
  function ToolbarItems(props){var prefixCls=props.prefixCls,overflow=props.overflow;var _useContext=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useContext)(EditorContext),fullscreen=_useContext.fullscreen,preview=_useContext.preview,_useContext$barPopup=_useContext.barPopup,barPopup=_useContext$barPopup===void 0?{}:_useContext$barPopup,commandOrchestrator=_useContext.commandOrchestrator,dispatch=_useContext.dispatch;var originalOverflow=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)('');function handleClick(command,name){if(!dispatch)return;var state={barPopup:_objectSpread2({},barPopup)};if(command.keyCommand==='preview'){state.preview=command.value;}if(command.keyCommand==='fullscreen'){state.fullscreen=!fullscreen;}if(props.commands&&command.keyCommand==='group'){props.commands.forEach(function(item){if(name===item.groupName){state.barPopup[name]=true;}else if(item.keyCommand){state.barPopup[item.groupName]=false;}});}else if(name||command.parent){Object.keys(state.barPopup||{}).forEach(function(keyName){state.barPopup[keyName]=false;});}if(Object.keys(state).length){dispatch(_objectSpread2({},state));}commandOrchestrator&&commandOrchestrator.executeCommand(command);}(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(document&&overflow){if(fullscreen){// prevent scroll on fullscreen
62557
62256
  document.body.style.overflow='hidden';}else{// get the original overflow only the first time
62558
62257
  if(!originalOverflow.current){originalOverflow.current=window.getComputedStyle(document.body,null).overflow;}// reset to the original overflow
62559
- document.body.style.overflow=originalOverflow.current;}}},[fullscreen,originalOverflow,overflow]);return/*#__PURE__*/(0,jsx_runtime.jsx)("ul",{children:(props.commands||[]).map(function(item,idx){if(item.keyCommand==='divider'){return/*#__PURE__*/(0,jsx_runtime.jsx)("li",_objectSpread2(_objectSpread2({},item.liProps),{},{className:"".concat(prefixCls,"-toolbar-divider")}),idx);}if(!item.keyCommand)return/*#__PURE__*/(0,jsx_runtime.jsx)(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment,{},idx);var activeBtn=fullscreen&&item.keyCommand==='fullscreen'||item.keyCommand==='preview'&&preview===item.value;var childNode=item.children&&typeof item.children==='function'?item.children({getState:function getState(){return commandOrchestrator.getState();},textApi:commandOrchestrator?commandOrchestrator.textApi:undefined,close:function close(){return handleClick({},item.groupName);},execute:function execute(){return handleClick({execute:item.execute});}}):undefined;var disabled=barPopup&&preview&&preview==='preview'&&!/(preview|fullscreen)/.test(item.keyCommand);return/*#__PURE__*/(0,jsx_runtime.jsxs)("li",_objectSpread2(_objectSpread2({},item.liProps),{},{className:activeBtn?"active":'',children:[!item.buttonProps&&item.icon,item.buttonProps&&/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement('button',_objectSpread2(_objectSpread2({type:'button',key:idx,disabled:disabled,'data-name':item.name},item.buttonProps),{},{onClick:function onClick(evn){evn.stopPropagation();handleClick(item,item.groupName);}}),item.icon),item.children&&/*#__PURE__*/(0,jsx_runtime.jsx)(Child_Child,{overflow:overflow,groupName:item.groupName,prefixCls:prefixCls,children:childNode,commands:Array.isArray(item.children)?item.children:undefined})]}),idx);})});}function Toolbar_Toolbar(){var props=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var prefixCls=props.prefixCls,_props$height=props.height,height=_props$height===void 0?29:_props$height,isChild=props.isChild;var _useContext2=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useContext)(EditorContext),commands=_useContext2.commands,extraCommands=_useContext2.extraCommands;return/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{className:"".concat(prefixCls,"-toolbar"),style:{height:height},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ToolbarItems,_objectSpread2(_objectSpread2({},props),{},{commands:props.commands||commands||[]})),!isChild&&/*#__PURE__*/(0,jsx_runtime.jsx)(ToolbarItems,_objectSpread2(_objectSpread2({},props),{},{commands:extraCommands||[]}))]});}
62258
+ document.body.style.overflow=originalOverflow.current;}}},[fullscreen,originalOverflow,overflow]);return/*#__PURE__*/(0,jsx_runtime.jsx)("ul",{children:(props.commands||[]).map(function(item,idx){if(item.keyCommand==='divider'){return/*#__PURE__*/(0,jsx_runtime.jsx)("li",_objectSpread2(_objectSpread2({},item.liProps),{},{className:"".concat(prefixCls,"-toolbar-divider")}),idx);}if(!item.keyCommand)return/*#__PURE__*/(0,jsx_runtime.jsx)(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment,{},idx);var activeBtn=fullscreen&&item.keyCommand==='fullscreen'||item.keyCommand==='preview'&&preview===item.value;var childNode=item.children&&typeof item.children==='function'?item.children({getState:function getState(){return commandOrchestrator.getState();},textApi:commandOrchestrator?commandOrchestrator.textApi:undefined,close:function close(){return handleClick({},item.groupName);},execute:function execute(){return handleClick({execute:item.execute});}}):undefined;var disabled=barPopup&&preview&&preview==='preview'&&!/(preview|fullscreen)/.test(item.keyCommand);return/*#__PURE__*/(0,jsx_runtime.jsxs)("li",_objectSpread2(_objectSpread2({},item.liProps),{},{className:activeBtn?"active":'',children:[!item.buttonProps&&item.icon,item.buttonProps&&/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement('button',_objectSpread2(_objectSpread2({type:'button',key:idx,disabled:disabled,'data-name':item.name},item.buttonProps),{},{onClick:function onClick(evn){evn.stopPropagation();handleClick(item,item.groupName);}}),item.icon),item.children&&/*#__PURE__*/(0,jsx_runtime.jsx)(Child_Child,{overflow:overflow,groupName:item.groupName,prefixCls:prefixCls,children:childNode,commands:Array.isArray(item.children)?item.children:undefined})]}),idx);})});}function Toolbar_Toolbar(){var props=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var prefixCls=props.prefixCls,_props$height=props.height,height=_props$height===void 0?29:_props$height,toolbarBottom=props.toolbarBottom,isChild=props.isChild;var _useContext2=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useContext)(EditorContext),commands=_useContext2.commands,extraCommands=_useContext2.extraCommands;var bottomClassName=toolbarBottom?'bottom':'';return/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{className:"".concat(prefixCls,"-toolbar ").concat(bottomClassName),style:{height:height},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ToolbarItems,_objectSpread2(_objectSpread2({},props),{},{commands:props.commands||commands||[]})),!isChild&&/*#__PURE__*/(0,jsx_runtime.jsx)(ToolbarItems,_objectSpread2(_objectSpread2({},props),{},{commands:extraCommands||[]}))]});}
62560
62259
  ;// CONCATENATED MODULE: ./src/components/DragBar/index.less
62561
62260
  // extracted by mini-css-extract-plugin
62562
62261
  /* harmony default export */ const DragBar = ({});
@@ -62567,14 +62266,14 @@ var DragBar_DragBar=function DragBar(props){var _ref=props||{},prefixCls=_ref.pr
62567
62266
  // extracted by mini-css-extract-plugin
62568
62267
  /* harmony default export */ const src = ({});
62569
62268
  ;// CONCATENATED MODULE: ./src/Editor.tsx
62570
- 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","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,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?typeof props.visiableDragbar==='boolean'?props.visiableDragbar: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
62571
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
62572
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
62573
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
62574
62273
  [highlightEnable]);// eslint-disable-next-line react-hooks/exhaustive-deps
62575
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
62576
62275
  [fullscreen]);// eslint-disable-next-line react-hooks/exhaustive-deps
62577
- (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&&/*#__PURE__*/(0,jsx_runtime.jsx)(Toolbar_Toolbar,{prefixCls:prefixCls,height:toolbarHeight,overflow:overflow}),/*#__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});}})]}))});};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);
62578
62277
  ;// CONCATENATED MODULE: ./src/index.tsx
62579
62278
  /* harmony default export */ const src_0 = (Editor);
62580
62279
  })();