+
File Name: ${fileInfo.name}
${Object.entries(fileInfo.references).map(([key, ref]) => {
- // 对HTML代码进行编码,用于存储在data-copy属性中
const encodedCode = ref.code.replace(/"/g, '"').replace(/'/g, ''');
let htmlEncoded = false;
- // 考虑修复HTML代码问题
if (ref.label.includes('HTML')) {
htmlEmbedCode = ref.code;
htmlEncoded = true;
}
return `
-
-
-
${ref.label}
+
+
- ${htmlEncoded ? '
' :
- '
'+ref.code+'
'}
+ ${htmlEncoded ?
+ '
' :
+ '
'+ref.code+'
'
+ }
`;
@@ -156,26 +153,21 @@ function createCopyDialog(fileInfo) {
`;
- // Handle copy button clicks
dialog.addEventListener('click', async (e) => {
- const copyButton = e.target.closest('button[data-copy]');
+ const copyButton = e.target.closest('.imgfans-extension-copy-button');
if (copyButton) {
- const code = copyButton.dataset.copy;
try {
- // 解码HTML内容
const code = copyButton.dataset.copy.replace(/"/g, '"').replace(/'/g, "'");
await navigator.clipboard.writeText(code);
- // Update button content to show copied state
const originalContent = copyButton.innerHTML;
copyButton.innerHTML = `
-