Commit aa7045f4 authored by jan.koester's avatar jan.koester
Browse files

test

parent 54c8cfb7
Loading
Loading
Loading
Loading
+5 −0
Changes for CMakeLists.txt: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -40,3 +40,8 @@ add_subdirectory(src)
add_subdirectory(plugins)
add_subdirectory(tests)
add_subdirectory(data)

option(BUILD_CLIENT "Build the Qt desktop editor client" OFF)
if(BUILD_CLIENT)
    add_subdirectory(client)
endif()

client/CMakeLists.txt

0 → 100644
+46 −0
Changes for client/CMakeLists.txt: 46 added lines, 0 removed lines.
Original line number Diff line number Diff line
cmake_minimum_required(VERSION 3.18)

find_package(Qt6 REQUIRED COMPONENTS Core Widgets WebEngineWidgets Network)
qt_standard_project_setup()

set(CMAKE_AUTOMOC ON)

qt_add_executable(blogi-editor
    main.cpp
    mainwindow.cpp
    mainwindow.h
    documentmanager.cpp
    documentmanager.h
    publishclient.cpp
    publishclient.h
    localapi.cpp
    localapi.h
)

qt_add_resources(blogi-editor "editor_resources"
    PREFIX "/editor"
    FILES
        html/editor.html
        html/editor.css
        html/editor.js
)

target_link_libraries(blogi-editor PRIVATE
    Qt6::Core
    Qt6::Widgets
    Qt6::WebEngineWidgets
    Qt6::Network
    blogidev
    tinyxml2::tinyxml2
    json-c::json-c
    uuidp::uuidp
    htmlpp::htmlpp
)

target_include_directories(blogi-editor PRIVATE
    ${CMAKE_SOURCE_DIR}/src
)

add_subdirectory(widgets)

install(TARGETS blogi-editor DESTINATION bin)
+755 −0

File added.

Preview size limit exceeded, changes collapsed.

+109 −0
Changes for client/documentmanager.h: 109 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*******************************************************************************
 * Copyright (c) 2026, Jan Koester jan.koester@gmx.net
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 * Neither the name of the <organization> nor the
 *      names of its contributors may be used to endorse or promote products
 *      derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *******************************************************************************/

#pragma once

#include <QObject>
#include <QString>
#include <QList>
#include <memory>
#include <vector>
#include <map>

#include <tinyxml2.h>
#include <json-c/json.h>

namespace blogi { namespace webedit {
    class EditPlugin;
    class EditPluginLoad;
}}

class DocumentManager : public QObject {
    Q_OBJECT
public:
    explicit DocumentManager(const QString &pluginDir, QObject *parent = nullptr);
    ~DocumentManager();

    void newDocument();
    bool loadFromFile(const QString &path);
    bool saveToFile(const QString &path);
    QString exportXml() const;
    bool importXml(const QString &xml);
    QString renderToHtml();

    /* Plugin info */
    QString getPluginTypes() const;

    /* Document tree */
    QString getDocTree() const;

    /* Element operations — return JSON response */
    QString addElement(const QString &parentUuid, const QString &pluginName, int position);
    QString removeElement(const QString &uuid);
    QString moveElementUp(const QString &uuid);
    QString moveElementDown(const QString &uuid);
    QString indentElement(const QString &uuid);
    QString outdentElement(const QString &uuid);
    QString copyElement(const QString &uuid);
    QString pasteElement(const QString &targetUuid);

    /* Property access */
    QString getElementProperties(const QString &uuid);
    QString setElementProperties(const QString &uuid, const QString &propsJson);

private:
    void clearDocument();
    void loadWidgetsFromXml(tinyxml2::XMLElement *xmlEl,
                            blogi::webedit::EditPlugin *parent);
    blogi::webedit::EditPlugin *createPluginByName(const std::string &name);
    blogi::webedit::EditPlugin *findByUuid(blogi::webedit::EditPlugin *root,
                                            const std::string &uuid);

    struct NodeContext {
        blogi::webedit::EditPlugin *node   = nullptr;
        blogi::webedit::EditPlugin *parent = nullptr;
        blogi::webedit::EditPlugin *prev   = nullptr;
    };
    NodeContext findNodeContext(const std::string &uuid);

    json_object *buildTreeJson(const blogi::webedit::EditPlugin *el) const;

    std::unique_ptr<blogi::webedit::EditPluginLoad> _pluginLoader;
    tinyxml2::XMLDocument                           _doc;
    tinyxml2::XMLElement                           *_rootEl = nullptr;

    /* Live widget tree — linked list of top-level elements */
    blogi::webedit::EditPlugin *_docRoot = nullptr;

    /* Owned element storage */
    std::vector<std::unique_ptr<blogi::webedit::EditPlugin,
                blogi::webedit::EditPluginDeleter>> _ownedElements;

    /* Clipboard */
    tinyxml2::XMLDocument _clipDoc;
    tinyxml2::XMLElement *_clipEl = nullptr;
};

client/html/editor.css

0 → 100644
+286 −0
Changes for client/html/editor.css: 286 added lines, 0 removed lines.
Original line number Diff line number Diff line
/* Blogi Desktop Editor – Dark Theme */
:root {
    --bg-primary: #1e1e2e;
    --bg-secondary: #2b2b3d;
    --bg-tertiary: #363650;
    --bg-hover: #3f3f5c;
    --text-primary: #cdd6f4;
    --text-secondary: #9399b2;
    --text-muted: #6c7086;
    --accent: #89b4fa;
    --accent-hover: #74c7ec;
    --border: #45475a;
    --success: #a6e3a1;
    --warning: #f9e2af;
    --danger: #f38ba8;
    --radius: 6px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

/* Layout */
#app {
    display: grid;
    grid-template-columns: 320px 6px 1fr;
    grid-template-rows: 48px 1fr;
    height: 100vh;
}

/* Header */
#header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}
#header h1 { font-size: 16px; font-weight: 600; }
#header .view-toggle {
    margin-left: auto;
    display: flex; gap: 4px;
}
#header .view-toggle button {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
}
#header .view-toggle button.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

/* Sidebar */
#sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Resizer */
#resizer {
    background: var(--border);
    cursor: col-resize;
    transition: background 0.2s;
}
#resizer:hover { background: var(--accent); }

/* Preview */
#preview-container {
    overflow: auto;
    background: #fff;
    position: relative;
}
#preview-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}
#preview-frame.mobile {
    width: 375px;
    margin: 0 auto;
    display: block;
}

/* Sections */
.section { margin-bottom: 8px; }
.section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

/* Plugin toolbar */
#plugin-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.plugin-btn {
    padding: 8px 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 11px;
    text-align: center;
    transition: all 0.15s;
}
.plugin-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

/* Document tree */
#doc-tree { font-size: 13px; }
.tree-node {
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}
.tree-node:hover { background: var(--bg-hover); }
.tree-node.selected { background: var(--accent); color: var(--bg-primary); }
.tree-node .expand-icon {
    width: 16px; text-align: center;
    font-size: 10px; color: var(--text-muted);
}
.tree-children { padding-left: 16px; }

/* Context menu buttons */
.node-actions {
    margin-left: auto;
    display: flex; gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}
.tree-node:hover .node-actions { opacity: 1; }
.node-action-btn {
    width: 22px; height: 22px;
    border: none; border-radius: 3px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    display: flex; align-items: center; justify-content: center;
}
.node-action-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.node-action-btn.danger:hover { color: var(--danger); }

/* Properties panel */
#properties-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.prop-group { margin-bottom: 4px; }
.prop-group label {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.prop-group input[type="text"],
.prop-group input[type="color"],
.prop-group input[type="number"],
.prop-group select,
.prop-group textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 13px;
}
.prop-group textarea { min-height: 60px; resize: vertical; }
.prop-group input:focus,
.prop-group select:focus,
.prop-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}
.prop-group input[type="checkbox"] { width: auto; margin-right: 6px; }

/* Rich text toolbar */
.richtext-toolbar {
    display: flex; flex-wrap: wrap; gap: 2px;
    padding: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
}
.richtext-toolbar button {
    padding: 4px 8px;
    border: none; border-radius: 3px;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
}
.richtext-toolbar button:hover { background: var(--bg-hover); }
.richtext-area {
    min-height: 100px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    outline: none;
}

/* Mobile overrides section */
.mobile-section {
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 8px;
}
.mobile-section .section-title { color: var(--warning); }

/* Buttons */
.btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}
.btn-danger {
    border-color: var(--danger);
    color: var(--danger);
}
.btn-danger:hover { background: rgba(243,139,168,0.15); }

/* Status */
#status-bar {
    font-size: 11px;
    color: var(--text-muted);
    padding: 4px 0;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
Loading