n8n-nodes-notion-advanced 1.2.0-beta → 1.2.2-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.
@@ -10,6 +10,7 @@ export declare class NotionAITool implements INodeType {
|
|
10
10
|
static queryDatabase(executeFunctions: IExecuteFunctions, itemIndex: number): Promise<IDataObject>;
|
11
11
|
static parseContentToBlocks(content: string): IDataObject[];
|
12
12
|
static processXmlTags(content: string, blocks: IDataObject[]): string;
|
13
|
+
static cleanupRemainingHtml(content: string): string;
|
13
14
|
static getCalloutEmoji(type: string): string;
|
14
15
|
static getCalloutColor(type: string): string;
|
15
16
|
static parseBasicMarkdown(text: string): IDataObject[];
|
@@ -815,6 +815,140 @@ class NotionAITool {
|
|
815
815
|
return `__XML_BLOCK_${blockCounter++}__`;
|
816
816
|
}
|
817
817
|
},
|
818
|
+
// Paragraphs: <p>content</p>
|
819
|
+
{
|
820
|
+
regex: /<p>(.*?)<\/p>/gis,
|
821
|
+
processor: (match, content) => {
|
822
|
+
blocks.push({
|
823
|
+
type: 'paragraph',
|
824
|
+
paragraph: {
|
825
|
+
rich_text: NotionAITool.parseBasicMarkdown(content.trim()),
|
826
|
+
},
|
827
|
+
});
|
828
|
+
return `__XML_BLOCK_${blockCounter++}__`;
|
829
|
+
}
|
830
|
+
},
|
831
|
+
// Process complete bulleted lists first: <ul><li>item</li></ul>
|
832
|
+
{
|
833
|
+
regex: /<ul\s*[^>]*>(.*?)<\/ul>/gis,
|
834
|
+
processor: (match, listContent) => {
|
835
|
+
// Extract individual list items and process them
|
836
|
+
const items = listContent.match(/<li\s*[^>]*>(.*?)<\/li>/gis) || [];
|
837
|
+
items.forEach(item => {
|
838
|
+
const itemContent = item.replace(/<\/?li[^>]*>/gi, '').trim();
|
839
|
+
if (itemContent) {
|
840
|
+
blocks.push({
|
841
|
+
type: 'bulleted_list_item',
|
842
|
+
bulleted_list_item: {
|
843
|
+
rich_text: NotionAITool.parseBasicMarkdown(itemContent),
|
844
|
+
},
|
845
|
+
});
|
846
|
+
}
|
847
|
+
});
|
848
|
+
return `__XML_BLOCK_${blockCounter++}__`;
|
849
|
+
}
|
850
|
+
},
|
851
|
+
// Process complete numbered lists first: <ol><li>item</li></ol>
|
852
|
+
{
|
853
|
+
regex: /<ol\s*[^>]*>(.*?)<\/ol>/gis,
|
854
|
+
processor: (match, listContent) => {
|
855
|
+
// Extract individual list items and process them
|
856
|
+
const items = listContent.match(/<li\s*[^>]*>(.*?)<\/li>/gis) || [];
|
857
|
+
items.forEach(item => {
|
858
|
+
const itemContent = item.replace(/<\/?li[^>]*>/gi, '').trim();
|
859
|
+
if (itemContent) {
|
860
|
+
blocks.push({
|
861
|
+
type: 'numbered_list_item',
|
862
|
+
numbered_list_item: {
|
863
|
+
rich_text: NotionAITool.parseBasicMarkdown(itemContent),
|
864
|
+
},
|
865
|
+
});
|
866
|
+
}
|
867
|
+
});
|
868
|
+
return `__XML_BLOCK_${blockCounter++}__`;
|
869
|
+
}
|
870
|
+
},
|
871
|
+
// Blockquotes: <blockquote>content</blockquote>
|
872
|
+
{
|
873
|
+
regex: /<blockquote>(.*?)<\/blockquote>/gis,
|
874
|
+
processor: (match, content) => {
|
875
|
+
blocks.push({
|
876
|
+
type: 'quote',
|
877
|
+
quote: {
|
878
|
+
rich_text: NotionAITool.parseBasicMarkdown(content.trim()),
|
879
|
+
},
|
880
|
+
});
|
881
|
+
return `__XML_BLOCK_${blockCounter++}__`;
|
882
|
+
}
|
883
|
+
},
|
884
|
+
// Preformatted text: <pre>content</pre>
|
885
|
+
{
|
886
|
+
regex: /<pre>(.*?)<\/pre>/gis,
|
887
|
+
processor: (match, content) => {
|
888
|
+
blocks.push({
|
889
|
+
type: 'code',
|
890
|
+
code: {
|
891
|
+
rich_text: [(0, NotionUtils_1.createRichText)(content.trim())],
|
892
|
+
language: 'plain_text',
|
893
|
+
},
|
894
|
+
});
|
895
|
+
return `__XML_BLOCK_${blockCounter++}__`;
|
896
|
+
}
|
897
|
+
},
|
898
|
+
// Standalone list items (only if not already processed in lists): <li>content</li>
|
899
|
+
{
|
900
|
+
regex: /<li\s*[^>]*>(.*?)<\/li>/gis,
|
901
|
+
processor: (match, content) => {
|
902
|
+
if (content.trim()) {
|
903
|
+
blocks.push({
|
904
|
+
type: 'bulleted_list_item',
|
905
|
+
bulleted_list_item: {
|
906
|
+
rich_text: NotionAITool.parseBasicMarkdown(content.trim()),
|
907
|
+
},
|
908
|
+
});
|
909
|
+
}
|
910
|
+
return `__XML_BLOCK_${blockCounter++}__`;
|
911
|
+
}
|
912
|
+
},
|
913
|
+
// Strong/Bold: <strong>content</strong> or <b>content</b> (only as standalone)
|
914
|
+
{
|
915
|
+
regex: /(?:^|>|\s)<(strong|b)>(.*?)<\/(strong|b)>(?=<|$|\s)/gis,
|
916
|
+
processor: (match, tag, content) => {
|
917
|
+
blocks.push({
|
918
|
+
type: 'paragraph',
|
919
|
+
paragraph: {
|
920
|
+
rich_text: NotionAITool.parseBasicMarkdown(`**${content.trim()}**`),
|
921
|
+
},
|
922
|
+
});
|
923
|
+
return `__XML_BLOCK_${blockCounter++}__`;
|
924
|
+
}
|
925
|
+
},
|
926
|
+
// Emphasis/Italic: <em>content</em> or <i>content</i> (only as standalone)
|
927
|
+
{
|
928
|
+
regex: /(?:^|>|\s)<(em|i)>(.*?)<\/(em|i)>(?=<|$|\s)/gis,
|
929
|
+
processor: (match, tag, content) => {
|
930
|
+
blocks.push({
|
931
|
+
type: 'paragraph',
|
932
|
+
paragraph: {
|
933
|
+
rich_text: NotionAITool.parseBasicMarkdown(`*${content.trim()}*`),
|
934
|
+
},
|
935
|
+
});
|
936
|
+
return `__XML_BLOCK_${blockCounter++}__`;
|
937
|
+
}
|
938
|
+
},
|
939
|
+
// Line breaks: <br/> or <br>
|
940
|
+
{
|
941
|
+
regex: /<br\s*\/?>/gis,
|
942
|
+
processor: (match) => {
|
943
|
+
blocks.push({
|
944
|
+
type: 'paragraph',
|
945
|
+
paragraph: {
|
946
|
+
rich_text: [(0, NotionUtils_1.createRichText)('')],
|
947
|
+
},
|
948
|
+
});
|
949
|
+
return `__XML_BLOCK_${blockCounter++}__`;
|
950
|
+
}
|
951
|
+
},
|
818
952
|
];
|
819
953
|
// Process each tag type
|
820
954
|
tagProcessors.forEach(({ regex, processor }) => {
|
@@ -822,8 +956,35 @@ class NotionAITool {
|
|
822
956
|
return processor(match, group1 || '', group2 || '', group3 || '');
|
823
957
|
});
|
824
958
|
});
|
959
|
+
// Clean up any remaining HTML tags that weren't processed
|
960
|
+
processedContent = NotionAITool.cleanupRemainingHtml(processedContent);
|
825
961
|
return processedContent;
|
826
962
|
}
|
963
|
+
// Cleanup function to remove remaining HTML tags
|
964
|
+
static cleanupRemainingHtml(content) {
|
965
|
+
let cleaned = content;
|
966
|
+
// Remove common HTML tags that might be left behind
|
967
|
+
const htmlTagsToRemove = [
|
968
|
+
/<\/?ul\s*[^>]*>/gi,
|
969
|
+
/<\/?ol\s*[^>]*>/gi,
|
970
|
+
/<\/?li\s*[^>]*>/gi,
|
971
|
+
/<\/?strong\s*[^>]*>/gi,
|
972
|
+
/<\/?b\s*[^>]*>/gi,
|
973
|
+
/<\/?em\s*[^>]*>/gi,
|
974
|
+
/<\/?i\s*[^>]*>/gi,
|
975
|
+
/<\/?div\s*[^>]*>/gi,
|
976
|
+
/<\/?span\s*[^>]*>/gi,
|
977
|
+
/<br\s*\/?>/gi,
|
978
|
+
];
|
979
|
+
htmlTagsToRemove.forEach(regex => {
|
980
|
+
cleaned = cleaned.replace(regex, '');
|
981
|
+
});
|
982
|
+
// Remove empty lines created by tag removal
|
983
|
+
cleaned = cleaned.replace(/^\s*[\r\n]/gm, '');
|
984
|
+
// Remove multiple consecutive line breaks
|
985
|
+
cleaned = cleaned.replace(/\n{3,}/g, '\n\n');
|
986
|
+
return cleaned.trim();
|
987
|
+
}
|
827
988
|
// Helper function to get callout emoji based on type
|
828
989
|
static getCalloutEmoji(type) {
|
829
990
|
const emojiMap = {
|
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.2-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
|
"build": "echo 'Already built'",
|