i want to add a behavior to a button i made in summernote to add a h4 tag to a selection:
heading: function (context) {
var ui = $.summernote.ui;
var button = ui.button({
contents: 'H',
click: function () {
var range = context.invoke('editor.createRange');
if (range.toString()) {
var heading = document.createElement('h4');
$(heading).text(range.toString());
context.invoke('editor.insertNode', heading);
} else {
context.invoke('editor.formatH4');
}
}
});
using the current formatH4 wont work for my use case because i want to add this tag to a user range selection instead of just formating the entire line into h4
now i want to add behavior to my button so it gets selected when your cursor is inside a h4 tag
i tried creating a range with summernote api but i just cant figure out how to use this created range to see if i'm inside a h4 tag