fix(components): add RTLTextPlugin prop to disable remote script loading (#2477)#3336
Open
pierreeurope wants to merge 1 commit intokeplergl:masterfrom
Open
fix(components): add RTLTextPlugin prop to disable remote script loading (#2477)#3336pierreeurope wants to merge 1 commit intokeplergl:masterfrom
pierreeurope wants to merge 1 commit intokeplergl:masterfrom
Conversation
…ing (keplergl#2477) Add RTLTextPlugin prop to KeplerGl and MapContainer components, allowing users to pass RTLTextPlugin={false} to prevent react-map-gl from loading the mapbox-gl-rtl-text plugin from a remote URL. This is needed in strict Content Security Policy (CSP) environments where loading external scripts is prohibited. Closes keplergl#2477 Signed-off-by: pierreeurope <pierre.europe@pm.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an
RTLTextPluginprop to theKeplerGlandMapContainercomponents, allowing users to disable the automatic loading of the mapbox-gl-rtl-text plugin from a remote URL.Problem
react-map-glloads the RTL text plugin fromhttps://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.jsby default. This violates strict Content Security Policy (CSP) environments where loading external scripts is prohibited.See also: visgl/react-map-gl#2310
Solution
Thread the
RTLTextPluginprop fromKeplerGl→MapContainer→react-map-gl'sMapcomponent. Users can now:When the prop is not provided, the default
react-map-glbehavior is preserved (loads from Mapbox CDN).Changes
src/components/src/kepler-gl.tsx: AddRTLTextPlugintoKeplerGLBasicPropsand pass it toMapContainersrc/components/src/map-container.tsx: AddRTLTextPlugintoMapContainerPropsand include it inmapPropsCloses #2477