wysiwyg block

This commit is contained in:
2025-09-04 21:46:12 +01:00
parent 89ca57e44d
commit a665235b9f
15 changed files with 822 additions and 85 deletions

View File

@@ -0,0 +1,13 @@
@extends('layouts.block', [
'block' => $block,
'data' => $data,
])
@section('block-content')
@if(@$data['wysiwyg'])
<div class="main-wysiwyg wysiwyg">
{!! @$data['wysiwyg'] !!}
</div>
@endif
@overwrite

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

View File

@@ -0,0 +1,74 @@
<?php
namespace Blocks\WYSIWYG;
use App\Utilities;
use App\ACF;
class WYSIWYG
{
public function __construct()
{
add_action('acf/init', [$this, 'init']);
}
public function init()
{
acf_register_block_type([
'name' => 'badegg/wysiwyg',
'title' => __('Basic Content'),
'description' => __('Basic text editor '),
'render_callback' => [ $this, 'render'],
'category' => 'badegg',
'icon' => 'editor-paragraph',
'supports' => [
'align' => false,
],
'example' => [
'attributes' => [
'mode' => 'preview',
'data' => [
'inserter' => true,
],
],
],
]);
}
public function render($block, $content = '', $is_preview = false)
{
$name = basename(__FILE__, '.php');
$themeURL = get_template_directory_uri();
if($is_preview && @$block['data']['inserter']):
echo '<img style="display: block; width: 100%" src="' . $themeURL . '/resources/views/blocks/' . $name . '/' . $name . '.jpg" />';
return;
endif;
$CssClasses = new Utilities\CssClasses;
$Colour = new Utilities\Colour;
$CloneGroup = new ACF\CloneGroup;
$data = [];
$fields = [
'wysiwyg',
];
$fields = array_merge($fields, $CloneGroup->block_all());
foreach($fields as $field):
$data[$field] = get_field($field);
endforeach;
unset($block['data']);
$block['name'] = str_replace('acf/', '', $block['name']);
$data = array_merge($data, $block);
$data['section_classes'] = $CssClasses->section($data);
$data['block'] = $block;
echo \Roots\view("blocks.$name.$name", [
'data' => $data,
'block' => $block,
])->render();
}
}

View File

@@ -0,0 +1,13 @@
.section-badegg-wysiwyg {
container-name: WYSIWYG;
container-type: inline-size;
.main-wysiwyg {
@container WYSIWYG (min-width: #{$screen-lg}) {
font-size: 1.25em;
}
}
.section-intro { padding-bottom: $sectionSmall; }
.section-footer { padding-top: $sectionSmall; }
}