reallysimpledocs 1.0.0-beta.3 → 1.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -31
- package/package.json +10 -5
- package/src/astro/index.js +46 -43
- package/src/astro/preview-source.js +90 -0
- package/src/components/index.js +1 -0
- package/src/css/custom.css +259 -29
- package/src/css/styles/luma.css +11 -0
- package/src/css/styles/lyra.css +11 -0
- package/src/css/styles/maia.css +11 -0
- package/src/css/styles/mira.css +11 -0
- package/src/css/styles/nova.css +11 -0
- package/src/css/styles/rhea.css +11 -0
- package/src/css/styles/sera.css +11 -0
- package/src/css/styles/vega.css +11 -0
- package/src/runtime/components/BaseLayout.astro +20 -27
- package/src/runtime/components/CommandDialog.astro +29 -14
- package/src/runtime/components/DefaultContentHeader.astro +2 -0
- package/src/runtime/components/DefaultHead.astro +120 -0
- package/src/runtime/components/DefaultHeadContent.astro +2 -0
- package/src/runtime/components/DefaultSidebarFooter.astro +2 -0
- package/src/runtime/components/DefaultSidebarHeader.astro +1 -1
- package/src/runtime/components/DocsLayout.astro +90 -122
- package/src/runtime/components/DropdownMenu.astro +1 -1
- package/src/runtime/components/Sidebar.astro +4 -0
- package/src/runtime/components/ThemeToggle.astro +21 -0
- package/src/runtime/components/mdx/Callout.astro +2 -9
- package/src/runtime/components/mdx/Card.astro +3 -8
- package/src/runtime/components/mdx/CardGrid.astro +1 -1
- package/src/runtime/components/mdx/Code.astro +2 -16
- package/src/runtime/components/mdx/CodeGroup.astro +7 -11
- package/src/runtime/components/mdx/Preview.astro +7 -12
- package/src/runtime/components/mdx/Steps.astro +1 -5
- package/src/runtime/components/mdx/Tab.astro +6 -0
- package/src/runtime/components/mdx/Tabs.astro +7 -7
- package/src/runtime/lib/docs.js +122 -16
- package/src/runtime/lib/highlight.js +1 -14
- package/src/runtime/lib/macros.js +11 -2
- package/src/runtime/lib/markdown-export.js +163 -0
- package/src/runtime/lib/site.js +0 -1
- package/src/runtime/pages/search-index.ts +10 -1
- package/src/css/overrides.css +0 -1
- package/src/css/sources.css +0 -1
- package/src/runtime/scripts/copy-code.js +0 -109
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import Copy from "lucide-static/icons/copy.svg?raw";
|
|
2
|
-
import Check from "lucide-static/icons/check.svg?raw";
|
|
3
|
-
|
|
4
|
-
const copyText = async (text) => {
|
|
5
|
-
if (window.isSecureContext && navigator.clipboard?.writeText) {
|
|
6
|
-
return navigator.clipboard.writeText(text);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const textarea = document.createElement("textarea");
|
|
10
|
-
textarea.value = text;
|
|
11
|
-
textarea.setAttribute("readonly", "");
|
|
12
|
-
textarea.style.position = "fixed";
|
|
13
|
-
textarea.style.top = "-9999px";
|
|
14
|
-
textarea.style.left = "-9999px";
|
|
15
|
-
document.body.appendChild(textarea);
|
|
16
|
-
textarea.select();
|
|
17
|
-
const ok = document.execCommand("copy");
|
|
18
|
-
textarea.remove();
|
|
19
|
-
if (!ok) throw new Error("Copy failed");
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const activePanelCode = (root) => root.querySelector(':scope > [role="tabpanel"]:not([hidden]) code');
|
|
23
|
-
const codeFrameClass = "relative my-6 w-full max-w-full overflow-hidden rounded-lg";
|
|
24
|
-
const codePreClasses = ["!my-0", "max-w-full", "overflow-x-auto", "!rounded-none", "!border-0"];
|
|
25
|
-
const codeContentClasses = ["block", "min-w-full", "w-max", "px-4", "py-3", "text-[13px]"];
|
|
26
|
-
const copyButtonClass =
|
|
27
|
-
"flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 dark:hover:bg-accent/50 [&_svg]:size-4";
|
|
28
|
-
|
|
29
|
-
const initCopyCode = (codeBlock) => {
|
|
30
|
-
const codeEl = codeBlock.querySelector(":scope > code");
|
|
31
|
-
if (!codeEl) return;
|
|
32
|
-
|
|
33
|
-
codeBlock.classList.add(...codePreClasses);
|
|
34
|
-
codeEl.classList.add(...codeContentClasses);
|
|
35
|
-
|
|
36
|
-
let target = null;
|
|
37
|
-
let frame = codeBlock.closest("[data-code-group]");
|
|
38
|
-
let getCode = frame ? () => activePanelCode(frame) || codeEl : () => codeEl;
|
|
39
|
-
if (frame) target = frame.querySelector(":scope > header");
|
|
40
|
-
|
|
41
|
-
const preview = codeBlock.closest("[data-preview]");
|
|
42
|
-
const previewCodePanel = preview?.querySelector(":scope > [data-code-panel]");
|
|
43
|
-
if (!frame && previewCodePanel?.contains(codeBlock)) {
|
|
44
|
-
frame = preview;
|
|
45
|
-
target = frame.querySelector(":scope > header");
|
|
46
|
-
getCode = () => codeEl;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (!frame) {
|
|
50
|
-
frame = codeBlock.parentElement?.hasAttribute("data-code-block") ? codeBlock.parentElement : null;
|
|
51
|
-
if (!frame) {
|
|
52
|
-
frame = document.createElement("div");
|
|
53
|
-
frame.dataset.codeBlock = "";
|
|
54
|
-
frame.className = codeFrameClass;
|
|
55
|
-
codeBlock.parentNode.insertBefore(frame, codeBlock);
|
|
56
|
-
frame.appendChild(codeBlock);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
target ||= frame.querySelector(":scope > header") || frame;
|
|
61
|
-
|
|
62
|
-
if (target.querySelector(":scope > button[aria-label='Copy code']")) {
|
|
63
|
-
codeBlock.dataset.copyCodeInitialized = true;
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const button = document.createElement("button");
|
|
68
|
-
button.type = "button";
|
|
69
|
-
button.setAttribute("aria-label", "Copy code");
|
|
70
|
-
button.className = `${copyButtonClass} ${
|
|
71
|
-
target === frame
|
|
72
|
-
? "absolute right-2.5 top-2.5 bg-muted/50 shadow-sm backdrop-blur-sm"
|
|
73
|
-
: "ml-auto"
|
|
74
|
-
}`;
|
|
75
|
-
button.innerHTML = Copy;
|
|
76
|
-
|
|
77
|
-
button.addEventListener("click", async () => {
|
|
78
|
-
const text = (getCode()?.textContent || "").replace(/\n$/, "");
|
|
79
|
-
if (!text) return;
|
|
80
|
-
|
|
81
|
-
button.disabled = true;
|
|
82
|
-
try {
|
|
83
|
-
await copyText(text);
|
|
84
|
-
button.innerHTML = Check;
|
|
85
|
-
} catch (error) {
|
|
86
|
-
console.error("[copy] Failed to copy:", error);
|
|
87
|
-
button.textContent = "Failed";
|
|
88
|
-
}
|
|
89
|
-
window.setTimeout(() => {
|
|
90
|
-
button.disabled = false;
|
|
91
|
-
button.innerHTML = Copy;
|
|
92
|
-
}, 1200);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
target.appendChild(button);
|
|
96
|
-
if (previewCodePanel?.contains(codeBlock)) {
|
|
97
|
-
const syncPreviewCopyButton = () => {
|
|
98
|
-
button.hidden = previewCodePanel.hidden;
|
|
99
|
-
};
|
|
100
|
-
syncPreviewCopyButton();
|
|
101
|
-
new MutationObserver(syncPreviewCopyButton).observe(previewCodePanel, {
|
|
102
|
-
attributes: true,
|
|
103
|
-
attributeFilter: ["hidden"],
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
codeBlock.dataset.copyCodeInitialized = true;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
window.basecoat?.register("copy-code", "pre:has(> code):not([data-copy-code-initialized])", initCopyCode);
|