Closed sajozsattila closed 11 months ago
Well, what is your exact question?
In my version of code every instance of ParserCollection corresponds to an editor. If you have several editors on a single page, you have to instantiate several parser collections and supply every parser collection with its own ImageLoader instance.
Unfortunately, it is not true. Because of the debounce. When you have multiple ParseCollection you can use an example:
var imageLoader1 = New ImageLoader();
var imageLoader2 = New ImageLoader();
var parserCollection1 = new parserCollection ( .. imageLoader1 ... )... ;
var parserCollection2 = new parserCollection ( .. imageLoader2 ... )... ;
// make update
parserCollection1.updateResult();
parserCollection2.updateResult();
The above is work.
But if you do:
varupdateText1=debounce(parserCollection1.updateResult,300,{maxWait: 3000});
varupdateText2=debounce(parserCollection2.updateResult,300,{maxWait: 3000});
Some reason the varupdateText1 will use the parserCollection2 imageLoader.
Other problem with the multiple parserCollection: the ImageLoader have hardcoded prefix ('s2tex_'), which make so you are ending up with multiple 'id="s2tex_0"' etc. in your page. And as you use ID to load them in the utils:
function insertPicture(index, svg, baselineShift, mode) {
var id = 's2tex_' + index,
oldSvgNode = document.getElementById(id),
So probably could be a good idea, if you add a prefix setting possibility to the ImageLoader.
Unfortunately, I haven't had a chance to look at the problem until now. Maybe I'll come back to it if I do some refactoring. For now, I'm closing the issue as outdated. If there was a pull-request with a possible solution, I'd love to see it and accept it.
When having multiple parserCollection on one page the ImageLoader in the parserCollection is always the last which was initialized. The reason for this I belive the:
In my project, I have worked around the issue with rewriting the updateResult:
And I pass the ImageLoader every time to the:
See (search for updateMain )