| 8 | }; |
| 9 | |
| 10 | const groupBlockContent = (blockMap: BlockMapType): string[][] => { |
| 11 | const output: string[][] = []; |
| 12 | |
| 13 | let lastType: string | undefined = undefined; |
| 14 | let index = -1; |
| 15 | |
| 16 | Object.keys(blockMap).forEach(id => { |
| 17 | blockMap[id].value.content?.forEach(blockId => { |
| 18 | const blockType = blockMap[blockId]?.value?.type; |
| 19 | |
| 20 | if (blockType && blockType !== lastType) { |
| 21 | index++; |
| 22 | lastType = blockType; |
| 23 | output[index] = []; |
| 24 | } |
| 25 | |
| 26 | output[index].push(blockId); |
| 27 | }); |
| 28 | |
| 29 | lastType = undefined; |
| 30 | }); |
| 31 | |
| 32 | return output; |
| 33 | }; |
| 34 | |
| 35 | export const getListNumber = (blockId: string, blockMap: BlockMapType) => { |
| 36 | const groups = groupBlockContent(blockMap); |