When I try to use portalLib.sanitizeHtml() to sanitize input from an HtmlArea which I have already processed with portalLib.processHtml(), it removes the macros in use.
So, if I want to sanitize an editors input from an HtmlArea, they will not be able to use macros (for example from your app Social Macros) as they are removed.
Can this be fixed, so we can use both sanitizeHtml and macros?
sanitizeHtml is used to make some untrusted HTML safer. It allows only very basic tags and no scripts or iframes. H handful function to sanitize user-input (blog post comments, for instance) before it is stored.
processHtml is a function that generates trusted HTML from HtmlArea. Since it is trusted, sanitizeHtml should not be applied to it.
Could it be possible to not remove the <!--#MACRO _name="youtube" title="Enonic video" url="https://www.youtube.com/watch?v=clH9eIoMcJ8" _document="__macroDocument1" _body=""--> with sanitizeHtml so this can be used in Enonic to actually allow the macro to be shown?
You may, of curse, write your own customSanitazeHtml with your own rules.
Note, however that MACRO instruction comment is an implementation detail of XP - it is not documented.