Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions assets/copybutton.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
var mdUrl = config.mdUrl || "";
var providers = config.providers || [];
var prompt = config.prompt || "";
var copyLabel = config.copyLabel || "Copy for AI";
var canonicalBase = config.canonicalBase || "";
var pagePath = config.pagePath || "";

Expand Down Expand Up @@ -50,17 +51,17 @@
var group = document.createElement("div");
group.className = "copybutton-group";

// --- Copy as Markdown button ---
// --- Copy for AI button ---
var copyBtn = document.createElement("button");
copyBtn.className = "button";
copyBtn.title = "Copy page as Markdown";
copyBtn.setAttribute("aria-label", "Copy page as Markdown");
copyBtn.title = "Copy page as Markdown for AI";
copyBtn.setAttribute("aria-label", "Copy page as Markdown for AI");
copyBtn.innerHTML =
'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">' +
'<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>' +
'<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>' +
'</svg>' +
'<span>Copy</span>';
'<span>' + copyLabel + '</span>';

copyBtn.addEventListener("click", function () {
fetchAndCopy(mdUrl, function (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/pipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function _inject_html!(html_path, plugin, md_filename, md_content, rel_prefix, c

injection = """
<script id="documenter-copybutton-config" type="application/json">
{"mdUrl":$(json_str(md_url)),"providers":[$providers_json],"prompt":$(json_str(plugin.prompt))$canonical_field,"pagePath":$(json_str(src))}
{"mdUrl":$(json_str(md_url)),"providers":[$providers_json],"prompt":$(json_str(plugin.prompt)),"copyLabel":$(json_str(plugin.copy_label))$canonical_field,"pagePath":$(json_str(src))}
</script>
<script id="documenter-copybutton-content" type="text/plain">$(escaped_md)</script>
<link rel="stylesheet" href="$(rel_prefix)copybutton.css"/>
Expand Down
7 changes: 5 additions & 2 deletions src/plugin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const DEFAULT_PROVIDERS = Provider[
]

"""
CopyButton(; providers=nothing, prompt="Read")
CopyButton(; providers=nothing, prompt="Read", copy_label="Copy for AI")

A [`Documenter.Plugin`] that adds floating "Copy as Markdown" and "Open in AI"
buttons to opted-in documentation pages.
Expand All @@ -52,6 +52,7 @@ Pages opt in by including a [`@copybutton`](@ref CopyButtonBlocks) block in thei
Set to an empty list to disable the "Open in AI" button.
- `prompt`: A prefix string prepended to the URL when opening in an AI provider.
Defaults to `"Read"`.
- `copy_label`: Label text for the copy button. Defaults to `"Copy for AI"`.

# Example

Expand All @@ -76,10 +77,12 @@ CopyButton(providers = [
struct CopyButton <: Plugin
providers::Vector{Provider}
prompt::String
copy_label::String

function CopyButton(;
providers=nothing,
prompt="Read",
copy_label="Copy for AI",
)
provs = if providers === nothing
copy(DEFAULT_PROVIDERS)
Expand All @@ -91,6 +94,6 @@ struct CopyButton <: Plugin
for p in providers
]
end
new(provs, prompt)
new(provs, prompt, copy_label)
end
end
Loading