synology:dokuwiki
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| synology:dokuwiki [2024/04/09 23:35] – [Allow additional file types] Wuff | synology:dokuwiki [2026/07/26 13:57] (current) – Wuff | ||
|---|---|---|---|
| Line 313: | Line 313: | ||
| php bin/ | php bin/ | ||
| php bin/ | php bin/ | ||
| + | </ | ||
| + | |||
| + | ===== Fix code copy ===== | ||
| + | |||
| + | The code copying replaces empty new lines with space (nbsp;) which are copied via selection or using the copy button. To replace the spaces with actual newlines, create conf/ | ||
| + | <code javascript conf/ | ||
| + | jQuery(function() { | ||
| + | // Helper function to sanitize text formatting | ||
| + | function cleanDokuWikiCodeSpaces(text) { | ||
| + | return text | ||
| + | .replace(/ | ||
| + | .replace(/ | ||
| + | .replace(/ | ||
| + | .replace(/ | ||
| + | } | ||
| + | |||
| + | // FIX 1: Handle standard user manual mouse selections (Ctrl+C) | ||
| + | document.addEventListener(' | ||
| + | const selection = window.getSelection(); | ||
| + | if (selection.rangeCount > 0 && selection.anchorNode.parentElement.closest(' | ||
| + | let cleanedText = cleanDokuWikiCodeSpaces(selection.toString()); | ||
| + | e.clipboardData.setData(' | ||
| + | e.preventDefault(); | ||
| + | } | ||
| + | }); | ||
| + | |||
| + | // FIX 2: Handle DokuWiki Core's Native Async Copy Button | ||
| + | document.addEventListener(' | ||
| + | // Targets DokuWiki' | ||
| + | const btn = e.target.closest(' | ||
| + | if (!btn) return; | ||
| + | |||
| + | // Force monitor the system clipboard immediately following the click | ||
| + | let attempts = 0; | ||
| + | const maxAttempts = 10; | ||
| + | |||
| + | const checkAndCleanClipboard = setInterval(async () => { | ||
| + | attempts++; | ||
| + | try { | ||
| + | let currentText = await navigator.clipboard.readText(); | ||
| + | |||
| + | // If clipboard contains data and has the raw space error, rewrite it immediately | ||
| + | if (currentText && (currentText.includes(' | ||
| + | let cleanedText = cleanDokuWikiCodeSpaces(currentText); | ||
| + | await navigator.clipboard.writeText(cleanedText); | ||
| + | clearInterval(checkAndCleanClipboard); | ||
| + | } | ||
| + | } catch (err) { | ||
| + | // Clipboard permissions might delay slightly, keep trying | ||
| + | } | ||
| + | |||
| + | if (attempts >= maxAttempts) { | ||
| + | clearInterval(checkAndCleanClipboard); | ||
| + | } | ||
| + | }, 30); // Check every 30ms for immediate execution | ||
| + | }); | ||
| + | }); | ||
| + | |||
| </ | </ | ||
synology/dokuwiki.txt · Last modified: by Wuff