Live data from Hacker News

Trix: A rich text editor for everyday writing

github.com

91–100 of 137 posts

Re: Trix: A rich text editor for everyday writing

#91
200kb for css+js

have fun with that on mobile where like all browsers, javascript is single threaded

the reason why we use contenteditable is that it can be done in 15kb and the browser can do it natively, then you just clean up the resulting code on the backend

Re: Trix: A rich text editor for everyday writing

#94
Looks decent. The approach taken is the right one: we do something very similar with the Squire rich text editor (https://github.com/neilj/Squire) which I wrote for FastMail's webmail. Basically the browser can't be trusted to do any formatting itself, which is a slightly depressing state of affairs, especially as there has been zero improvements in this area for the last 5 years. I guess it's not shiny enough for browser devs to focus on.

Looking through the code, a few things jumped out that should be looked at:

* Native TreeWalker implementations are buggy in some browsers. In the end we decided it was safer to just implement the bit we needed ourselves (see comment at top of https://github.com/neilj/Squire/blob/master/source/TreeWalke...).

* The HTML sanitisation using document.implementation doesn't account for DOM clobbering so is currently bypassable with the right malicious content. I recommend using https://github.com/cure53/DOMPurify for this rather than writing your own. It's tricky to get all the edge cases right, so better to use something that's been reviewed by several people (and in DOMPurify's case also undergone a formal security review). Again, we use this at FastMail as part of our webmail.

Re: Trix: A rich text editor for everyday writing

#95
post #48
post #46

Earlier quoted context omitted.

Isn't CoffeeScript the " Macro -assembler" of JavaScript? i.e. a simple 1:1 syntax mapping, without no differentiating semantics of its own. Or am I wrong?

It's neither a subset nor a superset of JavaScript. It's a language that isn't JavaScript that is compiled to JavaScript. There are to-JavaScript compilers for many languages now including Scala, Kotlin, Clojure and more. Maybe people who write CoffeeScript as part of some public thing consider themselves to be part of a JavaScript project, but I wouldn't.

You know that "languages that compile to JavaScript" (thanks for not using the word "transpiled", btw) include JavaScript? Babel, Traceur - does it ring a bell? Would you argue that their users are not a "part of JavaScript"? What about TypeScript (it's just an implementation of some ES6 features + a powerful linter)?

Coffee is just a set of syntactic improvements (well, it's debatable - let's say "syntactic changes") over JavaScript. JS is too weak a language to implement this syntactic sugar inside of it, so there is a need for an external tool. But if you take a look at any Lisp, you'll see that people are building syntactic abstraction inside a language and that it doesn't make their code "a different language compiled to (their kind of) Lisp".

This is not to say that everything compiled down to JS is still JS. But the difference is quite neatly explained in Mathias Felleisen great paper: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.51.4... All that Coffee does are local transformations, equivalent to what you could do with Lisp or Nim or Dylan macros.

[EDIT: removed the "soooo cute" opening sentence, as it was brought to my attention that it distracted readers]

Re: Trix: A rich text editor for everyday writing

#96
post #48

Earlier quoted context omitted.

It's neither a subset nor a superset of JavaScript. It's a language that isn't JavaScript that is compiled to JavaScript. There are to-JavaScript compilers for many languages now including Scala, Kotlin, Clojure and more. Maybe people who write CoffeeScript as part of some public thing consider themselves to be part of a JavaScript project, but I wouldn't.

You know that "languages that compile to JavaScript" (thanks for not using the word "transpiled", btw) include JavaScript? Babel, Traceur - does it ring a bell? Would you argue that their users are not a "part of JavaScript"? What about TypeScript (it's just an implementation of some ES6 features + a powerful linter)? Coffee is just a set of syntactic improvements (well, it's debatable - let's say "syntactic changes"…

> Soooo cute...

I stopped reading your reply after this. Just FYI, HN doesn't condone bad attitudes. You'll end up getting hell banned.

Having said that, my down-voted comments are factual. They are not incorrect, they were down voted by people who have strong emotions about CoffeeScript.

True or false? All the statements below are true.

Trix is writen in CoffeeScript?

CoffeeScript is not superset or a subset of JavaScript?

Are there other languages that compile to JavaScript?

I don't consider projects written in CoffeeScript JavaScript projects?

I gave simple statements of fact that were not incorrect, and they got down voted and emotional replies.

Re: Trix: A rich text editor for everyday writing

#97
It reminds me of Prosemirror: "By strictly separating its document data structure from the browser's DOM, ProseMirror sidesteps most of the mess that is contentEditable, and ensures that the document stays entirely under the control of the editor." http://prosemirror.net/

Re: Trix: A rich text editor for everyday writing

#98
post #73

I don't get these simplistic editors. You just have to learn ten HTML tags to do the formatting these editors offer. What would be useful though, would be an editor that supported "design" and not just text.

This isn't meant to replace something like say vim, or perhaps dream weaver. Instead, I believe this is for people who want to make it easy for casual users to format text in a comment or what not.

Re: Trix: A rich text editor for everyday writing

#100
post #90
post #80

Earlier quoted context omitted.

hahaha… oh god. This place is such an echo chamber…

Is "what would be useful is an editor that supports design" an echo chamber? Mightbe pretty hard to do right, but not an ordinary idea. About rich text editors, since there are so many editors (even native) that lag on input I have just assumed that is something that only I care about.

Probably more the "You just have to learn a few HTML tags", which reminded me (since it was quoted in another discussion today) of the comment about Dropbox saying that it was trivial to replicate by getting FTP space, mounting it using some tool and running SVN on top.

EDIT: https://news.ycombinator.com/item?id=10412530

Post reply on HN