1 $.Redactor
.prototype.WoltLabKeydown = function() {
8 this.keydown
.onArrowDown
= (function() {
9 var tags
= this.WoltLabKeydown
._getBlocks();
11 for (var i
= 0; i
< tags
.length
; i
++) {
13 this.keydown
.insertAfterLastElement(tags
[i
]);
19 this.keydown
.onArrowUp
= (function() {
20 var tags
= this.WoltLabKeydown
._getBlocks();
22 for (var i
= 0; i
< tags
.length
; i
++) {
24 this.keydown
.insertBeforeFirstElement(tags
[i
]);
30 var mpOnEnter
= this.keydown
.onEnter
;
31 this.keydown
.onEnter
= (function(e
) {
32 var isBlockquote
= this.keydown
.blockquote
;
33 if (isBlockquote
) this.keydown
.blockquote
= false;
35 mpOnEnter
.call(this, e
);
37 if (isBlockquote
) this.keydown
.blockquote
= isBlockquote
;
40 this.keydown
.onShiftEnter
= (function(e
) {
43 if (this.keydown
.pre
) {
44 return this.keydown
.insertNewLine(e
);
47 return this.insert
.raw('<br>\u200B');
50 var mpOnTab
= this.keydown
.onTab
;
51 this.keydown
.onTab
= (function(e
, key
) {
52 if (!this.keydown
.pre
&& $(this.selection
.current()).closest('ul, ol', this.core
.editor()[0]).length
=== 0) {
56 return mpOnTab
.call(this, e
, key
);
59 require(['Core', 'Environment'], (function (Core
, Environment
) {
60 if (Environment
.platform() !== 'desktop') {
61 // ignore mobile devices
65 var container
= this.$editor
[0].closest('form, .message');
66 if (container
=== null) return;
68 var formSubmit
= elBySel('.formSubmit', container
);
69 if (formSubmit
=== null) return;
71 var submitButton
= elBySel('input[type="submit"], button[data-type="save"], button[accesskey="s"]', formSubmit
);
74 submitButton
.removeAttribute('accesskey');
76 // mimic the same behavior which will also work with more
77 // than one editor instance on the page
78 this.WoltLabEvent
.register('keydown', (function (data
) {
80 if (data
.event
.which
=== 83) {
83 if (window
.navigator
.platform
.match(/^Mac/)) {
84 if (data
.event
.ctrlKey
&& data
.event
.altKey
) {
88 else if (data
.event
.altKey
&& !data
.event
.ctrlKey
) {
95 Core
.triggerEvent(submitButton
, WCF_CLICK_EVENT
);
104 register: function (tag
) {
105 if (_tags
.indexOf(tag
) === -1) {
110 _getBlocks: function () {
111 var tags
= [this.keydown
.blockquote
, this.keydown
.pre
, this.keydown
.figcaption
];
113 for (var i
= 0, length
= _tags
.length
; i
< length
; i
++) {
114 tags
.push(this.utils
.isTag(this.keydown
.current
, _tags
[i
]))