User:Bosco/Unsigned helper.js: Difference between revisions

From Test Wiki
Content deleted Content added
doAddUnsignedTemplate: improve filtering of the selection to filter out output of Template:Unsigned and Template:Unsigned IP – when the output ends in a closing tag </small>
doAddUnsignedTemplate: drop line breaks from selection
Line 508: Line 508:
* For reference, see https://en.wikipedia.org/wiki/MediaWiki:Gadget-charinsert-core.js#L-251--L-258
* For reference, see https://en.wikipedia.org/wiki/MediaWiki:Gadget-charinsert-core.js#L-251--L-258
*/
*/
const $editor = $(wikitextEditor);
while ($editor.textSelection('getSelection').endsWith('\n')) {
const [selectionStart, selectionEnd] = $editor.textSelection('getCaretPosition', {startAndEnd:true});
$editor.textSelection('setSelection', {start: selectionStart, end:(selectionEnd - 1)});
}
const originalSelection = $(wikitextEditor).textSelection('getSelection');
const originalSelection = $(wikitextEditor).textSelection('getSelection');
let selection = originalSelection;
let selection = originalSelection;