summernoteInit static method

String summernoteInit({
  1. String? selector,
  2. String? placeholder,
  3. bool spellCheck = false,
  4. int maximumFileSize = 5 * 1024 * 1024,
  5. List<String> customOptions = const [],
  6. List<String> summernoteCallbacks = const [],
  7. ResizeMode resizeMode = ResizeMode.resizeToParent,
})

Build the initialiser code for the summernote editor.

selector is the jQuery selector of the element where summernote editor is initialised. It's an alternative to summernoteSelector.

Implementation

static String summernoteInit({
  String? selector,
  String? placeholder,
  bool spellCheck = false,
  int maximumFileSize = 5 * 1024 * 1024,
  List<String> customOptions = const [],
  List<String> summernoteCallbacks = const [],
  ResizeMode resizeMode = ResizeMode.resizeToParent,
}) =>
    '''
\$('${selector ?? summernoteSelector}').summernote({
${(placeholder?.trim().isNotEmpty ?? false) ? "placeholder: '$placeholder'," : ""}
tabsize: 2,
toolbar: [],
disableGrammar: false,
spellCheck: $spellCheck,
maximumImageFileSize: $maximumFileSize,
${customOptions.join("\n")}
callbacks: {
  ${summernoteCallbacks.join(",\n")}
}
});
if (${resizeMode == ResizeMode.resizeToParent}) {
resizeToParent();
addEventListener("resize", (event) => resizeToParent());
}
document.addEventListener("selectionchange", () => onSelectionChange());
''';