Comments (11)
Oops, just noticed, that I had found that nice solution back in 2016 already ;-))
http://mbless.de/blog/2015/01/15/looking-for-wisdom-about-javascript.html#copy-to-clipboard
from sphinx_typo3_theme.
How about using https://sphinx-copybutton.readthedocs.io/en/latest/ ?
from sphinx_typo3_theme.
How about using https://sphinx-copybutton.readthedocs.io/en/latest/ ?
Cool, will have a look.
from sphinx_typo3_theme.
-
Files can be shown in code-blocks, though we hardly use that. In that case you can simply write a link to that file as well.
-
I don't know how the dokuwiki does that downloading of code-block content as file. Im curious, but I don't think it's an essential feature.
-
A button: "Mark all content of the code-block" and copy it to the clipboard could be convenient.
I close this issue for now. If somebodies stumbles across a nice solution for three on some other website we can still consider that and reopen this issue.
from sphinx_typo3_theme.
Can we reopen? I think copy to clipboard would be more useful than download to file.
I changed the title.
Examples that use this in the TYPO3 universe:
Forger reST helper for changelog
https://forger.typo3.com/utilities/rst
- Click "Breaking"
- Click "Code Block"
- Click the icon
Gerrit
- open a review, e.g. https://review.typo3.org/c/Packages/TYPO3.CMS/+/58255
- press download
from sphinx_typo3_theme.
As far as I understand, we "just" need to add @marble JavaScript solution to the theme?
from sphinx_typo3_theme.
Example on Symfony page:
https://symfony.com/doc/current/doctrine.html
from sphinx_typo3_theme.
Ok, I'll go for a solution. Is certainly a useful "nice to have".
from sphinx_typo3_theme.
On the symfonie page it's
(window.webpackJsonp = window.webpackJsonp || []).push([["doc"], {
b2hv: function (e, t, n) {
}, "ip/K": function (e, t, n) {
"use strict";
n.r(t);
var c = n("eBEy");
function o(e) {
var t = localStorage.getItem("selectedFormat"),
n = e.querySelector("li");
e.querySelectorAll("[class^=highlight-]").forEach(function (e) {
e.style.display = "none"
}), e.querySelectorAll("li").forEach(function (e) {
e.classList.remove("selected"), e.querySelector("em").textContent == t && (n = e)
});
var c = n.querySelector("[class^=highlight-]"),
o = n.closest("ul.simple"),
i = 28 + (c.classList.contains("highlight-terminal") ? 34 : 0);
n.classList.add("selected"), c.style.display = "block", o.style.height = c.scrollHeight + i + "px"
}
n("b2hv"), window.addEventListener("load", function () {
!function () {
var e = {
allowHTML: !0,
animateFill: !1,
animation: "fade",
ignoreAttributes: !0,
interactive: !0,
maxWidth: 500,
placement: "right",
sticky: !0,
trigger: "click",
theme: "light-border"
};
if (null === document.querySelector("#doc-menu-guides")) return;
Object(c.a)("#doc-menu-guides", Object.assign({}, e, {content: document.querySelector("#doc-menu-guides-content").innerHTML})), Object(c.a)("#doc-menu-components", Object.assign({}, e, {
content: document.querySelector("#doc-menu-components-content").innerHTML,
maxWidth: 650
}))
}(), document.querySelectorAll("div.configuration-block").forEach(function (e) {
e.classList.add("jsactive", "clearfix"), o(e), e.querySelectorAll("li").forEach(function (e) {
var t = e.querySelector("em"), n = t.textContent;
t.innerHTML = '<a href="#">' + n + "</a>", t.addEventListener("click", function (e) {
localStorage.setItem("selectedFormat", n), document.querySelectorAll("div.configuration-block").forEach(function (e) {
o(e)
}), e.preventDefault()
})
})
}), document.querySelectorAll(".highlight-terminal .gp, .highlight-terminal .c1").forEach(function (e) {
e.dataset.content = e.textContent
}), document.querySelectorAll("div.literal-block .highlight").forEach(function (e) {
var t = e.closest("[class*=highlight-]");
if (!t.classList.contains("highlight-terminal") && !t.classList.contains("highlight-diff")) {
var n = document.createElement("button");
n.classList.add("btn", "btn--code-copy"), e.prepend(n), n.addEventListener("click", function (t) {
var c, o;
c = e.textContent, (o = document.createElement("textarea")).setAttribute("readonly", ""), o.style = {
position: "absolute",
left: "-9999px"
}, o.value = c, document.body.appendChild(o), o.select(), document.execCommand("copy"), document.body.removeChild(o), n.classList.add("btn--code-copied"), setTimeout(function () {
n.classList.remove("btn--code-copied")
}, 1500), t.preventDefault()
})
}
})
})
}
}, [["ip/K", "runtime", 1]]]);
from sphinx_typo3_theme.
①
https://www.30secondsofcode.org/js/s/copy-to-clipboard
②
https://codepen.io/shaikmaqsood/pen/XmydxJ
③
https://www.30secondsofcode.org/js/s/copy-to-clipboard
④
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard
from sphinx_typo3_theme.
Done and solved with Docker rendering container version v2.9.0
from sphinx_typo3_theme.
Related Issues (20)
- Use white background for numbered sections like symfony HOT 1
- Text is white/gray HOT 9
- Reduce "visual clutter" by using different style for inline code (without background color)? HOT 3
- Clamp multiple paragraphs of directives like "versionadded" visually HOT 9
- Dark-on-dark syntax highlighting after upgrade HOT 5
- `t3-function-*` are not recognizable as links HOT 7
- Change request: 'view source' and 'Edit on GitHub' buttons could open in a new window HOT 9
- Copying code snippets will include line numbers HOT 11
- Indenting of code-blocks with captions is different from code blocks without captions HOT 2
- Re-enable gh-pages in CI.yml HOT 1
- Simplify '.. seealso::' appearance HOT 1
- Make .compact-list work everywhere HOT 1
- Update docs and gh-pages
- Make admonitions appear 'lighter' HOT 1
- Input value name "q" is in conflict with Sphinx code
- Change Html theme options and/or remove some parts of the sphinx_typo3_theme ? HOT 1
- Increase the size of contents in body of index HOT 3
- Include print.js for print to pdf to sphinx typo3 theme. HOT 2
- Using "rst-class:: bignums" has impact on subsequent lists HOT 3
- [Features] Content list and add a download 'view source' link or button
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sphinx_typo3_theme.