Skip to content

Commit fbf2791

Browse files
authored
feat: remove RTLTextPlugin default for MapLibre (#2480)
1 parent 74a652e commit fbf2791

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

docs/api-reference/maplibre/map.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -493,14 +493,12 @@ If `reuseMaps` is set to `true`, when a map component is unmounted, the underlyi
493493

494494
Note that since some map options cannot be modified after initialization, when reusing maps, only the reactive props and `initialViewState` of the new component are respected.
495495

496-
#### `RTLTextPlugin`: string | false {#rtltextplugin}
496+
#### `RTLTextPlugin`: string | object {#rtltextplugin}
497497

498-
Default: `'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js'`
499-
500-
Sets the map's [RTL text plugin](https://www.mapbox.com/mapbox-gl-js/plugins/#mapbox-gl-rtl-text). Necessary for supporting the Arabic and Hebrew languages, which are written right-to-left.
501-
502-
Setting this prop is the equivalent of calling [setRTLTextPlugin](https://maplibre.org/maplibre-gl-js/docs/API/functions/setRTLTextPlugin/) with `lazy: true`. Set to `false` to disable loading the RTL text plugin.
498+
- `pluginUrl`: `string` URL to the plugin JS file.
499+
- `lazy`: `boolean` When true, the plugin is only loaded when the map first encounters Hebrew or Arabic text. Default `true`.
503500

501+
Sets the map's RTL text plugin via [setRTLTextPlugin](https://maplibre.org/maplibre-gl-js/docs/API/functions/setRTLTextPlugin/). Can be used with [mapbox-gl-rtl-text](https://github.com/mapbox/mapbox-gl-rtl-text). Necessary for supporting the Arabic and Hebrew languages, which are written right-to-left.
504502

505503
#### `workerCount`: number {#workercount}
506504

docs/upgrade-guide.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@
1818
| `*Layer` | `*LayerSpecification` |
1919
| `*SourceRaw` | `*SourceSpecification` |
2020

21+
### MapLibre
22+
23+
#### Removed default for `RTLTextPlugin`
24+
25+
The default `RTLTextPlugin` loaded from mapbox.com has been removed to align with the default behavior of MapLibre.
26+
To keep the previous behavior, specify the `pluginUrl` which was previously used or supply the plugin from any other source:
27+
28+
```tsx
29+
<Map RTLTextPlugin="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js" />
30+
```
31+
2132

2233
## Upgrading to v7.1
2334

modules/react-maplibre/src/utils/set-globals.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export type GlobalSettings = {
44
*/
55
maxParallelImageRequests?: number;
66
/** The map's RTL text plugin. Necessary for supporting the Arabic and Hebrew languages, which are written right-to-left. */
7-
RTLTextPlugin?: string | false;
7+
RTLTextPlugin?: string | {pluginUrl: string; lazy?: boolean};
88
/** The number of web workers instantiated on a page with maplibre-gl maps.
99
* @default 2
1010
*/
@@ -16,26 +16,24 @@ export type GlobalSettings = {
1616
};
1717

1818
export default function setGlobals(mapLib: any, props: GlobalSettings) {
19-
const {
20-
RTLTextPlugin = 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js',
21-
maxParallelImageRequests,
22-
workerCount,
23-
workerUrl
24-
} = props;
19+
const {RTLTextPlugin, maxParallelImageRequests, workerCount, workerUrl} = props;
2520
if (
2621
RTLTextPlugin &&
2722
mapLib.getRTLTextPluginStatus &&
2823
mapLib.getRTLTextPluginStatus() === 'unavailable'
2924
) {
25+
const {pluginUrl, lazy = true} =
26+
typeof RTLTextPlugin === 'string' ? {pluginUrl: RTLTextPlugin} : RTLTextPlugin;
27+
3028
mapLib.setRTLTextPlugin(
31-
RTLTextPlugin,
29+
pluginUrl,
3230
(error?: Error) => {
3331
if (error) {
3432
// eslint-disable-next-line
3533
console.error(error);
3634
}
3735
},
38-
true
36+
lazy
3937
);
4038
}
4139
if (maxParallelImageRequests !== undefined) {

0 commit comments

Comments
 (0)