@synclineapi/mdx-editor 0.1.1 → 0.1.2
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/README.md +3 -1
- package/dist/core/renderer.d.ts +3 -0
- package/dist/syncline-mdx-editor.js +68 -24
- package/dist/syncline-mdx-editor.umd.cjs +60 -54
- package/package.json +2 -9
package/README.md
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
# @synclineapi/mdx-editor
|
|
2
2
|
|
|
3
|
-
[](https://github.com/RadhaHariharan/syncline-mdx-editor/actions/workflows/ci.yml)
|
|
4
3
|
[](https://www.npmjs.com/package/@synclineapi/mdx-editor)
|
|
5
4
|
[](https://opensource.org/licenses/MIT)
|
|
6
5
|
[](https://www.typescriptlang.org/)
|
|
7
6
|
[](https://www.w3.org/TR/WCAG21/)
|
|
7
|
+
[](https://markdown.synclineapi.com/)
|
|
8
8
|
|
|
9
9
|
A **framework-agnostic**, plugin-based MDX/Markdown editor with toolbar customization, live preview, and 33+ built-in features. Works with React, Vue, Angular, Next.js, Svelte, or plain JavaScript.
|
|
10
10
|
|
|
11
|
+
**[Live Demo →](https://markdown.synclineapi.com/)**
|
|
12
|
+
|
|
11
13
|
## Quick Start
|
|
12
14
|
|
|
13
15
|
```bash
|
package/dist/core/renderer.d.ts
CHANGED
|
@@ -19,6 +19,9 @@ export declare class Renderer {
|
|
|
19
19
|
private renderMarkdown;
|
|
20
20
|
private renderTables;
|
|
21
21
|
private parseTableRow;
|
|
22
|
+
private isListItem;
|
|
23
|
+
private buildNestedList;
|
|
24
|
+
private renderNestedLists;
|
|
22
25
|
private escapeHtml;
|
|
23
26
|
/**
|
|
24
27
|
* Validate MDX component tags — detect unclosed or mismatched tags.
|
|
@@ -296,7 +296,7 @@ class z {
|
|
|
296
296
|
document.removeEventListener("click", this.documentClickHandler), (e = this.el) == null || e.remove();
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
const
|
|
299
|
+
const N = /* @__PURE__ */ new Set([
|
|
300
300
|
"script",
|
|
301
301
|
"style",
|
|
302
302
|
"object",
|
|
@@ -310,14 +310,14 @@ const R = /* @__PURE__ */ new Set([
|
|
|
310
310
|
"applet",
|
|
311
311
|
"frame",
|
|
312
312
|
"frameset"
|
|
313
|
-
]),
|
|
313
|
+
]), R = [
|
|
314
314
|
"https://www.youtube.com/embed/",
|
|
315
315
|
"https://youtube.com/embed/",
|
|
316
316
|
"https://codepen.io/",
|
|
317
317
|
"https://codesandbox.io/embed/"
|
|
318
318
|
];
|
|
319
319
|
function O(r) {
|
|
320
|
-
return
|
|
320
|
+
return R.some((e) => r.startsWith(e));
|
|
321
321
|
}
|
|
322
322
|
const S = /^on/i, j = /^\s*javascript\s*:/i;
|
|
323
323
|
function G(r) {
|
|
@@ -328,7 +328,7 @@ function G(r) {
|
|
|
328
328
|
for (; s; ) {
|
|
329
329
|
if (s.nodeType === Node.ELEMENT_NODE) {
|
|
330
330
|
const n = s, a = n.tagName.toLowerCase();
|
|
331
|
-
if (
|
|
331
|
+
if (N.has(a))
|
|
332
332
|
i.push(n);
|
|
333
333
|
else if (a === "iframe") {
|
|
334
334
|
const d = n.getAttribute("src") || "";
|
|
@@ -455,13 +455,13 @@ class _ {
|
|
|
455
455
|
} catch {
|
|
456
456
|
m = this.escapeHtml(h);
|
|
457
457
|
}
|
|
458
|
-
const
|
|
458
|
+
const u = n ? c[n.toLowerCase()] || n.charAt(0).toUpperCase() + n.slice(1) : "", x = u ? `<span class="smdx-code-lang">${u}</span>` : "", b = a ? `<span class="smdx-code-filename"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>${this.escapeHtml(a)}</span>` : "", v = '<button class="smdx-copy-btn" data-copy-btn="true" title="Copy code" aria-label="Copy code"><svg class="smdx-copy-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg><svg class="smdx-check-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg></button>', f = u || a, k = f ? `<div class="smdx-code-header">${x}${b}${v}</div>` : "";
|
|
459
459
|
return o.push(
|
|
460
460
|
`<div class="smdx-code-block${f ? " smdx-has-header" : ""}">${k}<pre><code class="hljs language-${n || "text"}">${m}</code></pre>${f ? "" : v}</div>`
|
|
461
461
|
), `%%CODEBLOCK_${l}%%`;
|
|
462
462
|
}), t = t.replace(/`([^`]+)`/g, (s, n) => `<code class="smdx-inline-code">${this.escapeHtml(n)}</code>`);
|
|
463
463
|
const i = (s) => s.toLowerCase().replace(/[^\w]+/g, "-").replace(/^-|-$/g, "");
|
|
464
|
-
t = t.replace(/^######\s+(.+)$/gm, (s, n) => `<h6 id="${i(n)}">${n}</h6>`), t = t.replace(/^#####\s+(.+)$/gm, (s, n) => `<h5 id="${i(n)}">${n}</h5>`), t = t.replace(/^####\s+(.+)$/gm, (s, n) => `<h4 id="${i(n)}">${n}</h4>`), t = t.replace(/^###\s+(.+)$/gm, (s, n) => `<h3 id="${i(n)}">${n}</h3>`), t = t.replace(/^##\s+(.+)$/gm, (s, n) => `<h2 id="${i(n)}">${n}</h2>`), t = t.replace(/^#\s+(.+)$/gm, (s, n) => `<h1 id="${i(n)}">${n}</h1>`), t = t.replace(/^---$/gm, "<hr/>"), t = t.replace(/\*\*\*(.+?)\*\*\*/g, "<strong><em>$1</em></strong>"), t = t.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>"), t = t.replace(/\*(.+?)\*/g, "<em>$1</em>"), t = t.replace(/~~(.+?)~~/g, "<del>$1</del>"), t = t.replace(/^>\s+(.+)$/gm, "<blockquote>$1</blockquote>"), t = t.replace(/^- \[x\]\s+(.+)$/gm, '<div class="smdx-task"><input type="checkbox" checked disabled /><span>$1</span></div>'), t = t.replace(/^- \[ \]\s+(.+)$/gm, '<div class="smdx-task"><input type="checkbox" disabled /><span>$1</span></div>'), t =
|
|
464
|
+
t = t.replace(/^######\s+(.+)$/gm, (s, n) => `<h6 id="${i(n)}">${n}</h6>`), t = t.replace(/^#####\s+(.+)$/gm, (s, n) => `<h5 id="${i(n)}">${n}</h5>`), t = t.replace(/^####\s+(.+)$/gm, (s, n) => `<h4 id="${i(n)}">${n}</h4>`), t = t.replace(/^###\s+(.+)$/gm, (s, n) => `<h3 id="${i(n)}">${n}</h3>`), t = t.replace(/^##\s+(.+)$/gm, (s, n) => `<h2 id="${i(n)}">${n}</h2>`), t = t.replace(/^#\s+(.+)$/gm, (s, n) => `<h1 id="${i(n)}">${n}</h1>`), t = t.replace(/^---$/gm, "<hr/>"), t = t.replace(/\*\*\*(.+?)\*\*\*/g, "<strong><em>$1</em></strong>"), t = t.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>"), t = t.replace(/\*(.+?)\*/g, "<em>$1</em>"), t = t.replace(/~~(.+?)~~/g, "<del>$1</del>"), t = t.replace(/^>\s+(.+)$/gm, "<blockquote>$1</blockquote>"), t = t.replace(/^- \[x\]\s+(.+)$/gm, '<div class="smdx-task"><input type="checkbox" checked disabled /><span>$1</span></div>'), t = t.replace(/^- \[ \]\s+(.+)$/gm, '<div class="smdx-task"><input type="checkbox" disabled /><span>$1</span></div>'), t = this.renderNestedLists(t), t = t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, '<img src="$2" alt="$1" class="smdx-image"/>'), t = t.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'), t = this.renderTables(t), t = t.replace(/ {2,}$/gm, "<br/>"), t = t.replace(/^(?!\s*<[a-zA-Z/!]|\s*%%)(.*\S.*)$/gm, "<p>$1</p>"), t = t.replace(/<p>\s*<\/p>/g, "");
|
|
465
465
|
for (let s = 0; s < o.length; s++)
|
|
466
466
|
t = t.replace(`%%CODEBLOCK_${s}%%`, o[s]);
|
|
467
467
|
return t;
|
|
@@ -487,6 +487,46 @@ class _ {
|
|
|
487
487
|
parseTableRow(e) {
|
|
488
488
|
return e.split("|").slice(1, -1).map((t) => t.trim());
|
|
489
489
|
}
|
|
490
|
+
isListItem(e) {
|
|
491
|
+
return /^\s*[-*]\s+/.test(e) || /^\s*\d+\.\s+/.test(e);
|
|
492
|
+
}
|
|
493
|
+
buildNestedList(e) {
|
|
494
|
+
var d, l, c;
|
|
495
|
+
if (e.length === 0) return "";
|
|
496
|
+
const t = ((d = e[0].match(/^(\s*)/)) == null ? void 0 : d[1].length) ?? 0, o = /^\s*\d+\.\s+/.test(e[0]), i = o ? "ol" : "ul", s = o ? "smdx-ol-item" : "smdx-ul-item";
|
|
497
|
+
let n = `<${i}>`, a = 0;
|
|
498
|
+
for (; a < e.length; ) {
|
|
499
|
+
const m = e[a], h = ((l = m.match(/^(\s*)/)) == null ? void 0 : l[1].length) ?? 0;
|
|
500
|
+
if (h < t) break;
|
|
501
|
+
if (h > t) {
|
|
502
|
+
a++;
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
const u = o ? m.replace(/^\s*\d+\.\s+/, "") : m.replace(/^\s*[-*]\s+/, "");
|
|
506
|
+
a++;
|
|
507
|
+
const x = [];
|
|
508
|
+
for (; a < e.length && ((((c = e[a].match(/^(\s*)/)) == null ? void 0 : c[1].length) ?? 0) > t && this.isListItem(e[a])); )
|
|
509
|
+
x.push(e[a]), a++;
|
|
510
|
+
const b = x.length > 0 ? this.buildNestedList(x) : "";
|
|
511
|
+
n += `<li class="${s}">${u}${b}</li>`;
|
|
512
|
+
}
|
|
513
|
+
return n += `</${i}>`, n;
|
|
514
|
+
}
|
|
515
|
+
renderNestedLists(e) {
|
|
516
|
+
const t = e.split(`
|
|
517
|
+
`), o = [];
|
|
518
|
+
let i = 0;
|
|
519
|
+
for (; i < t.length; )
|
|
520
|
+
if (this.isListItem(t[i])) {
|
|
521
|
+
const s = [];
|
|
522
|
+
for (; i < t.length && this.isListItem(t[i]); )
|
|
523
|
+
s.push(t[i]), i++;
|
|
524
|
+
o.push(this.buildNestedList(s));
|
|
525
|
+
} else
|
|
526
|
+
o.push(t[i]), i++;
|
|
527
|
+
return o.join(`
|
|
528
|
+
`);
|
|
529
|
+
}
|
|
490
530
|
escapeHtml(e) {
|
|
491
531
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
492
532
|
}
|
|
@@ -511,13 +551,13 @@ class _ {
|
|
|
511
551
|
if (!m) continue;
|
|
512
552
|
const h = d.index + 1;
|
|
513
553
|
if (c.startsWith("</")) {
|
|
514
|
-
let
|
|
554
|
+
let x = !1;
|
|
515
555
|
for (let b = i.length - 1; b >= 0; b--)
|
|
516
556
|
if (i[b].tag === m) {
|
|
517
|
-
i.splice(b, 1),
|
|
557
|
+
i.splice(b, 1), x = !0;
|
|
518
558
|
break;
|
|
519
559
|
}
|
|
520
|
-
|
|
560
|
+
x || t.push(`Unexpected closing tag '</${m}>' at line ${n + 1}:${h} — no matching opening tag found.`);
|
|
521
561
|
} else
|
|
522
562
|
i.push({ tag: m, line: n + 1, col: h });
|
|
523
563
|
}
|
|
@@ -581,8 +621,8 @@ class q {
|
|
|
581
621
|
const c = n.closest(".smdx-tabs");
|
|
582
622
|
if (c) {
|
|
583
623
|
const m = parseInt(n.dataset.tabIndex ?? "0", 10);
|
|
584
|
-
c.querySelectorAll(".smdx-tab-btn").forEach((h) => h.classList.remove("smdx-active")), n.classList.add("smdx-active"), c.querySelectorAll(".smdx-tab-panel").forEach((h,
|
|
585
|
-
h.style.display =
|
|
624
|
+
c.querySelectorAll(".smdx-tab-btn").forEach((h) => h.classList.remove("smdx-active")), n.classList.add("smdx-active"), c.querySelectorAll(".smdx-tab-panel").forEach((h, u) => {
|
|
625
|
+
h.style.display = u === m ? "block" : "none";
|
|
586
626
|
});
|
|
587
627
|
}
|
|
588
628
|
return;
|
|
@@ -1561,9 +1601,13 @@ ${t}
|
|
|
1561
1601
|
let i = [], s;
|
|
1562
1602
|
for (; (s = o.exec(e[2])) !== null; )
|
|
1563
1603
|
i.push(M(s[1]));
|
|
1564
|
-
let n = `<div class="smdx-columns" style="grid-template-columns:repeat(${t},1fr)"
|
|
1604
|
+
let n = `<div class="smdx-columns" style="grid-template-columns:repeat(${t},1fr)">
|
|
1605
|
+
`;
|
|
1565
1606
|
for (const a of i)
|
|
1566
|
-
n += `<div class="smdx-column"
|
|
1607
|
+
n += `<div class="smdx-column">
|
|
1608
|
+
${a}
|
|
1609
|
+
</div>
|
|
1610
|
+
`;
|
|
1567
1611
|
return n += "</div>", n;
|
|
1568
1612
|
},
|
|
1569
1613
|
priority: 13
|
|
@@ -2448,8 +2492,8 @@ function Te() {
|
|
|
2448
2492
|
if (m)
|
|
2449
2493
|
a.innerHTML = `<span class="smdx-snippet-icon">⚠️</span> <span class="smdx-snippet-error">${g(m)}</span>`, a.classList.add("smdx-snippet-failed");
|
|
2450
2494
|
else {
|
|
2451
|
-
const h = l ? t(c, l) : c,
|
|
2452
|
-
a.innerHTML = `<div class="smdx-snippet-header"><span class="smdx-snippet-icon">📋</span> <code>${g(d)}</code>${
|
|
2495
|
+
const h = l ? t(c, l) : c, u = d.split(".").pop() || "text", x = l ? ` <span class="smdx-snippet-lines">(lines ${g(l)})</span>` : "";
|
|
2496
|
+
a.innerHTML = `<div class="smdx-snippet-header"><span class="smdx-snippet-icon">📋</span> <code>${g(d)}</code>${x}</div><pre class="smdx-snippet-code"><code class="language-${g(u)}">${g(h)}</code></pre>`, a.classList.add("smdx-snippet-loaded");
|
|
2453
2497
|
}
|
|
2454
2498
|
}
|
|
2455
2499
|
}
|
|
@@ -2618,10 +2662,10 @@ function I(r) {
|
|
|
2618
2662
|
const o = r.getValue(), i = [], s = o.split(`
|
|
2619
2663
|
`);
|
|
2620
2664
|
for (const h of s) {
|
|
2621
|
-
const
|
|
2622
|
-
if (
|
|
2623
|
-
const
|
|
2624
|
-
i.push({ level:
|
|
2665
|
+
const u = h.match(/^(#{1,4})\s+(.+)$/);
|
|
2666
|
+
if (u) {
|
|
2667
|
+
const x = u[2].replace(/[*_`~]/g, ""), b = x.toLowerCase().replace(/[^\w]+/g, "-").replace(/^-|-$/g, "");
|
|
2668
|
+
i.push({ level: u[1].length, text: x, slug: b });
|
|
2625
2669
|
}
|
|
2626
2670
|
}
|
|
2627
2671
|
if (i.length === 0) return;
|
|
@@ -2633,10 +2677,10 @@ function I(r) {
|
|
|
2633
2677
|
d.className = "smdx-toc-list";
|
|
2634
2678
|
const l = r.getPreview(), c = e.querySelector(".smdx-textarea");
|
|
2635
2679
|
i.forEach((h) => {
|
|
2636
|
-
const
|
|
2637
|
-
|
|
2638
|
-
const
|
|
2639
|
-
|
|
2680
|
+
const u = document.createElement("li");
|
|
2681
|
+
u.className = "smdx-toc-item";
|
|
2682
|
+
const x = document.createElement("a");
|
|
2683
|
+
x.className = `smdx-toc-link smdx-toc-h${h.level}`, x.textContent = h.text, x.title = h.text, x.addEventListener("click", (b) => {
|
|
2640
2684
|
b.preventDefault();
|
|
2641
2685
|
const v = l.querySelector(`#${CSS.escape(h.slug)}`);
|
|
2642
2686
|
if (v && v.scrollIntoView({ behavior: "smooth", block: "start" }), c) {
|
|
@@ -2654,7 +2698,7 @@ function I(r) {
|
|
|
2654
2698
|
k += f[y].length + 1;
|
|
2655
2699
|
}
|
|
2656
2700
|
}
|
|
2657
|
-
}),
|
|
2701
|
+
}), u.appendChild(x), d.appendChild(u);
|
|
2658
2702
|
}), n.appendChild(d), t.appendChild(n);
|
|
2659
2703
|
}
|
|
2660
2704
|
function Ie() {
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
(function(m,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("highlight.js")):typeof define=="function"&&define.amd?define(["exports","highlight.js"],v):(m=typeof globalThis<"u"?globalThis:m||self,v(m.SynclineMDXEditor={},m.hljs))})(this,function(m,v){"use strict";class S{constructor(){this.listeners=new Map}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){var o;(o=this.listeners.get(e))==null||o.delete(t)}emit(e,t){var o;(o=this.listeners.get(e))==null||o.forEach(i=>{try{i(t)}catch(s){console.error(`[SynclineMDX] Error in event handler for "${e}":`,s)}})}removeAllListeners(e){e?this.listeners.delete(e):this.listeners.clear()}}class T{constructor(e,t){this.editorApi=e,this.plugins=new Map,this.toolbarItems=new Map,this.shortcuts=[],this.renderers=[],this.parsers=[],this.styleElements=[],this.events=t}async register(e){if(this.plugins.has(e.name)){console.warn(`[SynclineMDX] Plugin "${e.name}" is already registered.`);return}if(e.dependencies){for(const t of e.dependencies)if(!this.plugins.has(t))throw new Error(`[SynclineMDX] Plugin "${e.name}" requires "${t}" which is not registered.`)}if(this.plugins.set(e.name,e),e.toolbarItems)for(const t of e.toolbarItems)this.toolbarItems.set(t.id,t);e.shortcuts&&this.shortcuts.push(...e.shortcuts),e.renderers&&(this.renderers.push(...e.renderers),this.renderers.sort((t,o)=>(o.priority??0)-(t.priority??0))),e.parsers&&(this.parsers.push(...e.parsers),this.parsers.sort((t,o)=>(o.priority??0)-(t.priority??0))),e.styles&&this.injectStyles(e.styles),e.init&&await e.init(this.createContext()),this.events.emit("plugin-registered",e.name)}unregister(e){const t=this.plugins.get(e);if(t){if(t.destroy&&t.destroy(this.createContext()),t.toolbarItems)for(const o of t.toolbarItems)this.toolbarItems.delete(o.id);if(t.shortcuts&&(this.shortcuts=this.shortcuts.filter(o=>!t.shortcuts.some(i=>i.key===o.key))),t.renderers){const o=new Set(t.renderers.map(i=>i.name));this.renderers=this.renderers.filter(i=>!o.has(i.name))}if(t.parsers){const o=new Set(t.parsers.map(i=>i.name));this.parsers=this.parsers.filter(i=>!o.has(i.name))}this.plugins.delete(e),this.events.emit("plugin-removed",e)}}getToolbarItem(e){return this.toolbarItems.get(e)}getAllToolbarItems(){return this.toolbarItems}getShortcuts(){return this.shortcuts}getRenderers(){return this.renderers}getParsers(){return this.parsers}hasPlugin(e){return this.plugins.has(e)}createContext(){return{editor:this.editorApi,registerToolbarItem:e=>this.toolbarItems.set(e.id,e),registerShortcut:e=>this.shortcuts.push(e),registerRenderer:e=>{this.renderers.push(e),this.renderers.sort((t,o)=>(o.priority??0)-(t.priority??0))},registerParser:e=>{this.parsers.push(e),this.parsers.sort((t,o)=>(o.priority??0)-(t.priority??0))},injectStyles:e=>this.injectStyles(e),emit:(e,t)=>this.events.emit(e,t),on:(e,t)=>this.events.on(e,t),off:(e,t)=>this.events.off(e,t)}}injectStyles(e){const t=document.createElement("style");t.setAttribute("data-syncline-mdx","plugin"),t.textContent=e,document.head.appendChild(t),this.styleElements.push(t)}destroy(){for(const[e]of this.plugins)this.unregister(e);for(const e of this.styleElements)e.remove();this.styleElements=[]}}class E{constructor(e,t,o,i){this.config=e,this.pluginManager=t,this.editorApi=o,this.events=i,this.activeDropdown=null,this.documentClickHandler=s=>{this.activeDropdown&&!this.activeDropdown.contains(s.target)&&this.closeDropdowns()}}render(e){this.el=document.createElement("div"),this.el.className="smdx-toolbar";for(const t of this.config){const o=document.createElement("div");o.className="smdx-toolbar-row",this.renderRow(t,o),this.el.appendChild(o)}return e.appendChild(this.el),document.addEventListener("click",this.documentClickHandler),this.el}renderRow(e,t){for(const o of e)typeof o=="string"?o==="|"?this.renderDivider(t):this.renderItem(o,t):"type"in o&&o.type==="divider"?this.renderDivider(t):"type"in o&&o.type==="group"&&this.renderGroup(o,t)}renderDivider(e){const t=document.createElement("span");t.className="smdx-toolbar-divider",e.appendChild(t)}renderItem(e,t){const o=this.pluginManager.getToolbarItem(e);if(o)if(o.children&&o.children.length>0)this.renderDropdownItem(o,t);else{const i=this.createButton(o);t.appendChild(i)}}renderGroup(e,t){if(e.display==="dropdown")this.renderDropdownGroup(e,t);else{const o=document.createElement("div");o.className="smdx-toolbar-group";for(const i of e.items)typeof i=="string"?this.renderItem(i,o):this.renderGroup(i,o);t.appendChild(o)}}renderDropdownGroup(e,t){const o=document.createElement("div");o.className="smdx-toolbar-dropdown";const i=document.createElement("button");i.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",i.type="button",i.innerHTML=`${e.icon||""}<span class="smdx-toolbar-btn-label">${e.label||""}</span><svg class="smdx-dropdown-arrow" width="10" height="6" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" stroke="currentColor" fill="none" stroke-width="1.5"/></svg>`,i.title=e.label||"",i.setAttribute("aria-label",e.label||"Dropdown"),i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-expanded","false");const s=document.createElement("div");s.className="smdx-toolbar-dropdown-menu",s.setAttribute("role","menu"),s.style.display="none";for(const n of e.items)if(typeof n=="string"){const a=this.pluginManager.getToolbarItem(n);if(!a)continue;if(a.children&&a.children.length>0)this.renderSubmenu(a,s);else{const d=this.createMenuButton(a);s.appendChild(d)}}else{const a=document.createElement("div");if(a.className="smdx-toolbar-dropdown-section",n.label){const d=document.createElement("div");d.className="smdx-toolbar-dropdown-section-label",d.textContent=n.label,a.appendChild(d)}for(const d of n.items)if(typeof d=="string"){const l=this.pluginManager.getToolbarItem(d);if(l)if(l.children&&l.children.length>0)this.renderSubmenu(l,a);else{const c=this.createMenuButton(l);a.appendChild(c)}}s.appendChild(a)}i.addEventListener("click",n=>{n.stopPropagation(),this.toggleDropdown(s,o)}),o.appendChild(i),o.appendChild(s),t.appendChild(o)}renderDropdownItem(e,t){const o=document.createElement("div");o.className="smdx-toolbar-dropdown";const i=document.createElement("button");i.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",i.type="button",i.innerHTML=`${e.icon||""}<span class="smdx-toolbar-btn-label">${e.label}</span><svg class="smdx-dropdown-arrow" width="10" height="6" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" stroke="currentColor" fill="none" stroke-width="1.5"/></svg>`,i.title=e.tooltip||e.label,i.setAttribute("aria-label",e.tooltip||e.label),i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-expanded","false");const s=document.createElement("div");s.className="smdx-toolbar-dropdown-menu",s.setAttribute("role","menu"),s.style.display="none";for(const n of e.children)if(n.children&&n.children.length>0)this.renderSubmenu(n,s);else{const a=this.createMenuButton(n);s.appendChild(a)}i.addEventListener("click",n=>{n.stopPropagation(),this.toggleDropdown(s,o)}),o.appendChild(i),o.appendChild(s),t.appendChild(o)}renderSubmenu(e,t){const o=document.createElement("div");o.className="smdx-toolbar-submenu";const i=document.createElement("button");i.className="smdx-toolbar-menu-btn smdx-toolbar-submenu-trigger",i.type="button",i.innerHTML=`${e.icon||""}<span>${e.label}</span><svg class="smdx-submenu-arrow" width="6" height="10" viewBox="0 0 6 10"><path d="M1 1l4 4-4 4" stroke="currentColor" fill="none" stroke-width="1.5"/></svg>`;const s=document.createElement("div");s.className="smdx-toolbar-dropdown-menu smdx-toolbar-submenu-menu",s.style.display="none";for(const c of e.children)if(c.children&&c.children.length>0)this.renderSubmenu(c,s);else{const h=this.createMenuButton(c);s.appendChild(h)}const n=()=>{const c=o.getBoundingClientRect();s.style.left=`${c.right}px`,s.style.top=`${c.top}px`,requestAnimationFrame(()=>{const h=s.getBoundingClientRect();h.right>window.innerWidth&&(s.style.left=`${c.left-h.width}px`),h.bottom>window.innerHeight&&(s.style.top=`${window.innerHeight-h.height-8}px`)})};let a=null;const d=()=>{a&&(clearTimeout(a),a=null),s.style.display="",n()},l=()=>{a&&clearTimeout(a),a=setTimeout(()=>{s.style.display="none",a=null},120)};i.addEventListener("mouseenter",d),s.addEventListener("mouseenter",d),o.addEventListener("mouseleave",l),s.addEventListener("mouseleave",l),o.appendChild(i),o.appendChild(s),t.appendChild(o)}createButton(e){const t=document.createElement("button");return t.className=`smdx-toolbar-btn${e.className?" "+e.className:""}`,t.type="button",t.tabIndex=0,t.title=e.tooltip||e.label,t.setAttribute("aria-label",e.tooltip||e.label),t.dataset.toolbarId=e.id,e.icon?t.innerHTML=e.icon:t.textContent=e.label,e.shortcutLabel&&(t.title+=` (${e.shortcutLabel})`),t.addEventListener("click",o=>{o.preventDefault(),this.executeAction(e)}),e.render&&e.render(t,this.getActionContext()),t}createMenuButton(e){const t=document.createElement("button");return t.className=`smdx-toolbar-menu-btn${e.className?" "+e.className:""}`,t.type="button",t.setAttribute("role","menuitem"),t.dataset.toolbarId=e.id,t.innerHTML=`${e.icon||""}<span>${e.label}</span>${e.shortcutLabel?`<span class="smdx-shortcut-label">${e.shortcutLabel}</span>`:""}`,t.addEventListener("click",o=>{o.preventDefault(),this.closeDropdowns(),this.executeAction(e)}),t}executeAction(e){var o;const t=this.getActionContext();(o=e.isDisabled)!=null&&o.call(e,t)||(e.action(t),this.events.emit("toolbar-action",e.id))}getActionContext(){return{editor:this.editorApi,selection:this.editorApi.getSelection()}}toggleDropdown(e,t){if(e.style.display==="none"){this.closeDropdowns(),e.style.display="",this.activeDropdown=t;const o=t.querySelector(".smdx-toolbar-dropdown-trigger");o==null||o.setAttribute("aria-expanded","true")}else{e.style.display="none";const o=t.querySelector(".smdx-toolbar-dropdown-trigger");o==null||o.setAttribute("aria-expanded","false"),this.activeDropdown=null}}closeDropdowns(){var e,t;(e=this.el)==null||e.querySelectorAll(".smdx-toolbar-dropdown-menu").forEach(o=>{o.style.display="none"}),(t=this.el)==null||t.querySelectorAll('[aria-expanded="true"]').forEach(o=>{o.setAttribute("aria-expanded","false")}),this.activeDropdown=null}updateActiveStates(){var t;const e=this.getActionContext();(t=this.el)==null||t.querySelectorAll("[data-toolbar-id]").forEach(o=>{const i=o.dataset.toolbarId,s=this.pluginManager.getToolbarItem(i);s!=null&&s.isActive&&o.classList.toggle("smdx-active",s.isActive(e)),s!=null&&s.isDisabled&&(o.disabled=s.isDisabled(e))})}destroy(){var e;document.removeEventListener("click",this.documentClickHandler),(e=this.el)==null||e.remove()}}const Ce=new Set(["script","style","object","embed","base","form","input","link","meta","noscript","applet","frame","frameset"]),$e=["https://www.youtube.com/embed/","https://youtube.com/embed/","https://codepen.io/","https://codesandbox.io/embed/"];function Se(r){return $e.some(e=>r.startsWith(e))}const L=/^on/i,Te=/^\s*javascript\s*:/i;function Ee(r){if(typeof document>"u")return r;const t=new DOMParser().parseFromString(`<!DOCTYPE html><body>${r}</body>`,"text/html"),o=document.createTreeWalker(t.body,NodeFilter.SHOW_ELEMENT),i=[];let s=o.currentNode;for(;s;){if(s.nodeType===Node.ELEMENT_NODE){const n=s,a=n.tagName.toLowerCase();if(Ce.has(a))i.push(n);else if(a==="iframe"){const d=n.getAttribute("src")||"";if(!Se(d))i.push(n);else{const l=[];for(const c of Array.from(n.attributes))L.test(c.name)&&l.push(c.name);for(const c of l)n.removeAttribute(c)}}else{const d=[];for(const l of Array.from(n.attributes))(L.test(l.name)||(l.name==="href"||l.name==="src"||l.name==="action")&&Te.test(l.value))&&d.push(l.name);for(const l of d)n.removeAttribute(l)}}s=o.nextNode()}for(const n of i)n.remove();return t.body.innerHTML}class M{constructor(){this.renderers=[],this.parsers=[]}setRenderers(e){this.renderers=e}setParsers(e){this.parsers=e}async render(e){let t=e;const o=this.validateMdxTags(e),i=[];t=t.replace(/`([^`\n]+)`/g,(s,n)=>{const a=i.length;return i.push(n),`%%INLINECODE_${a}%%`}),t=this.applyParsers(t),t=this.applyRenderers(t);for(let s=0;s<i.length;s++)t=t.replace(`%%INLINECODE_${s}%%`,`\`${i[s]}\``);return t=this.renderMarkdown(t),o.length>0&&(t=o.map(n=>`<div class="smdx-parse-error"><span class="smdx-parse-error-icon">⚠</span> ${this.escapeHtml(n)}</div>`).join("")+t),Ee(t)}applyParsers(e){let t=e;for(const o of this.parsers)t=t.replace(o.pattern,(...i)=>{const s=i;return o.transform(s)});return t}applyRenderers(e){let t=e;for(const o of this.renderers)t=t.replace(o.pattern,(i,...s)=>{const n={};return s.length>0&&(n.content=s[0]||""),o.render(i,n)});return t}renderMarkdown(e){let t=e;const o=[];t=t.replace(/```(\w*)(?:[\t ]+([\w.\/ \-]+?))?\n([\s\S]*?)```/g,(s,n,a,d)=>{const l=o.length,c={js:"JavaScript",javascript:"JavaScript",ts:"TypeScript",typescript:"TypeScript",py:"Python",python:"Python",java:"Java",rb:"Ruby",ruby:"Ruby",go:"Go",rust:"Rust",rs:"Rust",cpp:"C++",c:"C",cs:"C#",csharp:"C#",php:"PHP",swift:"Swift",kt:"Kotlin",kotlin:"Kotlin",scala:"Scala",sh:"Shell",bash:"Bash",zsh:"Zsh",sql:"SQL",html:"HTML",css:"CSS",scss:"SCSS",less:"LESS",json:"JSON",yaml:"YAML",yml:"YAML",xml:"XML",md:"Markdown",markdown:"Markdown",graphql:"GraphQL",dart:"Dart",r:"R",lua:"Lua",perl:"Perl",text:"Text",txt:"Text"};let h;const u=d.trimEnd();try{n&&v.getLanguage(n)?h=v.highlight(u,{language:n}).value:h=v.highlightAuto(u).value}catch{h=this.escapeHtml(u)}const x=n?c[n.toLowerCase()]||n.charAt(0).toUpperCase()+n.slice(1):"",g=x?`<span class="smdx-code-lang">${x}</span>`:"",b=a?`<span class="smdx-code-filename"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>${this.escapeHtml(a)}</span>`:"",y='<button class="smdx-copy-btn" data-copy-btn="true" title="Copy code" aria-label="Copy code"><svg class="smdx-copy-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg><svg class="smdx-check-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg></button>',k=x||a,w=k?`<div class="smdx-code-header">${g}${b}${y}</div>`:"";return o.push(`<div class="smdx-code-block${k?" smdx-has-header":""}">${w}<pre><code class="hljs language-${n||"text"}">${h}</code></pre>${k?"":y}</div>`),`%%CODEBLOCK_${l}%%`}),t=t.replace(/`([^`]+)`/g,(s,n)=>`<code class="smdx-inline-code">${this.escapeHtml(n)}</code>`);const i=s=>s.toLowerCase().replace(/[^\w]+/g,"-").replace(/^-|-$/g,"");t=t.replace(/^######\s+(.+)$/gm,(s,n)=>`<h6 id="${i(n)}">${n}</h6>`),t=t.replace(/^#####\s+(.+)$/gm,(s,n)=>`<h5 id="${i(n)}">${n}</h5>`),t=t.replace(/^####\s+(.+)$/gm,(s,n)=>`<h4 id="${i(n)}">${n}</h4>`),t=t.replace(/^###\s+(.+)$/gm,(s,n)=>`<h3 id="${i(n)}">${n}</h3>`),t=t.replace(/^##\s+(.+)$/gm,(s,n)=>`<h2 id="${i(n)}">${n}</h2>`),t=t.replace(/^#\s+(.+)$/gm,(s,n)=>`<h1 id="${i(n)}">${n}</h1>`),t=t.replace(/^---$/gm,"<hr/>"),t=t.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>"),t=t.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/~~(.+?)~~/g,"<del>$1</del>"),t=t.replace(/^>\s+(.+)$/gm,"<blockquote>$1</blockquote>"),t=t.replace(/^- \[x\]\s+(.+)$/gm,'<div class="smdx-task"><input type="checkbox" checked disabled /><span>$1</span></div>'),t=t.replace(/^- \[ \]\s+(.+)$/gm,'<div class="smdx-task"><input type="checkbox" disabled /><span>$1</span></div>'),t=t.replace(/^[-*]\s+(.+)$/gm,'<li class="smdx-ul-item">$1</li>'),t=t.replace(/((?:<li class="smdx-ul-item">.*<\/li>\n?)+)/g,"<ul>$1</ul>"),t=t.replace(/^\d+\.\s+(.+)$/gm,'<li class="smdx-ol-item">$1</li>'),t=t.replace(/((?:<li class="smdx-ol-item">.*<\/li>\n?)+)/g,"<ol>$1</ol>"),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" class="smdx-image"/>'),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),t=this.renderTables(t),t=t.replace(/ {2,}$/gm,"<br/>"),t=t.replace(/^(?!\s*<[a-zA-Z/!]|\s*%%)(.*\S.*)$/gm,"<p>$1</p>"),t=t.replace(/<p>\s*<\/p>/g,"");for(let s=0;s<o.length;s++)t=t.replace(`%%CODEBLOCK_${s}%%`,o[s]);return t}renderTables(e){const t=/(?:^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)*))/gm;return e.replace(t,(o,i,s,n)=>{const a=this.parseTableRow(i),d=n.trim().split(`
|
|
2
|
-
`).filter(Boolean).map(c=>this.parseTableRow(c));let l='<div class="smdx-table-wrapper"><table class="smdx-table"><thead><tr>';for(const c of a)l+=`<th>${c}</th>`;l+="</tr></thead><tbody>";for(const c of d){l+="<tr>";for(const
|
|
3
|
-
`)
|
|
4
|
-
|
|
1
|
+
(function(m,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("highlight.js")):typeof define=="function"&&define.amd?define(["exports","highlight.js"],v):(m=typeof globalThis<"u"?globalThis:m||self,v(m.SynclineMDXEditor={},m.hljs))})(this,function(m,v){"use strict";class S{constructor(){this.listeners=new Map}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){var i;(i=this.listeners.get(e))==null||i.delete(t)}emit(e,t){var i;(i=this.listeners.get(e))==null||i.forEach(o=>{try{o(t)}catch(s){console.error(`[SynclineMDX] Error in event handler for "${e}":`,s)}})}removeAllListeners(e){e?this.listeners.delete(e):this.listeners.clear()}}class T{constructor(e,t){this.editorApi=e,this.plugins=new Map,this.toolbarItems=new Map,this.shortcuts=[],this.renderers=[],this.parsers=[],this.styleElements=[],this.events=t}async register(e){if(this.plugins.has(e.name)){console.warn(`[SynclineMDX] Plugin "${e.name}" is already registered.`);return}if(e.dependencies){for(const t of e.dependencies)if(!this.plugins.has(t))throw new Error(`[SynclineMDX] Plugin "${e.name}" requires "${t}" which is not registered.`)}if(this.plugins.set(e.name,e),e.toolbarItems)for(const t of e.toolbarItems)this.toolbarItems.set(t.id,t);e.shortcuts&&this.shortcuts.push(...e.shortcuts),e.renderers&&(this.renderers.push(...e.renderers),this.renderers.sort((t,i)=>(i.priority??0)-(t.priority??0))),e.parsers&&(this.parsers.push(...e.parsers),this.parsers.sort((t,i)=>(i.priority??0)-(t.priority??0))),e.styles&&this.injectStyles(e.styles),e.init&&await e.init(this.createContext()),this.events.emit("plugin-registered",e.name)}unregister(e){const t=this.plugins.get(e);if(t){if(t.destroy&&t.destroy(this.createContext()),t.toolbarItems)for(const i of t.toolbarItems)this.toolbarItems.delete(i.id);if(t.shortcuts&&(this.shortcuts=this.shortcuts.filter(i=>!t.shortcuts.some(o=>o.key===i.key))),t.renderers){const i=new Set(t.renderers.map(o=>o.name));this.renderers=this.renderers.filter(o=>!i.has(o.name))}if(t.parsers){const i=new Set(t.parsers.map(o=>o.name));this.parsers=this.parsers.filter(o=>!i.has(o.name))}this.plugins.delete(e),this.events.emit("plugin-removed",e)}}getToolbarItem(e){return this.toolbarItems.get(e)}getAllToolbarItems(){return this.toolbarItems}getShortcuts(){return this.shortcuts}getRenderers(){return this.renderers}getParsers(){return this.parsers}hasPlugin(e){return this.plugins.has(e)}createContext(){return{editor:this.editorApi,registerToolbarItem:e=>this.toolbarItems.set(e.id,e),registerShortcut:e=>this.shortcuts.push(e),registerRenderer:e=>{this.renderers.push(e),this.renderers.sort((t,i)=>(i.priority??0)-(t.priority??0))},registerParser:e=>{this.parsers.push(e),this.parsers.sort((t,i)=>(i.priority??0)-(t.priority??0))},injectStyles:e=>this.injectStyles(e),emit:(e,t)=>this.events.emit(e,t),on:(e,t)=>this.events.on(e,t),off:(e,t)=>this.events.off(e,t)}}injectStyles(e){const t=document.createElement("style");t.setAttribute("data-syncline-mdx","plugin"),t.textContent=e,document.head.appendChild(t),this.styleElements.push(t)}destroy(){for(const[e]of this.plugins)this.unregister(e);for(const e of this.styleElements)e.remove();this.styleElements=[]}}class E{constructor(e,t,i,o){this.config=e,this.pluginManager=t,this.editorApi=i,this.events=o,this.activeDropdown=null,this.documentClickHandler=s=>{this.activeDropdown&&!this.activeDropdown.contains(s.target)&&this.closeDropdowns()}}render(e){this.el=document.createElement("div"),this.el.className="smdx-toolbar";for(const t of this.config){const i=document.createElement("div");i.className="smdx-toolbar-row",this.renderRow(t,i),this.el.appendChild(i)}return e.appendChild(this.el),document.addEventListener("click",this.documentClickHandler),this.el}renderRow(e,t){for(const i of e)typeof i=="string"?i==="|"?this.renderDivider(t):this.renderItem(i,t):"type"in i&&i.type==="divider"?this.renderDivider(t):"type"in i&&i.type==="group"&&this.renderGroup(i,t)}renderDivider(e){const t=document.createElement("span");t.className="smdx-toolbar-divider",e.appendChild(t)}renderItem(e,t){const i=this.pluginManager.getToolbarItem(e);if(i)if(i.children&&i.children.length>0)this.renderDropdownItem(i,t);else{const o=this.createButton(i);t.appendChild(o)}}renderGroup(e,t){if(e.display==="dropdown")this.renderDropdownGroup(e,t);else{const i=document.createElement("div");i.className="smdx-toolbar-group";for(const o of e.items)typeof o=="string"?this.renderItem(o,i):this.renderGroup(o,i);t.appendChild(i)}}renderDropdownGroup(e,t){const i=document.createElement("div");i.className="smdx-toolbar-dropdown";const o=document.createElement("button");o.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",o.type="button",o.innerHTML=`${e.icon||""}<span class="smdx-toolbar-btn-label">${e.label||""}</span><svg class="smdx-dropdown-arrow" width="10" height="6" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" stroke="currentColor" fill="none" stroke-width="1.5"/></svg>`,o.title=e.label||"",o.setAttribute("aria-label",e.label||"Dropdown"),o.setAttribute("aria-haspopup","true"),o.setAttribute("aria-expanded","false");const s=document.createElement("div");s.className="smdx-toolbar-dropdown-menu",s.setAttribute("role","menu"),s.style.display="none";for(const n of e.items)if(typeof n=="string"){const a=this.pluginManager.getToolbarItem(n);if(!a)continue;if(a.children&&a.children.length>0)this.renderSubmenu(a,s);else{const d=this.createMenuButton(a);s.appendChild(d)}}else{const a=document.createElement("div");if(a.className="smdx-toolbar-dropdown-section",n.label){const d=document.createElement("div");d.className="smdx-toolbar-dropdown-section-label",d.textContent=n.label,a.appendChild(d)}for(const d of n.items)if(typeof d=="string"){const l=this.pluginManager.getToolbarItem(d);if(l)if(l.children&&l.children.length>0)this.renderSubmenu(l,a);else{const c=this.createMenuButton(l);a.appendChild(c)}}s.appendChild(a)}o.addEventListener("click",n=>{n.stopPropagation(),this.toggleDropdown(s,i)}),i.appendChild(o),i.appendChild(s),t.appendChild(i)}renderDropdownItem(e,t){const i=document.createElement("div");i.className="smdx-toolbar-dropdown";const o=document.createElement("button");o.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",o.type="button",o.innerHTML=`${e.icon||""}<span class="smdx-toolbar-btn-label">${e.label}</span><svg class="smdx-dropdown-arrow" width="10" height="6" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" stroke="currentColor" fill="none" stroke-width="1.5"/></svg>`,o.title=e.tooltip||e.label,o.setAttribute("aria-label",e.tooltip||e.label),o.setAttribute("aria-haspopup","true"),o.setAttribute("aria-expanded","false");const s=document.createElement("div");s.className="smdx-toolbar-dropdown-menu",s.setAttribute("role","menu"),s.style.display="none";for(const n of e.children)if(n.children&&n.children.length>0)this.renderSubmenu(n,s);else{const a=this.createMenuButton(n);s.appendChild(a)}o.addEventListener("click",n=>{n.stopPropagation(),this.toggleDropdown(s,i)}),i.appendChild(o),i.appendChild(s),t.appendChild(i)}renderSubmenu(e,t){const i=document.createElement("div");i.className="smdx-toolbar-submenu";const o=document.createElement("button");o.className="smdx-toolbar-menu-btn smdx-toolbar-submenu-trigger",o.type="button",o.innerHTML=`${e.icon||""}<span>${e.label}</span><svg class="smdx-submenu-arrow" width="6" height="10" viewBox="0 0 6 10"><path d="M1 1l4 4-4 4" stroke="currentColor" fill="none" stroke-width="1.5"/></svg>`;const s=document.createElement("div");s.className="smdx-toolbar-dropdown-menu smdx-toolbar-submenu-menu",s.style.display="none";for(const c of e.children)if(c.children&&c.children.length>0)this.renderSubmenu(c,s);else{const p=this.createMenuButton(c);s.appendChild(p)}const n=()=>{const c=i.getBoundingClientRect();s.style.left=`${c.right}px`,s.style.top=`${c.top}px`,requestAnimationFrame(()=>{const p=s.getBoundingClientRect();p.right>window.innerWidth&&(s.style.left=`${c.left-p.width}px`),p.bottom>window.innerHeight&&(s.style.top=`${window.innerHeight-p.height-8}px`)})};let a=null;const d=()=>{a&&(clearTimeout(a),a=null),s.style.display="",n()},l=()=>{a&&clearTimeout(a),a=setTimeout(()=>{s.style.display="none",a=null},120)};o.addEventListener("mouseenter",d),s.addEventListener("mouseenter",d),i.addEventListener("mouseleave",l),s.addEventListener("mouseleave",l),i.appendChild(o),i.appendChild(s),t.appendChild(i)}createButton(e){const t=document.createElement("button");return t.className=`smdx-toolbar-btn${e.className?" "+e.className:""}`,t.type="button",t.tabIndex=0,t.title=e.tooltip||e.label,t.setAttribute("aria-label",e.tooltip||e.label),t.dataset.toolbarId=e.id,e.icon?t.innerHTML=e.icon:t.textContent=e.label,e.shortcutLabel&&(t.title+=` (${e.shortcutLabel})`),t.addEventListener("click",i=>{i.preventDefault(),this.executeAction(e)}),e.render&&e.render(t,this.getActionContext()),t}createMenuButton(e){const t=document.createElement("button");return t.className=`smdx-toolbar-menu-btn${e.className?" "+e.className:""}`,t.type="button",t.setAttribute("role","menuitem"),t.dataset.toolbarId=e.id,t.innerHTML=`${e.icon||""}<span>${e.label}</span>${e.shortcutLabel?`<span class="smdx-shortcut-label">${e.shortcutLabel}</span>`:""}`,t.addEventListener("click",i=>{i.preventDefault(),this.closeDropdowns(),this.executeAction(e)}),t}executeAction(e){var i;const t=this.getActionContext();(i=e.isDisabled)!=null&&i.call(e,t)||(e.action(t),this.events.emit("toolbar-action",e.id))}getActionContext(){return{editor:this.editorApi,selection:this.editorApi.getSelection()}}toggleDropdown(e,t){if(e.style.display==="none"){this.closeDropdowns(),e.style.display="",this.activeDropdown=t;const i=t.querySelector(".smdx-toolbar-dropdown-trigger");i==null||i.setAttribute("aria-expanded","true")}else{e.style.display="none";const i=t.querySelector(".smdx-toolbar-dropdown-trigger");i==null||i.setAttribute("aria-expanded","false"),this.activeDropdown=null}}closeDropdowns(){var e,t;(e=this.el)==null||e.querySelectorAll(".smdx-toolbar-dropdown-menu").forEach(i=>{i.style.display="none"}),(t=this.el)==null||t.querySelectorAll('[aria-expanded="true"]').forEach(i=>{i.setAttribute("aria-expanded","false")}),this.activeDropdown=null}updateActiveStates(){var t;const e=this.getActionContext();(t=this.el)==null||t.querySelectorAll("[data-toolbar-id]").forEach(i=>{const o=i.dataset.toolbarId,s=this.pluginManager.getToolbarItem(o);s!=null&&s.isActive&&i.classList.toggle("smdx-active",s.isActive(e)),s!=null&&s.isDisabled&&(i.disabled=s.isDisabled(e))})}destroy(){var e;document.removeEventListener("click",this.documentClickHandler),(e=this.el)==null||e.remove()}}const Ce=new Set(["script","style","object","embed","base","form","input","link","meta","noscript","applet","frame","frameset"]),$e=["https://www.youtube.com/embed/","https://youtube.com/embed/","https://codepen.io/","https://codesandbox.io/embed/"];function Se(r){return $e.some(e=>r.startsWith(e))}const L=/^on/i,Te=/^\s*javascript\s*:/i;function Ee(r){if(typeof document>"u")return r;const t=new DOMParser().parseFromString(`<!DOCTYPE html><body>${r}</body>`,"text/html"),i=document.createTreeWalker(t.body,NodeFilter.SHOW_ELEMENT),o=[];let s=i.currentNode;for(;s;){if(s.nodeType===Node.ELEMENT_NODE){const n=s,a=n.tagName.toLowerCase();if(Ce.has(a))o.push(n);else if(a==="iframe"){const d=n.getAttribute("src")||"";if(!Se(d))o.push(n);else{const l=[];for(const c of Array.from(n.attributes))L.test(c.name)&&l.push(c.name);for(const c of l)n.removeAttribute(c)}}else{const d=[];for(const l of Array.from(n.attributes))(L.test(l.name)||(l.name==="href"||l.name==="src"||l.name==="action")&&Te.test(l.value))&&d.push(l.name);for(const l of d)n.removeAttribute(l)}}s=i.nextNode()}for(const n of o)n.remove();return t.body.innerHTML}class I{constructor(){this.renderers=[],this.parsers=[]}setRenderers(e){this.renderers=e}setParsers(e){this.parsers=e}async render(e){let t=e;const i=this.validateMdxTags(e),o=[];t=t.replace(/`([^`\n]+)`/g,(s,n)=>{const a=o.length;return o.push(n),`%%INLINECODE_${a}%%`}),t=this.applyParsers(t),t=this.applyRenderers(t);for(let s=0;s<o.length;s++)t=t.replace(`%%INLINECODE_${s}%%`,`\`${o[s]}\``);return t=this.renderMarkdown(t),i.length>0&&(t=i.map(n=>`<div class="smdx-parse-error"><span class="smdx-parse-error-icon">⚠</span> ${this.escapeHtml(n)}</div>`).join("")+t),Ee(t)}applyParsers(e){let t=e;for(const i of this.parsers)t=t.replace(i.pattern,(...o)=>{const s=o;return i.transform(s)});return t}applyRenderers(e){let t=e;for(const i of this.renderers)t=t.replace(i.pattern,(o,...s)=>{const n={};return s.length>0&&(n.content=s[0]||""),i.render(o,n)});return t}renderMarkdown(e){let t=e;const i=[];t=t.replace(/```(\w*)(?:[\t ]+([\w.\/ \-]+?))?\n([\s\S]*?)```/g,(s,n,a,d)=>{const l=i.length,c={js:"JavaScript",javascript:"JavaScript",ts:"TypeScript",typescript:"TypeScript",py:"Python",python:"Python",java:"Java",rb:"Ruby",ruby:"Ruby",go:"Go",rust:"Rust",rs:"Rust",cpp:"C++",c:"C",cs:"C#",csharp:"C#",php:"PHP",swift:"Swift",kt:"Kotlin",kotlin:"Kotlin",scala:"Scala",sh:"Shell",bash:"Bash",zsh:"Zsh",sql:"SQL",html:"HTML",css:"CSS",scss:"SCSS",less:"LESS",json:"JSON",yaml:"YAML",yml:"YAML",xml:"XML",md:"Markdown",markdown:"Markdown",graphql:"GraphQL",dart:"Dart",r:"R",lua:"Lua",perl:"Perl",text:"Text",txt:"Text"};let p;const u=d.trimEnd();try{n&&v.getLanguage(n)?p=v.highlight(u,{language:n}).value:p=v.highlightAuto(u).value}catch{p=this.escapeHtml(u)}const g=n?c[n.toLowerCase()]||n.charAt(0).toUpperCase()+n.slice(1):"",x=g?`<span class="smdx-code-lang">${g}</span>`:"",f=a?`<span class="smdx-code-filename"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>${this.escapeHtml(a)}</span>`:"",y='<button class="smdx-copy-btn" data-copy-btn="true" title="Copy code" aria-label="Copy code"><svg class="smdx-copy-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg><svg class="smdx-check-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg></button>',k=g||a,w=k?`<div class="smdx-code-header">${x}${f}${y}</div>`:"";return i.push(`<div class="smdx-code-block${k?" smdx-has-header":""}">${w}<pre><code class="hljs language-${n||"text"}">${p}</code></pre>${k?"":y}</div>`),`%%CODEBLOCK_${l}%%`}),t=t.replace(/`([^`]+)`/g,(s,n)=>`<code class="smdx-inline-code">${this.escapeHtml(n)}</code>`);const o=s=>s.toLowerCase().replace(/[^\w]+/g,"-").replace(/^-|-$/g,"");t=t.replace(/^######\s+(.+)$/gm,(s,n)=>`<h6 id="${o(n)}">${n}</h6>`),t=t.replace(/^#####\s+(.+)$/gm,(s,n)=>`<h5 id="${o(n)}">${n}</h5>`),t=t.replace(/^####\s+(.+)$/gm,(s,n)=>`<h4 id="${o(n)}">${n}</h4>`),t=t.replace(/^###\s+(.+)$/gm,(s,n)=>`<h3 id="${o(n)}">${n}</h3>`),t=t.replace(/^##\s+(.+)$/gm,(s,n)=>`<h2 id="${o(n)}">${n}</h2>`),t=t.replace(/^#\s+(.+)$/gm,(s,n)=>`<h1 id="${o(n)}">${n}</h1>`),t=t.replace(/^---$/gm,"<hr/>"),t=t.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>"),t=t.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/~~(.+?)~~/g,"<del>$1</del>"),t=t.replace(/^>\s+(.+)$/gm,"<blockquote>$1</blockquote>"),t=t.replace(/^- \[x\]\s+(.+)$/gm,'<div class="smdx-task"><input type="checkbox" checked disabled /><span>$1</span></div>'),t=t.replace(/^- \[ \]\s+(.+)$/gm,'<div class="smdx-task"><input type="checkbox" disabled /><span>$1</span></div>'),t=this.renderNestedLists(t),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" class="smdx-image"/>'),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),t=this.renderTables(t),t=t.replace(/ {2,}$/gm,"<br/>"),t=t.replace(/^(?!\s*<[a-zA-Z/!]|\s*%%)(.*\S.*)$/gm,"<p>$1</p>"),t=t.replace(/<p>\s*<\/p>/g,"");for(let s=0;s<i.length;s++)t=t.replace(`%%CODEBLOCK_${s}%%`,i[s]);return t}renderTables(e){const t=/(?:^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)*))/gm;return e.replace(t,(i,o,s,n)=>{const a=this.parseTableRow(o),d=n.trim().split(`
|
|
2
|
+
`).filter(Boolean).map(c=>this.parseTableRow(c));let l='<div class="smdx-table-wrapper"><table class="smdx-table"><thead><tr>';for(const c of a)l+=`<th>${c}</th>`;l+="</tr></thead><tbody>";for(const c of d){l+="<tr>";for(const p of c)l+=`<td>${p}</td>`;l+="</tr>"}return l+="</tbody></table></div>",l})}parseTableRow(e){return e.split("|").slice(1,-1).map(t=>t.trim())}isListItem(e){return/^\s*[-*]\s+/.test(e)||/^\s*\d+\.\s+/.test(e)}buildNestedList(e){var d,l,c;if(e.length===0)return"";const t=((d=e[0].match(/^(\s*)/))==null?void 0:d[1].length)??0,i=/^\s*\d+\.\s+/.test(e[0]),o=i?"ol":"ul",s=i?"smdx-ol-item":"smdx-ul-item";let n=`<${o}>`,a=0;for(;a<e.length;){const p=e[a],u=((l=p.match(/^(\s*)/))==null?void 0:l[1].length)??0;if(u<t)break;if(u>t){a++;continue}const g=i?p.replace(/^\s*\d+\.\s+/,""):p.replace(/^\s*[-*]\s+/,"");a++;const x=[];for(;a<e.length&&((((c=e[a].match(/^(\s*)/))==null?void 0:c[1].length)??0)>t&&this.isListItem(e[a]));)x.push(e[a]),a++;const f=x.length>0?this.buildNestedList(x):"";n+=`<li class="${s}">${g}${f}</li>`}return n+=`</${o}>`,n}renderNestedLists(e){const t=e.split(`
|
|
3
|
+
`),i=[];let o=0;for(;o<t.length;)if(this.isListItem(t[o])){const s=[];for(;o<t.length&&this.isListItem(t[o]);)s.push(t[o]),o++;i.push(this.buildNestedList(s))}else i.push(t[o]),o++;return i.join(`
|
|
4
|
+
`)}escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}validateMdxTags(e){const t=[];let i=e.replace(/```[\s\S]*?```/g,"");i=i.replace(/`[^`]+`/g,"");const o=[],s=i.split(`
|
|
5
|
+
`);for(let n=0;n<s.length;n++){const a=s[n];let d;const l=/<\/?([A-Z][A-Za-z0-9]*)(?:\s[^>]*)?\/?>|<([A-Z][A-Za-z0-9]*)(?:\s[^>]*)?>/g;for(;(d=l.exec(a))!==null;){const c=d[0];if(c.endsWith("/>"))continue;const p=d[1]||d[2];if(!p)continue;const u=d.index+1;if(c.startsWith("</")){let x=!1;for(let f=o.length-1;f>=0;f--)if(o[f].tag===p){o.splice(f,1),x=!0;break}x||t.push(`Unexpected closing tag '</${p}>' at line ${n+1}:${u} — no matching opening tag found.`)}else o.push({tag:p,line:n+1,col:u})}}for(const n of o)t.push(`Expected a closing tag for '<${n.tag}>' (${n.line}:${n.col}) before the end of the document.`);return t}}class M{constructor(e=100){this.stack=[],this.pointer=-1,this.maxSize=e}push(e){this.pointer<this.stack.length-1&&(this.stack=this.stack.slice(0,this.pointer+1)),this.stack[this.stack.length-1]!==e&&(this.stack.push(e),this.stack.length>this.maxSize&&this.stack.shift(),this.pointer=this.stack.length-1)}undo(){if(this.pointer>0)return this.pointer--,this.stack[this.pointer]}redo(){if(this.pointer<this.stack.length-1)return this.pointer++,this.stack[this.pointer]}current(){return this.stack[this.pointer]}clear(){this.stack=[],this.pointer=-1}}class B{constructor(e){this.events=new S,this.renderer=new I,this.history=new M,this.renderTimer=null,this.historyTimer=null,this._destroyed=!1,this.config=e,this.mode=e.mode||"split",this.init()}init(){const e=typeof this.config.container=="string"?document.querySelector(this.config.container):this.config.container;if(!e)throw new Error("[SynclineMDX] Container element not found");this.buildDOM(e),this.config.theme&&this.applyTheme(this.config.theme),this.pluginManager=new T(this,this.events);const t=this.config.toolbar||[this.getDefaultToolbar()];this.toolbar=new E(t,this.pluginManager,this,this.events),this.config.value&&(this.textarea.value=this.config.value),this.config.plugins?this.registerPlugins(this.config.plugins).then(()=>{this.toolbar.render(this.toolbarEl),this.history.push(this.textarea.value),this.renderPreview()}):(this.toolbar.render(this.toolbarEl),this.history.push(this.textarea.value),this.renderPreview()),this.textarea.addEventListener("input",this.onInput.bind(this)),this.textarea.addEventListener("keydown",this.onKeyDown.bind(this)),this.textarea.addEventListener("click",this.onSelectionChange.bind(this)),this.textarea.addEventListener("select",this.onSelectionChange.bind(this)),this.textarea.addEventListener("focus",()=>this.events.emit("focus")),this.textarea.addEventListener("blur",()=>this.events.emit("blur")),this.config.scrollSync!==!1&&this.textarea.addEventListener("scroll",()=>{requestAnimationFrame(()=>{const i=this.textarea.scrollHeight-this.textarea.clientHeight,o=i>0?this.textarea.scrollTop/i:0,s=this.previewContent.scrollHeight-this.previewContent.clientHeight;this.previewContent.scrollTop=o*s})}),this.config.readOnly&&(this.textarea.readOnly=!0),this.config.placeholder&&(this.textarea.placeholder=this.config.placeholder),this.setMode(this.mode),this.config.onChange&&this.on("change",i=>{typeof i=="string"&&this.config.onChange(i)})}buildDOM(e){this.root=document.createElement("div"),this.root.className="smdx-editor",this.root.setAttribute("role","application"),this.root.setAttribute("aria-label","Markdown Editor");const t=document.createElement("a");t.className="smdx-skip-link",t.href="#smdx-editor-content",t.textContent="Skip to editor",this.root.appendChild(t),this.toolbarEl=document.createElement("div"),this.toolbarEl.className="smdx-toolbar-container",this.toolbarEl.setAttribute("role","toolbar"),this.toolbarEl.setAttribute("aria-label","Formatting toolbar");const i=document.createElement("div");i.className="smdx-main",this.editorPane=document.createElement("div"),this.editorPane.className="smdx-editor-pane",this.editorPane.id="smdx-editor-content",this.textarea=document.createElement("textarea"),this.textarea.className="smdx-textarea",this.textarea.spellcheck=!0,this.textarea.setAttribute("autocomplete","off"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("role","textbox"),this.textarea.setAttribute("aria-label","Markdown editor"),this.textarea.setAttribute("aria-multiline","true"),this.editorPane.appendChild(this.textarea),this.previewPane=document.createElement("div"),this.previewPane.className="smdx-preview-pane",this.previewContent=document.createElement("div"),this.previewContent.className="smdx-preview-content",this.previewContent.setAttribute("role","region"),this.previewContent.setAttribute("aria-label","Preview"),this.previewContent.setAttribute("aria-live","polite"),this.previewContent.addEventListener("click",o=>{const s=o.target,n=s.closest("[data-smdx-tab-btn]");if(n){const c=n.closest(".smdx-tabs");if(c){const p=parseInt(n.dataset.tabIndex??"0",10);c.querySelectorAll(".smdx-tab-btn").forEach(u=>u.classList.remove("smdx-active")),n.classList.add("smdx-active"),c.querySelectorAll(".smdx-tab-panel").forEach((u,g)=>{u.style.display=g===p?"block":"none"})}return}const a=s.closest("[data-copy-btn]");if(!a)return;const d=a.closest(".smdx-code-block"),l=d==null?void 0:d.querySelector("code");l&&navigator.clipboard.writeText(l.textContent||"").then(()=>{a.classList.add("smdx-copied"),setTimeout(()=>a.classList.remove("smdx-copied"),2e3)}).catch(()=>{})}),this.previewPane.appendChild(this.previewContent),i.appendChild(this.editorPane),i.appendChild(this.previewPane),this.statusBar=document.createElement("div"),this.statusBar.className="smdx-status-bar",this.statusBar.setAttribute("role","status"),this.statusBar.setAttribute("aria-label","Editor status"),this.updateStatusBar(),this.root.appendChild(this.toolbarEl),this.root.appendChild(i),this.root.appendChild(this.statusBar),e.appendChild(this.root)}async registerPlugins(e){for(const t of e)await this.pluginManager.register(t)}getDefaultToolbar(){return["heading","|","bold","italic","strikethrough","|","quote","link","image","|","code","codeBlock","|","unorderedList","orderedList","taskList","|","table","|","highlight","admonition","|","accordion","steps","tab","|","card","multiColumn","|","tip","container","|","emoji","formula","|","embedVideo","embedOthers","|","mermaid","|","copyText","tooltip"]}onInput(){this.historyTimer&&clearTimeout(this.historyTimer),this.historyTimer=setTimeout(()=>{this.history.push(this.textarea.value)},300),this.scheduleRender(),this.updateStatusBar(),this.events.emit("change",this.textarea.value)}onKeyDown(e){if(e.key==="Tab"){e.preventDefault();const o=this.textarea.selectionStart,s=this.textarea.selectionEnd,n=this.textarea.value;if(e.shiftKey){const a=n.lastIndexOf(`
|
|
6
|
+
`,o-1)+1;n.substring(a,a+2)===" "&&(this.textarea.value=n.substring(0,a)+n.substring(a+2),this.textarea.selectionStart=Math.max(o-2,a),this.textarea.selectionEnd=Math.max(s-2,a))}else this.textarea.value=n.substring(0,o)+" "+n.substring(s),this.textarea.selectionStart=this.textarea.selectionEnd=o+2;this.onInput();return}if(e.metaKey||e.ctrlKey){if(e.key==="z"&&!e.shiftKey){e.preventDefault(),this.undo();return}if(e.key==="z"&&e.shiftKey||e.key==="y"){e.preventDefault(),this.redo();return}}const i=this.pluginManager.getShortcuts();for(const o of i)if(this.matchShortcut(e,o.key)){e.preventDefault(),o.action({editor:this,selection:this.getSelection()});return}}matchShortcut(e,t){const i=t.toLowerCase().split("+"),o=i.includes("cmd")||i.includes("meta"),s=i.includes("ctrl"),n=i.includes("shift"),a=i.includes("alt"),d=o||s,l=i.filter(p=>!["cmd","meta","ctrl","shift","alt"].includes(p))[0];return(o?e.metaKey:!e.metaKey||d)&&(s?e.ctrlKey:!e.ctrlKey||d)&&(n?e.shiftKey:!e.shiftKey)&&(a?e.altKey:!e.altKey)&&(d?e.metaKey||e.ctrlKey:!e.metaKey&&!e.ctrlKey)&&e.key.toLowerCase()===l}onSelectionChange(){this.toolbar.updateActiveStates(),this.events.emit("selection-change",this.getSelection())}scheduleRender(){this.renderTimer&&clearTimeout(this.renderTimer),this.renderTimer=setTimeout(()=>this.renderPreview(),150)}updateStatusBar(){const e=this.getWordCount(),t=this.getLineCount();this.statusBar.innerHTML=`<span>Words: ${e}</span><span>Lines: ${t}</span>`;const i=document.createElement("div");i.className="smdx-mode-switch",["editor","split","preview"].forEach(o=>{const s=document.createElement("button");s.type="button",s.className=`smdx-mode-btn${o===this.mode?" smdx-active":""}`,s.textContent=o.charAt(0).toUpperCase()+o.slice(1),s.setAttribute("aria-label",`${o.charAt(0).toUpperCase()+o.slice(1)} mode`),s.setAttribute("aria-pressed",String(o===this.mode)),s.addEventListener("click",()=>this.setMode(o)),i.appendChild(s)}),this.statusBar.appendChild(i)}getValue(){return this.textarea.value}setValue(e){this.textarea.value=e,this.history.push(e),this.scheduleRender(),this.events.emit("change",e)}insertText(e){const t=this.textarea.selectionStart,i=this.textarea.selectionEnd,o=this.textarea.value;this.textarea.value=o.substring(0,t)+e+o.substring(i),this.textarea.selectionStart=this.textarea.selectionEnd=t+e.length,this.textarea.focus(),this.onInput()}wrapSelection(e,t){const{start:i,end:o,text:s}=this.getSelection(),n=this.textarea.value,a=e+(s||"text")+t;this.textarea.value=n.substring(0,i)+a+n.substring(o),this.textarea.selectionStart=i+e.length,this.textarea.selectionEnd=i+e.length+(s||"text").length,this.textarea.focus(),this.onInput()}replaceSelection(e){const{start:t,end:i}=this.getSelection(),o=this.textarea.value;this.textarea.value=o.substring(0,t)+e+o.substring(i),this.textarea.selectionStart=this.textarea.selectionEnd=t+e.length,this.textarea.focus(),this.onInput()}getSelection(){const e=this.textarea.selectionStart,t=this.textarea.selectionEnd,i=this.textarea.value;return{start:e,end:t,text:i.substring(e,t),beforeText:i.substring(0,e),afterText:i.substring(t)}}setSelection(e,t){this.textarea.selectionStart=e,this.textarea.selectionEnd=t,this.textarea.focus()}insertBlock(e){const{start:t,end:i}=this.getSelection(),o=this.textarea.value,s=o.substring(0,t),n=o.substring(i),a=s.length>0&&!s.endsWith(`
|
|
5
7
|
`),d=n.length>0&&!n.startsWith(`
|
|
6
8
|
`),l=(a?`
|
|
7
9
|
|
|
8
10
|
`:"")+e+(d?`
|
|
9
11
|
|
|
10
|
-
`:"");this.textarea.value=s+l+n,this.textarea.selectionStart=this.textarea.selectionEnd=s.length+l.length,this.textarea.focus(),this.onInput()}getTextarea(){return this.textarea}getPreview(){return this.previewContent}getRoot(){return this.root}focus(){this.textarea.focus()}async renderPreview(){this.renderer.setRenderers(this.pluginManager.getRenderers()),this.renderer.setParsers(this.pluginManager.getParsers());const e=await this.renderer.render(this.textarea.value);this.previewContent.innerHTML=e,this.events.emit("render",e)}getMode(){return this.mode}setMode(e){this.mode=e,this.root.classList.remove("smdx-mode-split","smdx-mode-editor","smdx-mode-preview"),this.root.classList.add(`smdx-mode-${e}`),this.updateStatusBar(),this.events.emit("mode-change",e)}registerPlugin(e){this.pluginManager.register(e).then(()=>{this.toolbarEl.innerHTML="",this.toolbar.render(this.toolbarEl),this.renderPreview()})}unregisterPlugin(e){this.pluginManager.unregister(e),this.toolbarEl.innerHTML="",this.toolbar.render(this.toolbarEl),this.renderPreview()}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}emit(e,t){this.events.emit(e,t)}destroy(){this._destroyed||(this._destroyed=!0,this.pluginManager.destroy(),this.toolbar.destroy(),this.events.removeAllListeners(),this.renderTimer&&clearTimeout(this.renderTimer),this.historyTimer&&clearTimeout(this.historyTimer),this.root.remove())}undo(){const e=this.history.undo();e!==void 0&&(this.textarea.value=e,this.scheduleRender(),this.events.emit("change",e))}redo(){const e=this.history.redo();e!==void 0&&(this.textarea.value=e,this.scheduleRender(),this.events.emit("change",e))}getCurrentLine(){const e=this.textarea.value,t=this.textarea.selectionStart,
|
|
11
|
-
`,t-1)+1,
|
|
12
|
-
`,t);return e.substring(o
|
|
13
|
-
`).length}replaceCurrentLine(e){const t=this.textarea.value,
|
|
14
|
-
`,
|
|
15
|
-
`,
|
|
16
|
-
`).length}applyTheme(e){for(const[t,o]of Object.entries(e))this.root.style.setProperty(t.startsWith("--")?t:`--smdx-${t}`,o)}}const p={heading:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 12h16M4 6v12M20 6v12"/></svg>',h1:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H1</text></svg>',h2:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H2</text></svg>',h3:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H3</text></svg>',h4:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H4</text></svg>',h5:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H5</text></svg>',h6:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H6</text></svg>',bold:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 4h8a4 4 0 014 4 4 4 0 01-4 4H6zM6 12h9a4 4 0 014 4 4 4 0 01-4 4H6z"/></svg>',italic:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/></svg>',strikethrough:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M16 4H9a3 3 0 00-3 3v0a3 3 0 003 3h6a3 3 0 013 3v0a3 3 0 01-3 3H8"/><line x1="4" y1="12" x2="20" y2="12"/></svg>',quote:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3z"/></svg>',link:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71"/></svg>',image:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',code:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',codeBlock:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="3" width="20" height="18" rx="2"/><polyline points="10 8 6 12 10 16"/><polyline points="14 8 18 12 14 16"/></svg>',unorderedList:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><circle cx="4" cy="6" r="1" fill="currentColor"/><circle cx="4" cy="12" r="1" fill="currentColor"/><circle cx="4" cy="18" r="1" fill="currentColor"/></svg>',orderedList:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><text x="2" y="9" font-size="8" fill="currentColor" stroke="none">1</text><text x="2" y="15" font-size="8" fill="currentColor" stroke="none">2</text><text x="2" y="21" font-size="8" fill="currentColor" stroke="none">3</text></svg>',taskList:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="5" width="6" height="6" rx="1"/><path d="M5 8l1 1 2-2"/><line x1="13" y1="8" x2="21" y2="8"/><rect x="3" y="13" width="6" height="6" rx="1"/><line x1="13" y1="16" x2="21" y2="16"/></svg>',table:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>',highlight:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 013 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>',admonition:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>',tab:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="6" width="20" height="14" rx="2"/><path d="M2 10h20"/><path d="M5 6V4a2 2 0 012-2h4a2 2 0 012 2v2"/></svg>',imageBackground:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="20" rx="2"/><rect x="5" y="5" width="14" height="14" rx="1" stroke-dasharray="4,2"/><circle cx="12" cy="12" r="3"/></svg>',imageFrame:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="20" rx="2"/><rect x="5" y="5" width="14" height="14" rx="1"/></svg>',accordion:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="6" rx="1"/><path d="M15 6l-3 3-3-3"/><rect x="3" y="13" width="18" height="6" rx="1"/></svg>',accordionGroup:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="2" width="18" height="5" rx="1"/><rect x="3" y="9" width="18" height="5" rx="1"/><rect x="3" y="16" width="18" height="5" rx="1"/></svg>',multiColumn:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="18" rx="1"/><rect x="14" y="3" width="7" height="18" rx="1"/></svg>',card:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="3"/><line x1="7" y1="10" x2="17" y2="10"/><line x1="7" y1="14" x2="13" y2="14"/></svg>',cardGroup:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="3" width="8" height="8" rx="2"/><rect x="14" y="3" width="8" height="8" rx="2"/><rect x="2" y="13" width="8" height="8" rx="2"/><rect x="14" y="13" width="8" height="8" rx="2"/></svg>',step:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="5" r="3"/><circle cx="12" cy="12" r="3"/><circle cx="12" cy="19" r="3"/><line x1="12" y1="8" x2="12" y2="9"/><line x1="12" y1="15" x2="12" y2="16"/></svg>',tip:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18h6M10 22h4M12 2a7 7 0 017 7c0 2.38-1.19 4.47-3 5.74V17H8v-2.26C6.19 13.47 5 11.38 5 9a7 7 0 017-7z"/></svg>',container:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" stroke-dasharray="4,2"/></svg>',copyText:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>',tooltip:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="12" rx="2"/><path d="M9 15l3 4 3-4"/></svg>',embedVideo:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="4" width="20" height="16" rx="2"/><polygon points="10,8 16,12 10,16"/></svg>',embedOthers:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><ellipse cx="12" cy="12" rx="4" ry="10"/></svg>',mermaid:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="8" height="6" rx="1"/><rect x="14" y="16" width="8" height="6" rx="1"/><rect x="14" y="2" width="8" height="6" rx="1"/><path d="M10 5h4M6 8v8l12-4"/></svg>',emoji:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>',formula:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="3" y="17" font-size="14" fill="currentColor" stroke="none" font-style="italic">∑x</text></svg>',insert:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg>',scrollSync:'<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 12h16M12 4v16"/></svg>'};function P(){return{name:"heading",toolbarItems:[{id:"heading",label:"Heading",icon:p.heading,tooltip:"Heading",children:[1,2,3,4,5,6].map(r=>({id:`h${r}`,label:`Heading ${r}`,icon:p[`h${r}`],tooltip:`Heading ${r}`,action:({editor:e})=>{const t="#".repeat(r)+" ",i=e.getCurrentLine().replace(/^#{1,6}\s*/,"");e.replaceCurrentLine(t+i)}})),action:({editor:r})=>{const e=r.getCurrentLine(),t=e.match(/^(#{1,6})\s/);if(t){const o=Math.min(t[1].length+1,6),i=e.replace(/^#{1,6}\s*/,"");r.replaceCurrentLine("#".repeat(o)+" "+i)}else r.replaceCurrentLine("# "+e)}}],shortcuts:[{key:"Ctrl+1",action:({editor:r})=>r.replaceCurrentLine("# "+r.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 1"},{key:"Ctrl+2",action:({editor:r})=>r.replaceCurrentLine("## "+r.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 2"},{key:"Ctrl+3",action:({editor:r})=>r.replaceCurrentLine("### "+r.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 3"}]}}function A(){return{name:"bold",toolbarItems:[{id:"bold",label:"Bold",icon:p.bold,tooltip:"Bold",shortcutLabel:"⌘B",action:({editor:r})=>r.wrapSelection("**","**"),isActive:({selection:r})=>{const{beforeText:e,afterText:t,text:o}=r;return e.endsWith("**")&&t.startsWith("**")||/^\*\*.+\*\*$/.test(o)}}],shortcuts:[{key:"Ctrl+b",action:({editor:r})=>r.wrapSelection("**","**"),description:"Bold"}]}}function D(){return{name:"italic",toolbarItems:[{id:"italic",label:"Italic",icon:p.italic,tooltip:"Italic",shortcutLabel:"⌘I",action:({editor:r})=>r.wrapSelection("*","*"),isActive:({selection:r})=>{const{beforeText:e,afterText:t,text:o}=r;return e.endsWith("*")&&!e.endsWith("**")&&t.startsWith("*")&&!t.startsWith("**")||/^\*[^*]+\*$/.test(o)}}],shortcuts:[{key:"Ctrl+i",action:({editor:r})=>r.wrapSelection("*","*"),description:"Italic"}]}}function H(){return{name:"strikethrough",toolbarItems:[{id:"strikethrough",label:"Strikethrough",icon:p.strikethrough,tooltip:"Strikethrough",shortcutLabel:"⌘⇧X",action:({editor:r})=>r.wrapSelection("~~","~~")}],shortcuts:[{key:"Ctrl+Shift+x",action:({editor:r})=>r.wrapSelection("~~","~~"),description:"Strikethrough"}]}}function z(){return{name:"quote",toolbarItems:[{id:"quote",label:"Quote",icon:p.quote,tooltip:"Blockquote",shortcutLabel:"⌘⇧.",action:({editor:r})=>{const e=r.getCurrentLine();e.startsWith("> ")?r.replaceCurrentLine(e.substring(2)):r.replaceCurrentLine("> "+e)}}],shortcuts:[{key:"Ctrl+Shift+.",action:({editor:r})=>{const e=r.getCurrentLine();r.replaceCurrentLine(e.startsWith("> ")?e.substring(2):"> "+e)},description:"Blockquote"}]}}function R(){return{name:"link",toolbarItems:[{id:"link",label:"Link",icon:p.link,tooltip:"Insert Link",shortcutLabel:"⌘K",action:({editor:r,selection:e})=>{e.text?r.replaceSelection(`[${e.text}](url)`):r.insertText("[link text](url)")}}],shortcuts:[{key:"Ctrl+k",action:({editor:r,selection:e})=>{e.text?r.replaceSelection(`[${e.text}](url)`):r.insertText("[link text](url)")},description:"Insert Link"}]}}function N(){return{name:"image",toolbarItems:[{id:"image",label:"Image",icon:p.image,tooltip:"Insert Image",action:({editor:r,selection:e})=>{const t=e.text||"alt text";r.replaceSelection(``)}}]}}function O(){return{name:"code",toolbarItems:[{id:"code",label:"Inline Code",icon:p.code,tooltip:"Inline Code",shortcutLabel:"⌘E",action:({editor:r})=>r.wrapSelection("`","`")},{id:"codeBlock",label:"Code Block",icon:p.codeBlock,tooltip:"Code Block",shortcutLabel:"⌘⇧C",action:({editor:r,selection:e})=>{r.insertBlock("```language\n"+(e.text||"code here")+"\n```")}}],shortcuts:[{key:"Ctrl+e",action:({editor:r})=>r.wrapSelection("`","`"),description:"Inline Code"},{key:"Ctrl+Shift+c",action:({editor:r,selection:e})=>{r.insertBlock("```language\n"+(e.text||"code here")+"\n```")},description:"Code Block"}]}}function j(){return{name:"unorderedList",toolbarItems:[{id:"unorderedList",label:"Unordered List",icon:p.unorderedList,tooltip:"Bullet List",action:({editor:r})=>{const e=r.getCurrentLine();e.match(/^[-*]\s/)?r.replaceCurrentLine(e.replace(/^[-*]\s/,"")):r.replaceCurrentLine("- "+e)}}]}}function G(){return{name:"orderedList",toolbarItems:[{id:"orderedList",label:"Ordered List",icon:p.orderedList,tooltip:"Numbered List",action:({editor:r})=>{const e=r.getCurrentLine();e.match(/^\d+\.\s/)?r.replaceCurrentLine(e.replace(/^\d+\.\s/,"")):r.replaceCurrentLine("1. "+e)}}]}}function _(){return{name:"taskList",toolbarItems:[{id:"taskList",label:"Task List",icon:p.taskList,tooltip:"Task List",action:({editor:r})=>{const e=r.getCurrentLine();e.match(/^- \[[ x]\]\s/)?r.replaceCurrentLine(e.replace(/^- \[[ x]\]\s/,"")):r.replaceCurrentLine("- [ ] "+e)}}]}}function q(){return{name:"table",toolbarItems:[{id:"table",label:"Table",icon:p.table,tooltip:"Insert Table",action:({editor:r})=>{r.insertBlock(`| Header 1 | Header 2 | Header 3 |
|
|
12
|
+
`:"");this.textarea.value=s+l+n,this.textarea.selectionStart=this.textarea.selectionEnd=s.length+l.length,this.textarea.focus(),this.onInput()}getTextarea(){return this.textarea}getPreview(){return this.previewContent}getRoot(){return this.root}focus(){this.textarea.focus()}async renderPreview(){this.renderer.setRenderers(this.pluginManager.getRenderers()),this.renderer.setParsers(this.pluginManager.getParsers());const e=await this.renderer.render(this.textarea.value);this.previewContent.innerHTML=e,this.events.emit("render",e)}getMode(){return this.mode}setMode(e){this.mode=e,this.root.classList.remove("smdx-mode-split","smdx-mode-editor","smdx-mode-preview"),this.root.classList.add(`smdx-mode-${e}`),this.updateStatusBar(),this.events.emit("mode-change",e)}registerPlugin(e){this.pluginManager.register(e).then(()=>{this.toolbarEl.innerHTML="",this.toolbar.render(this.toolbarEl),this.renderPreview()})}unregisterPlugin(e){this.pluginManager.unregister(e),this.toolbarEl.innerHTML="",this.toolbar.render(this.toolbarEl),this.renderPreview()}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}emit(e,t){this.events.emit(e,t)}destroy(){this._destroyed||(this._destroyed=!0,this.pluginManager.destroy(),this.toolbar.destroy(),this.events.removeAllListeners(),this.renderTimer&&clearTimeout(this.renderTimer),this.historyTimer&&clearTimeout(this.historyTimer),this.root.remove())}undo(){const e=this.history.undo();e!==void 0&&(this.textarea.value=e,this.scheduleRender(),this.events.emit("change",e))}redo(){const e=this.history.redo();e!==void 0&&(this.textarea.value=e,this.scheduleRender(),this.events.emit("change",e))}getCurrentLine(){const e=this.textarea.value,t=this.textarea.selectionStart,i=e.lastIndexOf(`
|
|
13
|
+
`,t-1)+1,o=e.indexOf(`
|
|
14
|
+
`,t);return e.substring(i,o===-1?e.length:o)}getCurrentLineNumber(){const e=this.textarea.value,t=this.textarea.selectionStart;return e.substring(0,t).split(`
|
|
15
|
+
`).length}replaceCurrentLine(e){const t=this.textarea.value,i=this.textarea.selectionStart,o=t.lastIndexOf(`
|
|
16
|
+
`,i-1)+1;let s=t.indexOf(`
|
|
17
|
+
`,i);s===-1&&(s=t.length),this.textarea.value=t.substring(0,o)+e+t.substring(s),this.textarea.selectionStart=this.textarea.selectionEnd=o+e.length,this.onInput()}insertAt(e,t){const i=this.textarea.value;this.textarea.value=i.substring(0,e)+t+i.substring(e),this.textarea.selectionStart=this.textarea.selectionEnd=e+t.length,this.onInput()}getWordCount(){const e=this.textarea.value.trim();return e?e.split(/\s+/).length:0}getLineCount(){return this.textarea.value.split(`
|
|
18
|
+
`).length}applyTheme(e){for(const[t,i]of Object.entries(e))this.root.style.setProperty(t.startsWith("--")?t:`--smdx-${t}`,i)}}const h={heading:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 12h16M4 6v12M20 6v12"/></svg>',h1:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H1</text></svg>',h2:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H2</text></svg>',h3:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H3</text></svg>',h4:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H4</text></svg>',h5:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H5</text></svg>',h6:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H6</text></svg>',bold:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 4h8a4 4 0 014 4 4 4 0 01-4 4H6zM6 12h9a4 4 0 014 4 4 4 0 01-4 4H6z"/></svg>',italic:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/></svg>',strikethrough:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M16 4H9a3 3 0 00-3 3v0a3 3 0 003 3h6a3 3 0 013 3v0a3 3 0 01-3 3H8"/><line x1="4" y1="12" x2="20" y2="12"/></svg>',quote:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3z"/></svg>',link:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71"/></svg>',image:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',code:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',codeBlock:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="3" width="20" height="18" rx="2"/><polyline points="10 8 6 12 10 16"/><polyline points="14 8 18 12 14 16"/></svg>',unorderedList:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><circle cx="4" cy="6" r="1" fill="currentColor"/><circle cx="4" cy="12" r="1" fill="currentColor"/><circle cx="4" cy="18" r="1" fill="currentColor"/></svg>',orderedList:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><text x="2" y="9" font-size="8" fill="currentColor" stroke="none">1</text><text x="2" y="15" font-size="8" fill="currentColor" stroke="none">2</text><text x="2" y="21" font-size="8" fill="currentColor" stroke="none">3</text></svg>',taskList:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="5" width="6" height="6" rx="1"/><path d="M5 8l1 1 2-2"/><line x1="13" y1="8" x2="21" y2="8"/><rect x="3" y="13" width="6" height="6" rx="1"/><line x1="13" y1="16" x2="21" y2="16"/></svg>',table:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>',highlight:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 013 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>',admonition:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>',tab:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="6" width="20" height="14" rx="2"/><path d="M2 10h20"/><path d="M5 6V4a2 2 0 012-2h4a2 2 0 012 2v2"/></svg>',imageBackground:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="20" rx="2"/><rect x="5" y="5" width="14" height="14" rx="1" stroke-dasharray="4,2"/><circle cx="12" cy="12" r="3"/></svg>',imageFrame:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="20" rx="2"/><rect x="5" y="5" width="14" height="14" rx="1"/></svg>',accordion:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="6" rx="1"/><path d="M15 6l-3 3-3-3"/><rect x="3" y="13" width="18" height="6" rx="1"/></svg>',accordionGroup:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="2" width="18" height="5" rx="1"/><rect x="3" y="9" width="18" height="5" rx="1"/><rect x="3" y="16" width="18" height="5" rx="1"/></svg>',multiColumn:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="18" rx="1"/><rect x="14" y="3" width="7" height="18" rx="1"/></svg>',card:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="3"/><line x1="7" y1="10" x2="17" y2="10"/><line x1="7" y1="14" x2="13" y2="14"/></svg>',cardGroup:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="3" width="8" height="8" rx="2"/><rect x="14" y="3" width="8" height="8" rx="2"/><rect x="2" y="13" width="8" height="8" rx="2"/><rect x="14" y="13" width="8" height="8" rx="2"/></svg>',step:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="5" r="3"/><circle cx="12" cy="12" r="3"/><circle cx="12" cy="19" r="3"/><line x1="12" y1="8" x2="12" y2="9"/><line x1="12" y1="15" x2="12" y2="16"/></svg>',tip:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18h6M10 22h4M12 2a7 7 0 017 7c0 2.38-1.19 4.47-3 5.74V17H8v-2.26C6.19 13.47 5 11.38 5 9a7 7 0 017-7z"/></svg>',container:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" stroke-dasharray="4,2"/></svg>',copyText:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>',tooltip:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="12" rx="2"/><path d="M9 15l3 4 3-4"/></svg>',embedVideo:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="4" width="20" height="16" rx="2"/><polygon points="10,8 16,12 10,16"/></svg>',embedOthers:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><ellipse cx="12" cy="12" rx="4" ry="10"/></svg>',mermaid:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="8" height="6" rx="1"/><rect x="14" y="16" width="8" height="6" rx="1"/><rect x="14" y="2" width="8" height="6" rx="1"/><path d="M10 5h4M6 8v8l12-4"/></svg>',emoji:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>',formula:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="3" y="17" font-size="14" fill="currentColor" stroke="none" font-style="italic">∑x</text></svg>',insert:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg>',scrollSync:'<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 12h16M12 4v16"/></svg>'};function P(){return{name:"heading",toolbarItems:[{id:"heading",label:"Heading",icon:h.heading,tooltip:"Heading",children:[1,2,3,4,5,6].map(r=>({id:`h${r}`,label:`Heading ${r}`,icon:h[`h${r}`],tooltip:`Heading ${r}`,action:({editor:e})=>{const t="#".repeat(r)+" ",o=e.getCurrentLine().replace(/^#{1,6}\s*/,"");e.replaceCurrentLine(t+o)}})),action:({editor:r})=>{const e=r.getCurrentLine(),t=e.match(/^(#{1,6})\s/);if(t){const i=Math.min(t[1].length+1,6),o=e.replace(/^#{1,6}\s*/,"");r.replaceCurrentLine("#".repeat(i)+" "+o)}else r.replaceCurrentLine("# "+e)}}],shortcuts:[{key:"Ctrl+1",action:({editor:r})=>r.replaceCurrentLine("# "+r.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 1"},{key:"Ctrl+2",action:({editor:r})=>r.replaceCurrentLine("## "+r.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 2"},{key:"Ctrl+3",action:({editor:r})=>r.replaceCurrentLine("### "+r.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 3"}]}}function A(){return{name:"bold",toolbarItems:[{id:"bold",label:"Bold",icon:h.bold,tooltip:"Bold",shortcutLabel:"⌘B",action:({editor:r})=>r.wrapSelection("**","**"),isActive:({selection:r})=>{const{beforeText:e,afterText:t,text:i}=r;return e.endsWith("**")&&t.startsWith("**")||/^\*\*.+\*\*$/.test(i)}}],shortcuts:[{key:"Ctrl+b",action:({editor:r})=>r.wrapSelection("**","**"),description:"Bold"}]}}function H(){return{name:"italic",toolbarItems:[{id:"italic",label:"Italic",icon:h.italic,tooltip:"Italic",shortcutLabel:"⌘I",action:({editor:r})=>r.wrapSelection("*","*"),isActive:({selection:r})=>{const{beforeText:e,afterText:t,text:i}=r;return e.endsWith("*")&&!e.endsWith("**")&&t.startsWith("*")&&!t.startsWith("**")||/^\*[^*]+\*$/.test(i)}}],shortcuts:[{key:"Ctrl+i",action:({editor:r})=>r.wrapSelection("*","*"),description:"Italic"}]}}function D(){return{name:"strikethrough",toolbarItems:[{id:"strikethrough",label:"Strikethrough",icon:h.strikethrough,tooltip:"Strikethrough",shortcutLabel:"⌘⇧X",action:({editor:r})=>r.wrapSelection("~~","~~")}],shortcuts:[{key:"Ctrl+Shift+x",action:({editor:r})=>r.wrapSelection("~~","~~"),description:"Strikethrough"}]}}function z(){return{name:"quote",toolbarItems:[{id:"quote",label:"Quote",icon:h.quote,tooltip:"Blockquote",shortcutLabel:"⌘⇧.",action:({editor:r})=>{const e=r.getCurrentLine();e.startsWith("> ")?r.replaceCurrentLine(e.substring(2)):r.replaceCurrentLine("> "+e)}}],shortcuts:[{key:"Ctrl+Shift+.",action:({editor:r})=>{const e=r.getCurrentLine();r.replaceCurrentLine(e.startsWith("> ")?e.substring(2):"> "+e)},description:"Blockquote"}]}}function N(){return{name:"link",toolbarItems:[{id:"link",label:"Link",icon:h.link,tooltip:"Insert Link",shortcutLabel:"⌘K",action:({editor:r,selection:e})=>{e.text?r.replaceSelection(`[${e.text}](url)`):r.insertText("[link text](url)")}}],shortcuts:[{key:"Ctrl+k",action:({editor:r,selection:e})=>{e.text?r.replaceSelection(`[${e.text}](url)`):r.insertText("[link text](url)")},description:"Insert Link"}]}}function R(){return{name:"image",toolbarItems:[{id:"image",label:"Image",icon:h.image,tooltip:"Insert Image",action:({editor:r,selection:e})=>{const t=e.text||"alt text";r.replaceSelection(``)}}]}}function O(){return{name:"code",toolbarItems:[{id:"code",label:"Inline Code",icon:h.code,tooltip:"Inline Code",shortcutLabel:"⌘E",action:({editor:r})=>r.wrapSelection("`","`")},{id:"codeBlock",label:"Code Block",icon:h.codeBlock,tooltip:"Code Block",shortcutLabel:"⌘⇧C",action:({editor:r,selection:e})=>{r.insertBlock("```language\n"+(e.text||"code here")+"\n```")}}],shortcuts:[{key:"Ctrl+e",action:({editor:r})=>r.wrapSelection("`","`"),description:"Inline Code"},{key:"Ctrl+Shift+c",action:({editor:r,selection:e})=>{r.insertBlock("```language\n"+(e.text||"code here")+"\n```")},description:"Code Block"}]}}function j(){return{name:"unorderedList",toolbarItems:[{id:"unorderedList",label:"Unordered List",icon:h.unorderedList,tooltip:"Bullet List",action:({editor:r})=>{const e=r.getCurrentLine();e.match(/^[-*]\s/)?r.replaceCurrentLine(e.replace(/^[-*]\s/,"")):r.replaceCurrentLine("- "+e)}}]}}function G(){return{name:"orderedList",toolbarItems:[{id:"orderedList",label:"Ordered List",icon:h.orderedList,tooltip:"Numbered List",action:({editor:r})=>{const e=r.getCurrentLine();e.match(/^\d+\.\s/)?r.replaceCurrentLine(e.replace(/^\d+\.\s/,"")):r.replaceCurrentLine("1. "+e)}}]}}function _(){return{name:"taskList",toolbarItems:[{id:"taskList",label:"Task List",icon:h.taskList,tooltip:"Task List",action:({editor:r})=>{const e=r.getCurrentLine();e.match(/^- \[[ x]\]\s/)?r.replaceCurrentLine(e.replace(/^- \[[ x]\]\s/,"")):r.replaceCurrentLine("- [ ] "+e)}}]}}function q(){return{name:"table",toolbarItems:[{id:"table",label:"Table",icon:h.table,tooltip:"Insert Table",action:({editor:r})=>{r.insertBlock(`| Header 1 | Header 2 | Header 3 |
|
|
17
19
|
| -------- | -------- | -------- |
|
|
18
20
|
| Cell 1 | Cell 2 | Cell 3 |
|
|
19
|
-
| Cell 4 | Cell 5 | Cell 6 |`)}}]}}const Le=[{name:"Yellow",color:"#fef08a",darkColor:"#854d0e",class:"yellow"},{name:"Green",color:"#bbf7d0",darkColor:"#166534",class:"green"},{name:"Blue",color:"#bfdbfe",darkColor:"#1e3a5f",class:"blue"},{name:"Purple",color:"#ddd6fe",darkColor:"#4c1d95",class:"purple"},{name:"Pink",color:"#fbcfe8",darkColor:"#831843",class:"pink"},{name:"Red",color:"#fecaca",darkColor:"#991b1b",class:"red"},{name:"Orange",color:"#fed7aa",darkColor:"#9a3412",class:"orange"},{name:"Cyan",color:"#a5f3fc",darkColor:"#155e75",class:"cyan"}];function F(){return{name:"highlight",toolbarItems:[{id:"highlight",label:"Highlight",icon:
|
|
21
|
+
| Cell 4 | Cell 5 | Cell 6 |`)}}]}}const Le=[{name:"Yellow",color:"#fef08a",darkColor:"#854d0e",class:"yellow"},{name:"Green",color:"#bbf7d0",darkColor:"#166534",class:"green"},{name:"Blue",color:"#bfdbfe",darkColor:"#1e3a5f",class:"blue"},{name:"Purple",color:"#ddd6fe",darkColor:"#4c1d95",class:"purple"},{name:"Pink",color:"#fbcfe8",darkColor:"#831843",class:"pink"},{name:"Red",color:"#fecaca",darkColor:"#991b1b",class:"red"},{name:"Orange",color:"#fed7aa",darkColor:"#9a3412",class:"orange"},{name:"Cyan",color:"#a5f3fc",darkColor:"#155e75",class:"cyan"}];function F(){return{name:"highlight",toolbarItems:[{id:"highlight",label:"Highlight",icon:h.highlight,tooltip:"Highlight Text",children:Le.map(r=>({id:`highlight-${r.class}`,label:r.name,icon:`<span class="smdx-color-dot" style="background:${r.color}"></span>`,tooltip:`${r.name} Highlight`,action:({editor:e})=>{e.wrapSelection(`<Highlight color="${r.class}">`,"</Highlight>")}})),action:({editor:r})=>{r.wrapSelection('<Highlight color="yellow">',"</Highlight>")}}],renderers:[{name:"highlight",pattern:/<Highlight\s+color="([^"]+)">([\s\S]*?)<\/Highlight>/g,render:r=>{const e=r.match(/<Highlight\s+color="([^"]+)">([\s\S]*?)<\/Highlight>/);return e?`<mark class="smdx-highlight smdx-highlight-${e[1]}">${e[2]}</mark>`:r}}],styles:`
|
|
20
22
|
.smdx-highlight { padding: 2px 4px; border-radius: 3px; }
|
|
21
23
|
.smdx-highlight-yellow { background-color: #fef08a; }
|
|
22
24
|
.smdx-highlight-green { background-color: #bbf7d0; }
|
|
@@ -35,11 +37,11 @@
|
|
|
35
37
|
.smdx-dark .smdx-highlight-orange { background-color: #9a3412; color: #fed7aa; }
|
|
36
38
|
.smdx-dark .smdx-highlight-cyan { background-color: #155e75; color: #a5f3fc; }
|
|
37
39
|
.smdx-color-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.15); vertical-align: middle; margin-right: 6px; }
|
|
38
|
-
`}}const V=[{type:"tip",label:"TIP",color:"#10b981",bg:"#ecfdf5",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#10b981"/><path d="M9 12l2 2 4-4" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{type:"warning",label:"WARNING",color:"#f59e0b",bg:"#fffbeb",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z" fill="#f59e0b"/><path d="M12 9v4M12 17h.01" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"caution",label:"CAUTION",color:"#f97316",bg:"#fff7ed",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#f97316"/><path d="M12 8v4M12 16h.01" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"danger",label:"DANGER",color:"#ef4444",bg:"#fef2f2",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#ef4444"/><path d="M15 9l-6 6M9 9l6 6" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"check",label:"CHECK",color:"#22c55e",bg:"#f0fdf4",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#22c55e"/><path d="M8 12l3 3 5-5" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{type:"info",label:"INFO",color:"#3b82f6",bg:"#eff6ff",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#3b82f6"/><path d="M12 16v-4M12 8h.01" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"note",label:"NOTE",color:"#8b5cf6",bg:"#f5f3ff",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><rect x="3" y="3" width="18" height="18" rx="3" fill="#8b5cf6"/><path d="M8 10h8M8 14h5" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'}];function W(){return{name:"admonition",toolbarItems:[{id:"admonition",label:"Admonition",icon:
|
|
40
|
+
`}}const V=[{type:"tip",label:"TIP",color:"#10b981",bg:"#ecfdf5",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#10b981"/><path d="M9 12l2 2 4-4" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{type:"warning",label:"WARNING",color:"#f59e0b",bg:"#fffbeb",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z" fill="#f59e0b"/><path d="M12 9v4M12 17h.01" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"caution",label:"CAUTION",color:"#f97316",bg:"#fff7ed",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#f97316"/><path d="M12 8v4M12 16h.01" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"danger",label:"DANGER",color:"#ef4444",bg:"#fef2f2",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#ef4444"/><path d="M15 9l-6 6M9 9l6 6" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"check",label:"CHECK",color:"#22c55e",bg:"#f0fdf4",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#22c55e"/><path d="M8 12l3 3 5-5" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{type:"info",label:"INFO",color:"#3b82f6",bg:"#eff6ff",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#3b82f6"/><path d="M12 16v-4M12 8h.01" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"note",label:"NOTE",color:"#8b5cf6",bg:"#f5f3ff",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><rect x="3" y="3" width="18" height="18" rx="3" fill="#8b5cf6"/><path d="M8 10h8M8 14h5" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'}];function W(){return{name:"admonition",toolbarItems:[{id:"admonition",label:"Admonition",icon:h.admonition,tooltip:"Admonition / Callout",children:V.map(r=>({id:`admonition-${r.type}`,label:r.label,icon:r.icon,tooltip:`${r.label} callout`,action:({editor:e})=>{e.insertBlock(`:::${r.type}
|
|
39
41
|
${r.label}: Your message here
|
|
40
42
|
:::`)}})),action:({editor:r})=>{r.insertBlock(`:::info
|
|
41
43
|
INFO: Your message here
|
|
42
|
-
:::`)}}],renderers:[{name:"admonition",pattern:/:::(tip|warning|caution|danger|check|info|note)(?:\[([^\]]*)\])?\n([\s\S]*?):::/g,render:r=>{const e=r.match(/:::(tip|warning|caution|danger|check|info|note)(?:\[([^\]]*)\])?\n([\s\S]*?):::/);if(!e)return r;const t=V.find(
|
|
44
|
+
:::`)}}],renderers:[{name:"admonition",pattern:/:::(tip|warning|caution|danger|check|info|note)(?:\[([^\]]*)\])?\n([\s\S]*?):::/g,render:r=>{const e=r.match(/:::(tip|warning|caution|danger|check|info|note)(?:\[([^\]]*)\])?\n([\s\S]*?):::/);if(!e)return r;const t=V.find(o=>o.type===e[1]),i=e[2]||t.label;return`<div class="smdx-admonition smdx-admonition-${e[1]}"><div class="smdx-admonition-title"><span class="smdx-admonition-icon">${t.icon}</span>${i}</div><div class="smdx-admonition-content">${e[3]}</div></div>`},priority:10}],styles:`
|
|
43
45
|
.smdx-admonition { padding: 14px 16px; border-radius: 6px; margin: 12px 0; border-left: 4px solid; }
|
|
44
46
|
.smdx-admonition-title { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 6px; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.02em; }
|
|
45
47
|
.smdx-admonition-icon { display: flex; align-items: center; flex-shrink: 0; }
|
|
@@ -68,23 +70,23 @@ INFO: Your message here
|
|
|
68
70
|
.smdx-dark .smdx-admonition-info { background: #172554; }
|
|
69
71
|
.smdx-dark .smdx-admonition-note { background: #2e1065; }
|
|
70
72
|
.smdx-dark .smdx-admonition-content { color: var(--smdx-text, #e2e8f0); }
|
|
71
|
-
`}}function
|
|
72
|
-
`),t=e.filter(
|
|
73
|
-
`).trim():r.trim()}function K(){return{name:"tab",toolbarItems:[{id:"tab",label:"Tab",icon:
|
|
73
|
+
`}}function Ie(r){const e=r.split(`
|
|
74
|
+
`),t=e.filter(o=>o.trim().length>0),i=t.length>0?Math.min(...t.map(o=>o.match(/^\s*/)[0].length)):0;return i>0?e.map(o=>o.slice(i)).join(`
|
|
75
|
+
`).trim():r.trim()}function K(){return{name:"tab",toolbarItems:[{id:"tab",label:"Tab",icon:h.tab,tooltip:"Insert Tabs",action:({editor:r})=>{r.insertBlock(`<Tabs>
|
|
74
76
|
<Tab title="Tab 1">
|
|
75
77
|
Content for tab 1
|
|
76
78
|
</Tab>
|
|
77
79
|
<Tab title="Tab 2">
|
|
78
80
|
Content for tab 2
|
|
79
81
|
</Tab>
|
|
80
|
-
</Tabs>`)}}],renderers:[{name:"tabs",pattern:/<Tabs>([\s\S]*?)<\/Tabs>/g,render:r=>{const e=/<Tab\s+title="([^"]*)">([\s\S]*?)<\/Tab>/g;let t=[],
|
|
82
|
+
</Tabs>`)}}],renderers:[{name:"tabs",pattern:/<Tabs>([\s\S]*?)<\/Tabs>/g,render:r=>{const e=/<Tab\s+title="([^"]*)">([\s\S]*?)<\/Tab>/g;let t=[],i;for(;(i=e.exec(r))!==null;)t.push({title:i[1],content:Ie(i[2])});if(t.length===0)return r;let s=`<div class="smdx-tabs" data-tab-id="${"tab-"+Math.random().toString(36).substring(2,8)}"><div class="smdx-tabs-header">`;return t.forEach((n,a)=>{s+=`<button class="smdx-tab-btn${a===0?" smdx-active":""}" data-smdx-tab-btn="true" data-tab-index="${a}">${n.title}</button>`}),s+="</div>",t.forEach((n,a)=>{s+=`<div class="smdx-tab-panel" style="display:${a===0?"block":"none"}">${n.content}</div>`}),s+="</div>",s},priority:15}],styles:`
|
|
81
83
|
.smdx-tabs { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; overflow: hidden; margin: 12px 0; }
|
|
82
84
|
.smdx-tabs-header { display: flex; background: var(--smdx-bg-muted, #f8fafc); border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
|
|
83
85
|
.smdx-tab-btn { padding: 8px 16px; border: none; background: none; cursor: pointer; font-size: 0.9em; color: var(--smdx-text-muted, #64748b); border-bottom: 2px solid transparent; transition: all 0.15s; }
|
|
84
86
|
.smdx-tab-btn:hover { color: var(--smdx-text, #1e293b); }
|
|
85
87
|
.smdx-tab-btn.smdx-active { color: var(--smdx-primary, #6366f1); border-bottom-color: var(--smdx-primary, #6366f1); background: var(--smdx-bg, #fff); }
|
|
86
88
|
.smdx-tab-panel { padding: 16px; }
|
|
87
|
-
`}}function U(){return{name:"imageBackground",toolbarItems:[{id:"imageBackground",label:"Image Background",icon:
|
|
89
|
+
`}}function U(){return{name:"imageBackground",toolbarItems:[{id:"imageBackground",label:"Image Background",icon:h.imageBackground,tooltip:"Image with Background",action:({editor:r})=>{r.insertBlock(`<ImageBackground src="image-url" alt="description" background="#f0f0f0">
|
|
88
90
|
Content overlaying the image
|
|
89
91
|
</ImageBackground>`)}}],renderers:[{name:"imageBackground",pattern:/<ImageBackground\s+src="([^"]*)"(?:\s+alt="([^"]*)")?(?:\s+background="([^"]*)")?\s*>([\s\S]*?)<\/ImageBackground>/g,render:r=>{const e=r.match(/<ImageBackground\s+src="([^"]*)"(?:\s+alt="([^"]*)")?(?:\s+background="([^"]*)")?\s*>([\s\S]*?)<\/ImageBackground>/);return e?`<div class="smdx-image-bg" style="${e[3]?`background-image:url(${e[1]});background-color:${e[3]}`:`background-image:url(${e[1]})`}">
|
|
90
92
|
<div class="smdx-image-bg-overlay">${e[4].trim()}</div>
|
|
@@ -92,7 +94,7 @@ INFO: Your message here
|
|
|
92
94
|
.smdx-image-bg { background-size: cover; background-position: center; border-radius: 8px; overflow: hidden; min-height: 200px; display: flex; align-items: center; justify-content: center; margin: 12px 0; background-color: var(--smdx-bg-muted, #f0f0f0); border: 1px solid var(--smdx-border, #e2e8f0); }
|
|
93
95
|
.smdx-image-bg-overlay { background: rgba(0,0,0,0.5); color: white; padding: 24px; width: 100%; text-align: center; }
|
|
94
96
|
.smdx-dark .smdx-image-bg-overlay { background: rgba(0,0,0,0.6); }
|
|
95
|
-
`}}function Y(){return{name:"imageFrame",toolbarItems:[{id:"imageFrame",label:"Image Frame",icon:
|
|
97
|
+
`}}function Y(){return{name:"imageFrame",toolbarItems:[{id:"imageFrame",label:"Image Frame",icon:h.imageFrame,tooltip:"Image in Frame",action:({editor:r})=>{r.insertBlock('<ImageFrame src="image-url" alt="description" caption="Image caption" />')}}],renderers:[{name:"imageFrame",pattern:/<ImageFrame\s+src="([^"]*)"(?:\s+alt="([^"]*)")?(?:\s+caption="([^"]*)")?\s*\/>/g,render:r=>{const e=r.match(/<ImageFrame\s+src="([^"]*)"(?:\s+alt="([^"]*)")?(?:\s+caption="([^"]*)")?\s*\/>/);return e?`<figure class="smdx-image-frame">
|
|
96
98
|
<img src="${e[1]}" alt="${e[2]||""}" />
|
|
97
99
|
${e[3]?`<figcaption>${e[3]}</figcaption>`:""}
|
|
98
100
|
</figure>`:r}}],styles:`
|
|
@@ -100,8 +102,8 @@ INFO: Your message here
|
|
|
100
102
|
.smdx-image-frame img { width: 100%; border-radius: 4px; display: block; }
|
|
101
103
|
.smdx-image-frame figcaption { text-align: center; padding: 8px 0 4px; font-size: 0.85em; color: var(--smdx-text-muted, #64748b); }
|
|
102
104
|
`}}function X(r){const e=r.split(`
|
|
103
|
-
`),t=e.filter(
|
|
104
|
-
`).trim():r.trim()}function J(){return{name:"accordion",toolbarItems:[{id:"accordion",label:"Accordion",icon:
|
|
105
|
+
`),t=e.filter(o=>o.trim().length>0),i=t.length>0?Math.min(...t.map(o=>o.match(/^\s*/)[0].length)):0;return i>0?e.map(o=>o.slice(i)).join(`
|
|
106
|
+
`).trim():r.trim()}function J(){return{name:"accordion",toolbarItems:[{id:"accordion",label:"Accordion",icon:h.accordion,tooltip:"Insert Accordion",action:({editor:r})=>{r.insertBlock(`<Accordion title="Accordion Title" defaultOpen>
|
|
105
107
|
Your content here. You can include any markdown or components.
|
|
106
108
|
</Accordion>`)}}],renderers:[{name:"accordion",pattern:/<Accordion\s+title="([^"]*)"(\s+defaultOpen)?\s*>([\s\S]*?)<\/Accordion>/g,render:r=>{const e=r.match(/<Accordion\s+title="([^"]*)"(\s+defaultOpen)?\s*>([\s\S]*?)<\/Accordion>/);return e?`<details class="smdx-accordion"${e[2]?" open":""}><summary class="smdx-accordion-header"><span class="smdx-accordion-arrow"></span><span class="smdx-accordion-title">${e[1]}</span></summary><div class="smdx-accordion-content">${X(e[3])}</div></details>`:r},priority:12}],styles:`
|
|
107
109
|
.smdx-accordion { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; margin: 8px 0; overflow: hidden; background: var(--smdx-bg, #fff); }
|
|
@@ -113,7 +115,7 @@ INFO: Your message here
|
|
|
113
115
|
.smdx-accordion-content { padding: 14px 18px 18px 18px; border-top: 1px solid var(--smdx-border, #e2e8f0); }
|
|
114
116
|
.smdx-accordion-content p { margin: 6px 0; }
|
|
115
117
|
.smdx-accordion-content > :last-child { margin-bottom: 0; }
|
|
116
|
-
`}}function Z(){return{name:"accordionGroup",dependencies:["accordion"],toolbarItems:[{id:"accordionGroup",label:"Accordion Group",icon:
|
|
118
|
+
`}}function Z(){return{name:"accordionGroup",dependencies:["accordion"],toolbarItems:[{id:"accordionGroup",label:"Accordion Group",icon:h.accordionGroup,tooltip:"Insert Accordion Group",action:({editor:r})=>{r.insertBlock(`<AccordionGroup>
|
|
117
119
|
<Accordion title="Section 1" defaultOpen>
|
|
118
120
|
Content for section 1
|
|
119
121
|
</Accordion>
|
|
@@ -129,8 +131,8 @@ INFO: Your message here
|
|
|
129
131
|
.smdx-accordion-group .smdx-accordion { margin: 0; border-radius: 0; border-bottom: none; }
|
|
130
132
|
.smdx-accordion-group .smdx-accordion:first-of-type { border-radius: 8px 8px 0 0; }
|
|
131
133
|
.smdx-accordion-group .smdx-accordion:last-of-type { border-radius: 0 0 8px 8px; border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
|
|
132
|
-
`}}function Q(){return{name:"multiColumn",toolbarItems:[{id:"multiColumn",label:"Columns",icon:
|
|
133
|
-
Column ${
|
|
134
|
+
`}}function Q(){return{name:"multiColumn",toolbarItems:[{id:"multiColumn",label:"Columns",icon:h.multiColumn,tooltip:"Multiple Columns",children:[2,3,4,5].map(r=>({id:`columns-${r}`,label:`${r} Columns`,tooltip:`${r} column layout`,action:({editor:e})=>{const t=Array.from({length:r},(i,o)=>` <Column>
|
|
135
|
+
Column ${o+1} content
|
|
134
136
|
</Column>`).join(`
|
|
135
137
|
`);e.insertBlock(`<Columns count="${r}">
|
|
136
138
|
${t}
|
|
@@ -141,14 +143,18 @@ ${t}
|
|
|
141
143
|
<Column>
|
|
142
144
|
Column 2 content
|
|
143
145
|
</Column>
|
|
144
|
-
</Columns>`)}}],renderers:[{name:"columns",pattern:/<Columns\s+count="(\d+)">([\s\S]*?)<\/Columns>/g,render:r=>{const e=r.match(/<Columns\s+count="(\d+)">([\s\S]*?)<\/Columns>/);if(!e)return r;const t=parseInt(e[1]),
|
|
146
|
+
</Columns>`)}}],renderers:[{name:"columns",pattern:/<Columns\s+count="(\d+)">([\s\S]*?)<\/Columns>/g,render:r=>{const e=r.match(/<Columns\s+count="(\d+)">([\s\S]*?)<\/Columns>/);if(!e)return r;const t=parseInt(e[1]),i=/<Column>([\s\S]*?)<\/Column>/g;let o=[],s;for(;(s=i.exec(e[2]))!==null;)o.push(X(s[1]));let n=`<div class="smdx-columns" style="grid-template-columns:repeat(${t},1fr)">
|
|
147
|
+
`;for(const a of o)n+=`<div class="smdx-column">
|
|
148
|
+
${a}
|
|
149
|
+
</div>
|
|
150
|
+
`;return n+="</div>",n},priority:13}],styles:`
|
|
145
151
|
.smdx-columns { display: grid; gap: 16px; margin: 12px 0; }
|
|
146
152
|
.smdx-column { padding: 12px; border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 6px; }
|
|
147
|
-
`}}function
|
|
148
|
-
`),t=e.filter(
|
|
149
|
-
`).trim():r.trim()}function ee(){return{name:"card",toolbarItems:[{id:"card",label:"Card",icon:
|
|
153
|
+
`}}function Me(r){const e=r.split(`
|
|
154
|
+
`),t=e.filter(o=>o.trim().length>0),i=t.length>0?Math.min(...t.map(o=>o.match(/^\s*/)[0].length)):0;return i>0?e.map(o=>o.slice(i)).join(`
|
|
155
|
+
`).trim():r.trim()}function ee(){return{name:"card",toolbarItems:[{id:"card",label:"Card",icon:h.card,tooltip:"Insert Card",action:({editor:r})=>{r.insertBlock(`<Card title="Card Title" icon="📄" href="/link">
|
|
150
156
|
Card description or content goes here.
|
|
151
|
-
</Card>`)}}],renderers:[{name:"card",pattern:/<Card\s+title="([^"]*)"(?:\s+icon="([^"]*)")?(?:\s+href="([^"]*)")?\s*>([\s\S]*?)<\/Card>/g,render:r=>{const e=r.match(/<Card\s+title="([^"]*)"(?:\s+icon="([^"]*)")?(?:\s+href="([^"]*)")?\s*>([\s\S]*?)<\/Card>/);if(!e)return r;const t=e[3]?"a":"div",
|
|
157
|
+
</Card>`)}}],renderers:[{name:"card",pattern:/<Card\s+title="([^"]*)"(?:\s+icon="([^"]*)")?(?:\s+href="([^"]*)")?\s*>([\s\S]*?)<\/Card>/g,render:r=>{const e=r.match(/<Card\s+title="([^"]*)"(?:\s+icon="([^"]*)")?(?:\s+href="([^"]*)")?\s*>([\s\S]*?)<\/Card>/);if(!e)return r;const t=e[3]?"a":"div",i=e[3]?` href="${e[3]}" target="_blank" rel="noopener noreferrer"`:"",o=e[2]?`<span class="smdx-card-icon">${e[2]}</span>`:"",s=e[3]?'<svg class="smdx-card-arrow" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>':"";return`<${t} class="smdx-card"${i}><div class="smdx-card-header">${o}<span class="smdx-card-title">${e[1]}</span>${s}</div><div class="smdx-card-content">${Me(e[4])}</div></${t}>`},priority:11}],styles:`
|
|
152
158
|
.smdx-card { display: block; border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 10px; padding: 16px 20px; margin: 8px 0; text-decoration: none; color: inherit; transition: border-color 0.2s, box-shadow 0.2s, background 0.2s; background: var(--smdx-bg, #fff); }
|
|
153
159
|
a.smdx-card { cursor: pointer; }
|
|
154
160
|
a.smdx-card:hover { border-color: var(--smdx-primary, #6366f1); box-shadow: 0 2px 12px rgba(99,102,241,0.1); background: var(--smdx-bg-muted, #f8fafc); }
|
|
@@ -158,7 +164,7 @@ ${t}
|
|
|
158
164
|
.smdx-card-arrow { margin-left: auto; flex-shrink: 0; color: var(--smdx-text-muted, #94a3b8); transition: transform 0.2s, color 0.2s; }
|
|
159
165
|
a.smdx-card:hover .smdx-card-arrow { transform: translateX(2px); color: var(--smdx-primary, #6366f1); }
|
|
160
166
|
.smdx-card-content { font-size: 0.9em; color: var(--smdx-text-muted, #64748b); line-height: 1.5; }
|
|
161
|
-
`}}function te(){return{name:"cardGroup",dependencies:["card"],toolbarItems:[{id:"cardGroup",label:"Card Group",icon:
|
|
167
|
+
`}}function te(){return{name:"cardGroup",dependencies:["card"],toolbarItems:[{id:"cardGroup",label:"Card Group",icon:h.cardGroup,tooltip:"Insert Card Group",action:({editor:r})=>{r.insertBlock(`<CardGroup cols="2">
|
|
162
168
|
<Card title="Card 1" icon="📄">
|
|
163
169
|
Description for card 1
|
|
164
170
|
</Card>
|
|
@@ -175,8 +181,8 @@ ${t}
|
|
|
175
181
|
.smdx-card-group { display: grid; gap: 12px; margin: 12px 0; }
|
|
176
182
|
.smdx-card-group .smdx-card { margin: 0; }
|
|
177
183
|
`}}function re(r){const e=r.split(`
|
|
178
|
-
`),t=e.filter(
|
|
179
|
-
`).trim():r.trim()}function
|
|
184
|
+
`),t=e.filter(o=>o.trim().length>0),i=t.length>0?Math.min(...t.map(o=>o.match(/^\s*/)[0].length)):0;return i>0?e.map(o=>o.slice(i)).join(`
|
|
185
|
+
`).trim():r.trim()}function ie(){return{name:"step",toolbarItems:[{id:"steps",label:"Steps",icon:h.step,tooltip:"Insert Steps",action:({editor:r})=>{r.insertBlock(`<Steps>
|
|
180
186
|
<Step title="First Step">
|
|
181
187
|
These are instructions or content that only pertain to the first step.
|
|
182
188
|
</Step>
|
|
@@ -186,7 +192,7 @@ ${t}
|
|
|
186
192
|
<Step title="Third Step">
|
|
187
193
|
These are instructions or content that only pertain to the third step.
|
|
188
194
|
</Step>
|
|
189
|
-
</Steps>`)}}],renderers:[{name:"steps",pattern:/<Steps>([\s\S]*?)<\/Steps>/g,render:r=>{const e=r.match(/<Steps>([\s\S]*?)<\/Steps>/);if(!e)return r;const t=/<Step\s+title="([^"]*)">([\s\S]*?)<\/Step>/g;let
|
|
195
|
+
</Steps>`)}}],renderers:[{name:"steps",pattern:/<Steps>([\s\S]*?)<\/Steps>/g,render:r=>{const e=r.match(/<Steps>([\s\S]*?)<\/Steps>/);if(!e)return r;const t=/<Step\s+title="([^"]*)">([\s\S]*?)<\/Step>/g;let i=[],o;for(;(o=t.exec(e[1]))!==null;)i.push({title:o[1],content:re(o[2])});let s='<div class="smdx-steps">';return i.forEach((n,a)=>{const d=a===i.length-1;s+=`<div class="smdx-step"><div class="smdx-step-indicator"><div class="smdx-step-number">${a+1}</div>${d?"":'<div class="smdx-step-line"></div>'}</div><div class="smdx-step-content"><div class="smdx-step-title">${n.title}</div><div class="smdx-step-body">${n.content}</div></div></div>`}),s+="</div>",s},priority:15}],styles:`
|
|
190
196
|
.smdx-steps { margin: 20px 0; }
|
|
191
197
|
.smdx-step { display: flex; gap: 20px; position: relative; }
|
|
192
198
|
.smdx-step-indicator { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; min-width: 34px; position: relative; }
|
|
@@ -196,7 +202,7 @@ ${t}
|
|
|
196
202
|
.smdx-step:last-child .smdx-step-content { padding-bottom: 0; }
|
|
197
203
|
.smdx-step-title { font-weight: 700; font-size: 1.05em; color: var(--smdx-text, #1e293b); margin-bottom: 8px; }
|
|
198
204
|
.smdx-step-body { color: var(--smdx-text-muted, #64748b); font-size: 0.95em; line-height: 1.7; }
|
|
199
|
-
`}}const
|
|
205
|
+
`}}const oe=[{type:"good",label:"Good",color:"#22c55e",bg:"#f0fdf4",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#22c55e"/><path d="M8 12l3 3 5-5" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{type:"bad",label:"Bad",color:"#ef4444",bg:"#fef2f2",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#ef4444"/><path d="M15 9l-6 6M9 9l6 6" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"info",label:"Info",color:"#3b82f6",bg:"#eff6ff",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#3b82f6"/><path d="M12 16v-4M12 8h.01" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'}];function se(){return{name:"tip",toolbarItems:[{id:"tip",label:"Tip",icon:h.tip,tooltip:"Insert Tip",children:oe.map(r=>({id:`tip-${r.type}`,label:r.label,icon:r.icon,tooltip:`${r.label} tip`,action:({editor:e})=>{e.insertBlock(`<Tip${r.type.charAt(0).toUpperCase()+r.type.slice(1)}>Your tip message here</Tip${r.type.charAt(0).toUpperCase()+r.type.slice(1)}>`)}})),action:({editor:r})=>{r.insertBlock("<TipGood>Your tip message here</TipGood>")}}],renderers:oe.map(r=>({name:`tip-${r.type}`,pattern:new RegExp(`<Tip${r.type.charAt(0).toUpperCase()+r.type.slice(1)}>([\\s\\S]*?)<\\/Tip${r.type.charAt(0).toUpperCase()+r.type.slice(1)}>`,"g"),render:e=>{const t=`Tip${r.type.charAt(0).toUpperCase()+r.type.slice(1)}`,i=new RegExp(`<${t}>([\\s\\S]*?)<\\/${t}>`),o=e.match(i);return o?`<div class="smdx-tip smdx-tip-${r.type}"><span class="smdx-tip-icon">${r.icon}</span><span class="smdx-tip-text">${o[1].trim()}</span></div>`:e},priority:10})),styles:`
|
|
200
206
|
.smdx-tip { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: 6px; margin: 8px 0; font-size: 0.95em; border-left: 4px solid; }
|
|
201
207
|
.smdx-tip-icon { flex-shrink: 0; display: flex; align-items: center; margin-top: 1px; }
|
|
202
208
|
.smdx-tip-icon svg { display: block; }
|
|
@@ -207,12 +213,12 @@ ${t}
|
|
|
207
213
|
.smdx-dark .smdx-tip-good { background: #052e16; }
|
|
208
214
|
.smdx-dark .smdx-tip-bad { background: #450a0a; }
|
|
209
215
|
.smdx-dark .smdx-tip-info { background: #172554; }
|
|
210
|
-
`}}function ne(){return{name:"container",toolbarItems:[{id:"container",label:"Container",icon:
|
|
216
|
+
`}}function ne(){return{name:"container",toolbarItems:[{id:"container",label:"Container",icon:h.container,tooltip:"Insert Container",action:({editor:r})=>{r.insertBlock(`<Container>
|
|
211
217
|
Content inside a styled container.
|
|
212
218
|
</Container>`)}}],renderers:[{name:"container",pattern:/<Container(?:\s+title="([^"]*)")?>([\s\S]*?)<\/Container>/g,render:r=>{const e=r.match(/<Container(?:\s+title="([^"]*)")?>([\s\S]*?)<\/Container>/);return e?`<div class="smdx-container">${e[1]?`<div class="smdx-container-title">${e[1]}</div>`:""}<div class="smdx-container-content">${re(e[2])}</div></div>`:r}}],styles:`
|
|
213
219
|
.smdx-container { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; padding: 16px; margin: 12px 0; background: var(--smdx-bg-muted, #f8fafc); }
|
|
214
220
|
.smdx-container-title { font-weight: 600; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
|
|
215
|
-
`}}function ae(){return{name:"copyText",toolbarItems:[{id:"copyText",label:"Copy Text",icon:
|
|
221
|
+
`}}function ae(){return{name:"copyText",toolbarItems:[{id:"copyText",label:"Copy Text",icon:h.copyText,tooltip:"Copyable Text Block",action:({editor:r})=>{r.insertBlock("<CopyText>Text that users can click to copy</CopyText>")}}],renderers:[{name:"copyText",pattern:/<CopyText>([\s\S]*?)<\/CopyText>/g,render:r=>{const e=r.match(/<CopyText>([\s\S]*?)<\/CopyText>/);if(!e)return r;const t=e[1].trim();return`<div class="smdx-copy-text" onclick="navigator.clipboard.writeText(this.dataset.text);this.classList.add('smdx-copied');setTimeout(()=>this.classList.remove('smdx-copied'),2000)" data-text="${t.replace(/"/g,""")}"><code class="smdx-copy-text-content">${t}</code><button class="smdx-copy-text-btn" type="button"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg></button></div>`}}],styles:`
|
|
216
222
|
.smdx-copy-text { display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--smdx-bg-muted, #f1f5f9); border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; cursor: pointer; transition: all 0.15s; font-size: 0.9em; margin: 6px 0; }
|
|
217
223
|
.smdx-copy-text:hover { border-color: var(--smdx-primary, #6366f1); }
|
|
218
224
|
.smdx-copy-text.smdx-copied { border-color: #22c55e; background: #f0fdf4; }
|
|
@@ -221,7 +227,7 @@ ${t}
|
|
|
221
227
|
.smdx-copy-text:hover .smdx-copy-text-btn { color: var(--smdx-text, #1e293b); }
|
|
222
228
|
.smdx-copy-text.smdx-copied .smdx-copy-text-btn { color: #22c55e; }
|
|
223
229
|
.smdx-dark .smdx-copy-text.smdx-copied { background: #052e16; border-color: #166534; }
|
|
224
|
-
`}}function de(){return{name:"tooltip",toolbarItems:[{id:"tooltip",label:"Tooltip",icon:
|
|
230
|
+
`}}function de(){return{name:"tooltip",toolbarItems:[{id:"tooltip",label:"Tooltip",icon:h.tooltip,tooltip:"Insert Tooltip",action:({editor:r})=>{const t=r.getSelection().text||"hover text";r.replaceSelection(`<Tooltip tip="Tooltip content">${t}</Tooltip>`)}}],renderers:[{name:"tooltip",pattern:/<Tooltip\s+tip="([^"]*)">([\s\S]*?)<\/Tooltip>/g,render:r=>{const e=r.match(/<Tooltip\s+tip="([^"]*)">([\s\S]*?)<\/Tooltip>/);return e?`<span class="smdx-tooltip-wrapper"><span class="smdx-tooltip-trigger">${e[2]}<span class="smdx-tooltip-popup">${e[1]}</span></span></span>`:r}}],styles:`
|
|
225
231
|
.smdx-tooltip-wrapper { position: relative; display: inline; }
|
|
226
232
|
.smdx-tooltip-trigger { position: relative; border-bottom: 1px dashed var(--smdx-primary, #6366f1); cursor: help; text-decoration: none; }
|
|
227
233
|
.smdx-tooltip-popup { visibility: hidden; opacity: 0; position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); padding: 6px 12px; background: #1e293b; color: #fff; border-radius: 6px; font-size: 0.8em; white-space: nowrap; transition: opacity 0.15s, visibility 0.15s; z-index: 1000; pointer-events: none; }
|
|
@@ -229,16 +235,16 @@ ${t}
|
|
|
229
235
|
.smdx-tooltip-trigger:hover .smdx-tooltip-popup { visibility: visible; opacity: 1; }
|
|
230
236
|
.smdx-dark .smdx-tooltip-popup { background: #e2e8f0; color: #1e293b; }
|
|
231
237
|
.smdx-dark .smdx-tooltip-popup::after { border-top-color: #e2e8f0; }
|
|
232
|
-
`}}function le(){return{name:"embedVideo",toolbarItems:[{id:"embedVideo",label:"Embed Video",icon:
|
|
238
|
+
`}}function le(){return{name:"embedVideo",toolbarItems:[{id:"embedVideo",label:"Embed Video",icon:h.embedVideo,tooltip:"Embed Video",children:[{id:"embed-youtube",label:"YouTube",tooltip:"Embed YouTube video",action:({editor:r})=>{r.insertBlock('<EmbedVideo type="youtube" src="https://www.youtube.com/watch?v=VIDEO_ID" />')}},{id:"embed-video-file",label:"Video File",tooltip:"Embed video file",action:({editor:r})=>{r.insertBlock('<EmbedVideo type="file" src="video.mp4" />')}}],action:({editor:r})=>{r.insertBlock('<EmbedVideo type="youtube" src="https://www.youtube.com/watch?v=VIDEO_ID" />')}}],renderers:[{name:"embedVideo",pattern:/<EmbedVideo\s+type="([^"]*)"(?:\s+src="([^"]*)")?\s*\/>/g,render:r=>{const e=r.match(/<EmbedVideo\s+type="([^"]*)"(?:\s+src="([^"]*)")?\s*\/>/);if(!e)return r;const t=e[1],i=e[2]||"";if(t==="youtube"){const o=i.match(/(?:v=|\/embed\/|youtu\.be\/)([\w-]+)/),s=o?o[1]:i;return`<div class="smdx-embed-video">
|
|
233
239
|
<iframe src="https://www.youtube.com/embed/${encodeURIComponent(s)}" frameborder="0" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"></iframe>
|
|
234
240
|
</div>`}return`<div class="smdx-embed-video">
|
|
235
|
-
<video controls src="${
|
|
241
|
+
<video controls src="${i}" class="smdx-video-player">
|
|
236
242
|
Your browser does not support the video tag.
|
|
237
243
|
</video>
|
|
238
244
|
</div>`}}],styles:`
|
|
239
245
|
.smdx-embed-video { position: relative; width: 100%; padding-top: 56.25%; margin: 12px 0; border-radius: 8px; overflow: hidden; background: #000; }
|
|
240
246
|
.smdx-embed-video iframe, .smdx-embed-video video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
|
|
241
|
-
`}}function ce(){return{name:"embedOthers",toolbarItems:[{id:"embedOthers",label:"Embed",icon:
|
|
247
|
+
`}}function ce(){return{name:"embedOthers",toolbarItems:[{id:"embedOthers",label:"Embed",icon:h.embedOthers,tooltip:"Embed External Content",children:[{id:"embed-github",label:"GitHub Gist",tooltip:"Embed GitHub Gist",action:({editor:r})=>{r.insertBlock('<Embed type="github" src="https://gist.github.com/USER/GIST_ID" />')}},{id:"embed-twitter",label:"Twitter/X Post",tooltip:"Embed Tweet",action:({editor:r})=>{r.insertBlock('<Embed type="twitter" src="https://twitter.com/user/status/TWEET_ID" />')}},{id:"embed-codepen",label:"CodePen",tooltip:"Embed CodePen",action:({editor:r})=>{r.insertBlock('<Embed type="codepen" src="https://codepen.io/user/pen/PEN_ID" />')}},{id:"embed-codesandbox",label:"CodeSandbox",tooltip:"Embed CodeSandbox",action:({editor:r})=>{r.insertBlock('<Embed type="codesandbox" src="https://codesandbox.io/s/SANDBOX_ID" />')}}],action:({editor:r})=>{r.insertBlock('<Embed type="github" src="https://gist.github.com/USER/GIST_ID" />')}}],renderers:[{name:"embedOthers",pattern:/<Embed\s+[^>]*?\/>/g,render:r=>{const e=r.match(/type="([^"]*)"/),t=r.match(/src="([^"]*)"/),i=r.match(/label="([^"]*)"/);if(!e)return r;const o=e[1],s=t?t[1]:"",n=i?i[1]:"";switch(o){case"github":return`<div class="smdx-embed smdx-embed-card"><div class="smdx-embed-card-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"/></svg></div><div class="smdx-embed-card-body"><div class="smdx-embed-card-title">${n||"GitHub Gist"}</div><div class="smdx-embed-card-url">${s}</div></div><a href="${s}" target="_blank" rel="noopener noreferrer" class="smdx-embed-card-link">Open <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></a></div>`;case"twitter":return`<div class="smdx-embed smdx-embed-card"><div class="smdx-embed-card-icon smdx-embed-twitter-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg></div><div class="smdx-embed-card-body"><div class="smdx-embed-card-title">${n||"Post on X (Twitter)"}</div><div class="smdx-embed-card-url">${s}</div></div><a href="${s}" target="_blank" rel="noopener noreferrer" class="smdx-embed-card-link">Open <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></a></div>`;case"codepen":{const a=s.match(/codepen\.io\/([^/]+)\/pen\/([^/?]+)/);return a?`<div class="smdx-embed smdx-embed-codepen"><iframe height="400" style="width:100%" scrolling="no" src="https://codepen.io/${encodeURIComponent(a[1])}/embed/${encodeURIComponent(a[2])}?default-tab=result" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true"></iframe></div>`:`<div class="smdx-embed smdx-embed-card"><div class="smdx-embed-card-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 22 8.5 22 15.5 12 22 2 15.5 2 8.5 12 2"/><line x1="12" y1="22" x2="12" y2="15.5"/><polyline points="22 8.5 12 15.5 2 8.5"/></svg></div><div class="smdx-embed-card-body"><div class="smdx-embed-card-title">${n||"CodePen"}</div><div class="smdx-embed-card-url">${s}</div></div><a href="${s}" target="_blank" rel="noopener noreferrer" class="smdx-embed-card-link">Open <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></a></div>`}case"codesandbox":{const a=s.split("/").pop()||"";return`<div class="smdx-embed smdx-embed-codesandbox"><iframe src="https://codesandbox.io/embed/${encodeURIComponent(a)}" style="width:100%;height:500px;border:0;border-radius:4px;overflow:hidden" allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking" sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"></iframe></div>`}default:return`<div class="smdx-embed smdx-embed-card"><div class="smdx-embed-card-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71"/></svg></div><div class="smdx-embed-card-body"><div class="smdx-embed-card-title">${n||"Embedded Content"}</div><div class="smdx-embed-card-url">${s}</div></div><a href="${s}" target="_blank" rel="noopener noreferrer" class="smdx-embed-card-link">Open <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></a></div>`}}}],styles:`
|
|
242
248
|
.smdx-embed { margin: 12px 0; border-radius: 8px; overflow: hidden; }
|
|
243
249
|
.smdx-embed iframe { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; }
|
|
244
250
|
.smdx-embed-card { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; background: var(--smdx-bg-muted, #f8fafc); transition: border-color 0.15s; }
|
|
@@ -301,7 +307,7 @@ ${t}
|
|
|
301
307
|
Another task :after a1 , 20d
|
|
302
308
|
section Another
|
|
303
309
|
Task in sec :2014-01-12 , 12d
|
|
304
|
-
another task : 24d`}];function pe(){return{name:"mermaid",toolbarItems:[{id:"mermaid",label:"Mermaid",icon:
|
|
310
|
+
another task : 24d`}];function pe(){return{name:"mermaid",toolbarItems:[{id:"mermaid",label:"Mermaid",icon:h.mermaid,tooltip:"Insert Mermaid Diagram",children:me.map(r=>({id:`mermaid-${r.id}`,label:r.label,tooltip:`Insert ${r.label}`,action:({editor:e})=>{e.insertBlock("```mermaid\n"+r.template+"\n```")}})),action:({editor:r})=>{r.insertBlock("```mermaid\n"+me[0].template+"\n```")}}],renderers:[{name:"mermaid",pattern:/```mermaid\n([\s\S]*?)```/g,render:r=>{const e=r.match(/```mermaid\n([\s\S]*?)```/);if(!e)return r;const t="mermaid-"+Math.random().toString(36).substring(2,10),i=encodeURIComponent(e[1].trim());return`<div class="smdx-mermaid" data-mermaid-id="${t}" data-mermaid-code="${i}"><div class="smdx-mermaid-placeholder">Loading diagram…</div></div>`},priority:20}],async init(r){const e=async()=>{try{const t=window.mermaid;if(!t)return;const i=r.editor.getRoot().classList.contains("smdx-dark");t.initialize({startOnLoad:!1,theme:i?"dark":"default"});const o=r.editor.getPreview();if(!o)return;const s=o.querySelectorAll(".smdx-mermaid[data-mermaid-code]");for(const n of Array.from(s)){const a=decodeURIComponent(n.getAttribute("data-mermaid-code")),d=n.getAttribute("data-mermaid-id");try{const{svg:l}=await t.render(d,a);n.innerHTML=l,n.removeAttribute("data-mermaid-code")}catch{n.innerHTML=`<pre class="smdx-mermaid-error">${a.replace(/</g,"<").replace(/>/g,">")}</pre>`,n.removeAttribute("data-mermaid-code")}}}catch{}};r.on("render",e)},styles:`
|
|
305
311
|
.smdx-mermaid { margin: 12px 0; text-align: center; }
|
|
306
312
|
.smdx-mermaid svg { max-width: 100%; height: auto; }
|
|
307
313
|
.smdx-mermaid-placeholder { padding: 24px; color: var(--smdx-text-muted, #94a3b8); font-size: 0.9em; }
|
|
@@ -352,9 +358,9 @@ ${t}
|
|
|
352
358
|
.smdx-dark .smdx-mermaid .section0,
|
|
353
359
|
.smdx-dark .smdx-mermaid .section1 { fill: #374151 !important; }
|
|
354
360
|
.smdx-dark .smdx-mermaid .today { stroke: #818cf8 !important; }
|
|
355
|
-
`}}const $=[["😀","grinning smile happy"],["😂","joy laugh cry tears"],["🥰","love hearts smiling"],["😎","cool sunglasses"],["🤔","thinking hmm"],["😢","cry sad tear"],["😡","angry mad rage"],["🥳","party celebrate"],["👍","thumbs up good yes ok"],["👎","thumbs down bad no"],["👋","wave hello hi bye"],["🙏","pray please thanks"],["💪","strong muscle flex"],["🎉","party tada celebrate confetti"],["🔥","fire hot lit"],["⭐","star favorite"],["❤️","heart love red"],["💔","broken heart"],["💯","hundred perfect score"],["✅","check done yes complete"],["❌","cross no wrong cancel"],["⚠️","warning alert caution"],["💡","idea bulb light tip"],["🚀","rocket launch ship fast"],["📝","memo note write edit"],["📌","pin pushpin"],["📎","paperclip clip attach"],["🔗","link chain url"],["📁","folder file directory"],["🗂️","dividers tabs index"],["🔍","search magnifying find look"],["🔧","wrench tool fix settings"],["🎯","target goal dart bullseye"],["🏆","trophy winner cup award"],["🎨","art palette paint color"],["🎵","music note song"],["📊","chart bar graph stats"],["📈","chart up increase growth"],["📉","chart down decrease decline"],["💰","money bag dollar rich"],["🕐","clock time one"],["📅","calendar date schedule"],["🌟","glowing star sparkle shine"],["🌍","earth globe world"],["☀️","sun sunny bright"],["🌙","moon crescent night"],["⚡","lightning bolt zap electric"],["💧","water drop droplet"],["🟢","green circle dot"],["🔴","red circle dot"],["🟡","yellow circle dot"],["🔵","blue circle dot"],["⚪","white circle dot"],["⚫","black circle dot"],["🟣","purple circle dot"],["🟠","orange circle dot"]];function he(){return{name:"emoji",toolbarItems:[{id:"emoji",label:"Emoji",icon:
|
|
361
|
+
`}}const $=[["😀","grinning smile happy"],["😂","joy laugh cry tears"],["🥰","love hearts smiling"],["😎","cool sunglasses"],["🤔","thinking hmm"],["😢","cry sad tear"],["😡","angry mad rage"],["🥳","party celebrate"],["👍","thumbs up good yes ok"],["👎","thumbs down bad no"],["👋","wave hello hi bye"],["🙏","pray please thanks"],["💪","strong muscle flex"],["🎉","party tada celebrate confetti"],["🔥","fire hot lit"],["⭐","star favorite"],["❤️","heart love red"],["💔","broken heart"],["💯","hundred perfect score"],["✅","check done yes complete"],["❌","cross no wrong cancel"],["⚠️","warning alert caution"],["💡","idea bulb light tip"],["🚀","rocket launch ship fast"],["📝","memo note write edit"],["📌","pin pushpin"],["📎","paperclip clip attach"],["🔗","link chain url"],["📁","folder file directory"],["🗂️","dividers tabs index"],["🔍","search magnifying find look"],["🔧","wrench tool fix settings"],["🎯","target goal dart bullseye"],["🏆","trophy winner cup award"],["🎨","art palette paint color"],["🎵","music note song"],["📊","chart bar graph stats"],["📈","chart up increase growth"],["📉","chart down decrease decline"],["💰","money bag dollar rich"],["🕐","clock time one"],["📅","calendar date schedule"],["🌟","glowing star sparkle shine"],["🌍","earth globe world"],["☀️","sun sunny bright"],["🌙","moon crescent night"],["⚡","lightning bolt zap electric"],["💧","water drop droplet"],["🟢","green circle dot"],["🔴","red circle dot"],["🟡","yellow circle dot"],["🔵","blue circle dot"],["⚪","white circle dot"],["⚫","black circle dot"],["🟣","purple circle dot"],["🟠","orange circle dot"]];function he(){return{name:"emoji",toolbarItems:[{id:"emoji",label:"Emoji",icon:h.emoji,tooltip:"Insert Emoji",action:r=>{},render:(r,e)=>{r.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),Be(r,e.editor)})}}]}}function Be(r,e){var l;(l=document.querySelector(".smdx-emoji-picker"))==null||l.remove();const t=document.createElement("div");t.className="smdx-emoji-picker";const i=r.closest(".smdx-editor");i!=null&&i.classList.contains("smdx-dark")&&t.classList.add("smdx-dark");const o=document.createElement("input");o.type="text",o.placeholder="Search emoji...",o.className="smdx-emoji-search",t.appendChild(o);const s=document.createElement("div");s.className="smdx-emoji-grid";const n=c=>{s.innerHTML="";for(const[p]of c){const u=document.createElement("button");u.type="button",u.className="smdx-emoji-btn",u.textContent=p,u.addEventListener("click",()=>{e.insertText(p),t.remove()}),s.appendChild(u)}};n($),o.addEventListener("input",()=>{const c=o.value.toLowerCase().trim();if(!c){n($);return}n($.filter(([,p])=>p.includes(c)))}),t.appendChild(s);const a=r.getBoundingClientRect();t.style.position="fixed",t.style.top=`${a.bottom+4}px`,t.style.left=`${a.left}px`,document.body.appendChild(t);const d=c=>{!t.contains(c.target)&&c.target!==r&&(t.remove(),document.removeEventListener("click",d))};setTimeout(()=>document.addEventListener("click",d),0),o.focus()}function ue(){return{name:"formula",toolbarItems:[{id:"formula",label:"Formula",icon:h.formula,tooltip:"Insert Formula",children:[{id:"formula-inline",label:"Inline Formula",tooltip:"Inline math: $formula$",action:({editor:r})=>{r.wrapSelection("$","$")}},{id:"formula-block",label:"Block Formula",tooltip:"Block math: $$formula$$",action:({editor:r,selection:e})=>{r.insertBlock(`$$
|
|
356
362
|
`+(e.text||"E = mc^2")+`
|
|
357
|
-
$$`)}}],action:({editor:r})=>{r.wrapSelection("$","$")}}],renderers:[{name:"formula-block",pattern:/\$\$([\s\S]*?)\$\$/g,render:r=>{const e=r.match(/\$\$([\s\S]*?)\$\$/);if(!e)return r;const t=e[1].trim();try{const
|
|
363
|
+
$$`)}}],action:({editor:r})=>{r.wrapSelection("$","$")}}],renderers:[{name:"formula-block",pattern:/\$\$([\s\S]*?)\$\$/g,render:r=>{const e=r.match(/\$\$([\s\S]*?)\$\$/);if(!e)return r;const t=e[1].trim();try{const i=window.katex;if(i)return`<div class="smdx-formula-block">${i.renderToString(t,{displayMode:!0,throwOnError:!1})}</div>`}catch{}return`<div class="smdx-formula-block smdx-formula-fallback"><code>${t}</code></div>`},priority:18},{name:"formula-inline",pattern:new RegExp("(?<!\\$)\\$(?!\\$)((?:[^$\\\\]|\\\\.)+)\\$","g"),render:r=>{const e=r.match(new RegExp("(?<!\\$)\\$(?!\\$)((?:[^$\\\\]|\\\\.)+)\\$"));if(!e)return r;const t=e[1].trim();try{const i=window.katex;if(i)return i.renderToString(t,{displayMode:!1,throwOnError:!1})}catch{}return`<code class="smdx-formula-inline">${t}</code>`},priority:17}],styles:`
|
|
358
364
|
.smdx-formula-block { text-align: center; margin: 16px 0; font-size: 1.2em; overflow-x: auto; }
|
|
359
365
|
.smdx-formula-fallback { background: var(--smdx-bg-muted, #f8fafc); padding: 12px; border-radius: 6px; border: 1px solid var(--smdx-border, #e2e8f0); }
|
|
360
366
|
.smdx-formula-inline { font-size: 0.95em; }
|
|
@@ -369,10 +375,10 @@ $$`)}}],action:({editor:r})=>{r.wrapSelection("$","$")}}],renderers:[{name:"form
|
|
|
369
375
|
.smdx-dark .smdx-emoji-search, .smdx-emoji-picker.smdx-dark .smdx-emoji-search { background: #2a2a3c; color: #e2e8f0; border-color: #374151; }
|
|
370
376
|
.smdx-dark .smdx-emoji-search:focus, .smdx-emoji-picker.smdx-dark .smdx-emoji-search:focus { border-color: #818cf8; }
|
|
371
377
|
.smdx-dark .smdx-emoji-btn:hover, .smdx-emoji-picker.smdx-dark .smdx-emoji-btn:hover { background: #2a2a3c; }
|
|
372
|
-
`}}function
|
|
373
|
-
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\'/g,"'").replace(/\\\\/g,"\\").replace(/\\u([\da-fA-F]{4})/g,(c,
|
|
378
|
+
`}}function b(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function xe(){const r=new Map;async function e(o){if(r.has(o))return r.get(o);try{let s=await fetch(o+"?raw");if(s.ok||(s=await fetch(o)),!s.ok){const c={content:null,error:`File not found: ${o} (${s.status})`};return r.set(o,c),c}let n=await s.text();const a=n.trimStart();if(a.startsWith("<!DOCTYPE")||a.startsWith("<!doctype")||a.startsWith("<html")){const c={content:null,error:`File not found: ${o}`};return r.set(o,c),c}const d=n.match(/^export default (?:\/\*(?:[^*]|\*(?!\/))*\*\/\s*)?["']([\s\S]*)["']\s*;?\s*$/);d&&(n=d[1].replace(/\\n/g,`
|
|
379
|
+
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\'/g,"'").replace(/\\\\/g,"\\").replace(/\\u([\da-fA-F]{4})/g,(c,p)=>String.fromCharCode(parseInt(p,16))));const l={content:n};return r.set(o,l),l}catch{const s={content:null,error:`Failed to load: ${o}`};return r.set(o,s),s}}function t(o,s){const n=s.match(/^(\d+)-(\d+)$/);if(!n)return o;const a=Math.max(1,parseInt(n[1],10)),d=parseInt(n[2],10);return o.split(`
|
|
374
380
|
`).slice(a-1,d).join(`
|
|
375
|
-
`)}async function o
|
|
381
|
+
`)}async function i(o){const s=o.querySelectorAll(".smdx-import[data-src]");for(const a of s){if(a.dataset.loaded==="true")continue;a.dataset.loaded="true";const d=a.dataset.src,{content:l,error:c}=await e(d);c?(a.innerHTML=`<span class="smdx-import-icon">⚠️</span> <span class="smdx-import-error">${b(c)}</span>`,a.classList.add("smdx-import-failed")):(a.innerHTML=`<div class="smdx-import-header"><span class="smdx-import-icon">📄</span> <code>${b(d)}</code></div><div class="smdx-import-content">${b(l)}</div>`,a.classList.add("smdx-import-loaded"))}const n=o.querySelectorAll(".smdx-snippet[data-src]");for(const a of n){if(a.dataset.loaded==="true")continue;a.dataset.loaded="true";const d=a.dataset.src,l=a.dataset.lines||"",{content:c,error:p}=await e(d);if(p)a.innerHTML=`<span class="smdx-snippet-icon">⚠️</span> <span class="smdx-snippet-error">${b(p)}</span>`,a.classList.add("smdx-snippet-failed");else{const u=l?t(c,l):c,g=d.split(".").pop()||"text",x=l?` <span class="smdx-snippet-lines">(lines ${b(l)})</span>`:"";a.innerHTML=`<div class="smdx-snippet-header"><span class="smdx-snippet-icon">📋</span> <code>${b(d)}</code>${x}</div><pre class="smdx-snippet-code"><code class="language-${b(g)}">${b(u)}</code></pre>`,a.classList.add("smdx-snippet-loaded")}}}return{name:"insert",init(o){o.on("render",()=>{const s=o.editor.getPreview();s&&i(s)})},toolbarItems:[{id:"insert",label:"Insert",icon:h.insert,tooltip:"Insert Component",children:[{id:"insert-endpoint",label:"API Endpoint",tooltip:"Insert API endpoint block",action:({editor:o})=>{o.insertBlock(`<Endpoint method="GET" path="/api/v1/resource">
|
|
376
382
|
Description of the endpoint.
|
|
377
383
|
|
|
378
384
|
**Parameters:**
|
|
@@ -387,13 +393,13 @@ $$`)}}],action:({editor:r})=>{r.wrapSelection("$","$")}}],renderers:[{name:"form
|
|
|
387
393
|
"data": {}
|
|
388
394
|
}
|
|
389
395
|
\`\`\`
|
|
390
|
-
</Endpoint>`)}},{id:"insert-markdown",label:"Markdown Import",tooltip:"Import external markdown",action:({editor:
|
|
396
|
+
</Endpoint>`)}},{id:"insert-markdown",label:"Markdown Import",tooltip:"Import external markdown",action:({editor:o})=>{o.insertBlock('<Import src="./path/to/file.md" />')}},{id:"insert-snippet",label:"Code Snippet",tooltip:"Insert code snippet reference",action:({editor:o})=>{o.insertBlock('<Snippet src="./snippets/example.ts" lines="1-20" />')}}],action:()=>{}}],renderers:[{name:"endpoint",pattern:/<Endpoint\s+method="([^"]*)"(?:\s+path="([^"]*)")?\s*>([\s\S]*?)<\/Endpoint>/g,render:o=>{const s=o.match(/<Endpoint\s+method="([^"]*)"(?:\s+path="([^"]*)")?\s*>([\s\S]*?)<\/Endpoint>/);if(!s)return o;const n=s[1].toUpperCase(),a=s[2]||"";return`<div class="smdx-endpoint">
|
|
391
397
|
<div class="smdx-endpoint-header">
|
|
392
398
|
<span class="smdx-endpoint-method" style="background:${{GET:"#22c55e",POST:"#3b82f6",PUT:"#f59e0b",PATCH:"#a855f7",DELETE:"#ef4444"}[n]||"#64748b"}">${n}</span>
|
|
393
399
|
<code class="smdx-endpoint-path">${a}</code>
|
|
394
400
|
</div>
|
|
395
401
|
<div class="smdx-endpoint-body">${s[3].trim()}</div>
|
|
396
|
-
</div>`},priority:10},{name:"import",pattern:/<Import\s+src="([^"]*)"(?:\s*\/)?>/g,render:
|
|
402
|
+
</div>`},priority:10},{name:"import",pattern:/<Import\s+src="([^"]*)"(?:\s*\/)?>/g,render:o=>{const s=o.match(/<Import\s+src="([^"]*)"(?:\s*\/)?>/);if(!s)return o;const n=s[1];return`<div class="smdx-import" data-src="${b(n)}"><span class="smdx-import-icon">📄</span> Loading <code>${b(n)}</code>…</div>`}},{name:"snippet",pattern:/<Snippet\s+src="([^"]*)"(?:\s+lines="([^"]*)")?\s*\/>/g,render:o=>{const s=o.match(/<Snippet\s+src="([^"]*)"(?:\s+lines="([^"]*)")?\s*\/>/);if(!s)return o;const n=s[1],a=s[2]||"";return`<div class="smdx-snippet" data-src="${b(n)}"${a?` data-lines="${b(a)}"`:""}><span class="smdx-snippet-icon">📋</span> Loading <code>${b(n)}</code>…</div>`}}],styles:`
|
|
397
403
|
.smdx-endpoint { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; overflow: hidden; margin: 12px 0; }
|
|
398
404
|
.smdx-endpoint-header { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--smdx-bg-muted, #f8fafc); border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
|
|
399
405
|
.smdx-endpoint-method { color: white; padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: 0.8em; letter-spacing: 0.05em; }
|
|
@@ -411,7 +417,7 @@ $$`)}}],action:({editor:r})=>{r.wrapSelection("$","$")}}],renderers:[{name:"form
|
|
|
411
417
|
.smdx-import-error, .smdx-snippet-error { color: #b91c1c; }
|
|
412
418
|
.smdx-dark .smdx-import-failed, .smdx-dark .smdx-snippet-failed { background: #450a0a; border-color: #991b1b; }
|
|
413
419
|
.smdx-dark .smdx-import-error, .smdx-dark .smdx-snippet-error { color: #fca5a5; }
|
|
414
|
-
`}}function ge(){return{name:"toc",toolbarItems:[{id:"toc",label:"ToC",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="6" x2="21" y2="6"/><line x1="6" y1="12" x2="21" y2="12"/><line x1="6" y1="18" x2="21" y2="18"/><circle cx="3" cy="12" r="1" fill="currentColor"/><circle cx="3" cy="18" r="1" fill="currentColor"/></svg>',tooltip:"Toggle Table of Contents",action:({editor:r})=>{const e=r.getRoot(),t=e.querySelector(".smdx-toc-sidebar");t?(t.remove(),e.classList.remove("smdx-toc-open")):(e.classList.add("smdx-toc-open"),
|
|
420
|
+
`}}function ge(){return{name:"toc",toolbarItems:[{id:"toc",label:"ToC",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="6" x2="21" y2="6"/><line x1="6" y1="12" x2="21" y2="12"/><line x1="6" y1="18" x2="21" y2="18"/><circle cx="3" cy="12" r="1" fill="currentColor"/><circle cx="3" cy="18" r="1" fill="currentColor"/></svg>',tooltip:"Toggle Table of Contents",action:({editor:r})=>{const e=r.getRoot(),t=e.querySelector(".smdx-toc-sidebar");t?(t.remove(),e.classList.remove("smdx-toc-open")):(e.classList.add("smdx-toc-open"),be(r))}}],init(r){r.on("render",()=>{r.editor.getRoot().classList.contains("smdx-toc-open")&&be(r.editor)})},styles:`
|
|
415
421
|
.smdx-toc-sidebar { position: absolute; top: 0; right: 0; width: 220px; height: 100%; overflow-y: auto; background: var(--smdx-bg, #fff); border-left: 1px solid var(--smdx-border, #e2e8f0); padding: 16px 12px; z-index: 50; font-size: 0.85em; }
|
|
416
422
|
.smdx-toc-open .smdx-preview-pane { position: relative; }
|
|
417
423
|
.smdx-toc-title { font-weight: 700; font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.05em; color: var(--smdx-text-muted, #64748b); margin-bottom: 12px; }
|
|
@@ -422,7 +428,7 @@ $$`)}}],action:({editor:r})=>{r.wrapSelection("$","$")}}],renderers:[{name:"form
|
|
|
422
428
|
.smdx-toc-link.smdx-toc-h2 { padding-left: 16px; }
|
|
423
429
|
.smdx-toc-link.smdx-toc-h3 { padding-left: 28px; font-size: 0.95em; }
|
|
424
430
|
.smdx-toc-link.smdx-toc-h4 { padding-left: 40px; font-size: 0.9em; }
|
|
425
|
-
`}}function
|
|
426
|
-
`);for(const u of s){const
|
|
427
|
-
`);let w=0;for(let C=0;C<k.length;C++){const we=k[C].match(/^#{1,4}\s+(.+)$/);if(we&&we[1].replace(/[*_`~]/g,"")===u.text){c.focus(),c.setSelectionRange(w,w);const Ae=parseFloat(getComputedStyle(c).lineHeight)||22,
|
|
428
|
-
`)}}]}}function ve(){return{name:"horizontalRule",toolbarItems:[{id:"horizontalRule",label:"Horizontal Rule",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="12" x2="21" y2="12"/></svg>',tooltip:"Insert Horizontal Rule",action:({editor:r})=>{r.insertBlock("---")}}]}}function ke(){return[P(),A(),
|
|
431
|
+
`}}function be(r){var p;const e=r.getRoot(),t=e.querySelector(".smdx-preview-pane");if(!t)return;(p=e.querySelector(".smdx-toc-sidebar"))==null||p.remove();const i=r.getValue(),o=[],s=i.split(`
|
|
432
|
+
`);for(const u of s){const g=u.match(/^(#{1,4})\s+(.+)$/);if(g){const x=g[2].replace(/[*_`~]/g,""),f=x.toLowerCase().replace(/[^\w]+/g,"-").replace(/^-|-$/g,"");o.push({level:g[1].length,text:x,slug:f})}}if(o.length===0)return;const n=document.createElement("div");n.className="smdx-toc-sidebar";const a=document.createElement("div");a.className="smdx-toc-title",a.textContent="On this page",n.appendChild(a);const d=document.createElement("ul");d.className="smdx-toc-list";const l=r.getPreview(),c=e.querySelector(".smdx-textarea");o.forEach(u=>{const g=document.createElement("li");g.className="smdx-toc-item";const x=document.createElement("a");x.className=`smdx-toc-link smdx-toc-h${u.level}`,x.textContent=u.text,x.title=u.text,x.addEventListener("click",f=>{f.preventDefault();const y=l.querySelector(`#${CSS.escape(u.slug)}`);if(y&&y.scrollIntoView({behavior:"smooth",block:"start"}),c){const k=c.value.split(`
|
|
433
|
+
`);let w=0;for(let C=0;C<k.length;C++){const we=k[C].match(/^#{1,4}\s+(.+)$/);if(we&&we[1].replace(/[*_`~]/g,"")===u.text){c.focus(),c.setSelectionRange(w,w);const Ae=parseFloat(getComputedStyle(c).lineHeight)||22,He=C*Ae-c.clientHeight/3;c.scrollTop=Math.max(0,He);break}w+=k[C].length+1}}}),g.appendChild(x),d.appendChild(g)}),n.appendChild(d),t.appendChild(n)}function fe(){return{name:"breakLine",toolbarItems:[{id:"breakLine",label:"Line Break",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 7H3"/><path d="M21 17H9"/><path d="M18 13l3 4-3 4"/></svg>',tooltip:"Insert Line Break",action:({editor:r})=>{r.insertText(`<br/>
|
|
434
|
+
`)}}]}}function ve(){return{name:"horizontalRule",toolbarItems:[{id:"horizontalRule",label:"Horizontal Rule",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="12" x2="21" y2="12"/></svg>',tooltip:"Insert Horizontal Rule",action:({editor:r})=>{r.insertBlock("---")}}]}}function ke(){return[P(),A(),H(),D(),z(),N(),R(),O(),j(),G(),_(),q(),F(),W(),K(),U(),Y(),J(),Z(),Q(),ee(),te(),ie(),se(),ne(),ae(),de(),le(),ce(),pe(),he(),ue(),xe(),ge(),fe(),ve()]}function ye(){return[["heading","|","bold","italic","strikethrough","|","quote","link","image","|","code","codeBlock","|","unorderedList","orderedList","taskList","|","table","|","emoji","formula","|","toc","|",{type:"group",label:"Insert",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg>',display:"dropdown",items:[{type:"group",label:"Layout",items:["highlight","admonition","tab","imageBackground","imageFrame","accordion","accordionGroup","multiColumn","card","cardGroup","steps","tip","container"]},{type:"group",label:"Others",items:["copyText","tooltip","embedVideo","embedOthers","breakLine","horizontalRule"]},{type:"group",label:"Diagrams",items:["mermaid"]},{type:"group",label:"Apidog Widget",items:["insert"]}]}]]}function Pe(r){return new B({plugins:ke(),toolbar:ye(),placeholder:"Start writing markdown...",scrollSync:!0,mode:"split",...r})}m.EventEmitter=S,m.History=M,m.PluginManager=T,m.Renderer=I,m.SynclineMDXEditor=B,m.Toolbar=E,m.accordionGroupPlugin=Z,m.accordionPlugin=J,m.admonitionPlugin=W,m.allPlugins=ke,m.boldPlugin=A,m.breakLinePlugin=fe,m.cardGroupPlugin=te,m.cardPlugin=ee,m.codePlugin=O,m.containerPlugin=ne,m.copyTextPlugin=ae,m.createEditor=Pe,m.defaultToolbar=ye,m.embedOthersPlugin=ce,m.embedVideoPlugin=le,m.emojiPlugin=he,m.formulaPlugin=ue,m.headingPlugin=P,m.highlightPlugin=F,m.horizontalRulePlugin=ve,m.icons=h,m.imageBackgroundPlugin=U,m.imageFramePlugin=Y,m.imagePlugin=R,m.insertPlugin=xe,m.italicPlugin=H,m.linkPlugin=N,m.mermaidPlugin=pe,m.multiColumnPlugin=Q,m.orderedListPlugin=G,m.quotePlugin=z,m.stepPlugin=ie,m.strikethroughPlugin=D,m.tabPlugin=K,m.tablePlugin=q,m.taskListPlugin=_,m.tipPlugin=se,m.tocPlugin=ge,m.tooltipPlugin=de,m.unorderedListPlugin=j,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.2",
|
|
7
7
|
"description": "Framework-agnostic, plugin-based MDX/Markdown editor with toolbar customization and live preview",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "dist/syncline-mdx-editor.umd.cjs",
|
|
@@ -47,14 +47,7 @@
|
|
|
47
47
|
"wysiwyg"
|
|
48
48
|
],
|
|
49
49
|
"license": "MIT",
|
|
50
|
-
"
|
|
51
|
-
"type": "git",
|
|
52
|
-
"url": "https://github.com/RadhaHariharan/syncline-mdx-editor.git"
|
|
53
|
-
},
|
|
54
|
-
"bugs": {
|
|
55
|
-
"url": "https://github.com/RadhaHariharan/syncline-mdx-editor/issues"
|
|
56
|
-
},
|
|
57
|
-
"homepage": "https://syncline-mdx-editor.vercel.app",
|
|
50
|
+
"homepage": "https://markdown.synclineapi.com/",
|
|
58
51
|
"engines": {
|
|
59
52
|
"node": ">=18.0.0"
|
|
60
53
|
},
|