Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 63852fe

Browse files
authored
Maybe fix for Windows?
1 parent fd9daf8 commit 63852fe

File tree

1 file changed

+20
-20
lines changed
  • paste-rich-text.html

1 file changed

+20
-20
lines changed

paste-rich-text.html

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
background-color: #f5f5f5;
3030
font-size: 16px;
3131
font-family: Helvetica, Arial, sans-serif;
32+
overflow: auto;
3233
}
3334

3435
#output-container {
@@ -93,7 +94,7 @@

Rich text HTML extractor

9394
<p>Copy formatted text from a webpage and paste here to extract the HTML:p>
9495

9596
<div id="paste-area" contenteditable="true">div>
96-
<p class="info-text">Paste using Ctrl+V or +V to capture the rich text HTMLp>
97+
<p class="info-text">Paste using Ctrl+V or +V to capture the rich text HTML. For best results on Windows, try pasting into word processors first.p>
9798

9899
<div id="output-container">
99100
<h2>HTML codeh2>
@@ -129,26 +130,25 @@

Preview

129130

130131
// Handle paste event to capture HTML
131132
pasteArea.addEventListener('paste', function(e) {
132-
// Get HTML data from clipboard
133-
const clipboardData = e.clipboardData || window.clipboardData;
134-
const pastedHtml = clipboardData.getData('text/html');
135-
136-
if (pastedHtml) {
137-
// Prevent default paste
138-
e.preventDefault();
139-
140-
// Display the HTML code with escaped characters
141-
htmlOutput.value = pastedHtml;
142-
143-
// Show the output container
144-
outputContainer.style.display = 'block';
145-
146-
// Show preview of how the HTML renders
147-
previewContent.innerHTML = pastedHtml;
133+
// Let the paste happen normally first
134+
setTimeout(() => {
135+
// Get current HTML content after the paste
136+
const pastedContent = pasteArea.innerHTML;
148137

149-
// Let user know paste was successful
150-
pasteArea.innerHTML = '

Content pasted. HTML extracted.

'
;
151-
}
138+
if (pastedContent) {
139+
// Display the HTML code with escaped characters
140+
htmlOutput.value = pastedContent;
141+
142+
// Show the output container
143+
outputContainer.style.display = 'block';
144+
145+
// Show preview of how the HTML renders
146+
previewContent.innerHTML = pastedContent;
147+
148+
// Let user know paste was successful
149+
pasteArea.innerHTML = '

Content pasted. HTML extracted.

'
;
150+
}
151+
}, 0);
152152
});
153153

154154
// Reset paste area when clicked

0 commit comments

Comments
(0)