[dokuwiki] Entity expansion in JS

  • From: TNHarris <telliamed@xxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sat, 23 Oct 2010 15:18:51 -0400

With the shortcomings of entities in DW (Can't use them in headlines, link titles, etc. They're not expanded in metadata.), I think a more useful way to insert entities would be on the browser-side. (Does FCKW do this already?)


I've made a quick autocomplete script to do simple substitutions. Conversion happens when you type a key that isn't part of an entity. Typing Shift+Space will add a space without converting. And it's supposed to undo the last conversion when you press Escape, but that only worked for me in Windows. So there's still a lot of work to do, and there may be a better way. But javascript is one of my weaknesses. I'm hoping that someone with more skill can take over. And there's there's the matter of changing quotes as well.

What would be helpful is to popup an autocomplete box with the entity values. Then you can see what will be inserted, or press Escape to cancel, or click an entity when there's more than one option. (Typing -- will show both en-dash and em-dash.) But I have no idea how to get the absolute position of the cursor in a textarea. I found a code snippet[1] that measures the size of a text selection, but it can't see inside a textarea.

Another feature I've considered is a recently-used list in the character picker. That's easy to do and I'll have a patch for it by Monday or Tuesday. (Add a div and clone the clicked button into it. And a bit of housekeeping to keep the MRU list short.)

[1] http://stackoverflow.com/questions/2031518/javascript-selection-range-coordinates

--
- tom
telliamed@xxxxxxxxxxxxx
Title: Test

Other related posts: