Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _fileInputOnChange = (): void => {
const { roosterCommandBarPlugin, imageManager } = this.props;
const editor: Editor = roosterCommandBarPlugin.getEditor();
const file = this._fileInput.files[0];
if (editor && !editor.isDisposed() && file) {
if (imageManager) {
const placeholder = imageManager.upload(editor, file);
editor.insertNode(placeholder);
editor.triggerContentChangedEvent(ChangeSource.Format);
editor.addUndoSnapshot();
} else {
insertImage(editor, file);
}
this._fileInput.value = "";
}
};
document.getElementById('selectFile').addEventListener('change', function() {
let input = document.getElementById('selectFile') as HTMLInputElement;
let file = input.files[0];
if (file) {
insertImage(getCurrentEditor(), file);
input.value = '';
}
});
fileInput.addEventListener('change', () => {
let file = fileInput.files[0];
if (file) {
insertImage(editor, file);
}
});
document.body.appendChild(fileInput);