diff --git a/site/assets/images/plugins/remove-extra-spaces.dark.png b/site/assets/images/plugins/remove-extra-spaces.dark.png index 04f45ed08..6bcc7bbba 100644 Binary files a/site/assets/images/plugins/remove-extra-spaces.dark.png and b/site/assets/images/plugins/remove-extra-spaces.dark.png differ diff --git a/site/assets/images/plugins/remove-extra-spaces.png b/site/assets/images/plugins/remove-extra-spaces.png index fabfc9174..ead9ef325 100644 Binary files a/site/assets/images/plugins/remove-extra-spaces.png and b/site/assets/images/plugins/remove-extra-spaces.png differ diff --git a/site/pages/Docs/Plugin and Macros/Macros/Samples/Remove extra spaces/index.md b/site/pages/Docs/Plugin and Macros/Macros/Samples/Remove extra spaces/index.md index ba2bc067d..b04f2ddf6 100644 --- a/site/pages/Docs/Plugin and Macros/Macros/Samples/Remove extra spaces/index.md +++ b/site/pages/Docs/Plugin and Macros/Macros/Samples/Remove extra spaces/index.md @@ -13,31 +13,31 @@ Removes extra spaces in text document. ```ts (function() { - const oDocument = Api.GetDocument(); -const oRange = oDocument.GetRangeBySelect(); -const rawText = oRange.GetText(); -oRange.Delete(); - -// Split the original word into an array of paragraphs based on newline characters -const paragraphs = rawText.split('\n'); - -// Create an array to store cleaned paragraphs -const cleanedParagraphs = []; - -// Clean each paragraph and store it in the cleanedParagraphs array -for (const paragraph of paragraphs) { - // Use a regular expression to replace consecutive whitespaces with a single space - const cleanedParagraph = paragraph.replace(/\s+/g, ' '); - cleanedParagraphs.push(cleanedParagraph); -} - -// Join the cleaned paragraphs back together with newline characters -const cleanedText = cleanedParagraphs.join('\n'); - -// Insert the cleanedText with original paragraph structure -const oParagraph = Api.CreateParagraph(); -oParagraph.AddText(cleanedText); -oDocument.InsertContent([oParagraph], { "KeepTextOnly": true }); + const oDocument = Api.GetDocument(); + const oRange = oDocument.GetRangeBySelect(); + const rawText = oRange.GetText(); + oRange.Delete(); + + // Split the original word into an array of paragraphs based on newline characters + const paragraphs = rawText.split('\n'); + + // Create an array to store cleaned paragraphs + const cleanedParagraphs = []; + + // Clean each paragraph and store it in the cleanedParagraphs array + for (const paragraph of paragraphs) { + // Use a regular expression to replace consecutive whitespaces with a single space + const cleanedParagraph = paragraph.replace(/\s+/g, ' '); + cleanedParagraphs.push(cleanedParagraph); + } + + // Join the cleaned paragraphs with newline characters + const cleanedText = cleanedParagraphs.join('\n'); + + // Insert the cleanedText into the original paragraph structure + const oParagraph = Api.CreateParagraph(); + oParagraph.AddText(cleanedText); + oDocument.InsertContent([oParagraph], { "KeepTextOnly": true }); })(); ```