|
@@ -31,8 +31,9 @@ export const codeRender = (element: HTMLElement) => {
|
|
|
item.remove();
|
|
|
});
|
|
|
codeText = codeElement.innerText;
|
|
|
+ } else if (codeText.endsWith("\n")) {
|
|
|
+ codeText = codeText.substr(0, codeText.length - 1)
|
|
|
}
|
|
|
-
|
|
|
let iconHTML = '<svg><use xlink:href="#vditor-icon-copy"></use></svg>';
|
|
|
if (!document.getElementById("vditorIconScript")) {
|
|
|
iconHTML = '<svg viewBox="0 0 32 32"><path d="M22.545-0h-17.455c-1.6 0-2.909 1.309-2.909 2.909v20.364h2.909v-20.364h17.455v-2.909zM26.909 5.818h-16c-1.6 0-2.909 1.309-2.909 2.909v20.364c0 1.6 1.309 2.909 2.909 2.909h16c1.6 0 2.909-1.309 2.909-2.909v-20.364c0-1.6-1.309-2.909-2.909-2.909zM26.909 29.091h-16v-20.364h16v20.364z"></path></svg>';
|
|
@@ -43,7 +44,7 @@ export const codeRender = (element: HTMLElement) => {
|
|
|
divElement.innerHTML = `<span aria-label="${window.VditorI18n?.copy || "复制"}"
|
|
|
onmouseover="this.setAttribute('aria-label', '${window.VditorI18n?.copy || "复制"}')"
|
|
|
class="vditor-tooltipped vditor-tooltipped__w"
|
|
|
-onclick="this.previousElementSibling.select();document.execCommand('copy');this.setAttribute('aria-label', '${window.VditorI18n?.copy || "已复制"}')">${iconHTML}</span>`;
|
|
|
+onclick="this.previousElementSibling.select();document.execCommand('copy');this.setAttribute('aria-label', '${window.VditorI18n?.copied || "已复制"}')">${iconHTML}</span>`;
|
|
|
const textarea = document.createElement("textarea");
|
|
|
textarea.value = code160to32(codeText);
|
|
|
divElement.insertAdjacentElement("afterbegin", textarea);
|