n8n-nodes-notion-advanced 1.2.23-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: Clean up any remaining HTML tags
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 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-notion-advanced",
3
- "version": "1.2.23-beta",
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": [