function InitializeSummerNote(Data) {
//Initialize editor only once when DOM is loaded
$(document).ready(function() {
//Bind InvokeExtensibilityMethod for OnChange BC event
const OnChange = getALMethod('OnChange',false);
editor = $('#summernote');
editor.summernote({
height: ($(window).height() - 55),
focus: true,
callbacks: {
//Bind onChange callback with our OnChange BC event
onChange: function(contents, $editable) {
OnChange(contents);
}
},
//List of features to include them to toolbar
toolbar: [
['style', ['style']],
['font', ['bold', 'underline', 'clear']],
['fontname', ['fontname']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']],
['insert', ['link', 'picture', 'video']],
['view', ['codeview', 'help']],
]
});
//Set init data
$('.note-editable').html(Data);
});
}
page 81500 "SMT Summer Note Editor"
{
Caption = 'Summer Note Editor';
PageType = Card;
UsageCategory = None;
SourceTable = "SMT Content";
layout
{
area(Content)
{
group(GrpEditor)
{
Caption = 'Editor';
usercontrol(SMTEditor; "SMT Editor")
{
ApplicationArea = All;
trigger ControlAddinReady()
begin
NewData := Rec.GetContent();
CurrPage.SMTEditor.InitializeSummerNote(NewData);
end;
trigger OnChange(Data: Text)
begin
NewData := Data;
end;
}
}
}
}
trigger OnNewRecord(BelowxRec: Boolean)
begin
Rec.FilterGroup(4);
if Rec.GetFilter("Source Record ID") <> '' then
evaluate(Rec."Source Record ID", Rec.GetFilter("Source Record ID"));
Rec.FilterGroup(0);
end;
trigger OnClosePage()
begin
Rec.SetContent(NewData);
end;
var
NewData: Text;
}