block editor

This commit is contained in:
2023-10-14 18:06:36 +03:00
parent 9e37a7f730
commit 2e81d27ff6
21 changed files with 523 additions and 141 deletions
+25
View File
@@ -0,0 +1,25 @@
import {randomId} from "../../../helpers.js";
export function insertBlock(blockData, blockField, afterBlockId = null) {
if (!afterBlockId) {
return [{
meta: blockField,
id: randomId(),
value: null
}, ...blockData];
}
return blockData.reduce((carry, block) => {
carry.push(block)
if (block.id === afterBlockId) {
carry.push({
meta: blockField,
id: randomId(),
value: null
});
}
return carry;
}, []);
}