apostrophecms / apostrophe

A full-featured, open-source content management framework built with Node.js that empowers organizations by combining in-context editing and headless architecture in a full-stack JS environment.
https://apostrophecms.com
MIT License
4.36k stars 590 forks source link

Limit Amount of a Widget Type in an Area #4655

Open LeviticusMaximus opened 3 months ago

LeviticusMaximus commented 3 months ago

I know I can limit the number of widgets in an area with

main: {
  type: 'area',
  options: {
    widgets: {
      '@apostrophecms/rich-text': {},
      '@apostrophecms/image': {},
      '@apostrophecms/video': {}
    },
    max: 3
  }
}

but is there any way to limit the amount of any specific widget in that area? e.g.

main: {
  type: 'area',
  options: {
    widgets: {
      '@apostrophecms/rich-text': {},
      '@apostrophecms/image': {},
      '@apostrophecms/video': {
          max: 1 // 👈 this puppy here means only one video widget in this area
      }
    },
    max: 3
  }
}

I know I could make another area, but the order of areas in the page is still fixed; this feature would allow users to re-organise the area content avoiding this fixed-layout problem.

boutell commented 3 months ago

Currently this is not possible. I am curious what the use case would be for the feature? e.g. what is the specific scenario where you want to let people freely add a mix of widgets, but limit the number of each type separately?