n8n-nodes-notion-advanced 1.2.22-beta → 1.2.24-beta
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.
@@ -49,6 +49,7 @@ export declare class NotionAITool implements INodeType {
|
|
49
49
|
static applyHierarchicalReplacements(content: string, nodes: XMLNode[], replacements: Map<string, string>): string;
|
50
50
|
static getAllNodesFromTree(nodes: XMLNode[]): XMLNode[];
|
51
51
|
static processXmlTags(content: string, blocks: IDataObject[]): string;
|
52
|
+
static cleanupAllPlaceholders(content: string): string;
|
52
53
|
static decodeHtmlEntities(content: string): string;
|
53
54
|
static cleanupRemainingHtml(content: string, placeholderPrefix?: string): string;
|
54
55
|
static processNestedHtmlInListItem(content: string): string;
|
@@ -1157,7 +1157,9 @@ class NotionAITool {
|
|
1157
1157
|
const replacements = NotionAITool.processXMLTreeDepthFirst(xmlTree, blocks, counterRef);
|
1158
1158
|
// Step 3: Apply hierarchical replacements to content
|
1159
1159
|
processedContent = NotionAITool.applyHierarchicalReplacements(processedContent, xmlTree, replacements);
|
1160
|
-
// Step 4:
|
1160
|
+
// Step 4: Immediately replace all placeholders with empty strings since blocks are already in blocks array
|
1161
|
+
processedContent = NotionAITool.cleanupAllPlaceholders(processedContent);
|
1162
|
+
// Step 5: Clean up any remaining HTML tags
|
1161
1163
|
processedContent = NotionAITool.cleanupRemainingHtml(processedContent);
|
1162
1164
|
if (DEBUG_ORDERING) {
|
1163
1165
|
console.log(`Processed ${xmlTree.length} root XML nodes hierarchically, created ${blocks.length} blocks`);
|
@@ -1210,6 +1212,55 @@ class NotionAITool {
|
|
1210
1212
|
}
|
1211
1213
|
return processedContent;
|
1212
1214
|
}
|
1215
|
+
// Helper function to immediately clean up all placeholders after hierarchical processing
|
1216
|
+
static cleanupAllPlaceholders(content) {
|
1217
|
+
let cleaned = content;
|
1218
|
+
// Since blocks have already been added to the blocks array during hierarchical processing,
|
1219
|
+
// we can safely remove all placeholders immediately to prevent partial replacement issues
|
1220
|
+
// Primary sequential placeholder patterns: __BLOCK_N__
|
1221
|
+
const sequentialPatterns = [
|
1222
|
+
/__BLOCK_\d+__/g, // Standard format: __BLOCK_1__, __BLOCK_2__, etc.
|
1223
|
+
/\b__BLOCK_\d+__\b/g, // Word boundary version
|
1224
|
+
/__BL\w*_\d+__/g, // Partial matches like __BL..._N__
|
1225
|
+
/\b\w*OCK\d+_\b/g, // Catch patterns like "OCK23_"
|
1226
|
+
/\b\w*CK\d+_\b/g, // Catch patterns like "CK23_"
|
1227
|
+
/\b\w*K\d+_\b/g, // Catch patterns like "K23_"
|
1228
|
+
/\b\d+__\b/g, // Remnants like "23__"
|
1229
|
+
/__\d+__/g, // Alternative format: __1__, __2__, etc.
|
1230
|
+
/__\w*\d+_*/g, // Any underscore-digit patterns
|
1231
|
+
/\b[A-Z]*OCK\d+_*\b/g, // Case variations of OCK patterns
|
1232
|
+
];
|
1233
|
+
// Apply all sequential cleanup patterns
|
1234
|
+
sequentialPatterns.forEach(pattern => {
|
1235
|
+
cleaned = cleaned.replace(pattern, '');
|
1236
|
+
});
|
1237
|
+
// Legacy UUID-based placeholder cleanup (for backwards compatibility)
|
1238
|
+
const legacyPatterns = [
|
1239
|
+
/__XML_[a-f0-9]{8}_\d+__/g, // Standard format: __XML_abc12345_1__
|
1240
|
+
/\b[A-Z]{2}[a-z0-9]{8,12}_+\b/g, // Variations like "MLb82d670450__"
|
1241
|
+
/\b[A-Za-z]{2,4}[a-f0-9]{6,12}_+\b/g, // More flexible pattern matching
|
1242
|
+
/_[a-f0-9]{8,12}_\d+_*/g, // Underscore variations
|
1243
|
+
/[a-f0-9]{8,12}_\d+__/g, // Without prefix
|
1244
|
+
];
|
1245
|
+
// Apply legacy cleanup patterns
|
1246
|
+
legacyPatterns.forEach(pattern => {
|
1247
|
+
cleaned = cleaned.replace(pattern, '');
|
1248
|
+
});
|
1249
|
+
// Additional aggressive patterns to catch any partial remnants
|
1250
|
+
const aggressivePatterns = [
|
1251
|
+
/\b[A-Z]{1,4}\d{1,3}_+\b/g, // Patterns like "OCK23_", "CK23_", "K23_"
|
1252
|
+
/\b[A-Za-z]{1,6}\d{1,4}_+\b/g, // More general partial patterns
|
1253
|
+
/_{2,}\d+_{0,2}/g, // Multiple underscores with digits
|
1254
|
+
/__+[A-Za-z]*\d+_*/g, // Underscore patterns with letters and digits
|
1255
|
+
];
|
1256
|
+
// Apply aggressive cleanup patterns as final pass
|
1257
|
+
aggressivePatterns.forEach(pattern => {
|
1258
|
+
cleaned = cleaned.replace(pattern, '');
|
1259
|
+
});
|
1260
|
+
// Remove any double spaces created by removals
|
1261
|
+
cleaned = cleaned.replace(/\s{2,}/g, ' ').trim();
|
1262
|
+
return cleaned;
|
1263
|
+
}
|
1213
1264
|
// Helper function to decode HTML entities
|
1214
1265
|
static decodeHtmlEntities(content) {
|
1215
1266
|
const entityMap = {
|
@@ -1227,37 +1278,37 @@ class NotionAITool {
|
|
1227
1278
|
});
|
1228
1279
|
return decoded;
|
1229
1280
|
}
|
1230
|
-
// Cleanup function to remove remaining HTML tags and
|
1281
|
+
// Cleanup function to remove remaining HTML tags and placeholder artifacts
|
1231
1282
|
static cleanupRemainingHtml(content, placeholderPrefix) {
|
1232
1283
|
let cleaned = content;
|
1233
|
-
//
|
1284
|
+
// Clean up sequential placeholder format: __BLOCK_N__
|
1285
|
+
const sequentialPlaceholderPatterns = [
|
1286
|
+
/__BLOCK_\d+__/g, // Standard format: __BLOCK_1__, __BLOCK_2__, etc.
|
1287
|
+
/\b\d+__\b/g, // Remnants like "7__"
|
1288
|
+
/__\d+__/g, // Alternative format: __1__, __2__, etc.
|
1289
|
+
];
|
1290
|
+
sequentialPlaceholderPatterns.forEach(pattern => {
|
1291
|
+
cleaned = cleaned.replace(pattern, '');
|
1292
|
+
});
|
1293
|
+
// Legacy placeholder cleanup (for backwards compatibility)
|
1234
1294
|
if (placeholderPrefix) {
|
1235
|
-
// Clean up our specific placeholder format: __XML_{uuid8}_{number}__
|
1236
1295
|
const escapedPrefix = placeholderPrefix.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
1237
1296
|
const placeholderPattern = new RegExp(`${escapedPrefix}\\d+__`, 'g');
|
1238
1297
|
cleaned = cleaned.replace(placeholderPattern, '');
|
1239
1298
|
}
|
1240
|
-
//
|
1241
|
-
const
|
1299
|
+
// Clean up old UUID-based placeholders (for backwards compatibility)
|
1300
|
+
const legacyPlaceholderPatterns = [
|
1242
1301
|
/__XML_[a-f0-9]{8}_\d+__/g, // Standard format: __XML_abc12345_1__
|
1243
1302
|
/\b[A-Z]{2}[a-z0-9]{8,12}_+\b/g, // Variations like "MLb82d670450__"
|
1244
1303
|
/\b[A-Za-z]{2,4}[a-f0-9]{6,12}_+\b/g, // More flexible pattern matching
|
1245
1304
|
/_[a-f0-9]{8,12}_\d+_*/g, // Underscore variations
|
1246
1305
|
/[a-f0-9]{8,12}_\d+__/g, // Without prefix
|
1247
1306
|
];
|
1248
|
-
|
1249
|
-
cleaned = cleaned.replace(pattern, '');
|
1250
|
-
});
|
1251
|
-
// Remove entire lines containing XML content to prevent double processing
|
1252
|
-
const xmlContentLines = [
|
1253
|
-
/^.*<[^>]+>.*$/gm, // Any line with XML/HTML tags
|
1254
|
-
/^.*<[^&]+>.*$/gm, // HTML-encoded tags
|
1255
|
-
/^.*<(h[1-6]|p|ul|ol|li|strong|em|b|i|code|blockquote|callout|todo|image|embed|bookmark|equation|toggle|divider|quote|pre)\b[^>]*>.*$/gim, // Specific XML content
|
1256
|
-
];
|
1257
|
-
xmlContentLines.forEach(pattern => {
|
1307
|
+
legacyPlaceholderPatterns.forEach(pattern => {
|
1258
1308
|
cleaned = cleaned.replace(pattern, '');
|
1259
1309
|
});
|
1260
|
-
// Remove common HTML tags that might be left behind
|
1310
|
+
// Remove common HTML tags that might be left behind AFTER processing
|
1311
|
+
// Note: We don't remove entire lines here - only clean up leftover tags
|
1261
1312
|
const htmlTagsToRemove = [
|
1262
1313
|
/<\/?ul\s*[^>]*>/gi,
|
1263
1314
|
/<\/?ol\s*[^>]*>/gi,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "n8n-nodes-notion-advanced",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.24-beta",
|
4
4
|
"description": "Advanced n8n Notion nodes: Full-featured workflow node + AI Agent Tool for intelligent Notion automation with 25+ block types (BETA)",
|
5
5
|
"scripts": {},
|
6
6
|
"files": [
|