Git Product home page Git Product logo

Comments (11)

marble avatar marble commented on August 30, 2024 1

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.

susannemoog avatar susannemoog commented on August 30, 2024 1

How about using https://sphinx-copybutton.readthedocs.io/en/latest/ ?

from sphinx_typo3_theme.

marble avatar marble commented on August 30, 2024 1

How about using https://sphinx-copybutton.readthedocs.io/en/latest/ ?

Cool, will have a look.

from sphinx_typo3_theme.

marble avatar marble commented on August 30, 2024
  1. 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.

  2. 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.

  3. 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.

sypets avatar sypets commented on August 30, 2024

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

  1. Click "Breaking"
  2. Click "Code Block"
  3. Click the icon

forger

Gerrit

  1. open a review, e.g. https://review.typo3.org/c/Packages/TYPO3.CMS/+/58255
  2. press download

gerrit

from sphinx_typo3_theme.

DanielSiepmann avatar DanielSiepmann commented on August 30, 2024

As far as I understand, we "just" need to add @marble JavaScript solution to the theme?

from sphinx_typo3_theme.

sypets avatar sypets commented on August 30, 2024

Example on Symfony page:

clipboard

https://symfony.com/doc/current/doctrine.html

from sphinx_typo3_theme.

marble avatar marble commented on August 30, 2024

Ok, I'll go for a solution. Is certainly a useful "nice to have".

from sphinx_typo3_theme.

marble avatar marble commented on August 30, 2024

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.

marble avatar marble commented on August 30, 2024


https://www.30secondsofcode.org/js/s/copy-to-clipboard
grafik


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.

marble avatar marble commented on August 30, 2024

Done and solved with Docker rendering container version v2.9.0

from sphinx_typo3_theme.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.