Compare commits

...

84 commits

Author SHA1 Message Date
Simon Vieille a80dc9999c Merge branch 'develop' 2024-05-17 22:02:18 +02:00
Simon Vieille b9566853ef
allow buildHtml to get null, array or string 2024-05-17 22:02:16 +02:00
Simon Vieille bc7e8ef263 Merge branch 'develop' 2024-05-17 21:38:50 +02:00
Simon Vieille 25efd11ea3
add BuilderBlockContainer::removeBlock 2024-05-17 21:38:48 +02:00
Simon Vieille e23f7d3c73 Merge branch 'develop' 2024-05-17 21:34:16 +02:00
Simon Vieille 85f054956c
sanitize builder component value 2024-05-17 21:34:08 +02:00
Simon Vieille b12f4db16f Merge branch 'develop' 2024-05-16 21:42:42 +02:00
Simon Vieille 6bb29dd5c3
add margin and border color to builder block widgets 2024-05-16 21:42:40 +02:00
Simon Vieille 7824e96bab Merge branch 'develop' 2024-05-16 11:17:10 +02:00
Simon Vieille 56177c14da
improve block builder picker 2024-05-16 11:16:48 +02:00
Simon Vieille 4f1c5b8f14 Merge branch 'develop' 2024-05-16 08:56:14 +02:00
Simon Vieille e8c9520378
update builder block default template 2024-05-16 08:56:06 +02:00
Simon Vieille 283223446a Merge branch 'develop' 2024-05-15 23:24:18 +02:00
Simon Vieille 46e01f504f
add maker for builder block 2024-05-15 23:24:11 +02:00
Simon Vieille a80ee03fcd Merge branch 'develop' 2024-05-15 18:39:15 +02:00
Simon Vieille d1649a4959
add builder as new type in the page maker 2024-05-15 18:39:09 +02:00
Simon Vieille 38791f1d7a Merge branch 'develop' 2024-05-15 18:27:22 +02:00
Simon Vieille d74cd52711
add builer block context 2024-05-15 18:27:19 +02:00
Simon Vieille b451df61e8 Merge branch 'develop' 2024-05-15 18:19:11 +02:00
Simon Vieille 7c124008c0
add builer block context 2024-05-15 18:18:56 +02:00
Simon Vieille 9cf95dba64 Merge branch 'develop' 2024-05-14 22:13:44 +02:00
Simon Vieille b680946daf
block builder: add test to check if the widget exists 2024-05-14 22:13:36 +02:00
Simon Vieille 1995298977 Merge branch 'develop' 2024-05-14 20:24:58 +02:00
Simon Vieille 4acba618cb
block builder: add colors depending of depth and keep open/closed settings when moved 2024-05-14 20:24:34 +02:00
Simon Vieille 92eaaba699 Merge branch 'develop' 2024-05-13 17:58:11 +02:00
Simon Vieille 357856f8ce
release v1.25.1 2024-05-13 17:58:08 +02:00
Simon Vieille dfbe282d0e
add drag and drop in the block builder 2024-05-13 17:40:05 +02:00
Simon Vieille 857fcd9897
add blocks 2024-05-13 13:58:07 +02:00
Simon Vieille 48ca5a96e6
rename blocks 2024-05-13 13:57:58 +02:00
Simon Vieille 065bb0db22
rename blocks 2024-05-13 13:57:49 +02:00
Simon Vieille bf6777054f
add order property 2024-05-13 13:57:34 +02:00
Simon Vieille 51acd82432 order blocks 2024-05-13 13:57:01 +02:00
Simon Vieille c6cbc405e4 Merge branch 'develop' 2024-05-13 11:20:11 +02:00
Simon Vieille 150f3afd6a
add build block vars 2024-05-13 11:19:56 +02:00
Simon Vieille 4a0e616897 Merge branch 'develop' 2024-05-13 09:27:18 +02:00
Simon Vieille 4eb13a4022
add diffent border color on the root block of the builder
add default class in blocks
2024-05-13 09:26:31 +02:00
Simon Vieille 8bb6267a77 Merge branch 'develop' 2024-05-12 22:49:46 +02:00
Simon Vieille 8044ff3605
update changelog 2024-05-12 22:49:43 +02:00
Simon Vieille 71d3d40d5f Merge branch 'develop' 2024-05-12 22:48:33 +02:00
Simon Vieille 9324837bd9
update changelog 2024-05-12 22:48:30 +02:00
Simon Vieille b8dfaaed10 Merge branch 'feature/blocks' into develop 2024-05-12 22:41:44 +02:00
Simon Vieille 2d49b8ddee
move build add button 2024-05-12 22:40:52 +02:00
Simon Vieille 232b92267e
add build block loader
add builder block rendering

fix issues with components
2024-05-12 22:24:51 +02:00
Simon Vieille ca23a22807
rollback indentation 2024-05-12 22:24:10 +02:00
Simon Vieille 78965bbf10
allow to move blocks
update builder view
2024-05-12 14:30:28 +02:00
Simon Vieille 7fe1acd47d
add base of the block builder 2024-05-11 17:45:57 +02:00
Simon Vieille 26cbaa8469 Merge branch 'develop' 2024-05-03 17:58:22 +02:00
Simon Vieille 7897bafcc2
fix undefined window.tinymce.murph 2024-05-03 17:57:43 +02:00
Simon Vieille 63a8a60e2d Merge branch 'develop' 2024-03-31 16:57:56 +02:00
Simon Vieille d01e9d618b
add border color on tinymce editor 2024-03-31 16:57:46 +02:00
Simon Vieille 96347a1730 Merge branch 'develop' 2024-03-31 16:50:47 +02:00
Simon Vieille aeb0e6c109 allow to use window.tinymceModes to add or override tinymce modes 2024-03-31 16:50:18 +02:00
Simon Vieille 64258a2d8c Merge branch 'develop' 2024-03-25 15:27:12 +01:00
Simon Vieille 70329ceeda
fix template of CrudController (maker) 2024-03-25 15:27:06 +01:00
Simon Vieille 1adb1ebe2b Merge branch 'develop' 2024-03-25 13:04:17 +01:00
Simon Vieille f57cc8e4d6
fix hidden save button in file manager 2024-03-25 13:04:16 +01:00
Simon Vieille b21967028e Merge branch 'develop' 2024-03-25 13:03:01 +01:00
Simon Vieille 5b22851674
fix hidden save button in file manager 2024-03-25 13:02:20 +01:00
Simon Vieille 4082bb171a
fix use of IsGranted is CrudController 2024-02-04 16:48:44 +01:00
Simon Vieille dc19617fb1 Merge branch 'develop' 2024-02-04 16:33:34 +01:00
Simon Vieille dbd2036fb0
rollback commit 614ae40 (add IsGranted in all methods of the CrudController maker template) 2024-02-04 16:33:30 +01:00
Simon Vieille 8e2566abc8
rollback commit 614ae40 (add IsGranted in all methods of the CrudController maker template) 2024-02-04 16:33:22 +01:00
Simon Vieille 66e1a9c87f
rollback commit 614ae40 (add IsGranted in all methods of the CrudController maker template) 2024-02-04 16:31:21 +01:00
Simon Vieille 6709c0a303
update changelog 2024-02-04 16:17:49 +01:00
Simon Vieille 614ae40901 add IsGranted in all methods of the CrudController maker template 2024-02-04 16:16:22 +01:00
Simon Vieille 430bff9433
fix default crud sort 2024-02-02 20:04:19 +01:00
Simon Vieille 6441da8a27
fix default crud sort 2024-02-02 20:03:57 +01:00
Simon Vieille 801e3317e7
update changelog 2024-02-02 20:02:00 +01:00
Simon Vieille f7604d2a45
fix default crud sort 2024-02-02 20:01:23 +01:00
Simon Vieille 8a632a1b14
update Murph version constant 2024-02-01 18:46:33 +01:00
Simon Vieille 4701090134
update changelog 2024-01-27 15:49:58 +01:00
Simon Vieille c40c7e3362
fix type casting in slugifier 2024-01-27 15:49:39 +01:00
Simon Vieille 8edbf0cc08
add default default on node's code when slugify 2023-11-27 10:32:38 +01:00
Simon Vieille 175321bc2d
fix issue on file manager when a file is selected in the file in the file picker 2023-11-16 23:06:00 +01:00
Simon Vieille 5d6531d197
fix sidebar scroll algo 2023-11-14 23:21:24 +01:00
Simon Vieille 90603f62e0
add side bar scroll animation 2023-11-14 23:08:09 +01:00
Simon Vieille 053f4aa5b8
add auto-scroll on current sidebar item 2023-11-14 23:03:43 +01:00
Simon Vieille 79754d45c1
add auto-scroll on current sidebar item
remove jquery from sidebar module
2023-11-14 22:51:40 +01:00
Simon Vieille c98ea50f30
fix undefined pager on index 2023-11-13 16:06:06 +01:00
Simon Vieille 0f1bc761b2
add no-wrap around the thead sort link 2023-11-10 19:42:45 +01:00
Simon Vieille 50dbb07314
update changelog 2023-11-10 19:35:48 +01:00
Simon Vieille 72e783f865
fix render of the URL when the window is small 2023-11-10 19:35:39 +01:00
Simon Vieille ee28c9abb7
copy the pager in the bottom of the index table
remove the with class of the action column
2023-11-10 19:28:20 +01:00
Simon Vieille 2bd6836a7f
fix issue on file manager when a file is selected in the file in the file picker 2023-11-09 17:19:09 +01:00
51 changed files with 1742 additions and 150 deletions

View file

@ -1,5 +1,32 @@
## [Unreleased]
## [v1.25.1] - 2024-05-13
### Added
* add drag&drop in the block builder
## [v1.25.0] - 2024-05-12
### Added
* add block builder widget
* allow to use `window.tinymceModes` to add or override tinymce modes
* add border color on tinymce editor
### Fixed
* fix default crud sort
* fix hidden save button in file manager
* fix template of CrudController (maker)
* fix undefined `window.tinymce.murph`
## [v1.24.1] - 2024-02-01
### Fixed
* update Murph version constant
## [v1.24.0] - 2024-01-27
### Added
* add CSS class `no-wrap`
* copy the pager of the CRUD at the bottom of the list
### Fixed
* fix an issue with the file manager when editing an item opened in a modal
* fix type casting in slugifier
## [v1.23.0] - 2023-11-01
### Added
* allow to define templates show before and after a murph collection item

View file

@ -0,0 +1,47 @@
<?php
namespace App\Core\BuilderBlock\Block\Bootstrap;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
use Symfony\Contracts\Translation\TranslatorInterface;
#[AutoconfigureTag('builder_block.widget')]
class AlertBlock extends BootstrapBlock
{
public function __construct(protected TranslatorInterface $translator)
{
}
public function configure()
{
parent::configure();
$options = [];
foreach ([
'Primary' => 'primary',
'Secondary' => 'secondary',
'Info' => 'info',
'Success' => 'success',
'Danger' => 'danger',
'Warning' => 'warning',
'Light' => 'light',
'Dark' => 'dark',
] as $k => $v) {
$options[] = [
'text' => $this->translator->trans($k),
'value' => $v,
];
}
$this
->setName('bsAlert')
->setLabel('Alert')
->setOrder(4)
->setIsContainer(true)
->setIcon('<i class="fas fa-exclamation-circle"></i>')
->setTemplate('@Core/builder_block/bootstrap/alert.html.twig')
->addSetting(name: 'level', label: 'Level', type: 'select', extraOptions: ['options' => $options])
;
}
}

View file

@ -0,0 +1,14 @@
<?php
namespace App\Core\BuilderBlock\Block\Bootstrap;
use App\Core\BuilderBlock\BuilderBlock;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
class BootstrapBlock extends BuilderBlock
{
public function configure()
{
$this->setCategory('Bootstrap');
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Core\BuilderBlock\Block\Bootstrap;
use App\Core\BuilderBlock\BuilderBlock;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
#[AutoconfigureTag('builder_block.widget')]
class ColumnBlock extends BootstrapBlock
{
public function configure()
{
parent::configure();
$this
->setName('bsColumn')
->setLabel('Column')
->setIsContainer(true)
->setOrder(3)
->setClass('col-12 col-lg-2 pr-md-1')
->setTemplate('@Core/builder_block/bootstrap/column.html.twig')
->setIcon('<i class="fas fa-columns"></i>')
->addSetting(name: 'size', label: 'Extra small', type: 'number', attributes: ['min' => 0, 'max' => 12])
->addSetting(name: 'sizeSm', label: 'Small', type: 'number', attributes: ['min' => 0, 'max' => 12])
->addSetting(name: 'sizeMd', label: 'Medium', type: 'number', attributes: ['min' => 0, 'max' => 12])
->addSetting(name: 'sizeLg', label: 'Large', type: 'number', attributes: ['min' => 0, 'max' => 12])
->addSetting(name: 'sizeXl', label: 'Extra large', type: 'number', attributes: ['min' => 0, 'max' => 12])
;
}
}

View file

@ -0,0 +1,25 @@
<?php
namespace App\Core\BuilderBlock\Block\Bootstrap;
use App\Core\BuilderBlock\BuilderBlock;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
#[AutoconfigureTag('builder_block.widget')]
class ContainerBlock extends BootstrapBlock
{
public function configure()
{
parent::configure();
$this
->setName('bsContainer')
->setLabel('Container')
->setIsContainer(true)
->setOrder(1)
->setTemplate('@Core/builder_block/bootstrap/container.html.twig')
->setIcon('<i class="fas fa-th"></i>')
->addSetting(name: 'isFluid', label: 'Fluid', type: 'checkbox')
;
}
}

View file

@ -0,0 +1,25 @@
<?php
namespace App\Core\BuilderBlock\Block\Bootstrap;
use App\Core\BuilderBlock\BuilderBlock;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
#[AutoconfigureTag('builder_block.widget')]
class RowBlock extends BootstrapBlock
{
public function configure()
{
parent::configure();
$this
->setName('bsRow')
->setLabel('Row')
->setOrder(2)
->setIsContainer(true)
->setIcon('<i class="fas fa-align-justify"></i>')
->setTemplate('@Core/builder_block/bootstrap/row.html.twig')
->addWidget('bsColumn')
;
}
}

View file

@ -0,0 +1,14 @@
<?php
namespace App\Core\BuilderBlock\Block\Editor;
use App\Core\BuilderBlock\BuilderBlock;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
class EditorBlock extends BuilderBlock
{
public function configure()
{
$this->setCategory('Editor');
}
}

View file

@ -0,0 +1,26 @@
<?php
namespace App\Core\BuilderBlock\Block\Editor;
use App\Core\BuilderBlock\BuilderBlock;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
#[AutoconfigureTag('builder_block.widget')]
class TextareaBlock extends EditorBlock
{
public function configure()
{
parent::configure();
$this
->setName('textarea')
->setLabel('Text')
->setIsContainer(false)
->setIcon('<i class="fas fa-pencil-alt"></i>')
->setTemplate('@Core/builder_block/editor/textarea.html.twig')
->addSetting(name: 'nl2br', label: 'Insert line breaks', type: 'checkbox', default: true)
->addSetting(name: 'allowHtml', label: 'Allow HTML', type: 'checkbox', default: false)
->addSetting(name: 'value', type: 'textarea')
;
}
}

View file

@ -0,0 +1,24 @@
<?php
namespace App\Core\BuilderBlock\Block\Editor;
use App\Core\BuilderBlock\BuilderBlock;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
#[AutoconfigureTag('builder_block.widget')]
class TinymceBlock extends EditorBlock
{
public function configure()
{
parent::configure();
$this
->setName('tinymce')
->setLabel('TinyMCE')
->setIsContainer(false)
->setIcon('<i class="fas fa-pencil-alt"></i>')
->setTemplate('@Core/builder_block/editor/tinymce.html.twig')
->addSetting(name: 'value', type: 'textarea', attributes: ['data-tinymce' => ''])
;
}
}

View file

@ -0,0 +1,195 @@
<?php
namespace App\Core\BuilderBlock;
abstract class BuilderBlock
{
protected string $name;
protected string $label;
protected ?string $class = 'col-12';
protected ?string $category = null;
protected array $settings = [];
protected array $widgets = [];
protected array $vars = [];
protected string $template = '';
protected bool $isContainer = false;
protected ?string $icon = null;
protected int $order = 1;
abstract public function configure();
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
public function getLabel(): string
{
return $this->label;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getName(): string
{
return $this->name;
}
public function setCategory(?string $category): self
{
$this->category = $category;
return $this;
}
public function getCategory(): ?string
{
return $this->category;
}
public function setIsContainer(bool $isContainer): self
{
$this->isContainer = $isContainer;
return $this;
}
public function getIsContainer(): bool
{
return $this->isContainer;
}
public function setWidgets(array $widgets): self
{
$this->widgets = $widgets;
return $this;
}
public function addWidget(string $widget): self
{
if (!in_array($widget, $this->widgets)) {
$this->widgets[] = $widget;
}
return $this;
}
public function getWidgets(): array
{
return $this->widgets;
}
public function setSettings(array $settings): self
{
$this->settings = $settings;
return $this;
}
public function addSetting(
string $name,
string $type = 'input',
?string $label = null,
array $attributes = [],
array $extraOptions = [],
$default = null
) {
$this->settings[$name] = [
'label' => $label,
'type' => $type,
'attr' => $attributes,
'default' => $default,
];
foreach ($extraOptions as $key => $value) {
if (!in_array($key, array_keys($this->settings[$name]))) {
$this->settings[$name][$key] = $value;
}
}
return $this;
}
public function getSettings(): array
{
return $this->settings;
}
public function setTemplate(string $template): self
{
$this->template = $template;
return $this;
}
public function getTemplate(): string
{
return $this->template;
}
public function setClass(?string $class): self
{
$this->class = $class;
return $this;
}
public function getClass(): ?string
{
return $this->class;
}
public function setIcon(?string $icon): self
{
$this->icon = $icon;
return $this;
}
public function getIcon(): ?string
{
return $this->icon;
}
public function setOrder(int $order): self
{
$this->order = $order;
return $this;
}
public function getOrder(): int
{
return $this->order;
}
public function buildVars(array $data, array $context)
{
}
public function getVars(): array
{
return $this->vars;
}
public function toArray(): array
{
return [
'label' => $this->getLabel(),
'category' => $this->getCategory(),
'isContainer' => $this->getIsContainer(),
'widgets' => $this->getWidgets(),
'settings' => $this->getSettings(),
'class' => $this->getClass(),
'icon' => $this->getIcon(),
];
}
}

View file

@ -0,0 +1,41 @@
<?php
namespace App\Core\BuilderBlock;
class BuilderBlockContainer
{
protected array $widgets = [];
public function addWidget(BuilderBlock $widget): self
{
$widget->configure();
$this->widgets[$widget->getName()] = $widget;
return $this;
}
public function removeWidget(string $name)
{
unset($this->widgets[$name]);
return $this;
}
public function getWidgets(): array
{
usort($this->widgets, fn(BuilderBlock $a, BuilderBlock $b) => $a->getOrder() <=> $b->getOrder());
return $this->widgets;
}
public function hasWidget(string $name)
{
return isset($this->widgets[$name]);
}
public function getWidget(string $name): BuilderBlock
{
return $this->widgets[$name];
}
}

View file

@ -424,15 +424,14 @@ abstract class CrudController extends AdminController
$sessionSortName = sprintf('%s_label', $sessionId);
$sessionSortDirection = sprintf('%s_direction', $sessionId);
$name = $request->query->get(
'_sort',
$session->get($sessionSortName, $defaultSort['label'] ?? null)
);
$name = $request->query->get('_sort', $session->get($sessionSortName)) ?? $defaultSort['label'] ?? null;
$direction = strtolower($request->query->get(
'_sort_direction',
$session->get($sessionSortDirection, $defaultSort['direction'] ?? 'asc')
));
$direction = strtolower(
$request->query->get(
'_sort_direction',
$session->get($sessionSortDirection)
) ?? $defaultSort['direction'] ?? 'asc'
);
$session->set($sessionSortName, $name);
$session->set($sessionSortDirection, $direction);

View file

@ -0,0 +1,40 @@
<?php
namespace App\Core\Controller\Editor;
use App\Core\BuilderBlock\BuilderBlockContainer;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
#[Route(path: '/admin/editor/builder_block')]
class BuilderBlockController extends AbstractController
{
public function __construct(protected TranslatorInterface $translator)
{
}
#[Route(path: '/widgets', name: 'admin_editor_builder_block_widgets', options: ['expose' => true])]
public function widgets(BuilderBlockContainer $container): JsonResponse
{
$data = [];
foreach ($container->getWidgets() as $widget) {
$data[$widget->getName()] = $this->translate($widget->toArray());
}
return $this->json($data);
}
protected function translate(array $data)
{
$data['label'] = $this->translator->trans($data['label']);
foreach ($data['settings'] as $key => $value) {
$data['settings'][$key]['label'] = $this->translator->trans($data['settings'][$key]['label']);
}
return $data;
}
}

View file

@ -0,0 +1,25 @@
<?php
namespace App\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use App\Core\BuilderBlock\BuilderBlockContainer;
class BuilderBlockPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
if (!$container->has(BuilderBlockContainer::class)) {
return;
}
$definition = $container->findDefinition(BuilderBlockContainer::class);
$taggedServices = $container->findTaggedServiceIds('builder_block.widget');
foreach ($taggedServices as $id => $tags) {
$definition->addMethodCall('addWidget', [new Reference($id)]);
}
}
}

View file

@ -46,99 +46,99 @@ class Configuration implements ConfigurationInterface
$treeBuilder->getRootNode()
->children()
->arrayNode('site')
->children()
->scalarNode('name')
->defaultValue('Murph')
->isRequired()
->end()
->scalarNode('logo')
->defaultValue('build/images/core/logo.svg')
->isRequired()
->end()
->arrayNode('controllers')
->prototype('array')
->children()
->scalarNode('name')
->cannotBeEmpty()
->end()
->scalarNode('action')
->cannotBeEmpty()
->end()
->end()
->end()
->end()
->arrayNode('security')
->children()
->arrayNode('roles')
->prototype('array')
->children()
->scalarNode('name')
->cannotBeEmpty()
->end()
->scalarNode('role')
->cannotBeEmpty()
->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('pages')
->prototype('array')
->children()
->scalarNode('name')
->isRequired()
->cannotBeEmpty()
->end()
->arrayNode('templates')
->prototype('array')
->children()
->scalarNode('name')
->cannotBeEmpty()
->end()
->scalarNode('file')
->cannotBeEmpty()
->end()
->end()
->end()
->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('editor_js')
->children()
->arrayNode('blocks')
->scalarPrototype()
->end()
->end()
->end()
->end()
->arrayNode('file_manager')
->children()
->arrayNode('mimes')
->scalarPrototype()
->end()
->defaultValue($defaultMimetypes)
->end()
->scalarNode('path')
->defaultValue('%kernel.project_dir%/public/uploads')
->cannotBeEmpty()
->end()
->scalarNode('path_uri')
->defaultValue('/uploads')
->cannotBeEmpty()
->end()
->arrayNode('path_locked')
->scalarPrototype()
->end()
->defaultValue($defaultLocked)
->end()
->end()
->end()
->end()
->arrayNode('site')
->children()
->scalarNode('name')
->defaultValue('Murph')
->isRequired()
->end()
->scalarNode('logo')
->defaultValue('build/images/core/logo.svg')
->isRequired()
->end()
->arrayNode('controllers')
->prototype('array')
->children()
->scalarNode('name')
->cannotBeEmpty()
->end()
->scalarNode('action')
->cannotBeEmpty()
->end()
->end()
->end()
->end()
->arrayNode('security')
->children()
->arrayNode('roles')
->prototype('array')
->children()
->scalarNode('name')
->cannotBeEmpty()
->end()
->scalarNode('role')
->cannotBeEmpty()
->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('pages')
->prototype('array')
->children()
->scalarNode('name')
->isRequired()
->cannotBeEmpty()
->end()
->arrayNode('templates')
->prototype('array')
->children()
->scalarNode('name')
->cannotBeEmpty()
->end()
->scalarNode('file')
->cannotBeEmpty()
->end()
->end()
->end()
->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('editor_js')
->children()
->arrayNode('blocks')
->scalarPrototype()
->end()
->end()
->end()
->end()
->arrayNode('file_manager')
->children()
->arrayNode('mimes')
->scalarPrototype()
->end()
->defaultValue($defaultMimetypes)
->end()
->scalarNode('path')
->defaultValue('%kernel.project_dir%/public/uploads')
->cannotBeEmpty()
->end()
->scalarNode('path_uri')
->defaultValue('/uploads')
->cannotBeEmpty()
->end()
->arrayNode('path_locked')
->scalarPrototype()
->end()
->defaultValue($defaultLocked)
->end()
->end()
->end()
->end();
;
return $treeBuilder;

View file

@ -2,6 +2,7 @@
namespace App\Core\DependencyInjection;
use App\Core\DependencyInjection\Compiler\BuilderBlockPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;

View file

@ -0,0 +1,20 @@
<?php
namespace App\Core\Entity\Site\Page;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class BuilderBlock extends JsonBlock
{
public function getValue()
{
$value = parent::getValue();
if (is_string($value)) {
return json_decode($value, true);
}
return [];
}
}

View file

@ -5,15 +5,6 @@ namespace App\Core\Entity\Site\Page;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class ChoiceBlock extends Block
class ChoiceBlock extends JsonBlock
{
public function getValue()
{
return json_decode(parent::getValue(), true);
}
public function setValue($value): self
{
return parent::setValue(json_encode($value));
}
}

View file

@ -0,0 +1,19 @@
<?php
namespace App\Core\Entity\Site\Page;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class JsonBlock extends Block
{
public function getValue()
{
return json_decode(parent::getValue(), true);
}
public function setValue($value): self
{
return parent::setValue(json_encode($value));
}
}

View file

@ -49,7 +49,7 @@ class NodeEventSubscriber extends EntityManagerEventSubscriber
$node = $event->getEntity();
$node->setCode($this->codeSlugify->slugify($node->getCode()));
$node->setCode($this->codeSlugify->slugify($node->getCode() ?? ''));
if ($node->getDisableUrl()) {
$node->setUrl(null);

View file

@ -0,0 +1,32 @@
<?php
namespace App\Core\Form\Site\Page;
use App\Core\Entity\Site\Page\BuilderBlock;
use App\Core\Form\Type\BuilderType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class BuilderBlockType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add(
'value',
BuilderType::class,
array_merge([
'required' => false,
'label' => false,
], $options['options']),
);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => BuilderBlock::class,
'options' => [],
]);
}
}

View file

@ -0,0 +1,38 @@
<?php
namespace App\Core\Form\Type;
use Symfony\Component\Form\Extension\Core\Type\CollectionType as BaseCollectionType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
class BuilderType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
parent::buildView($view, $form, $options);
$view->vars = array_replace($view->vars, [
]);
}
public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults([
'compound' => false,
]);
}
public function getBlockPrefix()
{
return 'builder';
}
}

View file

@ -0,0 +1,97 @@
<?php
namespace App\Core\Maker;
use Doctrine\Common\Annotations\Annotation;
use Symfony\Bundle\MakerBundle\ConsoleStyle;
use Symfony\Bundle\MakerBundle\DependencyBuilder;
use Symfony\Bundle\MakerBundle\Generator;
use Symfony\Bundle\MakerBundle\InputConfiguration;
use Symfony\Bundle\MakerBundle\Maker\AbstractMaker;
use Symfony\Bundle\MakerBundle\Str;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Filesystem\Filesystem;
class MakeBuilderBlock extends AbstractMaker
{
public static function getCommandName(): string
{
return 'make:builder-block';
}
public static function getCommandDescription(): string
{
return 'Creates a new builder block class';
}
public function configureCommand(Command $command, InputConfiguration $inputConf)
{
$command
->addArgument(
'builder-block-class',
InputArgument::OPTIONAL,
'Choose a name for your block class (e.g. <fg=yellow>ExampleBlock</>)'
)
->setHelp('')
;
}
public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator)
{
$blockClassNameDetails = $generator->createClassNameDetails(
$input->getArgument('builder-block-class'),
'BuilderBlock\\',
'Block'
);
$templatePath = sprintf(
'builder_block/%s.html.twig',
Str::asSnakeCase(preg_replace('/Block$/', '', $blockClassNameDetails->getShortName()))
);
$options = [
'entity' => $blockClassNameDetails->getFullName(),
'template' => $templatePath,
'label' => Str::asHumanWords($blockClassNameDetails->getShortName())
];
$blockPath = $generator->generateController(
$blockClassNameDetails->getFullName(),
__DIR__.'/../Resources/maker/builder/Block.tpl.php',
$options
);
$generator->writeChanges();
$realTemplatePath = 'templates/'.$templatePath;
$filesystem = new Filesystem();
if (!$filesystem->exists($templatePath)) {
$filesystem->mkdir(dirname($realTemplatePath));
$filesystem->dumpFile($realTemplatePath, $this->getTemplate());
$io->comment(sprintf('<fg=blue>created</>: %s', $realTemplatePath));
}
$this->writeSuccessMessage($io);
}
protected function getTemplate(): string
{
return <<< EOF
<div id="{{ id }}">
{% for item in children %}
{{ item|block_to_html(context) }}
{% endfor %}
</div>
EOF;
}
public function configureDependencies(DependencyBuilder $dependencies)
{
}
}

View file

@ -149,6 +149,7 @@ EOF
'textarea' => null,
'choice' => 'BlockEntity\\ChoiceBlock::class',
'collection' => 'BlockEntity\\CollectionBlock::class',
'builder' => 'BlockEntity\\BuilderBlock::class',
'editor_js_textarea' => null,
'file' => 'BlockEntity\\FileBlock::class',
'file_picker' => null,

View file

@ -3,7 +3,7 @@
namespace App\Core;
if (!defined('MURPH_VERSION')) {
define('MURPH_VERSION', 'v1.23.0');
define('MURPH_VERSION', 'v1.25.1');
}
/**

View file

@ -619,7 +619,11 @@ fieldset.form-group {
&-filter {
padding-right: 20px;
padding-bottom: 20px;
padding-bottom: 15px;
.pagination {
margin-bottom: 0;
}
@media screen and (max-width: 769px) {
padding-right: 10px;
@ -650,8 +654,20 @@ fieldset.form-group {
}
}
.table .crud-batch-column {
width: 1%;
.table {
.crud-batch-column {
width: 1%;
}
.crud-action-column {
text-align: right;
white-space: nowrap;
width: 1px;
}
}
.no-wrap {
white-space: nowrap;
}
form {
@ -728,11 +744,93 @@ label.required::after {
background: map-get($theme-colors, 'dark-blue');
}
.tox.tox-silver-sink.tox-tinymce-aux {
z-index: 3000 !important;
.tox {
&.tox-silver-sink.tox-tinymce-aux {
z-index: 3000 !important;
}
&.tox-tinymce {
border-color: $input-border-color;
border-radius: 5px;
}
}
.field-boolean {
color: #49555b;
font-size: 20px;
}
.builder-widget {
.block {
border: 1px solid rgba(map-get($theme-colors, 'dark-blue'), 0.3);
padding: 10px;
border-radius: 4px;
margin-bottom: 10px;
background: rgba(map-get($theme-colors, 'dark-blue'), 0.02);
}
> .block {
border: 1px solid map-get($theme-colors, 'dark-blue');
}
.block-header {
.block-header-item {
font-size: 12px;
display: inline-block;
margin-bottom: 10px;
padding: 2px 6px;
border-radius: 4px;
margin-right: 2px;
cursor: pointer;
}
}
$block-colors: #E183F5 #E3F7C6 #82DDF5 #F5BA82 #A088A6;
$block-colors-length: length($block-colors);
@for $i from 1 through 100 {
$block-color-index: ($block-colors-length + $i) % $block-colors-length + 1;
.block-depth-#{$i} {
.block-label {
background: nth($block-colors, $block-color-index);
border: 1px solid darken(nth($block-colors, $block-color-index), 50%);
color: darken(nth($block-colors, $block-color-index), 50%);
}
.builder-add .btn {
background: nth($block-colors, $block-color-index);
border: 1px solid darken(nth($block-colors, $block-color-index), 50%);
color: darken(nth($block-colors, $block-color-index), 50%);
}
}
}
.builder-add .btn {
font-size: 12px;
line-height: 14px;
padding: 3px 5px;
}
.block-settings-inverse {
background: none;
border: 1px solid map-get($theme-colors, 'dark-blue');
color: map-get($theme-colors, 'dark-blue');
}
.block-settings {
padding: 4px;
margin-bottom: 5px;
}
.block-id {
font-size: 12px;
margin-right: 5px;
}
.block-show-dropzone {
.block-dropzone {
min-height: 40px;
}
}
}

View file

@ -1,6 +1,7 @@
import '../../../../../../../../assets/css/admin.scss';
require('../../../../../../../../node_modules/bootstrap/dist/js/bootstrap.min.js')
require('./modules/sidebar.js')()
require('./modules/table-fixed.js')()
require('./modules/form-confirm.js')()
require('./modules/form-file.js')()
@ -27,5 +28,5 @@ require('./modules/file-manager.js')()
require('./modules/file-picker.js')()
require('./modules/analytics.js')()
require('./modules/page.js')()
require('./modules/sidebar.js')()
require('./modules/node.js')()
require('./modules/builder-block.js')()

View file

@ -0,0 +1,123 @@
<template>
<Draggable
v-if="Object.keys(widgets).length"
v-model="value"
:key="blockKey"
:animation="200"
group="children"
ghost-class="ghost"
@start="dragStart"
@end="dragEnd"
handle=".dragger"
:class="{'block-show-dropzone': showDragDrop}"
class="block"
>
<BuilderBlockItem
v-for="(block, key) in value"
:key="block.id + '-' + key"
:item="block"
:widgets="widgets"
:openedBlocks="openedBlocks"
:depth="1"
@remove-item="removeBlock(key)"
@drag-start="dragStart"
@drag-end="dragEnd"
/>
<div class="container">
<BuilderBlockCreate
:container="value"
:widgets="widgets"
:openedBlocks="openedBlocks"
:allowedWidgets="[]"
/>
</div>
<textarea :name="name" class="d-none">{{ toJson(value) }}</textarea>
</Draggable>
</template>
<script>
import BuilderBlockItem from './BuilderBlockItem'
import BuilderBlockCreate from './BuilderBlockCreate'
import Routing from '../../../../../../../../../friendsofsymfony/jsrouting-bundle/Resources/public/js/router.min.js'
import Draggable from 'vuedraggable'
const axios = require('axios').default
const routes = require('../../../../../../../../../../public/js/fos_js_routes.json')
Routing.setRoutingData(routes)
export default {
name: 'BuilderBlock',
props: {
id: {
type: String,
required: true,
},
name: {
type: String,
required: true,
},
initialValue: {
type: Array,
required: false,
}
},
data() {
return {
value: this.initialValue,
widgets: {},
openedBlocks: {},
blockKey: 0,
showDragDrop: false,
}
},
methods: {
toJson(value) {
return JSON.stringify(value)
},
triggerBuilderBlockEvent() {
document.querySelector('body').dispatchEvent(new Event('builder_block.update'))
},
removeBlock(key) {
let newValue = []
this.value.forEach((v, k) => {
if (k !== key) {
newValue.push(v)
}
})
this.value = newValue
++this.blockKey
},
dragStart() {
this.showDragDrop = true
},
dragEnd() {
this.showDragDrop = false
++this.blockKey
},
},
components: {
BuilderBlockItem,
BuilderBlockCreate,
Draggable,
},
mounted() {
this.triggerBuilderBlockEvent()
const that = this
axios.get(Routing.generate('admin_editor_builder_block_widgets'))
.then((response) => {
that.widgets = response.data
})
},
created() {
this.triggerBuilderBlockEvent()
},
updated() {
this.triggerBuilderBlockEvent()
}
}
</script>

View file

@ -0,0 +1,181 @@
<style scoped>
.builder-block-picker {
padding: 8px;
border: 1px solid #333;
border-radius: 4px;
background: #fff;
}
.builder-block-picker-menu {
width: 150px;
}
.builder-block-picker-widgets {
width: calc(100% - 150px - 10px);
padding-left: 5px;
}
.nav-item {
cursor: pointer;
width: 100%;
}
.widget-icon {
margin-right: 3px;
}
.widget {
background: #fff;
padding: 10px;
border-radius: 4px;
cursor: pointer;
margin-right: 7px;
margin-bottom: 9px;
border: 1px solid #b4b4b4;
font-weight: bold;
}
.widget:hover {
background: #eee;
border: 1px solid #1e2430;
}
</style>
<template>
<div class="builder-add">
<span class="btn btn-secondary" v-on:click="togglePicker">
<span class="fa fa-plus"></span>
</span>
<div class="builder-block-picker mt-2 row" :class="{'d-none': !showPicker}">
<div class="col-auto builder-block-picker-menu">
<ul class="nav nav-pills pl-0">
<li
v-for="(category, key) in categories()"
v-if="Object.keys(category.widgets).length"
class="nav-item d-block"
>
<a
class="nav-link d-block mb-1"
:class="{'active': activeCategory == key}"
v-on:click="activeCategory = key"
>
{{ category.label }}
</a>
</li>
</ul>
</div>
<div
v-for="(category, key) in categories()"
v-if="Object.keys(category.widgets).length"
class="col-auto builder-block-picker-widgets"
:class="{'d-none': activeCategory !== key}"
>
<div class="row">
<div
v-for="(widget, name) in category.widgets"
v-on:click="add(name, widget)"
class="widget col-auto"
>
<span class="widget-icon" v-if="widget.icon" v-html="widget.icon"></span>
{{ widget.label }}
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'BuilderBlockCreate',
props: {
container: {
type: Array,
required: true
},
widgets: {
type: Object,
required: true
},
allowedWidgets: {
type: Array,
required: true
},
openedBlocks: {
type: Object,
required: true
}
},
data() {
return {
showPicker: false,
activeCategory: 'all',
}
},
methods: {
add(name, widget) {
let settings = {}
for (let i in widget.settings) {
settings[i] = widget.settings[i].default
}
const block = {
id: this.makeId(),
widget: name,
settings,
children: [],
}
this.container.push(block)
this.openedBlocks[block.id] = true
this.$emit('updateContainer', this.container)
this.togglePicker()
},
makeId() {
let result = ''
const characters = 'abcdefghijklmnopqrstuvwxyz0123456789'
const charactersLength = characters.length
for (let i = 0; i < 7; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength))
}
return `block-${result}`
},
togglePicker() {
this.showPicker = !this.showPicker
},
categories() {
let items = {
all: {label: 'All', widgets: {}},
}
for (let widgetName in this.widgets) {
let value = this.widgets[widgetName]
if (!value.category) {
value.category = 'all'
}
if (typeof items[value.category] === 'undefined') {
items[value.category] = {
label: value.category,
widgets: {},
}
}
if (!this.allowedWidgets.length || this.allowedWidgets.includes(widgetName)) {
items[value.category].widgets[widgetName] = value
items['all'].widgets[widgetName] = value
}
}
return items
}
},
}
</script>

View file

@ -0,0 +1,159 @@
<template>
<div
class="block"
:class="'block-depth-' + depth"
v-if="widget"
:key="blockKey"
>
<div class="block-header">
<div class="float-right">
<span class="block-id">
{{ item.id }}
</span>
<div class="block-header-item text-white bg-danger" v-on:click="removeMe(item)">
<span class="fa fa-trash"></span>
</div>
</div>
<div
class="block-header-item block-label"
:title="item.widget"
>
{{ widget.label }}
</div>
<div
class="block-header-item block-settings-inverse"
v-on:click="toggleSettings"
v-if="Object.keys(widget.settings).length"
>
<span class="fa fa-cog"></span>
</div>
<div
class="block-header-item block-settings-inverse dragger"
>
<span class="fa fa-arrows-alt"></span>
</div>
</div>
<div class="block-settings" v-if="Object.keys(widget.settings).length" :class="{'d-none': !showSettings}">
<div class="row">
<BuilderBlockSetting
class="mb-0"
v-for="(params, setting) in widget.settings"
:key="item.id + '-' + setting"
:class="widget.class"
:item="item"
:params="params"
:setting="setting"
/>
</div>
</div>
<Draggable
v-if="widget.isContainer"
v-model="item.children"
ghost-class="ghost"
group="children"
@start="dragStart"
@end="dragEnd"
:animation="200"
handle=".dragger"
class="block-dropzone"
>
<BuilderBlockItem
v-if="item.children !== null && item.children.length > 0"
v-for="(child, key) in item.children"
:key="child.id"
:item="child"
:widgets="widgets"
:openedBlocks="openedBlocks"
:depth="depth + 1"
@remove-item="removeBlock(key)"
@drag-start="dragStart"
@drag-end="dragEnd"
/>
</Draggable>
<div v-if="widget.isContainer" class="container">
<BuilderBlockCreate
:container="item.children"
:widgets="widgets"
:openedBlocks="openedBlocks"
:allowedWidgets="widget.widgets"
/>
</div>
</div>
</template>
<script>
import BuilderBlockCreate from './BuilderBlockCreate'
import BuilderBlockSetting from './BuilderBlockSetting'
import Draggable from 'vuedraggable'
export default {
name: 'BuilderBlockItem',
props: {
widgets: {
type: Object,
required: true
},
item: {
type: Object,
required: true
},
openedBlocks: {
type: Object,
required: true
},
depth: {
type: Number,
required: true
}
},
data() {
return {
widget: null,
showSettings: this.openedBlocks[this.item.id] === true,
blockKey: 0,
}
},
methods: {
toggleSettings() {
this.openedBlocks[this.item.id] = !this.openedBlocks[this.item.id]
this.showSettings = !this.showSettings
},
removeMe() {
this.$emit('remove-item')
},
removeBlock(key) {
let children = []
this.item.children.forEach((v, k) => {
if (k !== key) {
children.push(v)
}
})
this.item.children = children
++this.blockKey
},
dragStart() {
this.$emit('drag-start')
},
dragEnd() {
this.$emit('drag-end')
++this.blockKey
},
},
components: {
BuilderBlockCreate,
BuilderBlockSetting,
Draggable,
},
mounted() {
this.widget = this.widgets[this.item.widget]
},
updated() {
document.querySelector('body').dispatchEvent(new Event('builder_block.update'))
}
}
</script>

View file

@ -0,0 +1,59 @@
<template>
<label class="form-group mb-2">
<span v-if="params.label && params.type !== 'checkbox'" v-text="params.label"></span>
<input
v-if="['number', 'checkbox', 'text'].includes(params.type)"
v-model="item.settings[setting]"
v-bind="params.attr"
:type="params.type"
:class="{'form-control': params.type !== 'checkbox'}"
/>
<span v-if="params.label && params.type == 'checkbox'" v-text="params.label"></span>
<textarea
v-if="params.type == 'textarea'"
v-model="item.settings[setting]"
v-bind="params.attr"
class="form-control"
></textarea>
<select
v-if="params.type == 'select'"
v-model="item.settings[setting]"
v-bind="params.attr"
class="form-control"
>
<option :value="v.value" v-for="(v, k) in params.options" :key="k">
{{ v.text }}
</option>
</select>
</label>
</template>
<script>
export default {
name: 'BuilderBlockSetting',
props: {
item: {
type: Object,
required: true,
},
params: {
type: Object,
required: true,
},
setting: {
type: String,
required: true,
}
},
}
</script>
<style scoped>
label > span {
margin-bottom: 3px;
}
</style>

View file

@ -201,7 +201,6 @@ import Routing from '../../../../../../../../../friendsofsymfony/jsrouting-bundl
import FileIcon from './FileIcon'
const axios = require('axios').default
const $ = require('jquery')
const routes = require('../../../../../../../../../../public/js/fos_js_routes.json')
Routing.setRoutingData(routes)

View file

@ -0,0 +1,28 @@
const Vue = require('vue').default
const BuilderBlock = require('../components/builder-block/BuilderBlock').default
module.exports = () => {
const wrappers = document.querySelectorAll('.builder-widget')
wrappers.forEach((wrapper) => {
const component = wrapper.querySelector('.builder-widget-component')
return new Vue({
el: component,
template: `<BuilderBlock
:initialValue="value"
name="${component.getAttribute('data-name')}"
id="${component.getAttribute('data-id')}"
/>`,
data() {
return {
value: JSON.parse(component.getAttribute('data-value'))
}
},
components: {
BuilderBlock
}
})
})
}

View file

@ -36,8 +36,9 @@ const fileManagerBrowser = function (callback) {
const clickCallback = (e) => {
callback($(e.target).attr('data-value'), {})
$('div[id^="modal-container-"]').modal('hide')
container.modal('hide')
$('#fm-modal').next('.modal-backdrop').remove()
$('#fm-modal').next('div[id^="modal-container-"]').modal('hide')
$('#fm-modal').modal('hide')
$('body').off('click', '#file-manager-insert', clickCallback)
}

View file

@ -1,9 +1,34 @@
const $ = require('jquery')
const SidebarOpener = () => {
$('.sidebar-toggler .btn').click(() => {
$('.sidebar').toggleClass('is-open')
const Sidebar = () => {
const menu = document.querySelector('.sidebar')
if (!menu) {
return
}
const stickyMenu = menu.querySelector('.sidebar-sticky')
const items = stickyMenu.querySelectorAll('a.nav-link')
const currentItem = menu.querySelector('.nav-link.active')
items.forEach((item) => {
item.addEventListener('click', () => {
localStorage.setItem('sidebar-item-top', stickyMenu.scrollTop)
})
})
const toggler = menu.querySelector('.sidebar-toggler .btn')
toggler.addEventListener('click', () => {
menu.classList.toggle('is-open')
})
if (currentItem) {
stickyMenu.scrollTo({
top: Math.min(currentItem.offsetTop, localStorage.getItem('sidebar-item-top') ?? 0),
behavior: 'smooth'
})
}
}
module.exports = SidebarOpener
module.exports = Sidebar

View file

@ -53,7 +53,7 @@ const fileManagerBrowser = function (callback) {
})
}
if (typeof window.tinymce !== 'undefined') {
const createTinymceConfig = function () {
window.tinymce.murph = window.tinymce.murph || {}
window.tinymce.murph.selector = window.tinymce.murph.selector || '*[data-tinymce]'
window.tinymce.murph.configurationBase = window.tinymce.murph.configurationBase || {
@ -74,12 +74,15 @@ if (typeof window.tinymce !== 'undefined') {
})
editor.on('Change', () => {
editor.save();
editor.getElement().dispatchEvent(new Event('input'));
window.tinymce.triggerSave(false, true)
})
}
}
window.tinymce.murph.modes = window.tinymce.murph.modes || {}
window.tinymceModes = window.tinymceModes || {}
window.tinymce.murph.modes.default = window.tinymce.murph.modes.default || {
plugins: 'print preview importcss searchreplace visualblocks visualchars fullscreen template table charmap hr pagebreak nonbreaking toc insertdatetime advlist lists wordcount textpattern noneditable help charmap quickbars link image code autoresize',
@ -95,6 +98,11 @@ if (typeof window.tinymce !== 'undefined') {
toolbar: 'undo redo | bold italic underline'
}
window.tinymce.murph.modes = {
...window.tinymce.murph.modes,
...window.tinymceModes
}
tinymce.addI18n('fr_FR', {
Redo: 'R\u00e9tablir',
Undo: 'Annuler',
@ -612,17 +620,21 @@ const doInitEditor = () => {
}
module.exports = function () {
if (typeof tinymce === 'undefined') {
return
}
const observer = new MutationObserver(doInitEditor)
const config = { attributes: false, childList: true, subtree: true }
observer.observe(document.querySelector('body'), config)
document.querySelector('body').addEventListener('builder_block.update', () => {
window.setTimeout(() => {
createTinymceConfig()
doInitEditor()
}, 500)
})
$(() => {
createTinymceConfig()
doInitEditor()
const observer = new MutationObserver(doInitEditor)
const config = { attributes: false, childList: true, subtree: true }
observer.observe(document.querySelector('body'), config)
$('body').on('hidden.bs.modal', '.modal', (e) => {
if (!$('.tox-dialog').length) {
$(e.target).find('.tox-tinymce').each(() => {

View file

@ -0,0 +1,38 @@
<?php echo "<?php\n"; ?>
namespace <?php echo $namespace; ?>;
use App\Core\BuilderBlock\BuilderBlock;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
#[AutoconfigureTag('builder_block.widget')]
class <?php echo $class_name; ?> extends BuilderBlock
{
public function configure()
{
$this
->setName('<?php echo $class_name; ?>')
->setCategory('Custom')
->setTemplate('<?php echo $template; ?>')
->setLabel('<?php echo $label; ?>')
// ->setOrder(1)
// ->setIsContainer(false)
// ->setIcon('<i class="fas fa-pencil-alt"></i>')
// ->setClass('col-md-12')
// ->addSetting(name: 'value1', label: 'Text', type: 'text', attributes: [], default: '')
// ->addSetting(name: 'value2', label: 'Checkbox', type: 'checkbox', attributes: [], default: true)
// ->addSetting(name: 'value2', label: 'Number', type: 'checkbox', attributes: [], default: true)
// ->addSetting(name: 'value3', label: 'Textarea', type: 'textarea', attributes: [], default: '')
// ->addSetting(name: 'value4', label: 'Choice', type: 'select', attributes: [], default: '', extraOptions: [
// 'options' => [
// ['text' => 'Choice 1', 'value' => 'choice1'],
// ['text' => 'Choice 2', 'value' => 'choice2'],
// ],
// ])
;
}
public function buildVars(array $data, array $context)
{
}
}

View file

@ -11,11 +11,11 @@ use <?php echo $entity; ?> as Entity;
use <?php echo $factory; ?> as Factory;
use <?php echo $form; ?> as Type;
use <?php echo $repository_query; ?> as RepositoryQuery;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class <?php echo $class_name; ?> extends CrudController
{

View file

@ -224,3 +224,11 @@
"All roles": "Tous les rôles"
"Enable A/B Testing": "Activer le test A/B"
"Color": "Couleur"
"Extra small": "Très petit"
"Small": "Petit"
"Medium": "Moyen"
"Large": "Large"
"Extra large": "Très large"
"Level": "Niveau"
"Insert line breaks": "Ajouter les retours chariot"
'Allow HTML': "Autoriser l'HTML"

View file

@ -1,6 +1,7 @@
{% extends '@Core/admin/layout.html.twig' %}
{% set context = context ?? 'index' %}
{% set pager_render = pager is defined ? knp_pagination_render(pager) : null %}
{% block title %}{{ configuration.pageTitle(context)|trans }} {{ parent() ? ('- ' ~ parent()) : '' }}{% endblock %}
@ -67,16 +68,17 @@
<div class="row crud-header-filter">
<div class="col-auto ml-auto {% if pager.getPaginationData.pageCount > 1 %}mr-3{% endif %}">
<button data-modal="{{ path(configuration.pageRoute('filter'), configuration.pageRouteParams('filter')) }}" class="btn btn-sm btn-secondary">
<span class="fa fa-search mr-1"></span>
{{ 'Filter'|trans }} {% if not filters.isEmpty %}({{ 'yes'|trans }}){% endif %}
</button>
</div>
<div class="col-auto">
{{ knp_pagination_render(pager) }}
{{ pager_render|raw }}
</div>
</div>
{% else %}
<div class="crud-header-filter">
{{ knp_pagination_render(pager) }}
{{ pager_render|raw }}
</div>
{% endif %}
{% endblock %}
@ -85,6 +87,7 @@
{% block list %}
{% set isSortable = configuration.isSortableCollection(context) %}
{% set colspan = configuration.fields(context)|length + 1 + (configuration.hasBatchAction(context) ? 1 : 0) %}
<div class="table-responsive">
<table class="table">
@ -129,10 +132,13 @@
<a href="{{ url }}">
{% if icon is defined %}
<span class="{{ icon }}"></span>
<span class="no-wrap">
<span class="{{ icon }}"></span>
{{ label|trans }}
</span>
{% else %}
{{ label|trans }}
{% endif %}
{{ label|trans }}
</a>
{% else %}
{{ label|trans }}
@ -144,7 +150,7 @@
{% endblock %}
{% endfor %}
{% if configuration.showActions %}
<th class="crud-action-column miw-100 text-right">
<th class="crud-action-column">
{{ 'Actions'|trans }}
</th>
{% endif %}
@ -223,7 +229,7 @@
{% endfor %}
{% if configuration.showActions %}
<td class="crud-action-column col-2 miw-200 text-right">
<td class="crud-action-column">
{% block list_item_actions %}
{% block list_item_actions_before %}{% endblock %}
@ -281,6 +287,10 @@
</div>
{% endif %}
<div class="float-right mr-2">
{{ pager_render|raw }}
</div>
{% if configuration.hasBatchAction(context) %}
<div class="mb-2">
<form class="form-inline" action="{{ path(configuration.pageRoute('batch'), {
@ -315,13 +325,8 @@
{% endblock %}
{% endif %}
{% else %}
{% set count = configuration.fields(context)|length + 1 %}
{% if configuration.hasBatchAction(context) %}
{% set count = count + 1 %}
{% endif %}
<tr>
<td class="col-12 text-center p-4 text-black-50" colspan="{{ count }}">
<td class="col-12 text-center p-4 text-black-50" colspan="{{ colspan }}">
<div class="display-1">
<span class="fa fa-search"></span>
</div>

View file

@ -0,0 +1,5 @@
<div class="alert {% if settings.level|default(null) %}alert-{{ settings.level }}{% endif %}" id="{{ id }}">
{% for item in children %}
{{ item|block_to_html(context) }}
{% endfor %}
</div>

View file

@ -0,0 +1,13 @@
{% set sizes = {
'col-': settings.size|default(null),
'col-xs-': settings.sizeXs|default(null),
'col-md-': settings.sizeMd|default(null),
'col-lg-': settings.sizeLg|default(null),
'col-xl-': settings.sizeXl|default(null),
} %}
<div class="col {% for i, v in sizes%}{% if v|length %}{{ i }}{{ v }} {% endif %}{% endfor -%}" id="{{ id }}">
{% for item in children %}
{{ item|block_to_html(context) }}
{% endfor %}
</div>

View file

@ -0,0 +1,5 @@
<div class="container{% if settings.isFluid|default(false) %}-fluid{% endif %}" id="{{ id }}">
{% for item in children %}
{{ item|block_to_html(context) }}
{% endfor %}
</div>

View file

@ -0,0 +1,5 @@
<div class="row" id="{{ id }}">
{% for item in children %}
{{ item|block_to_html(context) }}
{% endfor %}
</div>

View file

@ -0,0 +1,13 @@
{%- if settings.nl2br|default(null) -%}
{% if settings.allowHtml|default(null) %}
{{- settings.value|default(null)|raw|nl2br -}}
{%- else -%}
{{- settings.value|default(null)|nl2br -}}
{%- endif -%}
{%- else -%}
{% if settings.allowHtml|default(null) %}
{{- settings.value|default(null)|raw -}}
{%- else -%}
{{- settings.value|default(null) -}}
{%- endif -%}
{% endif %}

View file

@ -0,0 +1 @@
{{ settings.value|default(null)|file_attributes|murph_url|raw }}

View file

@ -197,6 +197,10 @@
</div>
<div>
{% if splInfo.isFile and not isLocked %}
<button type="submit" class="btn btn-primary" form="form-fm-attributes">{{ 'Save'|trans }}</button>
{% endif %}
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ 'Close'|trans }}</button>
</div>
{% endif %}

View file

@ -1,5 +1,19 @@
{% extends 'bootstrap_4_layout.html.twig' %}
{% block builder_widget %}
{% set row_attr = row_attr|merge({class: 'builder-widget ' ~ (row_attr.class ?? '')}) %}
{% set value = value is iterable ? value|json_encode : value %}
{% if value == '' %}
{% set value = '[]' %}
{% endif %}
<div {% for attr, value in row_attr %}{{ attr }}="{{ value }}" {% endfor %}>
<div class="builder-widget-component" data-value="{{ value }}" data-name="{{ full_name }}" data-id="{{ id }}">
</div>
</div>
{% endblock %}
{% block grapesjs_widget %}
<div class="gjs"></div>
<div class="d-none">

View file

@ -81,7 +81,7 @@
<div class="col-6" style="padding-left: {{ (node.treeLevel - 1) * 30 }}px">
{{ node.label }}
<span class="ml-3 btn-group d-none d-md-inline-block">
<span class="ml-3 btn-group d-none d-md-inline-block no-wrap">
{% if node.aliasNode %}
<span title="{{ node.aliasNode.label }}" data-toggle="tooltip" data-placement="top" class="btn btn-sm border border-secondary btn-light">
<span class="fa fa-file-import"></span>

View file

@ -13,7 +13,7 @@ class Slugify
{
public function slugify($data): ?string
{
return $this->create()->slugify($data);
return $this->create()->slugify((string) $data);
}
protected function create(): BaseSlugify

View file

@ -0,0 +1,64 @@
<?php
namespace App\Core\Twig\Extension;
use App\Core\BuilderBlock\BuilderBlockContainer;
use Twig\Environment;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
class BuilderExtension extends AbstractExtension
{
public function __construct(protected Environment $twig, protected BuilderBlockContainer $container)
{
}
/**
* {@inheritdoc}
*/
public function getFilters()
{
return [
new TwigFilter('block_to_html', [$this, 'buildHtml'], ['is_safe' => ['html']]),
];
}
public function buildHtml(null|array|string $data, array $context = []): ?string
{
if (null === $data) {
return null;
}
if (is_string($data)) {
$data = json_decode($data, true);
}
if (!is_array($data)) {
return null;
}
if (isset($data['widget'])) {
if (!$this->container->hasWidget($data['widget'])) {
return null;
}
$widget = $this->container->getWidget($data['widget']);
$widget->buildVars($data, $context);
return $this->twig->render($widget->getTemplate(), [
'id' => $data['id'],
'settings' => $data['settings'],
'children' => $data['children'],
'context' => $context,
'vars' => $widget->getVars(),
]);
}
$render = '';
foreach ($data as $item) {
$render .= $this->buildHtml($item, $context);
}
return $render;
}
}