Creating a simple web-based text editor with HTML, CSS, and JavaScript that supports copying text and sharing it via URL fragments (using #) is definitely doable. However, supporting 10GB of text in-browser is practically impossible due to browser memory and performance constraints—most browsers cannot handle multi-gigabyte data in memory efficiently.
That said, I can help you build a lightweight text editor that lets you type, copy content, and encode/decode the content into the URL fragment (after #) for sharing. The URL length is practically limited (usually to a few thousand characters), so this works well only for smaller texts.
Features
Edits text in a <textarea>
Updates the fragment identifier (location.hash) with the base64-encoded text content
On page load, restores text from URL fragment if available
Copy button to copy the text to clipboard
Example Code
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Simple Text Editor with Shareable URL</title>
<style>
body {
margin: 0;
font-family: sans-serif;
display: flex;
flex-direction: column;
height: 100vh;
}
textarea {
flex-grow: 1;
padding: 10px;
font-family: monospace;
font-size: 1em;
border: none;
resize: none;
outline: none;
}
.toolbar {
padding: 10px;
background: #eee;
display: flex;
gap: 10px;
}
button {
padding: 6px 12px;
font-size: 1em;
cursor: pointer;
}
</style>
</head>
<body>
<div class="toolbar">
<button id="copyBtn">Copy Text</button>
<button id="shareBtn">Update URL to Share</button>
</div>
<textarea id="editor" placeholder="Type or paste text here..."></textarea>
<script>
const editor = document.getElementById('editor');
const copyBtn = document.getElementById('copyBtn');
const shareBtn = document.getElementById('shareBtn');
// Helper: encode text to base64 unicode-safe
function encodeBase64Unicode(str) {
// https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#unicode_category
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
(match, p1) => String.fromCharCode('0x' + p1)));
}
// Helper: decode from base64 unicode-safe
function decodeBase64Unicode(str) {
try {
return decodeURIComponent(atob(str).split('').map(c =>
'%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
).join(''));
} catch {
return '';
}
}
// Restore content from URL fragment on load
function restoreFromHash() {
const hash = location.hash.slice(1);
if (hash) {
const text = decodeBase64Unicode(hash);
if (text) {
editor.value = text;
}
}
}
// Copy text to clipboard
copyBtn.addEventListener('click', () => {
navigator.clipboard.writeText(editor.value)
.then(() => alert('Text copied to clipboard!'))
.catch(() => alert('Failed to copy text.'));
});
// Update URL fragment to share current text
shareBtn.addEventListener('click', () => {
try {
const encoded = encodeBase64Unicode(editor.value);
// Consider user/browser max URL length limit (~2000 chars safe)
if (encoded.length > 2000) {
alert('Text too long to share via URL fragment.');
return;
}
location.hash = encoded;
alert('URL updated! You can share this link.');
} catch {
alert('Failed to encode text for URL.');
}
});
// Optionally auto-save changes to URL fragment (commented out because it might cause performance issues)
/*
editor.addEventListener('input', () => {
try {
const encoded = encodeBase64Unicode(editor.value);
if (encoded.length < 2000) {
history.replaceState(null, '', '#' + encoded);
}
} catch {}
});
*/
restoreFromHash();
</script>
</body>
</html>
How it works
When you open the page, it looks at the URL fragment after #, decodes it, and puts the text into the editor.
Press "Copy Text" to copy the editor content to clipboard.
Press "Update URL to Share" to encode the current text and place it into the URL fragment.
Then you can copy the page URL and share it; opening it reconstructs the text.
Limitations
URL Length: Browsers restrict URL length (~2000 - 8000 characters). This restricts text size to roughly a few KB.
Memory & Performance: Encoding/decoding large text in base64 and storing in URL will degrade performance.
No persistent storage: Refreshing page with no hash will clear the editor.
If you want a more full-featured text editor with persistent storage (localStorage) or file import/export support, or syncing large text files between computers, that would require backend services or advanced File APIs and isn't feasible purely with URL fragments.
Let me know if you'd like help with such features!