Open AmineId opened 3 years ago
@AmineId - so would an option to provide a mime-type instead of the hard-coded work?
@AmineId - I'm trying to implement PowerPoint generation in Salesforce & saw this entry. I'm a little confused as it what you did. I can see from your very detailed description that you added a couple of lines - one for window object & another to allow plain text output but my knowledge of Javascript libraries is limited & I'm struggling to get this working with the current files in the repo. I've tried adding window.PptxGenJS = PptxGenJS; into the end of pptxgen.min.js but it doesn't pick it up in the loadScript in LWC. Any help really appreciated.
This is working fine @gitbrent 🤘 . Here's a repo with a sample @AmineId @Praenei : https://github.com/MayTheSForceBeWithYou/PptxGenJsForce
Hi @MayTheSForceBeWithYou,
Your GUTHUB helped a lot. I was using JavaScript from your repository, but I encountered an issue with the Lightning Locker service while working on LWC. To bypass the issue, we need to enable Lightning Web Security, we need to compromise on the security, which is not feasible due to security concerns. I have tried removing the "use strict" and replacing "self" with "global" but the JavaScript is still not loading unless I enable the "Use Lightning Web Security for Lightning web components and Aura components" option. Is there a workaround or JS file which can consume the locker service to fulfil the PPTX download?
LWC > Load Script > Static Resource JS File > Not Working
https://developer.salesforce.com/docs/platform/lwc/guide/security-lwsec-enable.html
@maheshtechpro So, it looks like even the minified version of PptxGenJS is larger than the 131,072 byte restriction on LWC JS files, so you can't include it "locally" to the LWC instead of use it as a Static Resource. This article says that "LWS relies on Stricter CSP to fully implement its security measures. We strongly advise that you keep the Enable Stricter Content Security Policy setting switched on when LWS is enabled." Not sure if this still functions with that setting still enabled, but that could address your security concerns.
Category
Version
Please specify what version of the library you are using: [ 3.7.1 ]
Expected / Desired Behavior / Question
I am actually using PptxGenJS in Salesforce with Lightning Web Component (LWC), the problem I've encountered is that i could not initiate a new PptxGenJS object using the constructor, because in LWC we cannot use standard html markup to add script in
but we load script using a Salesforce Platform Resource Loader and to use an object from a third party JS library it needs to be bind to the window object.I have succeeded in loading the library correctly and initiating a PptxGenJS object with just adding window.PptxGenJS = PptxGenJS in pptxgen.gulp.js and pptxgen.js (after running gulp build) like so
Everything worked fine until I executed the function writeFile when i had 'Unexpected MIME Type' error, in Salesforce there are only few mime type that are whitelisted :
So i had to change the markup in writeFileToBrowser from application/vnd.openxmlformats-officedocument.presentationml.presentation to text/plain like so
I hope you could do this change in a future build so other LWC users will benefit from this plugin bld.zip