@clepit/core 0.6.0-beta.415 → 0.6.0-beta.417

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
@@ -8,13 +8,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
  ## [Unreleased]
9
9
 
10
10
  ### Added
11
+ - `DrawContext.locale` and `DrawContext.defaultLocale`: `renderBlocks` draws each translated field in the language asked for, falling back to the page's own, and draws a translated document that names no language in the first of its languages, where it drew "[object Object]". A document with no translation draws exactly as before.
11
12
  - `EditorConfig.onClearRequest`: the toolbar's Clear awaits the host and empties the page only when it resolves `true`; a rejection leaves the page and is reported. Absent, Clear empties the page at once, as before. `@clepit/react`'s `ClepitEditor` forwards it through the same latest-props contract as `onChange`.
12
13
  - `EditorConfig.dialogLabels` and `DIALOG_LABELS`: the link, tooltip and status dialogs draw the host's words (titles, field labels, placeholders, the status variants, Cancel and Apply), in English when absent. Each dialog element carries a test id (`link-dialog-title`, `status-dialog-variant-success` and the rest).
13
14
  - Six `blockToolbarLabels` keys for the image block's own words: `imageDropTitle`, `imageDropAction`, `imageDropFormats`, `imageUploading`, `imageUploadFailed` and `imageInvalidType`, in English when absent. The drop area's delete button takes the `delete` label as its tooltip and its `aria-label`. Each state carries a test id (`image-drop`, `image-drop-title`, `image-uploading`, `image-upload-failed`, `image-invalid-type` and the rest).
14
15
  - `UploadRefusal` and `UploadNotice`: an image uploader that rejects with `new UploadRefusal({ title, body, action, remove })` turns the block into a framed notice in the host's words, in place of the drop area: the title, the reason, the action as a link opening in a new tab (http and https only; left out when absent) and a Remove that deletes the block. Any other rejection still shows the failed-upload line. Test ids `image-refusal`, `image-refusal-title`, `image-refusal-body`, `image-refusal-action` and `image-refusal-remove`.
15
16
  - `PublicPage.alternates` and `PublicPage.notice`: `renderPage` writes one `<link rel="alternate">` per hreflang and address pair, and draws the notice (a title and a line, test id `public-page-notice`) below the page title with its own styles. A page passing neither renders exactly as before.
17
+ - `pageMetadata`, `renderNotice` and `noticeStylesheet`: a host that frames a public page in its own chrome writes the page's description, canonical, language and link-preview tags and draws its language notice exactly as `renderPage` does, which now draws both through them.
18
+ - `PublicPage.scheme`: `renderPage` draws the page in `light` or `dark` only, by setting `data-clepit-theme` on `<body>` (the attribute the theme's tokens resolve under) and a `color-scheme` meta so the browser's own canvas and text follow it. A page passing no scheme renders exactly as before.
16
19
 
17
20
  ### Fixed
21
+ - An editor given `locale` kept only the language being edited: an edit replaced a field's map of languages with one string. The editor now keeps each block's stored data and writes an edit back into it with the rule both twins share, on every way a block leaves it (`onChange`, `data.extract()`, `blocks.get` and `blocks.getAll`), while `blocks.insert`, `blocks.update` and `data.set` take stored data and show it in the language being edited. A converted block keeps the languages of the fields both types share.
22
+ - An editor given no `locale` drew a translated field as "[object Object]". It now shows a translated document in the first of its languages, and keeps the others through an edit.
18
23
  - The inline toolbar no longer leaves a hidden copy of the rewrite menu behind each time a new selection repaints it, so each rewrite action exists once in the page.
19
24
 
20
25
  ## [0.6.0] - 2026-09-25
@@ -1,5 +1,6 @@
1
1
  import { EditorAPI, EditorConfig } from '../../types';
2
2
  export declare class Editor {
3
+ private static sources;
3
4
  static create(config: EditorConfig): EditorAPI;
4
5
  private static initialize;
5
6
  /**
@@ -12,6 +13,10 @@ export declare class Editor {
12
13
  * change when they switched.
13
14
  */
14
15
  private static localizeData;
16
+ private static localizeBlock;
17
+ private static localizeArriving;
18
+ private static delocalizeBlock;
19
+ private static delocalizeData;
15
20
  private static render;
16
21
  /** Releases the runtime a container holds and leaves its document in the
17
22
  * store. `create` runs this first so a second create in the same container
@@ -66,6 +66,8 @@ export type DrawContext = {
66
66
  issueChip?: IssueChipParts;
67
67
  /** Translated issue words; English fallbacks otherwise. */
68
68
  issueLabels?: Partial<Record<IssueLabel, string>>;
69
+ locale?: string;
70
+ defaultLocale?: string;
69
71
  };
70
72
  export type Backing = {
71
73
  create(tag: string): ClepitElement;
@@ -40,4 +40,9 @@ export declare const resolveLocalized: <T>(value: Localized<T> | undefined, requ
40
40
  * changes shape.
41
41
  */
42
42
  export declare const withLocale: <T>(value: Localized<T> | undefined, locale: string, next: T, documentDefault: string) => Localized<T>;
43
+ export declare const writeBlockData: (blockType: string, stored: Record<string, unknown> | undefined, edited: Record<string, unknown>, locale: string, documentDefault: string) => Record<string, unknown>;
44
+ export declare const firstLocaleOf: (blocks: {
45
+ data: unknown;
46
+ type: string;
47
+ }[]) => string | undefined;
43
48
  //# sourceMappingURL=index.d.ts.map
@@ -10,6 +10,7 @@ export type PublicPage = {
10
10
  canonicalUrl?: string;
11
11
  alternates?: PublicPageAlternate[];
12
12
  notice?: PublicPageNotice;
13
+ scheme?: 'light' | 'dark';
13
14
  };
14
15
  export type PublicPageAlternate = {
15
16
  href: string;
@@ -19,6 +20,9 @@ export type PublicPageNotice = {
19
20
  body: string;
20
21
  title: string;
21
22
  };
23
+ export declare const noticeStylesheet: () => string;
24
+ export declare const renderNotice: (notice: PublicPageNotice) => string;
25
+ export declare const pageMetadata: (page: Pick<PublicPage, "alternates" | "canonicalUrl" | "description" | "title">) => string;
22
26
  /**
23
27
  * Every stylesheet a drawn document needs, as text.
24
28
  *
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { StyleManager } from './core/managers/style';
4
4
  export { Renderer } from './core/renderer';
5
5
  export { activateBlocks } from './core/renderer/activate';
6
6
  export { drawBlock } from './core/renderer/draw';
7
- export { type PublicPage, type PublicPageAlternate, type PublicPageNotice, pageStylesheet, renderBlocks, renderPage } from './core/renderer/page';
7
+ export { noticeStylesheet, type PublicPage, type PublicPageAlternate, type PublicPageNotice, pageMetadata, pageStylesheet, renderBlocks, renderNotice, renderPage } from './core/renderer/page';
8
8
  export { type ThemeTokens, tokensToLightDarkBlock } from './core/theme';
9
9
  export { UploadRefusal } from './core/upload-refusal';
10
10
  export { EMBED_ENGLISH, EMBED_TOOL_NAMES, embedLabel } from './tools/block/embed/output';