Skip to content

Commit

Permalink
add withExtendedDropzone method to content element builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Fabel authored and Oliver Fabel committed Aug 3, 2022
1 parent f829515 commit 89fbeec
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/content-element/content-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export default class ContentElement extends AbstractBuilder {
}

/**
* Define the dropzones of this include.
* Define the dropzones of this content element.
*
* @example
* .withDropzones(
Expand All @@ -338,14 +338,36 @@ export default class ContentElement extends AbstractBuilder {
* require('./content-elements/basic/text'),
* require('./content-elements/basic/image'))
* .withMaxAllowedElements(1))
* @param {...Dropzone} dropzones - The dropzones of this include.
* @param {...Dropzone} dropzones - The dropzones of this content element.
* @returns {ContentElement}
*/
withDropzones(...dropzones) {
this._dropzones = dropzones;
return this;
}

/**
* Extend the allowed elements list of a defined dropzone.
*
* @example
* .withExtendedDropzone(
* 'a5142bca-448b-40c5-bdde-942f531fcd12',
* require('./content-elements/basic/text'),
* require('./content-elements/basic/image'))
* @param {string} id - The ID of the dropzone to extend (set with {@link Dropzone#withDropzone}).
* @param {...ContentElement} elements - The elements to add to the allowed elements list.
* @returns {ContentElement}
*/
withExtendedDropzone(id, ...elements) {
let dropzone = this._dropzones?.find(dropzone => dropzone.dropzone === id);

if (dropzone) {
dropzone.withAllowedElements(...dropzone.allowedElements, ...elements);
}

return this;
}

isCompatible() {
return super.isCompatible() && !this._hasIncompatibleParts();
}
Expand Down

0 comments on commit 89fbeec

Please sign in to comment.