diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9ae1cae..c5eb0b7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,6 +6,8 @@ on: tags: - "v*" - "*@v*" + schedule: + - cron: '30 0 * * 0' # Sunday Only jobs: perl: diff --git a/plugins/MTBlockEditor/lib/MT/Plugin/MTBlockEditor/App/CMS.pm b/plugins/MTBlockEditor/lib/MT/Plugin/MTBlockEditor/App/CMS.pm index 6afa9e5..066d899 100644 --- a/plugins/MTBlockEditor/lib/MT/Plugin/MTBlockEditor/App/CMS.pm +++ b/plugins/MTBlockEditor/lib/MT/Plugin/MTBlockEditor/App/CMS.pm @@ -65,17 +65,19 @@ sub init_app { } sub insert_after { - my ($tmpl, $id, $tokens) = @_; + my ($tmpl, $reference_node, $tokens) = @_; - my $before = $id ? $tmpl->getElementById($id) : undef; + if ($reference_node && !ref $reference_node) { + $reference_node = $tmpl->getElementById($reference_node); # assume it's an ID + } if (!ref $tokens) { $tokens = plugin()->load_tmpl($tokens)->tokens; } foreach my $t (@$tokens) { - $tmpl->insertAfter($t, $before); - $before = $t; + $tmpl->insertAfter($t, $reference_node); + $reference_node = $t; } } @@ -254,7 +256,8 @@ sub template_param_edit_content_type { } $param->{mt_block_editor_configs} = [map { { id => $_->id, label => $_->label } } MT->model('be_config')->load({ blog_id => [0, $blog_id] })]; - insert_after($tmpl, undef, 'mt_block_editor_edit_content_type.tmpl'); + my $reference_node = $tmpl->getElementsByName('options_scripts')->[0]; + insert_after($tmpl, $reference_node, 'mt_block_editor_edit_content_type.tmpl'); } sub template_source_field_html_multi_line_text { diff --git a/plugins/MTBlockEditor/t/05-app-cms.t b/plugins/MTBlockEditor/t/05-app-cms.t index 475a0ac..463e731 100644 --- a/plugins/MTBlockEditor/t/05-app-cms.t +++ b/plugins/MTBlockEditor/t/05-app-cms.t @@ -89,6 +89,28 @@ subtest 'entry' => sub { like $out, qr{}; }; +subtest 'content_type' => sub { + $app = _run_app( + 'MT::App::CMS', + { + __test_user => $admin, + __request_method => 'GET', + __mode => 'view', + _type => 'content_type', + id => $content_type->id, + blog_id => $blog->id, + }); + $out = delete $app->{__test_output}; + + like $out, qr{ + /mt-static/js/build/contenttype.js + .* + /mt-static/plugins/MTBlockEditor/content-field/dist/index.js + }sx, 'content-field/diest/index.js is loaded after contenttype.js'; + is $out =~ m{/mt-static/plugins/MTBlockEditor/content-field/dist/index.js}g, 1, 'content-field/dist/index.js is included only once'; + like $out, qr{\s*$}, 'should not break the template'; +}; + subtest 'content_data' => sub { $app = _run_app( 'MT::App::CMS', diff --git a/plugins/MTBlockEditor/tmpl/admin2023/mt_block_editor_edit_content_type.tmpl b/plugins/MTBlockEditor/tmpl/admin2023/mt_block_editor_edit_content_type.tmpl index f365f38..8dbd727 100644 --- a/plugins/MTBlockEditor/tmpl/admin2023/mt_block_editor_edit_content_type.tmpl +++ b/plugins/MTBlockEditor/tmpl/admin2023/mt_block_editor_edit_content_type.tmpl @@ -1,9 +1,7 @@ - - - + diff --git a/plugins/MTBlockEditor/tmpl/admin2025/mt_block_editor_edit_content_type.tmpl b/plugins/MTBlockEditor/tmpl/admin2025/mt_block_editor_edit_content_type.tmpl index f365f38..8dbd727 100644 --- a/plugins/MTBlockEditor/tmpl/admin2025/mt_block_editor_edit_content_type.tmpl +++ b/plugins/MTBlockEditor/tmpl/admin2025/mt_block_editor_edit_content_type.tmpl @@ -1,9 +1,7 @@ - - - +