fix: adds a check in the tinymce blockpicker plugin to ensure the entries context is available and if not to warn about it, since the whole plugin does not work without it

This commit is contained in:
Jacob Overgaard
2024-09-10 17:16:27 +02:00
parent 859276680f
commit e96e1ff2b4

View File

@@ -59,14 +59,19 @@ export default class UmbTinyMceMultiUrlPickerPlugin extends UmbTinyMcePluginBase
}
#createBlock() {
if (!this.#entriesContext) {
console.error('[Block Picker] No entries context available.');
return;
}
// TODO: Missing solution to skip catalogue if only one type available. [NL]
let createPath: string | undefined = undefined;
if (this._blocks?.length === 1) {
const elementKey = this._blocks[0].contentElementTypeKey;
createPath = this.#entriesContext?.getPathForCreateBlock() + 'modal/umb-modal-workspace/create/' + elementKey;
createPath = this.#entriesContext.getPathForCreateBlock() + 'modal/umb-modal-workspace/create/' + elementKey;
} else {
createPath = this.#entriesContext?.getPathForCreateBlock();
createPath = this.#entriesContext.getPathForCreateBlock();
}
if (createPath) {