Skip to content

Commit cd971ba

Browse files
authored
Merge branch 'wintercms:main' into main
2 parents 26b4fc5 + ec86098 commit cd971ba

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
lines changed

README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
![Blocks Plugin](https://github.com/wintercms/wn-blocks-plugin/blob/main/.github/banner.png?raw=true)
44

5+
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/wintercms/wn-blocks-plugin/blob/main/LICENSE)
6+
57
Provides a "block based" content management experience in Winter CMS
68

79
>**NOTE:** This plugin is still in development and is likely to undergo changes. Do not use in production environments without using a version constraint in your composer.json file and carefully monitoring for breaking changes.
810
9-
>**NOTE:** This plugin requires Winter CMS v1.2.2 or above.
10-
11-
1211
## Installation
1312

1413
This plugin is available for installation via [Composer](http://getcomposer.org/).
@@ -17,8 +16,13 @@ This plugin is available for installation via [Composer](http://getcomposer.org/
1716
composer require winter/wn-blocks-plugin
1817
```
1918

20-
In order to have the `actions` support function correctly, you need to load `/plugins/winter/blocks/assets/dist/js/blocks.js` after the Snowboard framework has been loaded.
19+
After installing the plugin you will need to run the migrations and (if you are using a [public folder](https://wintercms.com/docs/develop/docs/setup/configuration#using-a-public-folder)) [republish your public directory](https://wintercms.com/docs/develop/docs/console/setup-maintenance#mirror-public-files).
20+
21+
```bash
22+
php artisan migrate
23+
```
2124

25+
>**NOTE:** In order to have the `actions` support function correctly, you need to load `/plugins/winter/blocks/assets/dist/js/blocks.js` after the Snowboard framework has been loaded.
2226
2327
## Core Concepts
2428

classes/BlockManager.php

+16
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,20 @@ public function isBlock(string $type): bool
128128
{
129129
return !!$this->getConfig($type);
130130
}
131+
132+
/**
133+
* Remove a block by key
134+
*/
135+
public function removeBlock(string|array $key): void
136+
{
137+
if (is_array($key)) {
138+
foreach ($key as $k) {
139+
$this->removeBlock($k);
140+
}
141+
142+
return;
143+
}
144+
145+
unset($this->blocks[$key]);
146+
}
131147
}

classes/BlocksDatasource.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ class BlocksDatasource extends Datasource
1515
public function __construct()
1616
{
1717
$this->processor = new BlockProcessor();
18-
$this->blocks = BlockManager::instance()->getRegisteredBlocks();
18+
$this->blocks = array_merge(
19+
// Get blocks registered via plugins
20+
BlockManager::instance()->getRegisteredBlocks(),
21+
// Get blocks existing in the autodatasource
22+
BlockManager::instance()->getBlocks()->map(function ($block) {
23+
return ['name' => $block->id, 'path' => $block->getFilePath()];
24+
})->pluck('path', 'name')->toArray()
25+
);
1926
}
2027

2128
/**

lang/fr/lang.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'description' => 'Ouvrez l\'URL fournie',
1212
'href' => 'URL',
1313
'target' => 'Ouvrir l\'URL dans',
14-
'target_self' => 'Même onget',
14+
'target_self' => 'Même onglet',
1515
'target_blank' => 'Nouvel onglet',
1616
],
1717
'open_media' => [
@@ -115,9 +115,9 @@
115115
'default' => 'Défaut',
116116
'alignment_x' => [
117117
'label' => 'Alignement horizontal',
118-
'left' => 'A gauche',
119-
'center' => 'Au entre',
120-
'right' => 'A droite',
118+
'left' => 'À gauche',
119+
'center' => 'Centré',
120+
'right' => 'À droite',
121121
],
122122
],
123123
];

0 commit comments

Comments
 (0)