Skip to content

Commit

Permalink
Release 0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiTelteu committed Sep 26, 2024
1 parent b688b35 commit bb97883
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 18 deletions.
38 changes: 29 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ php artisan vendor:publish --provider="VanOns\Laraberg\LarabergServiceProvider"
php artisan vendor:publish --provider="Customberg\PHP\CustombergServiceProvider"
```

# Usage
# Model Setup

The model that you want to use this block editor should have:

Expand All @@ -37,6 +37,18 @@ CRUD::field('content')
->view_namespace('customberg::');
```

# Usage

Create a new block with the `make:block` command:

```bash
php artisan make:block AwesomeBlock
```

Then edit the block field definition in `app/Blocks/AwesomeBlock.php` file, and the block view in `resources/views/blocks/cb-awesome-block.blade.php`.

Checkout [/example/app/Blocks/EverySingleField.php](https://github.com/customberg/customberg-php/blob/main/example/app/Blocks/EverySingleField.php) for a full example with every field type.

# Update

After an update, get the latest assets using:
Expand All @@ -63,17 +75,25 @@ Enjoy !

# Roadmap:

| | |
| -------- | ----------------------------- |
| ☐ | A checkbox and a switch field |
| ☐ | Radio field |
| ☐ | Slider field |
| ☐ | Google Maps field |
| ☐ | Documentation ! |
| ☐ | Icon picker field |
| | |
| -------- | ----------------- |
|| A checkbox field |
| ☐ | Switch field |
| ☐ | Radio field |
| ☐ | Slider field |
| ☐ | Google Maps field |
| ☐ | Documentation ! |
| ☐ | Icon picker field |

# Changelog:

### v0.15 - 2024-09-26

- New field types: `checkbox`, `textarea`, `number`, `email`, `url`
- New property `placeholder` for text fields
- New property `hint` and `hint_html` for all fields that show a small helper text
- Checkout [/example/app/Blocks/EverySingleField.php](https://github.com/customberg/customberg-php/blob/main/example/app/Blocks/EverySingleField.php) for a full example

### v0.14 - 2024-08-07

- Bugfix: Preview API while rendering a block with multilanguage, when i'm selecting the new language that does not have translation saved.
Expand Down
23 changes: 14 additions & 9 deletions src/CustombergInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,18 @@ public function loadBlocks()
}
$blockJson = json_encode($block);
$init .= "
window.Laraberg.registerBlockType('cb/{$block['slug']}', {
title: '{$block['name']}',
icon: '{$block['icon']}',
category: 'customberg',
attributes: $attributesJson,
edit: window.CustombergEditFields($blockJson),
save: function (props) { return null; },
});
try {
window.Laraberg.registerBlockType('cb/{$block['slug']}', {
title: '{$block['name']}',
icon: '{$block['icon']}',
category: 'customberg',
attributes: $attributesJson,
edit: window.CustombergEditFields($blockJson),
save: function (props) { return null; },
});
} catch (e) {
console.error('Error registering block: cb/{$block['slug']}', e.message, { e });
}
";
}
return "
Expand Down Expand Up @@ -199,7 +203,8 @@ public function render($html, $lang = null)
}
}

function str_replace_limit($find, $replacement, $subject, $limit = 0) {
function str_replace_limit($find, $replacement, $subject, $limit = 0)
{
if ($limit == 0) {
return str_replace($find, $replacement, $subject);
}
Expand Down

0 comments on commit bb97883

Please sign in to comment.