@uiw/react-md-editor 3.12.3 → 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/mdeditor.css +5 -0
  2. package/dist/mdeditor.js +846 -1376
  3. package/dist/mdeditor.min.css +1 -1
  4. package/dist/mdeditor.min.js +1 -1
  5. package/dist/mdeditor.min.js.LICENSE.txt +0 -9
  6. package/esm/Editor.d.ts +2 -0
  7. package/esm/Editor.js +10 -3
  8. package/esm/Editor.js.map +3 -2
  9. package/esm/components/Toolbar/index.css +5 -0
  10. package/esm/components/Toolbar/index.d.ts +1 -0
  11. package/esm/components/Toolbar/index.js +3 -1
  12. package/esm/components/Toolbar/index.js.map +5 -3
  13. package/esm/components/Toolbar/index.less +5 -0
  14. package/lib/Context.js.map +1 -1
  15. package/lib/Editor.d.ts +2 -0
  16. package/lib/Editor.js +11 -3
  17. package/lib/Editor.js.map +10 -2
  18. package/lib/commands/bold.js.map +2 -1
  19. package/lib/commands/code.js.map +4 -1
  20. package/lib/commands/comment.js.map +2 -1
  21. package/lib/commands/image.js.map +2 -1
  22. package/lib/commands/index.js.map +2 -1
  23. package/lib/commands/italic.js.map +2 -1
  24. package/lib/commands/link.js.map +2 -1
  25. package/lib/commands/list.js.map +4 -1
  26. package/lib/commands/quote.js.map +4 -1
  27. package/lib/commands/strikeThrough.js.map +2 -1
  28. package/lib/commands/title1.js.map +2 -1
  29. package/lib/commands/title2.js.map +2 -1
  30. package/lib/commands/title3.js.map +2 -1
  31. package/lib/commands/title4.js.map +2 -1
  32. package/lib/commands/title5.js.map +2 -1
  33. package/lib/commands/title6.js.map +2 -1
  34. package/lib/components/DragBar/index.js.map +5 -2
  35. package/lib/components/TextArea/Markdown.js.map +5 -1
  36. package/lib/components/TextArea/Textarea.js.map +5 -1
  37. package/lib/components/TextArea/handleKeyDown.js.map +3 -1
  38. package/lib/components/TextArea/index.js.map +3 -2
  39. package/lib/components/Toolbar/Child.js.map +3 -1
  40. package/lib/components/Toolbar/index.d.ts +1 -0
  41. package/lib/components/Toolbar/index.js +3 -1
  42. package/lib/components/Toolbar/index.js.map +8 -3
  43. package/lib/components/Toolbar/index.less +5 -0
  44. package/markdown-editor.css +5 -0
  45. package/package.json +1 -1
  46. package/src/Editor.tsx +9 -1
  47. package/src/components/Toolbar/index.less +5 -0
  48. package/src/components/Toolbar/index.tsx +4 -2
package/dist/mdeditor.js CHANGED
@@ -9504,1276 +9504,6 @@ Mixin.install = function(host, Ctor, opts) {
9504
9504
  module.exports = Mixin;
9505
9505
 
9506
9506
 
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
9507
  /***/ }),
10778
9508
 
10779
9509
  /***/ 59:
@@ -11064,18 +9794,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__787__;
11064
9794
  /******/ };
11065
9795
  /******/ })();
11066
9796
  /******/
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
9797
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
11080
9798
  /******/ (() => {
11081
9799
  /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
@@ -37992,8 +36710,823 @@ function disallowed(code) {
37992
36710
  )
37993
36711
  }
37994
36712
 
37995
- // EXTERNAL MODULE: ./node_modules/prismjs/components/prism-core.js
37996
- var prism_core = __webpack_require__(975);
36713
+ ;// CONCATENATED MODULE: ./node_modules/refractor/lib/prism-core.js
36714
+ // @ts-nocheck
36715
+
36716
+ // This is a slimmed down version of `prism-core.js`, to remove globals,
36717
+ // document, workers, `util.encode`, `Token.stringify`
36718
+
36719
+ // Private helper vars
36720
+ var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i
36721
+ var uniqueId = 0
36722
+
36723
+ // The grammar object for plaintext
36724
+ var plainTextGrammar = {}
36725
+
36726
+ var _ = {
36727
+ /**
36728
+ * A namespace for utility methods.
36729
+ *
36730
+ * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
36731
+ * change or disappear at any time.
36732
+ *
36733
+ * @namespace
36734
+ * @memberof Prism
36735
+ */
36736
+ util: {
36737
+ /**
36738
+ * Returns the name of the type of the given value.
36739
+ *
36740
+ * @param {any} o
36741
+ * @returns {string}
36742
+ * @example
36743
+ * type(null) === 'Null'
36744
+ * type(undefined) === 'Undefined'
36745
+ * type(123) === 'Number'
36746
+ * type('foo') === 'String'
36747
+ * type(true) === 'Boolean'
36748
+ * type([1, 2]) === 'Array'
36749
+ * type({}) === 'Object'
36750
+ * type(String) === 'Function'
36751
+ * type(/abc+/) === 'RegExp'
36752
+ */
36753
+ type: function (o) {
36754
+ return Object.prototype.toString.call(o).slice(8, -1)
36755
+ },
36756
+
36757
+ /**
36758
+ * Returns a unique number for the given object. Later calls will still return the same number.
36759
+ *
36760
+ * @param {Object} obj
36761
+ * @returns {number}
36762
+ */
36763
+ objId: function (obj) {
36764
+ if (!obj['__id']) {
36765
+ Object.defineProperty(obj, '__id', {value: ++uniqueId})
36766
+ }
36767
+ return obj['__id']
36768
+ },
36769
+
36770
+ /**
36771
+ * Creates a deep clone of the given object.
36772
+ *
36773
+ * The main intended use of this function is to clone language definitions.
36774
+ *
36775
+ * @param {T} o
36776
+ * @param {Record<number, any>} [visited]
36777
+ * @returns {T}
36778
+ * @template T
36779
+ */
36780
+ clone: function deepClone(o, visited) {
36781
+ visited = visited || {}
36782
+
36783
+ var clone
36784
+ var id
36785
+ switch (_.util.type(o)) {
36786
+ case 'Object':
36787
+ id = _.util.objId(o)
36788
+ if (visited[id]) {
36789
+ return visited[id]
36790
+ }
36791
+ clone = /** @type {Record<string, any>} */ ({})
36792
+ visited[id] = clone
36793
+
36794
+ for (var key in o) {
36795
+ if (o.hasOwnProperty(key)) {
36796
+ clone[key] = deepClone(o[key], visited)
36797
+ }
36798
+ }
36799
+
36800
+ return /** @type {any} */ (clone)
36801
+
36802
+ case 'Array':
36803
+ id = _.util.objId(o)
36804
+ if (visited[id]) {
36805
+ return visited[id]
36806
+ }
36807
+ clone = []
36808
+ visited[id] = clone
36809
+
36810
+ o.forEach(function (v, i) {
36811
+ clone[i] = deepClone(v, visited)
36812
+ })
36813
+
36814
+ return /** @type {any} */ (clone)
36815
+
36816
+ default:
36817
+ return o
36818
+ }
36819
+ }
36820
+ },
36821
+
36822
+ /**
36823
+ * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
36824
+ *
36825
+ * @namespace
36826
+ * @memberof Prism
36827
+ * @public
36828
+ */
36829
+ languages: {
36830
+ /**
36831
+ * The grammar for plain, unformatted text.
36832
+ */
36833
+ plain: plainTextGrammar,
36834
+ plaintext: plainTextGrammar,
36835
+ text: plainTextGrammar,
36836
+ txt: plainTextGrammar,
36837
+
36838
+ /**
36839
+ * Creates a deep copy of the language with the given id and appends the given tokens.
36840
+ *
36841
+ * If a token in `redef` also appears in the copied language, then the existing token in the copied language
36842
+ * will be overwritten at its original position.
36843
+ *
36844
+ * ## Best practices
36845
+ *
36846
+ * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
36847
+ * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
36848
+ * understand the language definition because, normally, the order of tokens matters in Prism grammars.
36849
+ *
36850
+ * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
36851
+ * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
36852
+ *
36853
+ * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
36854
+ * @param {Grammar} redef The new tokens to append.
36855
+ * @returns {Grammar} The new language created.
36856
+ * @public
36857
+ * @example
36858
+ * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
36859
+ * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
36860
+ * // at its original position
36861
+ * 'comment': { ... },
36862
+ * // CSS doesn't have a 'color' token, so this token will be appended
36863
+ * 'color': /\b(?:red|green|blue)\b/
36864
+ * });
36865
+ */
36866
+ extend: function (id, redef) {
36867
+ var lang = _.util.clone(_.languages[id])
36868
+
36869
+ for (var key in redef) {
36870
+ lang[key] = redef[key]
36871
+ }
36872
+
36873
+ return lang
36874
+ },
36875
+
36876
+ /**
36877
+ * Inserts tokens _before_ another token in a language definition or any other grammar.
36878
+ *
36879
+ * ## Usage
36880
+ *
36881
+ * This helper method makes it easy to modify existing languages. For example, the CSS language definition
36882
+ * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
36883
+ * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
36884
+ * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
36885
+ * this:
36886
+ *
36887
+ * ```js
36888
+ * Prism.languages.markup.style = {
36889
+ * // token
36890
+ * };
36891
+ * ```
36892
+ *
36893
+ * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
36894
+ * before existing tokens. For the CSS example above, you would use it like this:
36895
+ *
36896
+ * ```js
36897
+ * Prism.languages.insertBefore('markup', 'cdata', {
36898
+ * 'style': {
36899
+ * // token
36900
+ * }
36901
+ * });
36902
+ * ```
36903
+ *
36904
+ * ## Special cases
36905
+ *
36906
+ * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
36907
+ * will be ignored.
36908
+ *
36909
+ * This behavior can be used to insert tokens after `before`:
36910
+ *
36911
+ * ```js
36912
+ * Prism.languages.insertBefore('markup', 'comment', {
36913
+ * 'comment': Prism.languages.markup.comment,
36914
+ * // tokens after 'comment'
36915
+ * });
36916
+ * ```
36917
+ *
36918
+ * ## Limitations
36919
+ *
36920
+ * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
36921
+ * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
36922
+ * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
36923
+ * deleting properties which is necessary to insert at arbitrary positions.
36924
+ *
36925
+ * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
36926
+ * Instead, it will create a new object and replace all references to the target object with the new one. This
36927
+ * can be done without temporarily deleting properties, so the iteration order is well-defined.
36928
+ *
36929
+ * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
36930
+ * you hold the target object in a variable, then the value of the variable will not change.
36931
+ *
36932
+ * ```js
36933
+ * var oldMarkup = Prism.languages.markup;
36934
+ * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
36935
+ *
36936
+ * assert(oldMarkup !== Prism.languages.markup);
36937
+ * assert(newMarkup === Prism.languages.markup);
36938
+ * ```
36939
+ *
36940
+ * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
36941
+ * object to be modified.
36942
+ * @param {string} before The key to insert before.
36943
+ * @param {Grammar} insert An object containing the key-value pairs to be inserted.
36944
+ * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
36945
+ * object to be modified.
36946
+ *
36947
+ * Defaults to `Prism.languages`.
36948
+ * @returns {Grammar} The new grammar object.
36949
+ * @public
36950
+ */
36951
+ insertBefore: function (inside, before, insert, root) {
36952
+ root = root || /** @type {any} */ (_.languages)
36953
+ var grammar = root[inside]
36954
+ /** @type {Grammar} */
36955
+ var ret = {}
36956
+
36957
+ for (var token in grammar) {
36958
+ if (grammar.hasOwnProperty(token)) {
36959
+ if (token == before) {
36960
+ for (var newToken in insert) {
36961
+ if (insert.hasOwnProperty(newToken)) {
36962
+ ret[newToken] = insert[newToken]
36963
+ }
36964
+ }
36965
+ }
36966
+
36967
+ // Do not insert token which also occur in insert. See #1525
36968
+ if (!insert.hasOwnProperty(token)) {
36969
+ ret[token] = grammar[token]
36970
+ }
36971
+ }
36972
+ }
36973
+
36974
+ var old = root[inside]
36975
+ root[inside] = ret
36976
+
36977
+ // Update references in other language definitions
36978
+ _.languages.DFS(_.languages, function (key, value) {
36979
+ if (value === old && key != inside) {
36980
+ this[key] = ret
36981
+ }
36982
+ })
36983
+
36984
+ return ret
36985
+ },
36986
+
36987
+ // Traverse a language definition with Depth First Search
36988
+ DFS: function DFS(o, callback, type, visited) {
36989
+ visited = visited || {}
36990
+
36991
+ var objId = _.util.objId
36992
+
36993
+ for (var i in o) {
36994
+ if (o.hasOwnProperty(i)) {
36995
+ callback.call(o, i, o[i], type || i)
36996
+
36997
+ var property = o[i]
36998
+ var propertyType = _.util.type(property)
36999
+
37000
+ if (propertyType === 'Object' && !visited[objId(property)]) {
37001
+ visited[objId(property)] = true
37002
+ DFS(property, callback, null, visited)
37003
+ } else if (propertyType === 'Array' && !visited[objId(property)]) {
37004
+ visited[objId(property)] = true
37005
+ DFS(property, callback, i, visited)
37006
+ }
37007
+ }
37008
+ }
37009
+ }
37010
+ },
37011
+
37012
+ plugins: {},
37013
+
37014
+ /**
37015
+ * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
37016
+ * and the language definitions to use, and returns a string with the HTML produced.
37017
+ *
37018
+ * The following hooks will be run:
37019
+ * 1. `before-tokenize`
37020
+ * 2. `after-tokenize`
37021
+ * 3. `wrap`: On each {@link Token}.
37022
+ *
37023
+ * @param {string} text A string with the code to be highlighted.
37024
+ * @param {Grammar} grammar An object containing the tokens to use.
37025
+ *
37026
+ * Usually a language definition like `Prism.languages.markup`.
37027
+ * @param {string} language The name of the language definition passed to `grammar`.
37028
+ * @returns {string} The highlighted HTML.
37029
+ * @memberof Prism
37030
+ * @public
37031
+ * @example
37032
+ * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
37033
+ */
37034
+ highlight: function (text, grammar, language) {
37035
+ var env = {
37036
+ code: text,
37037
+ grammar: grammar,
37038
+ language: language
37039
+ }
37040
+ _.hooks.run('before-tokenize', env)
37041
+ if (!env.grammar) {
37042
+ throw new Error('The language "' + env.language + '" has no grammar.')
37043
+ }
37044
+ env.tokens = _.tokenize(env.code, env.grammar)
37045
+ _.hooks.run('after-tokenize', env)
37046
+ return Token.stringify(_.util.encode(env.tokens), env.language)
37047
+ },
37048
+
37049
+ /**
37050
+ * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
37051
+ * and the language definitions to use, and returns an array with the tokenized code.
37052
+ *
37053
+ * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
37054
+ *
37055
+ * This method could be useful in other contexts as well, as a very crude parser.
37056
+ *
37057
+ * @param {string} text A string with the code to be highlighted.
37058
+ * @param {Grammar} grammar An object containing the tokens to use.
37059
+ *
37060
+ * Usually a language definition like `Prism.languages.markup`.
37061
+ * @returns {TokenStream} An array of strings and tokens, a token stream.
37062
+ * @memberof Prism
37063
+ * @public
37064
+ * @example
37065
+ * let code = `var foo = 0;`;
37066
+ * let tokens = Prism.tokenize(code, Prism.languages.javascript);
37067
+ * tokens.forEach(token => {
37068
+ * if (token instanceof Prism.Token && token.type === 'number') {
37069
+ * console.log(`Found numeric literal: ${token.content}`);
37070
+ * }
37071
+ * });
37072
+ */
37073
+ tokenize: function (text, grammar) {
37074
+ var rest = grammar.rest
37075
+ if (rest) {
37076
+ for (var token in rest) {
37077
+ grammar[token] = rest[token]
37078
+ }
37079
+
37080
+ delete grammar.rest
37081
+ }
37082
+
37083
+ var tokenList = new LinkedList()
37084
+ addAfter(tokenList, tokenList.head, text)
37085
+
37086
+ matchGrammar(text, tokenList, grammar, tokenList.head, 0)
37087
+
37088
+ return toArray(tokenList)
37089
+ },
37090
+
37091
+ /**
37092
+ * @namespace
37093
+ * @memberof Prism
37094
+ * @public
37095
+ */
37096
+ hooks: {
37097
+ all: {},
37098
+
37099
+ /**
37100
+ * Adds the given callback to the list of callbacks for the given hook.
37101
+ *
37102
+ * The callback will be invoked when the hook it is registered for is run.
37103
+ * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
37104
+ *
37105
+ * One callback function can be registered to multiple hooks and the same hook multiple times.
37106
+ *
37107
+ * @param {string} name The name of the hook.
37108
+ * @param {HookCallback} callback The callback function which is given environment variables.
37109
+ * @public
37110
+ */
37111
+ add: function (name, callback) {
37112
+ var hooks = _.hooks.all
37113
+
37114
+ hooks[name] = hooks[name] || []
37115
+
37116
+ hooks[name].push(callback)
37117
+ },
37118
+
37119
+ /**
37120
+ * Runs a hook invoking all registered callbacks with the given environment variables.
37121
+ *
37122
+ * Callbacks will be invoked synchronously and in the order in which they were registered.
37123
+ *
37124
+ * @param {string} name The name of the hook.
37125
+ * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
37126
+ * @public
37127
+ */
37128
+ run: function (name, env) {
37129
+ var callbacks = _.hooks.all[name]
37130
+
37131
+ if (!callbacks || !callbacks.length) {
37132
+ return
37133
+ }
37134
+
37135
+ for (var i = 0, callback; (callback = callbacks[i++]); ) {
37136
+ callback(env)
37137
+ }
37138
+ }
37139
+ },
37140
+
37141
+ Token: Token
37142
+ }
37143
+
37144
+ // Typescript note:
37145
+ // The following can be used to import the Token type in JSDoc:
37146
+ //
37147
+ // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
37148
+
37149
+ /**
37150
+ * Creates a new token.
37151
+ *
37152
+ * @param {string} type See {@link Token#type type}
37153
+ * @param {string | TokenStream} content See {@link Token#content content}
37154
+ * @param {string|string[]} [alias] The alias(es) of the token.
37155
+ * @param {string} [matchedStr=""] A copy of the full string this token was created from.
37156
+ * @class
37157
+ * @global
37158
+ * @public
37159
+ */
37160
+ function Token(type, content, alias, matchedStr) {
37161
+ /**
37162
+ * The type of the token.
37163
+ *
37164
+ * This is usually the key of a pattern in a {@link Grammar}.
37165
+ *
37166
+ * @type {string}
37167
+ * @see GrammarToken
37168
+ * @public
37169
+ */
37170
+ this.type = type
37171
+ /**
37172
+ * The strings or tokens contained by this token.
37173
+ *
37174
+ * This will be a token stream if the pattern matched also defined an `inside` grammar.
37175
+ *
37176
+ * @type {string | TokenStream}
37177
+ * @public
37178
+ */
37179
+ this.content = content
37180
+ /**
37181
+ * The alias(es) of the token.
37182
+ *
37183
+ * @type {string|string[]}
37184
+ * @see GrammarToken
37185
+ * @public
37186
+ */
37187
+ this.alias = alias
37188
+ // Copy of the full string this token was created from
37189
+ this.length = (matchedStr || '').length | 0
37190
+ }
37191
+
37192
+ /**
37193
+ * A token stream is an array of strings and {@link Token Token} objects.
37194
+ *
37195
+ * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
37196
+ * them.
37197
+ *
37198
+ * 1. No adjacent strings.
37199
+ * 2. No empty strings.
37200
+ *
37201
+ * The only exception here is the token stream that only contains the empty string and nothing else.
37202
+ *
37203
+ * @typedef {Array<string | Token>} TokenStream
37204
+ * @global
37205
+ * @public
37206
+ */
37207
+
37208
+ /**
37209
+ * @param {RegExp} pattern
37210
+ * @param {number} pos
37211
+ * @param {string} text
37212
+ * @param {boolean} lookbehind
37213
+ * @returns {RegExpExecArray | null}
37214
+ */
37215
+ function matchPattern(pattern, pos, text, lookbehind) {
37216
+ pattern.lastIndex = pos
37217
+ var match = pattern.exec(text)
37218
+ if (match && lookbehind && match[1]) {
37219
+ // change the match to remove the text matched by the Prism lookbehind group
37220
+ var lookbehindLength = match[1].length
37221
+ match.index += lookbehindLength
37222
+ match[0] = match[0].slice(lookbehindLength)
37223
+ }
37224
+ return match
37225
+ }
37226
+
37227
+ /**
37228
+ * @param {string} text
37229
+ * @param {LinkedList<string | Token>} tokenList
37230
+ * @param {any} grammar
37231
+ * @param {LinkedListNode<string | Token>} startNode
37232
+ * @param {number} startPos
37233
+ * @param {RematchOptions} [rematch]
37234
+ * @returns {void}
37235
+ * @private
37236
+ *
37237
+ * @typedef RematchOptions
37238
+ * @property {string} cause
37239
+ * @property {number} reach
37240
+ */
37241
+ function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
37242
+ for (var token in grammar) {
37243
+ if (!grammar.hasOwnProperty(token) || !grammar[token]) {
37244
+ continue
37245
+ }
37246
+
37247
+ var patterns = grammar[token]
37248
+ patterns = Array.isArray(patterns) ? patterns : [patterns]
37249
+
37250
+ for (var j = 0; j < patterns.length; ++j) {
37251
+ if (rematch && rematch.cause == token + ',' + j) {
37252
+ return
37253
+ }
37254
+
37255
+ var patternObj = patterns[j]
37256
+ var inside = patternObj.inside
37257
+ var lookbehind = !!patternObj.lookbehind
37258
+ var greedy = !!patternObj.greedy
37259
+ var alias = patternObj.alias
37260
+
37261
+ if (greedy && !patternObj.pattern.global) {
37262
+ // Without the global flag, lastIndex won't work
37263
+ var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0]
37264
+ patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g')
37265
+ }
37266
+
37267
+ /** @type {RegExp} */
37268
+ var pattern = patternObj.pattern || patternObj
37269
+
37270
+ for (
37271
+ // iterate the token list and keep track of the current token/string position
37272
+ var currentNode = startNode.next, pos = startPos;
37273
+ currentNode !== tokenList.tail;
37274
+ pos += currentNode.value.length, currentNode = currentNode.next
37275
+ ) {
37276
+ if (rematch && pos >= rematch.reach) {
37277
+ break
37278
+ }
37279
+
37280
+ var str = currentNode.value
37281
+
37282
+ if (tokenList.length > text.length) {
37283
+ // Something went terribly wrong, ABORT, ABORT!
37284
+ return
37285
+ }
37286
+
37287
+ if (str instanceof Token) {
37288
+ continue
37289
+ }
37290
+
37291
+ var removeCount = 1 // this is the to parameter of removeBetween
37292
+ var match
37293
+
37294
+ if (greedy) {
37295
+ match = matchPattern(pattern, pos, text, lookbehind)
37296
+ if (!match || match.index >= text.length) {
37297
+ break
37298
+ }
37299
+
37300
+ var from = match.index
37301
+ var to = match.index + match[0].length
37302
+ var p = pos
37303
+
37304
+ // find the node that contains the match
37305
+ p += currentNode.value.length
37306
+ while (from >= p) {
37307
+ currentNode = currentNode.next
37308
+ p += currentNode.value.length
37309
+ }
37310
+ // adjust pos (and p)
37311
+ p -= currentNode.value.length
37312
+ pos = p
37313
+
37314
+ // the current node is a Token, then the match starts inside another Token, which is invalid
37315
+ if (currentNode.value instanceof Token) {
37316
+ continue
37317
+ }
37318
+
37319
+ // find the last node which is affected by this match
37320
+ for (
37321
+ var k = currentNode;
37322
+ k !== tokenList.tail && (p < to || typeof k.value === 'string');
37323
+ k = k.next
37324
+ ) {
37325
+ removeCount++
37326
+ p += k.value.length
37327
+ }
37328
+ removeCount--
37329
+
37330
+ // replace with the new match
37331
+ str = text.slice(pos, p)
37332
+ match.index -= pos
37333
+ } else {
37334
+ match = matchPattern(pattern, 0, str, lookbehind)
37335
+ if (!match) {
37336
+ continue
37337
+ }
37338
+ }
37339
+
37340
+ // eslint-disable-next-line no-redeclare
37341
+ var from = match.index
37342
+ var matchStr = match[0]
37343
+ var before = str.slice(0, from)
37344
+ var after = str.slice(from + matchStr.length)
37345
+
37346
+ var reach = pos + str.length
37347
+ if (rematch && reach > rematch.reach) {
37348
+ rematch.reach = reach
37349
+ }
37350
+
37351
+ var removeFrom = currentNode.prev
37352
+
37353
+ if (before) {
37354
+ removeFrom = addAfter(tokenList, removeFrom, before)
37355
+ pos += before.length
37356
+ }
37357
+
37358
+ removeRange(tokenList, removeFrom, removeCount)
37359
+
37360
+ var wrapped = new Token(
37361
+ token,
37362
+ inside ? _.tokenize(matchStr, inside) : matchStr,
37363
+ alias,
37364
+ matchStr
37365
+ )
37366
+ currentNode = addAfter(tokenList, removeFrom, wrapped)
37367
+
37368
+ if (after) {
37369
+ addAfter(tokenList, currentNode, after)
37370
+ }
37371
+
37372
+ if (removeCount > 1) {
37373
+ // at least one Token object was removed, so we have to do some rematching
37374
+ // this can only happen if the current pattern is greedy
37375
+
37376
+ /** @type {RematchOptions} */
37377
+ var nestedRematch = {
37378
+ cause: token + ',' + j,
37379
+ reach: reach
37380
+ }
37381
+ matchGrammar(
37382
+ text,
37383
+ tokenList,
37384
+ grammar,
37385
+ currentNode.prev,
37386
+ pos,
37387
+ nestedRematch
37388
+ )
37389
+
37390
+ // the reach might have been extended because of the rematching
37391
+ if (rematch && nestedRematch.reach > rematch.reach) {
37392
+ rematch.reach = nestedRematch.reach
37393
+ }
37394
+ }
37395
+ }
37396
+ }
37397
+ }
37398
+ }
37399
+
37400
+ /**
37401
+ * @typedef LinkedListNode
37402
+ * @property {T} value
37403
+ * @property {LinkedListNode<T> | null} prev The previous node.
37404
+ * @property {LinkedListNode<T> | null} next The next node.
37405
+ * @template T
37406
+ * @private
37407
+ */
37408
+
37409
+ /**
37410
+ * @template T
37411
+ * @private
37412
+ */
37413
+ function LinkedList() {
37414
+ /** @type {LinkedListNode<T>} */
37415
+ var head = {value: null, prev: null, next: null}
37416
+ /** @type {LinkedListNode<T>} */
37417
+ var tail = {value: null, prev: head, next: null}
37418
+ head.next = tail
37419
+
37420
+ /** @type {LinkedListNode<T>} */
37421
+ this.head = head
37422
+ /** @type {LinkedListNode<T>} */
37423
+ this.tail = tail
37424
+ this.length = 0
37425
+ }
37426
+
37427
+ /**
37428
+ * Adds a new node with the given value to the list.
37429
+ *
37430
+ * @param {LinkedList<T>} list
37431
+ * @param {LinkedListNode<T>} node
37432
+ * @param {T} value
37433
+ * @returns {LinkedListNode<T>} The added node.
37434
+ * @template T
37435
+ */
37436
+ function addAfter(list, node, value) {
37437
+ // assumes that node != list.tail && values.length >= 0
37438
+ var next = node.next
37439
+
37440
+ var newNode = {value: value, prev: node, next: next}
37441
+ node.next = newNode
37442
+ next.prev = newNode
37443
+ list.length++
37444
+
37445
+ return newNode
37446
+ }
37447
+ /**
37448
+ * Removes `count` nodes after the given node. The given node will not be removed.
37449
+ *
37450
+ * @param {LinkedList<T>} list
37451
+ * @param {LinkedListNode<T>} node
37452
+ * @param {number} count
37453
+ * @template T
37454
+ */
37455
+ function removeRange(list, node, count) {
37456
+ var next = node.next
37457
+ for (var i = 0; i < count && next !== list.tail; i++) {
37458
+ next = next.next
37459
+ }
37460
+ node.next = next
37461
+ next.prev = node
37462
+ list.length -= i
37463
+ }
37464
+ /**
37465
+ * @param {LinkedList<T>} list
37466
+ * @returns {T[]}
37467
+ * @template T
37468
+ */
37469
+ function toArray(list) {
37470
+ var array = []
37471
+ var node = list.head.next
37472
+ while (node !== list.tail) {
37473
+ array.push(node.value)
37474
+ node = node.next
37475
+ }
37476
+ return array
37477
+ }
37478
+
37479
+ const Prism = _
37480
+
37481
+ // some additional documentation/types
37482
+
37483
+ /**
37484
+ * The expansion of a simple `RegExp` literal to support additional properties.
37485
+ *
37486
+ * @typedef GrammarToken
37487
+ * @property {RegExp} pattern The regular expression of the token.
37488
+ * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
37489
+ * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
37490
+ * @property {boolean} [greedy=false] Whether the token is greedy.
37491
+ * @property {string|string[]} [alias] An optional alias or list of aliases.
37492
+ * @property {Grammar} [inside] The nested grammar of this token.
37493
+ *
37494
+ * The `inside` grammar will be used to tokenize the text value of each token of this kind.
37495
+ *
37496
+ * This can be used to make nested and even recursive language definitions.
37497
+ *
37498
+ * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
37499
+ * each another.
37500
+ * @global
37501
+ * @public
37502
+ */
37503
+
37504
+ /**
37505
+ * @typedef Grammar
37506
+ * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
37507
+ * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
37508
+ * @global
37509
+ * @public
37510
+ */
37511
+
37512
+ /**
37513
+ * A function which will invoked after an element was successfully highlighted.
37514
+ *
37515
+ * @callback HighlightCallback
37516
+ * @param {Element} element The element successfully highlighted.
37517
+ * @returns {void}
37518
+ * @global
37519
+ * @public
37520
+ */
37521
+
37522
+ /**
37523
+ * @callback HookCallback
37524
+ * @param {Object<string, any>} env The environment variables of the hook.
37525
+ * @returns {void}
37526
+ * @global
37527
+ * @public
37528
+ */
37529
+
37997
37530
  ;// CONCATENATED MODULE: ./node_modules/refractor/lib/core.js
37998
37531
  /**
37999
37532
  * @typedef _Token A hidden Prism token
@@ -38029,53 +37562,18 @@ var prism_core = __webpack_require__(975);
38029
37562
  * @property {Languages} languages
38030
37563
  */
38031
37564
 
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
37565
  // Load all stuff in `prism.js` itself, except for `prism-file-highlight.js`.
38063
37566
  // The wrapped non-leaky grammars are loaded instead of Prism’s originals.
38064
- ;
38065
-
38066
- // @ts-expect-error: untyped.
38067
37567
 
38068
37568
 
38069
- /* eslint-enable import/first */
38070
37569
 
38071
- restore()
38072
37570
 
38073
37571
  const lib_core_own = {}.hasOwnProperty
38074
37572
 
38075
37573
  // Inherit.
38076
37574
  function Refractor() {}
38077
37575
 
38078
- Refractor.prototype = prism_core
37576
+ Refractor.prototype = Prism
38079
37577
 
38080
37578
  /** @type {Refractor} */
38081
37579
  // @ts-expect-error: TS is wrong.
@@ -38134,7 +37632,8 @@ function highlight(value, language) {
38134
37632
 
38135
37633
  return {
38136
37634
  type: 'root',
38137
- children: prism_core.highlight.call(refractor, value, grammar, name)
37635
+ // @ts-expect-error: we hacked Prism to accept and return the things we want.
37636
+ children: Prism.highlight.call(refractor, value, grammar, name)
38138
37637
  }
38139
37638
  }
38140
37639
 
@@ -38315,36 +37814,6 @@ function core_attributes(attrs) {
38315
37814
  return attrs
38316
37815
  }
38317
37816
 
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
37817
  ;// CONCATENATED MODULE: ./node_modules/refractor/lib/common.js
38349
37818
  /**
38350
37819
  * @typedef {import('./core.js').RefractorRoot} RefractorRoot
@@ -58954,7 +58423,7 @@ const pseudo_handle = zwitch('name', {
58954
58423
  // @ts-expect-error: hush.
58955
58424
  has,
58956
58425
  // @ts-expect-error: hush.
58957
- lang,
58426
+ lang: pseudo_lang,
58958
58427
  // @ts-expect-error: hush.
58959
58428
  'last-child': lastChild,
58960
58429
  // @ts-expect-error: hush.
@@ -59268,7 +58737,7 @@ function firstChild(query, _1, _2, _3, state) {
59268
58737
  * @param {SelectState} state
59269
58738
  * @returns {boolean}
59270
58739
  */
59271
- function lang(query, _1, _2, _3, state) {
58740
+ function pseudo_lang(query, _1, _2, _3, state) {
59272
58741
  return (
59273
58742
  state.language !== '' &&
59274
58743
  state.language !== undefined &&
@@ -60321,10 +59790,7 @@ var jsx_runtime = __webpack_require__(724);
60321
59790
  ;// CONCATENATED MODULE: ./node_modules/@uiw/react-markdown-preview/esm/index.js
60322
59791
 
60323
59792
 
60324
- var _excluded = ["prefixCls", "className", "source", "style", "onScroll", "onMouseOver", "pluginsFilter", "warpperElement"];
60325
-
60326
-
60327
-
59793
+ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "onScroll", "onMouseOver", "pluginsFilter", "warpperElement"];
60328
59794
 
60329
59795
 
60330
59796
 
@@ -60337,23 +59803,7 @@ var _excluded = ["prefixCls", "className", "source", "style", "onScroll", "onMou
60337
59803
 
60338
59804
 
60339
59805
 
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
59806
 
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
59807
 
60358
59808
  /* harmony default export */ const esm = (/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().forwardRef((props, ref) => {
60359
59809
  var {
@@ -60361,6 +59811,7 @@ var rehypeRewriteHandle = (node, index, parent) => {
60361
59811
  className,
60362
59812
  source,
60363
59813
  style,
59814
+ disableCopy = false,
60364
59815
  onScroll,
60365
59816
  onMouseOver,
60366
59817
  pluginsFilter,
@@ -60373,6 +59824,25 @@ var rehypeRewriteHandle = (node, index, parent) => {
60373
59824
  mdp
60374
59825
  }), [mdp, props]);
60375
59826
  var cls = (prefixCls || '') + " " + (className || '');
59827
+
59828
+ var rehypeRewriteHandle = (node, index, parent) => {
59829
+ if (node.type === 'element' && parent && parent.type === 'root' && /h(1|2|3|4|5|6)/.test(node.tagName)) {
59830
+ var child = node.children && node.children[0];
59831
+
59832
+ if (child && child.properties && child.properties.ariaHidden === 'true') {
59833
+ child.properties = _extends({
59834
+ class: 'anchor'
59835
+ }, child.properties);
59836
+ child.children = [octiconLink];
59837
+ }
59838
+ }
59839
+
59840
+ if (node.type === 'element' && node.tagName === 'pre' && !disableCopy) {
59841
+ var code = getCodeString(node.children);
59842
+ node.children.push(copyElement(code));
59843
+ }
59844
+ };
59845
+
60376
59846
  var rehypePlugins = [reservedMeta, [m, {
60377
59847
  ignoreMissing: true
60378
59848
  }], rehypeRaw, rehypeSlug, rehypeAutolinkHeadings, [rehype_rewrite_lib, {
@@ -62556,7 +62026,7 @@ function Child_Child(props){var _ref=props||{},prefixCls=_ref.prefixCls,groupNam
62556
62026
  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
62027
  document.body.style.overflow='hidden';}else{// get the original overflow only the first time
62558
62028
  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||[]}))]});}
62029
+ 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
62030
  ;// CONCATENATED MODULE: ./src/components/DragBar/index.less
62561
62031
  // extracted by mini-css-extract-plugin
62562
62032
  /* harmony default export */ const DragBar = ({});
@@ -62567,14 +62037,14 @@ var DragBar_DragBar=function DragBar(props){var _ref=props||{},prefixCls=_ref.pr
62567
62037
  // extracted by mini-css-extract-plugin
62568
62038
  /* harmony default export */ const src = ({});
62569
62039
  ;// 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
62040
+ var Editor_excluded=["prefixCls","className","value","commands","commandsFilter","extraCommands","height","toolbarHeight","enableScroll","visiableDragbar","highlightEnable","preview","fullscreen","overflow","previewOptions","textareaProps","maxHeight","minHeight","autoFocus","tabSize","defaultTabEnable","onChange","onHeightChange","hideToolbar","toolbarBottom","renderTextarea"];function setGroupPopFalse(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};Object.keys(data).forEach(function(keyname){data[keyname]=false;});return data;}var InternalMDEditor=function InternalMDEditor(props,ref){var _ref=props||{},_ref$prefixCls=_ref.prefixCls,prefixCls=_ref$prefixCls===void 0?'w-md-editor':_ref$prefixCls,className=_ref.className,propsValue=_ref.value,_ref$commands=_ref.commands,commands=_ref$commands===void 0?commands_getCommands():_ref$commands,commandsFilter=_ref.commandsFilter,_ref$extraCommands=_ref.extraCommands,extraCommands=_ref$extraCommands===void 0?getExtraCommands():_ref$extraCommands,_ref$height=_ref.height,height=_ref$height===void 0?200:_ref$height,_ref$toolbarHeight=_ref.toolbarHeight,toolbarHeight=_ref$toolbarHeight===void 0?29:_ref$toolbarHeight,_ref$enableScroll=_ref.enableScroll,enableScroll=_ref$enableScroll===void 0?true:_ref$enableScroll,_ref$visiableDragbar=_ref.visiableDragbar,visiableDragbar=_ref$visiableDragbar===void 0?true:_ref$visiableDragbar,_ref$highlightEnable=_ref.highlightEnable,highlightEnable=_ref$highlightEnable===void 0?true:_ref$highlightEnable,_ref$preview=_ref.preview,previewType=_ref$preview===void 0?'live':_ref$preview,_ref$fullscreen=_ref.fullscreen,fullscreen=_ref$fullscreen===void 0?false:_ref$fullscreen,_ref$overflow=_ref.overflow,overflow=_ref$overflow===void 0?true:_ref$overflow,_ref$previewOptions=_ref.previewOptions,previewOptions=_ref$previewOptions===void 0?{}:_ref$previewOptions,textareaProps=_ref.textareaProps,_ref$maxHeight=_ref.maxHeight,maxHeight=_ref$maxHeight===void 0?1200:_ref$maxHeight,_ref$minHeight=_ref.minHeight,minHeight=_ref$minHeight===void 0?100:_ref$minHeight,autoFocus=_ref.autoFocus,_ref$tabSize=_ref.tabSize,tabSize=_ref$tabSize===void 0?2:_ref$tabSize,_ref$defaultTabEnable=_ref.defaultTabEnable,defaultTabEnable=_ref$defaultTabEnable===void 0?false:_ref$defaultTabEnable,_onChange=_ref.onChange,onHeightChange=_ref.onHeightChange,hideToolbar=_ref.hideToolbar,_ref$toolbarBottom=_ref.toolbarBottom,toolbarBottom=_ref$toolbarBottom===void 0?false:_ref$toolbarBottom,renderTextarea=_ref.renderTextarea,other=_objectWithoutProperties(_ref,Editor_excluded);var cmds=commands.map(function(item){return commandsFilter?commandsFilter(item,false):item;}).filter(Boolean);var extraCmds=extraCommands.map(function(item){return commandsFilter?commandsFilter(item,true):item;}).filter(Boolean);var _useReducer=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useReducer)(reducer,{markdown:propsValue,preview:previewType,height:height,highlightEnable:highlightEnable,tabSize:tabSize,defaultTabEnable:defaultTabEnable,scrollTop:0,scrollTopPreview:0,commands:cmds,extraCommands:extraCmds,fullscreen:fullscreen,barPopup:{}}),_useReducer2=_slicedToArray(_useReducer,2),state=_useReducer2[0],dispatch=_useReducer2[1];var container=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var previewRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var enableScrollRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(enableScroll);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(ref,function(){return _objectSpread2({},state);});(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return enableScrollRef.current=enableScroll;},[enableScroll]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){var stateInit={};if(container.current){stateInit.container=container.current||undefined;}stateInit.markdown=propsValue||'';stateInit.barPopup={};if(dispatch){dispatch(_objectSpread2(_objectSpread2({},state),stateInit));}// eslint-disable-next-line react-hooks/exhaustive-deps
62571
62041
  },[]);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
62042
  (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
62043
  (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
62044
  [highlightEnable]);// eslint-disable-next-line react-hooks/exhaustive-deps
62575
62045
  (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
62046
  [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);
62047
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return height!==state.height&&dispatch({height:height});},[height]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return height!==state.height&&onHeightChange&&onHeightChange(state.height,height,state);},[height,onHeightChange,state]);var textareaDomRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)();var active=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)('preview');var initScroll=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){textareaDomRef.current=state.textareaWarp;if(state.textareaWarp){state.textareaWarp.addEventListener('mouseover',function(){active.current='text';});state.textareaWarp.addEventListener('mouseleave',function(){active.current='preview';});}},[state.textareaWarp]);var handleScroll=function handleScroll(e,type){if(!enableScrollRef.current)return;var textareaDom=textareaDomRef.current;var previewDom=previewRef.current?previewRef.current.mdp.current:undefined;if(!initScroll.current){active.current=type;initScroll.current=true;}if(textareaDom&&previewDom){var scale=(textareaDom.scrollHeight-textareaDom.offsetHeight)/(previewDom.scrollHeight-previewDom.offsetHeight);if(e.target===textareaDom&&active.current==='text'){previewDom.scrollTop=textareaDom.scrollTop/scale;}if(e.target===previewDom&&active.current==='preview'){textareaDom.scrollTop=previewDom.scrollTop*scale;}var scrollTop=0;if(active.current==='text'){scrollTop=textareaDom.scrollTop||0;}else if(active.current==='preview'){scrollTop=previewDom.scrollTop||0;}dispatch({scrollTop:scrollTop});}};var mdPreview=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return/*#__PURE__*/(0,jsx_runtime.jsx)(esm,_objectSpread2(_objectSpread2({},previewOptions),{},{onScroll:function onScroll(e){return handleScroll(e,'preview');},ref:previewRef,source:state.markdown||'',className:"".concat(prefixCls,"-preview ").concat(previewOptions.className||'')}));},[prefixCls,previewOptions,state.markdown]);return/*#__PURE__*/(0,jsx_runtime.jsx)(EditorContext.Provider,{value:_objectSpread2(_objectSpread2({},state),{},{dispatch:dispatch}),children:/*#__PURE__*/(0,jsx_runtime.jsxs)("div",_objectSpread2(_objectSpread2({ref:container,className:cls},other),{},{onClick:function onClick(){dispatch({barPopup:_objectSpread2({},setGroupPopFalse(state.barPopup))});},style:_objectSpread2(_objectSpread2({},other.style),{},{height:state.fullscreen?'100%':hideToolbar?Number(state.height)-toolbarHeight:state.height}),children:[!hideToolbar&&!toolbarBottom&&/*#__PURE__*/(0,jsx_runtime.jsx)(Toolbar_Toolbar,{prefixCls:prefixCls,height:toolbarHeight,overflow:overflow,toolbarBottom:toolbarBottom}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{className:"".concat(prefixCls,"-content"),style:{height:state.fullscreen?"calc(100% - ".concat(toolbarHeight,"px)"):Number(state.height)-toolbarHeight},children:[/(edit|live)/.test(state.preview||'')&&/*#__PURE__*/(0,jsx_runtime.jsx)(TextArea_TextArea,_objectSpread2(_objectSpread2({className:"".concat(prefixCls,"-input"),prefixCls:prefixCls,autoFocus:autoFocus},textareaProps),{},{onChange:function onChange(evn){_onChange&&_onChange(evn.target.value,evn,state);if(textareaProps&&textareaProps.onChange){textareaProps.onChange(evn);}},renderTextarea:renderTextarea,onScroll:function onScroll(e){return handleScroll(e,'text');}})),/(live|preview)/.test(state.preview||'')&&mdPreview]}),visiableDragbar&&!state.fullscreen&&/*#__PURE__*/(0,jsx_runtime.jsx)(components_DragBar,{prefixCls:prefixCls,height:state.height,maxHeight:maxHeight,minHeight:minHeight,onChange:function onChange(newHeight){dispatch({height:newHeight});}}),!hideToolbar&&toolbarBottom&&/*#__PURE__*/(0,jsx_runtime.jsx)(Toolbar_Toolbar,{prefixCls:prefixCls,height:toolbarHeight,overflow:overflow,toolbarBottom:toolbarBottom})]}))});};var mdEditor=/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().forwardRef(InternalMDEditor);mdEditor.Markdown=esm;/* harmony default export */ const Editor = (mdEditor);
62578
62048
  ;// CONCATENATED MODULE: ./src/index.tsx
62579
62049
  /* harmony default export */ const src_0 = (Editor);
62580
62050
  })();