@powerduck/md-editor 0.11.4 → 0.11.5

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/index.mjs CHANGED
@@ -1296,7 +1296,7 @@ const Cn = /\b\B/, ht = "[a-zA-Z]\\w*", Re = "[a-zA-Z_]\\w*", pt = "\\b\\d+(\\.\
1296
1296
  // look for 3 words in a row
1297
1297
  }
1298
1298
  ), i;
1299
- }, Dn = ve("//", "$"), Pn = ve("/\\*", "\\*/"), Bn = ve("#", "$"), $n = {
1299
+ }, Dn = ve("//", "$"), Pn = ve("/\\*", "\\*/"), $n = ve("#", "$"), Bn = {
1300
1300
  scope: "number",
1301
1301
  begin: pt,
1302
1302
  relevance: 0
@@ -1360,11 +1360,11 @@ var fe = /* @__PURE__ */ Object.freeze({
1360
1360
  C_NUMBER_MODE: Un,
1361
1361
  C_NUMBER_RE: gt,
1362
1362
  END_SAME_AS_BEGIN: qn,
1363
- HASH_COMMENT_MODE: Bn,
1363
+ HASH_COMMENT_MODE: $n,
1364
1364
  IDENT_RE: ht,
1365
1365
  MATCH_NOTHING_RE: Cn,
1366
1366
  METHOD_GUARD: Gn,
1367
- NUMBER_MODE: $n,
1367
+ NUMBER_MODE: Bn,
1368
1368
  NUMBER_RE: pt,
1369
1369
  PHRASAL_WORDS_MODE: Ln,
1370
1370
  QUOTE_STRING_MODE: In,
@@ -1638,17 +1638,17 @@ const xe = lt, Je = j, je = Symbol("nomatch"), ui = 7, Et = function(n) {
1638
1638
  let k = "", T = "";
1639
1639
  typeof _ == "object" ? (k = h, f = _.ignoreIllegals, T = _.language) : (re("10.7.0", "highlight(lang, code, ...args) has been deprecated."), re("10.7.0", `Please use highlight(code, options) instead.
1640
1640
  https://github.com/highlightjs/highlight.js/issues/2277`), T = h, k = _), f === void 0 && (f = !0);
1641
- const B = {
1641
+ const $ = {
1642
1642
  code: k,
1643
1643
  language: T
1644
1644
  };
1645
- Q("before:highlight", B);
1646
- const K = B.result ? B.result : u(B.language, B.code, f);
1647
- return K.code = B.code, Q("after:highlight", K), K;
1645
+ Q("before:highlight", $);
1646
+ const K = $.result ? $.result : u($.language, $.code, f);
1647
+ return K.code = $.code, Q("after:highlight", K), K;
1648
1648
  }
1649
1649
  function u(h, _, f, k) {
1650
1650
  const T = /* @__PURE__ */ Object.create(null);
1651
- function B(g, y) {
1651
+ function $(g, y) {
1652
1652
  return g.keywords[y];
1653
1653
  }
1654
1654
  function K() {
@@ -1661,7 +1661,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), T = h, k = _), f ===
1661
1661
  let y = v.keywordPatternRe.exec(R), N = "";
1662
1662
  for (; y; ) {
1663
1663
  N += R.substring(g, y.index);
1664
- const C = Z.case_insensitive ? y[0].toLowerCase() : y[0], G = B(v, C);
1664
+ const C = Z.case_insensitive ? y[0].toLowerCase() : y[0], G = $(v, C);
1665
1665
  if (G) {
1666
1666
  const [V, Gt] = G;
1667
1667
  if (z.addText(N), N = "", T[C] = (T[C] || 0) + 1, T[C] <= ui && (ge += Gt), V.startsWith("_"))
@@ -1684,7 +1684,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), T = h, k = _), f ===
1684
1684
  z.addText(R);
1685
1685
  return;
1686
1686
  }
1687
- g = u(v.subLanguage, R, !0, $e[v.subLanguage]), $e[v.subLanguage] = /** @type {CompiledMode} */
1687
+ g = u(v.subLanguage, R, !0, Be[v.subLanguage]), Be[v.subLanguage] = /** @type {CompiledMode} */
1688
1688
  g._top;
1689
1689
  } else
1690
1690
  g = m(R, v.subLanguage.length ? v.subLanguage : null);
@@ -1755,7 +1755,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), T = h, k = _), f ===
1755
1755
  g.forEach((y) => z.openNode(y));
1756
1756
  }
1757
1757
  let pe = {};
1758
- function Be(g, y) {
1758
+ function $e(g, y) {
1759
1759
  const N = y && y[0];
1760
1760
  if (R += g, N == null)
1761
1761
  return q(), 0;
@@ -1788,7 +1788,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), T = h, k = _), f ===
1788
1788
  throw ne(a.replace("{}", h)), new Error('Unknown language: "' + h + '"');
1789
1789
  const Kt = ai(Z);
1790
1790
  let ke = "", v = k || Kt;
1791
- const $e = {}, z = new o.__emitter(o);
1791
+ const Be = {}, z = new o.__emitter(o);
1792
1792
  zt();
1793
1793
  let R = "", ge = 0, te = 0, Ne = 0, Se = !1;
1794
1794
  try {
@@ -1799,10 +1799,10 @@ https://github.com/highlightjs/highlight.js/issues/2277`), T = h, k = _), f ===
1799
1799
  Ne++, Se ? Se = !1 : v.matcher.considerAll(), v.matcher.lastIndex = te;
1800
1800
  const g = v.matcher.exec(_);
1801
1801
  if (!g) break;
1802
- const y = _.substring(te, g.index), N = Be(y, g);
1802
+ const y = _.substring(te, g.index), N = $e(y, g);
1803
1803
  te = g.index + N;
1804
1804
  }
1805
- Be(_.substring(te));
1805
+ $e(_.substring(te));
1806
1806
  }
1807
1807
  return z.finalize(), ke = z.toHTML(), {
1808
1808
  language: h,
@@ -1866,7 +1866,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), T = h, k = _), f ===
1866
1866
  return -1;
1867
1867
  }
1868
1868
  return 0;
1869
- }), [B, K] = T, W = B;
1869
+ }), [$, K] = T, W = $;
1870
1870
  return W.secondBest = K, W;
1871
1871
  }
1872
1872
  function b(h, _, f) {
@@ -1939,7 +1939,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), T = h, k = _), f ===
1939
1939
  for (const _ of Object.keys(t))
1940
1940
  t[_] === h && delete t[_];
1941
1941
  }
1942
- function $() {
1942
+ function B() {
1943
1943
  return Object.keys(e);
1944
1944
  }
1945
1945
  function U(h) {
@@ -1993,7 +1993,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), T = h, k = _), f ===
1993
1993
  initHighlightingOnLoad: I,
1994
1994
  registerLanguage: L,
1995
1995
  unregisterLanguage: P,
1996
- listLanguages: $,
1996
+ listLanguages: B,
1997
1997
  getLanguage: U,
1998
1998
  registerAliases: F,
1999
1999
  autoDetection: X,
@@ -2181,19 +2181,19 @@ function kt(n) {
2181
2181
  * @param {CallbackResponse} response
2182
2182
  */
2183
2183
  isTrulyOpeningTag: (f, k) => {
2184
- const T = f[0].length + f.index, B = f.input[T];
2184
+ const T = f[0].length + f.index, $ = f.input[T];
2185
2185
  if (
2186
2186
  // HTML should not include another raw `<` inside a tag
2187
2187
  // nested type?
2188
2188
  // `<Array<Array<number>>`, etc.
2189
- B === "<" || // the , gives away that this is not HTML
2189
+ $ === "<" || // the , gives away that this is not HTML
2190
2190
  // `<T, A extends keyof T, V>`
2191
- B === ","
2191
+ $ === ","
2192
2192
  ) {
2193
2193
  k.ignoreMatch();
2194
2194
  return;
2195
2195
  }
2196
- B === ">" && (t(f, { after: T }) || k.ignoreMatch());
2196
+ $ === ">" && (t(f, { after: T }) || k.ignoreMatch());
2197
2197
  let K;
2198
2198
  const W = f.input.substring(T);
2199
2199
  if (K = W.match(/^\s*=/)) {
@@ -2366,7 +2366,7 @@ function kt(n) {
2366
2366
  excludeEnd: !0,
2367
2367
  keywords: o,
2368
2368
  contains: L
2369
- }, $ = {
2369
+ }, B = {
2370
2370
  variants: [
2371
2371
  // class Car extends vehicle
2372
2372
  {
@@ -2667,7 +2667,7 @@ function kt(n) {
2667
2667
  },
2668
2668
  ce,
2669
2669
  ee,
2670
- $,
2670
+ B,
2671
2671
  le,
2672
2672
  {
2673
2673
  match: /\$[(.]/
@@ -2838,19 +2838,19 @@ function bi(n) {
2838
2838
  * @param {CallbackResponse} response
2839
2839
  */
2840
2840
  isTrulyOpeningTag: (f, k) => {
2841
- const T = f[0].length + f.index, B = f.input[T];
2841
+ const T = f[0].length + f.index, $ = f.input[T];
2842
2842
  if (
2843
2843
  // HTML should not include another raw `<` inside a tag
2844
2844
  // nested type?
2845
2845
  // `<Array<Array<number>>`, etc.
2846
- B === "<" || // the , gives away that this is not HTML
2846
+ $ === "<" || // the , gives away that this is not HTML
2847
2847
  // `<T, A extends keyof T, V>`
2848
- B === ","
2848
+ $ === ","
2849
2849
  ) {
2850
2850
  k.ignoreMatch();
2851
2851
  return;
2852
2852
  }
2853
- B === ">" && (t(f, { after: T }) || k.ignoreMatch());
2853
+ $ === ">" && (t(f, { after: T }) || k.ignoreMatch());
2854
2854
  let K;
2855
2855
  const W = f.input.substring(T);
2856
2856
  if (K = W.match(/^\s*=/)) {
@@ -3023,7 +3023,7 @@ function bi(n) {
3023
3023
  excludeEnd: !0,
3024
3024
  keywords: o,
3025
3025
  contains: L
3026
- }, $ = {
3026
+ }, B = {
3027
3027
  variants: [
3028
3028
  // class Car extends vehicle
3029
3029
  {
@@ -3324,7 +3324,7 @@ function bi(n) {
3324
3324
  },
3325
3325
  ce,
3326
3326
  ee,
3327
- $,
3327
+ B,
3328
3328
  le,
3329
3329
  {
3330
3330
  match: /\$[(.]/
@@ -5962,9 +5962,9 @@ function Mi(n) {
5962
5962
  };
5963
5963
  function M(L, {
5964
5964
  exceptions: P,
5965
- when: $
5965
+ when: B
5966
5966
  } = {}) {
5967
- const U = $;
5967
+ const U = B;
5968
5968
  return P = P || [], L.map((F) => F.match(/\|\d+$/) || P.includes(F) ? F : U(F) ? `${F}|0` : F);
5969
5969
  }
5970
5970
  return {
@@ -7339,7 +7339,7 @@ function Ii(n) {
7339
7339
  }
7340
7340
  ]),
7341
7341
  relevance: 0
7342
- }, $ = {
7342
+ }, B = {
7343
7343
  begin: "(" + s + "[\\*&\\s]+){1," + A + "}" + S,
7344
7344
  returnBegin: !0,
7345
7345
  end: /[{;=]/,
@@ -7410,7 +7410,7 @@ function Ii(n) {
7410
7410
  illegal: "</",
7411
7411
  contains: [].concat(
7412
7412
  P,
7413
- $,
7413
+ B,
7414
7414
  L,
7415
7415
  [
7416
7416
  ...b,
@@ -7436,7 +7436,7 @@ function Ii(n) {
7436
7436
  }
7437
7437
  };
7438
7438
  }
7439
- function Bt(n) {
7439
+ function $t(n) {
7440
7440
  const e = n.regex, t = n.COMMENT("//", "$", { contains: [{ begin: /\\\n/ }] }), i = "decltype\\(auto\\)", r = "[a-zA-Z_]\\w*::", s = "(?!struct)(" + i + "|" + e.optional(r) + "[a-zA-Z_]\\w*" + e.optional("<[^<>]+>") + ")", o = {
7441
7441
  className: "type",
7442
7442
  begin: "\\b[a-z\\d_]*_t\\b"
@@ -7781,7 +7781,7 @@ function Bt(n) {
7781
7781
  "visit",
7782
7782
  "vprintf",
7783
7783
  "vsprintf"
7784
- ], $ = {
7784
+ ], B = {
7785
7785
  type: I,
7786
7786
  keyword: A,
7787
7787
  literal: [
@@ -7832,12 +7832,12 @@ function Bt(n) {
7832
7832
  end: /;/
7833
7833
  }
7834
7834
  ],
7835
- keywords: $,
7835
+ keywords: B,
7836
7836
  contains: F.concat([
7837
7837
  {
7838
7838
  begin: /\(/,
7839
7839
  end: /\)/,
7840
- keywords: $,
7840
+ keywords: B,
7841
7841
  contains: F.concat(["self"]),
7842
7842
  relevance: 0
7843
7843
  }
@@ -7849,13 +7849,13 @@ function Bt(n) {
7849
7849
  returnBegin: !0,
7850
7850
  end: /[{;=]/,
7851
7851
  excludeEnd: !0,
7852
- keywords: $,
7852
+ keywords: B,
7853
7853
  illegal: /[^\w\s\*&:<>.]/,
7854
7854
  contains: [
7855
7855
  {
7856
7856
  // to prevent it from being confused as the function title
7857
7857
  begin: i,
7858
- keywords: $,
7858
+ keywords: B,
7859
7859
  relevance: 0
7860
7860
  },
7861
7861
  {
@@ -7889,7 +7889,7 @@ function Bt(n) {
7889
7889
  className: "params",
7890
7890
  begin: /\(/,
7891
7891
  end: /\)/,
7892
- keywords: $,
7892
+ keywords: B,
7893
7893
  relevance: 0,
7894
7894
  contains: [
7895
7895
  t,
@@ -7901,7 +7901,7 @@ function Bt(n) {
7901
7901
  {
7902
7902
  begin: /\(/,
7903
7903
  end: /\)/,
7904
- keywords: $,
7904
+ keywords: B,
7905
7905
  relevance: 0,
7906
7906
  contains: [
7907
7907
  "self",
@@ -7931,7 +7931,7 @@ function Bt(n) {
7931
7931
  "hxx",
7932
7932
  "cxx"
7933
7933
  ],
7934
- keywords: $,
7934
+ keywords: B,
7935
7935
  illegal: "</",
7936
7936
  classNameAliases: { "function.dispatch": "built_in" },
7937
7937
  contains: [].concat(
@@ -7945,7 +7945,7 @@ function Bt(n) {
7945
7945
  // containers: ie, `vector <int> rooms (9);`
7946
7946
  begin: "\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",
7947
7947
  end: ">",
7948
- keywords: $,
7948
+ keywords: B,
7949
7949
  contains: [
7950
7950
  "self",
7951
7951
  o
@@ -7953,7 +7953,7 @@ function Bt(n) {
7953
7953
  },
7954
7954
  {
7955
7955
  begin: n.IDENT_RE + "::",
7956
- keywords: $
7956
+ keywords: B
7957
7957
  },
7958
7958
  {
7959
7959
  match: [
@@ -7995,8 +7995,8 @@ x.registerLanguage("rust", Dt);
7995
7995
  x.registerLanguage("rs", Dt);
7996
7996
  x.registerLanguage("java", Oi);
7997
7997
  x.registerLanguage("c", Ii);
7998
- x.registerLanguage("cpp", Bt);
7999
- x.registerLanguage("c++", Bt);
7998
+ x.registerLanguage("cpp", $t);
7999
+ x.registerLanguage("c++", $t);
8000
8000
  const Li = /* @__PURE__ */ new Set(["mindmap"]);
8001
8001
  function de(n) {
8002
8002
  return n.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
@@ -8038,14 +8038,14 @@ function Di(n, e = {}) {
8038
8038
  return `<div class="md-editor-codeblock"><div class="md-editor-codeblock-header"><span class="md-editor-codeblock-lights"><span class="md-editor-codeblock-dot md-editor-codeblock-dot--red"></span><span class="md-editor-codeblock-dot md-editor-codeblock-dot--yellow"></span><span class="md-editor-codeblock-dot md-editor-codeblock-dot--green"></span></span><span class="md-editor-codeblock-lang">${de(b)}</span><button type="button" class="md-editor-codeblock-copy" aria-label="Copy code">Copy</button></div><pre class="md-editor-codeblock-pre"><code class="language-${de(b)}">${m}</code></pre></div>`;
8039
8039
  };
8040
8040
  }
8041
- const Pi = [".mp4", ".webm", ".ogg", ".mov", ".m4v", ".avi", ".mkv"], Bi = [
8041
+ const Pi = [".mp4", ".webm", ".ogg", ".mov", ".m4v", ".avi", ".mkv"], $i = [
8042
8042
  /(?:youtube\.com\/watch\?[^ ]*v=|youtu\.be\/|youtube\.com\/embed\/|youtube\.com\/shorts\/|youtube\.com\/v\/)([a-zA-Z0-9_-]{11})/,
8043
8043
  /^([a-zA-Z0-9_-]{11})$/
8044
8044
  ];
8045
- function $i(n) {
8045
+ function Bi(n) {
8046
8046
  const e = n.trim();
8047
8047
  if (!e) return null;
8048
- for (const t of Bi) {
8048
+ for (const t of $i) {
8049
8049
  const i = e.match(t);
8050
8050
  if (i && i[1]) return i[1];
8051
8051
  }
@@ -8160,7 +8160,7 @@ function Vi(n) {
8160
8160
  return e ? e(t, i, r, a, s) : s.renderToken(t, i, r);
8161
8161
  };
8162
8162
  }
8163
- class $t {
8163
+ class Bt {
8164
8164
  constructor(e = {}) {
8165
8165
  this.md = new Jt({
8166
8166
  html: e.html ?? !1,
@@ -8187,7 +8187,8 @@ class $t {
8187
8187
  }
8188
8188
  }
8189
8189
  function Er(n, e = {}) {
8190
- return new $t(e).render(n);
8190
+ const i = new Bt(e).render(n);
8191
+ return e.theme ? `<div class="md-editor-standalone" data-theme="${e.theme}">${i}</div>` : i;
8191
8192
  }
8192
8193
  class Xi {
8193
8194
  constructor(e) {
@@ -8598,7 +8599,7 @@ class Nr {
8598
8599
  this.previewPane = null, this.incremental = null, this.toolbar = null, this.statusBar = null, this.activePopup = null, this.scheduledRender = null, this.scheduledWait = 0;
8599
8600
  const i = typeof e == "string" ? document.querySelector(e) : e;
8600
8601
  if (!i) throw new Error("MarkdownEditor: mount container not found");
8601
- this.container = i, this.mode = t.mode ?? "simple", this.theme = t.theme ?? "light", this.showPreview = t.preview ?? !0, this.autoPreview = t.autoPreview ?? !0, this.renderDebounceOpt = t.renderDebounce, this.onChange = t.onChange, this.onImageUpload = t.onImageUpload, this.toolbarConfig = t.toolbar, this.shortcuts = cr, this.container.classList.add("md-editor-root", `md-editor-mode-${this.mode}`), this.container.setAttribute("data-theme", this.theme), this.renderer = new $t({
8602
+ this.container = i, this.mode = t.mode ?? "simple", this.theme = t.theme ?? "light", this.showPreview = t.preview ?? !0, this.autoPreview = t.autoPreview ?? !0, this.renderDebounceOpt = t.renderDebounce, this.onChange = t.onChange, this.onImageUpload = t.onImageUpload, this.toolbarConfig = t.toolbar, this.shortcuts = cr, this.container.classList.add("md-editor-root", `md-editor-mode-${this.mode}`), this.container.setAttribute("data-theme", this.theme), this.renderer = new Bt({
8602
8603
  math: t.math ?? !0,
8603
8604
  mindmap: t.mindmap ?? !0,
8604
8605
  codeHighlight: t.codeHighlight ?? !0,
@@ -8756,7 +8757,7 @@ class Nr {
8756
8757
  }
8757
8758
  ],
8758
8759
  onSubmit: (i) => {
8759
- const r = i.url ?? "", a = $i(r);
8760
+ const r = i.url ?? "", a = Bi(r);
8760
8761
  a && this.codeEditor.insertAtCursor(Ui(a));
8761
8762
  }
8762
8763
  }), this.activePopup.show();
@@ -9137,14 +9138,14 @@ export {
9137
9138
  sr as IncrementalRenderer,
9138
9139
  Nr as MarkdownEditor,
9139
9140
  J as Popup,
9140
- $t as Renderer,
9141
+ Bt as Renderer,
9141
9142
  Qi as StatusBar,
9142
9143
  Xi as Toolbar,
9143
9144
  ar as adaptiveDebounceMs,
9144
9145
  wr as cancelIdle,
9145
9146
  rt as countText,
9146
9147
  or as debounce,
9147
- $i as extractYouTubeId,
9148
+ Bi as extractYouTubeId,
9148
9149
  kr as formatShortcut,
9149
9150
  lr as formatShortcutHtml,
9150
9151
  O as icons,