qwqoffice / html2wxml

用于微信小程序的HTML和Markdown格式的富文本渲染组件,支持代码高亮
https://www.qwqoffice.com/article.php?mod=view&tid=40
GNU General Public License v2.0
231 stars 86 forks source link

markdown 的代码块,q请求加个复制按钮 #31

Open ZhangLe1993 opened 2 years ago

Lxb921006 commented 6 months ago

我是改了大佬源码实现了,求指点 在html2xml.wxml 113行添加 `

code 点击复制

**html2xml.js** copyMdCode(e) { console.log(e); let that = this; let dt = e.currentTarget.dataset.copy; let res = this.getText(dt); wx.setClipboardData({ data: res, success: function (res) { that.setData({ textCopy: "点击复制" }); } }) }, getText(data) { let text = ''; for (let i = 0; i < data.length; i++) { if (data[i].text) { text += data[i].text; } if (data[i].nodes && data[i].nodes.length > 0) { text += this.getText(data[i].nodes); } } return text; }, },`

Lxb921006 commented 6 months ago

111 效果展示