Hi
Using MW 1.42.3, the copied source code gets a double "end line characters" for every line.
For example
line 1 line 2 line 3 line 4
gets copied as
line 1 line 2 line 3 line 4
Hi
Using MW 1.42.3, the copied source code gets a double "end line characters" for every line.
For example
line 1 line 2 line 3 line 4
gets copied as
line 1 line 2 line 3 line 4
To add some more detail, the result is the same when the destination file is either Linux format or Windows format
Thanks for reporting. I couldn't quite reproduce this.
Can you try to add a "trim" to https://github.com/wikimedia/mediawiki-extensions-PreToClip/blob/1.0.12/resources/ext.preToClip.js#L19 ?
var clipboardText = pre.innerText.trim();
Or maybe better remove "carriage returns"
var clipboardText = pre.innerText.replace(/\r/gm, "");
If pre element is one line only, this extension changes the height of the lement on hover event to fit the button
Would be cool to preserver the height even for one liners.
I also agree that this would be a nice change, changing the css for the whole Wiki for pre elements to include min-height property might be a workaround.
Smth like that should help:
Hello and thank you for this wonderful extension. However, on my MW 1.40.0 website it doesn't really work. It's rather strange – it is always visible and functional when previewing pages with PRE tags, and also visible right after submitting the edit. In any other circumstances, the pageloader merely ignores it – there is no HTML of it in the code. Any idea ? I've tried both the 1.39 (not at al functional) and master version. Thank you, 213.233.108.192 08:12, 20 October 2023 (UTC)
I have the same problem, using MW1_39. The copy button does only appear right after an edit. On subsequent page calls, no buttons are shown. A look in the javascript console showed the following error:
Uncaught ReferenceError: OO is not defined createPreToClipButton https://<host>/extensions/PreToClip/resources/ext.preToClip.js?4b2c4:23 <anonymous> https://<host>/extensions/PreToClip/resources/ext.preToClip.js?4b2c4:11 <anonymous> https://<host>/extensions/PreToClip/resources/ext.preToClip.js?4b2c4:42 ext.preToClip.js:23:20
After getting a little bit aquainted with the OOUI Library I added a line to the extension's extension.json
:
{
"ResourceModules": {
"ext.preToClip": {
"localBasePath": "resources",
"remoteExtPath": "PreToClip/resources",
"scripts": [
"ext.preToClip.js"
],
"styles": [
"ext.preToClip.css"
],
"dependencies": [
"mediawiki.ui.button",
"oojs-ui-core",
"oojs-ui.styles.icons-editing-advanced"
],
"messages": [
"pretoclip-button-tooltip",
"pretoclip-button-notification-text"
]
}
}
}
And now it works fine.
PS: I would like to have submitted a gerrit patch, alas I'm a github user and digging into gerrit-manuals was too much a strain on my time. Sorry.
Ok, took the time (what else is there to do). Here is the link to the patch: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/PreToClip/+/968990
Would be nice, if you could backport this patch into branch REL1_39.
I have merged and released this fix as version 1.0.5. @Oetterer Thanks for the contribution.