Dosiero demo: HugeRTE

Demo only. Everything you upload is visible to every other visitor of this demo, and is deleted again within minutes. Actions are logged, including your IP address. Do not upload anything private, unlawful, or that you are not entitled to share.

HugeRTE is an MIT fork of TinyMCE 6, loaded here straight from the jsDelivr CDN — no license key, no build step, and no base_url: the editor finds its skins and plugins next to the script it was loaded from, the same way Dosiero finds its stylesheet. file_picker_callback has the signature it has in TinyMCE, so the code below differs from the TinyMCE 6 demo only in the global it initialises through.

The file manager opens in a new window, which a popup blocker can stop. The browser allows window.open() only while it is still handling a user gesture, so open() must be reached synchronously from the click — never after an await. Even then some blockers refuse, and the click then appears to do nothing; the browser shows a blocked-popup icon in the address bar. If that is not acceptable for your integration, use mode: 'iframe' and render the manager into a dialog of your own.

Integration

HugeRTE is a fork of TinyMCE 6, so file_picker_callback has the signature it has there: the editor hands you a callback to return the chosen URL to. The only difference from the TinyMCE 6 demo is the global the editor is initialised through. This is the code this page runs:

<script type="module">
    import {Dosiero} from '/dosiero/dosiero.min.mjs';

    document.addEventListener('DOMContentLoaded', () => {
        hugerte.init({
            selector: '.editor',
            plugins: 'image link media',
            toolbar: 'image link media',

            file_picker_callback: function (callback, value, meta) {
                new Dosiero({
                    mode: 'window',
                    endpoint: window.location.origin + '/endpoint/index.php',
                    onSelectFile: function (files) {
                        // the manager allows multiple selection, an editor wants one file
                        for (let file of files) {
                            if (file.type === 'file') {
                                callback(file.url, {alt: file.name, title: file.name});
                                break;
                            }
                        }
                    },
                }).open();
            }
        });
    });
</script>

Because the signature matches, one adapter can serve both families — that is why HugeRTE costs almost nothing to support next to TinyMCE.

Self-hosted instead of the CDN

Install the package and serve it yourself. The editor then needs base_url, because it is loaded from a path that does not match the layout it expects — everything else stays as it is above.

npm install --save hugerte
<script src="/node_modules/hugerte/hugerte.min.js"></script>

hugerte.init({
    selector: '.editor',
    base_url: '/node_modules/hugerte',
    // …the rest unchanged
});

That path assumes hugerte/ has been copied into the public assets — which is what this demo does with Dosiero itself: npm run build copies its dist/ into www/dosiero/, so node_modules stays out of the webroot entirely.

back