Add quick code tags keybind.
This commit is contained in:
parent
d6ba19b2a8
commit
bccee036b2
@ -160,7 +160,8 @@
|
|||||||
openEmptyQR: ['I', 'Open QR without post number inserted'],
|
openEmptyQR: ['I', 'Open QR without post number inserted'],
|
||||||
openOptions: ['ctrl+o', 'Open Options'],
|
openOptions: ['ctrl+o', 'Open Options'],
|
||||||
close: ['Esc', 'Close Options or QR'],
|
close: ['Esc', 'Close Options or QR'],
|
||||||
spoiler: ['ctrl+s', 'Quick spoiler'],
|
spoiler: ['ctrl+s', 'Quick spoiler tags'],
|
||||||
|
code: ['alt+c', 'Quick code tags'],
|
||||||
submit: ['alt+s', 'Submit post'],
|
submit: ['alt+s', 'Submit post'],
|
||||||
watch: ['w', 'Watch thread'],
|
watch: ['w', 'Watch thread'],
|
||||||
update: ['u', 'Update now'],
|
update: ['u', 'Update now'],
|
||||||
@ -1023,7 +1024,7 @@
|
|||||||
return $.on(d, 'keydown', Keybinds.keydown);
|
return $.on(d, 'keydown', Keybinds.keydown);
|
||||||
},
|
},
|
||||||
keydown: function(e) {
|
keydown: function(e) {
|
||||||
var key, link, o, range, selEnd, selStart, ta, thread, value;
|
var key, link, o, ta, thread;
|
||||||
if (!(key = Keybinds.keyCode(e)) || /TEXTAREA|INPUT/.test(e.target.nodeName) && !(e.altKey || e.ctrlKey || e.keyCode === 27)) {
|
if (!(key = Keybinds.keyCode(e)) || /TEXTAREA|INPUT/.test(e.target.nodeName) && !(e.altKey || e.ctrlKey || e.keyCode === 27)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1057,12 +1058,14 @@
|
|||||||
if (ta.nodeName !== 'TEXTAREA') {
|
if (ta.nodeName !== 'TEXTAREA') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
value = ta.value;
|
Keybinds.tags('spoiler', ta);
|
||||||
selStart = ta.selectionStart;
|
break;
|
||||||
selEnd = ta.selectionEnd;
|
case Conf.code:
|
||||||
ta.value = value.slice(0, selStart) + '[spoiler]' + value.slice(selStart, selEnd) + '[/spoiler]' + value.slice(selEnd);
|
ta = e.target;
|
||||||
range = 9 + selEnd;
|
if (ta.nodeName !== 'TEXTAREA') {
|
||||||
ta.setSelectionRange(range, range);
|
return;
|
||||||
|
}
|
||||||
|
Keybinds.tags('code', ta);
|
||||||
break;
|
break;
|
||||||
case Conf.watch:
|
case Conf.watch:
|
||||||
Watcher.toggle(thread);
|
Watcher.toggle(thread);
|
||||||
@ -1203,6 +1206,15 @@
|
|||||||
}
|
}
|
||||||
return key;
|
return key;
|
||||||
},
|
},
|
||||||
|
tags: function(tag, ta) {
|
||||||
|
var range, selEnd, selStart, value;
|
||||||
|
value = ta.value;
|
||||||
|
selStart = ta.selectionStart;
|
||||||
|
selEnd = ta.selectionEnd;
|
||||||
|
ta.value = value.slice(0, selStart) + ("[" + tag + "]") + value.slice(selStart, selEnd) + ("[/" + tag + "]") + value.slice(selEnd);
|
||||||
|
range = ("[" + tag + "]").length + selEnd;
|
||||||
|
return ta.setSelectionRange(range, range);
|
||||||
|
},
|
||||||
img: function(thread, all) {
|
img: function(thread, all) {
|
||||||
var thumb;
|
var thumb;
|
||||||
if (all) {
|
if (all) {
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
master
|
master
|
||||||
|
|
||||||
|
- Mayhem
|
||||||
|
Add quick [code] tags keybind (alt+c).
|
||||||
|
|
||||||
2.30.4
|
2.30.4
|
||||||
- Mayhem
|
- Mayhem
|
||||||
Add /co/ and /k/ archive redirection.
|
Add /co/ and /k/ archive redirection.
|
||||||
|
|||||||
@ -123,7 +123,8 @@ Config =
|
|||||||
openEmptyQR: ['I', 'Open QR without post number inserted']
|
openEmptyQR: ['I', 'Open QR without post number inserted']
|
||||||
openOptions: ['ctrl+o', 'Open Options']
|
openOptions: ['ctrl+o', 'Open Options']
|
||||||
close: ['Esc', 'Close Options or QR']
|
close: ['Esc', 'Close Options or QR']
|
||||||
spoiler: ['ctrl+s', 'Quick spoiler']
|
spoiler: ['ctrl+s', 'Quick spoiler tags']
|
||||||
|
code: ['alt+c', 'Quick code tags']
|
||||||
submit: ['alt+s', 'Submit post']
|
submit: ['alt+s', 'Submit post']
|
||||||
# Thread related
|
# Thread related
|
||||||
watch: ['w', 'Watch thread']
|
watch: ['w', 'Watch thread']
|
||||||
@ -801,19 +802,11 @@ Keybinds =
|
|||||||
when Conf.spoiler
|
when Conf.spoiler
|
||||||
ta = e.target
|
ta = e.target
|
||||||
return if ta.nodeName isnt 'TEXTAREA'
|
return if ta.nodeName isnt 'TEXTAREA'
|
||||||
|
Keybinds.tags 'spoiler', ta
|
||||||
value = ta.value
|
when Conf.code
|
||||||
selStart = ta.selectionStart
|
ta = e.target
|
||||||
selEnd = ta.selectionEnd
|
return if ta.nodeName isnt 'TEXTAREA'
|
||||||
|
Keybinds.tags 'code', ta
|
||||||
ta.value =
|
|
||||||
value[...selStart] +
|
|
||||||
'[spoiler]' + value[selStart...selEnd] + '[/spoiler]' +
|
|
||||||
value[selEnd..]
|
|
||||||
|
|
||||||
range = 9 + selEnd
|
|
||||||
# Move the caret to the end of the selection.
|
|
||||||
ta.setSelectionRange range, range
|
|
||||||
# Thread related
|
# Thread related
|
||||||
when Conf.watch
|
when Conf.watch
|
||||||
Watcher.toggle thread
|
Watcher.toggle thread
|
||||||
@ -884,6 +877,20 @@ Keybinds =
|
|||||||
if e.ctrlKey then key = 'ctrl+' + key
|
if e.ctrlKey then key = 'ctrl+' + key
|
||||||
key
|
key
|
||||||
|
|
||||||
|
tags: (tag, ta) ->
|
||||||
|
value = ta.value
|
||||||
|
selStart = ta.selectionStart
|
||||||
|
selEnd = ta.selectionEnd
|
||||||
|
|
||||||
|
ta.value =
|
||||||
|
value[...selStart] +
|
||||||
|
"[#{tag}]" + value[selStart...selEnd] + "[/#{tag}]" +
|
||||||
|
value[selEnd..]
|
||||||
|
|
||||||
|
range = "[#{tag}]".length + selEnd
|
||||||
|
# Move the caret to the end of the selection.
|
||||||
|
ta.setSelectionRange range, range
|
||||||
|
|
||||||
img: (thread, all) ->
|
img: (thread, all) ->
|
||||||
if all
|
if all
|
||||||
$.id('imageExpand').click()
|
$.id('imageExpand').click()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user