@max1874/feishu 0.2.9 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/docx.ts +13 -2
package/package.json
CHANGED
package/src/docx.ts
CHANGED
|
@@ -207,14 +207,25 @@ async function insertBlocks(
|
|
|
207
207
|
const BATCH_SIZE = 50;
|
|
208
208
|
const allChildren: any[] = [];
|
|
209
209
|
|
|
210
|
+
// Get current children count to determine insert index
|
|
211
|
+
let insertIndex = 0;
|
|
212
|
+
const existing = await client.docx.documentBlockChildren.get({
|
|
213
|
+
path: { document_id: docToken, block_id: blockId },
|
|
214
|
+
});
|
|
215
|
+
if (existing.code === 0) {
|
|
216
|
+
insertIndex = existing.data?.items?.length ?? 0;
|
|
217
|
+
}
|
|
218
|
+
|
|
210
219
|
for (let i = 0; i < cleaned.length; i += BATCH_SIZE) {
|
|
211
220
|
const batch = cleaned.slice(i, i + BATCH_SIZE);
|
|
212
221
|
const res = await client.docx.documentBlockChildren.create({
|
|
213
222
|
path: { document_id: docToken, block_id: blockId },
|
|
214
|
-
data: { children: batch },
|
|
223
|
+
data: { children: batch, index: insertIndex },
|
|
215
224
|
});
|
|
216
225
|
if (res.code !== 0) throw new Error(res.msg);
|
|
217
|
-
|
|
226
|
+
const inserted = res.data?.children ?? [];
|
|
227
|
+
allChildren.push(...inserted);
|
|
228
|
+
insertIndex += inserted.length;
|
|
218
229
|
}
|
|
219
230
|
|
|
220
231
|
return { children: allChildren, skipped };
|