From 074fc607c3aaf7773542972d3dc22258515cf549 Mon Sep 17 00:00:00 2001 From: Taku Amano Date: Mon, 1 Dec 2025 20:21:53 +0900 Subject: [PATCH 1/5] API has been changed to allow nodes to be passed directly to `insert_after`. --- .../lib/MT/Plugin/MTBlockEditor/App/CMS.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/MTBlockEditor/lib/MT/Plugin/MTBlockEditor/App/CMS.pm b/plugins/MTBlockEditor/lib/MT/Plugin/MTBlockEditor/App/CMS.pm index 6afa9e5..6517b06 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; } } From 952cfb836a3b64b8fa2803189e6dd038a5015c9b Mon Sep 17 00:00:00 2001 From: Taku Amano Date: Mon, 1 Dec 2025 20:22:41 +0900 Subject: [PATCH 2/5] Changed to explicitly look for name="options_scripts" and pass it to `insert_after`. --- plugins/MTBlockEditor/lib/MT/Plugin/MTBlockEditor/App/CMS.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/MTBlockEditor/lib/MT/Plugin/MTBlockEditor/App/CMS.pm b/plugins/MTBlockEditor/lib/MT/Plugin/MTBlockEditor/App/CMS.pm index 6517b06..066d899 100644 --- a/plugins/MTBlockEditor/lib/MT/Plugin/MTBlockEditor/App/CMS.pm +++ b/plugins/MTBlockEditor/lib/MT/Plugin/MTBlockEditor/App/CMS.pm @@ -256,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 { From 0dd6e404698fee3b1c5ea05dd34dbf18005d5e20 Mon Sep 17 00:00:00 2001 From: Taku Amano Date: Mon, 1 Dec 2025 20:24:08 +0900 Subject: [PATCH 3/5] Since the embedding destination is in mt:SetVarBlock, this template does not require explicit variable setting. --- .../mt_block_editor_edit_content_type.tmpl | 16 +++++++--------- .../mt_block_editor_edit_content_type.tmpl | 16 +++++++--------- 2 files changed, 14 insertions(+), 18 deletions(-) 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 @@ - - - + From 293160b294d94eb42dcfb05793a5ad8b48256771 Mon Sep 17 00:00:00 2001 From: Taku Amano Date: Mon, 1 Dec 2025 20:26:01 +0900 Subject: [PATCH 4/5] Test to make sure it is inserted only once in the correct place --- plugins/MTBlockEditor/t/05-app-cms.t | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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', From f4f7f5b564d7bc11d64836b2ff630bbe549ebc31 Mon Sep 17 00:00:00 2001 From: Taku Amano Date: Mon, 1 Dec 2025 20:26:27 +0900 Subject: [PATCH 5/5] Change schedule to run tests periodically --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) 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: