Skip to content

Commit 21bb5d5

Browse files
committed
Only output list of used blocks
1 parent b256607 commit 21bb5d5

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/TwillBlocks.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ public function getAllCropConfigs(): array
355355

356356
public function getListOfUsedBlocks(): Collection
357357
{
358-
return $this->usedBlocks->values();
358+
return $this->usedBlocks;
359359
}
360360

361361
public function generateListOfAllBlocks(bool $settingsOnly = false): Collection
@@ -391,7 +391,7 @@ function ($appBlock) use ($block) {
391391
return false;
392392
}
393393
}
394-
return isset($disabledBlocks[$block->name]) || isset($disabledBlocks[ltrim($block->componentClass, '\\')]);
394+
return !(isset($disabledBlocks[$block->name]) || isset($disabledBlocks[ltrim($block->componentClass, '\\')]));
395395
})->sortBy(function (Block $b) use ($customOrder) {
396396
// Sort blocks by custom order then by group and then by name
397397
return ($customOrder[$b->name] ?? $customOrder[ltrim($b->componentClass, '\\')] ?? PHP_INT_MAX) . '-' . $b->group . '-' . $b->name;
@@ -406,7 +406,7 @@ public function generateListOfAvailableBlocks(
406406
array|callable $excludeBlocks = [],
407407
bool $defaultOrder = false
408408
): Collection {
409-
$globalExcludeBlocks = TwillBlocks::getGloballyExcludedBlocks();
409+
$globalExcludeBlocks = $this->getGloballyExcludedBlocks();
410410

411411
$matchBlock = function ($matcher, $block, $someFn = null) {
412412
if (is_callable($matcher)) {
@@ -454,7 +454,8 @@ function (Block $block) use ($blocks, $groups, $excludeBlocks, $globalExcludeBlo
454454
$finalList = $finalList->sortBy(fn(Block $block) => $groups[$block->group] ?? PHP_INT_MAX, SORT_NUMERIC);
455455
}
456456
}
457-
$this->usedBlocks->merge($finalList->keyBy(fn(Block $block) => $block->name));
457+
458+
$this->usedBlocks = $this->usedBlocks->merge($finalList->keyBy(fn(Block $block) => $block->name));
458459
return $finalList;
459460
}
460461
}

views/layouts/form.blade.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,9 @@
223223
{{-- Permissions --}}
224224
window['{{ config('twill.js_namespace') }}'].STORE.groups = {!! isset($groups) ? json_encode($groups) : '[]' !!};
225225
window['{{ config('twill.js_namespace') }}'].STORE.groupUserMapping = {!! isset($groupUserMapping) ? json_encode($groupUserMapping) : '[]' !!};
226-
@stop
227226

228-
@push('vuexStore')
229-
window['{{config('twill.js_namespace')}}.STORE.form.allAvailableBlocks'] = {!! json_encode(TwillBlocks::getListOfUsedBlocks()) !!};
230-
@endpush
227+
window['{{config('twill.js_namespace')}}'].STORE.form.allAvailableBlocks = {!! TwillBlocks::getListOfUsedBlocks() !!}
228+
@stop
231229

232230
@prepend('extra_js')
233231
@includeWhen(config('twill.block_editor.inline_blocks_templates', true), 'twill::partials.form.utils._blocks_templates')

views/layouts/main.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
window.STORE.browsers.selected = {}
146146
147147
@stack('vuexStore')
148+
148149
</script>
149150
<script src="{{ twillAsset('chunk-vendors.js') }}"></script>
150151
<script src="{{ twillAsset('chunk-common.js') }}"></script>

0 commit comments

Comments
 (0)