@kardalum/plugin-sdk 0.17.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 +109 -0
- package/README.md +4 -3
- package/dist/assets/asset-picker.d.ts +11 -0
- package/dist/assets/asset-picker.js +109 -0
- package/dist/assets/asset-tree.d.ts +30 -0
- package/dist/assets/asset-tree.js +150 -0
- package/dist/built-in-editor-ids.d.ts +1 -0
- package/dist/built-in-editor-ids.js +20 -0
- package/dist/built-in-serializers.js +1 -1
- package/dist/built-in-settings-schemas.d.ts +2 -0
- package/dist/built-in-settings-schemas.js +31 -4
- package/dist/built-in-value-schemas.js +3 -0
- package/dist/built-ins.js +20 -11
- package/dist/capabilities.js +5 -0
- package/dist/data-type-plugin.d.ts +2 -2
- package/dist/datatype-validation.d.ts +2 -2
- package/dist/datatype-validation.js +20 -6
- package/dist/datatypes-entry.d.ts +1 -0
- package/dist/datatypes-entry.js +1 -0
- package/dist/define-plugin.d.ts +4 -4
- package/dist/define-plugin.js +5 -5
- package/dist/entitlement-entry.d.ts +3 -2
- package/dist/entitlement-entry.js +13 -1
- package/dist/entitlement-gate.d.ts +18 -0
- package/dist/entitlement-gate.js +95 -21
- package/dist/entitlement-plan.d.ts +21 -0
- package/dist/entitlement-plan.js +26 -0
- package/dist/entitlement-types.d.ts +21 -4
- package/dist/entitlement.d.ts +29 -1
- package/dist/entitlement.js +39 -0
- package/dist/grid-arrow-step.d.ts +7 -0
- package/dist/grid-arrow-step.js +20 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +11 -12
- package/dist/manifest-entry.d.ts +4 -0
- package/dist/manifest-entry.js +4 -0
- package/dist/manifest-schema.d.ts +5 -1
- package/dist/manifest-schema.js +14 -2
- package/dist/manifest.d.ts +21 -1
- package/dist/media/media-picker.js +34 -34
- package/dist/notify.d.ts +17 -0
- package/dist/notify.js +17 -0
- 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 +19 -20
- package/dist/richtext/extensions.js +17 -8
- package/dist/richtext/insert-menu.js +4 -4
- package/dist/richtext/kardalum-block.js +17 -17
- package/dist/richtext/style-listbox.js +2 -2
- package/dist/richtext/text-style-class.js +1 -1
- package/dist/richtext-html-entry.d.ts +35 -0
- package/dist/richtext-html-entry.js +73 -0
- package/dist/simple-storage-value-provider.js +3 -3
- package/dist/structured-storage-types.d.ts +12 -1
- package/dist/structured-storage-types.js +2 -2
- package/dist/tailwind.js +10 -3
- package/dist/tokens/tailwind-theme.css +176 -0
- package/dist/tokens/tokens.css +1 -0
- package/dist/tokens/tokens.json +2 -1
- package/dist/ui-entry.js +3 -3
- package/dist/vendor-check.d.ts +39 -0
- package/dist/vendor-check.js +79 -0
- package/dist/vendor-entry.d.ts +3 -0
- package/dist/vendor-entry.js +9 -0
- package/dist/vendor-service.d.ts +20 -0
- package/dist/vendor-service.js +20 -0
- package/dist/views/asset-view.d.ts +6 -0
- package/dist/views/asset-view.js +55 -0
- package/dist/views/content-list-settings-view.js +1 -1
- package/dist/views/content-list-view.js +1 -1
- package/dist/views/date-range-view.js +5 -5
- package/dist/views/html-code-editor.js +2 -3
- package/dist/views/html-view.js +7 -7
- package/dist/views/image-view.js +5 -5
- package/dist/views/rich-text-view.js +33 -32
- package/node_modules/@kardalum/api-schemas/README.md +1 -1
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +17 -15
- package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.d.ts +21 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.js +42 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +10 -3
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.d.ts +36 -0
- package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.js +46 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +30 -9
- 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 +12 -6
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +11 -6
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +50 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +26 -6
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +6 -3
- package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.js +28 -0
- 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 +56 -6
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +8 -8
- package/node_modules/@kardalum/api-schemas/dist/home.schema.d.ts +130 -0
- package/node_modules/@kardalum/api-schemas/dist/home.schema.js +87 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +48 -19
- package/node_modules/@kardalum/api-schemas/dist/index.js +34 -12
- package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.js +9 -0
- 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 +162 -1
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +144 -9
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +26 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +15 -9
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +4 -4
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +5 -5
- package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +93 -0
- package/node_modules/@kardalum/api-schemas/dist/news.schema.js +86 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +410 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +193 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +86 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +92 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +7 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +7 -0
- 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 +251 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +196 -31
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +19 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +33 -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/plugin-template-payload.d.ts +10 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +24 -4
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +23 -20
- 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/revenue-view.schema.d.ts +83 -0
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +73 -0
- 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/sites.schema.d.ts +14 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +3 -3
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +27 -12
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +22 -10
- 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.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +6 -1
- package/node_modules/@kardalum/api-schemas/dist/uuid.schema.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/uuid.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +88 -0
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +100 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +5 -0
- package/node_modules/@kardalum/design-tokens/README.md +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/build-theme-css.d.ts +16 -0
- package/node_modules/@kardalum/design-tokens/dist/build-theme-css.js +76 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.js +4 -1
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +176 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -1
- 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.css +1 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +3 -3
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +6 -5
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +2 -1
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +2 -1
- package/node_modules/@kardalum/design-tokens/dist/types.js +1 -1
- package/node_modules/@kardalum/design-tokens/package.json +6 -3
- package/node_modules/@kardalum/plugin-package/README.md +1 -1
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +4 -4
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +54 -6
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +18 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +9 -4
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +58 -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 +10 -10
- 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/index.d.ts +4 -2
- package/node_modules/@kardalum/plugin-package/dist/index.js +3 -1
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +56 -19
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +119 -25
- 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/plugin-package/dist/vendor-token.d.ts +24 -0
- package/node_modules/@kardalum/plugin-package/dist/vendor-token.js +118 -0
- package/node_modules/@kardalum/ui/README.md +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 +2 -2
- package/node_modules/@kardalum/ui/dist/components/checkbox.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/dialog.js +52 -4
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +5 -1
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +20 -7
- 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/popover-panel.d.ts +4 -0
- package/node_modules/@kardalum/ui/dist/components/popover-panel.js +13 -0
- 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 +15 -9
- package/node_modules/@kardalum/ui/dist/components/skeleton.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +3 -3
- package/node_modules/@kardalum/ui/dist/components/tab-strip.js +1 -1
- 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 +4 -1
- package/node_modules/@kardalum/ui/dist/index.js +4 -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 +21 -7
|
@@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from "react";
|
|
|
3
3
|
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
|
-
import { cn, usePropertyFieldControl } from "@kardalum/ui";
|
|
6
|
+
import { cn, IconTooltip, usePropertyFieldControl } from "@kardalum/ui";
|
|
7
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";
|
|
@@ -12,7 +12,7 @@ import { BlockPanel, BlockPreviewPopover } from "../richtext/block-panel.js";
|
|
|
12
12
|
import { StyleListbox } from "../richtext/style-listbox.js";
|
|
13
13
|
// The rich content editor (S197 spec §3): one TipTap editor definition
|
|
14
14
|
// (buildRichtextExtensions), mounted here with a fixed compact toolbar per
|
|
15
|
-
// the mockup's screen 3
|
|
15
|
+
// the mockup's screen 3: the same commands the on-page bubble toolbar
|
|
16
16
|
// offers, plus "Edit on page" (a later task wires the navigation; this
|
|
17
17
|
// task ships it as a disabled placeholder, spec-listed toolbar chrome).
|
|
18
18
|
//
|
|
@@ -25,7 +25,7 @@ const CONTENT_CLASSES = "text-sm text-text-primary [&_h1]:text-xl [&_h1]:font-bo
|
|
|
25
25
|
"[&_a]:text-primary-700 [&_a]:underline " +
|
|
26
26
|
"[&_blockquote]:border-s-2 [&_blockquote]:border-border-default [&_blockquote]:ps-3 [&_blockquote]:italic [&_blockquote]:text-text-secondary";
|
|
27
27
|
// Source view (Item 3, S197 QA-wave B): a light prettification, not a real
|
|
28
|
-
// formatter
|
|
28
|
+
// formatter: no dependency is worth pulling in just to indent nested
|
|
29
29
|
// markup. TipTap's own getHTML() emits one unbroken string with no
|
|
30
30
|
// whitespace between block elements at all (`<p>a</p><p>b</p>`); parsing it
|
|
31
31
|
// back and re-joining each TOP-LEVEL node's own outerHTML with a newline is
|
|
@@ -50,7 +50,7 @@ function useTextStyles() {
|
|
|
50
50
|
setLoading(true);
|
|
51
51
|
fetchApi(`${MANAGE_API}/render/text-styles`)
|
|
52
52
|
.then(async (response) => {
|
|
53
|
-
// The endpoint doesn't exist yet (a later task ships it)
|
|
53
|
+
// The endpoint doesn't exist yet (a later task ships it), so a 404,
|
|
54
54
|
// any other error status, and a genuinely empty declared list all
|
|
55
55
|
// render the same "no styles" state, so treat them identically.
|
|
56
56
|
if (!response.ok)
|
|
@@ -76,8 +76,8 @@ function useTextStyles() {
|
|
|
76
76
|
// Roving tabindex over the toolbar's top-level buttons (WAI-ARIA toolbar
|
|
77
77
|
// pattern): one stop in the page Tab order, arrow keys move focus among
|
|
78
78
|
// buttons, Home/End jump to the ends. Disabled buttons (Block, Edit on
|
|
79
|
-
// page
|
|
80
|
-
// native disabled-control behavior
|
|
79
|
+
// page, both placeholders this task) are skipped entirely, matching
|
|
80
|
+
// native disabled-control behavior, so they can never hold focus.
|
|
81
81
|
function useToolbarRovingTabIndex(focusableKeys) {
|
|
82
82
|
const [activeKey, setActiveKey] = useState(focusableKeys[0] ?? null);
|
|
83
83
|
const refs = useRef(new Map());
|
|
@@ -127,8 +127,9 @@ function useToolbarRovingTabIndex(focusableKeys) {
|
|
|
127
127
|
}
|
|
128
128
|
return { activeKey, setActiveKey, registerRef, handleKeyDown };
|
|
129
129
|
}
|
|
130
|
-
function ToolbarButton({ itemKey, label, ariaLabel,
|
|
131
|
-
|
|
130
|
+
function ToolbarButton({ itemKey, label, ariaLabel, active, disabled, expanded, hasPopup, isRovingActive, registerRef, onFocus, onClick, }) {
|
|
131
|
+
const button = (_jsx("button", { ref: registerRef, type: "button", "data-testid": `rt-toolbar-${itemKey}`, "aria-label": ariaLabel, "aria-pressed": active, "aria-haspopup": hasPopup, "aria-expanded": hasPopup ? expanded : undefined, disabled: disabled, tabIndex: disabled ? -1 : isRovingActive ? 0 : -1, onFocus: onFocus, onClick: onClick, className: cn("inline-flex h-8 items-center gap-1 rounded-md px-2 text-xs font-medium text-text-secondary hover:bg-background-hover disabled:pointer-events-none disabled:opacity-50", "focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600", active && "bg-primary-100 text-primary-800"), children: label }));
|
|
132
|
+
return ariaLabel ? _jsx(IconTooltip, { children: button }) : button;
|
|
132
133
|
}
|
|
133
134
|
function ToolbarSeparator() {
|
|
134
135
|
return _jsx("span", { "aria-hidden": "true", className: "mx-1 inline-block h-4 w-px bg-border-default" });
|
|
@@ -154,10 +155,10 @@ function LinkPopover({ initialHref, hasLink, onApply, onRemove, onClose }) {
|
|
|
154
155
|
if (href.trim())
|
|
155
156
|
onApply(href.trim());
|
|
156
157
|
}
|
|
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-
|
|
158
|
+
}, 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-hidden 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
159
|
}
|
|
159
160
|
// S197 Task 12: bubbles up so a mount that HAS routing (content-editor.tsx,
|
|
160
|
-
// admin-ui) can navigate to /content/:id/edit-on-page
|
|
161
|
+
// admin-ui) can navigate to /content/:id/edit-on-page, the same "plain DOM
|
|
161
162
|
// CustomEvent, no framework-specific callback" idiom the block chip's own
|
|
162
163
|
// "preview" button already uses (kardalum-block.ts's own doc comment), for
|
|
163
164
|
// the identical reason: this package has no router of its own, and the
|
|
@@ -185,7 +186,7 @@ function RichTextToolbar({ editor, containerRef, sourceMode, onToggleSource }) {
|
|
|
185
186
|
"editOnPage",
|
|
186
187
|
];
|
|
187
188
|
// Every other command is disabled in source mode (editing raw HTML has no
|
|
188
|
-
// "toggle bold" equivalent)
|
|
189
|
+
// "toggle bold" equivalent); Source itself is the only tab stop then, so
|
|
189
190
|
// the roving tabindex's own focusable set shrinks to match, same as the
|
|
190
191
|
// doc comment above useToolbarRovingTabIndex describes for disabled items.
|
|
191
192
|
const focusableKeys = sourceMode ? ["source"] : allItemKeys;
|
|
@@ -202,7 +203,7 @@ function RichTextToolbar({ editor, containerRef, sourceMode, onToggleSource }) {
|
|
|
202
203
|
}
|
|
203
204
|
}, [sourceMode]);
|
|
204
205
|
// The picked/uploaded item (S197 Task 2 contract) becomes a mediaId-backed
|
|
205
|
-
// image node
|
|
206
|
+
// image node: src is the item's path-relative downloadUrl, alt starts
|
|
206
207
|
// empty (there is no filename to fall back to once MediaPicker reports
|
|
207
208
|
// only {id, downloadUrl, alt}).
|
|
208
209
|
function handleMediaPick(item) {
|
|
@@ -234,11 +235,11 @@ function RichTextToolbar({ editor, containerRef, sourceMode, onToggleSource }) {
|
|
|
234
235
|
function RichTextEditor({ editable }) {
|
|
235
236
|
const { value, onChange } = usePluginValue();
|
|
236
237
|
// Guards the sync effect below against reacting to the update it just
|
|
237
|
-
// caused itself
|
|
238
|
+
// caused itself. Without this, every keystroke would round-trip
|
|
238
239
|
// through setContent and reset the cursor.
|
|
239
240
|
const isInternalUpdate = useRef(false);
|
|
240
241
|
// The host renders this inside a PropertyField, but TipTap's editable
|
|
241
|
-
// surface is a contenteditable <div role="textbox"
|
|
242
|
+
// surface is a contenteditable <div role="textbox">, not a labelable
|
|
242
243
|
// element, so the field's <label for> can never name it. editorProps
|
|
243
244
|
// .attributes is the only way to get aria onto that exact node, so the
|
|
244
245
|
// field's identity is stamped there instead (WCAG 4.1.2; axe reports
|
|
@@ -249,14 +250,14 @@ function RichTextEditor({ editable }) {
|
|
|
249
250
|
content: value ?? "",
|
|
250
251
|
editable,
|
|
251
252
|
// @tiptap/react 3.31 no longer re-renders the owning component on every
|
|
252
|
-
// transaction by default
|
|
253
|
+
// transaction by default. Without this the toolbar's isActive()/
|
|
253
254
|
// getAttributes() reads (bold state, the active heading level, the
|
|
254
255
|
// current link href) would go stale the instant the selection moves.
|
|
255
256
|
shouldRerenderOnTransaction: true,
|
|
256
257
|
editorProps: {
|
|
257
258
|
attributes: {
|
|
258
259
|
// ProseMirror's editable surface is a plain contenteditable div
|
|
259
|
-
// with NO role of its own
|
|
260
|
+
// with NO role of its own, which makes it a `generic` element,
|
|
260
261
|
// and aria-labelledby is *prohibited* on generic (axe flags the
|
|
261
262
|
// field's own label as "needs review": aria-prohibited-attr). The
|
|
262
263
|
// element genuinely IS a multi-line text field, so declaring that
|
|
@@ -273,7 +274,7 @@ function RichTextEditor({ editable }) {
|
|
|
273
274
|
const json = updated.getJSON();
|
|
274
275
|
// Non-edit 'update' events must not arm the echo guard below (they
|
|
275
276
|
// would swallow the next genuine external value change). The one
|
|
276
|
-
// programmatic emitter here
|
|
277
|
+
// programmatic emitter here (setEditable) is silenced at the
|
|
277
278
|
// source (emitUpdate: false, see the effect below), so any doc that
|
|
278
279
|
// still equals the external value is TipTap's own construction-time
|
|
279
280
|
// normalization pass, not an edit.
|
|
@@ -284,7 +285,7 @@ function RichTextEditor({ editable }) {
|
|
|
284
285
|
},
|
|
285
286
|
});
|
|
286
287
|
// Item 3 (S197 QA-wave B): the HTML source view. `null` means "not in
|
|
287
|
-
// source mode"
|
|
288
|
+
// source mode"; the textarea's own in-progress edits live here, entirely
|
|
288
289
|
// separate from `value`/onChange, until the toggle-back below commits
|
|
289
290
|
// them. Typing in source deliberately does NOT flow through onChange (the
|
|
290
291
|
// spec's own choice of the two offered): a half-typed `<p` mid-edit is not
|
|
@@ -292,21 +293,21 @@ function RichTextEditor({ editable }) {
|
|
|
292
293
|
// there is no debounce that makes an in-progress HTML string safe to
|
|
293
294
|
// parse. Commit happens on toggling back to the rich view; blurring the
|
|
294
295
|
// textarea without toggling back does NOT commit (the other choice the
|
|
295
|
-
// spec allows)
|
|
296
|
+
// spec allows): staying in source mode until the user explicitly asks to
|
|
296
297
|
// leave it means a click elsewhere never silently discards or applies an
|
|
297
298
|
// edit the user hasn't finished. Declared before the value-sync effect
|
|
298
299
|
// below (not just before its own toggle handler) because that effect
|
|
299
300
|
// needs to read the refs declared here.
|
|
300
301
|
const [sourceHtml, setSourceHtml] = useState(null);
|
|
301
302
|
const sourceMode = sourceHtml !== null;
|
|
302
|
-
// The HTML sourceHtml was last (re-)seeded with
|
|
303
|
+
// The HTML sourceHtml was last (re-)seeded with; sourceHtml !== this
|
|
303
304
|
// means the user has typed something, i.e. the buffer is "dirty". Used
|
|
304
305
|
// only by the external value-sync effect below to decide whether an
|
|
305
306
|
// external change can safely replace the buffer or must leave it (and
|
|
306
307
|
// the user's in-progress edits) alone. A ref, not state: nothing here
|
|
307
308
|
// needs to re-render on its own.
|
|
308
309
|
const sourceSeedRef = useRef(null);
|
|
309
|
-
// Whether an external value change arrived while the buffer was dirty
|
|
310
|
+
// Whether an external value change arrived while the buffer was dirty,
|
|
310
311
|
// shown as a small notice; cleared on toggle-back (the buffer commits,
|
|
311
312
|
// resolving the conflict) or on a later external change against a
|
|
312
313
|
// by-then-pristine buffer (re-seeded silently instead).
|
|
@@ -329,11 +330,11 @@ function RichTextEditor({ editable }) {
|
|
|
329
330
|
return;
|
|
330
331
|
}
|
|
331
332
|
// setContent's default emitUpdate: true fires the same onUpdate path a
|
|
332
|
-
// live edit would (JSON.stringify guard included)
|
|
333
|
+
// live edit would (JSON.stringify guard included), so no separate commit
|
|
333
334
|
// plumbing needed, this is the exact mechanism the external value-sync
|
|
334
335
|
// effect below already relies on. If an external change arrived while
|
|
335
336
|
// this buffer was dirty (sourceStale), this is the "informed overwrite"
|
|
336
|
-
// the notice warned about
|
|
337
|
+
// the notice warned about: the user's buffer wins, same as any other
|
|
337
338
|
// edit made after seeing the notice.
|
|
338
339
|
editor.commands.setContent(sourceHtml);
|
|
339
340
|
sourceSeedRef.current = null;
|
|
@@ -357,18 +358,18 @@ function RichTextEditor({ editable }) {
|
|
|
357
358
|
// back would setContent() the STALE buffer over it, re-emitting the
|
|
358
359
|
// stale content as a fresh edit and clobbering the external change.
|
|
359
360
|
// Refs (not state) so this effect doesn't need sourceMode/sourceHtml
|
|
360
|
-
// in its deps
|
|
361
|
+
// in its deps; it only needs their CURRENT values when `value`
|
|
361
362
|
// actually changes.
|
|
362
363
|
if (sourceModeRef.current) {
|
|
363
364
|
const pristine = sourceHtmlRef.current === sourceSeedRef.current;
|
|
364
365
|
if (!pristine) {
|
|
365
|
-
// The user has unsaved edits in the buffer
|
|
366
|
+
// The user has unsaved edits in the buffer: keep them (their
|
|
366
367
|
// choice to make, not this effect's), just flag that leaving
|
|
367
368
|
// source view now will overwrite the external change.
|
|
368
369
|
setSourceStale(true);
|
|
369
370
|
return;
|
|
370
371
|
}
|
|
371
|
-
// No local edits yet
|
|
372
|
+
// No local edits yet: safe to re-seed from the fresh external doc,
|
|
372
373
|
// same as the non-source branch below but keeping the textarea's
|
|
373
374
|
// displayed HTML in sync too.
|
|
374
375
|
editor.commands.setContent(value ?? "");
|
|
@@ -381,18 +382,18 @@ function RichTextEditor({ editable }) {
|
|
|
381
382
|
editor.commands.setContent(value ?? "");
|
|
382
383
|
}, [value, editor]);
|
|
383
384
|
useEffect(() => {
|
|
384
|
-
// emitUpdate: false
|
|
385
|
+
// emitUpdate: false, since setEditable's unconditional 'update' event is
|
|
385
386
|
// not an edit; silencing it at the source keeps onUpdate's arming
|
|
386
387
|
// logic honest (review fix, Editor.ts:307-313 in @tiptap/core 3.31).
|
|
387
388
|
editor?.setEditable(editable, false);
|
|
388
389
|
}, [editable, editor]);
|
|
389
390
|
// The block chip's "preview ⤢" button (kardalum-block.ts) is plain DOM with
|
|
390
|
-
// no React tree of its own
|
|
391
|
+
// no React tree of its own: it dispatches a bubbling
|
|
391
392
|
// "kardalum:preview-block" CustomEvent instead of fetching directly, since
|
|
392
393
|
// only this mount has the authenticated fetchApi and somewhere to render
|
|
393
394
|
// a popover. Listening on the wrapper (rather than threading a callback
|
|
394
395
|
// through buildRichtextExtensions' options) keeps the extension mount-
|
|
395
|
-
// agnostic
|
|
396
|
+
// agnostic: a vanilla mount can dispatch/listen for the same event with
|
|
396
397
|
// no React involved either.
|
|
397
398
|
const wrapperRef = useRef(null);
|
|
398
399
|
const [previewRequest, setPreviewRequest] = useState(null);
|
|
@@ -413,13 +414,13 @@ function RichTextEditor({ editable }) {
|
|
|
413
414
|
// right signal rather than separate open/close state.
|
|
414
415
|
const selection = editor?.state.selection;
|
|
415
416
|
const blockSelection = editor && selection instanceof NodeSelection && selection.node.type.name === "kardalumBlock" ? selection : null;
|
|
416
|
-
return (_jsxs("div", { ref: wrapperRef, className: cn(editable && "overflow-hidden rounded-md border border-border-default bg-background-elevated"), children: [_jsxs("div", { inert: editable && Boolean(blockSelection) ? true : undefined, children: [editable && editor && (_jsx(RichTextToolbar, { editor: editor, containerRef: wrapperRef, sourceMode: sourceMode, onToggleSource: handleToggleSource })), sourceMode ? (_jsxs(_Fragment, { children: [sourceStale && (_jsx("div", { role: "alert", "data-testid": "rt-source-stale-notice", className: "border-b border-warning-100 bg-warning-100 px-5 py-2 text-xs text-warning-800", children: "Content changed elsewhere. Leaving source view will overwrite it." })), _jsx("textarea", { "data-testid": "rt-source-textarea", "aria-label": "HTML source", value: sourceHtml, onChange: (event) => setSourceHtml(event.target.value), spellCheck: false, className: "block min-h-72 w-full resize-y border-0 bg-background-elevated px-5 py-4 font-mono text-xs text-text-primary focus-visible:outline-
|
|
417
|
+
return (_jsxs("div", { ref: wrapperRef, className: cn(editable && "overflow-hidden rounded-md border border-border-default bg-background-elevated"), children: [_jsxs("div", { inert: editable && Boolean(blockSelection) ? true : undefined, children: [editable && editor && (_jsx(RichTextToolbar, { editor: editor, containerRef: wrapperRef, sourceMode: sourceMode, onToggleSource: handleToggleSource })), sourceMode ? (_jsxs(_Fragment, { children: [sourceStale && (_jsx("div", { role: "alert", "data-testid": "rt-source-stale-notice", className: "border-b border-warning-100 bg-warning-100 px-5 py-2 text-xs text-warning-800", children: "Content changed elsewhere. Leaving source view will overwrite it." })), _jsx("textarea", { "data-testid": "rt-source-textarea", "aria-label": "HTML source", value: sourceHtml, onChange: (event) => setSourceHtml(event.target.value), spellCheck: false, className: "block min-h-72 w-full resize-y border-0 bg-background-elevated px-5 py-4 font-mono text-xs text-text-primary focus-visible:outline-hidden" })] })) : (_jsx(EditorContent, { editor: editor, className: cn(CONTENT_CLASSES, editable &&
|
|
417
418
|
// min-h-72 (18rem) matches the mockup's .rtbody proportions (S197
|
|
418
|
-
// screen 3)
|
|
419
|
+
// screen 3): the editor grows with content past that floor, it
|
|
419
420
|
// never shrinks below a real working height. px-5/py-4 are the
|
|
420
421
|
// token scale's closest steps to the mockup's literal 1.3rem/
|
|
421
422
|
// 1.1rem .rtbody padding (design-tokens has no 1.1/1.3rem step).
|
|
422
|
-
"min-h-72 px-5 py-4 focus-within:outline-
|
|
423
|
+
"min-h-72 px-5 py-4 focus-within:outline-hidden focus-within:ring-2 focus-within:ring-primary-600 focus-within:ring-offset-2 focus-within:ring-offset-background-base") }))] }), editable && editor && blockSelection && (_jsx(BlockPanel, { editor: editor, pos: blockSelection.from, partial: blockSelection.node.attrs.partial, params: blockSelection.node.attrs.params ?? {} })), previewRequest && (_jsx(BlockPreviewPopover, { partial: previewRequest.partial, params: previewRequest.params, anchorRect: previewRequest.anchorRect, onClose: () => setPreviewRequest(null) }))] }));
|
|
423
424
|
}
|
|
424
425
|
export function RichTextInputView() {
|
|
425
426
|
return _jsx(RichTextEditor, { editable: true });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
// The one error body shape every route uses
|
|
2
|
+
// The one error body shape every route uses: auth, content, media. Route
|
|
3
3
|
// handlers vary the status code, never the shape.
|
|
4
4
|
export const ApiErrorSchema = z.object({
|
|
5
5
|
message: z.string(),
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { TrashCursorSchema } from "./trash-cursor.schema.js";
|
|
3
|
-
import { AssetPathSchema, AssetVersionMetaSchema, AssetVersionSchema,
|
|
3
|
+
import { AssetPathSchema, AssetRoutePathSchema, AssetVersionMetaSchema, AssetVersionSchema, TrashedAssetSchema } from "./asset.schema.js";
|
|
4
4
|
import { VersionListQuerySchema } from "./content-api.schema.js";
|
|
5
5
|
// S192 asset tree browser: caps mirror the content-tree pagination
|
|
6
6
|
// philosophy (never load an unbounded subtree) even though the tree
|
|
7
|
-
// walk itself isn't cursor-paginated
|
|
7
|
+
// walk itself isn't cursor-paginated, but depth/entry caps bound the work.
|
|
8
8
|
export const ASSET_TREE_MAX_DEPTH = 8;
|
|
9
9
|
export const ASSET_TREE_MAX_ENTRIES = 2000;
|
|
10
10
|
export const AssetTreeEntrySchema = z.object({
|
|
11
|
-
path:
|
|
11
|
+
path: AssetRoutePathSchema,
|
|
12
12
|
kind: z.enum(["file", "folder"]),
|
|
13
13
|
size: z.number().int().min(0).nullable(),
|
|
14
14
|
mtimeMs: z.number().nullable(),
|
|
@@ -25,7 +25,7 @@ export const AssetTreeResponseSchema = z.object({
|
|
|
25
25
|
skipped: z.array(AssetTreeSkipSchema).optional(),
|
|
26
26
|
});
|
|
27
27
|
export const AssetContentResponseSchema = z.object({
|
|
28
|
-
path:
|
|
28
|
+
path: AssetRoutePathSchema,
|
|
29
29
|
content: z.string(),
|
|
30
30
|
size: z.number().int(),
|
|
31
31
|
registered: z.boolean(),
|
|
@@ -33,22 +33,24 @@ export const AssetContentResponseSchema = z.object({
|
|
|
33
33
|
version: z.number().int().min(1).nullable(),
|
|
34
34
|
});
|
|
35
35
|
export const WriteAssetContentRequestSchema = z
|
|
36
|
-
.object({ path:
|
|
36
|
+
.object({ path: AssetRoutePathSchema, content: z.string() })
|
|
37
37
|
.strict();
|
|
38
|
-
export const CreateAssetFolderRequestSchema = z.object({ path:
|
|
38
|
+
export const CreateAssetFolderRequestSchema = z.object({ path: AssetRoutePathSchema }).strict();
|
|
39
39
|
export const RenameAssetRequestSchema = z
|
|
40
|
-
.object({ path:
|
|
41
|
-
.strict()
|
|
40
|
+
.object({ path: AssetRoutePathSchema, newPath: AssetRoutePathSchema })
|
|
41
|
+
.strict()
|
|
42
|
+
// S314c6 (D6): both fields would otherwise show the same path, a rename that moves nothing.
|
|
43
|
+
.meta({ example: { path: "css/site.css", newPath: "css/main.css" } });
|
|
42
44
|
// DELETE /api/manage/v1/assets is a two-step confirm gate like content trash and
|
|
43
45
|
// plugin uninstall: confirm is a literal "true" query string (not a
|
|
44
46
|
// boolean) because query params are always strings on the wire.
|
|
45
47
|
export const DeleteAssetQuerySchema = z.object({
|
|
46
|
-
path:
|
|
48
|
+
path: AssetRoutePathSchema,
|
|
47
49
|
confirm: z.enum(["true"]).optional(),
|
|
48
50
|
});
|
|
49
51
|
export const AssetDeleteBlockedResponseSchema = z.object({
|
|
50
52
|
requiresConfirmation: z.literal(true),
|
|
51
|
-
path:
|
|
53
|
+
path: AssetRoutePathSchema,
|
|
52
54
|
kind: z.enum(["file", "folder"]),
|
|
53
55
|
entryCount: z.number().int().min(0),
|
|
54
56
|
registered: z.boolean(),
|
|
@@ -57,7 +59,7 @@ export const AssetDeleteBlockedResponseSchema = z.object({
|
|
|
57
59
|
export const ZipExtractReportSchema = z.object({
|
|
58
60
|
extracted: z.number().int().min(0),
|
|
59
61
|
skipped: z.array(z.object({ path: z.string(), reason: z.string() })),
|
|
60
|
-
targetFolder: AssetPathSchema.nullable(),
|
|
62
|
+
targetFolder: AssetPathSchema.meta({ example: "css" }).nullable(),
|
|
61
63
|
});
|
|
62
64
|
export const AssetSyncReportSchema = z.object({
|
|
63
65
|
checked: z.number().int(),
|
|
@@ -67,17 +69,17 @@ export const AssetSyncReportSchema = z.object({
|
|
|
67
69
|
// S314g (D5, P3): a registered text asset's history, addressed by its path as
|
|
68
70
|
// the other asset routes are. Same paging as the template history.
|
|
69
71
|
export const AssetVersionParamsSchema = z.object({ version: z.coerce.number().int().positive() });
|
|
70
|
-
export const AssetVersionListQuerySchema = VersionListQuerySchema.extend({ path:
|
|
71
|
-
export const AssetVersionQuerySchema = z.object({ path:
|
|
72
|
+
export const AssetVersionListQuerySchema = VersionListQuerySchema.extend({ path: AssetRoutePathSchema });
|
|
73
|
+
export const AssetVersionQuerySchema = z.object({ path: AssetRoutePathSchema });
|
|
72
74
|
export const AssetVersionListResponseSchema = z.object({
|
|
73
75
|
items: z.array(AssetVersionMetaSchema),
|
|
74
76
|
nextCursor: z.number().int().positive().nullable(),
|
|
75
77
|
});
|
|
76
78
|
export const AssetVersionResponseSchema = z.object({ version: AssetVersionSchema });
|
|
77
|
-
export const MakeAssetVersionCurrentRequestSchema = z.object({ path:
|
|
79
|
+
export const MakeAssetVersionCurrentRequestSchema = z.object({ path: AssetRoutePathSchema }).strict();
|
|
78
80
|
// The path D5 names, and the trashed row's id from the trash list: 0014 lets
|
|
79
81
|
// several trashed rows share one path, so the path alone cannot say which.
|
|
80
|
-
export const RestoreAssetRequestSchema = z.object({ path:
|
|
82
|
+
export const RestoreAssetRequestSchema = z.object({ path: AssetRoutePathSchema, id: z.string().uuid() }).strict();
|
|
81
83
|
// The restore's answer: the asset's content response, and whether a file found
|
|
82
84
|
// at the path was kept as a file-sync version first (as RestoreTemplateResponse).
|
|
83
85
|
export const RestoreAssetResponseSchema = AssetContentResponseSchema.extend({ foldedFile: z.boolean() });
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { DataTypeConfig } from "./data-type-config.schema.js";
|
|
3
|
+
export declare const ASSET_EDITOR_ID = "com.kardalum.asset";
|
|
4
|
+
export declare const ASSET_DATA_TYPE_ID = "b1e00000-0000-4000-8000-000000000014";
|
|
5
|
+
export declare const ASSET_IMAGE_EXTENSIONS: readonly ["png", "jpg", "jpeg", "gif", "webp", "svg", "avif"];
|
|
6
|
+
export declare const ASSET_ACCEPTS: readonly ["images", "any"];
|
|
7
|
+
export type AssetAccepts = (typeof ASSET_ACCEPTS)[number];
|
|
8
|
+
export declare const AssetFieldSettingsSchema: z.ZodObject<{
|
|
9
|
+
accepts: z.ZodDefault<z.ZodEnum<{
|
|
10
|
+
any: "any";
|
|
11
|
+
images: "images";
|
|
12
|
+
}>>;
|
|
13
|
+
startFolder: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
export type AssetFieldSettings = z.infer<typeof AssetFieldSettingsSchema>;
|
|
16
|
+
/** The last segment's extension, lower-cased, or "" when it has none (a leading dot is not one). */
|
|
17
|
+
export declare function assetExtension(path: string): string;
|
|
18
|
+
export declare function assetPathIsImage(path: string): boolean;
|
|
19
|
+
/** Whether a field with this `accepts` setting takes the file: a stored settings bag may lack the key, which means images. */
|
|
20
|
+
export declare function assetPathAccepted(path: string, accepts: unknown): boolean;
|
|
21
|
+
export declare const ASSET_DATA_TYPE_CONFIG: DataTypeConfig;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AssetPathSchema } from "./asset.schema.js";
|
|
3
|
+
// S314p (D3): the Asset data type. Its field points at a file under Settings, Assets (public/),
|
|
4
|
+
// stored as the path that screen shows, so a script can write it and a site built from an HTML
|
|
5
|
+
// kit can use the pictures it already has. A template gets the file's address, worked out at
|
|
6
|
+
// render (spec C5).
|
|
7
|
+
export const ASSET_EDITOR_ID = "com.kardalum.asset";
|
|
8
|
+
// The b1e00000 block continues: 0001 to 0009, 0012 and 0013 are seeded, and 0010 and 0011 are
|
|
9
|
+
// fixtures in document-type.schema.test.ts (see media-rendition.schema.ts).
|
|
10
|
+
export const ASSET_DATA_TYPE_ID = "b1e00000-0000-4000-8000-000000000014";
|
|
11
|
+
export const ASSET_IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "svg", "avif"];
|
|
12
|
+
export const ASSET_ACCEPTS = ["images", "any"];
|
|
13
|
+
// `.strict()` with defaults, the crop's idiom: the JSON Schema mirror in plugin-sdk is generated
|
|
14
|
+
// in input mode, and a strict object keeps `additionalProperties: false` there.
|
|
15
|
+
export const AssetFieldSettingsSchema = z
|
|
16
|
+
.object({
|
|
17
|
+
accepts: z.enum(ASSET_ACCEPTS).default("images"),
|
|
18
|
+
startFolder: AssetPathSchema.nullable().default(null),
|
|
19
|
+
})
|
|
20
|
+
.strict();
|
|
21
|
+
/** The last segment's extension, lower-cased, or "" when it has none (a leading dot is not one). */
|
|
22
|
+
export function assetExtension(path) {
|
|
23
|
+
const name = path.slice(path.lastIndexOf("/") + 1);
|
|
24
|
+
const dot = name.lastIndexOf(".");
|
|
25
|
+
return dot <= 0 ? "" : name.slice(dot + 1).toLowerCase();
|
|
26
|
+
}
|
|
27
|
+
export function assetPathIsImage(path) {
|
|
28
|
+
return ASSET_IMAGE_EXTENSIONS.includes(assetExtension(path));
|
|
29
|
+
}
|
|
30
|
+
/** Whether a field with this `accepts` setting takes the file: a stored settings bag may lack the key, which means images. */
|
|
31
|
+
export function assetPathAccepted(path, accepts) {
|
|
32
|
+
return accepts === "any" || assetPathIsImage(path);
|
|
33
|
+
}
|
|
34
|
+
// Seeded by migration 0033 on every install, never by BUILT_IN_DATA_TYPE_CONFIGS (0006 inserts
|
|
35
|
+
// that array only while it creates the table). The settings are parsed, so the stored row is the
|
|
36
|
+
// object the data types screen saves back unchanged.
|
|
37
|
+
export const ASSET_DATA_TYPE_CONFIG = {
|
|
38
|
+
id: ASSET_DATA_TYPE_ID,
|
|
39
|
+
name: "Asset",
|
|
40
|
+
editorId: ASSET_EDITOR_ID,
|
|
41
|
+
settings: AssetFieldSettingsSchema.parse({}),
|
|
42
|
+
};
|
|
@@ -54,16 +54,23 @@ export const AssetPathSchema = z
|
|
|
54
54
|
message: "this path root is reserved for the server (see RESERVED_ROOT_SLUGS)",
|
|
55
55
|
})
|
|
56
56
|
.describe("A path under public/: segments of letters, digits, spaces and _ - . ~ @ + , ( ) ! $ ' = ; & joined by /, none starting with a dot or ending with a dot or space, each at most 255 bytes, never under a reserved root.");
|
|
57
|
+
// S314c6 (D6): the generator's name rule gives a `path` field "/about-us", whose leading slash
|
|
58
|
+
// is the empty segment the refinements refuse. A route's path field carries a valid example;
|
|
59
|
+
// the shared AssetPathSchema stays without one, because the asset field's settings
|
|
60
|
+
// (startFolder, mirrored in the plugin SDK) reuse it for a folder.
|
|
61
|
+
export const AssetRoutePathSchema = AssetPathSchema.meta({ example: "css/site.css" });
|
|
57
62
|
export const AssetDefinitionSchema = z
|
|
58
63
|
.object({
|
|
59
64
|
id: z.string().uuid(),
|
|
60
|
-
path:
|
|
65
|
+
path: AssetRoutePathSchema,
|
|
61
66
|
pluginId: z.string().min(1).nullable(),
|
|
62
67
|
currentVersion: z.number().int().min(1),
|
|
63
68
|
})
|
|
64
69
|
.strict();
|
|
65
|
-
//
|
|
66
|
-
//
|
|
70
|
+
// S314c3 (D8): the default of a site's asset limit, in UTF-8 bytes. The server holds every
|
|
71
|
+
// write to KARDALUM_MAX_ASSET_BYTES (this number unless raised); the plugin build holds a
|
|
72
|
+
// package to this number (D10). The request schemas carry no maximum of their own, so the
|
|
73
|
+
// configured limit is enforced in one place.
|
|
67
74
|
export const MAX_ASSET_CONTENT_BYTES = 5_242_880;
|
|
68
75
|
export const AssetVersionSchema = z
|
|
69
76
|
.object({
|
|
@@ -19,7 +19,7 @@ const AuthUserSchema = z.object({
|
|
|
19
19
|
* at worst shows a control the server then refuses. */
|
|
20
20
|
actions: z.array(z.string()),
|
|
21
21
|
});
|
|
22
|
-
// The refresh token itself never appears in a request/response body
|
|
22
|
+
// The refresh token itself never appears in a request/response body: it
|
|
23
23
|
// travels only as an httpOnly cookie (see routes/auth.ts), so the JS client
|
|
24
24
|
// can never read it, and a page reload doesn't lose it.
|
|
25
25
|
export const LoginResponseSchema = z.object({
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type PlanShapeValue } from "./plan-editor.schema.js";
|
|
3
|
+
/** At most 7 digits: the plan cap is 1 000 000 cents. */
|
|
4
|
+
export declare const SHOWN_PRICE_DIGITS_MAX = 7;
|
|
5
|
+
/**
|
|
6
|
+
* Whole cents written as decimal digits. A linear scan with the length
|
|
7
|
+
* checked first, never a regex (a form field is untrusted text). Null unless
|
|
8
|
+
* it is a whole number from 0 to PLAN_MAX_PRICE_CENTS.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseShownCents(text: string): number | null;
|
|
11
|
+
export type ShownPlan = {
|
|
12
|
+
priceCents: number;
|
|
13
|
+
shape: PlanShapeValue;
|
|
14
|
+
};
|
|
15
|
+
export declare const ShownPlanFieldsSchema: z.ZodPipe<z.ZodObject<{
|
|
16
|
+
shownPriceCents: z.ZodString;
|
|
17
|
+
shownShape: z.ZodEnum<{
|
|
18
|
+
free: "free";
|
|
19
|
+
one_time: "one_time";
|
|
20
|
+
monthly: "monthly";
|
|
21
|
+
yearly: "yearly";
|
|
22
|
+
}>;
|
|
23
|
+
}, z.core.$strip>, z.ZodTransform<ShownPlan, {
|
|
24
|
+
shownPriceCents: string;
|
|
25
|
+
shownShape: "free" | "one_time" | "monthly" | "yearly";
|
|
26
|
+
}>>;
|
|
27
|
+
/** The two form fields, or null when either is missing or unreadable (read as a mismatch). */
|
|
28
|
+
export declare function readShownPlan(fields: {
|
|
29
|
+
shownPriceCents: unknown;
|
|
30
|
+
shownShape: unknown;
|
|
31
|
+
}): ShownPlan | null;
|
|
32
|
+
/** The plan still costs what the buyer was shown, in the kind they were shown. */
|
|
33
|
+
export declare function shownPlanMatches(shown: ShownPlan, plan: {
|
|
34
|
+
shape: string;
|
|
35
|
+
priceCents: number;
|
|
36
|
+
}): boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { PLAN_MAX_PRICE_CENTS, PlanShapeSchema } from "./plan-editor.schema.js";
|
|
3
|
+
// S322 (spec D3, 3a): what a buyer was shown, carried by every form that can
|
|
4
|
+
// charge or schedule a charge. The marketplace action compares it with the
|
|
5
|
+
// plan and refuses on a mismatch before any checkout or schedule exists.
|
|
6
|
+
/** At most 7 digits: the plan cap is 1 000 000 cents. */
|
|
7
|
+
export const SHOWN_PRICE_DIGITS_MAX = 7;
|
|
8
|
+
/**
|
|
9
|
+
* Whole cents written as decimal digits. A linear scan with the length
|
|
10
|
+
* checked first, never a regex (a form field is untrusted text). Null unless
|
|
11
|
+
* it is a whole number from 0 to PLAN_MAX_PRICE_CENTS.
|
|
12
|
+
*/
|
|
13
|
+
export function parseShownCents(text) {
|
|
14
|
+
if (text.length < 1 || text.length > SHOWN_PRICE_DIGITS_MAX)
|
|
15
|
+
return null;
|
|
16
|
+
let cents = 0;
|
|
17
|
+
for (let i = 0; i < text.length; i++) {
|
|
18
|
+
const c = text.charCodeAt(i);
|
|
19
|
+
if (c < 48 || c > 57)
|
|
20
|
+
return null;
|
|
21
|
+
cents = cents * 10 + (c - 48);
|
|
22
|
+
}
|
|
23
|
+
return cents <= PLAN_MAX_PRICE_CENTS ? cents : null;
|
|
24
|
+
}
|
|
25
|
+
export const ShownPlanFieldsSchema = z
|
|
26
|
+
.object({
|
|
27
|
+
shownPriceCents: z.string().max(SHOWN_PRICE_DIGITS_MAX),
|
|
28
|
+
shownShape: PlanShapeSchema,
|
|
29
|
+
})
|
|
30
|
+
.transform((fields, ctx) => {
|
|
31
|
+
const priceCents = parseShownCents(fields.shownPriceCents);
|
|
32
|
+
if (priceCents === null) {
|
|
33
|
+
ctx.addIssue({ code: "custom", message: "The shown price is not a whole number of cents", path: ["shownPriceCents"] });
|
|
34
|
+
return z.NEVER;
|
|
35
|
+
}
|
|
36
|
+
return { priceCents, shape: fields.shownShape };
|
|
37
|
+
});
|
|
38
|
+
/** The two form fields, or null when either is missing or unreadable (read as a mismatch). */
|
|
39
|
+
export function readShownPlan(fields) {
|
|
40
|
+
const parsed = ShownPlanFieldsSchema.safeParse(fields);
|
|
41
|
+
return parsed.success ? parsed.data : null;
|
|
42
|
+
}
|
|
43
|
+
/** The plan still costs what the buyer was shown, in the kind they were shown. */
|
|
44
|
+
export function shownPlanMatches(shown, plan) {
|
|
45
|
+
return shown.shape === plan.shape && shown.priceCents === plan.priceCents;
|
|
46
|
+
}
|
|
@@ -11,6 +11,11 @@ export declare const CreateContentRequestSchema: z.ZodObject<{
|
|
|
11
11
|
}, z.core.$strip>;
|
|
12
12
|
export type CreateContentRequest = z.infer<typeof CreateContentRequestSchema>;
|
|
13
13
|
export declare const ContentItemResponseSchema: z.ZodObject<{
|
|
14
|
+
readOnlyFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
15
|
+
fieldAlias: z.ZodString;
|
|
16
|
+
pluginId: z.ZodString;
|
|
17
|
+
message: z.ZodString;
|
|
18
|
+
}, z.core.$strip>>>;
|
|
14
19
|
node: z.ZodObject<{
|
|
15
20
|
id: z.ZodString;
|
|
16
21
|
parentId: z.ZodNullable<z.ZodString>;
|
|
@@ -19,6 +24,7 @@ export declare const ContentItemResponseSchema: z.ZodObject<{
|
|
|
19
24
|
sortOrder: z.ZodNumber;
|
|
20
25
|
documentTypeId: z.ZodString;
|
|
21
26
|
publishedAt: z.ZodNullable<z.ZodString>;
|
|
27
|
+
name: z.ZodOptional<z.ZodString>;
|
|
22
28
|
}, z.core.$strip>;
|
|
23
29
|
url: z.ZodNullable<z.ZodString>;
|
|
24
30
|
version: z.ZodObject<{
|
|
@@ -185,6 +191,11 @@ export declare const SaveContentRequestSchema: z.ZodObject<{
|
|
|
185
191
|
}, z.core.$strip>;
|
|
186
192
|
export type SaveContentRequest = z.infer<typeof SaveContentRequestSchema>;
|
|
187
193
|
export declare const SaveContentResponseSchema: z.ZodObject<{
|
|
194
|
+
readOnlyFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
195
|
+
fieldAlias: z.ZodString;
|
|
196
|
+
pluginId: z.ZodString;
|
|
197
|
+
message: z.ZodString;
|
|
198
|
+
}, z.core.$strip>>>;
|
|
188
199
|
version: z.ZodObject<{
|
|
189
200
|
id: z.ZodString;
|
|
190
201
|
contentId: z.ZodString;
|
|
@@ -224,6 +235,8 @@ export declare const LatestVersionResponseSchema: z.ZodObject<{
|
|
|
224
235
|
createdAt: z.ZodString;
|
|
225
236
|
createdBy: z.ZodString;
|
|
226
237
|
}, z.core.$strip>;
|
|
238
|
+
defaultCulture: z.ZodOptional<z.ZodString>;
|
|
239
|
+
saveKeepsName: z.ZodOptional<z.ZodLiteral<true>>;
|
|
227
240
|
fellBack: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
228
241
|
}, z.core.$strip>;
|
|
229
242
|
export type LatestVersionResponse = z.infer<typeof LatestVersionResponseSchema>;
|