User Tools

Site Tools


synology:dokuwiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
synology:dokuwiki [2024/02/13 23:09] – [Changes & Pagelist plugin] Wuffsynology:dokuwiki [2026/07/26 13:57] (current) Wuff
Line 264: Line 264:
  
 ===== Allow additional file types ===== ===== Allow additional file types =====
-Log into synology via ssh or access the dokuwiki folder.\\  
 <code> <code>
-cd /volume1/web/dokuwiki/conf +cd dokuwiki/conf 
-sudo cp mime.conf mime.local.conf +cp mime.conf mime.local.conf 
-sudo vi mime.local.conf+vi mime.local.conf
 #delete all but the text files towards the end of the file and enable them #delete all but the text files towards the end of the file and enable them
 #add json text/json #add json text/json
Line 314: Line 313:
 php bin/plugin.php extension install https://github.com/.../support_keycloak10.zip # installs from the URL php bin/plugin.php extension install https://github.com/.../support_keycloak10.zip # installs from the URL
 php bin/plugin.php extension install addnewpage # finds the download URL, install from it php bin/plugin.php extension install addnewpage # finds the download URL, install from it
 +</code>
 +
 +===== 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/userscript.js and copy the following code, then save and hard-refresh the browser:
 +<code javascript conf/userscript.js>
 +jQuery(function() {
 +    // Helper function to sanitize text formatting
 +    function cleanDokuWikiCodeSpaces(text) {
 +        return text
 +            .replace(/\r\n/g, '\n'             // Standardize linebreaks
 +            .replace(/\n[ \u00A0]+(?=\n)/g, '\n') // Remove spaces sitting completely alone on a line
 +            .replace(/^[ \u00A0]+\n/, '\n'      // Clean leading blank lines
 +            .replace(/\n[ \u00A0]+$/, '\n');      // Clean trailing blank lines
 +    }
 +
 +    // FIX 1: Handle standard user manual mouse selections (Ctrl+C)
 +    document.addEventListener('copy', function(e) {
 +        const selection = window.getSelection();
 +        if (selection.rangeCount > 0 && selection.anchorNode.parentElement.closest('pre.code')) {
 +            let cleanedText = cleanDokuWikiCodeSpaces(selection.toString());
 +            e.clipboardData.setData('text/plain', cleanedText);
 +            e.preventDefault();
 +        }
 +    });
 +
 +    // FIX 2: Handle DokuWiki Core's Native Async Copy Button
 +    document.addEventListener('click', function(e) {
 +        // Targets DokuWiki's core copy elements (like .button-copy or data targets)
 +        const btn = e.target.closest('button, a, div') && e.target.closest('[class*="copy"], [id*="copy"], [data-clipboard-target]');
 +        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('\n ') || currentText.includes('\n\u00A0'))) {
 +                    let cleanedText = cleanDokuWikiCodeSpaces(currentText);
 +                    await navigator.clipboard.writeText(cleanedText);
 +                    clearInterval(checkAndCleanClipboard); // Success, stop looping
 +                }
 +            } catch (err) {
 +                // Clipboard permissions might delay slightly, keep trying
 +            }
 +
 +            if (attempts >= maxAttempts) {
 +                clearInterval(checkAndCleanClipboard); // Timeout safety fallback
 +            }
 +        }, 30); // Check every 30ms for immediate execution
 +    });
 +});
 +
 </code> </code>
  
synology/dokuwiki.1707865792.txt.gz · Last modified: by Wuff