Returns file content for lastly called text


#1

HI,

I am calling Stackedit to pass the formatted text and get the respective html text. Example passing three component texts in each call. In that case in fileChange event it always returns the text for the last call only.

In react I am using like this:

const GetFormattedText = (text: string, name: string) => {
// console.log(name, text); <— using unique name for file like ‘file1’, ‘file2’ and ‘file3’ as per the call.
stackedit.openFile({
name: name,
content: { text: text }
}, true);
}

useEffect(() => {
stackedit.on(‘fileChange’, (file: any) => {
console.log(file); <— It always returns only for ‘file3’ (‘Sample text3’ ) in all three call.
setFormattedText(file.content.html);
});
}, [text, language]);

// — calling the functions here like:
GetFormattedText(‘Sample text1’, ‘file1’);
GetFormattedText('Sample text2, ‘file2’);
GetFormattedText(‘Sample text3’, ‘file3’);

Could some one please let me know how I can get the content for each call differently in fileChange event?

Thanks in advance.