@uiw/react-md-editor 3.9.7 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mdeditor.js CHANGED
@@ -38128,22 +38128,7 @@ function _objectWithoutProperties(source, excluded) {
38128
38128
  // EXTERNAL MODULE: external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"}
38129
38129
  var external_root_React_commonjs2_react_commonjs_react_amd_react_ = __webpack_require__(9787);
38130
38130
  var external_root_React_commonjs2_react_commonjs_react_amd_react_default = /*#__PURE__*/__webpack_require__.n(external_root_React_commonjs2_react_commonjs_react_amd_react_);
38131
- ;// CONCATENATED MODULE: ./node_modules/@uiw/react-markdown-preview/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js
38132
- function objectWithoutPropertiesLoose_objectWithoutPropertiesLoose(source, excluded) {
38133
- if (source == null) return {};
38134
- var target = {};
38135
- var sourceKeys = Object.keys(source);
38136
- var key, i;
38137
-
38138
- for (i = 0; i < sourceKeys.length; i++) {
38139
- key = sourceKeys[i];
38140
- if (excluded.indexOf(key) >= 0) continue;
38141
- target[key] = source[key];
38142
- }
38143
-
38144
- return target;
38145
- }
38146
- ;// CONCATENATED MODULE: ./node_modules/@uiw/react-markdown-preview/node_modules/@babel/runtime/helpers/esm/extends.js
38131
+ ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
38147
38132
  function _extends() {
38148
38133
  _extends = Object.assign || function (target) {
38149
38134
  for (var i = 1; i < arguments.length; i++) {
@@ -38164,19 +38149,18 @@ function _extends() {
38164
38149
  // EXTERNAL MODULE: ./node_modules/is-buffer/index.js
38165
38150
  var is_buffer = __webpack_require__(1433);
38166
38151
  ;// CONCATENATED MODULE: ./node_modules/unist-util-stringify-position/index.js
38167
- var own = {}.hasOwnProperty
38168
-
38169
38152
  /**
38153
+ * @typedef {import('unist').Point} Point
38170
38154
  * @typedef {import('unist').Node} Node
38171
38155
  * @typedef {import('unist').Position} Position
38172
- * @typedef {import('unist').Point} Point
38156
+ * @typedef {object & {type: string, position?: Position|undefined}} NodeLike
38173
38157
  */
38174
38158
 
38175
38159
  /**
38176
38160
  * Stringify one point, a position (start and end points), or a node’s
38177
38161
  * positional information.
38178
38162
  *
38179
- * @param {Node|Position|Point} [value]
38163
+ * @param {Node|NodeLike|Position|Point|null} [value]
38180
38164
  * @returns {string}
38181
38165
  */
38182
38166
  function stringifyPosition(value) {
@@ -38186,20 +38170,17 @@ function stringifyPosition(value) {
38186
38170
  }
38187
38171
 
38188
38172
  // Node.
38189
- if (own.call(value, 'position') || own.call(value, 'type')) {
38190
- // @ts-ignore looks like a node.
38173
+ if ('position' in value || 'type' in value) {
38191
38174
  return position(value.position)
38192
38175
  }
38193
38176
 
38194
38177
  // Position.
38195
- if (own.call(value, 'start') || own.call(value, 'end')) {
38196
- // @ts-ignore looks like a position.
38178
+ if ('start' in value || 'end' in value) {
38197
38179
  return position(value)
38198
38180
  }
38199
38181
 
38200
38182
  // Point.
38201
- if (own.call(value, 'line') || own.call(value, 'column')) {
38202
- // @ts-ignore looks like a point.
38183
+ if ('line' in value || 'column' in value) {
38203
38184
  return point(value)
38204
38185
  }
38205
38186
 
@@ -38208,7 +38189,7 @@ function stringifyPosition(value) {
38208
38189
  }
38209
38190
 
38210
38191
  /**
38211
- * @param {Point} point
38192
+ * @param {Point|undefined} point
38212
38193
  * @returns {string}
38213
38194
  */
38214
38195
  function point(point) {
@@ -38216,7 +38197,7 @@ function point(point) {
38216
38197
  }
38217
38198
 
38218
38199
  /**
38219
- * @param {Position} pos
38200
+ * @param {Position|undefined} pos
38220
38201
  * @returns {string}
38221
38202
  */
38222
38203
  function position(pos) {
@@ -38224,7 +38205,7 @@ function position(pos) {
38224
38205
  }
38225
38206
 
38226
38207
  /**
38227
- * @param {number} value
38208
+ * @param {number|undefined} value
38228
38209
  * @returns {number}
38229
38210
  */
38230
38211
  function index(value) {
@@ -38236,6 +38217,7 @@ function index(value) {
38236
38217
  * @typedef {import('unist').Node} Node
38237
38218
  * @typedef {import('unist').Position} Position
38238
38219
  * @typedef {import('unist').Point} Point
38220
+ * @typedef {object & {type: string, position?: Position|undefined}} NodeLike
38239
38221
  */
38240
38222
 
38241
38223
 
@@ -38246,29 +38228,29 @@ class VFileMessage extends Error {
38246
38228
  * When an error is passed in as `reason`, copies the `stack`.
38247
38229
  *
38248
38230
  * @param {string|Error} reason Reason for message (`string` or `Error`). Uses the stack and message of the error if given.
38249
- * @param {Node|Position|Point} [place] Place at which the message occurred in a file (`Node`, `Position`, or `Point`, optional).
38231
+ * @param {Node|NodeLike|Position|Point} [place] Place at which the message occurred in a file (`Node`, `Position`, or `Point`, optional).
38250
38232
  * @param {string} [origin] Place in code the message originates from (`string`, optional).
38251
38233
  */
38252
38234
  constructor(reason, place, origin) {
38253
- /** @type {[string?, string?]} */
38254
- var parts = [null, null]
38235
+ /** @type {[string|null, string|null]} */
38236
+ const parts = [null, null]
38255
38237
  /** @type {Position} */
38256
- var position = {
38238
+ let position = {
38239
+ // @ts-expect-error: we always follows the structure of `position`.
38257
38240
  start: {line: null, column: null},
38241
+ // @ts-expect-error: "
38258
38242
  end: {line: null, column: null}
38259
38243
  }
38260
- /** @type {number} */
38261
- var index
38262
38244
 
38263
38245
  super()
38264
38246
 
38265
38247
  if (typeof place === 'string') {
38266
38248
  origin = place
38267
- place = null
38249
+ place = undefined
38268
38250
  }
38269
38251
 
38270
38252
  if (typeof origin === 'string') {
38271
- index = origin.indexOf(':')
38253
+ const index = origin.indexOf(':')
38272
38254
 
38273
38255
  if (index === -1) {
38274
38256
  parts[1] = origin
@@ -38287,12 +38269,10 @@ class VFileMessage extends Error {
38287
38269
  }
38288
38270
  // Position.
38289
38271
  else if ('start' in place || 'end' in place) {
38290
- // @ts-ignore Looks like a position.
38291
38272
  position = place
38292
38273
  }
38293
38274
  // Point.
38294
38275
  else if ('line' in place || 'column' in place) {
38295
- // @ts-ignore Looks like a point.
38296
38276
  position.start = place
38297
38277
  }
38298
38278
  }
@@ -38906,6 +38886,7 @@ function getPathFromURLPosix(url) {
38906
38886
  * @typedef {import('unist').Node} Node
38907
38887
  * @typedef {import('unist').Position} Position
38908
38888
  * @typedef {import('unist').Point} Point
38889
+ * @typedef {Record<string, unknown> & {type: string, position?: Position|undefined}} NodeLike
38909
38890
  * @typedef {import('./minurl.shared.js').URL} URL
38910
38891
  * @typedef {import('..').VFileData} VFileData
38911
38892
  * @typedef {import('..').VFileValue} VFileValue
@@ -38916,7 +38897,6 @@ function getPathFromURLPosix(url) {
38916
38897
  * being needed.
38917
38898
  * Copied from: <https://github.com/DefinitelyTyped/DefinitelyTyped/blob/90a4ec8/types/node/buffer.d.ts#L170>
38918
38899
  *
38919
- *
38920
38900
  * @typedef {VFileValue|VFileOptions|VFile|URL} VFileCompatible
38921
38901
  * Things that can be passed to the constructor.
38922
38902
  *
@@ -39202,7 +39182,7 @@ class VFile {
39202
39182
  * Create a message and associates it w/ the file.
39203
39183
  *
39204
39184
  * @param {string|Error} reason Reason for message (`string` or `Error`). Uses the stack and message of the error if given.
39205
- * @param {Node|Position|Point} [place] Place at which the message occurred in a file (`Node`, `Position`, or `Point`, optional).
39185
+ * @param {Node|NodeLike|Position|Point} [place] Place at which the message occurred in a file (`Node`, `Position`, or `Point`, optional).
39206
39186
  * @param {string} [origin] Place in code the message originates from (`string`, optional).
39207
39187
  * @returns {VFileMessage}
39208
39188
  */
@@ -39227,7 +39207,7 @@ class VFile {
39227
39207
  * Calls `message()` internally.
39228
39208
  *
39229
39209
  * @param {string|Error} reason Reason for message (`string` or `Error`). Uses the stack and message of the error if given.
39230
- * @param {Node|Position|Point} [place] Place at which the message occurred in a file (`Node`, `Position`, or `Point`, optional).
39210
+ * @param {Node|NodeLike|Position|Point} [place] Place at which the message occurred in a file (`Node`, `Position`, or `Point`, optional).
39231
39211
  * @param {string} [origin] Place in code the message originates from (`string`, optional).
39232
39212
  * @returns {VFileMessage}
39233
39213
  */
@@ -39246,7 +39226,7 @@ class VFile {
39246
39226
  * Calls `message()` internally.
39247
39227
  *
39248
39228
  * @param {string|Error} reason Reason for message (`string` or `Error`). Uses the stack and message of the error if given.
39249
- * @param {Node|Position|Point} [place] Place at which the message occurred in a file (`Node`, `Position`, or `Point`, optional).
39229
+ * @param {Node|NodeLike|Position|Point} [place] Place at which the message occurred in a file (`Node`, `Position`, or `Point`, optional).
39250
39230
  * @param {string} [origin] Place in code the message originates from (`string`, optional).
39251
39231
  * @returns {never}
39252
39232
  */
@@ -39519,7 +39499,7 @@ function wrap(middleware, callback) {
39519
39499
  // Expose a frozen processor.
39520
39500
  const unified = base().freeze()
39521
39501
 
39522
- const lib_own = {}.hasOwnProperty
39502
+ const own = {}.hasOwnProperty
39523
39503
 
39524
39504
  // Function to create the first processor.
39525
39505
  /**
@@ -39592,7 +39572,7 @@ function base() {
39592
39572
  }
39593
39573
 
39594
39574
  // Get `key`.
39595
- return (lib_own.call(namespace, key) && namespace[key]) || null
39575
+ return (own.call(namespace, key) && namespace[key]) || null
39596
39576
  }
39597
39577
 
39598
39578
  // Set space.
@@ -39620,7 +39600,7 @@ function base() {
39620
39600
  }
39621
39601
 
39622
39602
  if (options[0] === true) {
39623
- options[1] = undefined
39603
+ options[0] = undefined
39624
39604
  }
39625
39605
 
39626
39606
  /** @type {Transformer|void} */
@@ -39978,7 +39958,7 @@ function keys(value) {
39978
39958
  let key
39979
39959
 
39980
39960
  for (key in value) {
39981
- if (lib_own.call(value, key)) {
39961
+ if (own.call(value, key)) {
39982
39962
  return true
39983
39963
  }
39984
39964
  }
@@ -46829,7 +46809,7 @@ function decode($0, $1, $2) {
46829
46809
 
46830
46810
 
46831
46811
 
46832
- const mdast_util_from_markdown_lib_own = {}.hasOwnProperty
46812
+ const lib_own = {}.hasOwnProperty
46833
46813
  /**
46834
46814
  * @param value Markdown to parse (`string` or `Buffer`).
46835
46815
  * @param [encoding] Character encoding to understand `value` as when it’s a `Buffer` (`string`, default: `'utf8'`).
@@ -47037,7 +47017,7 @@ function compiler(options = {}) {
47037
47017
  while (++index < events.length) {
47038
47018
  const handler = config[events[index][0]]
47039
47019
 
47040
- if (mdast_util_from_markdown_lib_own.call(handler, events[index][1].type)) {
47020
+ if (lib_own.call(handler, events[index][1].type)) {
47041
47021
  handler[events[index][1].type].call(
47042
47022
  Object.assign(
47043
47023
  {
@@ -47927,9 +47907,9 @@ function extension(combined, extension) {
47927
47907
  let key
47928
47908
 
47929
47909
  for (key in extension) {
47930
- if (mdast_util_from_markdown_lib_own.call(extension, key)) {
47910
+ if (lib_own.call(extension, key)) {
47931
47911
  const list = key === 'canContainEols' || key === 'transforms'
47932
- const maybe = mdast_util_from_markdown_lib_own.call(combined, key) ? combined[key] : undefined
47912
+ const maybe = lib_own.call(combined, key) ? combined[key] : undefined
47933
47913
  /* c8 ignore next */
47934
47914
 
47935
47915
  const left = maybe || (combined[key] = list ? [] : {})
@@ -49256,7 +49236,7 @@ function returnNode(h, node) {
49256
49236
  * @param {MdastNode} parent
49257
49237
  */
49258
49238
  function traverse_all(h, parent) {
49259
- /** @type {Array.<Content>} */
49239
+ /** @type {Array<Content>} */
49260
49240
  const values = []
49261
49241
 
49262
49242
  if ('children' in parent) {
@@ -49293,20 +49273,143 @@ function traverse_all(h, parent) {
49293
49273
  return values
49294
49274
  }
49295
49275
 
49296
- ;// CONCATENATED MODULE: ./node_modules/mdast-util-to-hast/lib/handlers/thematic-break.js
49276
+ ;// CONCATENATED MODULE: ./node_modules/micromark-util-encode/index.js
49277
+ const characterReferences = {'"': 'quot', '&': 'amp', '<': 'lt', '>': 'gt'}
49278
+
49297
49279
  /**
49298
- * @typedef {import('mdast').ThematicBreak} ThematicBreak
49299
- * @typedef {import('hast').Element} Element
49300
- * @typedef {import('../index.js').Handler} Handler
49280
+ * Encode only the dangerous HTML characters.
49281
+ *
49282
+ * This ensures that certain characters which have special meaning in HTML are
49283
+ * dealt with.
49284
+ * Technically, we can skip `>` and `"` in many cases, but CM includes them.
49285
+ *
49286
+ * @param {string} value
49287
+ * @returns {string}
49301
49288
  */
49289
+ function encode(value) {
49290
+ return value.replace(/["&<>]/g, replace)
49291
+
49292
+ /**
49293
+ * @param {string} value
49294
+ * @returns {string}
49295
+ */
49296
+ function replace(value) {
49297
+ // @ts-expect-error Hush, it’s fine.
49298
+ return '&' + characterReferences[value] + ';'
49299
+ }
49300
+ }
49301
+
49302
+ ;// CONCATENATED MODULE: ./node_modules/micromark-util-sanitize-uri/index.js
49303
+
49304
+
49302
49305
 
49303
49306
  /**
49304
- * @type {Handler}
49305
- * @param {ThematicBreak} [node]
49306
- * @returns {Element}
49307
+ * Make a value safe for injection as a URL.
49308
+ *
49309
+ * This encodes unsafe characters with percent-encoding and skips already
49310
+ * encoded sequences (see `normalizeUri` below).
49311
+ * Further unsafe characters are encoded as character references (see
49312
+ * `micromark-util-encode`).
49313
+ *
49314
+ * Then, a regex of allowed protocols can be given, in which case the URL is
49315
+ * sanitized.
49316
+ * For example, `/^(https?|ircs?|mailto|xmpp)$/i` can be used for `a[href]`,
49317
+ * or `/^https?$/i` for `img[src]`.
49318
+ * If the URL includes an unknown protocol (one not matched by `protocol`, such
49319
+ * as a dangerous example, `javascript:`), the value is ignored.
49320
+ *
49321
+ * @param {string|undefined} url
49322
+ * @param {RegExp} [protocol]
49323
+ * @returns {string}
49307
49324
  */
49308
- function thematic_break_thematicBreak(h, node) {
49309
- return h(node, 'hr')
49325
+ function sanitizeUri(url, protocol) {
49326
+ const value = encode(normalizeUri(url || ''))
49327
+
49328
+ if (!protocol) {
49329
+ return value
49330
+ }
49331
+
49332
+ const colon = value.indexOf(':')
49333
+ const questionMark = value.indexOf('?')
49334
+ const numberSign = value.indexOf('#')
49335
+ const slash = value.indexOf('/')
49336
+
49337
+ if (
49338
+ // If there is no protocol, it’s relative.
49339
+ colon < 0 || // If the first colon is after a `?`, `#`, or `/`, it’s not a protocol.
49340
+ (slash > -1 && colon > slash) ||
49341
+ (questionMark > -1 && colon > questionMark) ||
49342
+ (numberSign > -1 && colon > numberSign) || // It is a protocol, it should be allowed.
49343
+ protocol.test(value.slice(0, colon))
49344
+ ) {
49345
+ return value
49346
+ }
49347
+
49348
+ return ''
49349
+ }
49350
+ /**
49351
+ * Normalize a URL (such as used in definitions).
49352
+ *
49353
+ * Encode unsafe characters with percent-encoding, skipping already encoded
49354
+ * sequences.
49355
+ *
49356
+ * @param {string} value
49357
+ * @returns {string}
49358
+ */
49359
+
49360
+ function normalizeUri(value) {
49361
+ /** @type {string[]} */
49362
+ const result = []
49363
+ let index = -1
49364
+ let start = 0
49365
+ let skip = 0
49366
+
49367
+ while (++index < value.length) {
49368
+ const code = value.charCodeAt(index)
49369
+ /** @type {string} */
49370
+
49371
+ let replace = '' // A correct percent encoded value.
49372
+
49373
+ if (
49374
+ code === 37 &&
49375
+ asciiAlphanumeric(value.charCodeAt(index + 1)) &&
49376
+ asciiAlphanumeric(value.charCodeAt(index + 2))
49377
+ ) {
49378
+ skip = 2
49379
+ } // ASCII.
49380
+ else if (code < 128) {
49381
+ if (!/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(code))) {
49382
+ replace = String.fromCharCode(code)
49383
+ }
49384
+ } // Astral.
49385
+ else if (code > 55295 && code < 57344) {
49386
+ const next = value.charCodeAt(index + 1) // A correct surrogate pair.
49387
+
49388
+ if (code < 56320 && next > 56319 && next < 57344) {
49389
+ replace = String.fromCharCode(code, next)
49390
+ skip = 1
49391
+ } // Lone surrogate.
49392
+ else {
49393
+ replace = '\uFFFD'
49394
+ }
49395
+ } // Unicode.
49396
+ else {
49397
+ replace = String.fromCharCode(code)
49398
+ }
49399
+
49400
+ if (replace) {
49401
+ result.push(value.slice(start, index), encodeURIComponent(replace))
49402
+ start = index + skip + 1
49403
+ replace = ''
49404
+ }
49405
+
49406
+ if (skip) {
49407
+ index += skip
49408
+ skip = 0
49409
+ }
49410
+ }
49411
+
49412
+ return result.join('') + value.slice(start)
49310
49413
  }
49311
49414
 
49312
49415
  ;// CONCATENATED MODULE: ./node_modules/mdast-util-to-hast/lib/wrap.js
@@ -49320,12 +49423,12 @@ function thematic_break_thematicBreak(h, node) {
49320
49423
  * Wrap `nodes` with line feeds between each entry.
49321
49424
  * Optionally adds line feeds at the start and end.
49322
49425
  *
49323
- * @param {Array.<Content>} nodes
49426
+ * @param {Array<Content>} nodes
49324
49427
  * @param {boolean} [loose=false]
49325
- * @returns {Array.<Content>}
49428
+ * @returns {Array<Content>}
49326
49429
  */
49327
49430
  function wrap_wrap(nodes, loose) {
49328
- /** @type {Array.<Content>} */
49431
+ /** @type {Array<Content>} */
49329
49432
  const result = []
49330
49433
  let index = -1
49331
49434
 
@@ -49345,59 +49448,12 @@ function wrap_wrap(nodes, loose) {
49345
49448
  return result
49346
49449
  }
49347
49450
 
49348
- ;// CONCATENATED MODULE: ./node_modules/mdast-util-to-hast/lib/handlers/list.js
49349
- /**
49350
- * @typedef {import('mdast').List} List
49351
- * @typedef {import('hast').Element} Element
49352
- * @typedef {import('hast').Properties} Properties
49353
- * @typedef {import('../index.js').Handler} Handler
49354
- */
49355
-
49356
-
49357
-
49358
-
49359
- /**
49360
- * @type {Handler}
49361
- * @param {List} node
49362
- * @returns {Element}
49363
- */
49364
- function list_list(h, node) {
49365
- /** @type {Properties} */
49366
- const props = {}
49367
- const name = node.ordered ? 'ol' : 'ul'
49368
- const items = traverse_all(h, node)
49369
- let index = -1
49370
-
49371
- if (typeof node.start === 'number' && node.start !== 1) {
49372
- props.start = node.start
49373
- }
49374
-
49375
- // Like GitHub, add a class for custom styling.
49376
- while (++index < items.length) {
49377
- const item = items[index]
49378
-
49379
- if (
49380
- item.type === 'element' &&
49381
- item.tagName === 'li' &&
49382
- item.properties &&
49383
- Array.isArray(item.properties.className) &&
49384
- item.properties.className.includes('task-list-item')
49385
- ) {
49386
- props.className = ['contains-task-list']
49387
- break
49388
- }
49389
- }
49390
-
49391
- return h(node, name, props, wrap_wrap(items, true))
49392
- }
49393
-
49394
49451
  ;// CONCATENATED MODULE: ./node_modules/mdast-util-to-hast/lib/footer.js
49395
49452
  /**
49396
49453
  * @typedef {import('mdast').BlockContent} BlockContent
49397
49454
  * @typedef {import('mdast').FootnoteDefinition} FootnoteDefinition
49398
- * @typedef {import('mdast').Link} Link
49399
- * @typedef {import('mdast').ListItem} ListItem
49400
- * @typedef {import('mdast').Paragraph} Paragraph
49455
+ * @typedef {import('hast').Element} Element
49456
+ * @typedef {import('hast').ElementContent} ElementContent
49401
49457
  * @typedef {import('./index.js').H} H
49402
49458
  */
49403
49459
 
@@ -49405,67 +49461,118 @@ function list_list(h, node) {
49405
49461
 
49406
49462
 
49407
49463
 
49464
+
49408
49465
  /**
49409
49466
  * @param {H} h
49410
49467
  */
49411
49468
  function footer(h) {
49412
- const footnoteById = h.footnoteById
49413
- const footnoteOrder = h.footnoteOrder
49414
49469
  let index = -1
49415
- /** @type {Array.<ListItem>} */
49470
+ /** @type {Array<ElementContent>} */
49416
49471
  const listItems = []
49417
49472
 
49418
- while (++index < footnoteOrder.length) {
49419
- const def = footnoteById[footnoteOrder[index].toUpperCase()]
49473
+ while (++index < h.footnoteOrder.length) {
49474
+ const def = h.footnoteById[h.footnoteOrder[index].toUpperCase()]
49420
49475
 
49421
49476
  if (!def) {
49422
49477
  continue
49423
49478
  }
49424
49479
 
49425
- const marker = String(index + 1)
49426
- const content = [...def.children]
49427
- /** @type {Link} */
49428
- const backReference = {
49429
- type: 'link',
49430
- url: '#fnref' + marker,
49431
- data: {hProperties: {className: ['footnote-back'], role: 'doc-backlink'}},
49432
- children: [{type: 'text', value: '↩'}]
49480
+ const content = traverse_all(h, def)
49481
+ const id = String(def.identifier)
49482
+ const safeId = sanitizeUri(id.toLowerCase())
49483
+ let referenceIndex = 0
49484
+ /** @type {Array<ElementContent>} */
49485
+ const backReferences = []
49486
+
49487
+ while (++referenceIndex <= h.footnoteCounts[id]) {
49488
+ /** @type {Element} */
49489
+ const backReference = {
49490
+ type: 'element',
49491
+ tagName: 'a',
49492
+ properties: {
49493
+ href:
49494
+ '#' +
49495
+ h.clobberPrefix +
49496
+ 'fnref-' +
49497
+ safeId +
49498
+ (referenceIndex > 1 ? '-' + referenceIndex : ''),
49499
+ dataFootnoteBackref: true,
49500
+ className: ['data-footnote-backref'],
49501
+ ariaLabel: h.footnoteBackLabel
49502
+ },
49503
+ children: [{type: 'text', value: '↩'}]
49504
+ }
49505
+
49506
+ if (referenceIndex > 1) {
49507
+ backReference.children.push({
49508
+ type: 'element',
49509
+ tagName: 'sup',
49510
+ children: [{type: 'text', value: String(referenceIndex)}]
49511
+ })
49512
+ }
49513
+
49514
+ if (backReferences.length > 0) {
49515
+ backReferences.push({type: 'text', value: ' '})
49516
+ }
49517
+
49518
+ backReferences.push(backReference)
49433
49519
  }
49520
+
49434
49521
  const tail = content[content.length - 1]
49435
49522
 
49436
- if (tail && tail.type === 'paragraph') {
49437
- tail.children.push(backReference)
49523
+ if (tail && tail.type === 'element' && tail.tagName === 'p') {
49524
+ const tailTail = tail.children[tail.children.length - 1]
49525
+ if (tailTail && tailTail.type === 'text') {
49526
+ tailTail.value += ' '
49527
+ } else {
49528
+ tail.children.push({type: 'text', value: ' '})
49529
+ }
49530
+
49531
+ tail.children.push(...backReferences)
49438
49532
  } else {
49439
- // @ts-expect-error Indeed, link directly added in block content.
49440
- // Which we do because that way at least the handlers will be called
49441
- // for the other HTML we’re generating (as markdown).
49442
- content.push(backReference)
49533
+ content.push(...backReferences)
49443
49534
  }
49444
49535
 
49445
- listItems.push({
49446
- type: 'listItem',
49447
- data: {hProperties: {id: 'fn' + marker, role: 'doc-endnote'}},
49448
- children: content,
49449
- position: def.position
49450
- })
49536
+ /** @type {Element} */
49537
+ const listItem = {
49538
+ type: 'element',
49539
+ tagName: 'li',
49540
+ properties: {id: h.clobberPrefix + 'fn-' + safeId},
49541
+ children: wrap_wrap(content, true)
49542
+ }
49543
+
49544
+ if (def.position) {
49545
+ listItem.position = def.position
49546
+ }
49547
+
49548
+ listItems.push(listItem)
49451
49549
  }
49452
49550
 
49453
49551
  if (listItems.length === 0) {
49454
49552
  return null
49455
49553
  }
49456
49554
 
49457
- return h(
49458
- null,
49459
- 'section',
49460
- {className: ['footnotes'], role: 'doc-endnotes'},
49461
- wrap_wrap(
49462
- [
49463
- thematic_break_thematicBreak(h),
49464
- list_list(h, {type: 'list', ordered: true, children: listItems})
49465
- ],
49466
- true
49467
- )
49468
- )
49555
+ return {
49556
+ type: 'element',
49557
+ tagName: 'section',
49558
+ properties: {dataFootnotes: true, className: ['footnotes']},
49559
+ children: [
49560
+ {
49561
+ type: 'element',
49562
+ tagName: 'h2',
49563
+ properties: {id: 'footnote-label', className: ['sr-only']},
49564
+ children: [u('text', h.footnoteLabel)]
49565
+ },
49566
+ {type: 'text', value: '\n'},
49567
+ {
49568
+ type: 'element',
49569
+ tagName: 'ol',
49570
+ properties: {},
49571
+ children: wrap_wrap(listItems, true)
49572
+ },
49573
+ {type: 'text', value: '\n'}
49574
+ ]
49575
+ }
49469
49576
  }
49470
49577
 
49471
49578
  ;// CONCATENATED MODULE: ./node_modules/mdast-util-to-hast/lib/handlers/blockquote.js
@@ -49579,35 +49686,59 @@ function emphasis(h, node) {
49579
49686
 
49580
49687
 
49581
49688
 
49689
+
49582
49690
  /**
49583
49691
  * @type {Handler}
49584
49692
  * @param {FootnoteReference} node
49585
49693
  */
49586
49694
  function footnoteReference(h, node) {
49587
- const footnoteOrder = h.footnoteOrder
49588
- const identifier = String(node.identifier)
49589
- const index = footnoteOrder.indexOf(identifier)
49590
- const marker = String(
49591
- index === -1 ? footnoteOrder.push(identifier) : index + 1
49592
- )
49695
+ const id = String(node.identifier)
49696
+ const safeId = sanitizeUri(id.toLowerCase())
49697
+ const index = h.footnoteOrder.indexOf(id)
49698
+ /** @type {number} */
49699
+ let counter
49593
49700
 
49594
- return h(
49595
- node,
49596
- 'a',
49597
- {
49598
- href: '#fn' + marker,
49599
- className: ['footnote-ref'],
49600
- id: 'fnref' + marker,
49601
- role: 'doc-noteref'
49602
- },
49603
- [h(node.position, 'sup', [u('text', marker)])]
49604
- )
49701
+ if (index === -1) {
49702
+ h.footnoteOrder.push(id)
49703
+ h.footnoteCounts[id] = 1
49704
+ counter = h.footnoteOrder.length
49705
+ } else {
49706
+ h.footnoteCounts[id]++
49707
+ counter = index + 1
49708
+ }
49709
+
49710
+ const reuseCounter = h.footnoteCounts[id]
49711
+
49712
+ return h(node, 'sup', [
49713
+ h(
49714
+ node.position,
49715
+ 'a',
49716
+ {
49717
+ href: '#' + h.clobberPrefix + 'fn-' + safeId,
49718
+ id:
49719
+ h.clobberPrefix +
49720
+ 'fnref-' +
49721
+ safeId +
49722
+ (reuseCounter > 1 ? '-' + reuseCounter : ''),
49723
+ dataFootnoteRef: true,
49724
+ ariaDescribedBy: 'footnote-label'
49725
+ },
49726
+ [u('text', String(counter))]
49727
+ )
49728
+ ])
49605
49729
  }
49606
49730
 
49607
49731
  ;// CONCATENATED MODULE: ./node_modules/mdast-util-to-hast/lib/handlers/footnote.js
49608
49732
  /**
49609
49733
  * @typedef {import('mdast').Footnote} Footnote
49610
49734
  * @typedef {import('../index.js').Handler} Handler
49735
+ *
49736
+ * @todo
49737
+ * `footnote` (or “inline note”) are a pandoc footnotes feature (`^[a note]`)
49738
+ * that does not exist in GFM.
49739
+ * We still have support for it, so that things remain working with
49740
+ * `micromark-extension-footnote` and `mdast-util-footnote`, but in the future
49741
+ * we might be able to remove it?
49611
49742
  */
49612
49743
 
49613
49744
 
@@ -49618,17 +49749,12 @@ function footnoteReference(h, node) {
49618
49749
  */
49619
49750
  function footnote(h, node) {
49620
49751
  const footnoteById = h.footnoteById
49621
- const footnoteOrder = h.footnoteOrder
49622
49752
  let no = 1
49623
49753
 
49624
49754
  while (no in footnoteById) no++
49625
49755
 
49626
49756
  const identifier = String(no)
49627
49757
 
49628
- // No need to check if `identifier` exists in `footnoteOrder`, it’s guaranteed
49629
- // to not exist because we just generated it.
49630
- footnoteOrder.push(identifier)
49631
-
49632
49758
  footnoteById[identifier] = {
49633
49759
  type: 'footnoteDefinition',
49634
49760
  identifier,
@@ -49678,7 +49804,7 @@ function html(h, node) {
49678
49804
  }
49679
49805
 
49680
49806
  // EXTERNAL MODULE: ./node_modules/mdurl/encode.js
49681
- var encode = __webpack_require__(4547);
49807
+ var mdurl_encode = __webpack_require__(4547);
49682
49808
  ;// CONCATENATED MODULE: ./node_modules/mdast-util-to-hast/lib/revert.js
49683
49809
  /**
49684
49810
  * @typedef {import('mdast').LinkReference} LinkReference
@@ -49695,7 +49821,7 @@ var encode = __webpack_require__(4547);
49695
49821
  *
49696
49822
  * @type {Handler}
49697
49823
  * @param {ImageReference|LinkReference} node
49698
- * @returns {Content|Array.<Content>}
49824
+ * @returns {Content|Array<Content>}
49699
49825
  */
49700
49826
  function revert(h, node) {
49701
49827
  const subtype = node.referenceType
@@ -49753,7 +49879,7 @@ function imageReference(h, node) {
49753
49879
  }
49754
49880
 
49755
49881
  /** @type {Properties} */
49756
- const props = {src: encode(def.url || ''), alt: node.alt}
49882
+ const props = {src: mdurl_encode(def.url || ''), alt: node.alt}
49757
49883
 
49758
49884
  if (def.title !== null && def.title !== undefined) {
49759
49885
  props.title = def.title
@@ -49777,7 +49903,7 @@ function imageReference(h, node) {
49777
49903
  */
49778
49904
  function image_image(h, node) {
49779
49905
  /** @type {Properties} */
49780
- const props = {src: encode(node.url), alt: node.alt}
49906
+ const props = {src: mdurl_encode(node.url), alt: node.alt}
49781
49907
 
49782
49908
  if (node.title !== null && node.title !== undefined) {
49783
49909
  props.title = node.title
@@ -49825,7 +49951,7 @@ function linkReference(h, node) {
49825
49951
  }
49826
49952
 
49827
49953
  /** @type {Properties} */
49828
- const props = {href: encode(def.url || '')}
49954
+ const props = {href: mdurl_encode(def.url || '')}
49829
49955
 
49830
49956
  if (def.title !== null && def.title !== undefined) {
49831
49957
  props.title = def.title
@@ -49850,7 +49976,7 @@ function linkReference(h, node) {
49850
49976
  */
49851
49977
  function link_link(h, node) {
49852
49978
  /** @type {Properties} */
49853
- const props = {href: encode(node.url)}
49979
+ const props = {href: mdurl_encode(node.url)}
49854
49980
 
49855
49981
  if (node.title !== null && node.title !== undefined) {
49856
49982
  props.title = node.title
@@ -49882,7 +50008,7 @@ function listItem(h, node, parent) {
49882
50008
  const loose = parent ? listLoose(parent) : listItemLoose(node)
49883
50009
  /** @type {Properties} */
49884
50010
  const props = {}
49885
- /** @type {Array.<Content>} */
50011
+ /** @type {Array<Content>} */
49886
50012
  const wrapped = []
49887
50013
 
49888
50014
  if (typeof node.checked === 'boolean') {
@@ -49977,6 +50103,52 @@ function listItemLoose(node) {
49977
50103
  : spread
49978
50104
  }
49979
50105
 
50106
+ ;// CONCATENATED MODULE: ./node_modules/mdast-util-to-hast/lib/handlers/list.js
50107
+ /**
50108
+ * @typedef {import('mdast').List} List
50109
+ * @typedef {import('hast').Element} Element
50110
+ * @typedef {import('hast').Properties} Properties
50111
+ * @typedef {import('../index.js').Handler} Handler
50112
+ */
50113
+
50114
+
50115
+
50116
+
50117
+ /**
50118
+ * @type {Handler}
50119
+ * @param {List} node
50120
+ * @returns {Element}
50121
+ */
50122
+ function list_list(h, node) {
50123
+ /** @type {Properties} */
50124
+ const props = {}
50125
+ const name = node.ordered ? 'ol' : 'ul'
50126
+ const items = traverse_all(h, node)
50127
+ let index = -1
50128
+
50129
+ if (typeof node.start === 'number' && node.start !== 1) {
50130
+ props.start = node.start
50131
+ }
50132
+
50133
+ // Like GitHub, add a class for custom styling.
50134
+ while (++index < items.length) {
50135
+ const item = items[index]
50136
+
50137
+ if (
50138
+ item.type === 'element' &&
50139
+ item.tagName === 'li' &&
50140
+ item.properties &&
50141
+ Array.isArray(item.properties.className) &&
50142
+ item.properties.className.includes('task-list-item')
50143
+ ) {
50144
+ props.className = ['contains-task-list']
50145
+ break
50146
+ }
50147
+ }
50148
+
50149
+ return h(node, name, props, wrap_wrap(items, true))
50150
+ }
50151
+
49980
50152
  ;// CONCATENATED MODULE: ./node_modules/mdast-util-to-hast/lib/handlers/paragraph.js
49981
50153
  /**
49982
50154
  * @typedef {import('mdast').Paragraph} Paragraph
@@ -50049,19 +50221,22 @@ function table(h, node) {
50049
50221
  const rows = node.children
50050
50222
  let index = -1
50051
50223
  const align = node.align || []
50052
- /** @type {Array.<Element>} */
50224
+ /** @type {Array<Element>} */
50053
50225
  const result = []
50054
50226
 
50055
50227
  while (++index < rows.length) {
50056
50228
  const row = rows[index].children
50057
50229
  const name = index === 0 ? 'th' : 'td'
50058
- let pos = node.align ? align.length : row.length
50059
- /** @type {Array.<Content>} */
50230
+ /** @type {Array<Content>} */
50060
50231
  const out = []
50232
+ let cellIndex = -1
50233
+ const length = node.align ? align.length : row.length
50061
50234
 
50062
- while (pos--) {
50063
- const cell = row[pos]
50064
- out[pos] = h(cell, name, {align: align[pos]}, cell ? traverse_all(h, cell) : [])
50235
+ while (++cellIndex < length) {
50236
+ const cell = row[cellIndex]
50237
+ out.push(
50238
+ h(cell, name, {align: align[cellIndex]}, cell ? traverse_all(h, cell) : [])
50239
+ )
50065
50240
  }
50066
50241
 
50067
50242
  result[index] = h(rows[index], 'tr', wrap_wrap(out, true))
@@ -50107,6 +50282,22 @@ function handlers_text_text(h, node) {
50107
50282
  )
50108
50283
  }
50109
50284
 
50285
+ ;// CONCATENATED MODULE: ./node_modules/mdast-util-to-hast/lib/handlers/thematic-break.js
50286
+ /**
50287
+ * @typedef {import('mdast').ThematicBreak} ThematicBreak
50288
+ * @typedef {import('hast').Element} Element
50289
+ * @typedef {import('../index.js').Handler} Handler
50290
+ */
50291
+
50292
+ /**
50293
+ * @type {Handler}
50294
+ * @param {ThematicBreak} [node]
50295
+ * @returns {Element}
50296
+ */
50297
+ function thematic_break_thematicBreak(h, node) {
50298
+ return h(node, 'hr')
50299
+ }
50300
+
50110
50301
  ;// CONCATENATED MODULE: ./node_modules/mdast-util-to-hast/lib/handlers/index.js
50111
50302
 
50112
50303
 
@@ -50183,9 +50374,9 @@ function ignore() {
50183
50374
  * @typedef EmbeddedHastFields
50184
50375
  * @property {string} [hName] Defines the tag name of an element
50185
50376
  * @property {Properties} [hProperties] Defines the properties of an element
50186
- * @property {Array.<Content>} [hChildren] Defines the (hast) children of an element
50377
+ * @property {Array<Content>} [hChildren] Defines the (hast) children of an element
50187
50378
  *
50188
- * @typedef {Object.<string, unknown> & EmbeddedHastFields} Data unist data with embedded hast fields
50379
+ * @typedef {Record<string, unknown> & EmbeddedHastFields} Data unist data with embedded hast fields
50189
50380
  *
50190
50381
  * @typedef {MdastNode & {data?: Data}} NodeWithData unist node with embedded hast data
50191
50382
  *
@@ -50193,39 +50384,69 @@ function ignore() {
50193
50384
  * @param {H} h Handle context
50194
50385
  * @param {any} node mdast node to handle
50195
50386
  * @param {Parent|null} parent Parent of `node`
50196
- * @returns {Content|Array.<Content>|null|undefined} hast node
50387
+ * @returns {Content|Array<Content>|null|undefined} hast node
50197
50388
  *
50198
50389
  * @callback HFunctionProps
50199
50390
  * @param {MdastNode|PositionLike|null|undefined} node mdast node or unist position
50200
50391
  * @param {string} tagName HTML tag name
50201
50392
  * @param {Properties} props Properties
50202
- * @param {Array.<Content>?} [children] hast content
50393
+ * @param {Array<Content>?} [children] hast content
50203
50394
  * @returns {Element}
50204
50395
  *
50205
50396
  * @callback HFunctionNoProps
50206
50397
  * @param {MdastNode|PositionLike|null|undefined} node mdast node or unist position
50207
50398
  * @param {string} tagName HTML tag name
50208
- * @param {Array.<Content>?} [children] hast content
50399
+ * @param {Array<Content>?} [children] hast content
50209
50400
  * @returns {Element}
50210
50401
  *
50211
50402
  * @typedef HFields
50212
50403
  * @property {boolean} dangerous Whether HTML is allowed
50404
+ * @property {string} clobberPrefix Prefix to use to prevent DOM clobbering
50405
+ * @property {string} footnoteLabel Label to use to introduce the footnote section
50406
+ * @property {string} footnoteBackLabel Label to use to go back to a footnote call from the footnote section
50213
50407
  * @property {(identifier: string) => Definition|null} definition Definition cache
50214
- * @property {Object.<string, FootnoteDefinition>} footnoteById Footnote cache
50215
- * @property {Array.<string>} footnoteOrder Order in which footnotes occur
50408
+ * @property {Record<string, FootnoteDefinition>} footnoteById Footnote cache
50409
+ * @property {Array<string>} footnoteOrder Order in which footnotes occur
50410
+ * @property {Record<string, number>} footnoteCounts Counts the same footnote was used
50216
50411
  * @property {Handlers} handlers Applied handlers
50217
50412
  * @property {Handler} unknownHandler Handler for any none not in `passThrough` or otherwise handled
50218
50413
  * @property {(left: NodeWithData|PositionLike|null|undefined, right: Content) => Content} augment Like `h` but lower-level and usable on non-elements.
50219
- * @property {Array.<string>} passThrough List of node types to pass through untouched (except for their children).
50414
+ * @property {Array<string>} passThrough List of node types to pass through untouched (except for their children).
50220
50415
  *
50221
50416
  * @typedef Options
50222
- * @property {boolean} [allowDangerousHtml=false] Whether to allow `html` nodes and inject them as `raw` HTML
50223
- * @property {Handlers} [handlers] Object mapping mdast nodes to functions handling them
50224
- * @property {Array.<string>} [passThrough] List of custom mdast node types to pass through (keep) in hast
50225
- * @property {Handler} [unknownHandler] Handler for all unknown nodes.
50417
+ * @property {boolean} [allowDangerousHtml=false]
50418
+ * Whether to allow `html` nodes and inject them as `raw` HTML
50419
+ * @property {string} [clobberPrefix='user-content-']
50420
+ * Prefix to use before the `id` attribute to prevent it from *clobbering*.
50421
+ * attributes.
50422
+ * DOM clobbering is this:
50423
+ *
50424
+ * ```html
50425
+ * <p id=x></p>
50426
+ * <script>alert(x)</script>
50427
+ * ```
50428
+ *
50429
+ * Elements by their ID are made available in browsers on the `window` object.
50430
+ * Using a prefix prevents this from being a problem.
50431
+ * @property {string} [footnoteLabel='Footnotes']
50432
+ * Label to use for the footnotes section.
50433
+ * Affects screen reader users.
50434
+ * Change it if you’re authoring in a different language.
50435
+ * @property {string} [footnoteBackLabel='Back to content']
50436
+ * Label to use from backreferences back to their footnote call.
50437
+ * Affects screen reader users.
50438
+ * Change it if you’re authoring in a different language.
50439
+ * @property {Handlers} [handlers]
50440
+ * Object mapping mdast nodes to functions handling them
50441
+ * @property {Array<string>} [passThrough]
50442
+ * List of custom mdast node types to pass through (keep) in hast
50443
+ * @property {Handler} [unknownHandler]
50444
+ * Handler for all unknown nodes.
50226
50445
  *
50227
- * @typedef {Record.<string, Handler>} Handlers Map of node types to handlers
50228
- * @typedef {HFunctionProps & HFunctionNoProps & HFields} H Handle context
50446
+ * @typedef {Record<string, Handler>} Handlers
50447
+ * Map of node types to handlers
50448
+ * @typedef {HFunctionProps & HFunctionNoProps & HFields} H
50449
+ * Handle context
50229
50450
  */
50230
50451
 
50231
50452
 
@@ -50248,14 +50469,22 @@ const mdast_util_to_hast_lib_own = {}.hasOwnProperty
50248
50469
  function factory(tree, options) {
50249
50470
  const settings = options || {}
50250
50471
  const dangerous = settings.allowDangerousHtml || false
50251
- /** @type {Object.<string, FootnoteDefinition>} */
50472
+ /** @type {Record<string, FootnoteDefinition>} */
50252
50473
  const footnoteById = {}
50253
50474
 
50254
50475
  h.dangerous = dangerous
50476
+ h.clobberPrefix =
50477
+ settings.clobberPrefix === undefined || settings.clobberPrefix === null
50478
+ ? 'user-content-'
50479
+ : settings.clobberPrefix
50480
+ h.footnoteLabel = settings.footnoteLabel || 'Footnotes'
50481
+ h.footnoteBackLabel = settings.footnoteBackLabel || 'Back to content'
50255
50482
  h.definition = definitions(tree)
50256
50483
  h.footnoteById = footnoteById
50257
- /** @type {Array.<string>} */
50484
+ /** @type {Array<string>} */
50258
50485
  h.footnoteOrder = []
50486
+ /** @type {Record<string, number>} */
50487
+ h.footnoteCounts = {}
50259
50488
  h.augment = augment
50260
50489
  h.handlers = {...handlers, ...settings.handlers}
50261
50490
  h.unknownHandler = settings.unknownHandler
@@ -50362,9 +50591,10 @@ function toHast(tree, options) {
50362
50591
  return Array.isArray(node) ? {type: 'root', children: node} : node
50363
50592
  }
50364
50593
 
50365
- ;// CONCATENATED MODULE: ./node_modules/remark-rehype/index.js
50594
+
50595
+
50596
+ ;// CONCATENATED MODULE: ./node_modules/remark-rehype/lib/index.js
50366
50597
  /**
50367
- * @typedef {import('unist').Node} Node
50368
50598
  * @typedef {import('hast').Root} HastRoot
50369
50599
  * @typedef {import('mdast').Root} MdastRoot
50370
50600
  * @typedef {import('mdast-util-to-hast').Options} Options
@@ -50378,12 +50608,21 @@ function toHast(tree, options) {
50378
50608
  // Note: the `<MdastRoot, HastRoot>` overload doesn’t seem to work :'(
50379
50609
 
50380
50610
  /**
50381
- * Plugin to bridge or mutate to rehype.
50611
+ * Plugin that turns markdown into HTML to support rehype.
50382
50612
  *
50383
- * If a destination is given, runs the destination with the new hast tree
50384
- * (bridge-mode).
50385
- * Without destination, returns the hast tree: further plugins run on that tree
50386
- * (mutate-mode).
50613
+ * * If a destination processor is given, that processor runs with a new HTML
50614
+ * (hast) tree (bridge-mode).
50615
+ * As the given processor runs with a hast tree, and rehype plugins support
50616
+ * hast, that means rehype plugins can be used with the given processor.
50617
+ * The hast tree is discarded in the end.
50618
+ * It’s highly unlikely that you want to do this.
50619
+ * * The common case is to not pass a destination processor, in which case the
50620
+ * current processor continues running with a new HTML (hast) tree
50621
+ * (mutate-mode).
50622
+ * As the current processor continues with a hast tree, and rehype plugins
50623
+ * support hast, that means rehype plugins can be used after
50624
+ * `remark-rehype`.
50625
+ * It’s likely that this is what you want to do.
50387
50626
  *
50388
50627
  * @param destination
50389
50628
  * Optional unified processor.
@@ -50391,16 +50630,16 @@ function toHast(tree, options) {
50391
50630
  * Options passed to `mdast-util-to-hast`.
50392
50631
  */
50393
50632
  const remarkRehype =
50394
- /** @type {(import('unified').Plugin<[Processor, Options?]|[Options]|[], MdastRoot>)} */
50633
+ /** @type {(import('unified').Plugin<[Processor, Options?]|[null|undefined, Options?]|[Options]|[], MdastRoot>)} */
50395
50634
  (
50396
50635
  function (destination, options) {
50397
50636
  return destination && 'run' in destination
50398
50637
  ? bridge(destination, options)
50399
- : mutate(destination)
50638
+ : mutate(destination || options)
50400
50639
  }
50401
50640
  )
50402
50641
 
50403
- /* harmony default export */ const remark_rehype = (remarkRehype);
50642
+ /* harmony default export */ const lib = (remarkRehype);
50404
50643
 
50405
50644
  /**
50406
50645
  * Bridge-mode.
@@ -50418,12 +50657,12 @@ function bridge(destination, options) {
50418
50657
 
50419
50658
  /**
50420
50659
  * Mutate-mode.
50421
- * Further transformers run on the nlcst tree.
50660
+ * Further plugins run on the hast tree.
50422
50661
  *
50423
50662
  * @type {import('unified').Plugin<[Options?]|void[], MdastRoot, HastRoot>}
50424
50663
  */
50425
50664
  function mutate(options) {
50426
- // @ts-expect-error: assume a corresponding node is returned for `toHast`.
50665
+ // @ts-expect-error: assume a corresponding node is returned by `toHast`.
50427
50666
  return (node) => toHast(node, options)
50428
50667
  }
50429
50668
 
@@ -52910,9 +53149,9 @@ function flattenPosition(pos) {
52910
53149
  * @property {string} children
52911
53150
  *
52912
53151
  * @typedef PluginOptions
52913
- * @property {PluggableList} [plugins=[]] **deprecated**: use `remarkPlugins` instead
52914
53152
  * @property {PluggableList} [remarkPlugins=[]]
52915
53153
  * @property {PluggableList} [rehypePlugins=[]]
53154
+ * @property {import('remark-rehype').Options} [remarkRehypeOptions={}]
52916
53155
  *
52917
53156
  * @typedef LayoutOptions
52918
53157
  * @property {string} [className]
@@ -52941,6 +53180,7 @@ const changelog =
52941
53180
 
52942
53181
  /** @type {Record<string, Deprecation>} */
52943
53182
  const deprecated = {
53183
+ plugins: {to: 'plugins', id: 'change-plugins-to-remarkplugins'},
52944
53184
  renderers: {to: 'components', id: 'change-renderers-to-components'},
52945
53185
  astPlugins: {id: 'remove-buggy-html-in-markdown-parser'},
52946
53186
  allowDangerousHtml: {id: 'remove-buggy-html-in-markdown-parser'},
@@ -52985,9 +53225,11 @@ function ReactMarkdown(options) {
52985
53225
 
52986
53226
  const processor = unified()
52987
53227
  .use(remark_parse)
52988
- // TODO: deprecate `plugins` in v8.0.0.
52989
- .use(options.remarkPlugins || options.plugins || [])
52990
- .use(remark_rehype, {allowDangerousHtml: true})
53228
+ .use(options.remarkPlugins || [])
53229
+ .use(lib, {
53230
+ ...options.remarkRehypeOptions,
53231
+ allowDangerousHtml: true
53232
+ })
52991
53233
  .use(options.rehypePlugins || [])
52992
53234
  .use(rehypeFilter, options)
52993
53235
 
@@ -66880,7 +67122,7 @@ const rehypeAttrs = (options) => {
66880
67122
  });
66881
67123
  };
66882
67124
  };
66883
- /* harmony default export */ const lib = (rehypeAttrs);
67125
+ /* harmony default export */ const rehype_attr_lib = (rehypeAttrs);
66884
67126
 
66885
67127
  // EXTERNAL MODULE: ./node_modules/@mapbox/rehype-prism/index.js
66886
67128
  var rehype_prism = __webpack_require__(7748);
@@ -71329,7 +71571,7 @@ var jsx_runtime = __webpack_require__(9724);
71329
71571
  ;// CONCATENATED MODULE: ./node_modules/@uiw/react-markdown-preview/esm/index.js
71330
71572
 
71331
71573
 
71332
- var _excluded = ["prefixCls", "className", "source", "style", "onScroll", "onMouseOver", "warpperElement"];
71574
+ var _excluded = ["prefixCls", "className", "source", "style", "onScroll", "onMouseOver", "pluginsFilter", "warpperElement"];
71333
71575
 
71334
71576
 
71335
71577
 
@@ -71391,15 +71633,24 @@ var getCodeStr = function getCodeStr(data, code) {
71391
71633
  style,
71392
71634
  onScroll,
71393
71635
  onMouseOver,
71636
+ pluginsFilter,
71394
71637
  warpperElement = {}
71395
71638
  } = props,
71396
- other = objectWithoutPropertiesLoose_objectWithoutPropertiesLoose(props, _excluded);
71639
+ other = _objectWithoutPropertiesLoose(props, _excluded);
71397
71640
 
71398
71641
  var mdp = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
71399
71642
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(ref, () => _extends({}, props, {
71400
71643
  mdp
71401
71644
  }), [mdp, props]);
71402
71645
  var cls = (prefixCls || '') + " " + (className || '');
71646
+ var rehypePlugins = [[(rehype_prism_default()), {
71647
+ ignoreMissing: true
71648
+ }], rehypeRaw, rehypeSlug, rehypeAutolinkHeadings, [rehype_rewrite_lib, {
71649
+ rewrite: rehypeRewriteHandle
71650
+ }], [rehype_attr_lib, {
71651
+ properties: 'attr'
71652
+ }], ...(other.rehypePlugins || [])];
71653
+ var remarkPlugins = [...(other.remarkPlugins || []), remarkGfm];
71403
71654
  return /*#__PURE__*/(0,jsx_runtime.jsx)("div", _extends({
71404
71655
  ref: mdp,
71405
71656
  onScroll: onScroll,
@@ -71408,14 +71659,8 @@ var getCodeStr = function getCodeStr(data, code) {
71408
71659
  className: cls,
71409
71660
  style: style,
71410
71661
  children: /*#__PURE__*/(0,jsx_runtime.jsx)(ReactMarkdown, _extends({}, other, {
71411
- rehypePlugins: [[(rehype_prism_default()), {
71412
- ignoreMissing: true
71413
- }], rehypeRaw, rehypeSlug, rehypeAutolinkHeadings, [rehype_rewrite_lib, {
71414
- rewrite: rehypeRewriteHandle
71415
- }], [lib, {
71416
- properties: 'attr'
71417
- }], ...(other.rehypePlugins || [])],
71418
- remarkPlugins: [...(other.remarkPlugins || []), remarkGfm],
71662
+ rehypePlugins: pluginsFilter ? pluginsFilter('rehype', rehypePlugins) : rehypePlugins,
71663
+ remarkPlugins: pluginsFilter ? pluginsFilter('remark', remarkPlugins) : remarkPlugins,
71419
71664
  children: source || ''
71420
71665
  }))
71421
71666
  }));
@@ -75329,10 +75574,10 @@ function Child_Child(props){var _ref=props||{},prefixCls=_ref.prefixCls,groupNam
75329
75574
  // extracted by mini-css-extract-plugin
75330
75575
  /* harmony default export */ const Toolbar = ({});
75331
75576
  ;// CONCATENATED MODULE: ./src/components/Toolbar/index.tsx
75332
- function ToolbarItems(props){var prefixCls=props.prefixCls;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){if(fullscreen){// prevent scroll on fullscreen
75577
+ 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
75333
75578
  document.body.style.overflow='hidden';}else{// get the original overflow only the first time
75334
75579
  if(!originalOverflow.current){originalOverflow.current=window.getComputedStyle(document.body,null).overflow;}// reset to the original overflow
75335
- document.body.style.overflow=originalOverflow.current;}}},[fullscreen,originalOverflow]);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,{});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',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,{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||[]}))]});}
75580
+ 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||[]}))]});}
75336
75581
  ;// CONCATENATED MODULE: ./src/components/DragBar/index.less
75337
75582
  // extracted by mini-css-extract-plugin
75338
75583
  /* harmony default export */ const DragBar = ({});
@@ -75343,14 +75588,14 @@ var DragBar_DragBar=function DragBar(props){var _ref=props||{},prefixCls=_ref.pr
75343
75588
  // extracted by mini-css-extract-plugin
75344
75589
  /* harmony default export */ const src = ({});
75345
75590
  ;// CONCATENATED MODULE: ./src/Editor.tsx
75346
- var Editor_excluded=["prefixCls","className","value","commands","commandsFilter","extraCommands","height","toolbarHeight","enableScroll","visiableDragbar","highlightEnable","preview","fullscreen","previewOptions","textareaProps","maxHeight","minHeight","autoFocus","tabSize","defaultTabEnable","onChange","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$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,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
75591
+ 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","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,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
75347
75592
  },[]);var cls=[className,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
75348
75593
  (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
75349
75594
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return height!==state.height&&dispatch({height:height});},[height]);// eslint-disable-next-line react-hooks/exhaustive-deps
75350
75595
  (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
75351
75596
  [highlightEnable]);// eslint-disable-next-line react-hooks/exhaustive-deps
75352
75597
  (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
75353
- [fullscreen]);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}),/*#__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);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);
75598
+ [fullscreen]);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);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);
75354
75599
  ;// CONCATENATED MODULE: ./src/index.tsx
75355
75600
  /* harmony default export */ const src_0 = (Editor);
75356
75601
  })();