From ef7681f16af9ef4864622efecaa142416544ac36 Mon Sep 17 00:00:00 2001 From: megasteve19 Date: Sat, 27 Jan 2024 23:03:05 +0300 Subject: [PATCH 1/2] `Fakeable` contract. --- src/Blocks/Attaches.php | 3 ++- src/Blocks/Checklist.php | 3 ++- src/Blocks/Code.php | 3 ++- src/Blocks/Delimiter.php | 3 ++- src/Blocks/Embed.php | 3 ++- src/Blocks/Header.php | 3 ++- src/Blocks/Image.php | 3 ++- src/Blocks/LinkTool.php | 3 ++- src/Blocks/ListBlock.php | 3 ++- src/Blocks/Paragraph.php | 3 ++- src/Blocks/Personality.php | 3 ++- src/Blocks/Quote.php | 3 ++- src/Blocks/Raw.php | 3 ++- src/Blocks/Table.php | 4 ++-- src/Blocks/Warning.php | 3 ++- src/Contracts/Fakeable.php | 17 +++++++++++++++++ src/EditorPhp.php | 14 ++++++++++---- 17 files changed, 57 insertions(+), 20 deletions(-) create mode 100644 src/Contracts/Fakeable.php diff --git a/src/Blocks/Attaches.php b/src/Blocks/Attaches.php index 2bcd866..d2477cf 100644 --- a/src/Blocks/Attaches.php +++ b/src/Blocks/Attaches.php @@ -3,11 +3,12 @@ namespace BumpCore\EditorPhp\Blocks; use BumpCore\EditorPhp\Block\Block; +use BumpCore\EditorPhp\Contracts\Fakeable; use BumpCore\EditorPhp\EditorPhp; use BumpCore\EditorPhp\Helpers; use Illuminate\Support\Facades\View; -class Attaches extends Block +class Attaches extends Block implements Fakeable { /** * Tag allow list for purifying data. diff --git a/src/Blocks/Checklist.php b/src/Blocks/Checklist.php index 721a9c8..88bbc6c 100644 --- a/src/Blocks/Checklist.php +++ b/src/Blocks/Checklist.php @@ -3,11 +3,12 @@ namespace BumpCore\EditorPhp\Blocks; use BumpCore\EditorPhp\Block\Block; +use BumpCore\EditorPhp\Contracts\Fakeable; use BumpCore\EditorPhp\EditorPhp; use BumpCore\EditorPhp\Helpers; use Illuminate\Support\Facades\View; -class Checklist extends Block +class Checklist extends Block implements Fakeable { /** * Tag allow list for purifying data. diff --git a/src/Blocks/Code.php b/src/Blocks/Code.php index fb9e3dc..e94208e 100644 --- a/src/Blocks/Code.php +++ b/src/Blocks/Code.php @@ -3,11 +3,12 @@ namespace BumpCore\EditorPhp\Blocks; use BumpCore\EditorPhp\Block\Block; +use BumpCore\EditorPhp\Contracts\Fakeable; use BumpCore\EditorPhp\EditorPhp; use BumpCore\EditorPhp\Helpers; use Illuminate\Support\Facades\View; -class Code extends Block +class Code extends Block implements Fakeable { /** * Tag allow list for purifying data. diff --git a/src/Blocks/Delimiter.php b/src/Blocks/Delimiter.php index ae91359..1bf1e4d 100644 --- a/src/Blocks/Delimiter.php +++ b/src/Blocks/Delimiter.php @@ -3,11 +3,12 @@ namespace BumpCore\EditorPhp\Blocks; use BumpCore\EditorPhp\Block\Block; +use BumpCore\EditorPhp\Contracts\Fakeable; use BumpCore\EditorPhp\EditorPhp; use BumpCore\EditorPhp\Helpers; use Illuminate\Support\Facades\View; -class Delimiter extends Block +class Delimiter extends Block implements Fakeable { /** * Tag allow list for purifying data. diff --git a/src/Blocks/Embed.php b/src/Blocks/Embed.php index 1c8a9bd..8090f3b 100644 --- a/src/Blocks/Embed.php +++ b/src/Blocks/Embed.php @@ -3,11 +3,12 @@ namespace BumpCore\EditorPhp\Blocks; use BumpCore\EditorPhp\Block\Block; +use BumpCore\EditorPhp\Contracts\Fakeable; use BumpCore\EditorPhp\EditorPhp; use BumpCore\EditorPhp\Helpers; use Illuminate\Support\Facades\View; -class Embed extends Block +class Embed extends Block implements Fakeable { /** * Tag allow list for purifying data. diff --git a/src/Blocks/Header.php b/src/Blocks/Header.php index 8b27db0..90bfd74 100644 --- a/src/Blocks/Header.php +++ b/src/Blocks/Header.php @@ -3,11 +3,12 @@ namespace BumpCore\EditorPhp\Blocks; use BumpCore\EditorPhp\Block\Block; +use BumpCore\EditorPhp\Contracts\Fakeable; use BumpCore\EditorPhp\EditorPhp; use BumpCore\EditorPhp\Helpers; use Illuminate\Support\Facades\View; -class Header extends Block +class Header extends Block implements Fakeable { /** * Tag allow list for purifying data. diff --git a/src/Blocks/Image.php b/src/Blocks/Image.php index 8778987..cdb4b87 100644 --- a/src/Blocks/Image.php +++ b/src/Blocks/Image.php @@ -3,11 +3,12 @@ namespace BumpCore\EditorPhp\Blocks; use BumpCore\EditorPhp\Block\Block; +use BumpCore\EditorPhp\Contracts\Fakeable; use BumpCore\EditorPhp\EditorPhp; use BumpCore\EditorPhp\Helpers; use Illuminate\Support\Facades\View; -class Image extends Block +class Image extends Block implements Fakeable { /** * Tag allow list for purifying data. diff --git a/src/Blocks/LinkTool.php b/src/Blocks/LinkTool.php index 29ecaa4..cd054a7 100644 --- a/src/Blocks/LinkTool.php +++ b/src/Blocks/LinkTool.php @@ -3,11 +3,12 @@ namespace BumpCore\EditorPhp\Blocks; use BumpCore\EditorPhp\Block\Block; +use BumpCore\EditorPhp\Contracts\Fakeable; use BumpCore\EditorPhp\EditorPhp; use BumpCore\EditorPhp\Helpers; use Illuminate\Support\Facades\View; -class LinkTool extends Block +class LinkTool extends Block implements Fakeable { /** * Tag allow list for purifying data. diff --git a/src/Blocks/ListBlock.php b/src/Blocks/ListBlock.php index 68adc8d..19f6655 100644 --- a/src/Blocks/ListBlock.php +++ b/src/Blocks/ListBlock.php @@ -3,12 +3,13 @@ namespace BumpCore\EditorPhp\Blocks; use BumpCore\EditorPhp\Block\Block; +use BumpCore\EditorPhp\Contracts\Fakeable; use BumpCore\EditorPhp\EditorPhp; use BumpCore\EditorPhp\Helpers; use Illuminate\Support\Facades\View; use Illuminate\Validation\Rule; -class ListBlock extends Block +class ListBlock extends Block implements Fakeable { /** * Tag allow list for purifying data. diff --git a/src/Blocks/Paragraph.php b/src/Blocks/Paragraph.php index 6f9b18e..ca74bf6 100644 --- a/src/Blocks/Paragraph.php +++ b/src/Blocks/Paragraph.php @@ -3,11 +3,12 @@ namespace BumpCore\EditorPhp\Blocks; use BumpCore\EditorPhp\Block\Block; +use BumpCore\EditorPhp\Contracts\Fakeable; use BumpCore\EditorPhp\EditorPhp; use BumpCore\EditorPhp\Helpers; use Illuminate\Support\Facades\View; -class Paragraph extends Block +class Paragraph extends Block implements Fakeable { /** * Tag allow list for purifying data. diff --git a/src/Blocks/Personality.php b/src/Blocks/Personality.php index 432648e..4caaada 100644 --- a/src/Blocks/Personality.php +++ b/src/Blocks/Personality.php @@ -3,11 +3,12 @@ namespace BumpCore\EditorPhp\Blocks; use BumpCore\EditorPhp\Block\Block; +use BumpCore\EditorPhp\Contracts\Fakeable; use BumpCore\EditorPhp\EditorPhp; use BumpCore\EditorPhp\Helpers; use Illuminate\Support\Facades\View; -class Personality extends Block +class Personality extends Block implements Fakeable { /** * Tag allow list for purifying data. diff --git a/src/Blocks/Quote.php b/src/Blocks/Quote.php index 5e4ae8f..1a99dcd 100644 --- a/src/Blocks/Quote.php +++ b/src/Blocks/Quote.php @@ -3,12 +3,13 @@ namespace BumpCore\EditorPhp\Blocks; use BumpCore\EditorPhp\Block\Block; +use BumpCore\EditorPhp\Contracts\Fakeable; use BumpCore\EditorPhp\EditorPhp; use BumpCore\EditorPhp\Helpers; use Illuminate\Support\Facades\View; use Illuminate\Validation\Rule; -class Quote extends Block +class Quote extends Block implements Fakeable { /** * Tag allow list for purifying data. diff --git a/src/Blocks/Raw.php b/src/Blocks/Raw.php index 59e9f25..0be9350 100644 --- a/src/Blocks/Raw.php +++ b/src/Blocks/Raw.php @@ -3,8 +3,9 @@ namespace BumpCore\EditorPhp\Blocks; use BumpCore\EditorPhp\Block\Block; +use BumpCore\EditorPhp\Contracts\Fakeable; -class Raw extends Block +class Raw extends Block implements Fakeable { /** * Tag allow list for purifying data. diff --git a/src/Blocks/Table.php b/src/Blocks/Table.php index 4506ce5..f1bae1c 100644 --- a/src/Blocks/Table.php +++ b/src/Blocks/Table.php @@ -3,12 +3,12 @@ namespace BumpCore\EditorPhp\Blocks; use BumpCore\EditorPhp\Block\Block; -use BumpCore\EditorPhp\Block\Data; +use BumpCore\EditorPhp\Contracts\Fakeable; use BumpCore\EditorPhp\EditorPhp; use BumpCore\EditorPhp\Helpers; use Illuminate\Support\Facades\View; -class Table extends Block +class Table extends Block implements Fakeable { /** * Tag allow list for purifying data. diff --git a/src/Blocks/Warning.php b/src/Blocks/Warning.php index 18b1409..ee28802 100644 --- a/src/Blocks/Warning.php +++ b/src/Blocks/Warning.php @@ -3,11 +3,12 @@ namespace BumpCore\EditorPhp\Blocks; use BumpCore\EditorPhp\Block\Block; +use BumpCore\EditorPhp\Contracts\Fakeable; use BumpCore\EditorPhp\EditorPhp; use BumpCore\EditorPhp\Helpers; use Illuminate\Support\Facades\View; -class Warning extends Block +class Warning extends Block implements Fakeable { /** * Tag allow list for purifying data. diff --git a/src/Contracts/Fakeable.php b/src/Contracts/Fakeable.php new file mode 100644 index 0000000..4e8f4b8 --- /dev/null +++ b/src/Contracts/Fakeable.php @@ -0,0 +1,17 @@ + method_exists($provider, 'fake')); + $blocks = array_filter(Parser::$blocks, fn (string $provider) => is_subclass_of($provider, Fakeable::class)); $generatedBlocks = []; - foreach (range(0, fake()->numberBetween($minLength, $maxLength)) as $index) + foreach (range(0, $faker->numberBetween($minLength, $maxLength)) as $index) { - $block = fake()->randomElement($blocks); + $block = $faker->randomElement($blocks); $generatedBlocks[] = (new ($block)($block::fake($faker)))->toArray(); } $generated = json_encode([ 'time' => (int) Carbon::now()->getPreciseTimestamp(3), 'blocks' => $generatedBlocks, - 'version' => fake()->semver(), + 'version' => $faker->semver(), ]); return $instance ? static::make($generated) : $generated; From 13658ee1772948c3937da354a98637295903284a Mon Sep 17 00:00:00 2001 From: megasteve19 Date: Sat, 27 Jan 2024 20:03:50 +0000 Subject: [PATCH 2/2] Fix styling --- config/editor.php | 30 ++++++++++---------- resources/php/bootstrap-five/attaches.php | 8 +++--- resources/php/bootstrap-five/checklist.php | 6 ++-- resources/php/bootstrap-five/code.php | 2 +- resources/php/bootstrap-five/embed.php | 10 +++---- resources/php/bootstrap-five/header.php | 12 ++++---- resources/php/bootstrap-five/image.php | 4 +-- resources/php/bootstrap-five/linktool.php | 12 ++++---- resources/php/bootstrap-five/list.php | 4 +-- resources/php/bootstrap-five/paragraph.php | 2 +- resources/php/bootstrap-five/personality.php | 12 ++++---- resources/php/bootstrap-five/quote.php | 4 +-- resources/php/bootstrap-five/table.php | 4 +-- resources/php/bootstrap-five/warning.php | 4 +-- resources/php/tailwind/attaches.php | 8 +++--- resources/php/tailwind/checklist.php | 6 ++-- resources/php/tailwind/code.php | 2 +- resources/php/tailwind/embed.php | 10 +++---- resources/php/tailwind/header.php | 12 ++++---- resources/php/tailwind/image.php | 4 +-- resources/php/tailwind/linktool.php | 12 ++++---- resources/php/tailwind/list.php | 4 +-- resources/php/tailwind/paragraph.php | 2 +- resources/php/tailwind/personality.php | 12 ++++---- resources/php/tailwind/quote.php | 4 +-- resources/php/tailwind/table.php | 4 +-- resources/php/tailwind/warning.php | 4 +-- src/Parser.php | 30 ++++++++++---------- tests/Pest.php | 30 ++++++++++---------- 29 files changed, 129 insertions(+), 129 deletions(-) diff --git a/config/editor.php b/config/editor.php index 3cf1f1f..9ff1205 100644 --- a/config/editor.php +++ b/config/editor.php @@ -2,20 +2,20 @@ return [ 'blocks' => [ - 'attaches' => \BumpCore\EditorPhp\Blocks\Attaches::class, - 'checklist' => \BumpCore\EditorPhp\Blocks\Checklist::class, - 'code' => \BumpCore\EditorPhp\Blocks\Code::class, - 'delimiter' => \BumpCore\EditorPhp\Blocks\Delimiter::class, - 'embed' => \BumpCore\EditorPhp\Blocks\Embed::class, - 'header' => \BumpCore\EditorPhp\Blocks\Header::class, - 'image' => \BumpCore\EditorPhp\Blocks\Image::class, - 'linkTool' => \BumpCore\EditorPhp\Blocks\LinkTool::class, - 'list' => \BumpCore\EditorPhp\Blocks\ListBlock::class, - 'paragraph' => \BumpCore\EditorPhp\Blocks\Paragraph::class, - 'personality' => \BumpCore\EditorPhp\Blocks\Personality::class, - 'quote' => \BumpCore\EditorPhp\Blocks\Quote::class, - 'raw' => \BumpCore\EditorPhp\Blocks\Raw::class, - 'table' => \BumpCore\EditorPhp\Blocks\Table::class, - 'warning' => \BumpCore\EditorPhp\Blocks\Warning::class, + 'attaches' => BumpCore\EditorPhp\Blocks\Attaches::class, + 'checklist' => BumpCore\EditorPhp\Blocks\Checklist::class, + 'code' => BumpCore\EditorPhp\Blocks\Code::class, + 'delimiter' => BumpCore\EditorPhp\Blocks\Delimiter::class, + 'embed' => BumpCore\EditorPhp\Blocks\Embed::class, + 'header' => BumpCore\EditorPhp\Blocks\Header::class, + 'image' => BumpCore\EditorPhp\Blocks\Image::class, + 'linkTool' => BumpCore\EditorPhp\Blocks\LinkTool::class, + 'list' => BumpCore\EditorPhp\Blocks\ListBlock::class, + 'paragraph' => BumpCore\EditorPhp\Blocks\Paragraph::class, + 'personality' => BumpCore\EditorPhp\Blocks\Personality::class, + 'quote' => BumpCore\EditorPhp\Blocks\Quote::class, + 'raw' => BumpCore\EditorPhp\Blocks\Raw::class, + 'table' => BumpCore\EditorPhp\Blocks\Table::class, + 'warning' => BumpCore\EditorPhp\Blocks\Warning::class, ], ]; diff --git a/resources/php/bootstrap-five/attaches.php b/resources/php/bootstrap-five/attaches.php index 3bb1fb7..eb5a375 100644 --- a/resources/php/bootstrap-five/attaches.php +++ b/resources/php/bootstrap-five/attaches.php @@ -1,13 +1,13 @@
-
+

- +

-

MiB

+

MiB

diff --git a/resources/php/bootstrap-five/checklist.php b/resources/php/bootstrap-five/checklist.php index b166d38..5368a70 100644 --- a/resources/php/bootstrap-five/checklist.php +++ b/resources/php/bootstrap-five/checklist.php @@ -4,7 +4,7 @@ class="d-flex flex-column align-items-start pl-8 gap-1 mb-3" >
  • - + - + - +
  • diff --git a/resources/php/bootstrap-five/code.php b/resources/php/bootstrap-five/code.php index 2d8c635..1613ec1 100644 --- a/resources/php/bootstrap-five/code.php +++ b/resources/php/bootstrap-five/code.php @@ -1,5 +1,5 @@
    -
    +
    diff --git a/resources/php/bootstrap-five/embed.php b/resources/php/bootstrap-five/embed.php index a19fbef..a00f633 100644 --- a/resources/php/bootstrap-five/embed.php +++ b/resources/php/bootstrap-five/embed.php @@ -1,14 +1,14 @@

    - +

    @@ -16,9 +16,9 @@ class="block mb-3 rounded bg-white" + >

    diff --git a/resources/php/bootstrap-five/header.php b/resources/php/bootstrap-five/header.php index 006d49b..3bf1ef4 100644 --- a/resources/php/bootstrap-five/header.php +++ b/resources/php/bootstrap-five/header.php @@ -1,25 +1,25 @@ -

    +

    -

    +

    -

    +

    -

    +

    -
    +
    -
    +
    diff --git a/resources/php/bootstrap-five/image.php b/resources/php/bootstrap-five/image.php index e4347e6..630ab8c 100644 --- a/resources/php/bootstrap-five/image.php +++ b/resources/php/bootstrap-five/image.php @@ -1,5 +1,5 @@ <?php echo $data('caption'); ?> diff --git a/resources/php/bootstrap-five/linktool.php b/resources/php/bootstrap-five/linktool.php index 994188c..328c307 100644 --- a/resources/php/bootstrap-five/linktool.php +++ b/resources/php/bootstrap-five/linktool.php @@ -1,21 +1,21 @@
    <?php echo $data('meta.title'); ?>
    -

    +

    + >

    -

    +

    diff --git a/resources/php/bootstrap-five/list.php b/resources/php/bootstrap-five/list.php index 2aa39cc..5a71a48 100644 --- a/resources/php/bootstrap-five/list.php +++ b/resources/php/bootstrap-five/list.php @@ -1,13 +1,13 @@
      -
    1. +
      -
    • +
    diff --git a/resources/php/bootstrap-five/paragraph.php b/resources/php/bootstrap-five/paragraph.php index 31b4918..4bb06f7 100644 --- a/resources/php/bootstrap-five/paragraph.php +++ b/resources/php/bootstrap-five/paragraph.php @@ -1 +1 @@ -

    +

    diff --git a/resources/php/bootstrap-five/personality.php b/resources/php/bootstrap-five/personality.php index fd48399..637472d 100644 --- a/resources/php/bootstrap-five/personality.php +++ b/resources/php/bootstrap-five/personality.php @@ -1,21 +1,21 @@
    <?php echo $data('name'); ?>
    -

    +

    + >

    -

    +

    diff --git a/resources/php/bootstrap-five/quote.php b/resources/php/bootstrap-five/quote.php index 8d2f442..a02144a 100644 --- a/resources/php/bootstrap-five/quote.php +++ b/resources/php/bootstrap-five/quote.php @@ -13,7 +13,7 @@
    -

    - +

    +
    diff --git a/resources/php/bootstrap-five/table.php b/resources/php/bootstrap-five/table.php index dbb89f5..6bb06a3 100644 --- a/resources/php/bootstrap-five/table.php +++ b/resources/php/bootstrap-five/table.php @@ -4,7 +4,7 @@ - + @@ -18,7 +18,7 @@ - + diff --git a/resources/php/bootstrap-five/warning.php b/resources/php/bootstrap-five/warning.php index 90db360..bfefaab 100644 --- a/resources/php/bootstrap-five/warning.php +++ b/resources/php/bootstrap-five/warning.php @@ -17,7 +17,7 @@ class="d-flex justify-content-center align-items-start align-items-sm-center"
    -

    -

    +

    +

    diff --git a/resources/php/tailwind/attaches.php b/resources/php/tailwind/attaches.php index f099281..dcb5c2c 100644 --- a/resources/php/tailwind/attaches.php +++ b/resources/php/tailwind/attaches.php @@ -1,13 +1,13 @@
    -
    +

    - +

    -

    MiB

    +

    MiB

    diff --git a/resources/php/tailwind/checklist.php b/resources/php/tailwind/checklist.php index 2e4151b..1b7f408 100644 --- a/resources/php/tailwind/checklist.php +++ b/resources/php/tailwind/checklist.php @@ -1,7 +1,7 @@