return instances.get(element);
}
-export function getCkeditorById(id: string): Ckeditor | undefined {
+export function getCkeditorById(id: string, throwIfNotExists = true): Ckeditor | undefined {
const element = document.getElementById(id);
if (element === null) {
- throw new Error(`Unable to find an element with the id '${id}'.`);
+ if (throwIfNotExists) {
+ throw new Error(`Unable to find an element with the id '${id}'.`);
+ } else {
+ return undefined;
+ }
}
return getCkeditor(element);
* Destroys the editor instance.
*/
protected _destroyEditor(): void {
- void getCkeditorById(this._getEditorId())!.destroy();
+ void getCkeditorById(this._getEditorId(), false)?.destroy();
}
/**
return instances.get(element);
}
exports.getCkeditor = getCkeditor;
- function getCkeditorById(id) {
+ function getCkeditorById(id, throwIfNotExists = true) {
const element = document.getElementById(id);
if (element === null) {
- throw new Error(`Unable to find an element with the id '${id}'.`);
+ if (throwIfNotExists) {
+ throw new Error(`Unable to find an element with the id '${id}'.`);
+ }
+ else {
+ return undefined;
+ }
}
return getCkeditor(element);
}
* Destroys the editor instance.
*/
_destroyEditor() {
- void (0, Ckeditor_1.getCkeditorById)(this._getEditorId()).destroy();
+ void (0, Ckeditor_1.getCkeditorById)(this._getEditorId(), false)?.destroy();
}
/**
* Returns the hash added to the url after successfully editing a message.