Skip to content

feat: copy to clipboard for code blocks - #218

Open
zouyu4524 wants to merge 5 commits into
kitian616:masterfrom
zouyu4524:copy-to-clipboard
Open

feat: copy to clipboard for code blocks#218
zouyu4524 wants to merge 5 commits into
kitian616:masterfrom
zouyu4524:copy-to-clipboard

Conversation

@zouyu4524

@zouyu4524 zouyu4524 commented Oct 2, 2019

Copy link
Copy Markdown

Make code blocks copyable. Here is an example:

```python
def hello():
    print("Hello world!")
```
{: .copyable} 

which will look like this:
brightdark

If you don't need this feature for some code blocks, just write post as the original style.
(i.e., without {: .copyable} IAL tag)

@zouyu4524

zouyu4524 commented Oct 3, 2019

Copy link
Copy Markdown
Author

For those who might interest, here is a post introducing this PR. 😊(in Chinese)

@Yan2u

Yan2u commented Feb 7, 2020

Copy link
Copy Markdown

非常方便,感谢!😀

@Young-Lord

Copy link
Copy Markdown

bootcss 的 CDN 链接:clipboard: 'https://cdn.bootcdn.net/ajax/libs/clipboard.js/2.0.11/clipboard.min.js'

@Young-Lord

Young-Lord commented Jul 2, 2023

Copy link
Copy Markdown

另外,感觉你这个btn类太宽泛了,个人认为会影响到未来的其他功能或者被无关 CSS 污染,我这里是改用了copy-code-to-clipboard-button当类名
commit: Young-Lord/Young-Lord.github.io@c6e6abe Young-Lord/Young-Lord.github.io@22a8043
(另外一些小改动就是全部代码块默认显示、用 Toast 来防止“复制?”的提示导致凭空多出一个横向滚动条、_config.yml里的属性改成了copy_to_clipboard
(个人感觉这个 pr 还是破坏性太强了点……直接搬 demo 的代码不太好吧……)

Young-Lord added a commit to Young-Lord/Young-Lord.github.io that referenced this pull request Jul 2, 2023
Young-Lord added a commit to Young-Lord-Blogs/Blog-eu.org that referenced this pull request Jul 2, 2023
Young-Lord added a commit to Young-Lord/Young-Lord.github.io that referenced this pull request Jul 2, 2023
Young-Lord added a commit to Young-Lord-Blogs/Blog-eu.org that referenced this pull request Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants