Class LayoutStylingService

java.lang.Object
io.meeds.layout.service.LayoutStylingService

@Service public class LayoutStylingService extends Object
Writes a styling description onto a layout element exactly as the editor's styling inputs do, the inverse of LayoutDescriptionService.toStyling: the vocabulary is checked block by block against the destination's matrix before a field is written; a block, a text role or a text background the call leaves null is not written at all, a block whose enabled flag is false clears its fields, and a value outside the vocabulary is refused naming its path. A caller that keeps an element merges the call's description over the element's stored one first (merge(StylingDescription, StylingDescription, boolean)), so a value left null inside a block it turns on keeps what the element holds; the one block the merge restates on its own is a solid background with a scroll colour on an element that stops being sticky. Images are not written here: an image block is accepted only when it repeats the image the element already holds, which then stays as stored.
  • Field Details

  • Constructor Details

    • LayoutStylingService

      public LayoutStylingService()
  • Method Details

    • merge

      public static StylingDescription merge(StylingDescription stored, StylingDescription input, boolean sticky)
      The description a call means for a kept element: a block the call leaves null stays null, so the element keeps it untouched; a block it turns off is off; a block it sends without the flag is on; and inside a block it turns on every value it leaves null is the stored value, a text role, a padding side or a corner included. A stored gradient's effect is kept only while the call names neither a mode nor a colour, and a stored scroll colour only while the element stays sticky and solid: a solid background left untouched on an element that stops being sticky is restated without its scroll colour, as the editor does.
      Parameters:
      stored - the element's stored description, as the read answers it
      input - the call's description, null for every block untouched
      sticky - whether the element is sticky after the call
      Returns:
      the description to write
    • applyStyling

      public void applyStyling(LayoutModel target, StylingDescription styling, StylingDestination destination, boolean sticky, boolean plainColorOnly)
      Parameters:
      target - the element written
      styling - the blocks, null for every block untouched
      destination - the element's place in the matrix
      sticky - whether the element is a sticky site container, the only one with a scroll colour
      plainColorOnly - whether the background takes a plain colour only, as the editor offers on a topbar
    • applyStyling

      public void applyStyling(LayoutModel target, StylingDescription styling, StylingDestination destination, boolean sticky, boolean plainColorOnly, ImageConsumption images) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Parameters:
      target - the element written
      styling - the blocks, null for every block untouched
      destination - the element's place in the matrix
      sticky - whether the element is a sticky site container, the only one with a scroll colour
      plainColorOnly - whether the background takes a plain colour only, as the editor offers on a topbar
      images - the call's image consumption, on which a block carrying an image_upload_id claims its id; the placeholder it answers stands in the image fields until the attachment is saved
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when an image_upload_id names no staged upload
    • applyDisplay

      public void applyDisplay(LayoutModel target, DisplayMode display, StylingDestination destination, String refusal)
      Parameters:
      target - the element written
      display - the device visibility, null to leave it as it is
      destination - the element's place in the matrix
      refusal - the text answered when the destination does not offer the choice
    • strip

      public static String strip(String cssClass, Pattern tokens)
    • append

      public static String append(String cssClass, String token)