Skip to content

Commit

Permalink
Merge pull request #77 from liip/feat/row-block-transforms
Browse files Browse the repository at this point in the history
feat(): Row block transforms
  • Loading branch information
tschortsch committed Jun 4, 2021
2 parents a351142 + c7c69dc commit 4f933fb
Show file tree
Hide file tree
Showing 24 changed files with 2,769 additions and 3,592 deletions.
10 changes: 3 additions & 7 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"core": "WordPress/WordPress#5.7",
"core": "https://wordpress.org/wordpress-5.7.2.zip",
"plugins": [ "." ],
"env": {
"tests": {
"mappings": {
"wp-content/plugins/wp-bootstrap-blocks-test-plugins": "./e2e-test-plugins"
}
}
"mappings": {
"wp-content/plugins/wp-bootstrap-blocks-test-plugins": "./e2e-test-plugins"
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build Status](https://github.com/liip/bootstrap-blocks-wordpress-plugin/workflows/Lint%20Test%20Deploy/badge.svg?branch=master)](https://github.com/liip/bootstrap-blocks-wordpress-plugin/actions?query=workflow%3A%22Lint+Test+Deploy%22+branch%3Amaster)

Bootstrap Gutenberg Blocks for WordPress. Supports Bootstrap 4 and **Bootstrap 5** (experimental). This plugin adds Bootstrap components and layout options as Gutenberg blocks.
Bootstrap Gutenberg Blocks for WordPress. Supports Bootstrap v4 and v5. This plugin adds Bootstrap components and layout options as Gutenberg blocks.

## Available blocks

Expand Down Expand Up @@ -54,7 +54,7 @@ Bootstrap Gutenberg Blocks for WordPress. Supports Bootstrap 4 and **Bootstrap 5

## Supported Bootstrap versions

This plugin supports Bootstrap v4 and v5 (experimental). The support for v5 is still flagged as experimental since this version of Bootstrap is not officially released yet. The API could still change which could affect the options defined in this plugin.
This plugin supports Bootstrap v4 and v5.

The version can be selected in the plugin settings (Settings > Bootstrap Blocks) or by defining the `WP_BOOTSTRAP_BLOCKS_BOOTSTRAP_VERSION` constant in the `wp-config.php` file:

Expand Down
2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-polyfill'), 'version' => '3a27ed384c3dcb99453d681ff5156a5b');
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-polyfill'), 'version' => 'e62e695a63e7b76aa60ea1b85c9c50ba');
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/settings.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-polyfill'), 'version' => '17a3d0912e3f28b66ec90f712d14db46');
<?php return array('dependencies' => array('wp-polyfill'), 'version' => 'f667eacf17d0bdd32b04f62b195ef00e');
92 changes: 92 additions & 0 deletions cypress/integration/row/row-block-transforms.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/// <reference types="Cypress" />
import { testBlockTransform } from '../../support/row/transform-tests';
import { getAllBlocks } from 'cypress-wp-test-utils';

context( 'Row Block Transforms', () => {
describe( 'Custom template enabled', () => {
beforeEach( () => {
cy.loginUser();
cy.createNewPost();
} );

it( 'Should be possible to transform 2 blocks to row block', () => {
cy.insertBlock( 'Heading' );
cy.insertBlock( 'Heading' );

testBlockTransform();
cy.postContentMatchesSnapshot();
} );

it( 'Should be possible to transform 3 blocks to row block', () => {
cy.insertBlock( 'Heading' );
cy.insertBlock( 'Heading' );
cy.insertBlock( 'Heading' );

testBlockTransform();
cy.postContentMatchesSnapshot();
} );

it( 'Should be possible to transform 4 blocks to row block', () => {
cy.insertBlock( 'Heading' );
cy.insertBlock( 'Heading' );
cy.insertBlock( 'Heading' );
cy.insertBlock( 'Heading' );

testBlockTransform();
cy.postContentMatchesSnapshot();
} );

it( 'Columns should not be smaller than 3', () => {
cy.insertBlock( 'Heading' );
cy.insertBlock( 'Heading' );
cy.insertBlock( 'Heading' );
cy.insertBlock( 'Heading' );
cy.insertBlock( 'Heading' );

testBlockTransform();
cy.postContentMatchesSnapshot();
} );
} );

describe( 'Custom template disabled', () => {
before( () => {
cy.loginUser();
cy.activatePlugin( 'wp-bootstrap-blocks-test-row-filters' );
} );

after( () => {
cy.loginUser();
cy.deactivatePlugin( 'wp-bootstrap-blocks-test-row-filters' );
} );

beforeEach( () => {
cy.loginUser();
cy.createNewPost();
} );

it( 'Should not be possible to transform blocks if custom template is disabled', () => {
cy.insertBlock( 'Heading' );
cy.insertBlock( 'Heading' );

return getAllBlocks().then( ( blocks ) => {
const firstBlockId = blocks[ 0 ].clientId;
const lastBlockId = blocks[ blocks.length - 1 ].clientId;

return cy
.window()
.then( ( window ) => {
return window.wp.data
.dispatch( 'core/block-editor' )
.multiSelect( firstBlockId, lastBlockId );
} )
.then( () => {
// Transform block
cy.clickBlockToolbarButton( 'Heading' );
cy.get(
'.editor-block-list-item-wp-bootstrap-blocks-row'
).should( 'not.exist' );
} );
} );
} );
} );
} );
29 changes: 29 additions & 0 deletions cypress/support/row/transform-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { getAllBlocks } from 'cypress-wp-test-utils';

export const testBlockTransform = () => {
return getAllBlocks().then( ( blocks ) => {
const blockCount = blocks.length;
const firstBlockId = blocks[ 0 ].clientId;
const lastBlockId = blocks[ blocks.length - 1 ].clientId;
const expectedColumnSize = Math.max( Math.round( 12 / blockCount ), 3 );

return cy
.window()
.then( ( window ) => {
return window.wp.data
.dispatch( 'core/block-editor' )
.multiSelect( firstBlockId, lastBlockId );
} )
.then( () => {
// Transform block
cy.clickBlockToolbarButton( 'Heading' );
cy.get(
'.editor-block-list-item-wp-bootstrap-blocks-row'
).click();

cy.get(
`[data-type="wp-bootstrap-blocks/column"][data-size-md="${ expectedColumnSize }"]`
).should( 'have.length', blockCount );
} );
} );
};
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"translation-revision-date":"2020-10-18 22:25+0200","generator":"WP-CLI\/2.4.0","source":"build\/index.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"de_CH","plural-forms":"nplurals=2; plural=(n != 1);"},"Button":["Button"],"Bootstrap Button":["Bootstrap Button"],"Bootstrap":["Bootstrap"],"Primary":["Primary"],"Secondary":["Secondary"],"Add text...":["Text hinzuf\u00fcgen..."],"Style":["Stil"],"Link settings":["Link-Einstellungen"],"Open in new tab":["In einem neuen Tab \u00f6ffnen"],"Link rel":["Link rel"],"Change button alignment":["\u00c4ndere die Positionierung des Buttons"],"Apply":["\u00dcbernehmen"],"Column":["Column"],"Bootstrap Column":["Bootstrap Column"],"None":["Deaktiviert"],"Small":["Klein"],"Medium":["Mittel"],"Large":["Gross"],"Column size":["Anzahl Spalten"],"Xs Column count":["Xs Anzahl Spalten"],"Xs equal-width":["Xs gleiche Breite (equal-width)"],"Sm Column count":["Sm Anzahl Spalten"],"Sm equal-width":["Sm gleiche Breite (equal-width)"],"Md Column count":["Md Anzahl Spalten"],"Md equal-width":["Md gleiche Breite (equal-width)"],"Lg Column count":["Lg Anzahl Spalten"],"Lg equal-width":["Lg gleiche Breite (equal-width)"],"Xl Column count":["Xl Anzahl Spalten"],"Xl equal-width":["Xl gleiche Breite (equal-width)"],"Xxl Column count":["Xxl Anzahl Spalten"],"Xxl equal-width":["Xxl gleiche Breite (equal-width)"],"Background color":["Hintergrundfarbe"],"Center content vertically in row":["Zeileninhalt vertikal zentrieren"],"This setting only applies if there is no vertical alignment set on the parent row block.":["Diese Einstellung kann nur verwendet werden, wenn auf dem umschliessenden Row-Block keine vertikale Positionierung gesetzt ist."],"Padding (inside column)":["Padding (innerhalb der Spalte)"],"Size":["Gr\u00f6sse"],"Container":["Container"],"Bootstrap Container":["Bootstrap Container"],"Xl":["Xl"],"Lg":["Lg"],"Md":["Md"],"Sm":["Sm"],"Xxl":["Xxl"],"No breakpoint selected":["Kein Breakpoint ausgew\u00e4hlt"],"Fluid":["Fluid"],"Fluid Breakpoint":["Fluid Breakpoint"],"Fluid breakpoints only work with Bootstrap v4.4+. The container will be 100% wide until the specified breakpoint is reached, after which max-widths for each of the higher breakpoints will be applied.":["Fluid Breakpoints werden erst ab Bootstrap v4.4+ unterst\u00fctzt. Wenn die Option aktiviert ist, nimmt der Container 100% der Breite ein bis zum gew\u00e4hlten Breakpoint. Ab diesem Breakpoint gilt die jeweilige maximale Breite (max-width) des Containers."],"Margin":["Margin"],"Margin After":["Margin unterhalb vom Block"],"Row":["Row"],"Bootstrap Row":["Bootstrap Row"],"2 Columns (1:1)":["2 Spalten (1:1)"],"2 Columns (1:2)":["2 Spalten (1:2)"],"2 Columns (2:1)":["2 Spalten (2:1)"],"3 Columns (1:1:1)":["3 Spalten (1:1:1)"],"Custom":["Benutzerdefiniert"],"Bootstrap Default":["Bootstrap Standardwert"],"Bootstrap Default (None)":["Bootstrap Standardwert (Kein Abstand)"],"Align columns left":["Spalten links positionieren"],"Align columns center":["Spalten zentrieren"],"Align columns right":["Spalten rechts positionieren"],"Align columns top":["Spalten oben positionieren"],"Align columns bottom":["Spalten unten positionieren"],"Editor: Display columns stacked":["Editor: Spalten untereinander darstellen"],"Displays stacked columns in editor to enhance readability of block content. This option is only used in the editor and won't affect the output of the row.":["Stellt die Spalten untereinander dar um die Lesbarkeit der Block-Inhalte zu verbessern. Diese Option wird lediglich f\u00fcr den Editor verwendet und ver\u00e4ndert die Ausgabe des Blocks nicht."],"Change layout":["Layout \u00e4ndern"],"Row options":["Zeilen Optionen"],"No Gutters":["Keine Abst\u00e4nde zwischen Spalten (No Gutters)"],"Horizontal Gutters":["Horizontale Abst\u00e4nde zwischen Spalten"],"Vertical Gutters":["Vertikale Abst\u00e4nde zwischen Spalten"],"Change horizontal alignment of columns":["\u00c4ndere die horizontale Positionierung der Spalten"],"Change vertical alignment of columns":["\u00c4ndere die vertikale Positionierung der Spalten"]}}}
{"translation-revision-date":"2020-10-18 22:25+0200","generator":"WP-CLI\/2.5.0","source":"build\/index.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"de_CH","plural-forms":"nplurals=2; plural=(n != 1);"},"Button":["Button"],"Bootstrap Button":["Bootstrap Button"],"Bootstrap":["Bootstrap"],"Primary":["Primary"],"Secondary":["Secondary"],"Add text...":["Text hinzuf\u00fcgen..."],"Style":["Stil"],"Link settings":["Link-Einstellungen"],"Open in new tab":["In einem neuen Tab \u00f6ffnen"],"Link rel":["Link rel"],"Change button alignment":["\u00c4ndere die Positionierung des Buttons"],"Apply":["\u00dcbernehmen"],"Column":["Column"],"Bootstrap Column":["Bootstrap Column"],"None":["Deaktiviert"],"Small":["Klein"],"Medium":["Mittel"],"Large":["Gross"],"Column size":["Anzahl Spalten"],"Xs Column count":["Xs Anzahl Spalten"],"Xs equal-width":["Xs gleiche Breite (equal-width)"],"Sm Column count":["Sm Anzahl Spalten"],"Sm equal-width":["Sm gleiche Breite (equal-width)"],"Md Column count":["Md Anzahl Spalten"],"Md equal-width":["Md gleiche Breite (equal-width)"],"Lg Column count":["Lg Anzahl Spalten"],"Lg equal-width":["Lg gleiche Breite (equal-width)"],"Xl Column count":["Xl Anzahl Spalten"],"Xl equal-width":["Xl gleiche Breite (equal-width)"],"Xxl Column count":["Xxl Anzahl Spalten"],"Xxl equal-width":["Xxl gleiche Breite (equal-width)"],"Background color":["Hintergrundfarbe"],"Center content vertically in row":["Zeileninhalt vertikal zentrieren"],"This setting only applies if there is no vertical alignment set on the parent row block.":["Diese Einstellung kann nur verwendet werden, wenn auf dem umschliessenden Row-Block keine vertikale Positionierung gesetzt ist."],"Padding (inside column)":["Padding (innerhalb der Spalte)"],"Size":["Gr\u00f6sse"],"Container":["Container"],"Bootstrap Container":["Bootstrap Container"],"Xl":["Xl"],"Lg":["Lg"],"Md":["Md"],"Sm":["Sm"],"Xxl":["Xxl"],"No breakpoint selected":["Kein Breakpoint ausgew\u00e4hlt"],"Fluid":["Fluid"],"Fluid Breakpoint":["Fluid Breakpoint"],"Fluid breakpoints only work with Bootstrap v4.4+. The container will be 100% wide until the specified breakpoint is reached, after which max-widths for each of the higher breakpoints will be applied.":["Fluid Breakpoints werden erst ab Bootstrap v4.4+ unterst\u00fctzt. Wenn die Option aktiviert ist, nimmt der Container 100% der Breite ein bis zum gew\u00e4hlten Breakpoint. Ab diesem Breakpoint gilt die jeweilige maximale Breite (max-width) des Containers."],"Margin":["Margin"],"Margin After":["Margin unterhalb vom Block"],"Row":["Row"],"Bootstrap Row":["Bootstrap Row"],"2 Columns (1:1)":["2 Spalten (1:1)"],"2 Columns (1:2)":["2 Spalten (1:2)"],"2 Columns (2:1)":["2 Spalten (2:1)"],"3 Columns (1:1:1)":["3 Spalten (1:1:1)"],"Custom":["Benutzerdefiniert"],"Bootstrap Default":["Bootstrap Standardwert"],"Bootstrap Default (None)":["Bootstrap Standardwert (Kein Abstand)"],"Align columns left":["Spalten links positionieren"],"Align columns center":["Spalten zentrieren"],"Align columns right":["Spalten rechts positionieren"],"Align columns top":["Spalten oben positionieren"],"Align columns bottom":["Spalten unten positionieren"],"Editor: Display columns stacked":["Editor: Spalten untereinander darstellen"],"Displays stacked columns in editor to enhance readability of block content. This option is only used in the editor and won't affect the output of the row.":["Stellt die Spalten untereinander dar um die Lesbarkeit der Block-Inhalte zu verbessern. Diese Option wird lediglich f\u00fcr den Editor verwendet und ver\u00e4ndert die Ausgabe des Blocks nicht."],"Change layout":["Layout \u00e4ndern"],"Row options":["Zeilen Optionen"],"No Gutters":["Keine Abst\u00e4nde zwischen Spalten (No Gutters)"],"Horizontal Gutters":["Horizontale Abst\u00e4nde zwischen Spalten"],"Vertical Gutters":["Vertikale Abst\u00e4nde zwischen Spalten"],"Change horizontal alignment of columns":["\u00c4ndere die horizontale Positionierung der Spalten"],"Change vertical alignment of columns":["\u00c4ndere die vertikale Positionierung der Spalten"]}}}
Binary file modified languages/wp-bootstrap-blocks-de_CH.mo
Binary file not shown.
66 changes: 33 additions & 33 deletions languages/wp-bootstrap-blocks-de_CH.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# This file is distributed under the same license as the Bootstrap Blocks plugin.
msgid ""
msgstr ""
"Project-Id-Version: Bootstrap Blocks 3.1.3\n"
"Project-Id-Version: Bootstrap Blocks 3.2.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-bootstrap-"
"blocks\n"
"POT-Creation-Date: 2021-03-02T12:32:10+00:00\n"
"POT-Creation-Date: 2021-06-04T12:25:36+00:00\n"
"PO-Revision-Date: 2020-10-18 22:25+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down Expand Up @@ -51,8 +51,8 @@ msgid "Settings"
msgstr "Einstellungen"

#: src/settings/class-settings.php:166
msgid "Bootstrap Version (experimental)"
msgstr "Bootstrap Version (experimentell)"
msgid "Bootstrap Version"
msgstr "Bootstrap Version"

#: src/settings/class-settings.php:167
msgid ""
Expand Down Expand Up @@ -95,7 +95,7 @@ msgid "Bootstrap Button"
msgstr "Bootstrap Button"

#: build/index.js:636 build/index.js:893 build/index.js:1313
#: build/index.js:1802
#: build/index.js:1804
msgid "Bootstrap"
msgstr "Bootstrap"

Expand Down Expand Up @@ -143,21 +143,21 @@ msgstr "Column"
msgid "Bootstrap Column"
msgstr "Bootstrap Column"

#: build/index.js:1048 build/index.js:1404 build/index.js:2002
#: build/index.js:1048 build/index.js:1404 build/index.js:2008
msgid "None"
msgstr "Deaktiviert"

#: build/index.js:1051 build/index.js:1393 build/index.js:2005
#: build/index.js:2017
#: build/index.js:1051 build/index.js:1393 build/index.js:2011
#: build/index.js:2023
msgid "Small"
msgstr "Klein"

#: build/index.js:1054 build/index.js:1396
msgid "Medium"
msgstr "Mittel"

#: build/index.js:1057 build/index.js:1399 build/index.js:2008
#: build/index.js:2020
#: build/index.js:1057 build/index.js:1399 build/index.js:2014
#: build/index.js:2026
msgid "Large"
msgstr "Gross"

Expand Down Expand Up @@ -296,67 +296,67 @@ msgstr "Margin"
msgid "Margin After"
msgstr "Margin unterhalb vom Block"

#: build/index.js:1796 build/index.js:1802
#: build/index.js:1798 build/index.js:1804
msgid "Row"
msgstr "Row"

#: build/index.js:1802
#: build/index.js:1804
msgid "Bootstrap Row"
msgstr "Bootstrap Row"

#: build/index.js:1911
#: build/index.js:1917
msgid "2 Columns (1:1)"
msgstr "2 Spalten (1:1)"

#: build/index.js:1930
#: build/index.js:1936
msgid "2 Columns (1:2)"
msgstr "2 Spalten (1:2)"

#: build/index.js:1949
#: build/index.js:1955
msgid "2 Columns (2:1)"
msgstr "2 Spalten (2:1)"

#: build/index.js:1968
#: build/index.js:1974
msgid "3 Columns (1:1:1)"
msgstr "3 Spalten (1:1:1)"

#: build/index.js:1994
#: build/index.js:2000
msgid "Custom"
msgstr "Benutzerdefiniert"

#: build/index.js:2013
#: build/index.js:2019
msgid "Bootstrap Default"
msgstr "Bootstrap Standardwert"

#: build/index.js:2025
#: build/index.js:2031
msgid "Bootstrap Default (None)"
msgstr "Bootstrap Standardwert (Kein Abstand)"

#: build/index.js:2092
#: build/index.js:2098
msgid "Align columns left"
msgstr "Spalten links positionieren"

#: build/index.js:2096 build/index.js:2109
#: build/index.js:2102 build/index.js:2115
msgid "Align columns center"
msgstr "Spalten zentrieren"

#: build/index.js:2100
#: build/index.js:2106
msgid "Align columns right"
msgstr "Spalten rechts positionieren"

#: build/index.js:2105
#: build/index.js:2111
msgid "Align columns top"
msgstr "Spalten oben positionieren"

#: build/index.js:2113
#: build/index.js:2119
msgid "Align columns bottom"
msgstr "Spalten unten positionieren"

#: build/index.js:2117
#: build/index.js:2123
msgid "Editor: Display columns stacked"
msgstr "Editor: Spalten untereinander darstellen"

#: build/index.js:2118
#: build/index.js:2124
msgid ""
"Displays stacked columns in editor to enhance readability of block content. "
"This option is only used in the editor and won't affect the output of the "
Expand All @@ -366,30 +366,30 @@ msgstr ""
"verbessern. Diese Option wird lediglich für den Editor verwendet und "
"verändert die Ausgabe des Blocks nicht."

#: build/index.js:2126
#: build/index.js:2132
msgid "Change layout"
msgstr "Layout ändern"

#: build/index.js:2145
#: build/index.js:2151
msgid "Row options"
msgstr "Zeilen Optionen"

#: build/index.js:2147
#: build/index.js:2153
msgid "No Gutters"
msgstr "Keine Abstände zwischen Spalten (No Gutters)"

#: build/index.js:2155
#: build/index.js:2161
msgid "Horizontal Gutters"
msgstr "Horizontale Abstände zwischen Spalten"

#: build/index.js:2164
#: build/index.js:2170
msgid "Vertical Gutters"
msgstr "Vertikale Abstände zwischen Spalten"

#: build/index.js:2174
#: build/index.js:2180
msgid "Change horizontal alignment of columns"
msgstr "Ändere die horizontale Positionierung der Spalten"

#: build/index.js:2183
#: build/index.js:2189
msgid "Change vertical alignment of columns"
msgstr "Ändere die vertikale Positionierung der Spalten"
Loading

0 comments on commit 4f933fb

Please sign in to comment.