@signalsafe/content-editor-react 0.0.0-stage → 0.1.1
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/README.md +105 -2
- package/dist/BootstrapBlockRenderer.d.ts +10 -0
- package/dist/BootstrapBlockRenderer.js +256 -0
- package/dist/BootstrapInlineCanvasEditor.d.ts +11 -0
- package/dist/BootstrapInlineCanvasEditor.js +38 -0
- package/dist/BootstrapInlineText.d.ts +9 -0
- package/dist/BootstrapInlineText.js +121 -0
- package/dist/BootstrapNavigationBlocks.d.ts +13 -0
- package/dist/BootstrapNavigationBlocks.js +33 -0
- package/dist/BootstrapProgressGroup.d.ts +11 -0
- package/dist/BootstrapProgressGroup.js +13 -0
- package/dist/BootstrapProperties.d.ts +15 -0
- package/dist/BootstrapProperties.js +217 -0
- package/dist/CanvasTheme.d.ts +25 -0
- package/dist/CanvasTheme.js +34 -0
- package/dist/CollectionRowActions.d.ts +19 -0
- package/dist/CollectionRowActions.js +9 -0
- package/dist/ColorModeSelect.d.ts +9 -0
- package/dist/ColorModeSelect.js +28 -0
- package/dist/ColumnContent.d.ts +6 -0
- package/dist/ColumnContent.js +6 -0
- package/dist/ComponentPicker.d.ts +10 -0
- package/dist/ComponentPicker.js +22 -0
- package/dist/ComponentPickerIcon.d.ts +3 -0
- package/dist/ComponentPickerIcon.js +52 -0
- package/dist/ContentEditor.d.ts +16 -0
- package/dist/ContentEditor.js +73 -0
- package/dist/ContentImage.d.ts +16 -0
- package/dist/ContentImage.js +45 -0
- package/dist/ContentInteractionProvider.d.ts +21 -0
- package/dist/ContentInteractionProvider.js +102 -0
- package/dist/ContentKeyboardHelp.d.ts +4 -0
- package/dist/ContentKeyboardHelp.js +8 -0
- package/dist/ContentOutline.d.ts +20 -0
- package/dist/ContentOutline.js +71 -0
- package/dist/ContentRuntime.d.ts +28 -0
- package/dist/ContentRuntime.js +13 -0
- package/dist/EditorActionIcon.d.ts +18 -0
- package/dist/EditorActionIcon.js +32 -0
- package/dist/EditorCanvasScroll.d.ts +6 -0
- package/dist/EditorCanvasScroll.js +82 -0
- package/dist/EditorCanvasSettings.d.ts +5 -0
- package/dist/EditorCanvasSettings.js +21 -0
- package/dist/EditorCanvasToolbar.d.ts +16 -0
- package/dist/EditorCanvasToolbar.js +22 -0
- package/dist/EditorCollectionAdd.d.ts +6 -0
- package/dist/EditorCollectionAdd.js +6 -0
- package/dist/EditorCollectionRow.d.ts +18 -0
- package/dist/EditorCollectionRow.js +6 -0
- package/dist/EditorCommandBar.d.ts +7 -0
- package/dist/EditorCommandBar.js +9 -0
- package/dist/EditorContainerFields.d.ts +17 -0
- package/dist/EditorContainerFields.js +27 -0
- package/dist/EditorHistoryControls.d.ts +8 -0
- package/dist/EditorHistoryControls.js +6 -0
- package/dist/EditorIssuesPanel.d.ts +5 -0
- package/dist/EditorIssuesPanel.js +6 -0
- package/dist/EditorLayoutMenu.d.ts +23 -0
- package/dist/EditorLayoutMenu.js +13 -0
- package/dist/EditorMenuChoice.d.ts +8 -0
- package/dist/EditorMenuChoice.js +6 -0
- package/dist/EditorPanel.d.ts +10 -0
- package/dist/EditorPanel.js +12 -0
- package/dist/EditorPreviewToggle.d.ts +6 -0
- package/dist/EditorPreviewToggle.js +6 -0
- package/dist/EditorSidebarLayout.d.ts +8 -0
- package/dist/EditorSidebarLayout.js +29 -0
- package/dist/EditorStatusBar.d.ts +5 -0
- package/dist/EditorStatusBar.js +8 -0
- package/dist/EditorStatusBarContext.d.ts +2 -0
- package/dist/EditorStatusBarContext.js +3 -0
- package/dist/EditorSubmenu.d.ts +18 -0
- package/dist/EditorSubmenu.js +74 -0
- package/dist/EditorTabs.d.ts +9 -0
- package/dist/EditorTabs.js +28 -0
- package/dist/EditorTemplateMenu.d.ts +12 -0
- package/dist/EditorTemplateMenu.js +7 -0
- package/dist/EditorViewportSelect.d.ts +30 -0
- package/dist/EditorViewportSelect.js +17 -0
- package/dist/EditorWorkflowActions.d.ts +12 -0
- package/dist/EditorWorkflowActions.js +6 -0
- package/dist/EmptyContent.d.ts +6 -0
- package/dist/EmptyContent.js +18 -0
- package/dist/InlineCanvasEditor.d.ts +7 -0
- package/dist/InlineCanvasEditor.js +12 -0
- package/dist/InteractiveBootstrapBlocks.d.ts +17 -0
- package/dist/InteractiveBootstrapBlocks.js +434 -0
- package/dist/JsonEditor.css +163 -0
- package/dist/JsonTextEditor.d.ts +11 -0
- package/dist/JsonTextEditor.js +70 -0
- package/dist/JsonViewer.d.ts +15 -0
- package/dist/JsonViewer.js +109 -0
- package/dist/LayoutPresets.d.ts +8 -0
- package/dist/LayoutPresets.js +66 -0
- package/dist/LayoutPropertyFields.d.ts +8 -0
- package/dist/LayoutPropertyFields.js +43 -0
- package/dist/MarkdownEditor.d.ts +13 -0
- package/dist/MarkdownEditor.js +82 -0
- package/dist/PracticeInputBlock.d.ts +12 -0
- package/dist/PracticeInputBlock.js +21 -0
- package/dist/ReadableButton.d.ts +5 -0
- package/dist/ReadableButton.js +20 -0
- package/dist/ReadableDropdownSurface.d.ts +6 -0
- package/dist/ReadableDropdownSurface.js +16 -0
- package/dist/ReadableDropdownToggle.d.ts +2 -0
- package/dist/ReadableDropdownToggle.js +14 -0
- package/dist/ReadableFormSelect.d.ts +3 -0
- package/dist/ReadableFormSelect.js +10 -0
- package/dist/ReorderHandle.d.ts +15 -0
- package/dist/ReorderHandle.js +31 -0
- package/dist/ReorderTarget.d.ts +10 -0
- package/dist/ReorderTarget.js +7 -0
- package/dist/SpacingEditor.d.ts +9 -0
- package/dist/SpacingEditor.js +53 -0
- package/dist/authoringActions.d.ts +18 -0
- package/dist/authoringActions.js +172 -0
- package/dist/authoringText.d.ts +4 -0
- package/dist/authoringText.js +45 -0
- package/dist/authoringUuid.d.ts +2 -0
- package/dist/authoringUuid.js +11 -0
- package/dist/bootstrapFamilies.d.ts +10 -0
- package/dist/bootstrapFamilies.js +151 -0
- package/dist/bootstrapGridImport.d.ts +8 -0
- package/dist/bootstrapGridImport.js +122 -0
- package/dist/bootstrapGridMigration.d.ts +3 -0
- package/dist/bootstrapGridMigration.js +27 -0
- package/dist/bootstrapRegistry.d.ts +69 -0
- package/dist/bootstrapRegistry.js +966 -0
- package/dist/canvasPreferences.d.ts +27 -0
- package/dist/canvasPreferences.js +28 -0
- package/dist/collectionNavigation.d.ts +20 -0
- package/dist/collectionNavigation.js +38 -0
- package/dist/componentPickerFamilies.d.ts +5 -0
- package/dist/componentPickerFamilies.js +40 -0
- package/dist/componentPolicy.d.ts +31 -0
- package/dist/componentPolicy.js +25 -0
- package/dist/componentValidation.d.ts +23707 -0
- package/dist/componentValidation.js +7 -0
- package/dist/content-editor.css +584 -0
- package/dist/content-layout.css +597 -0
- package/dist/contentContainment.d.ts +4 -0
- package/dist/contentContainment.js +117 -0
- package/dist/contentCssPath.d.ts +5 -0
- package/dist/contentCssPath.js +63 -0
- package/dist/contentEditingCommands.d.ts +35 -0
- package/dist/contentEditingCommands.js +69 -0
- package/dist/contentInsertion.d.ts +3 -0
- package/dist/contentInsertion.js +16 -0
- package/dist/contentModel.d.ts +3 -0
- package/dist/contentModel.js +1 -0
- package/dist/contentTreeValidation.d.ts +8 -0
- package/dist/contentTreeValidation.js +211 -0
- package/dist/contracts/semantics.gen.d.ts +2 -0
- package/dist/contracts/semantics.gen.js +3 -0
- package/dist/contracts/types.gen.d.ts +3741 -0
- package/dist/contracts/types.gen.js +1 -0
- package/dist/contracts/zod.gen.d.ts +62365 -0
- package/dist/contracts/zod.gen.js +3036 -0
- package/dist/controlBackgroundIconContrast.d.ts +3 -0
- package/dist/controlBackgroundIconContrast.js +60 -0
- package/dist/dropdownContrast.d.ts +5 -0
- package/dist/dropdownContrast.js +34 -0
- package/dist/editor-ui-colors.css +40 -0
- package/dist/editorThemes.d.ts +10 -0
- package/dist/editorThemes.js +12 -0
- package/dist/inlineMarkup.d.ts +6 -0
- package/dist/inlineMarkup.js +171 -0
- package/dist/layout.d.ts +17 -0
- package/dist/layout.js +37 -0
- package/dist/nestedComponentLabel.d.ts +2 -0
- package/dist/nestedComponentLabel.js +17 -0
- package/dist/responsiveLayout.d.ts +51 -0
- package/dist/responsiveLayout.js +97 -0
- package/dist/slideAppearance.d.ts +25 -0
- package/dist/slideAppearance.js +283 -0
- package/dist/source-manifest.json +105 -0
- package/dist/spacingShorthand.d.ts +12 -0
- package/dist/spacingShorthand.js +47 -0
- package/dist/themes/canvas-themes.css +131 -0
- package/dist/useCanvasSelectionScroll.d.ts +3 -0
- package/dist/useCanvasSelectionScroll.js +51 -0
- package/dist/useContentHistory.d.ts +40 -0
- package/dist/useContentHistory.js +42 -0
- package/dist/useContentReorderTarget.d.ts +6 -0
- package/dist/useContentReorderTarget.js +44 -0
- package/dist/useContentSelection.d.ts +10 -0
- package/dist/useContentSelection.js +23 -0
- package/dist/useDropdownContrast.d.ts +16 -0
- package/dist/useDropdownContrast.js +145 -0
- package/dist/useEditorControlContrast.d.ts +3 -0
- package/dist/useEditorControlContrast.js +188 -0
- package/dist/useSiteThemeStyles.d.ts +3 -0
- package/dist/useSiteThemeStyles.js +30 -0
- package/dist/useValidationFocus.d.ts +5 -0
- package/dist/useValidationFocus.js +17 -0
- package/package.json +74 -5
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export type CanvasEditorKind = 'content' | 'lesson';
|
|
3
|
+
declare const preferencesSchema: z.ZodObject<{
|
|
4
|
+
version: z.ZodLiteral<1>;
|
|
5
|
+
theme: z.ZodEnum<{
|
|
6
|
+
Sandstone: "Sandstone";
|
|
7
|
+
Bootstrap: "Bootstrap";
|
|
8
|
+
Flatly: "Flatly";
|
|
9
|
+
Darkly: "Darkly";
|
|
10
|
+
Litera: "Litera";
|
|
11
|
+
Lux: "Lux";
|
|
12
|
+
Minty: "Minty";
|
|
13
|
+
Slate: "Slate";
|
|
14
|
+
Superhero: "Superhero";
|
|
15
|
+
Cyborg: "Cyborg";
|
|
16
|
+
}>;
|
|
17
|
+
colorMode: z.ZodDefault<z.ZodEnum<{
|
|
18
|
+
light: "light";
|
|
19
|
+
dark: "dark";
|
|
20
|
+
}>>;
|
|
21
|
+
width: z.ZodNullable<z.ZodNumber>;
|
|
22
|
+
}, z.core.$strict>;
|
|
23
|
+
export type CanvasPreferences = z.infer<typeof preferencesSchema>;
|
|
24
|
+
export declare function canvasPreferencesKey(editor: CanvasEditorKind): string;
|
|
25
|
+
export declare function loadCanvasPreferences(editor?: CanvasEditorKind): CanvasPreferences;
|
|
26
|
+
export declare function saveCanvasPreferences(editor: CanvasEditorKind, preferences: CanvasPreferences): void;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EDITOR_THEMES } from './editorThemes.js';
|
|
3
|
+
const preferencesSchema = z.object({
|
|
4
|
+
version: z.literal(1),
|
|
5
|
+
theme: z.enum(EDITOR_THEMES),
|
|
6
|
+
colorMode: z.enum(['light', 'dark']).default('light'),
|
|
7
|
+
width: z.number().int().min(240).max(7680).nullable(),
|
|
8
|
+
}).strict();
|
|
9
|
+
const DEFAULT_PREFERENCES = { version: 1, theme: 'Sandstone', colorMode: 'light', width: null };
|
|
10
|
+
export function canvasPreferencesKey(editor) { return `signalsafe.editor-canvas.v1:${editor}`; }
|
|
11
|
+
export function loadCanvasPreferences(editor) {
|
|
12
|
+
if (!editor)
|
|
13
|
+
return DEFAULT_PREFERENCES;
|
|
14
|
+
try {
|
|
15
|
+
const raw = JSON.parse(localStorage.getItem(canvasPreferencesKey(editor)) ?? 'null');
|
|
16
|
+
const parsed = preferencesSchema.safeParse(raw);
|
|
17
|
+
return parsed.success ? parsed.data : DEFAULT_PREFERENCES;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return DEFAULT_PREFERENCES;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function saveCanvasPreferences(editor, preferences) {
|
|
24
|
+
try {
|
|
25
|
+
localStorage.setItem(canvasPreferencesKey(editor), JSON.stringify(preferencesSchema.parse(preferences)));
|
|
26
|
+
}
|
|
27
|
+
catch { /* Editing remains available if browser preference storage is unavailable. */ }
|
|
28
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Vertical trees reserve Left/Right for branches; grids use both axes. */
|
|
2
|
+
export declare function collectionKeyIndex(key: string, index: number, count: number, grid?: boolean): number | undefined;
|
|
3
|
+
/** Compare values rather than interpolating authored identifiers into selectors. */
|
|
4
|
+
export declare function findOutlineElement(root: HTMLElement | null, attribute: string, id: string): HTMLElement | undefined;
|
|
5
|
+
export type CollectionEditingCommand = Readonly<{
|
|
6
|
+
kind: 'select';
|
|
7
|
+
index: number;
|
|
8
|
+
}> | Readonly<{
|
|
9
|
+
kind: 'move';
|
|
10
|
+
offset: -1 | 1;
|
|
11
|
+
}> | Readonly<{
|
|
12
|
+
kind: 'duplicate' | 'delete' | 'expand' | 'collapse' | 'edit';
|
|
13
|
+
}>;
|
|
14
|
+
/** Page and slide rows share navigation and authoring keys; hosts enforce their limits. */
|
|
15
|
+
export declare function collectionEditingCommand(event: Readonly<{
|
|
16
|
+
key: string;
|
|
17
|
+
altKey: boolean;
|
|
18
|
+
ctrlKey: boolean;
|
|
19
|
+
metaKey: boolean;
|
|
20
|
+
}>, index: number, count: number): CollectionEditingCommand | undefined;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Vertical trees reserve Left/Right for branches; grids use both axes. */
|
|
2
|
+
export function collectionKeyIndex(key, index, count, grid = false) {
|
|
3
|
+
let next;
|
|
4
|
+
if (key === 'Home')
|
|
5
|
+
next = 0;
|
|
6
|
+
else if (key === 'End')
|
|
7
|
+
next = count - 1;
|
|
8
|
+
else if (key === 'ArrowDown' || (grid && key === 'ArrowRight'))
|
|
9
|
+
next = index + 1;
|
|
10
|
+
else if (key === 'ArrowUp' || (grid && key === 'ArrowLeft'))
|
|
11
|
+
next = index - 1;
|
|
12
|
+
else
|
|
13
|
+
return undefined;
|
|
14
|
+
return next >= 0 && next < count ? next : undefined;
|
|
15
|
+
}
|
|
16
|
+
/** Compare values rather than interpolating authored identifiers into selectors. */
|
|
17
|
+
export function findOutlineElement(root, attribute, id) {
|
|
18
|
+
return Array.from(root?.querySelectorAll(`[${attribute}]`) ?? []).find(element => element.getAttribute(attribute) === id);
|
|
19
|
+
}
|
|
20
|
+
/** Page and slide rows share navigation and authoring keys; hosts enforce their limits. */
|
|
21
|
+
export function collectionEditingCommand(event, index, count) {
|
|
22
|
+
if (event.altKey)
|
|
23
|
+
return event.key === 'ArrowUp' || event.key === 'ArrowDown' ? { kind: 'move', offset: event.key === 'ArrowUp' ? -1 : 1 } : undefined;
|
|
24
|
+
if (event.ctrlKey || event.metaKey)
|
|
25
|
+
return event.key.toLowerCase() === 'd' ? { kind: 'duplicate' } : undefined;
|
|
26
|
+
const adjacent = collectionKeyIndex(event.key, index, count);
|
|
27
|
+
if (adjacent !== undefined)
|
|
28
|
+
return { kind: 'select', index: adjacent };
|
|
29
|
+
switch (event.key) {
|
|
30
|
+
case 'Delete':
|
|
31
|
+
case 'Backspace': return { kind: 'delete' };
|
|
32
|
+
case 'ArrowRight': return { kind: 'expand' };
|
|
33
|
+
case 'ArrowLeft': return { kind: 'collapse' };
|
|
34
|
+
case 'Enter':
|
|
35
|
+
case 'F2': return { kind: 'edit' };
|
|
36
|
+
default: return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Family membership is shared by every host of the generic component picker. */
|
|
2
|
+
const FAMILIES = [
|
|
3
|
+
{ label: 'Grid', types: ['Row', 'Column'] },
|
|
4
|
+
{ label: 'Figures', types: ['Figure', 'Figcaption'] },
|
|
5
|
+
{ label: 'Quotations', types: ['Blockquote', 'Cite'] },
|
|
6
|
+
{ label: 'Lists', types: ['ContentList', 'ContentListItem'] },
|
|
7
|
+
{ label: 'Description lists', types: ['DescriptionList', 'DescriptionTerm', 'DescriptionDetails'] },
|
|
8
|
+
{ label: 'Tables', types: ['Table', 'TableCaption', 'TableHead', 'TableBody', 'TableFoot', 'TableRow', 'TableHeader', 'TableCell'] },
|
|
9
|
+
{ label: 'Form controls', types: ['FormLabel', 'FormControl', 'FormSelect', 'FormRange'] },
|
|
10
|
+
{ label: 'Input groups', types: ['InputGroup', 'InputGroupText'] },
|
|
11
|
+
{ label: 'Practice controls', types: ['PracticeInput', 'PracticeSelect', 'PracticeCheck', 'PracticeRange'] },
|
|
12
|
+
{ label: 'Accordions', types: ['Accordion', 'AccordionItem'] },
|
|
13
|
+
{ label: 'Breadcrumbs', types: ['Breadcrumb', 'BreadcrumbItem'] },
|
|
14
|
+
{ label: 'Buttons', types: ['Button', 'ButtonGroup', 'CloseButton'] },
|
|
15
|
+
{ label: 'Cards', types: ['Card', 'CardHeader', 'CardBody', 'CardFooter', 'CardTitle', 'CardSubtitle', 'CardText', 'CardLink', 'CardImage', 'CardImageOverlay', 'CardGroup'] },
|
|
16
|
+
{ label: 'Carousels', types: ['Carousel', 'CarouselItem'] },
|
|
17
|
+
{ label: 'Dropdowns', types: ['Dropdown', 'DropdownHeader', 'DropdownItem', 'DropdownDivider'] },
|
|
18
|
+
{ label: 'List groups', types: ['ListGroup', 'ListGroupItem'] },
|
|
19
|
+
{ label: 'Navbars', types: ['Navbar', 'NavbarBrand', 'NavbarToggle', 'NavbarCollapse'] },
|
|
20
|
+
{ label: 'Navigation', types: ['Nav', 'NavLink'] },
|
|
21
|
+
{ label: 'Pagination', types: ['Pagination', 'PaginationItem'] },
|
|
22
|
+
{ label: 'Progress bars', types: ['Progress', 'ProgressGroup'] },
|
|
23
|
+
{ label: 'Overlays', types: ['Tooltip', 'Popover'] },
|
|
24
|
+
{ label: 'Placeholders', types: ['Placeholder', 'PlaceholderButton'] },
|
|
25
|
+
{ label: 'Tabs', types: ['Tabs', 'Tab', 'TabContainer', 'TabContent', 'TabPane'] },
|
|
26
|
+
];
|
|
27
|
+
const FAMILY_BY_TYPE = new Map(FAMILIES.flatMap(family => family.types.map(type => [type, family.label])));
|
|
28
|
+
export function componentPickerFamilies(types, label) {
|
|
29
|
+
const families = new Map();
|
|
30
|
+
for (const type of types) {
|
|
31
|
+
const family = FAMILY_BY_TYPE.get(type);
|
|
32
|
+
const key = family ? `family:${family}` : `type:${type}`;
|
|
33
|
+
const existing = families.get(key);
|
|
34
|
+
if (existing)
|
|
35
|
+
existing.types.push(type);
|
|
36
|
+
else
|
|
37
|
+
families.set(key, { id: key, label: family ?? label(type), types: [type] });
|
|
38
|
+
}
|
|
39
|
+
return [...families.values()];
|
|
40
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type BootstrapBlockType, type BootstrapPropertyDefinition } from './bootstrapRegistry.js';
|
|
2
|
+
/** A host chooses its palette and may narrow the properties of each supported component. */
|
|
3
|
+
export declare function createComponentPolicy<Type extends string>({ types, properties, }: Readonly<{
|
|
4
|
+
types: readonly Type[];
|
|
5
|
+
properties?: Partial<Record<BootstrapBlockType, readonly BootstrapPropertyDefinition[]>>;
|
|
6
|
+
}>): {
|
|
7
|
+
types: readonly Type[];
|
|
8
|
+
allows: (type: string) => type is Type;
|
|
9
|
+
canContain: (parent: string | undefined, child: string) => boolean;
|
|
10
|
+
groups: {
|
|
11
|
+
label: "Layout" | "Content" | "Forms" | "Components";
|
|
12
|
+
types: ("Accordion" | "AccordionItem" | "Alert" | "Audio" | "Badge" | "Blockquote" | "Breadcrumb" | "BreadcrumbItem" | "Button" | "ButtonGroup" | "Card" | "CardBody" | "CardFooter" | "CardGroup" | "CardHeader" | "CardImage" | "CardImageOverlay" | "CardLink" | "CardSubtitle" | "CardText" | "CardTitle" | "Carousel" | "CarouselItem" | "Cite" | "CloseButton" | "Column" | "Container" | "ContentList" | "ContentListItem" | "DescriptionDetails" | "DescriptionList" | "DescriptionTerm" | "Divider" | "Dropdown" | "DropdownDivider" | "DropdownHeader" | "DropdownItem" | "Embed" | "Figcaption" | "Figure" | "FormControl" | "FormLabel" | "FormRange" | "FormSelect" | "Group" | "Image" | "Indicator" | "InputGroup" | "InputGroupText" | "ListGroup" | "ListGroupItem" | "Modal" | "Nav" | "NavLink" | "Navbar" | "NavbarBrand" | "NavbarCollapse" | "NavbarToggle" | "Offcanvas" | "Pagination" | "PaginationItem" | "Placeholder" | "PlaceholderButton" | "Popover" | "PracticeCheck" | "PracticeInput" | "PracticeRange" | "PracticeSelect" | "Progress" | "ProgressGroup" | "Ratio" | "Reveal" | "Row" | "Spinner" | "Stack" | "Tab" | "TabContainer" | "TabContent" | "TabPane" | "Table" | "TableBody" | "TableCaption" | "TableCell" | "TableFoot" | "TableHead" | "TableHeader" | "TableRow" | "Tabs" | "Text" | "Toast" | "Tooltip" | "Video")[];
|
|
13
|
+
}[];
|
|
14
|
+
definition: (type: BootstrapBlockType) => {
|
|
15
|
+
properties: readonly Readonly<{
|
|
16
|
+
name: string;
|
|
17
|
+
label: string;
|
|
18
|
+
kind: "text" | "number" | "select" | "boolean" | "richText";
|
|
19
|
+
options?: readonly Readonly<{
|
|
20
|
+
label: string;
|
|
21
|
+
value: string;
|
|
22
|
+
}>[];
|
|
23
|
+
min?: number;
|
|
24
|
+
max?: number;
|
|
25
|
+
step?: number;
|
|
26
|
+
}>[];
|
|
27
|
+
allowedChildren: Type[];
|
|
28
|
+
type: "Accordion" | "AccordionItem" | "Alert" | "Audio" | "Badge" | "Blockquote" | "Breadcrumb" | "BreadcrumbItem" | "Button" | "ButtonGroup" | "Card" | "CardBody" | "CardFooter" | "CardGroup" | "CardHeader" | "CardImage" | "CardImageOverlay" | "CardLink" | "CardSubtitle" | "CardText" | "CardTitle" | "Carousel" | "CarouselItem" | "Cite" | "CloseButton" | "Column" | "Container" | "ContentList" | "ContentListItem" | "DescriptionDetails" | "DescriptionList" | "DescriptionTerm" | "Divider" | "Dropdown" | "DropdownDivider" | "DropdownHeader" | "DropdownItem" | "Embed" | "Figcaption" | "Figure" | "FormControl" | "FormLabel" | "FormRange" | "FormSelect" | "Group" | "Image" | "Indicator" | "InputGroup" | "InputGroupText" | "ListGroup" | "ListGroupItem" | "Modal" | "Nav" | "NavLink" | "Navbar" | "NavbarBrand" | "NavbarCollapse" | "NavbarToggle" | "Offcanvas" | "Pagination" | "PaginationItem" | "Placeholder" | "PlaceholderButton" | "Popover" | "PracticeCheck" | "PracticeInput" | "PracticeRange" | "PracticeSelect" | "Progress" | "ProgressGroup" | "Ratio" | "Reveal" | "Row" | "Spinner" | "Stack" | "Tab" | "TabContainer" | "TabContent" | "TabPane" | "Table" | "TableBody" | "TableCaption" | "TableCell" | "TableFoot" | "TableHead" | "TableHeader" | "TableRow" | "Tabs" | "Text" | "Toast" | "Tooltip" | "Video";
|
|
29
|
+
label: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { bootstrapBlockDefinition, bootstrapBlockGroups, isBootstrapBlockType, } from './bootstrapRegistry.js';
|
|
2
|
+
import { canContainContentBlock } from './contentContainment.js';
|
|
3
|
+
/** A host chooses its palette and may narrow the properties of each supported component. */
|
|
4
|
+
export function createComponentPolicy({ types, properties = {}, }) {
|
|
5
|
+
const supported = new Set(types);
|
|
6
|
+
return {
|
|
7
|
+
types,
|
|
8
|
+
allows: (type) => supported.has(type),
|
|
9
|
+
canContain: (parent, child) => supported.has(child) && (!parent || supported.has(parent)) && canContainContentBlock(parent, child),
|
|
10
|
+
groups: bootstrapBlockGroups.map((group) => ({
|
|
11
|
+
label: group.label,
|
|
12
|
+
types: group.types.filter((type) => supported.has(type)),
|
|
13
|
+
})).filter((group) => group.types.length > 0),
|
|
14
|
+
definition: (type) => {
|
|
15
|
+
if (!supported.has(type) || !isBootstrapBlockType(type))
|
|
16
|
+
throw new Error(`Unsupported content component: ${type}`);
|
|
17
|
+
const definition = bootstrapBlockDefinition(type);
|
|
18
|
+
return {
|
|
19
|
+
...definition,
|
|
20
|
+
properties: properties[type] ?? definition.properties,
|
|
21
|
+
allowedChildren: types.filter((child) => canContainContentBlock(type, child)),
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|