8000 Releases · Klehm/content-blocks-project · GitHub
[go: up one dir, main page]

Skip to content

Releases

v1.5.0

Choose a tag to compare

@Klehm Klehm released this 20 Oct 08:45
c9a2e82

This release lets a block bring its own CSS and JS, groups the add-block picker by category, tells a block view where and in which language it renders, can put the public CSS in a cascade layer, and lets an editor hold a language back on Publish. Everything is opt-in or additive: existing pages render the same.

A block declares the CSS and JS it needs (klehm/content-blocks)

A block type implementing the optional BlockAssetsInterface returns what its content needs:

public function assets(array $data): BlockAssets
{
    return new BlockAssets(
        stylesheets: ['blocks/counter.css'],
        modules: ($data['animate'] ?? true) ? ['blocks/counter.js'] : [],
    );
}

The page links those files only where such a block renders, each once, after the core's stylesheets. Paths go through asset() when the app has framework.assets. entries names bundler entries: with Webpack Encore installed they are linked with their runtime and shared chunks, and another bundler aliases its own EntrypointResolverInterface. In the builder, a block added or edited in place brings its assets into the preview.

With AssetMapper, declare a block's module entrypoint: true in importmap.php and pass it to no importmap() call, so its imports resolve without running it on every page.

→ CSS and JS a block needs

Picker categories

#[AsContentBlock(category: 'media')] puts a block in a group of the add-block picker; priority still orders it within the group. The built-in groups are text, media, layout, actions, advanced, and other for a block without a category. The kit's blocks come grouped.

content_blocks:
    picker:
        categories: { commerce: 'Shop' }   # added, relabelled or reordered; listed ones first
        blocks: { embed: commerce }        # move a block type to another group

A picker whose blocks all fall in one group keeps the flat grid it showed before. An undeclared category is refused at cache:clear.

→ Picker categories

A block view receives block and context

Beside data and block_id, a view template now gets block (id, type, read-only, never the entity) and context, the RenderContext. A view can tell the builder from the public page (context.preview) and knows its language (context.locale).

If you override render/block.html.twig, pass block: block.view, context: block.context in its include().

→ The view template

The public CSS in a cascade layer

content_blocks:
    css_layer: content-blocks

layout, styling and the kit's kit.css are then served inside @layer content-blocks { … }, so any unlayered rule of yours wins over them, whatever its specificity. It is off by default because turning it on also lets your global CSS (img, a, a reset) start winning: check your pages. The builder chrome is never layered.

→ Overriding the package CSS: cascade layers

Hold a language back on Publish (klehm/content-blocks-i18n)

With a translation pending, the builder's Publish and Revert to published open a dialog listing those languages, all ticked. An unticked language keeps its draft, and its public page stays as it is. The page's own draft always goes, so a translation can be held back but never pushed ahead of its source. With nothing pending, both buttons behave as before.

content_blocks_area_publish and content_blocks_area_discard take an optional body {"locales": [...]}; without it they cover every locale. A bundle keeping its own locale drafts implements LocaleDraftsProviderInterface.

→ Choosing languages in the builder

lang on text shown in another language (klehm/content-blocks-i18n)

content_blocks_i18n:
    fallback_lang: true

On a translated page, a field still in the source language, or read from a fallback locale, says its language, so screen readers and search engines do not read French as German (WCAG 3.1.2). A block nobody translated gets lang on its wrapper. In a partly translated block, the view marks each field with the new cb_lang(object, 'field') Twig function, which every kit view now calls. Off by default.

→ Marking text in another language · in a custom block

Fixed

  • Text typed right after adding a block could be lost: clicking the new block loaded its form a second time, which took focus away mid-typing. A click on the block or section the sidebar already shows now loads nothing.

Upgrading

No database migration. The three packages are tagged together. The kit now requires klehm/content-blocks ^1.5; i18n still accepts ^1.2, without the language dialog.

composer update "klehm/content-blocks*"

Details in each package's changelog: core · kit · i18n

v1.4.0

Choose a tag to compare

@Klehm Klehm released this 12 Oct 08:15
7bba97e

This release lets the colour palette follow your theme, including colours your admins edit in your own back office, and shows colour fields as swatches. Existing pages render the same.

Theme variables in the palette (klehm/content-blocks)

A palette entry can name a CSS custom property:

content_blocks:
    palette:
        - { label: 'Primary', color: 'var(--theme-primary, #eb0540)' }

The value is stored and rendered as written, so changing --theme-primary recolours every page that uses it. The hex fallback is the colour's swatch: the builder shows it in the sidebar and the section library thumbnails, and it decides the bg-dark / bg-light tone classes.

In rich text, CKEditor writes the variable as is, and the rich_text sanitizer keeps it. TinyMCE, whose swatches only take hex, writes the fallback.

→ Theme variables in the palette

Colours from your back office (klehm/content-blocks)

When colours are edited in your own admin, store the bare variable and give the current hex as the entry's swatch:

yield new PaletteColor('Primary', 'var(--brand)', swatch: $theme->primaryHex);

Content stores var(--brand) and never changes when the colour does. The builder's swatches, the tone classes and the thumbnails follow the current hex, with no CSS to add to the builder. A config entry takes the same swatch key. The palette is read once per request, so the provider may query your database, worker mode included.

→ Colours from a back office

Colour fields show swatches

PaletteColorType shows a row of swatches (None, your palette, a Custom… picker) instead of a text dropdown, with each colour's name on hover. The field is now a radio group. If a test or script of yours drives it, check() the input[value="#hex"] instead of calling selectOption() on the old <select>.

Fixed

  • A stored colour that is not a hex and is no longer in the palette stays on offer in the field. Before, it fell into the #rrggbb picker and was lost on the next save.

Upgrading

No database migration. The three packages are tagged together. The kit now requires klehm/content-blocks ^1.4.

composer update "klehm/content-blocks*"

Details in each package's changelog: core · kit · i18n

v1.3.1

Choose a tag to compare

@Klehm Klehm released this 05 Oct 13:04
c80206d

A patch release that fixes a block form that saved nothing.

Fixed (klehm/content-blocks)

  • An invalid field no longer holds the rest of a block's form. While a required field was still empty (the alert text, a button label), changing any other field saved nothing: the preview didn't update, and closing the sidebar lost the change. Now the invalid field keeps its stored value and the valid fields save. Its error shows once the editor has touched it, instead of on every field of the form. An error on the form itself still blocks the whole save.

The kit and i18n packages are unchanged.

Upgrading

No database migration. The three packages are tagged together.

composer update "klehm/content-blocks*"

Details in each package's changelog: core · kit · i18n

v1.3.0

8000

Choose a tag to compare

@Klehm Klehm released this 05 Oct 12:57
b368df6

This release lets a host narrow the builder down to what its editors need, and fixes how routes are mounted on Symfony 7.4+. Everything is additive: existing pages render the same.

A narrower builder (klehm/content-blocks)

content_blocks.structure decides what editors can do to sections and columns:

  • sections: hidden — a blocks-only builder. No section in the UI: blocks stack in one full-width section, created by the server with the first block.
  • sections: fixed — a skeleton to fill. Sections stay selectable, but can't be added, moved, duplicated, deleted, pasted or inserted.
  • columns: false — removes the Columns and Layout panels.

The endpoints refuse what a mode rules out (409, reasons: ["structure"]), so it holds beyond the UI. To choose per area, alias BuilderStructureResolverInterface.

content_blocks.styling: false hides the free styling fields (spacing, background, alignment). Use { block: false } or { section: false } to hide them in one sidebar only. Section style presets stay available. This is UI-only: stored values still render and survive a save.

→ Builder structure

Import and Export, each on its own (klehm/content-blocks)

ContentAreaType gains enable_import and enable_export (enableImport / enableExport on a launcher you include directly), so you can keep Export and drop Import, or the reverse. Left at null, they follow enable_import_export, which keeps its meaning.

Fixed

  • On Symfony 7.4+, routes were mounted at the root (/upload, /area/{id}/publish…) instead of under their prefix, in all three packages. A new app's config/routes.yaml imports routing.controllers, which picked up the packages' controllers a second time. They are no longer autoconfigured. Nothing to change on your side.
  • doctrine/collections 3 is accepted. A fresh Symfony 8.1 app on PHP 8.4 no longer needs composer require -W.
  • The Flex recipes apply without allow-contrib. Flex no longer asks before each recipe, and no longer skips them on a non-interactive install.

Upgrading

No database migration. The three packages are tagged together.

composer update "klehm/content-blocks*"

Details in each package's changelog: core · kit · i18n

v1.2.0

Choose a tag to compare

@Klehm Klehm released this 29 Sep 11:33
269b266

This release adds a way to build content from code, Symfony events around the builder's actions, and several translation features. Everything is additive: existing pages render the same.

Build content from code (klehm/content-blocks)

ContentManipulatorInterface adds, moves, duplicates, deletes and restores sections, columns and blocks the same way the builder does. Use it in fixtures, CMS migrations or seed commands instead of setting positions and ids by hand.

  • A new section gets its layout's columns. A new block starts from its type's default data.
  • Changes are written to the draft. The service never flushes, and nothing goes live until you publish.
  • If a change can't be applied, the service throws ContentManipulationException with a stable reason code.

The builder's own endpoints now use this service, so decorating it also covers the changes editors make. → Content from code

Server-side events (klehm/content-blocks)

Eight events in ContentBlocks\Event, in before/after pairs, around publish, discard, block save and block delete.

  • A Before… listener can refuse the action with $event->refuse('Why.'). The builder then shows the reason and changes nothing.
  • The After… events run after the flush. Use them for a cache purge or a webhook.

→ Server-side events

Translation (klehm/content-blocks-i18n)

  • Publish one language. The workbench has Publish and Discard buttons for the language being translated. They are disabled while the page itself has unpublished changes, because publishing would put those changes live too.
  • Replace images and videos per language. The kit's image, gallery, card and video blocks accept a different file for each language. Until one is uploaded, the source file is shown.
  • Translations carried by section templates and the clipboard. A translated section keeps its translations when it is saved to the library or copied and pasted.
  • Locale fallback chain (opt-in). With content_blocks_i18n.fallbacks: { fr_CA: fr }, an untranslated fr_CA field shows the fr translation before falling back to the source. You can also supply the chains from a service by aliasing LocaleFallbacksProviderInterface.
  • hreflang links. {{ cb_i18n_hreflang(page.contentArea) }} prints the <link rel="alternate" hreflang> tags, plus x-default. cb_i18n_alternates(area) returns the same data for your own markup.
  • Empty pages in progress badges. cb_i18n_progress() gains an empty key: a page with nothing to translate no longer reads as 100 % translated.

→ Translation guide

Fixed

  • A translation-only change can be published. After translating a field on an already published page, the builder's Publish button stayed disabled.
  • The workbench preview showed the source language on Sylius, and on any host that resets the request locale.
  • Duplicating a single block lost its translations. Duplicating its whole section already kept them.
  • Machine translation shows that it is running, and a run can no longer be started twice.

Upgrading

No database migration. The three packages are tagged together.

composer update "klehm/content-blocks*"
  • klehm/content-blocks-i18n now requires klehm/content-blocks ^1.2. Before, some translation features were quietly left out on an older core. They are now always on.
  • Copied builder/shell.html.twig or launcher.html.twig? Replace area.hasUnpublishedChanges with cb_has_unpublished_changes(area). Otherwise the Publish button won't light up for a translation-only change.
  • Overriding the cb-builder controller file through your importmap or bundler? Its code is now split into one file per feature under assets/builder/. Override the file that holds the method you need.

Details in each package's changelog: core · kit · i18n

v1.1.0

Choose a tag to compare

@Klehm Klehm released this 28 Sep 09:11
9dedc9b

This release carries two changes:

  • Fixed: concurrent section saves (klehm/content-blocks). Two section-setting autosaves in quick succession could overlap, and the older one could overwrite the newer. The section sidebar now sends one save at a time.
  • Added: host-supplied translation locales (klehm/content-blocks-i18n). The new interface ContentBlocks\I18n\Locale\TargetLocalesProviderInterface lets a host service supply the locales editors translate into, for example from the database. The default implementation, ContentBlocks\I18n\Locale\ConfiguredTargetLocalesProvider, keeps reading content_blocks_i18n.locales.

Nothing to migrate. The three packages are tagged together.

composer update "klehm/content-blocks*"

Details in each package's changelog: core · kit · i18n

v1.0.0

Choose a tag to compare

@Klehm Klehm released this 23 Sep 12:39

ContentBlocks 1.0 is the first stable release of a page builder that lives inside your Symfony app. You bring your entities, routes and auth, and it gives editors a builder over a live preview of your real page.

The builder

composer require klehm/content-blocks klehm/content-blocks-kit
composer require klehm/content-blocks-i18n   # optional: translated content

Start with the quick start.

Three packages

  • klehm/content-blocks: the core.
    • Content areas made of sections, columns and blocks, attached to any entity.
    • The builder, with draft and publish, undo and redo, copy and paste, a navigator, per-viewport display and order, section templates, and export and import.
  • klehm/content-blocks-kit: 19 ready-made blocks, styled by one stylesheet with no CSS framework and themed through seven CSS custom properties.
  • klehm/content-blocks-i18n: translated content.
    • One layout, a value per language, with per-field fallback and outdated detection.
    • A translation workbench with a live preview.
    • A seam for machine translation; no engine ships with the package.

What 1.0 promises

Everything the backward compatibility page lists is stable until 2.0. That covers the 38 interfaces, the form types, the Twig functions and blocks, the configuration, the route names, the cb:* events and the database tables. A 1.x release adds, fixes and deprecates, and removes nothing.

Proven in production

ContentBlocks is tested and used daily on four production sites, each set up differently: several Symfony versions, the Sylius Stack, Sylius 1.x, and plain Symfony.

  • 1,551 PHPUnit tests, 589 Vitest tests and 202 Playwright tests.
  • CI covers PHP 8.2 to 8.4 and Symfony 6.4, 7 and 8, on MySQL and PostgreSQL, plus a lowest-dependencies run.
  • Works under FrankenPHP worker mode, with a check in CI that no state carries from one request to the next.

Coming from a beta or a candidate: upgrade guide. Changelogs: core · kit · i18n.

0