n8n-nodes-notion-advanced 1.2.23-beta → 1.2.25-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;
@@ -486,7 +486,17 @@ class NotionAITool {
486
486
  const xmlTagPatterns = [
487
487
  /<[^>]+>/, // Any XML/HTML tag
488
488
  /&lt;[^&]+&gt;/, // HTML-encoded tags
489
+ // Comprehensive list of all supported XML tags
489
490
  /<(h[1-6]|p|ul|ol|li|strong|em|b|i|code|blockquote|callout|todo|image|embed|bookmark|equation|toggle|divider|quote|pre)\b[^>]*>/i,
491
+ // Self-closing tags
492
+ /<(image|divider|br)\s[^>]*\/>/i,
493
+ // Specific tag patterns that should be processed hierarchically
494
+ /<callout\s*(?:type="[^"]*")?\s*>/i,
495
+ /<code\s*(?:language="[^"]*")?\s*>/i,
496
+ /<todo\s*(?:checked="[^"]*")?\s*>/i,
497
+ /<image\s+src="[^"]*"[^>]*>/i,
498
+ // Closing tags
499
+ /<\/(h[1-6]|p|ul|ol|li|strong|em|b|i|code|blockquote|callout|todo|image|embed|bookmark|equation|toggle|divider|quote|pre)>/i,
490
500
  ];
491
501
  const hasXmlTags = xmlTagPatterns.some(pattern => pattern.test(trimmedLine));
492
502
  if (hasXmlTags) {
@@ -1157,7 +1167,9 @@ class NotionAITool {
1157
1167
  const replacements = NotionAITool.processXMLTreeDepthFirst(xmlTree, blocks, counterRef);
1158
1168
  // Step 3: Apply hierarchical replacements to content
1159
1169
  processedContent = NotionAITool.applyHierarchicalReplacements(processedContent, xmlTree, replacements);
1160
- // Step 4: Clean up any remaining HTML tags
1170
+ // Step 4: Immediately replace all placeholders with empty strings since blocks are already in blocks array
1171
+ processedContent = NotionAITool.cleanupAllPlaceholders(processedContent);
1172
+ // Step 5: Clean up any remaining HTML tags
1161
1173
  processedContent = NotionAITool.cleanupRemainingHtml(processedContent);
1162
1174
  if (DEBUG_ORDERING) {
1163
1175
  console.log(`Processed ${xmlTree.length} root XML nodes hierarchically, created ${blocks.length} blocks`);
@@ -1210,6 +1222,55 @@ class NotionAITool {
1210
1222
  }
1211
1223
  return processedContent;
1212
1224
  }
1225
+ // Helper function to immediately clean up all placeholders after hierarchical processing
1226
+ static cleanupAllPlaceholders(content) {
1227
+ let cleaned = content;
1228
+ // Since blocks have already been added to the blocks array during hierarchical processing,
1229
+ // we can safely remove all placeholders immediately to prevent partial replacement issues
1230
+ // Primary sequential placeholder patterns: __BLOCK_N__
1231
+ const sequentialPatterns = [
1232
+ /__BLOCK_\d+__/g, // Standard format: __BLOCK_1__, __BLOCK_2__, etc.
1233
+ /\b__BLOCK_\d+__\b/g, // Word boundary version
1234
+ /__BL\w*_\d+__/g, // Partial matches like __BL..._N__
1235
+ /\b\w*OCK\d+_\b/g, // Catch patterns like "OCK23_"
1236
+ /\b\w*CK\d+_\b/g, // Catch patterns like "CK23_"
1237
+ /\b\w*K\d+_\b/g, // Catch patterns like "K23_"
1238
+ /\b\d+__\b/g, // Remnants like "23__"
1239
+ /__\d+__/g, // Alternative format: __1__, __2__, etc.
1240
+ /__\w*\d+_*/g, // Any underscore-digit patterns
1241
+ /\b[A-Z]*OCK\d+_*\b/g, // Case variations of OCK patterns
1242
+ ];
1243
+ // Apply all sequential cleanup patterns
1244
+ sequentialPatterns.forEach(pattern => {
1245
+ cleaned = cleaned.replace(pattern, '');
1246
+ });
1247
+ // Legacy UUID-based placeholder cleanup (for backwards compatibility)
1248
+ const legacyPatterns = [
1249
+ /__XML_[a-f0-9]{8}_\d+__/g, // Standard format: __XML_abc12345_1__
1250
+ /\b[A-Z]{2}[a-z0-9]{8,12}_+\b/g, // Variations like "MLb82d670450__"
1251
+ /\b[A-Za-z]{2,4}[a-f0-9]{6,12}_+\b/g, // More flexible pattern matching
1252
+ /_[a-f0-9]{8,12}_\d+_*/g, // Underscore variations
1253
+ /[a-f0-9]{8,12}_\d+__/g, // Without prefix
1254
+ ];
1255
+ // Apply legacy cleanup patterns
1256
+ legacyPatterns.forEach(pattern => {
1257
+ cleaned = cleaned.replace(pattern, '');
1258
+ });
1259
+ // Additional aggressive patterns to catch any partial remnants
1260
+ const aggressivePatterns = [
1261
+ /\b[A-Z]{1,4}\d{1,3}_+\b/g, // Patterns like "OCK23_", "CK23_", "K23_"
1262
+ /\b[A-Za-z]{1,6}\d{1,4}_+\b/g, // More general partial patterns
1263
+ /_{2,}\d+_{0,2}/g, // Multiple underscores with digits
1264
+ /__+[A-Za-z]*\d+_*/g, // Underscore patterns with letters and digits
1265
+ ];
1266
+ // Apply aggressive cleanup patterns as final pass
1267
+ aggressivePatterns.forEach(pattern => {
1268
+ cleaned = cleaned.replace(pattern, '');
1269
+ });
1270
+ // Remove any double spaces created by removals
1271
+ cleaned = cleaned.replace(/\s{2,}/g, ' ').trim();
1272
+ return cleaned;
1273
+ }
1213
1274
  // Helper function to decode HTML entities
1214
1275
  static decodeHtmlEntities(content) {
1215
1276
  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.25-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": [