]> _ Git - cubist_cms-back.git/commitdiff
wip #7527 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 13 May 2025 13:23:06 +0000 (15:23 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 13 May 2025 13:23:06 +0000 (15:23 +0200)
src/resources/views/fields/simplemde.blade.php
src/resources/views/when.blade.php

index 60840053eca6314f54170692835d59fcc2358eae..9cea4e47f140bcf0cc2e8337ceaabfdc255217f7 100644 (file)
@@ -1,17 +1,17 @@
 <!-- Simple MDE - Markdown Editor -->
 @include('crud::fields.inc.wrapper_start')
-    <label>{!! $field['label'] !!}</label>
-    @include('crud::fields.inc.translatable_icon')
-    <textarea
-        class="simplemde_area" name="{{ $field['name'] }}"
-        data-simplemdeattrs="{{json_encode($field['simplemdeAttributes'])}}"
+<label>{!! $field['label'] !!}</label>
+@include('crud::fields.inc.translatable_icon')
+<textarea
+    class="simplemde_area" name="{{ $field['name'] }}"
+    data-simplemdeattrs="{{json_encode($field['simplemdeAttributes'])}}"
         @include('crud::fields.inc.attributes', ['default_class' => 'form-control'])
        >{{ old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? '' }}</textarea>
 
-    {{-- HINT --}}
-    @if (isset($field['hint']))
-        <p class="help-block">{!! $field['hint'] !!}</p>
-    @endif
+{{-- HINT --}}
+@if (isset($field['hint']))
+    <p class="help-block">{!! $field['hint'] !!}</p>
+@endif
 @include('crud::fields.inc.wrapper_end')
 
 
         <script>
             jQuery(document).ready(function ($) {
                 initAllMarkdown();
+
                 $(document).on('cubist.bunchmultiple.added', function () {
                     initAllMarkdown();
                 });
+
                 $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
                     setTimeout(function () {
                         refreshAllMarkdown();
             }
 
             function initOneMarkdown(el) {
+                if (el.closest('.item.sample').length > 0) {
+                    return;
+                }
                 var attributes = el.data('simplemdeattrs');
                 attributes.element = $(el).get(0);
                 var simplemde = new SimpleMDE(attributes);
                 simplemde.options.minHeight = simplemde.options.minHeight || "300px";
                 simplemde.codemirror.getScrollerElement().style.minHeight = simplemde.options.minHeight;
                 $(el).data('simplemde', simplemde);
+                simplemde.codemirror.on("change", function () {
+                    console.log('simplemde change', el);
+                    $(el).val(simplemde.value());
+                    $(el).trigger("change");
+                });
             }
         </script>
     @endpush
index b1feb424fd784458661e708904c4f19e5aca0905..2c042955ae73867393e1d7b24d8b2d9b881887cb 100644 (file)
@@ -27,7 +27,6 @@
                     var element = $(this);
                     if ($(this).data('when-normalized') === undefined) {
                         $(this).data('when-normalized', normalizeWhen($(this).data('when')));
-                        console.log(normalizeWhen($(this).data('when')));
                     }
                     var when = $(this).data('when-normalized');