Closed zyxue closed 8 years ago
simpleeditor uses a customized simple mode for ace editor, http://xkcd.com/simplewriter/ace/src-min/mode-upwriter.js in order to do the highlighting.
It looks Ace only supports highlighting. Inserting tags could be difficult. I am looking at an promising alternative solution now, https://facebook.github.io/draft-js/
I'm not sure whether putting the pinyin in with the editor will be helpful or not. I'm trying to imagine what it would be like to edit Chinese text with the pinyin mixed in. On the other hand, I really like the simplicity of a "one box" interface.
If you can find an easy way to do it with the highlighted Chinese text in one box and the pinyin in a separate box as it is now, that might be a good way to start.
If you can find an easy way to do it with the highlighted Chinese text in one box and the pinyin in a separate box as it is now, that might be a good way to start.
Pinyin in a separate box? I am not sure what that would be like. I think draftjs is quite promising. Let dig a little deeper.
I just meant the way we have it now: one box where you type Chinese text and a second box where you display the Chinese text with pinyin. The only change would be to put the frequency colouring on the box where you type. If draftjs looks promising, then carry on.
I have put a prototype with three elements all together at the draftjs branch. Most of the code in PinyinCushionEditor.js are removed. There is also conflicts with the master branch, so I haven't merged them yet. Overall, it looks neat.
<rt>
tagsIt looks way simpler that way, nice work! The cursor selection problem also seems to affect the home and end keys. Also, I can't override the pronunciation. It looks promising, though.
Thanks. I am still not sure if I used the right feature for of Draftjs for our purpose. Currently, I am using Decorators, but it seems that [Custom Block Components](maybe https://facebook.github.io/draft-js/docs/advanced-topics-block-components.html#content) can also do the job, I am experimenting.
BTW, it's good to know it affects home and end keys, I don't have those two keys on my laptop.
It looks that Custom Block Components may not be appropriate as it's mainly for block-like content, Ruby text may not fit very well. so will focus on Decorators and try to fix the selection problem.
Haven't found a solution yet, filed an issue on https://github.com/facebook/draft-js/issues/717
Will put Pinyin in the display for now.
I tried out the version on the colorbg branch, and it looks nice. Here are a couple of suggestions before we close this issue:
Hi @donkirkby, I have fixed the two problem, you could take a look and see if it's good to merge now.
Looks great, merge that baby!
Seems ace cannot be used directly with webpack or browserify, need to use brace instead