创建超级块

创建超级块

// layout的值 "col" | "row"
// id id或自动生成
// attrHTML dom
function genSBElement(layout, id, attrHTML) {
    const sbElement = document.createElement("div");
    sbElement.setAttribute("data-node-id", id || Lute.NewNodeID());
    sbElement.setAttribute("data-type", "NodeSuperBlock");
    sbElement.setAttribute("class", "sb");
    sbElement.setAttribute("data-sb-layout", layout);
    sbElement.innerHTML = attrHTML || `<div class="protyle-attr" contenteditable="false">${'\u200b'}</div>`;
    return sbElement;
}
// 使用示例
genSBElement('col');

创建超级块并移入指定的块

function createSBBlockAndMoveBlocks(layout, subBlocks = []) {
    genSBElement(layout);
    if(subBlocks.length > 0) {
      
    }
}

image.png

留下你的脚步
推荐阅读