@kardalum/plugin-sdk 0.18.0 → 0.19.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 +42 -0
- package/README.md +1 -1
- package/dist/assets/asset-picker.js +3 -3
- package/dist/built-in-serializers.js +1 -1
- package/dist/built-in-settings-schemas.js +4 -4
- package/dist/built-ins.js +10 -10
- package/dist/data-type-plugin.d.ts +2 -2
- package/dist/datatype-validation.d.ts +2 -2
- package/dist/datatype-validation.js +2 -2
- package/dist/define-plugin.d.ts +4 -4
- package/dist/define-plugin.js +5 -5
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -0
- package/dist/manifest-schema.js +7 -1
- package/dist/media/media-picker.js +4 -4
- package/dist/plugin-context.js +3 -3
- package/dist/register-built-ins.js +6 -6
- package/dist/registry.js +1 -1
- package/dist/richtext/block-panel.js +2 -2
- package/dist/richtext/extensions.js +7 -7
- package/dist/richtext/insert-menu.js +3 -3
- package/dist/richtext/style-listbox.js +1 -1
- package/dist/richtext/text-style-class.js +1 -1
- package/dist/simple-storage-value-provider.js +3 -3
- package/dist/structured-storage-types.d.ts +1 -1
- package/dist/structured-storage-types.js +2 -2
- package/dist/ui-entry.js +3 -3
- package/dist/views/asset-view.js +3 -3
- package/dist/views/date-range-view.js +5 -5
- package/dist/views/html-code-editor.js +2 -2
- package/dist/views/html-view.js +7 -7
- package/dist/views/image-view.js +4 -4
- package/dist/views/rich-text-view.js +4 -3
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +14 -8
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +3 -3
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +2 -2
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +2 -2
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +3 -3
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +90 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +14 -4
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +8 -8
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +11 -8
- package/node_modules/@kardalum/api-schemas/dist/index.js +6 -4
- package/node_modules/@kardalum/api-schemas/dist/listing-categories.schema.d.ts +46 -0
- package/node_modules/@kardalum/api-schemas/dist/listing-categories.schema.js +52 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +47 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +42 -8
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +9 -9
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +5 -5
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +1 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +24 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +39 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +3 -3
- package/node_modules/@kardalum/api-schemas/dist/render-editing.js +4 -4
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.d.ts +207 -0
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.js +147 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +17 -8
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +1 -1
- package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/build-css.js +2 -2
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +3 -3
- package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +2 -2
- package/node_modules/@kardalum/design-tokens/dist/theme-css.js +2 -2
- package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +2 -2
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +3 -3
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +3 -3
- package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/themes/light.js +1 -1
- package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +3 -3
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +5 -5
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/types.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +2 -1
- package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +2 -2
- package/node_modules/@kardalum/plugin-package/dist/envelope.js +2 -2
- package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +3 -3
- package/node_modules/@kardalum/plugin-package/dist/extract.js +9 -9
- package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/hash.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +2 -2
- package/node_modules/@kardalum/plugin-package/dist/package-contract.js +5 -5
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +8 -3
- package/node_modules/@kardalum/ui/dist/components/badge.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/button.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/dialog.js +49 -4
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +5 -1
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +18 -5
- package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +4 -4
- package/node_modules/@kardalum/ui/dist/components/input.js +6 -1
- package/node_modules/@kardalum/ui/dist/components/property-field.js +3 -3
- package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/sheet.js +12 -7
- package/node_modules/@kardalum/ui/dist/components/skeleton.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +3 -3
- package/node_modules/@kardalum/ui/dist/components/toast.js +4 -3
- package/node_modules/@kardalum/ui/dist/components/tooltip.d.ts +27 -0
- package/node_modules/@kardalum/ui/dist/components/tooltip.js +82 -0
- package/node_modules/@kardalum/ui/dist/components/truncated-text.d.ts +11 -0
- package/node_modules/@kardalum/ui/dist/components/truncated-text.js +94 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.js +2 -2
- package/node_modules/@kardalum/ui/dist/index.d.ts +3 -1
- package/node_modules/@kardalum/ui/dist/index.js +3 -1
- package/node_modules/@kardalum/ui/dist/lib/menu-host.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/lib/menu-host.js +17 -0
- package/node_modules/@kardalum/ui/package.json +8 -6
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,48 @@ Subpaths are noted per entry. `.` is the package index; `./manifest` is the
|
|
|
8
8
|
server-safe manifest contract subpath, which pulls in no React and no
|
|
9
9
|
`@kardalum/ui`.
|
|
10
10
|
|
|
11
|
+
## 0.19.0
|
|
12
|
+
|
|
13
|
+
Plugin views get the admin's tooltips: an icon-only button can name itself
|
|
14
|
+
on hover and focus, and a name cut off by its column shows in full. The
|
|
15
|
+
SDK's own pickers and rich text toolbar use them, and a bundle must now name
|
|
16
|
+
its members.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- `.`: `IconTooltip` (with `IconTooltipProps`), which wraps an icon-only
|
|
21
|
+
control and shows its `aria-label` as a tooltip, and `TruncatedText` (with
|
|
22
|
+
`TruncatedTextProps`), which renders text that truncates and shows the
|
|
23
|
+
whole text in a tooltip only when it is cut. The admin's
|
|
24
|
+
`TooltipProvider` sits above every mounted plugin view.
|
|
25
|
+
- `./ui`: everything `@kardalum/ui` gained comes through, so also
|
|
26
|
+
`Tooltip`, `TooltipContent`, `TooltipProvider`, `TooltipTrigger`,
|
|
27
|
+
`isTextCut` and `DropdownMenuContainer`.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- `.`: the rich text view's toolbar buttons show their names in a tooltip
|
|
32
|
+
instead of the browser's `title`, and the media picker, the asset picker,
|
|
33
|
+
the asset and image views and the rich text block panel show a cut-off
|
|
34
|
+
file or folder name in full through `TruncatedText`.
|
|
35
|
+
- `./manifest` and `.`: `contributions.bundledPlugins` must name at least
|
|
36
|
+
one member plugin id. Declaring members is what makes a plugin a bundle,
|
|
37
|
+
so an empty list is refused; a plugin that bundles none leaves the key
|
|
38
|
+
out.
|
|
39
|
+
|
|
40
|
+
### Tools
|
|
41
|
+
|
|
42
|
+
- `kardalum plugin build --out <dir>` refuses an output folder that is not
|
|
43
|
+
new, empty, a previous package or a folder holding a `remoteEntry` file,
|
|
44
|
+
and the default `kardalum-package` refuses a folder holding `.git`,
|
|
45
|
+
`package.json` or `node_modules`.
|
|
46
|
+
- `kardalum plugin validate` has a 30th check that warns when the
|
|
47
|
+
federation plugin's type declarations are on (`dts: false` is missing),
|
|
48
|
+
and build and pack drop the `@mf-types` files.
|
|
49
|
+
- A plugin whose migration rollback fails keeps the records of the
|
|
50
|
+
migrations still applied, and a later install or update treats them as
|
|
51
|
+
applied without running `up()` again.
|
|
52
|
+
|
|
11
53
|
## 0.18.0
|
|
12
54
|
|
|
13
55
|
Plugins can be sold on plans with a term they can read, and a plugin can call its
|
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ every operation.
|
|
|
73
73
|
## Docs
|
|
74
74
|
|
|
75
75
|
The plugin guide, the manifest reference and the storage reference are at
|
|
76
|
-
[dev.kardalum.com/docs](https://dev.kardalum.com/docs/v1/
|
|
76
|
+
[dev.kardalum.com/docs](https://dev.kardalum.com/docs/v1/plugins/build-a-plugin/).
|
|
77
77
|
|
|
78
78
|
## Support
|
|
79
79
|
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo, useRef, useState } from "react";
|
|
3
3
|
import { ChevronRight, Folder as FolderIcon } from "lucide-react";
|
|
4
4
|
import { assetPathAccepted, assetPathIsImage } from "@kardalum/api-schemas";
|
|
5
|
-
import { Button, cn, Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle } from "@kardalum/ui";
|
|
5
|
+
import { Button, cn, Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, TruncatedText } from "@kardalum/ui";
|
|
6
6
|
import { usePluginTranslate } from "../plugin-screen-context.js";
|
|
7
7
|
import { gridArrowStep } from "../grid-arrow-step.js";
|
|
8
8
|
import { assetBaseName, assetParent, normalizeStartFolder, useAssetThumbnail, useAssetTree } from "./asset-tree.js";
|
|
@@ -94,12 +94,12 @@ export function AssetPicker({ accepts, startFolder: rawStartFolder, currentPath
|
|
|
94
94
|
event.preventDefault();
|
|
95
95
|
opener.focus();
|
|
96
96
|
}
|
|
97
|
-
}, children: [_jsxs(SheetHeader, { className: "flex-col items-start gap-1", children: [_jsx(SheetTitle, { children: t("asset.pickerTitle") }), _jsx(SheetDescription, { children: t(accepts === "any" ? "asset.pickerAny" : "asset.pickerImages") })] }), _jsx("nav", { "aria-label": t("asset.location"), className: "shrink-0 border-b border-border-default px-4 py-2", children: _jsxs("ol", { className: "flex flex-wrap items-center gap-1 text-sm text-text-tertiary", children: [_jsx("li", { children: folder === "" ? (_jsx("span", { "aria-current": "page", className: "font-medium text-text-primary", children: t("asset.root") })) : (_jsx("button", { type: "button", onClick: () => openFolder(""), className: LINK_CLASS, children: t("asset.root") })) }), crumbs.map((crumb, index) => (_jsxs("li", { className: "flex min-w-0 items-center gap-1", children: [_jsx(ChevronRight, { "aria-hidden": "true", className: "size-3 shrink-0 rtl:rotate-180" }), index === crumbs.length - 1 ? (_jsx(
|
|
97
|
+
}, children: [_jsxs(SheetHeader, { className: "flex-col items-start gap-1", children: [_jsx(SheetTitle, { children: t("asset.pickerTitle") }), _jsx(SheetDescription, { children: t(accepts === "any" ? "asset.pickerAny" : "asset.pickerImages") })] }), _jsx("nav", { "aria-label": t("asset.location"), className: "shrink-0 border-b border-border-default px-4 py-2", children: _jsxs("ol", { className: "flex flex-wrap items-center gap-1 text-sm text-text-tertiary", children: [_jsx("li", { children: folder === "" ? (_jsx("span", { "aria-current": "page", className: "font-medium text-text-primary", children: t("asset.root") })) : (_jsx("button", { type: "button", onClick: () => openFolder(""), className: LINK_CLASS, children: t("asset.root") })) }), crumbs.map((crumb, index) => (_jsxs("li", { className: "flex min-w-0 items-center gap-1", children: [_jsx(ChevronRight, { "aria-hidden": "true", className: "size-3 shrink-0 rtl:rotate-180" }), index === crumbs.length - 1 ? (_jsx(TruncatedText, { "aria-current": "page", className: "truncate font-medium text-text-primary", children: crumb.name })) : (_jsx("button", { type: "button", onClick: () => openFolder(crumb.path), className: cn("min-w-0", LINK_CLASS), children: _jsx(TruncatedText, { className: "block truncate", children: crumb.name }) }))] }, crumb.path)))] }) }), _jsxs("div", { className: "flex flex-1 flex-col gap-4 overflow-y-auto p-4", children: [tree.status === "loading" && _jsx("p", { className: "text-sm text-text-secondary", children: t("asset.loading") }), tree.status === "forbidden" && _jsx("p", { className: "text-sm text-text-secondary", children: t("asset.noAccess") }), tree.status === "failed" && _jsx("p", { className: "text-sm text-danger-600", children: t("asset.loadFailed") }), tree.status === "ready" && tree.truncated && _jsx("p", { className: "text-sm text-text-tertiary", children: t("asset.truncated") }), folders.length > 0 && (_jsx("ul", { "aria-label": t("asset.folders"), className: "flex flex-wrap gap-2", children: folders.map((entry) => (_jsx("li", { className: "min-w-0", children: _jsxs("button", { type: "button", onClick: () => openFolder(entry.path), className: "flex max-w-full items-center gap-2 rounded-full border border-border-default bg-background-elevated px-3 py-1 text-xs text-text-secondary hover:bg-background-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600", children: [_jsx(FolderIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-text-tertiary" }), _jsx(TruncatedText, { className: "truncate", children: assetBaseName(entry.path) })] }) }, entry.path))) })), tree.status === "ready" && files.length === 0 && folders.length === 0 && (_jsx("p", { className: "text-sm text-text-secondary", children: t("asset.empty") })), files.length > 0 && (_jsx("div", { role: "listbox", "aria-label": t("asset.files"), onKeyDown: handleGridKeyDown, className: "grid grid-cols-2 gap-3 sm:grid-cols-3", children: files.map((entry, index) => {
|
|
98
98
|
const accepted = assetPathAccepted(entry.path, accepts);
|
|
99
99
|
const selected = selectedPath === entry.path;
|
|
100
100
|
return (_jsxs("button", { type: "button", ref: (element) => {
|
|
101
101
|
optionRefs.current[index] = element;
|
|
102
|
-
}, role: "option", "aria-selected": selected, "aria-disabled": !accepted, tabIndex: index === activeIndex ? 0 : -1, onFocus: () => setActiveIndex(index), onClick: () => choose(entry), className: cn("flex flex-col overflow-hidden rounded-md border text-start focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600", selected ? "border-primary-600 bg-primary-100" : "border-border-subtle hover:bg-background-elevated", !accepted && "cursor-not-allowed opacity-50 hover:bg-transparent"), children: [_jsx(TileThumbnail, { path: entry.path }), _jsxs("span", { className: "block min-w-0 px-2 py-1", children: [_jsx(
|
|
102
|
+
}, role: "option", "aria-selected": selected, "aria-disabled": !accepted, tabIndex: index === activeIndex ? 0 : -1, onFocus: () => setActiveIndex(index), onClick: () => choose(entry), className: cn("flex flex-col overflow-hidden rounded-md border text-start focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600", selected ? "border-primary-600 bg-primary-100" : "border-border-subtle hover:bg-background-elevated", !accepted && "cursor-not-allowed opacity-50 hover:bg-transparent"), children: [_jsx(TileThumbnail, { path: entry.path }), _jsxs("span", { className: "block min-w-0 px-2 py-1", children: [_jsx(TruncatedText, { className: "block truncate font-mono text-xs text-text-primary", children: assetBaseName(entry.path) }), _jsx(TruncatedText, { className: "block truncate text-xs text-text-tertiary", children: accepted ? formatSize(entry.size) : t("asset.notAnImage") })] })] }, entry.path));
|
|
103
103
|
}) }))] }), _jsxs(SheetFooter, { className: "items-center justify-end gap-2", children: [_jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: t("asset.cancel") }), _jsx(Button, { type: "button", disabled: selectedPath === null, onClick: () => {
|
|
104
104
|
if (selectedPath === null)
|
|
105
105
|
return;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// ./datatypes subpath (Session 69's "no browser weight in the server
|
|
4
4
|
// process" boundary), while built-ins.tsx re-imports them so the browser
|
|
5
5
|
// registry contract is unchanged. All six are identity today (Session
|
|
6
|
-
// 111 wires the PIPELINE, not new output shapes)
|
|
6
|
+
// 111 wires the PIPELINE, not new output shapes), so a built-in that needs
|
|
7
7
|
// a real serialized projection later changes its entry here and nowhere
|
|
8
8
|
// else. Keys are editor ids (DataTypeConfig.editorId), matching
|
|
9
9
|
// BUILT_IN_DATA_TYPE_CONFIGS in @kardalum/api-schemas.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Settings schemas for built-in editors that have real, validated settings
|
|
2
|
-
// (Session 69)
|
|
2
|
+
// (Session 69), keyed by the SAME id built-ins.tsx registers under
|
|
3
3
|
// (com.kardalum.<name>). Editors with no entry here have no server-side
|
|
4
4
|
// settings validation: either they have no settings at all (empty
|
|
5
5
|
// settingsSchema, e.g. number/boolean/date), or they're a third-party/
|
|
6
6
|
// remote plugin the server has no way to load code for (Module Federation
|
|
7
|
-
// remotes only ever run in the browser
|
|
7
|
+
// remotes only ever run in the browser, see manifest-entry.ts). This is a
|
|
8
8
|
// deliberate, documented scope boundary, not an oversight.
|
|
9
9
|
//
|
|
10
10
|
// Zero React import: this file (and the @kardalum/plugin-sdk/datatypes
|
|
@@ -17,7 +17,7 @@ export const TEXT_SETTINGS_SCHEMA = {
|
|
|
17
17
|
},
|
|
18
18
|
additionalProperties: false,
|
|
19
19
|
};
|
|
20
|
-
// Deliberately {}
|
|
20
|
+
// Deliberately {}: resolve-data-type.ts falls back to editor.defaultSettings
|
|
21
21
|
// for any config with empty settings (all six seeded built-ins today), so a
|
|
22
22
|
// non-empty default here would silently change every existing Text field's
|
|
23
23
|
// behavior the moment this ships.
|
|
@@ -72,7 +72,7 @@ export const IMAGE_SETTINGS_SCHEMA = {
|
|
|
72
72
|
};
|
|
73
73
|
export const IMAGE_DEFAULT_SETTINGS = {};
|
|
74
74
|
// S197 Task 8 (spec §7, D7): the raw-HTML datatype's one setting is an
|
|
75
|
-
// honest trust boundary, not a UX preference
|
|
75
|
+
// honest trust boundary, not a UX preference. It is default OFF, and the
|
|
76
76
|
// input view's settings screen states the trade-off inline (verbatim
|
|
77
77
|
// copy lives in html-view.tsx's HtmlSettingsView, not duplicated here).
|
|
78
78
|
export const HTML_SETTINGS_SCHEMA = {
|
package/dist/built-ins.js
CHANGED
|
@@ -29,14 +29,14 @@ function NotImplementedView() {
|
|
|
29
29
|
// Every built-in input view spreads usePropertyFieldControl(): the host
|
|
30
30
|
// renders these inside a PropertyField whose <label> has no child element
|
|
31
31
|
// to point at (the view is a component, not a DOM node), so without this
|
|
32
|
-
// the control has no accessible name at all
|
|
32
|
+
// the control has no accessible name at all (WCAG 4.1.2), and exactly
|
|
33
33
|
// what axe reports as `label` / `aria-input-field-name`.
|
|
34
34
|
function TextInputView() {
|
|
35
35
|
const { value, onChange } = usePluginValue();
|
|
36
36
|
const settings = usePluginSettings();
|
|
37
37
|
const field = usePropertyFieldControl();
|
|
38
38
|
return (_jsx(Input, { ...field, value: value ?? "", placeholder: settings.placeholder,
|
|
39
|
-
// Hard limit: the browser physically blocks keystrokes past this
|
|
39
|
+
// Hard limit: the browser physically blocks keystrokes past this,
|
|
40
40
|
// a different, config-level concept from FieldValidation.maxLength
|
|
41
41
|
// (field-row.tsx), which is a soft, validated-on-blur field rule.
|
|
42
42
|
maxLength: settings.maxLength, onChange: (e) => onChange(e.target.value) }));
|
|
@@ -45,7 +45,7 @@ function TextReadOnlyView() {
|
|
|
45
45
|
const { value } = usePluginValue();
|
|
46
46
|
return _jsx("p", { children: value ?? "" });
|
|
47
47
|
}
|
|
48
|
-
// Rendered by the Data Types editor only (data-type-editor.tsx)
|
|
48
|
+
// Rendered by the Data Types editor only (data-type-editor.tsx), a
|
|
49
49
|
// settings-EDITING view, so it uses usePluginSettingsValue() (write path),
|
|
50
50
|
// not usePluginSettings() (read-only, used by the input/readOnly views
|
|
51
51
|
// above). Hardcoded English strings: this file has no access to
|
|
@@ -91,7 +91,7 @@ const NOT_IMPLEMENTED_VIEWS = {
|
|
|
91
91
|
const NO_SETTINGS = { type: "object", properties: {} };
|
|
92
92
|
function builtIn(id, name, icon, schema, views = NOT_IMPLEMENTED_VIEWS, options = {}) {
|
|
93
93
|
// Through definePlugin (Session 61) so built-ins take the exact
|
|
94
|
-
// validation path external plugins do
|
|
94
|
+
// validation path external plugins do, so a regression in any built-in
|
|
95
95
|
// definition fails loudly at module load, not silently at render.
|
|
96
96
|
return definePlugin({
|
|
97
97
|
id: `com.kardalum.${id}`,
|
|
@@ -111,12 +111,12 @@ function builtIn(id, name, icon, schema, views = NOT_IMPLEMENTED_VIEWS, options
|
|
|
111
111
|
isEmpty: BUILT_IN_DATATYPE_VALIDATORS[`com.kardalum.${id}`]?.isEmpty,
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
-
// Real views (Session 35)
|
|
114
|
+
// Real views (Session 35): settings stays NotImplementedView for four
|
|
115
115
|
// of six (number/boolean/date/richtext) since they have no configurable
|
|
116
116
|
// settings yet (empty settingsSchema). text and image gained real
|
|
117
117
|
// settings + settingsSchema in Session 69, proving the settings pipeline
|
|
118
118
|
// before Google Maps uses the exact same path.
|
|
119
|
-
// `preview` is aliased to the same `readOnly` view (Session 41)
|
|
119
|
+
// `preview` is aliased to the same `readOnly` view (Session 41), used by
|
|
120
120
|
// the document type builder's per-field live preview while designing a
|
|
121
121
|
// field, deliberately not a `disabled`-attribute wrapper around `input`:
|
|
122
122
|
// the rich text view is TipTap/contenteditable, which a native `disabled`
|
|
@@ -146,7 +146,7 @@ registerDataType(builtIn("date", "Date", "calendar", BUILT_IN_VALUE_SCHEMAS["com
|
|
|
146
146
|
settings: NotImplementedView,
|
|
147
147
|
preview: DateReadOnlyView,
|
|
148
148
|
}));
|
|
149
|
-
// Stores a media reference id
|
|
149
|
+
// Stores a media reference id; the Media Library item itself is
|
|
150
150
|
// fetched separately (GET /api/manage/v1/media/:id), not embedded in the field
|
|
151
151
|
// value. S234d gave the view a second way to fill that id: Choose opens
|
|
152
152
|
// the shared media picker over the library, beside the upload it has had
|
|
@@ -188,10 +188,10 @@ registerDataType(builtIn("richtext", "Rich Text", "file-text", BUILT_IN_VALUE_SC
|
|
|
188
188
|
preview: RichTextReadOnlyView,
|
|
189
189
|
}));
|
|
190
190
|
// S197 Task 8 (spec §7, D7): developer-authored raw HTML, distinct from
|
|
191
|
-
// the rich (TipTap) editor above
|
|
191
|
+
// the rich (TipTap) editor above: a plain string value edited in
|
|
192
192
|
// CodeMirror. `trusted` (default false) is the datatype's one setting;
|
|
193
193
|
// the render pipeline (apps/server/src/render/render-context.ts) is what
|
|
194
|
-
// actually enforces the posture this settings flag configures
|
|
194
|
+
// actually enforces the posture this settings flag configures; this
|
|
195
195
|
// registration only carries the flag, it doesn't interpret it.
|
|
196
196
|
registerDataType(builtIn("html", "HTML", "code", BUILT_IN_VALUE_SCHEMAS["com.kardalum.html"], {
|
|
197
197
|
input: HtmlInputView,
|
|
@@ -199,7 +199,7 @@ registerDataType(builtIn("html", "HTML", "code", BUILT_IN_VALUE_SCHEMAS["com.kar
|
|
|
199
199
|
settings: HtmlSettingsView,
|
|
200
200
|
preview: HtmlReadOnlyView,
|
|
201
201
|
}, { settingsSchema: HTML_SETTINGS_SCHEMA, defaultSettings: HTML_DEFAULT_SETTINGS }));
|
|
202
|
-
// S198 Task 3: the first composite built-in datatype
|
|
202
|
+
// S198 Task 3: the first composite built-in datatype: its value has two
|
|
203
203
|
// interdependent members ({ start, end }), which is exactly what forces
|
|
204
204
|
// the validate hook's shape to be honest: `path` names which sub-input is
|
|
205
205
|
// at fault, and `isEmpty` lets `required` mean "a range must be provided"
|
|
@@ -19,8 +19,8 @@ export interface DataTypePlugin {
|
|
|
19
19
|
views: DataTypePluginViews;
|
|
20
20
|
serialize: (value: unknown, settings: Record<string, unknown>) => unknown;
|
|
21
21
|
deserialize: (raw: unknown, settings: Record<string, unknown>) => unknown;
|
|
22
|
-
/** Datatype-intrinsic validation (S198). Pure, synchronous, runtime-only
|
|
23
|
-
*
|
|
22
|
+
/** Datatype-intrinsic validation (S198). Pure, synchronous, runtime-only,
|
|
23
|
+
* never serialized into manifest.json (same as PluginHooks). */
|
|
24
24
|
validate?: DataTypeValidateHook;
|
|
25
25
|
/** Optional emptiness predicate for composite values, consulted by the
|
|
26
26
|
* `required` rule so a webmaster never needs to know the value shape. */
|
|
@@ -14,8 +14,8 @@ export interface DataTypeValidatorEntry {
|
|
|
14
14
|
/**
|
|
15
15
|
* The datatype's own `defaultSettings`. A DataTypeConfig stores `{}`
|
|
16
16
|
* until a webmaster opens the settings view and changes something, and
|
|
17
|
-
* the admin's resolver already substitutes these defaults in that case
|
|
18
|
-
*
|
|
17
|
+
* the admin's resolver already substitutes these defaults in that case,
|
|
18
|
+
* so the hook has to see them too, or it judges a value against
|
|
19
19
|
* different settings than the input view was configured with.
|
|
20
20
|
*/
|
|
21
21
|
defaultSettings?: Record<string, unknown>;
|
|
@@ -29,11 +29,11 @@ function isValidIsoDate(value) {
|
|
|
29
29
|
// its lookup with a single object read.
|
|
30
30
|
export const BUILT_IN_DATATYPE_VALIDATORS = {
|
|
31
31
|
"com.kardalum.daterange": {
|
|
32
|
-
// `required` asks this, not `validate
|
|
32
|
+
// `required` asks this, not `validate`. Task 2 only calls `validate`
|
|
33
33
|
// once a value is present, so "empty" for a two-member composite has
|
|
34
34
|
// to be answered here: both members null (or a value that is not an
|
|
35
35
|
// object at all) is empty. A member that is present but malformed is
|
|
36
|
-
// NOT empty
|
|
36
|
+
// NOT empty: it is a value the editor supplied and got wrong, so it
|
|
37
37
|
// must reach `validate` rather than be reported as a missing field.
|
|
38
38
|
isEmpty(value) {
|
|
39
39
|
const range = readDateRange(value);
|
package/dist/define-plugin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DataTypePlugin } from "./data-type-plugin.js";
|
|
2
2
|
/**
|
|
3
|
-
* Thrown when a plugin definition fails validation
|
|
3
|
+
* Thrown when a plugin definition fails validation, catchable by the
|
|
4
4
|
* registry's install() (Session 62) and `kardalum plugin validate`
|
|
5
5
|
* (Month 7), which want to report rather than crash.
|
|
6
6
|
*/
|
|
@@ -11,15 +11,15 @@ export declare class PluginDefinitionError extends Error {
|
|
|
11
11
|
* Validate a datatype plugin definition and hand it back. This is the
|
|
12
12
|
* one code path into the registry: built-ins construct their plugin
|
|
13
13
|
* objects through it (see built-ins.tsx), and external plugins do the
|
|
14
|
-
* same
|
|
14
|
+
* same, so a missing required view fails LOUDLY at definition time,
|
|
15
15
|
* never silently at render time (plugin-sdk.md).
|
|
16
16
|
*
|
|
17
17
|
* Deliberately does NOT register: Module Federation remotes (Session 66)
|
|
18
18
|
* export the defined plugin object, and the HOST decides when it enters
|
|
19
|
-
* the registry (install/activate lifecycle)
|
|
19
|
+
* the registry (install/activate lifecycle), as a define-time side effect
|
|
20
20
|
* would take that control away. Pass the result to registerDataType.
|
|
21
21
|
*
|
|
22
|
-
* Returns the ORIGINAL object (not a parsed clone)
|
|
22
|
+
* Returns the ORIGINAL object (not a parsed clone): a plugin carries
|
|
23
23
|
* React components and closures whose identity should survive.
|
|
24
24
|
*/
|
|
25
25
|
export declare function definePlugin(plugin: DataTypePlugin): DataTypePlugin;
|
package/dist/define-plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataTypePluginSchema, formatIssues } from "./manifest-schema.js";
|
|
2
2
|
/**
|
|
3
|
-
* Thrown when a plugin definition fails validation
|
|
3
|
+
* Thrown when a plugin definition fails validation, catchable by the
|
|
4
4
|
* registry's install() (Session 62) and `kardalum plugin validate`
|
|
5
5
|
* (Month 7), which want to report rather than crash.
|
|
6
6
|
*/
|
|
@@ -15,22 +15,22 @@ const REQUIRED_VIEWS = ["input", "readOnly", "settings"];
|
|
|
15
15
|
* Validate a datatype plugin definition and hand it back. This is the
|
|
16
16
|
* one code path into the registry: built-ins construct their plugin
|
|
17
17
|
* objects through it (see built-ins.tsx), and external plugins do the
|
|
18
|
-
* same
|
|
18
|
+
* same, so a missing required view fails LOUDLY at definition time,
|
|
19
19
|
* never silently at render time (plugin-sdk.md).
|
|
20
20
|
*
|
|
21
21
|
* Deliberately does NOT register: Module Federation remotes (Session 66)
|
|
22
22
|
* export the defined plugin object, and the HOST decides when it enters
|
|
23
|
-
* the registry (install/activate lifecycle)
|
|
23
|
+
* the registry (install/activate lifecycle), as a define-time side effect
|
|
24
24
|
* would take that control away. Pass the result to registerDataType.
|
|
25
25
|
*
|
|
26
|
-
* Returns the ORIGINAL object (not a parsed clone)
|
|
26
|
+
* Returns the ORIGINAL object (not a parsed clone): a plugin carries
|
|
27
27
|
* React components and closures whose identity should survive.
|
|
28
28
|
*/
|
|
29
29
|
export function definePlugin(plugin) {
|
|
30
30
|
const id = typeof plugin === "object" && plugin !== null && typeof plugin.id === "string"
|
|
31
31
|
? plugin.id
|
|
32
32
|
: "(unknown id)";
|
|
33
|
-
// Required views first, with purpose-built messages
|
|
33
|
+
// Required views first, with purpose-built messages, since Zod's generic
|
|
34
34
|
// "expected custom, received undefined" doesn't tell a plugin author
|
|
35
35
|
// what to fix.
|
|
36
36
|
const views = typeof plugin === "object" && plugin !== null ? plugin.views : undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export { Input, type InputProps } from "@kardalum/ui";
|
|
|
27
27
|
export { Button, type ButtonProps } from "@kardalum/ui";
|
|
28
28
|
export { Switch, type SwitchProps } from "@kardalum/ui";
|
|
29
29
|
export { Badge, type BadgeProps } from "@kardalum/ui";
|
|
30
|
+
export { IconTooltip, type IconTooltipProps } from "@kardalum/ui";
|
|
31
|
+
export { TruncatedText, type TruncatedTextProps } from "@kardalum/ui";
|
|
30
32
|
export { cn } from "@kardalum/ui";
|
|
31
33
|
export type { NotificationRefusalReason, PluginNotify, PluginNotifyInput, PluginNotifyResult } from "./notify.js";
|
|
32
34
|
export { VENDOR_SERVICE_ERROR_CODES, VendorServiceError, isVendorServiceError } from "./vendor-service.js";
|
package/dist/index.js
CHANGED
|
@@ -84,6 +84,10 @@ export { Input } from "@kardalum/ui";
|
|
|
84
84
|
export { Button } from "@kardalum/ui";
|
|
85
85
|
export { Switch } from "@kardalum/ui";
|
|
86
86
|
export { Badge } from "@kardalum/ui";
|
|
87
|
+
// S357b: a plugin's icon buttons and long names need the same two the admin
|
|
88
|
+
// uses; the admin's TooltipProvider is above every mounted plugin view.
|
|
89
|
+
export { IconTooltip } from "@kardalum/ui";
|
|
90
|
+
export { TruncatedText } from "@kardalum/ui";
|
|
87
91
|
export { cn } from "@kardalum/ui";
|
|
88
92
|
// S320: context.vendorService and its typed error.
|
|
89
93
|
export { VENDOR_SERVICE_ERROR_CODES, VendorServiceError, isVendorServiceError } from "./vendor-service.js";
|
package/dist/manifest-schema.js
CHANGED
|
@@ -513,7 +513,13 @@ const contributionsShape = {
|
|
|
513
513
|
// PLUGINS, each of which has a manifest and so is itself capped. A
|
|
514
514
|
// four-segment entry here could never resolve to an installable plugin,
|
|
515
515
|
// so catching it at publish beats discovering it at install.
|
|
516
|
-
|
|
516
|
+
// S349 (D2): at least one. Declaring members is what makes a plugin a
|
|
517
|
+
// bundle, whatever its label (D1), so an empty list would declare a
|
|
518
|
+
// bundle of nothing; a plugin that bundles none leaves the key out.
|
|
519
|
+
bundledPlugins: z
|
|
520
|
+
.array(manifestIdSchema)
|
|
521
|
+
.min(1, { error: "must name at least one member plugin id (leave bundledPlugins out when the plugin bundles none)" })
|
|
522
|
+
.optional(),
|
|
517
523
|
bundledTemplate: bundledTemplateSchema.optional(),
|
|
518
524
|
// S314n3 (D1): `true` or absent; the capability is derived from it.
|
|
519
525
|
notifications: z.literal(true).optional(),
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { ChevronRight, Folder as FolderIcon } from "lucide-react";
|
|
4
4
|
import { renditionShape, } from "@kardalum/api-schemas";
|
|
5
|
-
import { Button, cn, Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, } from "@kardalum/ui";
|
|
5
|
+
import { Button, cn, Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, TruncatedText, } from "@kardalum/ui";
|
|
6
6
|
import { MANAGE_API, usePluginApi } from "../plugin-context.js";
|
|
7
7
|
import { gridArrowStep } from "../grid-arrow-step.js";
|
|
8
8
|
import { readAllPages } from "../read-all-pages.js";
|
|
@@ -426,8 +426,8 @@ export function MediaPicker({ onPick, onClose, collectAlt, acceptedTypes, rendit
|
|
|
426
426
|
}
|
|
427
427
|
}, children: [_jsxs(SheetHeader, { className: "flex-col items-start gap-1", children: [_jsx(SheetTitle, { children: "Choose an image" }), _jsxs(SheetDescription, { children: ["Showing images from your library.", rendition ? (_jsxs(_Fragment, { children: [" ", "This field asks for a ", _jsx("strong", { className: "font-medium text-text-primary", children: requestedShape }), " crop."] })) : null] })] }), _jsx("nav", { "aria-label": "Folder location", className: "shrink-0 border-b border-border-default px-4 py-2", children: _jsxs("ol", { className: "flex flex-wrap items-center gap-1 text-sm text-text-tertiary", children: [_jsx("li", { children: currentFolderId === null ? (_jsx("span", { "aria-current": "page", className: "font-medium text-text-primary", children: ROOT_LABEL })) : (_jsx("button", { type: "button", onClick: () => openFolder(null), className: "rounded-md px-1 hover:text-primary-600 hover:underline focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600", children: ROOT_LABEL })) }), breadcrumbPath.map((folder, index) => {
|
|
428
428
|
const isCurrent = index === breadcrumbPath.length - 1;
|
|
429
|
-
return (_jsxs("li", { className: "flex min-w-0 items-center gap-1", children: [_jsx(ChevronRight, { "aria-hidden": "true", className: "size-3 shrink-0 rtl:rotate-180" }), isCurrent ? (_jsx(
|
|
430
|
-
})] }) }), _jsxs("div", { className: "flex flex-1 flex-col gap-4 overflow-y-auto p-4", children: [error && _jsx("p", { className: "text-sm text-danger-600", children: error }), visibleFolders.length > 0 && (_jsx("ul", { "aria-label": "Folders", className: "flex flex-wrap gap-2", children: visibleFolders.map((folder) => (_jsx("li", { className: "min-w-0", children: _jsxs("button", { type: "button", onClick: () => openFolder(folder.id), className: "flex max-w-full items-center gap-2 rounded-full border border-border-default bg-background-elevated px-3 py-1 text-xs text-text-secondary hover:bg-background-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600", children: [_jsx(FolderIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-text-tertiary" }), _jsx(
|
|
429
|
+
return (_jsxs("li", { className: "flex min-w-0 items-center gap-1", children: [_jsx(ChevronRight, { "aria-hidden": "true", className: "size-3 shrink-0 rtl:rotate-180" }), isCurrent ? (_jsx(TruncatedText, { "aria-current": "page", className: "truncate font-medium text-text-primary", children: folder.name })) : (_jsx("button", { type: "button", onClick: () => openFolder(folder.id), className: "min-w-0 rounded-md px-1 hover:text-primary-600 hover:underline focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600", children: _jsx(TruncatedText, { className: "block truncate", children: folder.name }) }))] }, folder.id));
|
|
430
|
+
})] }) }), _jsxs("div", { className: "flex flex-1 flex-col gap-4 overflow-y-auto p-4", children: [error && _jsx("p", { className: "text-sm text-danger-600", children: error }), visibleFolders.length > 0 && (_jsx("ul", { "aria-label": "Folders", className: "flex flex-wrap gap-2", children: visibleFolders.map((folder) => (_jsx("li", { className: "min-w-0", children: _jsxs("button", { type: "button", onClick: () => openFolder(folder.id), className: "flex max-w-full items-center gap-2 rounded-full border border-border-default bg-background-elevated px-3 py-1 text-xs text-text-secondary hover:bg-background-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600", children: [_jsx(FolderIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-text-tertiary" }), _jsx(TruncatedText, { className: "truncate", children: folder.name })] }) }, folder.id))) })), loading && _jsx("p", { className: "text-sm text-text-secondary", children: "Loading\u2026" }), emptyBecauseFiltered && (_jsx("p", { className: "text-sm text-text-secondary", children: "Nothing here is a kind this field accepts." })), !loading && rawItems.length === 0 && visibleFolders.length === 0 && (_jsx("p", { className: "text-sm text-text-secondary", children: currentFolderId === null ? "No images in the media library yet." : "No images in this folder yet." })), !loading && items.length > 0 && (_jsx("div", { role: "listbox", "aria-label": "Media library", onKeyDown: handleGridKeyDown, className: "grid grid-cols-3 gap-3", children: items.map((item, index) => {
|
|
431
431
|
const selected = pending?.id === item.id;
|
|
432
432
|
// `hasRendition` is only set when the listing was asked
|
|
433
433
|
// about a crop, so absent means nothing was asked and
|
|
@@ -442,6 +442,6 @@ export function MediaPicker({ onPick, onClose, collectAlt, acceptedTypes, rendit
|
|
|
442
442
|
optionRefs.current[index] = el;
|
|
443
443
|
}, role: "option", "aria-selected": selected, title: title, tabIndex: index === activeIndex ? 0 : -1, onFocus: () => setActiveIndex(index), onClick: () => selectItem(item), className: cn("flex flex-col overflow-hidden rounded-md border text-start focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600", selected
|
|
444
444
|
? "border-primary-600 bg-primary-100"
|
|
445
|
-
: "border-border-subtle hover:bg-background-elevated"), children: [_jsx("span", { className: "block aspect-square overflow-hidden bg-background-subtle", children: _jsx("img", { src: item.downloadUrl, alt: "", className: "h-full w-full object-cover" }) }), _jsxs("span", { className: "block min-w-0 px-2 py-1", children: [_jsx(
|
|
445
|
+
: "border-border-subtle hover:bg-background-elevated"), children: [_jsx("span", { className: "block aspect-square overflow-hidden bg-background-subtle", children: _jsx("img", { src: item.downloadUrl, alt: "", className: "h-full w-full object-cover" }) }), _jsxs("span", { className: "block min-w-0 px-2 py-1", children: [_jsx(TruncatedText, { className: "block truncate font-mono text-xs text-text-tertiary", children: item.filename }), fallsBack && (_jsx("span", { className: "mt-1 inline-block rounded-sm bg-warning-100 px-1 text-xs text-warning-800", children: "full image" }))] })] }, item.id));
|
|
446
446
|
}) })), !loading && nextCursor && (_jsx("div", { className: "flex justify-center", children: _jsx(Button, { type: "button", variant: "outline", size: "sm", disabled: loadingMore, onClick: () => void loadMore(), children: loadingMore ? "Loading…" : "Load more" }) }))] }), pending && (_jsxs("div", { className: "flex shrink-0 items-center gap-3 border-t border-border-default px-4 py-3", children: [_jsx("img", { src: pending.downloadUrl, alt: "", className: "h-12 w-12 shrink-0 rounded-md border border-border-subtle object-cover" }), _jsxs("div", { className: "flex-1", children: [_jsx("label", { htmlFor: "media-picker-alt", className: "mb-1 block text-xs font-medium text-text-secondary", children: "Alt text" }), _jsx("input", { id: "media-picker-alt", ref: altInputRef, type: "text", value: altText, onChange: (event) => setAltText(event.target.value), placeholder: "Describe this image for screen readers (optional)", className: "w-full rounded-md border border-border-default bg-background-elevated px-2 py-1 text-sm text-text-primary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600" })] })] })), _jsxs(SheetFooter, { className: "items-center justify-start", children: [_jsxs("p", { className: "text-sm text-text-tertiary", children: ["Or", " ", _jsx("button", { type: "button", disabled: uploading, onClick: () => uploadInputRef.current?.click(), className: "rounded-md text-primary-600 underline focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600", children: uploading ? `uploading into ${currentFolderName}…` : `upload into ${currentFolderName}` })] }), _jsx("input", { id: "media-picker-upload", ref: uploadInputRef, type: "file", className: "hidden", accept: acceptAttribute(acceptedTypes), "aria-label": `Upload into ${currentFolderName}`, disabled: uploading, onChange: (event) => void handleUpload(event) }), _jsx("span", { className: "ms-auto flex gap-2", children: pending ? (_jsxs(_Fragment, { children: [_jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: "Cancel" }), _jsx(Button, { type: "button", onClick: () => onPick({ id: pending.id, downloadUrl: pending.downloadUrl, alt: altText }), children: "Insert" })] })) : (_jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: "Close" })) })] })] }) }));
|
|
447
447
|
}
|
package/dist/plugin-context.js
CHANGED
|
@@ -5,7 +5,7 @@ export function PluginValueProvider({ value, onChange, children }) {
|
|
|
5
5
|
return _jsx(PluginValueContext.Provider, { value: { value, onChange }, children: children });
|
|
6
6
|
}
|
|
7
7
|
// A view calling this outside a host-rendered PluginValueProvider is a
|
|
8
|
-
// real bug (the host forgot to wrap it)
|
|
8
|
+
// real bug (the host forgot to wrap it), so throw loudly, don't hand back
|
|
9
9
|
// a silently-undefined value/no-op onChange.
|
|
10
10
|
export function usePluginValue() {
|
|
11
11
|
const ctx = useContext(PluginValueContext);
|
|
@@ -18,7 +18,7 @@ const PluginSettingsContext = createContext(null);
|
|
|
18
18
|
export function PluginSettingsProvider({ settings, onSettingsChange, children }) {
|
|
19
19
|
return (_jsx(PluginSettingsContext.Provider, { value: { settings, onSettingsChange }, children: children }));
|
|
20
20
|
}
|
|
21
|
-
// Returns settings directly (not {settings, onChange})
|
|
21
|
+
// Returns settings directly (not {settings, onChange}): this is the
|
|
22
22
|
// READ-ONLY path used by input/readOnly/preview views (Session 69). For a
|
|
23
23
|
// settings-EDITING view (the "settings" DataTypePluginViews slot), use
|
|
24
24
|
// usePluginSettingsValue() below instead.
|
|
@@ -30,7 +30,7 @@ export function usePluginSettings() {
|
|
|
30
30
|
return ctx.settings;
|
|
31
31
|
}
|
|
32
32
|
// Mirrors usePluginValue()'s {value, onChange} shape, for settings-EDITING
|
|
33
|
-
// views only (Session 69)
|
|
33
|
+
// views only (Session 69): the host (e.g. the Data Types editor) must
|
|
34
34
|
// supply onSettingsChange via PluginSettingsProvider, or this throws:
|
|
35
35
|
// a settings view rendered in a read-only context is a host bug, same
|
|
36
36
|
// "throw loudly" philosophy as usePluginValue().
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// The `@kardalum/plugin-sdk/register-built-ins` subpath: runs the
|
|
2
2
|
// package's built-in datatype registration side effect (the six
|
|
3
|
-
// `registerDataType()` calls in `built-ins.tsx
|
|
3
|
+
// `registerDataType()` calls in `built-ins.tsx`: text/number/boolean/
|
|
4
4
|
// date/image/richtext/html) and nothing else.
|
|
5
5
|
//
|
|
6
6
|
// S197 final-review fix F5: this used to be the package INDEX's own
|
|
7
7
|
// trailing side effect (`import "./built-ins.js"`), which meant importing
|
|
8
|
-
// ANYTHING from the bare `@kardalum/plugin-sdk` specifier
|
|
9
|
-
// primitive, a provider, a type
|
|
8
|
+
// ANYTHING from the bare `@kardalum/plugin-sdk` specifier (a UI
|
|
9
|
+
// primitive, a provider, a type) incidentally triggered it too. That was
|
|
10
10
|
// harmless on its own, but it meant the package's main entry could never
|
|
11
11
|
// be lightweight: `built-ins.tsx` statically imports both
|
|
12
12
|
// rich-text-view.tsx (TipTap) and, since S197 Task 8's HTML datatype,
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
//
|
|
17
17
|
// Every first-party plugin's Module Federation config shares
|
|
18
18
|
// `@kardalum/plugin-sdk` as a runtime singleton (see any
|
|
19
|
-
// `plugins/*/vite.config.ts`)
|
|
19
|
+
// `plugins/*/vite.config.ts`): that `shared` entry resolves to the bare
|
|
20
20
|
// package specifier, i.e. the MAIN entry, regardless of which subpath a
|
|
21
21
|
// plugin's own view code actually imports from. Module Federation still
|
|
22
22
|
// bundles a fallback copy of that shared module into every remote's own
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
// compatible version), so as long as the main entry pulled in TipTap +
|
|
25
25
|
// CodeMirror, EVERY plugin's packaged artifact carried a multi-hundred-KB
|
|
26
26
|
// dead-weight fallback chunk that never actually loads at runtime (the
|
|
27
|
-
// admin host's own copy always satisfies the singleton first)
|
|
27
|
+
// admin host's own copy always satisfies the singleton first), and this is
|
|
28
28
|
// what pushed google-maps' packaged bundle size over the marketplace's
|
|
29
29
|
// 250KB budget the moment CodeMirror/lezer landed in plugin-sdk's
|
|
30
30
|
// dependency tree, not anything google-maps' own view code did.
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
// that at the root for every plugin at once, not just the one that
|
|
34
34
|
// happened to trip a test. Exactly ONE real consumer needs this:
|
|
35
35
|
// apps/admin-ui's own bootstrap (main.tsx) and its vitest setup
|
|
36
|
-
// (vitest.setup.ts)
|
|
36
|
+
// (vitest.setup.ts): both import this once, for its side effect, the
|
|
37
37
|
// same "run once at startup" pattern initTheme()/the i18n import already
|
|
38
38
|
// use in main.tsx. A REMOTE plugin never needs this: its own views read
|
|
39
39
|
// datatypes through its OWN manifest object, never through this
|
package/dist/registry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Static registry: built-ins register into this exact same map at module
|
|
2
|
-
// load (Core vs Plugin
|
|
2
|
+
// load (Core vs Plugin: built-ins are statically registered, dynamically
|
|
3
3
|
// loaded marketplace plugins are a second registration path into this same
|
|
4
4
|
// registry, not a different kind of plugin).
|
|
5
5
|
const dataTypes = new Map();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { Selection } from "@tiptap/pm/state";
|
|
4
|
-
import { Button, Dialog, DialogCloseButton, DialogContent, DialogFooter, DialogHeader, DialogTitle, Input, PropertyField, Switch, } from "@kardalum/ui";
|
|
4
|
+
import { Button, Dialog, DialogCloseButton, DialogContent, DialogFooter, DialogHeader, DialogTitle, Input, PropertyField, Switch, TruncatedText, } from "@kardalum/ui";
|
|
5
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";
|
|
@@ -67,7 +67,7 @@ function BlockParamField({ spec, value, onChange, error }) {
|
|
|
67
67
|
case "choice":
|
|
68
68
|
return (_jsx(PropertyField, { label: spec.label, htmlFor: fieldId, error: error, children: _jsx("select", { id: fieldId, value: value ?? "", onChange: (event) => onChange(event.target.value), className: "h-10 w-full rounded-md border border-border-strong bg-background-elevated px-3 text-sm text-text-primary focus-visible:border-primary-600 focus-visible:outline-hidden focus-visible:ring-4 focus-visible:ring-primary-50", children: (spec.options ?? []).map((option) => (_jsx("option", { value: option, children: option }, option))) }) }));
|
|
69
69
|
case "image":
|
|
70
|
-
return (_jsxs(PropertyField, { label: spec.label, error: error, children: [_jsxs("div", { className: "flex items-center gap-3 rounded-md border border-border-default bg-background-subtle p-2", children: [preview ? (_jsx("img", { src: preview.downloadUrl, alt: "", className: "h-10 w-10 shrink-0 rounded-md object-cover" })) : (_jsx("div", { "aria-hidden": "true", className: "h-10 w-10 shrink-0 rounded-md bg-background-hover" })), _jsx(
|
|
70
|
+
return (_jsxs(PropertyField, { label: spec.label, error: error, children: [_jsxs("div", { className: "flex items-center gap-3 rounded-md border border-border-default bg-background-subtle p-2", children: [preview ? (_jsx("img", { src: preview.downloadUrl, alt: "", className: "h-10 w-10 shrink-0 rounded-md object-cover" })) : (_jsx("div", { "aria-hidden": "true", className: "h-10 w-10 shrink-0 rounded-md bg-background-hover" })), _jsx(TruncatedText, { className: "flex-1 truncate text-sm text-text-secondary", children: preview?.filename ?? "No image selected" }), _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => setPickerOpen(true), children: "Change" })] }), pickerOpen && (_jsx(MediaPicker
|
|
71
71
|
// A block param stores the media id and nothing else, so
|
|
72
72
|
// there is nowhere for alt text to go: asking for it here
|
|
73
73
|
// would be collecting something this field then discards.
|
|
@@ -3,7 +3,7 @@ import Image from "@tiptap/extension-image";
|
|
|
3
3
|
import Link from "@tiptap/extension-link";
|
|
4
4
|
// tiptap 3.31 ships table's row/header/cell as named exports of this ONE
|
|
5
5
|
// package (not the separate @tiptap/extension-table-row/-cell/-header
|
|
6
|
-
// packages older tiptap majors used)
|
|
6
|
+
// packages older tiptap majors used): no extra dependencies needed.
|
|
7
7
|
import { Table, TableRow, TableHeader, TableCell } from "@tiptap/extension-table";
|
|
8
8
|
import { TextStyleClass } from "./text-style-class.js";
|
|
9
9
|
import { KardalumBlock, KardalumBlockOnPage } from "./kardalum-block.js";
|
|
@@ -11,7 +11,7 @@ export { TextStyleClass } from "./text-style-class.js";
|
|
|
11
11
|
export { KardalumBlock, KardalumBlockOnPage, selectedKardalumBlock, findKardalumBlocks, setBlockHtml, unavailableBlockHtml, moveSelectionPastBlock, } from "./kardalum-block.js";
|
|
12
12
|
// The media-library image node (S197 spec §3 "Content shape"): `mediaId`
|
|
13
13
|
// is the reference the server resolves at render/edit time, never a raw
|
|
14
|
-
// pasted URL
|
|
14
|
+
// pasted URL: `src`/`alt` (the base extension's own attrs) are what the
|
|
15
15
|
// editor shows once resolved, kept in sync by whichever mount inserts the
|
|
16
16
|
// image (this package's toolbar today; the on-page iframe editor later).
|
|
17
17
|
const KardalumImage = Image.extend({
|
|
@@ -35,13 +35,13 @@ const KardalumImage = Image.extend({
|
|
|
35
35
|
// THE shared TipTap extension set (S197 spec §3: "one TipTap editor
|
|
36
36
|
// definition, mounted two ways"). This package's form-view editor
|
|
37
37
|
// (rich-text-view.tsx) consumes it today; the on-page iframe editor (a
|
|
38
|
-
// later task, spec §6.3
|
|
38
|
+
// later task, spec §6.3, a vanilla @tiptap/core instance, no React)
|
|
39
39
|
// consumes it unchanged. A mount-specific need (a bubble menu, an insert
|
|
40
40
|
// popover) belongs in that mount's own UI layer, never forked in here.
|
|
41
41
|
export function buildRichtextExtensions(options = {}) {
|
|
42
42
|
const { blockRenderMode = "chip" } = options;
|
|
43
43
|
return [
|
|
44
|
-
// StarterKit bundles its own Link internally (tiptap 3.31)
|
|
44
|
+
// StarterKit bundles its own Link internally (tiptap 3.31), disabled
|
|
45
45
|
// here so this package's own Link instance (prompt-free popover input,
|
|
46
46
|
// spec-listed as its own extension) is the only one registered; two
|
|
47
47
|
// instances of the same mark name throws.
|
|
@@ -52,9 +52,9 @@ export function buildRichtextExtensions(options = {}) {
|
|
|
52
52
|
blockRenderMode === "onPage" ? KardalumBlockOnPage : KardalumBlock,
|
|
53
53
|
// Registered as its own four-node set (S197 Task 11: the on-page
|
|
54
54
|
// insert menu's "Table" row needs a real `insertTable` command on
|
|
55
|
-
// BOTH mounts
|
|
56
|
-
// is the one shared extension list both consume). `resizable: false
|
|
57
|
-
//
|
|
55
|
+
// BOTH mounts (form-view and the vanilla iframe editor), since this
|
|
56
|
+
// is the one shared extension list both consume). `resizable: false`:
|
|
57
|
+
// column dragging needs floating-ui-style pointer tracking this
|
|
58
58
|
// project doesn't wire up anywhere yet; a fixed 3x3 grid (the insert
|
|
59
59
|
// menu's only entry point) needs none of that.
|
|
60
60
|
Table.configure({ resizable: false }),
|
|
@@ -36,7 +36,7 @@ export function defaultBlockParams(params) {
|
|
|
36
36
|
// a silent empty list). Shared between the insert menu (BlockInsertMenu,
|
|
37
37
|
// below) and the param panel (block-panel.tsx needs the same declared
|
|
38
38
|
// param specs + labels to render fields for a block already in the
|
|
39
|
-
// document)
|
|
39
|
+
// document): one fetch shape, not forked per consumer.
|
|
40
40
|
export function useBlockListings() {
|
|
41
41
|
const fetchApi = usePluginApi();
|
|
42
42
|
const [listings, setListings] = useState([]);
|
|
@@ -68,7 +68,7 @@ export function useBlockListings() {
|
|
|
68
68
|
}, [fetchApi]);
|
|
69
69
|
return { listings, loading, error };
|
|
70
70
|
}
|
|
71
|
-
// The toolbar's "◫ Block ▾" popover body (S197 mockup screen 2, "Blocks
|
|
71
|
+
// The toolbar's "◫ Block ▾" popover body (S197 mockup screen 2, "Blocks:
|
|
72
72
|
// from your templates" section): an ARIA listbox, same single-select
|
|
73
73
|
// pattern as StyleListbox (rich-text-view.tsx): roving tabindex,
|
|
74
74
|
// Arrow/Home/End move focus, Enter/Space commits, Escape closes.
|
|
@@ -76,7 +76,7 @@ export function useBlockListings() {
|
|
|
76
76
|
// Screen 2's mockup also shows Image/Quote/Table rows above the blocks
|
|
77
77
|
// list, but those are already reachable from this editor's own toolbar
|
|
78
78
|
// (the "🖼 Image" button, the "❝" blockquote button) or out of scope (no
|
|
79
|
-
// Table extension exists yet)
|
|
79
|
+
// Table extension exists yet), so this menu covers only what "◫ Block ▾" is
|
|
80
80
|
// for: inserting a template-declared block.
|
|
81
81
|
export function BlockInsertMenu({ onInsert, onClose }) {
|
|
82
82
|
const { listings, loading, error } = useBlockListings();
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo, useRef, useState } from "react";
|
|
3
3
|
import { cn } from "@kardalum/ui";
|
|
4
4
|
// The Aa Style dropdown's popover body: a proper ARIA listbox (role
|
|
5
|
-
// listbox/option), not a menu
|
|
5
|
+
// listbox/option), not a menu: it's a single-select "pick one" widget,
|
|
6
6
|
// same pattern as IconPickerDialog's grid (roving tabindex, Arrow/Home/End,
|
|
7
7
|
// Enter/Space commits).
|
|
8
8
|
export function StyleListbox({ styles, loading, activeStyleKey, onSelect, onClear, onClose }) {
|