Skip to content

Commit

Permalink
Added support for removing copy-to-clipboard button
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Nov 12, 2022
1 parent 557163a commit 128e267
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 17 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion material/.overrides/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
{% endblock %}
{% block scripts %}
{{ super() }}
<script src="{{ 'assets/javascripts/custom.f37eceaf.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/custom.a42114f4.min.js' | url }}"></script>
{% endblock %}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion material/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.4ef4f6b1.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.bde97ade.min.js' | url }}"></script>
{% for path in config.extra_javascript %}
<script src="{{ path | url }}"></script>
{% endfor %}
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ theme:
features:
# - announce.dismiss
- content.code.annotate
- content.code.copy
# - content.tabs.link
- content.tooltips
# - header.autohide
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/assets/javascripts/_/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { getElement, getLocation } from "~/browser"
export type Flag =
| "announce.dismiss" /* Dismissable announcement bar */
| "content.code.annotate" /* Code annotations */
| "content.code.copy" /* Code copy button */
| "content.lazy" /* Lazy content elements */
| "content.tabs.link" /* Link content tabs */
| "header.autohide" /* Hide header */
Expand Down
16 changes: 10 additions & 6 deletions src/assets/javascripts/components/content/code/_/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,16 @@ export function mountCodeBlock(

/* Render button for Clipboard.js integration */
if (ClipboardJS.isSupported()) {
const parent = el.closest("pre")!
parent.id = `__code_${++sequence}`
parent.insertBefore(
renderClipboardButton(parent.id),
el
)
if (el.closest(".copy") || (
feature("content.code.copy") && !el.closest(".no-copy")
)) {
const parent = el.closest("pre")!
parent.id = `__code_${++sequence}`
parent.insertBefore(
renderClipboardButton(parent.id),
el
)
}
}

/* Handle code annotations */
Expand Down

0 comments on commit 128e267

Please sign in to comment.