Skip to content

Commit 26342fb

Browse files
shove
1 parent 7c51f6c commit 26342fb

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

source/features/formats.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,22 @@ export function toggle_format_with_data(editor, format, data, event) {
1919
if (event) event.preventDefault()
2020
let selection = get_selection(editor)
2121
selection_edge(editor, selection)
22+
selection = get_selection(editor)
2223
if (data) apply_data(editor, selection, data)
23-
let apply = false
24-
selection_each_text(editor, selection, function(node, index) {
25-
if (! u(node).parent().hasClass(format)) apply = true
26-
})
24+
let apply = should_apply_format(editor, selection, format)
2725
if (apply) apply_format(editor, selection, format)
2826
else remove_format(editor, selection, format)
2927
}
3028

29+
function should_apply_format(editor, selection, format) {
30+
31+
let result = false
32+
selection_each_text(editor, selection, function(node, index) {
33+
if (! u(node).parent().hasClass(format)) result = true
34+
})
35+
return result
36+
}
37+
3138
function apply_data(editor, selection, data) {
3239

3340
selection_each_text(editor, selection, function(node, index) {

0 commit comments

Comments
 (0)