Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
tags:
- "v*"
- "*@v*"
schedule:
- cron: '30 0 * * 0' # Sunday Only

jobs:
perl:
Expand Down
13 changes: 8 additions & 5 deletions plugins/MTBlockEditor/lib/MT/Plugin/MTBlockEditor/App/CMS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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 {
Expand Down
22 changes: 22 additions & 0 deletions plugins/MTBlockEditor/t/05-app-cms.t
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@ subtest 'entry' => sub {
like $out, qr{<option value="block_editor">MT Block Editor</option>};
};

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{</html>\s*$}, 'should not break the template';
};

subtest 'content_data' => sub {
$app = _run_app(
'MT::App::CMS',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<mt:Var name="js_include" append="1">
<script
src="<$mt:var name="static_uri"$>plugins/MTBlockEditor/content-field/dist/index.js?v=<mt:Var name="mt_block_editor_version" />"
type="module"
id="mt-block-editor-content-field"
data-mt-block-editor-configs="<mt:Var name="mt_block_editor_configs" to_json="1" escape="html">"
data-mt-block-editor-config-label="<__trans phrase="Preset For Movable Type Block Editor" escape="html">"
></script>
</mt:Var>
<script
src="<$mt:var name="static_uri"$>plugins/MTBlockEditor/content-field/dist/index.js?v=<mt:Var name="mt_block_editor_version" />"
type="module"
id="mt-block-editor-content-field"
data-mt-block-editor-configs="<mt:Var name="mt_block_editor_configs" to_json="1" escape="html">"
data-mt-block-editor-config-label="<__trans phrase="Preset For Movable Type Block Editor" escape="html">"
></script>
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<mt:Var name="js_include" append="1">
<script
src="<$mt:var name="static_uri"$>plugins/MTBlockEditor/content-field/dist/index.js?v=<mt:Var name="mt_block_editor_version" />"
type="module"
id="mt-block-editor-content-field"
data-mt-block-editor-configs="<mt:Var name="mt_block_editor_configs" to_json="1" escape="html">"
data-mt-block-editor-config-label="<__trans phrase="Preset For Movable Type Block Editor" escape="html">"
></script>
</mt:Var>
<script
src="<$mt:var name="static_uri"$>plugins/MTBlockEditor/content-field/dist/index.js?v=<mt:Var name="mt_block_editor_version" />"
type="module"
id="mt-block-editor-content-field"
data-mt-block-editor-configs="<mt:Var name="mt_block_editor_configs" to_json="1" escape="html">"
data-mt-block-editor-config-label="<__trans phrase="Preset For Movable Type Block Editor" escape="html">"
></script>