MediaWiki:Citizen.js: Porovnání verzí
MediaWiki interface page
More actions
Bez shrnutí editace značka: revertováno |
Bez shrnutí editace značka: revertováno |
||
| Řádek 7: | Řádek 7: | ||
if (!surface || !surface.$element) return; | if (!surface || !surface.$element) return; | ||
if (surface.$element.data('shiftEnterBrBound')) return; | if (surface.$element.data('shiftEnterBrBound')) return; | ||
surface.$element.data('shiftEnterBrBound', true); | surface.$element.data('shiftEnterBrBound', true); | ||
| Řádek 21: | Řádek 20: | ||
// fallback – nic | // fallback – nic | ||
} | } | ||
} | |||
}); | |||
}); | |||
$(function () { | |||
if (mw.config.get('wgAction') !== 'edit' && mw.config.get('wgAction') !== 'submit') return; | |||
var $box = $('#wpTextbox1'); | |||
if (!$box.length) return; | |||
$box.on('keydown', function (e) { | |||
if (e.key === 'Enter' && e.shiftKey) { | |||
e.preventDefault(); | |||
var el = this, start = el.selectionStart, end = el.selectionEnd, v = el.value; | |||
var ins = '<br />'; | |||
el.value = v.slice(0, start) + ins + v.slice(end); | |||
el.selectionStart = el.selectionEnd = start + ins.length; | |||
} | } | ||
}); | }); | ||
}); | }); | ||
Verze z 9. 10. 2025, 17:04
/* Zde uvedený JavaScript bude použit pro všechny uživatele při načtení každé stránky */
mw.hook('ve.activationComplete').add(function () {
var target = ve.init && ve.init.target;
if (!target) return;
var surface = target.getSurface && target.getSurface();
if (!surface || !surface.$element) return;
if (surface.$element.data('shiftEnterBrBound')) return;
surface.$element.data('shiftEnterBrBound', true);
surface.$element.on('keydown', function (e) {
if (e.key === 'Enter' && e.shiftKey) {
e.preventDefault();
try {
var frag = surface.getModel().getFragment();
// VE interní “break” uzel = <br>
frag.insertContent([{ type: 'break' }]);
} catch (err) {
// fallback – nic
}
}
});
});
$(function () {
if (mw.config.get('wgAction') !== 'edit' && mw.config.get('wgAction') !== 'submit') return;
var $box = $('#wpTextbox1');
if (!$box.length) return;
$box.on('keydown', function (e) {
if (e.key === 'Enter' && e.shiftKey) {
e.preventDefault();
var el = this, start = el.selectionStart, end = el.selectionEnd, v = el.value;
var ins = '<br />';
el.value = v.slice(0, start) + ins + v.slice(end);
el.selectionStart = el.selectionEnd = start + ins.length;
}
});
});