Create and dispatch 'input' events for keybind tags and quote insertion.
This commit is contained in:
parent
69c21f771a
commit
5a64b7b06c
@ -1254,13 +1254,16 @@
|
|||||||
return key;
|
return key;
|
||||||
},
|
},
|
||||||
tags: function(tag, ta) {
|
tags: function(tag, ta) {
|
||||||
var range, selEnd, selStart, value;
|
var e, range, selEnd, selStart, value;
|
||||||
value = ta.value;
|
value = ta.value;
|
||||||
selStart = ta.selectionStart;
|
selStart = ta.selectionStart;
|
||||||
selEnd = ta.selectionEnd;
|
selEnd = ta.selectionEnd;
|
||||||
ta.value = value.slice(0, selStart) + ("[" + tag + "]") + value.slice(selStart, selEnd) + ("[/" + tag + "]") + value.slice(selEnd);
|
ta.value = value.slice(0, selStart) + ("[" + tag + "]") + value.slice(selStart, selEnd) + ("[/" + tag + "]") + value.slice(selEnd);
|
||||||
range = ("[" + tag + "]").length + selEnd;
|
range = ("[" + tag + "]").length + selEnd;
|
||||||
return ta.setSelectionRange(range, range);
|
ta.setSelectionRange(range, range);
|
||||||
|
e = d.createEvent('Event');
|
||||||
|
e.initEvent('input', true, false);
|
||||||
|
return ta.dispatchEvent(e);
|
||||||
},
|
},
|
||||||
img: function(thread, all) {
|
img: function(thread, all) {
|
||||||
var thumb;
|
var thumb;
|
||||||
@ -1560,10 +1563,13 @@
|
|||||||
}
|
}
|
||||||
ta = $('textarea', QR.el);
|
ta = $('textarea', QR.el);
|
||||||
caretPos = ta.selectionStart;
|
caretPos = ta.selectionStart;
|
||||||
QR.selected.el.lastChild.textContent = QR.selected.com = ta.value = ta.value.slice(0, caretPos) + text + ta.value.slice(ta.selectionEnd);
|
ta.value = ta.value.slice(0, caretPos) + text + ta.value.slice(ta.selectionEnd);
|
||||||
ta.focus();
|
ta.focus();
|
||||||
range = caretPos + text.length;
|
range = caretPos + text.length;
|
||||||
return ta.setSelectionRange(range, range);
|
ta.setSelectionRange(range, range);
|
||||||
|
e = d.createEvent('Event');
|
||||||
|
e.initEvent('input', true, false);
|
||||||
|
return ta.dispatchEvent(e);
|
||||||
},
|
},
|
||||||
drag: function(e) {
|
drag: function(e) {
|
||||||
var i;
|
var i;
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
master
|
master
|
||||||
|
- Mayhem
|
||||||
|
Fix spoiler/code tag keybinds being ignored on post submission.
|
||||||
|
|
||||||
2.31.6
|
2.31.6
|
||||||
- Mayhem
|
- Mayhem
|
||||||
|
|||||||
@ -914,6 +914,11 @@ Keybinds =
|
|||||||
# Move the caret to the end of the selection.
|
# Move the caret to the end of the selection.
|
||||||
ta.setSelectionRange range, range
|
ta.setSelectionRange range, range
|
||||||
|
|
||||||
|
# Fire the 'input' event
|
||||||
|
e = d.createEvent 'Event'
|
||||||
|
e.initEvent 'input', true, false
|
||||||
|
ta.dispatchEvent e
|
||||||
|
|
||||||
img: (thread, all) ->
|
img: (thread, all) ->
|
||||||
if all
|
if all
|
||||||
$.id('imageExpand').click()
|
$.id('imageExpand').click()
|
||||||
@ -1143,16 +1148,17 @@ QR =
|
|||||||
ta = $ 'textarea', QR.el
|
ta = $ 'textarea', QR.el
|
||||||
caretPos = ta.selectionStart
|
caretPos = ta.selectionStart
|
||||||
# Replace selection for text.
|
# Replace selection for text.
|
||||||
# onchange event isn't triggered, save value.
|
ta.value = ta.value[...caretPos] + text + ta.value[ta.selectionEnd..]
|
||||||
QR.selected.el.lastChild.textContent =
|
|
||||||
QR.selected.com =
|
|
||||||
ta.value =
|
|
||||||
ta.value[...caretPos] + text + ta.value[ta.selectionEnd..]
|
|
||||||
ta.focus()
|
ta.focus()
|
||||||
# Move the caret to the end of the new quote.
|
# Move the caret to the end of the new quote.
|
||||||
range = caretPos + text.length
|
range = caretPos + text.length
|
||||||
ta.setSelectionRange range, range
|
ta.setSelectionRange range, range
|
||||||
|
|
||||||
|
# Fire the 'input' event
|
||||||
|
e = d.createEvent 'Event'
|
||||||
|
e.initEvent 'input', true, false
|
||||||
|
ta.dispatchEvent e
|
||||||
|
|
||||||
drag: (e) ->
|
drag: (e) ->
|
||||||
# Let it drag anything from the page.
|
# Let it drag anything from the page.
|
||||||
i = if e.type is 'dragstart' then 'off' else 'on'
|
i = if e.type is 'dragstart' then 'off' else 'on'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user