From b7631364ec8bba4013e9b6bc7d67975251d8aed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Malich?= Date: Wed, 1 Nov 2023 04:19:25 +0100 Subject: [PATCH 1/2] Added tablet preview and categories for blocks --- public/editor.js | 2 +- resources/js/editor.js | 1 + resources/views/editor.blade.php | 63 ++++++++++++++++++++++++-------- src/Blocks/Block.php | 8 ++++ 4 files changed, 57 insertions(+), 17 deletions(-) diff --git a/public/editor.js b/public/editor.js index 69d2810..b81c53c 100644 --- a/public/editor.js +++ b/public/editor.js @@ -1 +1 @@ -(()=>{var e,t={950:()=>{function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,r){if(!e)return;if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t(e,r)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=n&&e.clientY<=a,l=e.clientY>=i&&e.clientY<=o;return s?"before":!!l&&"after"},component:function(){return Livewire.find(frame.closest("[wire\\:id]").getAttribute("wire:id"))},undo:function(e,t){!e.ctrlKey&&!e.metaKey||e.shiftKey||"z"!==e.key||(e.preventDefault(),-1!=navigator.userAgent.indexOf("Safari")&&-1==navigator.userAgent.indexOf("Chrome")&&window.history.forward(),t.component().call("undo"))},redo:function(e,t){(e.ctrlKey||e.metaKey)&&e.shiftKey&&"z"===e.key&&(e.preventDefault(),-1!=navigator.userAgent.indexOf("Safari")&&-1==navigator.userAgent.indexOf("Chrome")&&window.history.forward(),t.component().call("redo"))}}}},611:()=>{}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.m=t,e=[],n.O=(t,r,a,i)=>{if(!r){var o=1/0;for(d=0;d=i)&&Object.keys(n.O).every((e=>n.O[e](r[l])))?r.splice(l--,1):(s=!1,i0&&e[d-1][2]>i;d--)e[d]=e[d-1];e[d]=[r,a,i]},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={192:0,982:0};n.O.j=t=>0===e[t];var t=(t,r)=>{var a,i,[o,s,l]=r,c=0;if(o.some((t=>0!==e[t]))){for(a in s)n.o(s,a)&&(n.m[a]=s[a]);if(l)var d=l(n)}for(t&&t(r);cn(950)));var a=n.O(void 0,[982],(()=>n(611)));a=n.O(a)})(); \ No newline at end of file +(()=>{var e,t={950:()=>{function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,r){if(!e)return;if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t(e,r)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=n&&e.clientY<=a,l=e.clientY>=i&&e.clientY<=o;return s?"before":!!l&&"after"},component:function(){return Livewire.find(frame.closest("[wire\\:id]").getAttribute("wire:id"))},undo:function(e,t){!e.ctrlKey&&!e.metaKey||e.shiftKey||"z"!==e.key||(e.preventDefault(),-1!=navigator.userAgent.indexOf("Safari")&&-1==navigator.userAgent.indexOf("Chrome")&&window.history.forward(),t.component().call("undo"))},redo:function(e,t){(e.ctrlKey||e.metaKey)&&e.shiftKey&&"z"===e.key&&(e.preventDefault(),-1!=navigator.userAgent.indexOf("Safari")&&-1==navigator.userAgent.indexOf("Chrome")&&window.history.forward(),t.component().call("redo"))}}}},611:()=>{}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.m=t,e=[],n.O=(t,r,a,i)=>{if(!r){var o=1/0;for(d=0;d=i)&&Object.keys(n.O).every((e=>n.O[e](r[l])))?r.splice(l--,1):(s=!1,i0&&e[d-1][2]>i;d--)e[d]=e[d-1];e[d]=[r,a,i]},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={192:0,982:0};n.O.j=t=>0===e[t];var t=(t,r)=>{var a,i,[o,s,l]=r,c=0;if(o.some((t=>0!==e[t]))){for(a in s)n.o(s,a)&&(n.m[a]=s[a]);if(l)var d=l(n)}for(t&&t(r);cn(950)));var a=n.O(void 0,[982],(()=>n(611)));a=n.O(a)})(); diff --git a/resources/js/editor.js b/resources/js/editor.js index e6eec28..b6a98fa 100644 --- a/resources/js/editor.js +++ b/resources/js/editor.js @@ -7,6 +7,7 @@ window.dropblockeditor = (config) => { insert: false, mobile: false, + tablet: false, lastTopPos: 0, diff --git a/resources/views/editor.blade.php b/resources/views/editor.blade.php index 6fc0518..5cca3d2 100644 --- a/resources/views/editor.blade.php +++ b/resources/views/editor.blade.php @@ -9,7 +9,8 @@
@@ -43,15 +44,24 @@ class="dropblockeditor flex flex-col min-h-screen bg-gray-100">
- +
- - + +
@else -
- @foreach(collect($blocks)->map(function($block) { - return $this->getBlockFromClassName($block['class']); - }) as $i => $block) -
- @if($block->getIcon()) -
{!! $block->getIcon() !!}
- @endif +
+ @php + $blockGroups = collect($blocks)->map(function($block, $i) { + return [ + 'original_index' => $i, + 'block' => $this->getBlockFromClassName($block['class']), + ]; + })->groupBy(function($item) { + return $item['block']->getCategory(); + }); + @endphp - {{ $block->getTitle() }} + @foreach($blockGroups as $category => $categoryBlocks) +
+

{{ $category }}

+
+ @foreach($categoryBlocks as $groupedBlock) + @php + $i = $groupedBlock['original_index']; // Retrieve the original index + $block = $groupedBlock['block']; + @endphp - - - +
+ @if($block->getIcon()) +
{!! $block->getIcon() !!}
+ @endif + + {{ $block->getTitle() }} + + + + +
+ @endforeach +
@endforeach
diff --git a/src/Blocks/Block.php b/src/Blocks/Block.php index 9cccaf0..074bd2a 100644 --- a/src/Blocks/Block.php +++ b/src/Blocks/Block.php @@ -12,6 +12,8 @@ abstract class Block public $blockEditComponent; + public $category = 'Example Category'; + public $data = []; abstract public function render(); @@ -26,6 +28,11 @@ public function getTitle() return $this->title; } + public function getCategory() + { + return $this->category; + } + public function getData() { return $this->data; @@ -57,6 +64,7 @@ public function toArray() return [ 'data' => $this->data, 'class' => get_class($this), + 'category' => $this->category, ]; } } From 2906be2b0d561f4a7681cad55d91e9a8f7171c47 Mon Sep 17 00:00:00 2001 From: Jeffrey van Rossum Date: Fri, 17 Nov 2023 14:24:16 +0100 Subject: [PATCH 2/2] refactor --- public/editor.css | 2 +- public/editor.js | 2 +- resources/js/editor.js | 3 +-- resources/views/editor.blade.php | 36 +++++++++++++++----------------- src/Blocks/Block.php | 2 +- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/public/editor.css b/public/editor.css index bd7f4f4..d3f4f82 100644 --- a/public/editor.css +++ b/public/editor.css @@ -1 +1 @@ -/*! tailwindcss v3.2.2 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}html{-webkit-text-size-adjust:100%;font-feature-settings:normal;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.static{position:static}.absolute{position:absolute}.relative{position:relative}.right-4{right:1rem}.top-4{top:1rem}.right-5{right:1.25rem}.bottom-5{bottom:1.25rem}.mx-auto{margin-left:auto;margin-right:auto}.mx-4{margin-left:1rem;margin-right:1rem}.my-4{margin-bottom:1rem;margin-top:1rem}.mr-2{margin-right:.5rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-2{margin-bottom:.5rem}.mb-1{margin-bottom:.25rem}.block{display:block}.flex{display:flex}.grid{display:grid}.contents{display:contents}.h-5{height:1.25rem}.h-full{height:100%}.h-6{height:1.5rem}.h-4{height:1rem}.min-h-screen{min-height:100vh}.min-h-\[200px\]{min-height:200px}.w-5{width:1.25rem}.w-\[320px\]{width:320px}.w-full{width:100%}.w-6{width:1.5rem}.w-\[400px\]{width:400px}.w-4{width:1rem}.max-w-screen-xl{max-width:1280px}.max-w-screen-md{max-width:768px}.flex-initial{flex:0 1 auto}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.grow{flex-grow:1}@keyframes spin{to{transform:rotate(1turn)}}.animate-spin{animation:spin 1s linear infinite}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-grab{cursor:grab}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-2{gap:.5rem}.gap-4{gap:1rem}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rounded-md{border-radius:.375rem}.rounded-lg{border-radius:.5rem}.rounded-xl{border-radius:.75rem}.rounded{border-radius:.25rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-r{border-right-width:1px}.border-l{border-left-width:1px}.border-gray-100{--tw-border-opacity:1;border-color:rgb(243 244 246/var(--tw-border-opacity))}.border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.bg-blue-200{--tw-bg-opacity:1;background-color:rgb(191 219 254/var(--tw-bg-opacity))}.bg-gray-200\/50{background-color:rgba(229,231,235,.5)}.p-2{padding:.5rem}.p-4{padding:1rem}.p-8{padding:2rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.py-5{padding-bottom:1.25rem;padding-top:1.25rem}.px-3{padding-left:.75rem;padding-right:.75rem}.py-2{padding-bottom:.5rem;padding-top:.5rem}.py-1{padding-bottom:.25rem;padding-top:.25rem}.text-center{text-align:center}.text-sm{font-size:.875rem;line-height:1.25rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.font-medium{font-weight:500}.font-extrabold{font-weight:800}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.text-gray-300{--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity))}.text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity))}.text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity))}.text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity))}.text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity))}.text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity))}.opacity-25{opacity:.25}.opacity-75{opacity:.75}.opacity-50{opacity:.5}.shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.shadow-lg,.shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}[x-cloak]{display:none!important}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:top-0:before{content:var(--tw-content);top:0}.before\:left-0:before{content:var(--tw-content);left:0}.before\:h-full:before{content:var(--tw-content);height:100%}.before\:w-full:before{content:var(--tw-content);width:100%}.before\:border-2:before{border-width:2px;content:var(--tw-content)}.before\:border-gray-400:before{--tw-border-opacity:1;border-color:rgb(156 163 175/var(--tw-border-opacity));content:var(--tw-content)}.before\:opacity-0:before{content:var(--tw-content);opacity:0}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:left-0:after{content:var(--tw-content);left:0}.after\:top-0:after{content:var(--tw-content);top:0}.after\:bottom-0:after{bottom:0;content:var(--tw-content)}.after\:h-\[5px\]:after{content:var(--tw-content);height:5px}.after\:w-full:after{content:var(--tw-content);width:100%}.after\:bg-gray-400:after{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity));content:var(--tw-content)}.after\:opacity-0:after{content:var(--tw-content);opacity:0}.after\:opacity-100:after{content:var(--tw-content);opacity:1}.hover\:cursor-pointer:hover{cursor:pointer}.hover\:border-gray-200:hover{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}.hover\:text-gray-800:hover{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.hover\:opacity-75:hover{opacity:.75}.hover\:before\:opacity-100:hover:before{content:var(--tw-content);opacity:1}.active\:cursor-grabbing:active{cursor:grabbing}.\[\&_\*\]\:pointer-events-none *{pointer-events:none} +/*! tailwindcss v3.2.2 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}html{-webkit-text-size-adjust:100%;font-feature-settings:normal;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.static{position:static}.absolute{position:absolute}.relative{position:relative}.right-4{right:1rem}.top-4{top:1rem}.right-5{right:1.25rem}.bottom-5{bottom:1.25rem}.mx-auto{margin-left:auto;margin-right:auto}.mx-4{margin-left:1rem;margin-right:1rem}.my-4{margin-bottom:1rem;margin-top:1rem}.mr-2{margin-right:.5rem}.mb-4{margin-bottom:1rem}.mb-2{margin-bottom:.5rem}.mb-1{margin-bottom:.25rem}.block{display:block}.flex{display:flex}.grid{display:grid}.contents{display:contents}.h-5{height:1.25rem}.h-full{height:100%}.h-6{height:1.5rem}.h-4{height:1rem}.min-h-screen{min-height:100vh}.min-h-\[200px\]{min-height:200px}.w-5{width:1.25rem}.w-\[320px\]{width:320px}.w-\[768px\]{width:768px}.w-full{width:100%}.w-6{width:1.5rem}.w-\[400px\]{width:400px}.w-4{width:1rem}.max-w-screen-xl{max-width:1280px}.max-w-screen-md{max-width:768px}.flex-initial{flex:0 1 auto}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.grow{flex-grow:1}@keyframes spin{to{transform:rotate(1turn)}}.animate-spin{animation:spin 1s linear infinite}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}.cursor-grab{cursor:grab}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-2{gap:.5rem}.gap-4{gap:1rem}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rounded-md{border-radius:.375rem}.rounded-lg{border-radius:.5rem}.rounded-xl{border-radius:.75rem}.rounded{border-radius:.25rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-r{border-right-width:1px}.border-l{border-left-width:1px}.border-gray-100{--tw-border-opacity:1;border-color:rgb(243 244 246/var(--tw-border-opacity))}.border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.bg-blue-200{--tw-bg-opacity:1;background-color:rgb(191 219 254/var(--tw-bg-opacity))}.bg-gray-200\/50{background-color:rgba(229,231,235,.5)}.p-2{padding:.5rem}.p-4{padding:1rem}.p-8{padding:2rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.py-5{padding-bottom:1.25rem;padding-top:1.25rem}.px-3{padding-left:.75rem;padding-right:.75rem}.py-2{padding-bottom:.5rem;padding-top:.5rem}.py-1{padding-bottom:.25rem;padding-top:.25rem}.text-center{text-align:center}.text-sm{font-size:.875rem;line-height:1.25rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.font-medium{font-weight:500}.font-extrabold{font-weight:800}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.text-gray-300{--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity))}.text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity))}.text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity))}.text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity))}.text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity))}.text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity))}.opacity-25{opacity:.25}.opacity-75{opacity:.75}.opacity-50{opacity:.5}.shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.shadow-lg,.shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}[x-cloak]{display:none!important}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:top-0:before{content:var(--tw-content);top:0}.before\:left-0:before{content:var(--tw-content);left:0}.before\:h-full:before{content:var(--tw-content);height:100%}.before\:w-full:before{content:var(--tw-content);width:100%}.before\:border-2:before{border-width:2px;content:var(--tw-content)}.before\:border-gray-400:before{--tw-border-opacity:1;border-color:rgb(156 163 175/var(--tw-border-opacity));content:var(--tw-content)}.before\:opacity-0:before{content:var(--tw-content);opacity:0}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:left-0:after{content:var(--tw-content);left:0}.after\:top-0:after{content:var(--tw-content);top:0}.after\:bottom-0:after{bottom:0;content:var(--tw-content)}.after\:h-\[5px\]:after{content:var(--tw-content);height:5px}.after\:w-full:after{content:var(--tw-content);width:100%}.after\:bg-gray-400:after{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity));content:var(--tw-content)}.after\:opacity-0:after{content:var(--tw-content);opacity:0}.after\:opacity-100:after{content:var(--tw-content);opacity:1}.hover\:cursor-pointer:hover{cursor:pointer}.hover\:border-gray-200:hover{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}.hover\:text-gray-800:hover{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.hover\:opacity-75:hover{opacity:.75}.hover\:before\:opacity-100:hover:before{content:var(--tw-content);opacity:1}.active\:cursor-grabbing:active{cursor:grabbing}.\[\&_\*\]\:pointer-events-none *{pointer-events:none} diff --git a/public/editor.js b/public/editor.js index b81c53c..608c713 100644 --- a/public/editor.js +++ b/public/editor.js @@ -1 +1 @@ -(()=>{var e,t={950:()=>{function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,r){if(!e)return;if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t(e,r)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=n&&e.clientY<=a,l=e.clientY>=i&&e.clientY<=o;return s?"before":!!l&&"after"},component:function(){return Livewire.find(frame.closest("[wire\\:id]").getAttribute("wire:id"))},undo:function(e,t){!e.ctrlKey&&!e.metaKey||e.shiftKey||"z"!==e.key||(e.preventDefault(),-1!=navigator.userAgent.indexOf("Safari")&&-1==navigator.userAgent.indexOf("Chrome")&&window.history.forward(),t.component().call("undo"))},redo:function(e,t){(e.ctrlKey||e.metaKey)&&e.shiftKey&&"z"===e.key&&(e.preventDefault(),-1!=navigator.userAgent.indexOf("Safari")&&-1==navigator.userAgent.indexOf("Chrome")&&window.history.forward(),t.component().call("redo"))}}}},611:()=>{}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.m=t,e=[],n.O=(t,r,a,i)=>{if(!r){var o=1/0;for(d=0;d=i)&&Object.keys(n.O).every((e=>n.O[e](r[l])))?r.splice(l--,1):(s=!1,i0&&e[d-1][2]>i;d--)e[d]=e[d-1];e[d]=[r,a,i]},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={192:0,982:0};n.O.j=t=>0===e[t];var t=(t,r)=>{var a,i,[o,s,l]=r,c=0;if(o.some((t=>0!==e[t]))){for(a in s)n.o(s,a)&&(n.m[a]=s[a]);if(l)var d=l(n)}for(t&&t(r);cn(950)));var a=n.O(void 0,[982],(()=>n(611)));a=n.O(a)})(); +(()=>{var e,t={950:()=>{function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,r){if(!e)return;if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t(e,r)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=n&&e.clientY<=a,l=e.clientY>=i&&e.clientY<=o;return s?"before":!!l&&"after"},component:function(){return Livewire.find(frame.closest("[wire\\:id]").getAttribute("wire:id"))},undo:function(e,t){!e.ctrlKey&&!e.metaKey||e.shiftKey||"z"!==e.key||(e.preventDefault(),-1!=navigator.userAgent.indexOf("Safari")&&-1==navigator.userAgent.indexOf("Chrome")&&window.history.forward(),t.component().call("undo"))},redo:function(e,t){(e.ctrlKey||e.metaKey)&&e.shiftKey&&"z"===e.key&&(e.preventDefault(),-1!=navigator.userAgent.indexOf("Safari")&&-1==navigator.userAgent.indexOf("Chrome")&&window.history.forward(),t.component().call("redo"))}}}},611:()=>{}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.m=t,e=[],n.O=(t,r,a,i)=>{if(!r){var o=1/0;for(d=0;d=i)&&Object.keys(n.O).every((e=>n.O[e](r[l])))?r.splice(l--,1):(s=!1,i0&&e[d-1][2]>i;d--)e[d]=e[d-1];e[d]=[r,a,i]},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={192:0,982:0};n.O.j=t=>0===e[t];var t=(t,r)=>{var a,i,[o,s,l]=r,c=0;if(o.some((t=>0!==e[t]))){for(a in s)n.o(s,a)&&(n.m[a]=s[a]);if(l)var d=l(n)}for(t&&t(r);cn(950)));var a=n.O(void 0,[982],(()=>n(611)));a=n.O(a)})(); \ No newline at end of file diff --git a/resources/js/editor.js b/resources/js/editor.js index b6a98fa..bf441c6 100644 --- a/resources/js/editor.js +++ b/resources/js/editor.js @@ -6,8 +6,7 @@ window.dropblockeditor = (config) => { insert: false, - mobile: false, - tablet: false, + device: 'desktop', lastTopPos: 0, diff --git a/resources/views/editor.blade.php b/resources/views/editor.blade.php index 5cca3d2..8c9b787 100644 --- a/resources/views/editor.blade.php +++ b/resources/views/editor.blade.php @@ -8,10 +8,7 @@
@@ -44,24 +41,21 @@ class="dropblockeditor flex flex-col min-h-screen bg-gray-100">
- +
- -
@else -
+
@php $blockGroups = collect($blocks)->map(function($block, $i) { return [ @@ -128,16 +122,20 @@ class="dropblockeditor flex flex-col min-h-screen bg-gray-100"> ]; })->groupBy(function($item) { return $item['block']->getCategory(); - }); + })->sortBy(function($item, $key) { + return $key; + })->toArray(); @endphp @foreach($blockGroups as $category => $categoryBlocks) -
-

{{ $category }}

-
+
+ @if($category) +

{{ $category }}

+ @endif +
@foreach($categoryBlocks as $groupedBlock) @php - $i = $groupedBlock['original_index']; // Retrieve the original index + $i = $groupedBlock['original_index']; $block = $groupedBlock['block']; @endphp diff --git a/src/Blocks/Block.php b/src/Blocks/Block.php index 074bd2a..9fee270 100644 --- a/src/Blocks/Block.php +++ b/src/Blocks/Block.php @@ -12,7 +12,7 @@ abstract class Block public $blockEditComponent; - public $category = 'Example Category'; + public $category = null; public $data = [];