@prenta/admin 2.16.3 → 2.16.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @actuate-media/cms-admin
2
2
 
3
+ ## 2.16.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 5b188d4: The admin locale picker no longer crashes when browser storage is unavailable, such as in a private window; it falls back to the default locale.
8
+
9
+ ## 2.16.4
10
+
11
+ ### Patch Changes
12
+
13
+ - 5230917: Point repository links at github.com/Prenta-dev/prenta, where the source now lives. The `repository` field on npm, the importer adapters' docs links, the section editor's help link and the docs link `create-prenta` prints all moved from `actuate-media/prenta`. No behaviour changes.
14
+
3
15
  ## 2.16.3
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @prenta/admin
2
2
 
3
- The React admin UI for [Prenta CMS](https://github.com/actuate-media/prenta):
3
+ The React admin UI for [Prenta CMS](https://github.com/Prenta-dev/prenta):
4
4
  page/post section editors, media library, forms inbox, SEO tools, settings, and
5
5
  the setup wizard — mounted in your app via a single component.
6
6
 
@@ -28,7 +28,7 @@ site's CSS.
28
28
  ## Release notes
29
29
 
30
30
  See [CHANGELOG.md](./CHANGELOG.md) (shipped with the package) or the
31
- [GitHub releases](https://github.com/actuate-media/prenta/releases).
31
+ [GitHub releases](https://github.com/Prenta-dev/prenta/releases).
32
32
 
33
33
  ## License
34
34
 
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=locale-provider-storage.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-provider-storage.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/components/locale-provider-storage.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,59 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ // @vitest-environment happy-dom
3
+ import { act, fireEvent, render, screen } from '@testing-library/react';
4
+ import { afterEach, describe, expect, it, vi } from 'vitest';
5
+ import { LocaleProvider, useLocale } from '../../components/LocaleProvider.js';
6
+ const config = {
7
+ i18n: {
8
+ defaultLocale: 'en',
9
+ locales: [
10
+ { code: 'en', label: 'English' },
11
+ { code: 'es', label: 'Spanish' },
12
+ ],
13
+ },
14
+ };
15
+ function Probe() {
16
+ const { activeLocale, setLocale } = useLocale();
17
+ return (_jsxs("button", { type: "button", onClick: () => setLocale('es'), children: ["locale:", activeLocale] }));
18
+ }
19
+ function renderProvider() {
20
+ return render(_jsx(LocaleProvider, { config: config, children: _jsx(Probe, {}) }));
21
+ }
22
+ describe('LocaleProvider storage guard (#1210)', () => {
23
+ afterEach(() => {
24
+ vi.unstubAllGlobals();
25
+ });
26
+ it('renders with the default locale when localStorage is undefined', async () => {
27
+ vi.stubGlobal('localStorage', undefined);
28
+ renderProvider();
29
+ await act(async () => { });
30
+ const button = screen.getByRole('button');
31
+ expect(button.textContent).toBe('locale:en');
32
+ fireEvent.click(button);
33
+ expect(button.textContent).toBe('locale:es');
34
+ });
35
+ it('renders with the default locale when getItem and setItem throw', async () => {
36
+ const throwing = {
37
+ getItem: vi.fn(() => {
38
+ throw new DOMException('denied', 'SecurityError');
39
+ }),
40
+ setItem: vi.fn(() => {
41
+ throw new DOMException('denied', 'QuotaExceededError');
42
+ }),
43
+ removeItem: vi.fn(),
44
+ clear: vi.fn(),
45
+ key: vi.fn(() => null),
46
+ length: 0,
47
+ };
48
+ vi.stubGlobal('localStorage', throwing);
49
+ renderProvider();
50
+ await act(async () => { });
51
+ const button = screen.getByRole('button');
52
+ expect(throwing.getItem).toHaveBeenCalled();
53
+ expect(button.textContent).toBe('locale:en');
54
+ fireEvent.click(button);
55
+ expect(throwing.setItem).toHaveBeenCalledWith('prenta-locale', 'es');
56
+ expect(button.textContent).toBe('locale:es');
57
+ });
58
+ });
59
+ //# sourceMappingURL=locale-provider-storage.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-provider-storage.test.js","sourceRoot":"","sources":["../../../src/__tests__/components/locale-provider-storage.test.tsx"],"names":[],"mappings":";AAAA,gCAAgC;AAChC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE5D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AAE9E,MAAM,MAAM,GAAG;IACb,IAAI,EAAE;QACJ,aAAa,EAAE,IAAI;QACnB,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE;YAChC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE;SACjC;KACF;CACF,CAAA;AAED,SAAS,KAAK;IACZ,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAAA;IAC/C,OAAO,CACL,kBAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,wBAC1C,YAAY,IACb,CACV,CAAA;AACH,CAAC;AAED,SAAS,cAAc;IACrB,OAAO,MAAM,CACX,KAAC,cAAc,IAAC,MAAM,EAAE,MAAM,YAC5B,KAAC,KAAK,KAAG,GACM,CAClB,CAAA;AACH,CAAC;AAED,QAAQ,CAAC,sCAAsC,EAAE,GAAG,EAAE;IACpD,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,gBAAgB,EAAE,CAAA;IACvB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,gEAAgE,EAAE,KAAK,IAAI,EAAE;QAC9E,EAAE,CAAC,UAAU,CAAC,cAAc,EAAE,SAAS,CAAC,CAAA;QAExC,cAAc,EAAE,CAAA;QAChB,MAAM,GAAG,CAAC,KAAK,IAAI,E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;QAE5C,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QACvB,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,eAAe,EAAE,IAAI,CAAC,CAAA;QACpE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"LocaleProvider.d.ts","sourceRoot":"","sources":["../../src/components/LocaleProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA+D,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEnG,UAAU,kBAAkB;IAC1B,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAA;KAAE,CAAC,CAAA;CACrE;AAQD,wBAAgB,SAAS,uBAExB;AAID,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE;QACN,IAAI,CAAC,EAAE;YACL,aAAa,EAAE,MAAM,CAAA;YACrB,OAAO,EAAE,KAAK,CAAC;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAC;gBAAC,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAA;aAAE,CAAC,CAAA;YACpE,cAAc,CAAC,EAAE,MAAM,CAAA;SACxB,CAAA;KACF,CAAA;IACD,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,mBAAmB,2CAuBvE"}
1
+ {"version":3,"file":"LocaleProvider.d.ts","sourceRoot":"","sources":["../../src/components/LocaleProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA+D,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEnG,UAAU,kBAAkB;IAC1B,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAA;KAAE,CAAC,CAAA;CACrE;AAQD,wBAAgB,SAAS,uBAExB;AAwBD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE;QACN,IAAI,CAAC,EAAE;YACL,aAAa,EAAE,MAAM,CAAA;YACrB,OAAO,EAAE,KAAK,CAAC;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAC;gBAAC,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAA;aAAE,CAAC,CAAA;YACpE,cAAc,CAAC,EAAE,MAAM,CAAA;SACxB,CAAA;KACF,CAAA;IACD,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,mBAAmB,2CAuBvE"}
@@ -10,19 +10,41 @@ export function useLocale() {
10
10
  return useContext(LocaleContext);
11
11
  }
12
12
  const STORAGE_KEY = 'prenta-locale';
13
+ // Storage can be missing (Node without --localstorage-file, SSR) or throw
14
+ // (private windows, blocked site data); the locale then stays in memory only.
15
+ function readStoredLocale() {
16
+ try {
17
+ if (typeof localStorage === 'undefined' || !localStorage)
18
+ return null;
19
+ return localStorage.getItem(STORAGE_KEY);
20
+ }
21
+ catch {
22
+ return null;
23
+ }
24
+ }
25
+ function writeStoredLocale(locale) {
26
+ try {
27
+ if (typeof localStorage === 'undefined' || !localStorage)
28
+ return;
29
+ localStorage.setItem(STORAGE_KEY, locale);
30
+ }
31
+ catch {
32
+ // Storage unavailable: keep the choice for this session only.
33
+ }
34
+ }
13
35
  export function LocaleProvider({ config, children }) {
14
36
  const locales = config.i18n?.locales ?? [];
15
37
  const defaultLocale = config.i18n?.defaultLocale ?? 'en';
16
38
  const [activeLocale, setActiveLocale] = useState(defaultLocale);
17
39
  useEffect(() => {
18
- const stored = localStorage.getItem(STORAGE_KEY);
40
+ const stored = readStoredLocale();
19
41
  if (stored && locales.some((l) => l.code === stored)) {
20
42
  setActiveLocale(stored);
21
43
  }
22
44
  }, [locales]);
23
45
  const setLocale = useCallback((locale) => {
24
46
  setActiveLocale(locale);
25
- localStorage.setItem(STORAGE_KEY, locale);
47
+ writeStoredLocale(locale);
26
48
  }, []);
27
49
  return (_jsx(LocaleContext.Provider, { value: { activeLocale, setLocale, locales }, children: children }));
28
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"LocaleProvider.js","sourceRoot":"","sources":["../../src/components/LocaleProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAkB,MAAM,OAAO,CAAA;AAQnG,MAAM,aAAa,GAAG,aAAa,CAAqB;IACtD,YAAY,EAAE,IAAI;IAClB,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC;IACnB,OAAO,EAAE,EAAE;CACZ,CAAC,CAAA;AAEF,MAAM,UAAU,SAAS;IACvB,OAAO,UAAU,CAAC,aAAa,CAAC,CAAA;AAClC,CAAC;AAED,MAAM,WAAW,GAAG,eAAe,CAAA;AAanC,MAAM,UAAU,cAAc,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAuB;IACtE,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,CAAA;IAC1C,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,EAAE,aAAa,IAAI,IAAI,CAAA;IAExD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC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AAC,QAAQ,IAAC,KAAK,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,YAChE,QAAQ,GACc,CAC1B,CAAA;AACH,CAAC"}
@@ -48,6 +48,6 @@ export function SectionEditForm({ section, canEdit, onContentChange, onMetaChang
48
48
  // The validator reads the same helper, so it can never require a field the
49
49
  // editor is not drawing.
50
50
  const contentFields = visibleFields(def?.fields ?? [], section.content).filter((f) => !(editPostBodyField && f.key === 'body')) ?? [];
51
- return (_jsxs("div", { className: "border-border bg-muted/40 border-t px-3 py-3.5", children: [_jsxs("fieldset", { disabled: !canEdit, className: "space-y-3", children: [editPostBodyField && (_jsx(RichTextField, { label: "Post body field", value: postBody ?? '', onChange: onPostBodyChange, className: "[&_.ProseMirror]:min-h-[240px]", helpText: "Shared with post settings. Edits here change the post's Body field, which the canvas and the live site both render." })), contentFields.map((field) => (_jsx(ContentField, { id: `sec-${section.id}-${field.key}`, field: field, value: section.content[field.key], onChange: (v) => onContentChange({ [field.key]: v }), onPatch: (patch) => onContentChange(patch) }, field.key))), contentFields.length === 0 && !editPostBodyField && (_jsx("p", { className: "text-muted-foreground text-xs", children: "This section has no editable content \u2014 it is rendered entirely from the template." })), _jsxs("details", { className: "group", children: [_jsx("summary", { className: "text-muted-foreground hover:text-foreground cursor-pointer list-none text-[11px] font-medium tracking-wider uppercase", children: "Section settings" }), _jsxs("div", { className: "mt-2.5 space-y-3", children: [_jsxs("div", { children: [_jsx("label", { className: FIELD_LABEL, htmlFor: `sec-${section.id}-name`, children: "Section name" }), _jsx("input", { id: `sec-${section.id}-name`, className: FIELD_INPUT, value: section.name, onChange: (e) => onMetaChange({ name: e.target.value }) })] }), _jsxs("div", { children: [_jsx("label", { className: FIELD_LABEL, htmlFor: `sec-${section.id}-internal`, children: "Internal label" }), _jsx("input", { id: `sec-${section.id}-internal`, className: FIELD_INPUT, placeholder: "Team-only note (optional)", value: section.internalLabel ?? '', onChange: (e) => onMetaChange({ internalLabel: e.target.value }) })] })] })] })] }), _jsxs("p", { className: "text-muted-foreground mt-3 flex items-start gap-1.5 text-[11px] leading-relaxed", children: [_jsx(Lock, { className: "mt-0.5 h-3 w-3 shrink-0", "aria-hidden": true }), _jsxs("span", { children: ["Background, spacing and layout come from the template.", ' ', _jsxs("a", { href: "https://github.com/actuate-media/prenta/blob/main/docs/design-owned-sections.md", target: "_blank", rel: "noopener noreferrer", className: "text-brand inline-flex items-center gap-0.5 hover:underline", children: ["Why", _jsx(ExternalLink, { className: "h-2.5 w-2.5", "aria-hidden": true })] })] })] })] }));
51
+ return (_jsxs("div", { className: "border-border bg-muted/40 border-t px-3 py-3.5", children: [_jsxs("fieldset", { disabled: !canEdit, className: "space-y-3", children: [editPostBodyField && (_jsx(RichTextField, { label: "Post body field", value: postBody ?? '', onChange: onPostBodyChange, className: "[&_.ProseMirror]:min-h-[240px]", helpText: "Shared with post settings. Edits here change the post's Body field, which the canvas and the live site both render." })), contentFields.map((field) => (_jsx(ContentField, { id: `sec-${section.id}-${field.key}`, field: field, value: section.content[field.key], onChange: (v) => onContentChange({ [field.key]: v }), onPatch: (patch) => onContentChange(patch) }, field.key))), contentFields.length === 0 && !editPostBodyField && (_jsx("p", { className: "text-muted-foreground text-xs", children: "This section has no editable content \u2014 it is rendered entirely from the template." })), _jsxs("details", { className: "group", children: [_jsx("summary", { className: "text-muted-foreground hover:text-foreground cursor-pointer list-none text-[11px] font-medium tracking-wider uppercase", children: "Section settings" }), _jsxs("div", { className: "mt-2.5 space-y-3", children: [_jsxs("div", { children: [_jsx("label", { className: FIELD_LABEL, htmlFor: `sec-${section.id}-name`, children: "Section name" }), _jsx("input", { id: `sec-${section.id}-name`, className: FIELD_INPUT, value: section.name, onChange: (e) => onMetaChange({ name: e.target.value }) })] }), _jsxs("div", { children: [_jsx("label", { className: FIELD_LABEL, htmlFor: `sec-${section.id}-internal`, children: "Internal label" }), _jsx("input", { id: `sec-${section.id}-internal`, className: FIELD_INPUT, placeholder: "Team-only note (optional)", value: section.internalLabel ?? '', onChange: (e) => onMetaChange({ internalLabel: e.target.value }) })] })] })] })] }), _jsxs("p", { className: "text-muted-foreground mt-3 flex items-start gap-1.5 text-[11px] leading-relaxed", children: [_jsx(Lock, { className: "mt-0.5 h-3 w-3 shrink-0", "aria-hidden": true }), _jsxs("span", { children: ["Background, spacing and layout come from the template.", ' ', _jsxs("a", { href: "https://github.com/Prenta-dev/prenta/blob/main/docs/design-owned-sections.md", target: "_blank", rel: "noopener noreferrer", className: "text-brand inline-flex items-center gap-0.5 hover:underline", children: ["Why", _jsx(ExternalLink, { className: "h-2.5 w-2.5", "aria-hidden": true })] })] })] })] }));
52
52
  }
53
53
  //# sourceMappingURL=SectionEditForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SectionEditForm.js","sourceRoot":"","sources":["../../../src/views/page-editor/SectionEditForm.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAYnD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,OAAO,EACP,OAAO,EACP,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,gBAAgB,GACK;IACrB,MAAM,GAAG,GAAG,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAE/C,0EAA0E;IAC1E,gEAAgE;IAChE,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,OAAO,CACL,cAAK,SAAS,EAAC,8CAA8C,YAC3D,aAAG,SAAS,EAAC,sEAAsE,aACjF,KAAC,IAAI,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,EAAC,yBAAyB,wBAAe,EACxD,qFACyD,GAAG,EAC1D,aACE,IAAI,EAAC,iFAAiF,EACtF,MAAM,EAAC,QAAQ,EACf,GAAG,EAAC,qBAAqB,EACzB,SAAS,EAAC,6DAA6D,oBAGvE,KAAC,YAAY,IAAC,SAAS,EAAC,aAAa,wBAAe,IAClD,IACC,IACL,IACA,CACP,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"SectionEditForm.js","sourceRoot":"","sources":["../../../src/views/page-editor/SectionEditForm.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAYnD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,OAAO,EACP,OAAO,EACP,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,gBAAgB,GACK;IACrB,MAAM,GAAG,GAAG,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAE/C,0EAA0E;IAC1E,gEAAgE;IAChE,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,OAAO,CACL,cAAK,SAAS,EAAC,8CAA8C,YAC3D,aAAG,SAAS,EAAC,sEAAsE,aACjF,KAAC,IAAI,IAAC,SAAS,EAAC,6BAA6B,wBAAe,EAC5D,2BACE,eAAM,SAAS,EAAC,6BAA6B,2CAAkC,wCACzD,eAAM,SAAS,EAAC,WAAW,YAAE,OAAO,CAAC,WAAW,GAAQ,2EAEzE,IACL,GACA,CACP,CAAA;IACH,CAAC;IAED,MAAM,UAAU,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e,IAClD,IACC,IACL,IACA,CACP,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@prenta/admin",
3
- "version": "2.16.3",
3
+ "version": "2.16.5",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "https://github.com/actuate-media/prenta.git",
7
+ "url": "https://github.com/Prenta-dev/prenta.git",
8
8
  "directory": "packages/cms-admin"
9
9
  },
10
10
  "publishConfig": {
@@ -99,16 +99,16 @@
99
99
  "tailwindcss": "^4.0.0",
100
100
  "typescript": "^5.7.0",
101
101
  "vitest": "^4.1.12",
102
- "@prenta/core": "8.21.8",
103
- "@prenta/plugin-commerce": "1.0.1",
104
- "@prenta/plugin-ai": "4.0.1",
105
- "@prenta/plugin-blocks": "1.0.1",
106
- "@prenta/component-blocks": "0.3.1",
107
- "@prenta/plugin-forms": "1.0.2",
108
- "@prenta/plugin-media": "1.0.1",
109
- "@prenta/plugin-seo": "2.0.1",
110
- "@prenta/plugin-navigation": "1.1.0",
111
- "@prenta/sections-react": "0.20.24"
102
+ "@prenta/core": "8.21.11",
103
+ "@prenta/plugin-ai": "4.0.2",
104
+ "@prenta/component-blocks": "0.3.2",
105
+ "@prenta/plugin-blocks": "1.0.2",
106
+ "@prenta/plugin-commerce": "1.0.2",
107
+ "@prenta/plugin-media": "1.0.2",
108
+ "@prenta/plugin-navigation": "1.1.1",
109
+ "@prenta/plugin-seo": "2.0.2",
110
+ "@prenta/sections-react": "0.20.27",
111
+ "@prenta/plugin-forms": "1.0.3"
112
112
  },
113
113
  "scripts": {
114
114
  "build": "tsc --project tsconfig.json && npx @tailwindcss/cli -i src/styles/build-input.css -o dist/prenta-admin.css --minify && node scripts/copy-font-files.mjs",
@@ -0,0 +1,78 @@
1
+ // @vitest-environment happy-dom
2
+ import { act, fireEvent, render, screen } from '@testing-library/react'
3
+ import { afterEach, describe, expect, it, vi } from 'vitest'
4
+
5
+ import { LocaleProvider, useLocale } from '../../components/LocaleProvider.js'
6
+
7
+ const config = {
8
+ i18n: {
9
+ defaultLocale: 'en',
10
+ locales: [
11
+ { code: 'en', label: 'English' },
12
+ { code: 'es', label: 'Spanish' },
13
+ ],
14
+ },
15
+ }
16
+
17
+ function Probe() {
18
+ const { activeLocale, setLocale } = useLocale()
19
+ return (
20
+ <button type="button" onClick={() => setLocale('es')}>
21
+ locale:{activeLocale}
22
+ </button>
23
+ )
24
+ }
25
+
26
+ function renderProvider() {
27
+ return render(
28
+ <LocaleProvider config={config}>
29
+ <Probe />
30
+ </LocaleProvider>,
31
+ )
32
+ }
33
+
34
+ describe('LocaleProvider storage guard (#1210)', () => {
35
+ afterEach(() => {
36
+ vi.unstubAllGlobals()
37
+ })
38
+
39
+ it('renders with the default locale when localStorage is undefined', async () => {
40
+ vi.stubGlobal('localStorage', undefined)
41
+
42
+ renderProvider()
43
+ await act(async () => {})
44
+
45
+ const button = screen.getByRole('button')
46
+ expect(button.textContent).toBe('locale:en')
47
+
48
+ fireEvent.click(button)
49
+ expect(button.textContent).toBe('locale:es')
50
+ })
51
+
52
+ it('renders with the default locale when getItem and setItem throw', async () => {
53
+ const throwing = {
54
+ getItem: vi.fn(() => {
55
+ throw new DOMException('denied', 'SecurityError')
56
+ }),
57
+ setItem: vi.fn(() => {
58
+ throw new DOMException('denied', 'QuotaExceededError')
59
+ }),
60
+ removeItem: vi.fn(),
61
+ clear: vi.fn(),
62
+ key: vi.fn(() => null),
63
+ length: 0,
64
+ }
65
+ vi.stubGlobal('localStorage', throwing)
66
+
67
+ renderProvider()
68
+ await act(async () => {})
69
+
70
+ const button = screen.getByRole('button')
71
+ expect(throwing.getItem).toHaveBeenCalled()
72
+ expect(button.textContent).toBe('locale:en')
73
+
74
+ fireEvent.click(button)
75
+ expect(throwing.setItem).toHaveBeenCalledWith('prenta-locale', 'es')
76
+ expect(button.textContent).toBe('locale:es')
77
+ })
78
+ })
@@ -20,6 +20,26 @@ export function useLocale() {
20
20
 
21
21
  const STORAGE_KEY = 'prenta-locale'
22
22
 
23
+ // Storage can be missing (Node without --localstorage-file, SSR) or throw
24
+ // (private windows, blocked site data); the locale then stays in memory only.
25
+ function readStoredLocale(): string | null {
26
+ try {
27
+ if (typeof localStorage === 'undefined' || !localStorage) return null
28
+ return localStorage.getItem(STORAGE_KEY)
29
+ } catch {
30
+ return null
31
+ }
32
+ }
33
+
34
+ function writeStoredLocale(locale: string): void {
35
+ try {
36
+ if (typeof localStorage === 'undefined' || !localStorage) return
37
+ localStorage.setItem(STORAGE_KEY, locale)
38
+ } catch {
39
+ // Storage unavailable: keep the choice for this session only.
40
+ }
41
+ }
42
+
23
43
  export interface LocaleProviderProps {
24
44
  config: {
25
45
  i18n?: {
@@ -38,7 +58,7 @@ export function LocaleProvider({ config, children }: LocaleProviderProps) {
38
58
  const [activeLocale, setActiveLocale] = useState(defaultLocale)
39
59
 
40
60
  useEffect(() => {
41
- const stored = localStorage.getItem(STORAGE_KEY)
61
+ const stored = readStoredLocale()
42
62
  if (stored && locales.some((l) => l.code === stored)) {
43
63
  setActiveLocale(stored)
44
64
  }
@@ -46,7 +66,7 @@ export function LocaleProvider({ config, children }: LocaleProviderProps) {
46
66
 
47
67
  const setLocale = useCallback((locale: string) => {
48
68
  setActiveLocale(locale)
49
- localStorage.setItem(STORAGE_KEY, locale)
69
+ writeStoredLocale(locale)
50
70
  }, [])
51
71
 
52
72
  return (
@@ -154,7 +154,7 @@ export function SectionEditForm({
154
154
  <span>
155
155
  Background, spacing and layout come from the template.{' '}
156
156
  <a
157
- href="https://github.com/actuate-media/prenta/blob/main/docs/design-owned-sections.md"
157
+ href="https://github.com/Prenta-dev/prenta/blob/main/docs/design-owned-sections.md"
158
158
  target="_blank"
159
159
  rel="noopener noreferrer"
160
160
  className="text-brand inline-flex items-center gap-0.5 hover:underline"