Git Product home page Git Product logo

hilarious-text-editor's People

Contributors

elidupree avatar idupree avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

elidupree

hilarious-text-editor's Issues

Needs Readme :)

I managed to launch it, but how do I do all the other things?

A Readme could tell me :)

fix undo with switching files

Apparently browsers keep programmatic changes to a textarea in the textarea's undo history. At least some of them. Firefox does; Chromium doesn't. (Testing on Linux - there could well be OS differences too.)

There's no API to change a textarea's undo history. (Unless my Google-fu failed me;. I found a 2012 draft of an undo api but no evidence it made it into any spec or implementation.) However you can possibly create another textarea and delete the old textarea to clear the undo history (or at any rate, that would likely prevent the undo history from doing catastrophically wrong things). On Firefox, programmatically changing the textarea could be used to initialize an undo history, but that doesn't seem cross-browser enough to bother. (Particularly since Firefox is not a great browser to use with this editor, due to a reflow issue with Firefox, and since Dragon seems to work best with IE. It's possible IE also behaves this way, in which case it might be worth doing.) In any case, I don't want things to be more broken than they have to be on Firefox, so that means creating each new textarea with its initial contents already in it so that you can't undo yourself to an empty file by accident and delete all your work. For example, I can do this by something along the lines of createElement('div').innerHTML = '<textarea>'+escape(textareaContents)+'</textarea>'.

The undo stack is per-textarea in Firefox, but per the entire page in Chromium. In Chromium, when you undo, it focuses the textarea that you are undoing in, and makes the change. Except that if that textarea is display:none at the time, then it makes no change instead. This means you can generate infinite text by

  1. type something in a textarea
  2. make the textarea display:none
  3. undo (Ctrl-Z)
  4. make the textarea display:block
  5. redo (Ctrl-Shift-Z)
  6. go to step 2 (unless bored)
  7. profit???

This issue also means the Firefox textarea-reflowing workaround maybe should be scrapped, because the workaround messes up the undo history in Firefox. Instead, make the textarea longer-than-necessary just in case, and warn the user that the line numbers may be wrong sometimes (particularly if the user has verrrry long lines, but even a single wrapped line is occasionally enough to cause this problem depending exactly where the spaces are in the line and depending on luck.)

I've found no way to detect the problem programmatically. Firefox is too confused to adjust scrollHeight to be the abnormally large height that it needs to be when this happens, and it doesn't happen in the same way in the #testline textarea. TODO: create textcase and submit to moz bugzilla; searching https://www.google.com/search?q=textarea+reflow+scrollHeight+site%3Abugzilla.mozilla.org didn't find any that appeared relevant.

Page Down in textarea behaves oddly

It scrolls all the way down, rather than just one page down, at least with Firefox Linux keyboard PageDown and IE Dragon pagedown. Mirror problem with PageUp.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.