Commit 959cb943 authored by jan.koester's avatar jan.koester
Browse files

test

parent 526b66f9
Loading
Loading
Loading
Loading
+42 −0
Changes for data/template/default/editor.html: 42 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@
        CONFIRM_IMPORT: '${I18N_CONFIRM_IMPORT}',
        IMPORTING: '${I18N_IMPORTING}',
        XML_IMPORTED: '${I18N_XML_IMPORTED}',
        HTML_IMPORTED: '${I18N_HTML_IMPORTED}',
        IMPORT_FAILED: '${I18N_IMPORT_FAILED}',
        NO_TEMPLATES: '${I18N_NO_TEMPLATES}',
        LOAD: '${I18N_LOAD}',
@@ -540,6 +541,8 @@
                    <button class="tpl-btn tpl-btn-secondary" onclick="exportXml()" title="${I18N_TITLE_EXPORT_XML}">&#x1F4E4; ${I18N_EXPORT_XML}</button>
                    <button class="tpl-btn tpl-btn-secondary" onclick="importXmlClick()" title="${I18N_TITLE_IMPORT_XML}">&#x1F4E5; ${I18N_IMPORT_XML}</button>
                    <input type="file" id="xml-import-input" accept=".xml,text/xml" style="display:none" onchange="importXmlFile(this)">
                    <button class="tpl-btn tpl-btn-secondary" onclick="importHtmlClick()" title="${I18N_TITLE_IMPORT_HTML}">&#x1F310; ${I18N_IMPORT_HTML}</button>
                    <input type="file" id="html-import-input" accept=".html,.htm,text/html" style="display:none" onchange="importHtmlFile(this)">
                </div>
            </div>

@@ -2187,6 +2190,45 @@
            document.getElementById('xml-import-input').click();
        }

        /**
         * Trigger the hidden file input for HTML import.
         */
        function importHtmlClick() {
            document.getElementById('html-import-input').click();
        }

        /**
         * Read the selected HTML file and send it to the backend for import.
         * @param {HTMLInputElement} input The file input element.
         */
        async function importHtmlFile(input) {
            const file = input.files[0];
            if (!file) return;
            input.value = '';

            if (!confirm(`${I18N.CONFIRM_IMPORT} "${file.name}"?`)) return;

            try {
                setTplStatus(I18N.IMPORTING, false);
                const htmlText = await file.text();
                const result = await sendApiRequest([{ command: 'ImportHtml', html: htmlText }]);
                const resp = result[0];
                if (resp.status === 'success') {
                    currentTemplateId = null;
                    currentTemplateName = file.name.replace(/\.html?$/i, '');
                    updateCurrentTemplateDisplay(currentTemplateName, null);
                    await initDocumentTree();
                    reloadIframe();
                    handleElementSelection('WebEditor');
                    setTplStatus(I18N.HTML_IMPORTED, false);
                } else {
                    setTplStatus(resp.message || I18N.IMPORT_FAILED, true);
                }
            } catch (e) {
                setTplStatus('Error: ' + e.message, true);
            }
        }

        /**
         * Read the selected XML file and send it to the backend for import.
         * @param {HTMLInputElement} input The file input element.
+6 −0
Changes for src/translations.h: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -214,6 +214,9 @@ namespace blogi {
            {"I18N_EXPORT_XML",          "XML exportieren"},
            {"I18N_TITLE_IMPORT_XML",    "XML Datei in Editor importieren"},
            {"I18N_IMPORT_XML",          "XML importieren"},
            {"I18N_TITLE_IMPORT_HTML",   "HTML Datei in Editor importieren"},
            {"I18N_IMPORT_HTML",         "HTML importieren"},
            {"I18N_HTML_IMPORTED",       "HTML erfolgreich importiert."},
            {"I18N_PUBLISH",             "Ver&ouml;ffentlichen"},
            {"I18N_TITLE_PUBLISH",       "Inhalt ver&ouml;ffentlichen"},
            {"I18N_CONTENT_INDEX",       "Inhaltsverzeichnis"},
@@ -557,6 +560,9 @@ namespace blogi {
            {"I18N_EXPORT_XML",          "Export XML"},
            {"I18N_TITLE_IMPORT_XML",    "Import XML file into editor"},
            {"I18N_IMPORT_XML",          "Import XML"},
            {"I18N_TITLE_IMPORT_HTML",   "Import HTML file into editor"},
            {"I18N_IMPORT_HTML",         "Import HTML"},
            {"I18N_HTML_IMPORTED",       "HTML imported successfully."},
            {"I18N_PUBLISH",             "Publish"},
            {"I18N_TITLE_PUBLISH",       "Publish content"},
            {"I18N_CONTENT_INDEX",       "Content Index"},