mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 11:48:26 -06:00
UX: Add copied text upon copy button click (#9793)
This commit is contained in:
parent
3a615a8bdd
commit
9810ca1dbd
@ -2,6 +2,7 @@ import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import { cancel, later } from "@ember/runloop";
|
||||
import { Promise } from "rsvp";
|
||||
import { iconHTML } from "discourse-common/lib/icon-library";
|
||||
import I18n from "I18n";
|
||||
|
||||
// http://github.com/feross/clipboard-copy
|
||||
function clipboardCopy(text) {
|
||||
@ -86,6 +87,8 @@ export default {
|
||||
if (code) {
|
||||
clipboardCopy(code.innerText.trim()).then(() => {
|
||||
button.classList.add("copied");
|
||||
const state = button.innerHTML;
|
||||
button.innerHTML = I18n.t("copy_codeblock.copied");
|
||||
|
||||
const commandId = Ember.guidFor(button);
|
||||
|
||||
@ -96,6 +99,7 @@ export default {
|
||||
|
||||
_fadeCopyCodeblocksRunners[commandId] = later(() => {
|
||||
button.classList.remove("copied");
|
||||
button.innerHTML = state;
|
||||
delete _fadeCopyCodeblocksRunners[commandId];
|
||||
}, 3000);
|
||||
});
|
||||
|
@ -336,6 +336,9 @@ en:
|
||||
tomorrow_with_time: "tomorrow at %{time}"
|
||||
at_time: "at %{date_time}"
|
||||
existing_reminder: "You have a reminder set for this bookmark which will be sent"
|
||||
|
||||
copy_codeblock:
|
||||
copied: "copied!"
|
||||
|
||||
drafts:
|
||||
resume: "Resume"
|
||||
|
Loading…
Reference in New Issue
Block a user