[TYPO3-core] RFC: #16667: Bug: t3editor: typed text does not get replaced correctly by code completion on left side
Stephan Petzl
spetzl at gmx.at
Sun Dec 19 12:04:09 CET 2010
Am 19.12.10 08:55, schrieb Jigal van Hemert:
> On 18-12-2010 15:52, Stephan Petzl wrote:
>> This bug only occures when you wait for some seconds before pressing
>> return.
>
>> Solution: distinguish between replacing and inserting text at the
>> cursor position. see patch for details.
>
> Thanks for your patch. It works, but can you please explain a bit more?
> - why does it only happen after a few seconds (at first the code seems
> to handle the replacement correctly, but then something happens which
> prevents the typed text from being replaced)
>
> It feels like when the documentation is loaded the selection gets lost.
>
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...
--
Best Regards
Stephan Petzl
http://www.ajado.com
More information about the TYPO3-team-core
mailing list