[TYPO3-core] RFC: #16667: Bug: t3editor: typed text does not get replaced correctly by code completion on left side

Tobias Liebig mail_typo3 at etobi.de
Mon Dec 20 21:21:19 CET 2010


Am 19.12.2010 um 12:04 schrieb Stephan Petzl:

> Am 19.12.10 08:55, schrieb Jigal van Hemert:
>> On 18-12-2010 15:52, Stephan Petzl wrote:
>>> ...
>> 
>> It feels like when the documentation is loaded the selection gets lost.

right. it feels like its related to the description loading, but i just debugged that and actually it is not.


>> 
> 
> Hi Jigal!
> I honestly have to say, that I'm not 100% looking through myself. The complicated thing is, that there is a asynchronous script running in the background, which parses the typoscript (aka tokenization) and puts each token in a separate span tag.
> That's why the behaviour of the replacement depends on the point in time where you press return.
> 
> After some trial-and-error i figured out that, "mirror.replaceSelection(word)" gives this inconsistent behaviour, so I replaced it with "cursorNode.innerHTML = word;".
> the if-else switch is needed because otherwise inserting directly after a "." would replace the ".", so we still use mirror.repaceSelection to insert the word.
> 
> Tobias Liebig has a better insight in the codemirror API (he is the one who initially wrote the codemirror typoscript extension), maybe he could add some more explanations here...

Stephans explantation is correct.
mirror.replaceSelection depends on if the given node is already "parsed" by the asynchronous highlighting or not.
But cursorNode holds a "reference" to the actual dom node, which is still valid after the highlighting (wrapping with <span>-tags) happens.

So replacing the nodes innerHTML works fine in this case.

regards
  tobias



More information about the TYPO3-team-core mailing list