This commit is contained in:
Zsolt Viczian
2021-08-02 20:34:56 +02:00
parent 21ff1833a8
commit 2e36d83abc
6 changed files with 40 additions and 25 deletions

View File

@@ -399,18 +399,16 @@ export class ExcalidrawData {
return this.textElements.get(id)?.parsed;
}
public setTextElement(element:ExcalidrawTextElement, rawText:string, updateScene:Function):string {
public setTextElement(elementID:string, rawText:string, updateScene:Function):string {
const parseResult = this.quickParse(rawText); //will return the parsed result if raw text does not include transclusion
if(parseResult) { //No transclusion
this.textElements.set(element.id,{raw: rawText,parsed: parseResult});
this.textElements.set(elementID,{raw: rawText,parsed: parseResult});
return parseResult;
}
//transclusion needs to be resolved asynchornously
this.parse(rawText).then((parsedText:string)=> {
this.textElements.set(element.id,{raw: rawText,parsed: parsedText});
if(parsedText && element.text!=rawText) {
updateScene();
}
this.textElements.set(elementID,{raw: rawText,parsed: parsedText});
if(parsedText) updateScene(parsedText);
});
return null;
}