Skip to content
Closed
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
21 changes: 13 additions & 8 deletions plugins/MTBlockEditor/lib/MT/Plugin/MTBlockEditor/App/CMS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use utf8;

use MT::Util qw(encode_html);
use Class::Method::Modifiers qw(install_modifier);
use MT::Plugin::MTBlockEditor qw(plugin blocks to_custom_block_types_json tmpl_param);
use MT::Plugin::MTBlockEditor qw(plugin translate blocks to_custom_block_types_json tmpl_param);

my $Initialized;

Expand Down Expand Up @@ -248,13 +248,18 @@ sub template_param_edit_content_type {
my $blog = $app->blog;
my $blog_id = $blog ? $blog->id : 0;

my $tmpl_param = tmpl_param();
while (my ($k, $v) = each %$tmpl_param) {
$param->{$k} = $v;
}
$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 $tmpl_param = tmpl_param();
my $mt_block_editor_configs = [map { { id => $_->id, label => $_->label } } MT->model('be_config')->load({ blog_id => [0, $blog_id] })];

$param->{js_include} .= qq{
<script
src="@{[$param->{static_uri}]}plugins/MTBlockEditor/content-field/dist/index.js?v=@{[$tmpl_param->{mt_block_editor_version}]}"
type="module"
id="mt-block-editor-content-field"
data-mt-block-editor-configs="@{[ encode_html(MT::Util::to_json($mt_block_editor_configs)) ]}"
data-mt-block-editor-config-label="@{[ encode_html(translate("Preset For Movable Type Block Editor")) ]}"
></script>
};
}

sub template_source_field_html_multi_line_text {
Expand Down
18 changes: 18 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,24 @@ 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};

# loaded
like $out, qr{content-field/dist/index.js};
like $out, qr{</html>\s*$};
};

subtest 'content_data' => sub {
$app = _run_app(
'MT::App::CMS',
Expand Down

This file was deleted.

This file was deleted.