Closed danielearwicker closed 11 years ago
Have gone with first solution as requires reliable HTML generation/parsing such that Carota's content can be round-tripped perfectly without interference from browser-specific contentEditable implementation, which is unlikely (and that's the whole point of writing your own editor).
One (harmless) quirk of chosen solution is that you can copy rich text in Carota, paste it into Notepad, copy it from Notepad and then paste it into Carota, and it appears to have round-tripped the rich formatting (though really it has just noticed that it has a richer alternative for the plain text and so substituted it).
Ctrl+C copies from hidden textarea (HTA), which is plain text. Ctrl+V copies back to HTA, also plain text. This means we cannot round-trip rich text.
Solution: when updating HTA with plain text, also store corresponding runs and plain text in variables. When accepting input from HTA, compare it with stored plain text. If the same, use the stored runs instead.
OR... solution 2: instead of HTA have a DIV with contentEditable=true (sweet, sweet irony). Would also need to implement scanning function that generates runs from DOM tree, and vice versa, but they'd be useful anyway.