mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-20 15:09:40 +00:00
fix
This commit is contained in:
@@ -81,23 +81,41 @@ export async function getPageWithRetry(id, from, retryAttempts = 3) {
|
|||||||
function filterPostBlocks(id, blockMap, slice) {
|
function filterPostBlocks(id, blockMap, slice) {
|
||||||
const clonePageBlock = deepClone(blockMap)
|
const clonePageBlock = deepClone(blockMap)
|
||||||
let count = 0
|
let count = 0
|
||||||
|
const blocksToProcess = Object.keys(clonePageBlock?.block || {})
|
||||||
|
|
||||||
// 循环遍历文档的每个block
|
// 循环遍历文档的每个block
|
||||||
for (const i in clonePageBlock?.block) {
|
for (const i in clonePageBlock?.block) {
|
||||||
const b = clonePageBlock?.block[i]
|
for (let i = 0; i < blocksToProcess.length; i++) {
|
||||||
|
const blockId = blocksToProcess[i]
|
||||||
|
const b = clonePageBlock?.block[blockId]
|
||||||
|
|
||||||
if (slice && slice > 0 && count > slice) {
|
if (slice && slice > 0 && count > slice) {
|
||||||
delete clonePageBlock?.block[i]
|
delete clonePageBlock?.block[blockId]
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// 当BlockId等于PageId时移除
|
|
||||||
if (b?.value?.id === id) {
|
if (b?.value?.id === id) {
|
||||||
// 此block含有敏感信息
|
|
||||||
delete b?.value?.properties
|
delete b?.value?.properties
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
count++
|
count++
|
||||||
// 处理 c++、c#、汇编等语言名字映射
|
|
||||||
|
if (b?.value?.type === 'sync_block' && b?.value?.children) {
|
||||||
|
const childBlocks = b.value.children
|
||||||
|
// Remove the sync block
|
||||||
|
delete clonePageBlock.block[blockId]
|
||||||
|
// Insert child blocks in place of the sync block
|
||||||
|
childBlocks.forEach((childBlock, index) => {
|
||||||
|
const newBlockId = `${blockId}_child_${index}`
|
||||||
|
clonePageBlock.block[newBlockId] = childBlock
|
||||||
|
blocksToProcess.splice(i + index + 1, 0, newBlockId)
|
||||||
|
})
|
||||||
|
// Adjust the loop counter to process the newly inserted blocks
|
||||||
|
i--
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if (b?.value?.type === 'code') {
|
if (b?.value?.type === 'code') {
|
||||||
if (b?.value?.properties?.language?.[0][0] === 'C++') {
|
if (b?.value?.properties?.language?.[0][0] === 'C++') {
|
||||||
b.value.properties.language[0][0] = 'cpp'
|
b.value.properties.language[0][0] = 'cpp'
|
||||||
@@ -109,8 +127,7 @@ function filterPostBlocks(id, blockMap, slice) {
|
|||||||
b.value.properties.language[0][0] = 'asm6502'
|
b.value.properties.language[0][0] = 'asm6502'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果是文件,或嵌入式PDF,需要重新加密签名
|
|
||||||
if (
|
if (
|
||||||
(b?.value?.type === 'file' ||
|
(b?.value?.type === 'file' ||
|
||||||
b?.value?.type === 'pdf' ||
|
b?.value?.type === 'pdf' ||
|
||||||
@@ -123,16 +140,6 @@ function filterPostBlocks(id, blockMap, slice) {
|
|||||||
const newUrl = `https://notion.so/signed/${encodeURIComponent(oldUrl)}?table=block&id=${b?.value?.id}`
|
const newUrl = `https://notion.so/signed/${encodeURIComponent(oldUrl)}?table=block&id=${b?.value?.id}`
|
||||||
b.value.properties.source[0][0] = newUrl
|
b.value.properties.source[0][0] = newUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b?.value?.type === 'synced_block' && b?.value?.properties?.children) {
|
|
||||||
const childBlocks = b.value.properties.children;
|
|
||||||
delete clonePageBlock.block[blockId];
|
|
||||||
// Insert child blocks at the sync block's position
|
|
||||||
blockIds.splice(i + 1, 0, ...childBlocks);
|
|
||||||
// Adjust the loop counter to process the newly inserted blocks
|
|
||||||
i--;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 去掉不用的字段
|
// 去掉不用的字段
|
||||||
|
|||||||
Reference in New Issue
Block a user