@kardalum/plugin-sdk 0.15.0 → 0.17.0
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 +49 -1
- package/README.md +10 -0
- package/dist/admin-section-registry.d.ts +14 -5
- package/dist/admin-section-registry.js +14 -4
- package/dist/built-in-value-schemas.js +1 -1
- package/dist/built-ins.js +2 -2
- package/dist/capabilities.d.ts +8 -78
- package/dist/capabilities.js +23 -322
- package/dist/host-entry.d.ts +1 -1
- package/dist/host-entry.js +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +13 -12
- package/dist/license-verdict-keys.d.ts +4 -3
- package/dist/license-verdict-keys.js +6 -5
- package/dist/manifest-entry.d.ts +3 -3
- package/dist/manifest-entry.js +2 -2
- package/dist/manifest-schema.d.ts +113 -56
- package/dist/manifest-schema.js +192 -295
- package/dist/manifest.d.ts +145 -112
- package/dist/manifest.js +13 -36
- package/dist/media/media-picker.js +21 -12
- package/dist/media/upload-error.d.ts +1 -1
- package/dist/media/upload-error.js +1 -1
- package/dist/plugin-context.d.ts +7 -0
- package/dist/plugin-context.js +7 -0
- package/dist/plugin-screen-context.d.ts +44 -3
- package/dist/plugin-screen-context.js +27 -2
- package/dist/read-all-pages.d.ts +23 -0
- package/dist/read-all-pages.js +30 -0
- package/dist/richtext/block-panel.js +6 -6
- package/dist/richtext/insert-menu.js +4 -4
- package/dist/richtext/style-listbox.js +4 -4
- package/dist/tokens/tokens.css +1 -0
- package/dist/tokens/tokens.json +2 -1
- package/dist/type-equality.d.ts +2 -0
- package/dist/type-equality.js +1 -0
- package/dist/views/content-list-view.js +2 -2
- package/dist/views/html-view.js +1 -1
- package/dist/views/image-view.js +24 -39
- package/dist/views/rich-text-view.js +3 -3
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +43 -25
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +60 -8
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +90 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +33 -2
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +22 -1
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +50 -15
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +204 -0
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +134 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +18 -13
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +2 -2
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-path.js +11 -7
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +2 -1
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +143 -57
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +110 -60
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +67 -40
- package/node_modules/@kardalum/api-schemas/dist/index.js +35 -19
- package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/issue-list.d.ts +6 -0
- package/node_modules/@kardalum/api-schemas/dist/issue-list.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +73 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +104 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +356 -16
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +93 -10
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +38 -30
- package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +2 -2
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +6 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +8 -6
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +69 -4
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +76 -9
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +84 -24
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +17 -7
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +18 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +69 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +59 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +597 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +503 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.d.ts +60 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.js +116 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +82 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +228 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +33 -4
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +28 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +11 -3
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +17 -4
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +58 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +198 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.d.ts +64 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.js +134 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.d.ts +74 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +132 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.js +15 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +23 -4
- package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +4 -4
- package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +44 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +97 -0
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +126 -0
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.js +70 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +36 -6
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +17 -5
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +52 -33
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +195 -56
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +19 -3
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/strict-url.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/strict-url.js +31 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +105 -1
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +47 -7
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +30 -2
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +19 -5
- package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.js +29 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +15 -3
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +19 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +22 -0
- package/node_modules/@kardalum/api-schemas/package.json +2 -2
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +1 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +3 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +2 -1
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/README.md +4 -1
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +96 -0
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +66 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +103 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +346 -0
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +4 -0
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +25 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.d.ts +25 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.js +203 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +73 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +60 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.js +2052 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icons.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icons.js +51 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +8 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +7 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +119 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +14 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +21 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/locales.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/locales.js +148 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.js +76 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.d.ts +22 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +133 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +90 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/support.d.ts +24 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/support.js +55 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +6 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +158 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +53 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/types.js +1 -0
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +3 -2
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +4 -2
- package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +92 -3
- package/node_modules/@kardalum/plugin-package/dist/extract.js +251 -41
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +11 -2
- package/node_modules/@kardalum/plugin-package/dist/index.js +8 -2
- package/node_modules/@kardalum/plugin-package/dist/manifest-entry.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/manifest-entry.js +20 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +7 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +38 -1
- package/node_modules/@kardalum/plugin-package/dist/sample-content.js +84 -16
- package/node_modules/@kardalum/plugin-package/dist/shipped-files.d.ts +39 -0
- package/node_modules/@kardalum/plugin-package/dist/shipped-files.js +133 -0
- package/node_modules/@kardalum/plugin-package/dist/shipped-locales.d.ts +7 -0
- package/node_modules/@kardalum/plugin-package/dist/shipped-locales.js +27 -0
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +4 -6
- package/node_modules/@kardalum/plugin-package/dist/types.js +15 -1
- package/node_modules/@kardalum/plugin-package/package.json +9 -2
- package/node_modules/@kardalum/ui/dist/components/checkbox.js +2 -2
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +2 -2
- package/node_modules/@kardalum/ui/dist/components/property-field.js +4 -1
- package/node_modules/@kardalum/ui/package.json +1 -1
- package/package.json +6 -6
package/dist/plugin-context.d.ts
CHANGED
|
@@ -21,6 +21,13 @@ export declare function usePluginSettingsValue<T extends Record<string, unknown>
|
|
|
21
21
|
onChange: (value: T) => void;
|
|
22
22
|
};
|
|
23
23
|
export type PluginFetch = (input: string, init?: RequestInit) => Promise<Response>;
|
|
24
|
+
/**
|
|
25
|
+
* The base of the management API (2026-10-17-s302-the-admin-moves-onto-the-management-api-design.md D1). The host's
|
|
26
|
+
* fetch is the admin's authFetch: it passes a path through unchanged and adds the session, so a view that calls one
|
|
27
|
+
* of the CMS's own families spells the path as `${MANAGE_API}/<family>/...`. A plugin's own routes stay under
|
|
28
|
+
* /api/plugins/:pluginId/.
|
|
29
|
+
*/
|
|
30
|
+
export declare const MANAGE_API = "/api/manage/v1";
|
|
24
31
|
interface PluginApiProviderProps {
|
|
25
32
|
fetch: PluginFetch;
|
|
26
33
|
children: ReactNode;
|
package/dist/plugin-context.js
CHANGED
|
@@ -45,6 +45,13 @@ export function usePluginSettingsValue() {
|
|
|
45
45
|
}
|
|
46
46
|
return { value: ctx.settings, onChange: ctx.onSettingsChange };
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* The base of the management API (2026-10-17-s302-the-admin-moves-onto-the-management-api-design.md D1). The host's
|
|
50
|
+
* fetch is the admin's authFetch: it passes a path through unchanged and adds the session, so a view that calls one
|
|
51
|
+
* of the CMS's own families spells the path as `${MANAGE_API}/<family>/...`. A plugin's own routes stay under
|
|
52
|
+
* /api/plugins/:pluginId/.
|
|
53
|
+
*/
|
|
54
|
+
export const MANAGE_API = "/api/manage/v1";
|
|
48
55
|
const PluginApiContext = createContext(null);
|
|
49
56
|
export function PluginApiProvider({ fetch, children }) {
|
|
50
57
|
return _jsx(PluginApiContext.Provider, { value: fetch, children: children });
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Translates one of the plugin's own strings (S290): a key from its
|
|
4
|
+
* locales/<language>.json, in the admin's language, falling back to the
|
|
5
|
+
* plugin's locales/en.json, then to the key itself. `{{name}}` in the text
|
|
6
|
+
* is replaced by `values.name`. The result is plain text: render it as a
|
|
7
|
+
* child. The host's own strings and other plugins' strings are never
|
|
8
|
+
* reachable through it.
|
|
9
|
+
*/
|
|
10
|
+
export type PluginTranslate = (key: string, values?: Record<string, string | number>) => string;
|
|
2
11
|
/**
|
|
3
12
|
* Where a plugin screen is being rendered (S280, spec D7). Every slot kind
|
|
4
13
|
* hands its view this one context instead of props, so a view keeps taking
|
|
@@ -12,6 +21,9 @@ import { type ReactNode } from "react";
|
|
|
12
21
|
* - `kind: "rail"`: an entry the plugin adds to a built-in section's rail
|
|
13
22
|
* (content, media, settings, users). `sectionId` is null, because the
|
|
14
23
|
* section is not the plugin's; `entryId` is the entry's id.
|
|
24
|
+
* - `kind: "widget"`: a dashboard widget on the admin's Home page (S313b).
|
|
25
|
+
* `widgetId` is the widget's id; `sectionId` and `entryId` are null,
|
|
26
|
+
* because a widget belongs to no section.
|
|
15
27
|
*/
|
|
16
28
|
export interface PluginScreenContext {
|
|
17
29
|
pluginId: string;
|
|
@@ -19,22 +31,51 @@ export interface PluginScreenContext {
|
|
|
19
31
|
kind: "section" | "sectionRail" | "rail";
|
|
20
32
|
sectionId: string | null;
|
|
21
33
|
entryId: string | null;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "widget";
|
|
36
|
+
sectionId: null;
|
|
37
|
+
entryId: null;
|
|
38
|
+
widgetId: string;
|
|
22
39
|
};
|
|
23
|
-
/** The admin's active language, for
|
|
40
|
+
/** The admin's active language, for formatting dates and numbers. A
|
|
41
|
+
* screen's words come from `t`. */
|
|
24
42
|
locale: string;
|
|
43
|
+
/** The plugin's own strings in the admin's language (S290). */
|
|
44
|
+
t: PluginTranslate;
|
|
25
45
|
/**
|
|
26
46
|
* Navigates within the plugin's own section (kind section/sectionRail):
|
|
27
47
|
* pass the id of a rail entry that section declares, or null for the
|
|
28
48
|
* section's landing page. Anything else (a path such as `..`, another
|
|
29
49
|
* plugin's URL, an id the section's rail does not declare) does nothing,
|
|
30
50
|
* with a console warning in development. Always a no-op for a built-in
|
|
31
|
-
* rail entry, whose
|
|
51
|
+
* rail entry and for a dashboard widget, whose place is not the plugin's
|
|
52
|
+
* to move; a widget's navigate also prints a console warning in
|
|
53
|
+
* development, naming the plugin and the target.
|
|
32
54
|
*/
|
|
33
55
|
navigate: (entryId: string | null) => void;
|
|
34
56
|
}
|
|
35
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Supplied by the host around any view that reads the plugin's own strings
|
|
59
|
+
* (S291): a plugin screen, where PluginScreenProvider renders it with the
|
|
60
|
+
* screen's `t`, and a data type's views, where the admin renders it with
|
|
61
|
+
* the owning plugin's translator. In a test, `(key) => key` prints the keys.
|
|
62
|
+
*/
|
|
63
|
+
export declare function PluginTranslateProvider({ t, children }: {
|
|
64
|
+
t: PluginTranslate;
|
|
65
|
+
children: ReactNode;
|
|
66
|
+
}): import("react").JSX.Element;
|
|
67
|
+
/** Supplied by the host around a plugin screen's view. It also supplies
|
|
68
|
+
* usePluginTranslate() with the screen's own `t` (S291), so in a screen the
|
|
69
|
+
* two are one function. */
|
|
36
70
|
export declare function PluginScreenProvider({ value, children }: {
|
|
37
71
|
value: PluginScreenContext;
|
|
38
72
|
children: ReactNode;
|
|
39
73
|
}): import("react").JSX.Element;
|
|
40
74
|
export declare function usePluginScreen(): PluginScreenContext;
|
|
75
|
+
/**
|
|
76
|
+
* The plugin's own strings in the admin's language (S291), for a view with
|
|
77
|
+
* no usePluginScreen(): a data type's views (input, readOnly, settings,
|
|
78
|
+
* preview). Inside a plugin screen it returns the screen's own `t`. Outside
|
|
79
|
+
* a PluginTranslateProvider it is a host wiring bug, so it throws.
|
|
80
|
+
*/
|
|
81
|
+
export declare function usePluginTranslate(): PluginTranslate;
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
3
|
const PluginScreenReactContext = createContext(null);
|
|
4
|
-
|
|
4
|
+
const PluginTranslateReactContext = createContext(null);
|
|
5
|
+
/**
|
|
6
|
+
* Supplied by the host around any view that reads the plugin's own strings
|
|
7
|
+
* (S291): a plugin screen, where PluginScreenProvider renders it with the
|
|
8
|
+
* screen's `t`, and a data type's views, where the admin renders it with
|
|
9
|
+
* the owning plugin's translator. In a test, `(key) => key` prints the keys.
|
|
10
|
+
*/
|
|
11
|
+
export function PluginTranslateProvider({ t, children }) {
|
|
12
|
+
return _jsx(PluginTranslateReactContext.Provider, { value: t, children: children });
|
|
13
|
+
}
|
|
14
|
+
/** Supplied by the host around a plugin screen's view. It also supplies
|
|
15
|
+
* usePluginTranslate() with the screen's own `t` (S291), so in a screen the
|
|
16
|
+
* two are one function. */
|
|
5
17
|
export function PluginScreenProvider({ value, children }) {
|
|
6
|
-
return _jsx(PluginScreenReactContext.Provider, { value: value, children: children });
|
|
18
|
+
return (_jsx(PluginScreenReactContext.Provider, { value: value, children: _jsx(PluginTranslateProvider, { t: value.t, children: children }) }));
|
|
7
19
|
}
|
|
8
20
|
// A screen calling this outside a host-rendered PluginScreenProvider is a
|
|
9
21
|
// host wiring bug, so it throws, the same as usePluginApi.
|
|
@@ -14,3 +26,16 @@ export function usePluginScreen() {
|
|
|
14
26
|
}
|
|
15
27
|
return ctx;
|
|
16
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The plugin's own strings in the admin's language (S291), for a view with
|
|
31
|
+
* no usePluginScreen(): a data type's views (input, readOnly, settings,
|
|
32
|
+
* preview). Inside a plugin screen it returns the screen's own `t`. Outside
|
|
33
|
+
* a PluginTranslateProvider it is a host wiring bug, so it throws.
|
|
34
|
+
*/
|
|
35
|
+
export function usePluginTranslate() {
|
|
36
|
+
const t = useContext(PluginTranslateReactContext);
|
|
37
|
+
if (!t) {
|
|
38
|
+
throw new Error("usePluginTranslate must be called from a view rendered inside a PluginTranslateProvider");
|
|
39
|
+
}
|
|
40
|
+
return t;
|
|
41
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PluginFetch } from "./plugin-context.js";
|
|
2
|
+
/** A paged listing read to its end, or as far as the cap let it. */
|
|
3
|
+
export interface ListingPages<T> {
|
|
4
|
+
items: T[];
|
|
5
|
+
/** false when the page cap stopped the read with a cursor still pending: `items` is then a subset of the listing. */
|
|
6
|
+
complete: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ReadAllPagesOptions {
|
|
9
|
+
/** The key of the page's array: "items" for most listings, "folders" for the media folder list. */
|
|
10
|
+
itemKey?: string;
|
|
11
|
+
/** The page size asked of the server (default 100). */
|
|
12
|
+
limit?: number;
|
|
13
|
+
/** The most pages read before the read stops incomplete (default 20). */
|
|
14
|
+
cap?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Every page of a cursor-paginated listing, up to the cap. The listings a view reads this way are small, admin-only
|
|
18
|
+
* and read once when it mounts. They answer `{ <itemKey>: [...], nextCursor }` over the same `{ cursor, limit }` query.
|
|
19
|
+
* This is the helper image-view.tsx held privately since S234d, generalised to the page's item key
|
|
20
|
+
* (2026-10-17-s302-the-admin-moves-onto-the-management-api-design.md 3.8) so the media picker's folder list and the
|
|
21
|
+
* image view's rendition list follow nextCursor too.
|
|
22
|
+
*/
|
|
23
|
+
export declare function readAllPages<T>(fetchApi: PluginFetch, path: string, what: string, options?: ReadAllPagesOptions): Promise<ListingPages<T>>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every page of a cursor-paginated listing, up to the cap. The listings a view reads this way are small, admin-only
|
|
3
|
+
* and read once when it mounts. They answer `{ <itemKey>: [...], nextCursor }` over the same `{ cursor, limit }` query.
|
|
4
|
+
* This is the helper image-view.tsx held privately since S234d, generalised to the page's item key
|
|
5
|
+
* (2026-10-17-s302-the-admin-moves-onto-the-management-api-design.md 3.8) so the media picker's folder list and the
|
|
6
|
+
* image view's rendition list follow nextCursor too.
|
|
7
|
+
*/
|
|
8
|
+
export async function readAllPages(fetchApi, path, what, options = {}) {
|
|
9
|
+
const { itemKey = "items", limit = 100, cap = 20 } = options;
|
|
10
|
+
const all = [];
|
|
11
|
+
let cursor = null;
|
|
12
|
+
for (let page = 0; page < cap; page += 1) {
|
|
13
|
+
const params = new URLSearchParams();
|
|
14
|
+
params.set("limit", String(limit));
|
|
15
|
+
if (cursor)
|
|
16
|
+
params.set("cursor", cursor);
|
|
17
|
+
const response = await fetchApi(`${path}?${params.toString()}`);
|
|
18
|
+
if (!response.ok)
|
|
19
|
+
throw new Error(`Failed to load ${what} (${response.status})`);
|
|
20
|
+
const body = (await response.json());
|
|
21
|
+
const items = body[itemKey];
|
|
22
|
+
if (!Array.isArray(items))
|
|
23
|
+
throw new Error(`Failed to load ${what} (unexpected answer)`);
|
|
24
|
+
all.push(...items);
|
|
25
|
+
cursor = typeof body.nextCursor === "string" ? body.nextCursor : null;
|
|
26
|
+
if (cursor === null)
|
|
27
|
+
return { items: all, complete: true };
|
|
28
|
+
}
|
|
29
|
+
return { items: all, complete: false };
|
|
30
|
+
}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { Selection } from "@tiptap/pm/state";
|
|
4
4
|
import { Button, Dialog, DialogCloseButton, DialogContent, DialogFooter, DialogHeader, DialogTitle, Input, PropertyField, Switch, } from "@kardalum/ui";
|
|
5
|
-
import { usePluginApi } from "../plugin-context.js";
|
|
5
|
+
import { MANAGE_API, usePluginApi } from "../plugin-context.js";
|
|
6
6
|
import { MediaPicker } from "../media/media-picker.js";
|
|
7
7
|
import { useBlockListings } from "./insert-menu.js";
|
|
8
8
|
function useMediaParamPreview(mediaId) {
|
|
@@ -16,7 +16,7 @@ function useMediaParamPreview(mediaId) {
|
|
|
16
16
|
}
|
|
17
17
|
let cancelled = false;
|
|
18
18
|
setLoading(true);
|
|
19
|
-
fetchApi(
|
|
19
|
+
fetchApi(`${MANAGE_API}/media/${mediaId}`)
|
|
20
20
|
.then(async (response) => {
|
|
21
21
|
if (!response.ok)
|
|
22
22
|
throw new Error(`Failed to load media (${response.status})`);
|
|
@@ -161,10 +161,10 @@ export function BlockPanel({ editor, pos, partial, params }) {
|
|
|
161
161
|
// editor, so this is a real guard, not defensive-for-its-own-sake.
|
|
162
162
|
if (!editor.isDestroyed)
|
|
163
163
|
editor.commands.focus();
|
|
164
|
-
}, className: "flex max-h-[80vh] max-w-sm flex-col gap-0 p-0", children: [_jsxs(DialogHeader, { className: "border-b border-border-default px-4 py-3", children: [_jsxs("div", { className: "flex flex-col gap-
|
|
164
|
+
}, className: "flex max-h-[80vh] max-w-sm flex-col gap-0 p-0", children: [_jsxs(DialogHeader, { className: "border-b border-border-default px-4 py-3", children: [_jsxs("div", { className: "flex flex-col gap-px", children: [_jsx(DialogTitle, { children: listing?.name ?? partial }), _jsxs("span", { className: "font-mono text-xs text-text-tertiary", children: ["partial: ", partial, ".liquid"] })] }), _jsx(DialogCloseButton, { "aria-label": "Close" })] }), _jsxs("div", { className: "flex flex-1 flex-col gap-4 overflow-y-auto p-4", children: [_jsx(BlockParamFields, { listing: listing, listingsError: listingsError, params: params, onChange: updateParam }), _jsxs("p", { className: "rounded-md border border-border-default bg-background-subtle p-2 text-xs text-text-secondary", children: [_jsx("b", { className: "font-semibold text-text-primary", children: "Live preview." }), " This block is rendered by your own template on the server. What you see on the page is exactly what visitors will get."] })] }), _jsxs(DialogFooter, { className: "mt-0 justify-start border-t border-border-default p-4", children: [_jsx(Button, { type: "button", variant: "ghost", className: "text-danger-600 hover:text-danger-700", onClick: handleRemove, children: "Remove block" }), _jsx(Button, { type: "button", className: "ms-auto", onClick: moveSelectionPastBlock, children: "Done" })] })] }) }));
|
|
165
165
|
}
|
|
166
166
|
// The chip's "preview ⤢" affordance (S197 mockup screen 3): fetches
|
|
167
|
-
// POST /api/render/block for the block's CURRENT params and shows the
|
|
167
|
+
// POST /api/manage/v1/render/block for the block's CURRENT params and shows the
|
|
168
168
|
// returned HTML in a sandboxed iframe — sandbox="" (no tokens granted) so
|
|
169
169
|
// arbitrary template markup can never run script in the admin UI.
|
|
170
170
|
// Position is computed from a live viewport rect (getBoundingClientRect),
|
|
@@ -180,7 +180,7 @@ export function BlockPreviewPopover({ partial, params, anchorRect, onClose }) {
|
|
|
180
180
|
let cancelled = false;
|
|
181
181
|
setLoading(true);
|
|
182
182
|
setError(null);
|
|
183
|
-
fetchApi(
|
|
183
|
+
fetchApi(`${MANAGE_API}/render/block`, {
|
|
184
184
|
method: "POST",
|
|
185
185
|
headers: { "Content-Type": "application/json" },
|
|
186
186
|
body: JSON.stringify({ partial, params }),
|
|
@@ -228,5 +228,5 @@ export function BlockPreviewPopover({ partial, params, anchorRect, onClose }) {
|
|
|
228
228
|
if (event.key === "Escape")
|
|
229
229
|
onClose();
|
|
230
230
|
}
|
|
231
|
-
return (_jsxs("div", { ref: popoverRef, role: "dialog", "aria-label": `Preview: ${partial}`, onKeyDown: handleKeyDownCapture, style: { position: "fixed", top: anchorRect.bottom + 4, left: anchorRect.left }, className: "z-20 w-
|
|
231
|
+
return (_jsxs("div", { ref: popoverRef, role: "dialog", "aria-label": `Preview: ${partial}`, onKeyDown: handleKeyDownCapture, style: { position: "fixed", top: anchorRect.bottom + 4, left: anchorRect.left }, className: "z-20 w-72 rounded-md border border-border-default bg-background-elevated p-2 shadow-xl", children: [loading && _jsx("p", { className: "text-xs text-text-secondary", children: "Loading preview\u2026" }), error && _jsx("p", { className: "text-xs text-danger-600", children: error }), !loading && !error && (_jsx("iframe", { title: `Preview: ${partial}`, srcDoc: html ?? "", sandbox: "", className: "h-44 w-full rounded-sm border border-border-subtle bg-background-elevated" }))] }));
|
|
232
232
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { cn } from "@kardalum/ui";
|
|
4
|
-
import { usePluginApi } from "../plugin-context.js";
|
|
4
|
+
import { MANAGE_API, usePluginApi } from "../plugin-context.js";
|
|
5
5
|
// The value a freshly inserted block's params start with, before the user
|
|
6
6
|
// has touched anything in the param panel (S197 Task 3 brief, "Inserting a
|
|
7
7
|
// block": defaults: text/textarea "", number 0, boolean false, image
|
|
@@ -30,7 +30,7 @@ export function defaultBlockParams(params) {
|
|
|
30
30
|
}
|
|
31
31
|
return defaults;
|
|
32
32
|
}
|
|
33
|
-
// GET /api/render/blocks (S197 Task 6 ships this endpoint
|
|
33
|
+
// GET /api/manage/v1/render/blocks (S197 Task 6 ships this endpoint, until then
|
|
34
34
|
// every call 404s, and this hook surfaces that as `error`, same as
|
|
35
35
|
// MediaPicker's own fetch-failure handling, rather than swallowing it into
|
|
36
36
|
// a silent empty list). Shared between the insert menu (BlockInsertMenu,
|
|
@@ -46,7 +46,7 @@ export function useBlockListings() {
|
|
|
46
46
|
let cancelled = false;
|
|
47
47
|
setLoading(true);
|
|
48
48
|
setError(null);
|
|
49
|
-
fetchApi(
|
|
49
|
+
fetchApi(`${MANAGE_API}/render/blocks`)
|
|
50
50
|
.then(async (response) => {
|
|
51
51
|
if (!response.ok)
|
|
52
52
|
throw new Error(`Failed to load blocks (${response.status})`);
|
|
@@ -137,6 +137,6 @@ export function BlockInsertMenu({ onInsert, onClose }) {
|
|
|
137
137
|
const selected = index === activeIndex;
|
|
138
138
|
return (_jsxs("div", { ref: (el) => {
|
|
139
139
|
optionRefs.current[index] = el;
|
|
140
|
-
}, role: "option", "aria-selected": selected, tabIndex: selected ? 0 : -1, onFocus: () => setActiveIndex(index), onClick: () => commit(index), className: cn("flex cursor-pointer items-start gap-2 rounded-sm px-2 py-1
|
|
140
|
+
}, role: "option", "aria-selected": selected, tabIndex: selected ? 0 : -1, onFocus: () => setActiveIndex(index), onClick: () => commit(index), className: cn("flex cursor-pointer items-start gap-2 rounded-sm px-2 py-1 text-sm outline-none", "focus-visible:ring-2 focus-visible:ring-primary-600", selected ? "bg-primary-100" : "text-text-primary hover:bg-background-hover"), children: [_jsx("span", { "aria-hidden": "true", className: "mt-px text-text-secondary", children: "\u25EB" }), _jsxs("span", { className: "flex flex-col", children: [_jsx("span", { className: "font-medium text-text-primary", children: listing.name }), _jsxs("span", { className: "text-xs text-text-secondary", children: [listing.alias, ".liquid", listing.params.length > 0 ? ` · ${listing.params.map((param) => param.key).join(", ")}` : ""] })] })] }, listing.alias));
|
|
141
141
|
})] }));
|
|
142
142
|
}
|
|
@@ -10,10 +10,10 @@ export function StyleListbox({ styles, loading, activeStyleKey, onSelect, onClea
|
|
|
10
10
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
11
11
|
const optionRefs = useRef([]);
|
|
12
12
|
if (loading) {
|
|
13
|
-
return (_jsx("div", { role: "listbox", "aria-label": "Text styles", className: "min-w-
|
|
13
|
+
return (_jsx("div", { role: "listbox", "aria-label": "Text styles", className: "min-w-44 p-2 text-xs text-text-secondary", children: "Loading\u2026" }));
|
|
14
14
|
}
|
|
15
15
|
if (styles.length === 0) {
|
|
16
|
-
return (_jsx("div", { role: "listbox", "aria-label": "Text styles", className: "min-w-
|
|
16
|
+
return (_jsx("div", { role: "listbox", "aria-label": "Text styles", className: "min-w-44 p-2 text-xs text-text-secondary", children: "No theme styles declared" }));
|
|
17
17
|
}
|
|
18
18
|
function focusIndex(index) {
|
|
19
19
|
setActiveIndex(index);
|
|
@@ -60,10 +60,10 @@ export function StyleListbox({ styles, loading, activeStyleKey, onSelect, onClea
|
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
return (_jsx("div", { role: "listbox", "aria-label": "Text styles", onKeyDown: handleKeyDown, className: "min-w-
|
|
63
|
+
return (_jsx("div", { role: "listbox", "aria-label": "Text styles", onKeyDown: handleKeyDown, className: "min-w-44 p-1", children: options.map((option, index) => {
|
|
64
64
|
const selected = option.kind === "style" && option.style.key === activeStyleKey;
|
|
65
65
|
return (_jsx("div", { ref: (el) => {
|
|
66
66
|
optionRefs.current[index] = el;
|
|
67
|
-
}, role: "option", "aria-selected": selected, tabIndex: index === activeIndex ? 0 : -1, onFocus: () => setActiveIndex(index), onClick: () => commit(index), className: cn("cursor-pointer rounded-sm px-2 py-1
|
|
67
|
+
}, role: "option", "aria-selected": selected, tabIndex: index === activeIndex ? 0 : -1, onFocus: () => setActiveIndex(index), onClick: () => commit(index), className: cn("cursor-pointer rounded-sm px-2 py-1 text-sm outline-none", "focus-visible:ring-2 focus-visible:ring-primary-600", selected ? "bg-primary-100 text-primary-800" : "text-text-primary hover:bg-background-hover", option.kind === "clear" && "mt-1 border-t border-border-default pt-1 text-text-secondary"), children: option.kind === "style" ? option.style.label : "Clear style" }, option.kind === "style" ? option.style.key : "__clear__"));
|
|
68
68
|
}) }));
|
|
69
69
|
}
|
package/dist/tokens/tokens.css
CHANGED
package/dist/tokens/tokens.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,7 +3,7 @@ import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react"
|
|
|
3
3
|
import { CONTENT_LIST_DEFAULT_SETTINGS, } from "@kardalum/api-schemas";
|
|
4
4
|
import { Badge, Button, Input } from "@kardalum/ui";
|
|
5
5
|
import { Lock } from "lucide-react";
|
|
6
|
-
import { useContentHost, usePluginApi, usePluginSettings, } from "../plugin-context.js";
|
|
6
|
+
import { MANAGE_API, useContentHost, usePluginApi, usePluginSettings, } from "../plugin-context.js";
|
|
7
7
|
/** Column headers for the six built-in row properties. */
|
|
8
8
|
export const CONTENT_LIST_PROPERTY_LABELS = {
|
|
9
9
|
name: "Name",
|
|
@@ -160,7 +160,7 @@ function ContentListTable({ canCreate = false }) {
|
|
|
160
160
|
params.set("name", appliedSearch);
|
|
161
161
|
if (cursor)
|
|
162
162
|
params.set("cursor", cursor);
|
|
163
|
-
const response = await fetchApi(
|
|
163
|
+
const response = await fetchApi(`${MANAGE_API}/content/${nodeId}/list?${params.toString()}`);
|
|
164
164
|
if (!response.ok)
|
|
165
165
|
throw new Error(`Request failed (${response.status})`);
|
|
166
166
|
const body = (await response.json());
|
package/dist/views/html-view.js
CHANGED
|
@@ -15,7 +15,7 @@ const HtmlCodeEditorLazy = lazy(() => import("./html-code-editor.js").then((modu
|
|
|
15
15
|
// package's views deliberately hardcode English strings today, see
|
|
16
16
|
// built-ins.tsx's TextReadOnlyView/ImageInputView precedent).
|
|
17
17
|
function HtmlEditorFallback() {
|
|
18
|
-
return (_jsx("div", { role: "status", "aria-label": "Loading code editor\u2026", children: _jsx("div", { "aria-hidden": "true", className: "h-
|
|
18
|
+
return (_jsx("div", { role: "status", "aria-label": "Loading code editor\u2026", children: _jsx("div", { "aria-hidden": "true", className: "h-44 w-full animate-pulse rounded-md border border-border-default bg-background-subtle" }) }));
|
|
19
19
|
}
|
|
20
20
|
// The Trusted setting has no bearing on how this field is EDITED (both
|
|
21
21
|
// modes get the same CodeMirror surface) — only on how it's RENDERED
|
package/dist/views/image-view.js
CHANGED
|
@@ -4,21 +4,22 @@ import { CROP_EDITOR_ID, CropSettingsSchema, renditionName, renditionShape, THUM
|
|
|
4
4
|
import { Button, cn, Input, PropertyField, usePropertyFieldControl } from "@kardalum/ui";
|
|
5
5
|
import { MediaPicker } from "../media/media-picker.js";
|
|
6
6
|
import { uploadFailureMessage } from "../media/upload-error.js";
|
|
7
|
-
import { usePluginApi, usePluginSettings, usePluginSettingsValue, usePluginValue, } from "../plugin-context.js";
|
|
7
|
+
import { MANAGE_API, usePluginApi, usePluginSettings, usePluginSettingsValue, usePluginValue, } from "../plugin-context.js";
|
|
8
|
+
import { readAllPages } from "../read-all-pages.js";
|
|
8
9
|
// downloadUrl is the stable app path for a public item (S186c §1/§3) but
|
|
9
10
|
// carries a freshly minted, short-lived `?token=` for a private one —
|
|
10
|
-
// never persisted; refetch GET /api/media/:id whenever the field's value
|
|
11
|
+
// never persisted; refetch GET /api/manage/v1/media/:id whenever the field's value
|
|
11
12
|
// (media id) changes rather than caching one, so a private item's
|
|
12
13
|
// preview always has a live token.
|
|
13
14
|
//
|
|
14
|
-
// The crop is read from GET /api/media/:id/renditions, and only when the
|
|
15
|
+
// The crop is read from GET /api/manage/v1/media/:id/renditions, and only when the
|
|
15
16
|
// field asks for one. That listing is the renditions of the item's
|
|
16
17
|
// CURRENT version with the version beside them, which is the same
|
|
17
18
|
// question the renderer answers at read time, so what this view names is
|
|
18
19
|
// what the page will really serve. It is a second request, deliberately:
|
|
19
20
|
// the item response says nothing about crops, and naming a file the
|
|
20
21
|
// picture may not have is worse than one more read on a field that has
|
|
21
|
-
// just changed.
|
|
22
|
+
// just changed. The listing is paged (200 at a time), so every page is read before a miss means "none".
|
|
22
23
|
function useMediaPreview(mediaId, rendition) {
|
|
23
24
|
const fetchApi = usePluginApi();
|
|
24
25
|
const [preview, setPreview] = useState(null);
|
|
@@ -33,7 +34,7 @@ function useMediaPreview(mediaId, rendition) {
|
|
|
33
34
|
let cancelled = false;
|
|
34
35
|
setLoading(true);
|
|
35
36
|
setError(null);
|
|
36
|
-
const item = fetchApi(
|
|
37
|
+
const item = fetchApi(`${MANAGE_API}/media/${mediaId}`).then(async (response) => {
|
|
37
38
|
if (!response.ok)
|
|
38
39
|
throw new Error(`Failed to load media (${response.status})`);
|
|
39
40
|
return (await response.json());
|
|
@@ -47,13 +48,16 @@ function useMediaPreview(mediaId, rendition) {
|
|
|
47
48
|
// here (see ResolvedCut).
|
|
48
49
|
const cut = rendition === null
|
|
49
50
|
? Promise.resolve({ state: "unknown" })
|
|
50
|
-
: fetchApi
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const found =
|
|
56
|
-
|
|
51
|
+
: readAllPages(fetchApi, `${MANAGE_API}/media/${mediaId}/renditions`, "renditions", {
|
|
52
|
+
limit: 200,
|
|
53
|
+
cap: 50,
|
|
54
|
+
})
|
|
55
|
+
.then(({ items, complete }) => {
|
|
56
|
+
const found = items.find((item) => item.name === rendition);
|
|
57
|
+
if (found)
|
|
58
|
+
return { state: "found", name: found.name, filename: found.filename };
|
|
59
|
+
// A miss on a listing that was not read to its end says nothing about the crop: "could not ask", not "none".
|
|
60
|
+
return complete ? { state: "absent" } : { state: "unknown" };
|
|
57
61
|
})
|
|
58
62
|
.catch(() => ({ state: "unknown" }));
|
|
59
63
|
Promise.all([item, cut])
|
|
@@ -163,7 +167,7 @@ export function ImageInputView() {
|
|
|
163
167
|
try {
|
|
164
168
|
const formData = new FormData();
|
|
165
169
|
formData.append("file", file);
|
|
166
|
-
const response = await fetchApi(
|
|
170
|
+
const response = await fetchApi(`${MANAGE_API}/media`, { method: "POST", body: formData });
|
|
167
171
|
// The server's own sentence, not a status code: it may be refusing
|
|
168
172
|
// these bytes for the file upload type's limit, which this field
|
|
169
173
|
// knows nothing about, and that refusal names the limit and the
|
|
@@ -218,31 +222,12 @@ const TYPE_PAGE_LIMIT = 100;
|
|
|
218
222
|
const TYPE_PAGE_CAP = 20;
|
|
219
223
|
const SELECT_CLASS = "h-10 w-full rounded-md border border-border-strong bg-background-elevated px-2 text-sm text-text-primary " +
|
|
220
224
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600";
|
|
221
|
-
/**
|
|
222
|
-
* listings are small, admin-only and read once when this view mounts.
|
|
225
|
+
/** A listing read to its end, or as far as the cap allowed.
|
|
223
226
|
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
|
|
228
|
-
const all = [];
|
|
229
|
-
let cursor = null;
|
|
230
|
-
for (let page = 0; page < TYPE_PAGE_CAP; page += 1) {
|
|
231
|
-
const params = new URLSearchParams();
|
|
232
|
-
params.set("limit", String(TYPE_PAGE_LIMIT));
|
|
233
|
-
if (cursor)
|
|
234
|
-
params.set("cursor", cursor);
|
|
235
|
-
const response = await fetchApi(`${path}?${params.toString()}`);
|
|
236
|
-
if (!response.ok)
|
|
237
|
-
throw new Error(`Failed to load ${what} (${response.status})`);
|
|
238
|
-
const body = (await response.json());
|
|
239
|
-
all.push(...body.items);
|
|
240
|
-
cursor = body.nextCursor;
|
|
241
|
-
if (cursor === null)
|
|
242
|
-
return { items: all, complete: true };
|
|
243
|
-
}
|
|
244
|
-
return { items: all, complete: false };
|
|
245
|
-
}
|
|
227
|
+
* `complete` is false when the cursor was still running when the cap was
|
|
228
|
+
* reached. The rows in hand are real either way; what a short list cannot
|
|
229
|
+
* support is a statement about what is NOT in it, which is the one thing
|
|
230
|
+
* this view says about a stored crop it did not find. */
|
|
246
231
|
/** The rendition name a data type produces, or null when it is not a
|
|
247
232
|
* rendition editor at all or its settings do not parse.
|
|
248
233
|
*
|
|
@@ -301,8 +286,8 @@ function useRenditionChoices() {
|
|
|
301
286
|
setError(null);
|
|
302
287
|
setComplete(true);
|
|
303
288
|
Promise.all([
|
|
304
|
-
readAllPages(fetchApi,
|
|
305
|
-
readAllPages(fetchApi,
|
|
289
|
+
readAllPages(fetchApi, `${MANAGE_API}/document-types`, "document types", { limit: TYPE_PAGE_LIMIT, cap: TYPE_PAGE_CAP }),
|
|
290
|
+
readAllPages(fetchApi, `${MANAGE_API}/data-types`, "data types", { limit: TYPE_PAGE_LIMIT, cap: TYPE_PAGE_CAP }),
|
|
306
291
|
])
|
|
307
292
|
.then(([documentTypes, dataTypes]) => {
|
|
308
293
|
if (cancelled)
|
|
@@ -4,7 +4,7 @@ import { EditorContent, useEditor } from "@tiptap/react";
|
|
|
4
4
|
import { NodeSelection } from "@tiptap/pm/state";
|
|
5
5
|
import { Code2, Image as ImageIcon, Link as LinkIcon, List as ListIcon, Quote as QuoteIcon } from "lucide-react";
|
|
6
6
|
import { cn, usePropertyFieldControl } from "@kardalum/ui";
|
|
7
|
-
import { usePluginApi, usePluginValue } from "../plugin-context.js";
|
|
7
|
+
import { MANAGE_API, usePluginApi, usePluginValue } from "../plugin-context.js";
|
|
8
8
|
import { buildRichtextExtensions } from "../richtext/extensions.js";
|
|
9
9
|
import { MediaPicker } from "../media/media-picker.js";
|
|
10
10
|
import { BlockInsertMenu, defaultBlockParams } from "../richtext/insert-menu.js";
|
|
@@ -48,7 +48,7 @@ function useTextStyles() {
|
|
|
48
48
|
useEffect(() => {
|
|
49
49
|
let cancelled = false;
|
|
50
50
|
setLoading(true);
|
|
51
|
-
fetchApi(
|
|
51
|
+
fetchApi(`${MANAGE_API}/render/text-styles`)
|
|
52
52
|
.then(async (response) => {
|
|
53
53
|
// The endpoint doesn't exist yet (a later task ships it) — a 404,
|
|
54
54
|
// any other error status, and a genuinely empty declared list all
|
|
@@ -154,7 +154,7 @@ function LinkPopover({ initialHref, hasLink, onApply, onRemove, onClose }) {
|
|
|
154
154
|
if (href.trim())
|
|
155
155
|
onApply(href.trim());
|
|
156
156
|
}
|
|
157
|
-
}, className: "mb-2 w-full rounded-md border border-border-default bg-background-elevated px-2 py-1 text-sm text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600" }), _jsxs("div", { className: "flex justify-end gap-2", children: [hasLink && (_jsx("button", { type: "button", onClick: onRemove, className: "rounded-md px-2 py-1 text-xs text-danger-600 hover:bg-background-hover", children: "Remove link" })), _jsx("button", { type: "button", disabled: !href.trim(), onClick: () => onApply(href.trim()), className: "rounded-md bg-primary-600 px-2 py-1 text-xs font-medium text-
|
|
157
|
+
}, className: "mb-2 w-full rounded-md border border-border-default bg-background-elevated px-2 py-1 text-sm text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600" }), _jsxs("div", { className: "flex justify-end gap-2", children: [hasLink && (_jsx("button", { type: "button", onClick: onRemove, className: "rounded-md px-2 py-1 text-xs text-danger-600 hover:bg-background-hover", children: "Remove link" })), _jsx("button", { type: "button", disabled: !href.trim(), onClick: () => onApply(href.trim()), className: "rounded-md bg-primary-600 px-2 py-1 text-xs font-medium text-text-inverse hover:bg-primary-700 disabled:opacity-50", children: "Apply" })] })] }));
|
|
158
158
|
}
|
|
159
159
|
// S197 Task 12: bubbles up so a mount that HAS routing (content-editor.tsx,
|
|
160
160
|
// admin-ui) can navigate to /content/:id/edit-on-page — same "plain DOM
|
|
@@ -3,3 +3,15 @@ export declare const ApiErrorSchema: z.ZodObject<{
|
|
|
3
3
|
message: z.ZodString;
|
|
4
4
|
}, z.core.$strip>;
|
|
5
5
|
export type ApiError = z.infer<typeof ApiErrorSchema>;
|
|
6
|
+
export declare const BodyTooLargeErrorSchema: z.ZodObject<{
|
|
7
|
+
statusCode: z.ZodLiteral<413>;
|
|
8
|
+
code: z.ZodLiteral<"FST_ERR_CTP_BODY_TOO_LARGE">;
|
|
9
|
+
error: z.ZodString;
|
|
10
|
+
message: z.ZodString;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export type BodyTooLargeError = z.infer<typeof BodyTooLargeErrorSchema>;
|
|
13
|
+
export declare const RateLimitErrorSchema: z.ZodObject<{
|
|
14
|
+
statusCode: z.ZodLiteral<429>;
|
|
15
|
+
message: z.ZodString;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type RateLimitError = z.infer<typeof RateLimitErrorSchema>;
|
|
@@ -4,3 +4,22 @@ import { z } from "zod";
|
|
|
4
4
|
export const ApiErrorSchema = z.object({
|
|
5
5
|
message: z.string(),
|
|
6
6
|
});
|
|
7
|
+
// S297: the two answers the host gives every plugin route besides its own
|
|
8
|
+
// error shape, documented in the plugin operations
|
|
9
|
+
// (apps/server/src/docs/plugin-routes-openapi.ts) and never part of the
|
|
10
|
+
// dispatch routes' response map, so the real bodies are not rewritten.
|
|
11
|
+
// Both match what the server sends: the 413 is Fastify's own error body for a
|
|
12
|
+
// request past bodyLimit, the 429 is the rate limiter's errorResponseBuilder
|
|
13
|
+
// return (auth/rate-limit.ts), which carries no `error` field. The
|
|
14
|
+
// integration cases that provoke each status parse the real body with these.
|
|
15
|
+
export const BodyTooLargeErrorSchema = z.object({
|
|
16
|
+
statusCode: z.literal(413),
|
|
17
|
+
code: z.literal("FST_ERR_CTP_BODY_TOO_LARGE"),
|
|
18
|
+
// Node's STATUS_CODES text for 413, which the Node version owns.
|
|
19
|
+
error: z.string(),
|
|
20
|
+
message: z.string(),
|
|
21
|
+
});
|
|
22
|
+
export const RateLimitErrorSchema = z.object({
|
|
23
|
+
statusCode: z.literal(429),
|
|
24
|
+
message: z.string(),
|
|
25
|
+
});
|