Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

写入剪切板失败 #44

Closed
Liu8Can opened this issue Aug 4, 2024 · 4 comments
Closed

写入剪切板失败 #44

Liu8Can opened this issue Aug 4, 2024 · 4 comments

Comments

@Liu8Can
Copy link

Liu8Can commented Aug 4, 2024

网页版,转换完成后,点击复制按钮,并未能成功写入剪切板。
微信公众号排版编辑器v233

Google Chrome

版本 127.0.6533.73(正式版本) (64 位)

@jaywcjlove
Copy link
Owner

@Liu8Can 文章预览,全选 command + c 复制 我排查一下

jaywcjlove added a commit that referenced this issue Aug 4, 2024
@jaywcjlove
Copy link
Owner

@Liu8Can 问题已排除,js API 已过时的兼容问题,就使用最新的 API 吧

document.execCommand(`copy`);

github-actions bot pushed a commit that referenced this issue Aug 4, 2024
@wangdgui
Copy link

@Liu8Can 问题已排除,js API 已过时的兼容问题,就使用最新的 API 吧

document.execCommand(`copy`);

大佬这个复制后未能写入剪贴板的问题,可以更新镜像文件一下吗,我docker拉取了最新的镜像文件也存在这个问题

@jaywcjlove
Copy link
Owner

const htmlContent = dom.innerHTML;
navigator.clipboard
.writeText(htmlContent)
.then(() => {
toast.success(<div>复制成功!去公众号编辑器粘贴吧!</div>);
})
.catch((err) => {
toast.error(<div>{JSON.stringify(err)}</div>);
console.error('Failed to copy: ', err);
});
};

我测试过了没有问题可以复制的样子

@Liu8Can Liu8Can closed this as completed Dec 17, 2024
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

No branches or pull requests

3 participants