Loading src/edit.cpp +53 −4 Changes for src/edit.cpp: 53 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -1003,10 +1003,37 @@ void blogi::webedit::WebEditor::JsonApi(const int tid, json_object *request, jso } if (target_uuid) { // TODO: Implement indent. Remove from current sibling list, // append as last child of the previous sibling. NodeContext ctx = findNodeContext(target_uuid); if (ctx.node && ctx.prev && ctx.prev->canHaveChildren()) { // 1. Unlink node from current sibling chain // ctx.prev->nextEl currently points to ctx.node EditPlugin *nodeNext = const_cast<EditPlugin*>(ctx.node->nextElement()); ctx.prev->setNextEl(nodeNext); // 2. Append node as last child of ctx.prev EditPlugin *lastChild = const_cast<EditPlugin*>(ctx.prev->getChildElement()); if (!lastChild) { ctx.prev->setChildEl(ctx.node); } else { while (lastChild->nextElement()) { lastChild = const_cast<EditPlugin*>(lastChild->nextElement()); } lastChild->setNextEl(ctx.node); } ctx.node->setNextEl(nullptr); // Now last child json_object_object_add(single_response, "status", json_object_new_string("success")); json_object_object_add(single_response, "message", json_object_new_string("Element indented.")); } else if (ctx.node && !ctx.prev) { json_object_object_add(single_response, "status", json_object_new_string("error")); json_object_object_add(single_response, "message", json_object_new_string("No previous sibling to indent into.")); } else if (ctx.node && ctx.prev && !ctx.prev->canHaveChildren()) { json_object_object_add(single_response, "status", json_object_new_string("error")); json_object_object_add(single_response, "message", json_object_new_string("Previous sibling cannot have children.")); } else { json_object_object_add(single_response, "status", json_object_new_string("error")); json_object_object_add(single_response, "message", json_object_new_string("Element not found.")); } handled = true; } else { json_object_object_add(single_response, "status", json_object_new_string("error")); Loading @@ -1024,10 +1051,32 @@ void blogi::webedit::WebEditor::JsonApi(const int tid, json_object *request, jso } if (target_uuid) { // TODO: Implement outdent. Remove from parent's children, // insert as next sibling of the parent element. NodeContext ctx = findNodeContext(target_uuid); if (ctx.node && !ctx.isTopLevel && ctx.parent) { // 1. Unlink node from parent's child chain EditPlugin *nodeNext = const_cast<EditPlugin*>(ctx.node->nextElement()); if (ctx.prev) { // Not first child — previous sibling skips over this node ctx.prev->setNextEl(nodeNext); } else { // First child — parent now points to next sibling (or nullptr) ctx.parent->setChildEl(nodeNext); } // 2. Insert node as next sibling of parent EditPlugin *parentNext = const_cast<EditPlugin*>(ctx.parent->nextElement()); ctx.parent->setNextEl(ctx.node); ctx.node->setNextEl(parentNext); json_object_object_add(single_response, "status", json_object_new_string("success")); json_object_object_add(single_response, "message", json_object_new_string("Element outdented.")); } else if (ctx.node && ctx.isTopLevel) { json_object_object_add(single_response, "status", json_object_new_string("error")); json_object_object_add(single_response, "message", json_object_new_string("Element is already at the top level.")); } else { json_object_object_add(single_response, "status", json_object_new_string("error")); json_object_object_add(single_response, "message", json_object_new_string("Element not found.")); } handled = true; } else { json_object_object_add(single_response, "status", json_object_new_string("error")); Loading Loading
src/edit.cpp +53 −4 Changes for src/edit.cpp: 53 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -1003,10 +1003,37 @@ void blogi::webedit::WebEditor::JsonApi(const int tid, json_object *request, jso } if (target_uuid) { // TODO: Implement indent. Remove from current sibling list, // append as last child of the previous sibling. NodeContext ctx = findNodeContext(target_uuid); if (ctx.node && ctx.prev && ctx.prev->canHaveChildren()) { // 1. Unlink node from current sibling chain // ctx.prev->nextEl currently points to ctx.node EditPlugin *nodeNext = const_cast<EditPlugin*>(ctx.node->nextElement()); ctx.prev->setNextEl(nodeNext); // 2. Append node as last child of ctx.prev EditPlugin *lastChild = const_cast<EditPlugin*>(ctx.prev->getChildElement()); if (!lastChild) { ctx.prev->setChildEl(ctx.node); } else { while (lastChild->nextElement()) { lastChild = const_cast<EditPlugin*>(lastChild->nextElement()); } lastChild->setNextEl(ctx.node); } ctx.node->setNextEl(nullptr); // Now last child json_object_object_add(single_response, "status", json_object_new_string("success")); json_object_object_add(single_response, "message", json_object_new_string("Element indented.")); } else if (ctx.node && !ctx.prev) { json_object_object_add(single_response, "status", json_object_new_string("error")); json_object_object_add(single_response, "message", json_object_new_string("No previous sibling to indent into.")); } else if (ctx.node && ctx.prev && !ctx.prev->canHaveChildren()) { json_object_object_add(single_response, "status", json_object_new_string("error")); json_object_object_add(single_response, "message", json_object_new_string("Previous sibling cannot have children.")); } else { json_object_object_add(single_response, "status", json_object_new_string("error")); json_object_object_add(single_response, "message", json_object_new_string("Element not found.")); } handled = true; } else { json_object_object_add(single_response, "status", json_object_new_string("error")); Loading @@ -1024,10 +1051,32 @@ void blogi::webedit::WebEditor::JsonApi(const int tid, json_object *request, jso } if (target_uuid) { // TODO: Implement outdent. Remove from parent's children, // insert as next sibling of the parent element. NodeContext ctx = findNodeContext(target_uuid); if (ctx.node && !ctx.isTopLevel && ctx.parent) { // 1. Unlink node from parent's child chain EditPlugin *nodeNext = const_cast<EditPlugin*>(ctx.node->nextElement()); if (ctx.prev) { // Not first child — previous sibling skips over this node ctx.prev->setNextEl(nodeNext); } else { // First child — parent now points to next sibling (or nullptr) ctx.parent->setChildEl(nodeNext); } // 2. Insert node as next sibling of parent EditPlugin *parentNext = const_cast<EditPlugin*>(ctx.parent->nextElement()); ctx.parent->setNextEl(ctx.node); ctx.node->setNextEl(parentNext); json_object_object_add(single_response, "status", json_object_new_string("success")); json_object_object_add(single_response, "message", json_object_new_string("Element outdented.")); } else if (ctx.node && ctx.isTopLevel) { json_object_object_add(single_response, "status", json_object_new_string("error")); json_object_object_add(single_response, "message", json_object_new_string("Element is already at the top level.")); } else { json_object_object_add(single_response, "status", json_object_new_string("error")); json_object_object_add(single_response, "message", json_object_new_string("Element not found.")); } handled = true; } else { json_object_object_add(single_response, "status", json_object_new_string("error")); Loading