├── README.md ├── file.js └── index.html /README.md: -------------------------------------------------------------------------------- 1 | The distraction free writing tool I use for all my writing. 2 | 3 | You can try it here: https://www.gibney.org/writer 4 | 5 | It is simply a centered textarea on an empty html page. 6 | 7 | This creates a couple of nice features for free: 8 | 9 | - Hit F11 and the whole screen is just the writer. 10 | 11 | - The font size can be change with ctrl+ and ctrl- 12 | 13 | - The textarea can be resized with the mouse and 14 | by moving its lower right corner. 15 | While resizing it, it stays centered. 16 | 17 | Load and Save buttons will appear when you move the mouse 18 | to the upper left corner of the screen. 19 | 20 | Currently, loading and saving is a but cumbersome as it 21 | uses the download/upload functionality of the browser. 22 | It could be made more convenient by using the filesystem 23 | access api: https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API 24 | 25 | License: GNU General Public License, version 2 26 | -------------------------------------------------------------------------------- /file.js: -------------------------------------------------------------------------------- 1 | export let filename = 'new_file.txt'; 2 | 3 | export function save(text) { 4 | const link = document.createElement('a'); 5 | link.setAttribute( 6 | 'href', 7 | 'data:text/plain;charset=utf-8,' 8 | + encodeURIComponent(text) 9 | ); 10 | link.setAttribute('download', filename); 11 | 12 | if (document.createEvent) { 13 | var evnt = document.createEvent('MouseEvents'); 14 | evnt.initEvent('click', true, true); 15 | link.dispatchEvent(evnt); 16 | } 17 | else { 18 | link.click(); 19 | } 20 | } 21 | 22 | export async function load() { 23 | return new Promise((resolve, reject) => { 24 | const el = document.createElement('input'); 25 | el.type = 'file'; 26 | el.addEventListener('change', function() { 27 | var fr=new FileReader(); 28 | fr.onload=function() { 29 | resolve(fr.result) 30 | filename = el.files[0].name; 31 | } 32 | fr.readAsText(this.files[0]); 33 | }) 34 | el.click(); 35 | }) 36 | } 37 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 |