@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,3 @@
|
|
|
1
|
+
import { type DropdownRgb } from './dropdownContrast.js';
|
|
2
|
+
/** Keep Bootstrap's native check, switch and close geometry; repair only unreadable SVG ink. */
|
|
3
|
+
export declare function correctControlBackgroundIcon(element: HTMLElement, background: DropdownRgb, context: CanvasRenderingContext2D): void;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { dropdownTextContrast, mixDropdownColor, readableDropdownColor, } from './dropdownContrast.js';
|
|
2
|
+
/** Keep Bootstrap's native check, switch and close geometry; repair only unreadable SVG ink. */
|
|
3
|
+
export function correctControlBackgroundIcon(element, background, context) {
|
|
4
|
+
if (!element.matches('.btn-close, input.form-check-input') ||
|
|
5
|
+
element.matches(':disabled'))
|
|
6
|
+
return;
|
|
7
|
+
const style = getComputedStyle(element);
|
|
8
|
+
const match = /url\((["']?)(data:image\/svg\+xml,[\s\S]*?)\1\)/.exec(style.backgroundImage);
|
|
9
|
+
if (!match)
|
|
10
|
+
return;
|
|
11
|
+
let svg;
|
|
12
|
+
try {
|
|
13
|
+
svg = decodeURIComponent(match[2].slice(match[2].indexOf(',') + 1));
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const ink = /(?:fill|stroke)=(["'])(#[\da-f]{3,8}|white|black)\1/i.exec(svg)?.[2];
|
|
19
|
+
if (!ink)
|
|
20
|
+
return;
|
|
21
|
+
const filtered = (value, opacity = Number(style.opacity)) => {
|
|
22
|
+
context.clearRect(0, 0, 1, 1);
|
|
23
|
+
context.filter = style.filter;
|
|
24
|
+
context.fillStyle = value;
|
|
25
|
+
context.fillRect(0, 0, 1, 1);
|
|
26
|
+
const pixel = context.getImageData(0, 0, 1, 1).data;
|
|
27
|
+
context.filter = 'none';
|
|
28
|
+
return mixDropdownColor([pixel[0], pixel[1], pixel[2]], background, opacity);
|
|
29
|
+
};
|
|
30
|
+
const foreground = filtered(ink);
|
|
31
|
+
if (dropdownTextContrast(foreground, background) >= 3)
|
|
32
|
+
return;
|
|
33
|
+
let replacement;
|
|
34
|
+
if (style.filter === 'none' && Number(style.opacity) === 1)
|
|
35
|
+
replacement = readableDropdownColor(foreground, background, 3);
|
|
36
|
+
else
|
|
37
|
+
replacement =
|
|
38
|
+
dropdownTextContrast(filtered('#000'), background) >
|
|
39
|
+
dropdownTextContrast(filtered('#fff'), background)
|
|
40
|
+
? [0, 0, 0]
|
|
41
|
+
: [255, 255, 255];
|
|
42
|
+
if (!replacement)
|
|
43
|
+
return;
|
|
44
|
+
const color = `rgb(${replacement.join(', ')})`;
|
|
45
|
+
if (dropdownTextContrast(filtered(color), background) < 3) {
|
|
46
|
+
if (dropdownTextContrast(filtered(color, 1), background) < 3)
|
|
47
|
+
return;
|
|
48
|
+
let low = Number(style.opacity), high = 1;
|
|
49
|
+
for (let step = 0; step < 12; step++) {
|
|
50
|
+
const middle = (low + high) / 2;
|
|
51
|
+
if (dropdownTextContrast(filtered(color, middle), background) >= 3.05)
|
|
52
|
+
high = middle;
|
|
53
|
+
else
|
|
54
|
+
low = middle;
|
|
55
|
+
}
|
|
56
|
+
element.style.opacity = String(high);
|
|
57
|
+
}
|
|
58
|
+
const corrected = svg.replace(/((?:fill|stroke)=)(["'])(#[\da-f]{3,8}|white|black)\2/gi, (_match, prefix, quote) => `${prefix}${quote}${color}${quote}`);
|
|
59
|
+
element.style.backgroundImage = `url("data:image/svg+xml,${encodeURIComponent(corrected)}")`;
|
|
60
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type DropdownRgb = readonly [number, number, number];
|
|
2
|
+
export declare function dropdownTextContrast(a: DropdownRgb, b: DropdownRgb): number;
|
|
3
|
+
export declare function mixDropdownColor(front: DropdownRgb, back: DropdownRgb, amount: number): DropdownRgb;
|
|
4
|
+
/** Preserve theme ink when readable; otherwise make the smallest change toward black or white. */
|
|
5
|
+
export declare function readableDropdownColor(foreground: DropdownRgb, background: DropdownRgb, minimumContrast?: number): DropdownRgb | null;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const MINIMUM_TEXT_CONTRAST = 4.5;
|
|
2
|
+
const COLOR_SEARCH_STEPS = 12;
|
|
3
|
+
const BLACK = [0, 0, 0];
|
|
4
|
+
const WHITE = [255, 255, 255];
|
|
5
|
+
function luminance(color) {
|
|
6
|
+
const linear = (value) => {
|
|
7
|
+
const channel = value / 255;
|
|
8
|
+
return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
|
|
9
|
+
};
|
|
10
|
+
return linear(color[0]) * 0.2126 + linear(color[1]) * 0.7152 + linear(color[2]) * 0.0722;
|
|
11
|
+
}
|
|
12
|
+
export function dropdownTextContrast(a, b) {
|
|
13
|
+
const first = luminance(a), second = luminance(b);
|
|
14
|
+
return (Math.max(first, second) + 0.05) / (Math.min(first, second) + 0.05);
|
|
15
|
+
}
|
|
16
|
+
export function mixDropdownColor(front, back, amount) {
|
|
17
|
+
const channel = (index) => Math.round(front[index] * amount + back[index] * (1 - amount));
|
|
18
|
+
return [channel(0), channel(1), channel(2)];
|
|
19
|
+
}
|
|
20
|
+
/** Preserve theme ink when readable; otherwise make the smallest change toward black or white. */
|
|
21
|
+
export function readableDropdownColor(foreground, background, minimumContrast = MINIMUM_TEXT_CONTRAST) {
|
|
22
|
+
if (dropdownTextContrast(foreground, background) >= minimumContrast)
|
|
23
|
+
return null;
|
|
24
|
+
const target = dropdownTextContrast(BLACK, background) > dropdownTextContrast(WHITE, background) ? BLACK : WHITE;
|
|
25
|
+
let low = 0, high = 1;
|
|
26
|
+
for (let step = 0; step < COLOR_SEARCH_STEPS; step++) {
|
|
27
|
+
const middle = (low + high) / 2;
|
|
28
|
+
if (dropdownTextContrast(mixDropdownColor(target, foreground, middle), background) >= minimumContrast)
|
|
29
|
+
high = middle;
|
|
30
|
+
else
|
|
31
|
+
low = middle;
|
|
32
|
+
}
|
|
33
|
+
return mixDropdownColor(target, foreground, high);
|
|
34
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* Theme adapters for custom editor surfaces; Bootstrap controls keep their theme rules. */
|
|
2
|
+
:root, :where(.content-text-editor, .json-text-editor) {
|
|
3
|
+
--editor-ui-text: var(--bs-body-color);
|
|
4
|
+
--editor-ui-border: var(--bs-border-color);
|
|
5
|
+
--editor-ui-surface-subtle: var(--bs-body-bg);
|
|
6
|
+
--editor-ui-surface: var(--bs-body-bg);
|
|
7
|
+
--editor-ui-surface-hover: var(--bs-body-bg);
|
|
8
|
+
--editor-ui-primary-text: var(--bs-primary-text-emphasis);
|
|
9
|
+
--editor-ui-success-text: var(--bs-success-text-emphasis);
|
|
10
|
+
--editor-ui-info-text: var(--bs-info-text-emphasis);
|
|
11
|
+
--editor-ui-warning-text: var(--bs-warning-text-emphasis);
|
|
12
|
+
--editor-ui-danger-text: var(--bs-danger-text-emphasis);
|
|
13
|
+
}
|
|
14
|
+
/* JSON syntax colors need to remain legible on a dark custom source surface. */
|
|
15
|
+
[data-editor-color-scheme='dark'] .json-text-editor {
|
|
16
|
+
--editor-ui-primary-text: color-mix(in srgb, var(--bs-primary) 20%, var(--bs-body-color));
|
|
17
|
+
--editor-ui-success-text: color-mix(in srgb, var(--bs-success) 20%, var(--bs-body-color));
|
|
18
|
+
--editor-ui-info-text: color-mix(in srgb, var(--bs-info) 20%, var(--bs-body-color));
|
|
19
|
+
--editor-ui-warning-text: color-mix(in srgb, var(--bs-warning) 20%, var(--bs-body-color));
|
|
20
|
+
--editor-ui-danger-text: color-mix(in srgb, var(--bs-danger) 20%, var(--bs-body-color));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:is(.content-editor-toolbar, .lesson-toolbar, .editor-panel, .editor-selection-toolbar, .component-picker, .showcase-header, .lesson-showcase-header, .modal-content:has(.component-picker), .center-playback-footer) :is(button, input, select, textarea):focus-visible:not(.content-authoring-canvas *) {
|
|
24
|
+
outline: 2px solid var(--editor-focus-color, var(--bs-body-color));
|
|
25
|
+
outline-offset: 2px;
|
|
26
|
+
}
|
|
27
|
+
:is(.content-editor-shell, .component-picker) .editor-tabs .nav-link:focus-visible,
|
|
28
|
+
.content-editor-shell .editor-panel > summary:focus-visible {
|
|
29
|
+
outline: 2px solid var(--editor-focus-color, var(--bs-body-color));
|
|
30
|
+
outline-offset: -3px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* These custom headers use Bootstrap's light tertiary surface and its emphasis text. */
|
|
34
|
+
:is(.showcase-header, .lesson-showcase-header) {
|
|
35
|
+
color: var(--bs-emphasis-color);
|
|
36
|
+
--editor-focus-color: var(--bs-emphasis-color);
|
|
37
|
+
}
|
|
38
|
+
.content-editor-shell .editor-panel > summary:focus-visible {
|
|
39
|
+
outline-color: currentColor;
|
|
40
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const EDITOR_THEMES: readonly ["Sandstone", "Bootstrap", "Flatly", "Darkly", "Litera", "Lux", "Minty", "Slate", "Superhero", "Cyborg"];
|
|
2
|
+
export type EditorTheme = typeof EDITOR_THEMES[number];
|
|
3
|
+
export declare function isEditorTheme(value: string): value is EditorTheme;
|
|
4
|
+
export declare function themeStylesheet(theme: EditorTheme): string;
|
|
5
|
+
export declare function themeColorMode(theme: EditorTheme): 'light' | 'dark';
|
|
6
|
+
/** Bootswatch's named palettes use Bootstrap's default slot, including visually dark themes. */
|
|
7
|
+
export declare function applyEditorThemePalette(root: HTMLElement, theme: EditorTheme): void;
|
|
8
|
+
export type EditorColorMode = 'light' | 'dark';
|
|
9
|
+
export declare function isEditorColorMode(value: string): value is EditorColorMode;
|
|
10
|
+
export declare function editorColorScheme(theme: EditorTheme, mode: EditorColorMode): EditorColorMode;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const EDITOR_THEMES = ['Sandstone', 'Bootstrap', 'Flatly', 'Darkly', 'Litera', 'Lux', 'Minty', 'Slate', 'Superhero', 'Cyborg'];
|
|
2
|
+
export function isEditorTheme(value) { return EDITOR_THEMES.some(theme => theme === value); }
|
|
3
|
+
export function themeStylesheet(theme) { return `${theme.toLowerCase()}.min.css`; }
|
|
4
|
+
const DARK_THEMES = new Set(['Darkly', 'Slate', 'Superhero', 'Cyborg']);
|
|
5
|
+
export function themeColorMode(theme) { return DARK_THEMES.has(theme) ? 'dark' : 'light'; }
|
|
6
|
+
/** Bootswatch's named palettes use Bootstrap's default slot, including visually dark themes. */
|
|
7
|
+
export function applyEditorThemePalette(root, theme) {
|
|
8
|
+
root.dataset.bsTheme = 'light';
|
|
9
|
+
root.dataset.editorColorScheme = themeColorMode(theme);
|
|
10
|
+
}
|
|
11
|
+
export function isEditorColorMode(value) { return value === 'light' || value === 'dark'; }
|
|
12
|
+
export function editorColorScheme(theme, mode) { return mode === 'dark' ? 'dark' : themeColorMode(theme); }
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Strict authoring policy. The display sanitizer separately protects untrusted rendering. */
|
|
2
|
+
export declare const INLINE_ELEMENTS: ReadonlySet<string>;
|
|
3
|
+
export declare function validInlineClasses(value: string): boolean;
|
|
4
|
+
export declare function validContentUrl(value: string, allowContact?: boolean): boolean;
|
|
5
|
+
/** Tokenize authored source before a DOM parser can repair malformed nesting or duplicate attrs. */
|
|
6
|
+
export declare function validInlineMarkup(value: string): boolean;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/** Strict authoring policy. The display sanitizer separately protects untrusted rendering. */
|
|
2
|
+
export const INLINE_ELEMENTS = new Set([
|
|
3
|
+
'a',
|
|
4
|
+
'abbr',
|
|
5
|
+
'b',
|
|
6
|
+
'bdi',
|
|
7
|
+
'bdo',
|
|
8
|
+
'br',
|
|
9
|
+
'cite',
|
|
10
|
+
'code',
|
|
11
|
+
'del',
|
|
12
|
+
'dfn',
|
|
13
|
+
'em',
|
|
14
|
+
'i',
|
|
15
|
+
'ins',
|
|
16
|
+
'kbd',
|
|
17
|
+
'mark',
|
|
18
|
+
'q',
|
|
19
|
+
's',
|
|
20
|
+
'samp',
|
|
21
|
+
'small',
|
|
22
|
+
'span',
|
|
23
|
+
'strong',
|
|
24
|
+
'sub',
|
|
25
|
+
'sup',
|
|
26
|
+
'time',
|
|
27
|
+
'u',
|
|
28
|
+
'var',
|
|
29
|
+
'wbr',
|
|
30
|
+
]);
|
|
31
|
+
export function validInlineClasses(value) {
|
|
32
|
+
return value.length <= 1024 && value.split(/\s+/).filter(Boolean).every(token => /^(?:text-(?:primary|secondary|success|danger|warning|info|light|dark|body|muted|white)(?:-emphasis|-secondary|-tertiary)?|alert-link|visually-hidden|fw-bold|fw-normal|fst-italic|small)$/.test(token));
|
|
33
|
+
}
|
|
34
|
+
function invalidUrlCharacters(value) {
|
|
35
|
+
return /\s/u.test(value) || value.includes('\u0085') || value.includes('\\');
|
|
36
|
+
}
|
|
37
|
+
export function validContentUrl(value, allowContact = false) {
|
|
38
|
+
if (!value ||
|
|
39
|
+
invalidUrlCharacters(value) ||
|
|
40
|
+
Array.from(value).some((char) => {
|
|
41
|
+
// String iteration yields a nonempty code-point substring at every position.
|
|
42
|
+
const codePoint = char.codePointAt(0);
|
|
43
|
+
return codePoint < 32 || codePoint === 127;
|
|
44
|
+
}) ||
|
|
45
|
+
value.startsWith('//'))
|
|
46
|
+
return false;
|
|
47
|
+
const scheme = /^([a-z][a-z\d+.-]*):/i.exec(value)?.[1]?.toLowerCase();
|
|
48
|
+
if (!scheme)
|
|
49
|
+
return value.startsWith('/') || value.startsWith('#');
|
|
50
|
+
if (allowContact && (scheme === 'mailto' || scheme === 'tel'))
|
|
51
|
+
return !value.slice(scheme.length + 1).startsWith('//') && value.length > scheme.length + 1;
|
|
52
|
+
if ((scheme !== 'http' && scheme !== 'https') ||
|
|
53
|
+
!/^https?:\/\//i.test(value) ||
|
|
54
|
+
value
|
|
55
|
+
.slice(value.indexOf('://') + 3)
|
|
56
|
+
.split(/[/?#]/, 1)[0]
|
|
57
|
+
?.includes('@'))
|
|
58
|
+
return false;
|
|
59
|
+
try {
|
|
60
|
+
const url = new URL(value);
|
|
61
|
+
return Boolean(url.hostname) && !url.username && !url.password;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function decoded(value) {
|
|
68
|
+
const textarea = document.createElement('textarea');
|
|
69
|
+
textarea.innerHTML = value;
|
|
70
|
+
return textarea.value;
|
|
71
|
+
}
|
|
72
|
+
const TAG_ATTRIBUTES = new Map([
|
|
73
|
+
['a', ['href', 'target', 'rel']],
|
|
74
|
+
['q', ['cite']],
|
|
75
|
+
['time', ['datetime']],
|
|
76
|
+
]);
|
|
77
|
+
function attributeToken(source, offset) {
|
|
78
|
+
const names = /\s+([^\s=/>]+)/y;
|
|
79
|
+
names.lastIndex = offset;
|
|
80
|
+
const name = names.exec(source)?.[1];
|
|
81
|
+
if (!name)
|
|
82
|
+
return undefined;
|
|
83
|
+
const assignment = /\s*=\s*/y;
|
|
84
|
+
assignment.lastIndex = names.lastIndex;
|
|
85
|
+
if (!assignment.exec(source))
|
|
86
|
+
return undefined;
|
|
87
|
+
const values = /"([^"]*)"|'([^']*)'|[^\s>]+/y;
|
|
88
|
+
values.lastIndex = assignment.lastIndex;
|
|
89
|
+
const match = values.exec(source);
|
|
90
|
+
if (!match)
|
|
91
|
+
return undefined;
|
|
92
|
+
return { name: name.toLowerCase(), raw: match[1] ?? match[2] ?? match[0], end: values.lastIndex };
|
|
93
|
+
}
|
|
94
|
+
function validAttributeValue(name, value) {
|
|
95
|
+
if (name === "class")
|
|
96
|
+
return validInlineClasses(value);
|
|
97
|
+
if (Array.from(value).length > 2048)
|
|
98
|
+
return false;
|
|
99
|
+
if (name === 'href')
|
|
100
|
+
return validContentUrl(value, true);
|
|
101
|
+
if (name === 'cite')
|
|
102
|
+
return validContentUrl(value);
|
|
103
|
+
if (name === 'dir')
|
|
104
|
+
return ['ltr', 'rtl', 'auto'].includes(value);
|
|
105
|
+
if (name === 'target')
|
|
106
|
+
return ['_self', '_blank'].includes(value);
|
|
107
|
+
if (name === 'rel')
|
|
108
|
+
return value === 'noopener noreferrer';
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
function validAttributes(tag, source) {
|
|
112
|
+
const allowed = new Set(['title', 'lang', 'dir', 'class', ...(TAG_ATTRIBUTES.get(tag) ?? [])]);
|
|
113
|
+
const names = new Set();
|
|
114
|
+
let offset = 0;
|
|
115
|
+
while (source.slice(offset).trim()) {
|
|
116
|
+
const attribute = attributeToken(source, offset);
|
|
117
|
+
if (!attribute)
|
|
118
|
+
return false;
|
|
119
|
+
offset = attribute.end;
|
|
120
|
+
const { name, raw } = attribute;
|
|
121
|
+
if (!allowed.has(name) || names.has(name))
|
|
122
|
+
return false;
|
|
123
|
+
names.add(name);
|
|
124
|
+
const value = decoded(raw);
|
|
125
|
+
if (!validAttributeValue(name, value))
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
function acceptInlineTag(token, stack) {
|
|
131
|
+
const match = /^<(\/)?([a-z][a-z\d]*)/i.exec(token);
|
|
132
|
+
if (!match)
|
|
133
|
+
return false;
|
|
134
|
+
const closing = Boolean(match[1]), tag = match[2].toLowerCase();
|
|
135
|
+
let attributes = token.slice(match[0].length, -1);
|
|
136
|
+
if (!INLINE_ELEMENTS.has(tag))
|
|
137
|
+
return false;
|
|
138
|
+
if (closing) {
|
|
139
|
+
if (attributes.trim() || stack.pop() !== tag)
|
|
140
|
+
return false;
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
const selfClosing = attributes.endsWith('/');
|
|
144
|
+
if (selfClosing)
|
|
145
|
+
attributes = attributes.slice(0, -1);
|
|
146
|
+
if ((selfClosing && !['br', 'wbr'].includes(tag)) ||
|
|
147
|
+
!validAttributes(tag, attributes) ||
|
|
148
|
+
(tag === 'a' && stack.includes('a')))
|
|
149
|
+
return false;
|
|
150
|
+
if (!['br', 'wbr'].includes(tag))
|
|
151
|
+
stack.push(tag);
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
/** Tokenize authored source before a DOM parser can repair malformed nesting or duplicate attrs. */
|
|
155
|
+
export function validInlineMarkup(value) {
|
|
156
|
+
const stack = [];
|
|
157
|
+
const tags = /<(?:[^>"']|"[^"]*"|'[^']*')*>/y;
|
|
158
|
+
let offset = 0;
|
|
159
|
+
let opening = value.indexOf('<');
|
|
160
|
+
while (opening !== -1) {
|
|
161
|
+
tags.lastIndex = opening;
|
|
162
|
+
const token = tags.exec(value);
|
|
163
|
+
if (!token)
|
|
164
|
+
return false;
|
|
165
|
+
offset = tags.lastIndex;
|
|
166
|
+
if (!acceptInlineTag(token[0], stack))
|
|
167
|
+
return false;
|
|
168
|
+
opening = value.indexOf('<', offset);
|
|
169
|
+
}
|
|
170
|
+
return stack.length === 0;
|
|
171
|
+
}
|
package/dist/layout.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Layout wrappers are stored by identity, preserving existing flat slide documents. */
|
|
2
|
+
export declare function layoutParent(block: {
|
|
3
|
+
props: {
|
|
4
|
+
id: string;
|
|
5
|
+
};
|
|
6
|
+
}): string | undefined;
|
|
7
|
+
export declare function orderedSlideBlocks<Block extends {
|
|
8
|
+
props: {
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
}>(blocks: readonly Block[]): Block[];
|
|
12
|
+
/** Parent identities in traversal order, including detached owners and stopping safely at cycles. */
|
|
13
|
+
export declare function layoutAncestorIds<Block extends {
|
|
14
|
+
props: {
|
|
15
|
+
id: string;
|
|
16
|
+
};
|
|
17
|
+
}>(block: Block, blocks: readonly Block[]): string[];
|
package/dist/layout.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Layout wrappers are stored by identity, preserving existing flat slide documents. */
|
|
2
|
+
export function layoutParent(block) {
|
|
3
|
+
return 'parentId' in block.props && typeof block.props.parentId === 'string'
|
|
4
|
+
? block.props.parentId
|
|
5
|
+
: undefined;
|
|
6
|
+
}
|
|
7
|
+
export function orderedSlideBlocks(blocks) {
|
|
8
|
+
const seen = new Set();
|
|
9
|
+
const visit = (parent) => blocks
|
|
10
|
+
.filter((block) => layoutParent(block) === parent && !seen.has(block.props.id))
|
|
11
|
+
.flatMap((block) => {
|
|
12
|
+
if (seen.has(block.props.id))
|
|
13
|
+
return [];
|
|
14
|
+
seen.add(block.props.id);
|
|
15
|
+
return [block, ...visit(block.props.id)];
|
|
16
|
+
});
|
|
17
|
+
// Invalid detached/cyclic input must never hang or silently discard authored blocks.
|
|
18
|
+
const ordered = visit();
|
|
19
|
+
for (const block of blocks) {
|
|
20
|
+
if (seen.has(block.props.id))
|
|
21
|
+
continue;
|
|
22
|
+
seen.add(block.props.id);
|
|
23
|
+
ordered.push(block, ...visit(block.props.id));
|
|
24
|
+
}
|
|
25
|
+
return ordered;
|
|
26
|
+
}
|
|
27
|
+
/** Parent identities in traversal order, including detached owners and stopping safely at cycles. */
|
|
28
|
+
export function layoutAncestorIds(block, blocks) {
|
|
29
|
+
const ancestors = new Set();
|
|
30
|
+
let parent = layoutParent(block);
|
|
31
|
+
while (parent && !ancestors.has(parent)) {
|
|
32
|
+
ancestors.add(parent);
|
|
33
|
+
const owner = blocks.find((item) => item.props.id === parent);
|
|
34
|
+
parent = owner ? layoutParent(owner) : undefined;
|
|
35
|
+
}
|
|
36
|
+
return [...ancestors];
|
|
37
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Remove only complete leading words already supplied by a containing component. */
|
|
2
|
+
export function nestedComponentLabel(label, ancestorLabels) {
|
|
3
|
+
const words = label.split(' ');
|
|
4
|
+
let omitted = 0;
|
|
5
|
+
for (const ancestor of ancestorLabels) {
|
|
6
|
+
const context = ancestor.split(' ');
|
|
7
|
+
let common = 0;
|
|
8
|
+
while (common < words.length && common < context.length && words[common].toLowerCase() === context[common].toLowerCase())
|
|
9
|
+
common++;
|
|
10
|
+
if (common < words.length)
|
|
11
|
+
omitted = Math.max(omitted, common);
|
|
12
|
+
}
|
|
13
|
+
if (!omitted)
|
|
14
|
+
return label;
|
|
15
|
+
const remaining = words.slice(omitted).join(' ');
|
|
16
|
+
return remaining.charAt(0).toUpperCase() + remaining.slice(1);
|
|
17
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { BootstrapPropertyDefinition } from './bootstrapRegistry.js';
|
|
3
|
+
export declare const SLIDE_BREAKPOINTS: readonly [{
|
|
4
|
+
readonly suffix: "";
|
|
5
|
+
readonly css: "xs";
|
|
6
|
+
readonly width: 0;
|
|
7
|
+
readonly column: "mobile";
|
|
8
|
+
}, {
|
|
9
|
+
readonly suffix: "Sm";
|
|
10
|
+
readonly css: "sm";
|
|
11
|
+
readonly width: 576;
|
|
12
|
+
readonly column: "small";
|
|
13
|
+
}, {
|
|
14
|
+
readonly suffix: "Md";
|
|
15
|
+
readonly css: "md";
|
|
16
|
+
readonly width: 768;
|
|
17
|
+
readonly column: "medium";
|
|
18
|
+
}, {
|
|
19
|
+
readonly suffix: "Lg";
|
|
20
|
+
readonly css: "lg";
|
|
21
|
+
readonly width: 992;
|
|
22
|
+
readonly column: "large";
|
|
23
|
+
}, {
|
|
24
|
+
readonly suffix: "Xl";
|
|
25
|
+
readonly css: "xl";
|
|
26
|
+
readonly width: 1200;
|
|
27
|
+
readonly column: "extraLarge";
|
|
28
|
+
}, {
|
|
29
|
+
readonly suffix: "Xxl";
|
|
30
|
+
readonly css: "xxl";
|
|
31
|
+
readonly width: 1400;
|
|
32
|
+
readonly column: "extraExtraLarge";
|
|
33
|
+
}];
|
|
34
|
+
type BreakpointSuffix = typeof SLIDE_BREAKPOINTS[number]['suffix'];
|
|
35
|
+
type ColumnPrefix = typeof SLIDE_BREAKPOINTS[number]['column'];
|
|
36
|
+
type OptionalValue<T> = T | null | undefined;
|
|
37
|
+
type ResponsiveProps<Key extends string, Value> = Partial<Record<`${Key}${BreakpointSuffix}`, OptionalValue<Value>>>;
|
|
38
|
+
export type LayoutStyle = CSSProperties & Record<`--lesson-${string}`, string | number | undefined>;
|
|
39
|
+
export type RowLayoutProps = ResponsiveProps<'columns' | 'gutterX' | 'gutterY', number> & Partial<Record<'gap' | 'horizontalGap' | 'verticalGap', OptionalValue<number>>> & Partial<Record<'alignment' | 'justify', OptionalValue<string>>> & Partial<Record<'wrap', OptionalValue<boolean>>>;
|
|
40
|
+
export type ColumnLayoutProps = Partial<Record<`${ColumnPrefix}Width`, OptionalValue<number>>> & Partial<Record<`${ColumnPrefix}WidthMode` | 'widthMode', OptionalValue<'fixed' | 'equal' | 'auto'>>> & Partial<Record<`${ColumnPrefix}Offset` | `${ColumnPrefix}Order`, OptionalValue<number>>> & Partial<Record<'width' | 'offset' | 'order', OptionalValue<number>>> & Partial<Record<'alignSelf', OptionalValue<string>>>;
|
|
41
|
+
export type StackLayoutProps = ResponsiveProps<'direction', 'horizontal' | 'vertical'> & ResponsiveProps<'gap', number>;
|
|
42
|
+
export declare function bootstrapSpacing(value: number): string;
|
|
43
|
+
export declare const responsiveRowProperties: readonly BootstrapPropertyDefinition[];
|
|
44
|
+
export declare const responsiveColumnProperties: readonly BootstrapPropertyDefinition[];
|
|
45
|
+
export declare const responsiveStackProperties: readonly BootstrapPropertyDefinition[];
|
|
46
|
+
export declare function rowLayoutClassName(props: RowLayoutProps): string;
|
|
47
|
+
export declare function rowLayoutStyle(props: RowLayoutProps): LayoutStyle;
|
|
48
|
+
export declare function columnLayoutStyle(props: ColumnLayoutProps): LayoutStyle;
|
|
49
|
+
export declare function stackLayoutStyle(props: StackLayoutProps): LayoutStyle;
|
|
50
|
+
export declare function responsiveContainerClassName(fluid?: boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | null): string;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export const SLIDE_BREAKPOINTS = [
|
|
2
|
+
{ suffix: '', css: 'xs', width: 0, column: 'mobile' },
|
|
3
|
+
{ suffix: 'Sm', css: 'sm', width: 576, column: 'small' },
|
|
4
|
+
{ suffix: 'Md', css: 'md', width: 768, column: 'medium' },
|
|
5
|
+
{ suffix: 'Lg', css: 'lg', width: 992, column: 'large' },
|
|
6
|
+
{ suffix: 'Xl', css: 'xl', width: 1200, column: 'extraLarge' },
|
|
7
|
+
{ suffix: 'Xxl', css: 'xxl', width: 1400, column: 'extraExtraLarge' },
|
|
8
|
+
];
|
|
9
|
+
const SPACING_REM = [0, 0.25, 0.5, 1, 1.5, 3];
|
|
10
|
+
export function bootstrapSpacing(value) {
|
|
11
|
+
return `${SPACING_REM[value] ?? 0}rem`;
|
|
12
|
+
}
|
|
13
|
+
const field = (name, label, min, max) => ({ name, label, kind: 'number', min, max, step: 1 });
|
|
14
|
+
export const responsiveRowProperties = [
|
|
15
|
+
{ name: 'wrap', label: 'Wrap columns', kind: 'boolean' },
|
|
16
|
+
...SLIDE_BREAKPOINTS.flatMap(({ suffix, css }) => [
|
|
17
|
+
field(`columns${suffix}`, `Columns (${css})`, 1, 6),
|
|
18
|
+
...(suffix ? [field(`gutterX${suffix}`, `Horizontal gutter (${css})`, 0, 5),
|
|
19
|
+
field(`gutterY${suffix}`, `Vertical gutter (${css})`, 0, 5)] : []),
|
|
20
|
+
]),
|
|
21
|
+
];
|
|
22
|
+
export const responsiveColumnProperties = SLIDE_BREAKPOINTS.flatMap(({ column, css }) => [
|
|
23
|
+
{ name: `${column}WidthMode`, label: `Column sizing (${css})`, kind: 'select', options: ['fixed', 'equal', 'auto'].map(value => ({ label: value, value })) },
|
|
24
|
+
...(css === 'xxl' ? [field('extraExtraLargeWidth', 'Column width (xxl)', 1, 12)] : []),
|
|
25
|
+
...[field(`${column}Offset`, `Column offset (${css})`, 0, 11), field(`${column}Order`, `Column order (${css})`, css === 'xs' ? -1 : 0, css === 'xs' ? 6 : 5)],
|
|
26
|
+
]);
|
|
27
|
+
export const responsiveStackProperties = SLIDE_BREAKPOINTS.filter(({ suffix }) => suffix).flatMap(({ suffix, css }) => [
|
|
28
|
+
{ name: `direction${suffix}`, label: `Stack direction (${css})`, kind: 'select', options: ['horizontal', 'vertical'].map(value => ({ label: value, value })) },
|
|
29
|
+
field(`gap${suffix}`, `Stack gap (${css})`, 0, 5),
|
|
30
|
+
]);
|
|
31
|
+
export function rowLayoutClassName(props) {
|
|
32
|
+
const justifyClass = props.justify ? ` justify-content-${props.justify}` : '';
|
|
33
|
+
return `row lesson-responsive-row align-items-${props.alignment ?? 'stretch'}${justifyClass}`;
|
|
34
|
+
}
|
|
35
|
+
export function rowLayoutStyle(props) {
|
|
36
|
+
const style = { '--lesson-authoring-layout': 'flex', flexWrap: props.wrap === false ? 'nowrap' : 'wrap' };
|
|
37
|
+
let columns;
|
|
38
|
+
let gapX = props.horizontalGap ?? props.gap ?? 3;
|
|
39
|
+
let gapY = props.verticalGap ?? props.gap ?? 3;
|
|
40
|
+
for (const { suffix, css } of SLIDE_BREAKPOINTS) {
|
|
41
|
+
columns = props[`columns${suffix}`] ?? columns;
|
|
42
|
+
gapX = props[`gutterX${suffix}`] ?? gapX;
|
|
43
|
+
gapY = props[`gutterY${suffix}`] ?? gapY;
|
|
44
|
+
style[`--lesson-row-child-width-${css}`] = columns == null ? "initial" : `${100 / columns}%`;
|
|
45
|
+
style[`--lesson-row-child-flex-${css}`] = columns == null ? "initial" : "0 0 auto";
|
|
46
|
+
style[`--lesson-row-gutter-x-${css}`] = bootstrapSpacing(gapX);
|
|
47
|
+
style[`--lesson-row-gutter-y-${css}`] = bootstrapSpacing(gapY);
|
|
48
|
+
}
|
|
49
|
+
return style;
|
|
50
|
+
}
|
|
51
|
+
export function columnLayoutStyle(props) {
|
|
52
|
+
const style = { minWidth: 0 };
|
|
53
|
+
let width = props.mobileWidth ?? 12;
|
|
54
|
+
let mode = props.mobileWidthMode ?? 'fixed';
|
|
55
|
+
let offset = 0;
|
|
56
|
+
let order = 0;
|
|
57
|
+
for (const { css, column } of SLIDE_BREAKPOINTS) {
|
|
58
|
+
const legacy = css === 'md' ? props : undefined;
|
|
59
|
+
const definedWidth = props[`${column}Width`] ?? legacy?.width;
|
|
60
|
+
const definedMode = props[`${column}WidthMode`] ?? legacy?.widthMode;
|
|
61
|
+
if (definedWidth != null)
|
|
62
|
+
width = definedWidth;
|
|
63
|
+
mode = definedMode ?? (definedWidth != null ? 'fixed' : mode);
|
|
64
|
+
offset = props[`${column}Offset`] ?? legacy?.offset ?? offset;
|
|
65
|
+
order = props[`${column}Order`] ?? legacy?.order ?? order;
|
|
66
|
+
let columnWidth = '0';
|
|
67
|
+
if (mode === 'fixed')
|
|
68
|
+
columnWidth = `${width / 12 * 100}%`;
|
|
69
|
+
else if (mode === 'auto')
|
|
70
|
+
columnWidth = 'auto';
|
|
71
|
+
style[`--lesson-column-width-${css}`] = columnWidth;
|
|
72
|
+
style[`--lesson-column-flex-${css}`] = mode === 'equal' ? '1 0 0%' : '0 0 auto';
|
|
73
|
+
style[`--lesson-column-offset-${css}`] = `${offset / 12 * 100}%`;
|
|
74
|
+
style[`--lesson-column-order-${css}`] = order;
|
|
75
|
+
}
|
|
76
|
+
return style;
|
|
77
|
+
}
|
|
78
|
+
export function stackLayoutStyle(props) {
|
|
79
|
+
const style = { '--lesson-authoring-layout': 'flex' };
|
|
80
|
+
let direction = props.direction ?? 'vertical';
|
|
81
|
+
let gap = props.gap ?? 0;
|
|
82
|
+
for (const { suffix, css } of SLIDE_BREAKPOINTS) {
|
|
83
|
+
direction = props[`direction${suffix}`] ?? direction;
|
|
84
|
+
gap = props[`gap${suffix}`] ?? gap;
|
|
85
|
+
style[`--lesson-stack-direction-${css}`] = direction === 'horizontal' ? 'row' : 'column';
|
|
86
|
+
style[`--lesson-stack-gap-${css}`] = bootstrapSpacing(gap);
|
|
87
|
+
}
|
|
88
|
+
return style;
|
|
89
|
+
}
|
|
90
|
+
export function responsiveContainerClassName(fluid) {
|
|
91
|
+
let container = 'fixed';
|
|
92
|
+
if (fluid === true)
|
|
93
|
+
container = 'fluid';
|
|
94
|
+
else if (typeof fluid === 'string')
|
|
95
|
+
container = fluid;
|
|
96
|
+
return `lesson-responsive-container lesson-container-${container}`;
|
|
97
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import { SLIDE_BREAKPOINTS } from "./responsiveLayout.js";
|
|
3
|
+
import type { BootstrapProps } from "./contracts/types.gen.js";
|
|
4
|
+
import type { BootstrapPropertyDefinition } from "./bootstrapRegistry.js";
|
|
5
|
+
type ResponsiveAppearance = Partial<Record<`display${typeof SLIDE_BREAKPOINTS[number]['suffix']}`, string | null>> & Partial<Record<`${'margin' | 'padding'}${Exclude<typeof SLIDE_BREAKPOINTS[number]['suffix'], ''>}`, string | null>> & Partial<{
|
|
6
|
+
[Key in 'overflow' | 'overflowX' | 'overflowY' | 'textDecoration']: CSSProperties[Key] | null;
|
|
7
|
+
}> & {
|
|
8
|
+
objectPosition?: string | null;
|
|
9
|
+
opacity?: number | null;
|
|
10
|
+
minWidth?: string | null;
|
|
11
|
+
maxWidth?: string | null;
|
|
12
|
+
minHeight?: string | null;
|
|
13
|
+
maxHeight?: string | null;
|
|
14
|
+
flexGrow?: boolean | null;
|
|
15
|
+
flexShrink?: boolean | null;
|
|
16
|
+
alignSelf?: string | null;
|
|
17
|
+
ariaLabel?: string | null;
|
|
18
|
+
};
|
|
19
|
+
type AppearanceStyleValue = string | number | undefined;
|
|
20
|
+
type AppearanceProps = Partial<Omit<BootstrapProps, 'alignment'>> & ResponsiveAppearance;
|
|
21
|
+
export declare const appearanceProperties: readonly BootstrapPropertyDefinition[];
|
|
22
|
+
export declare function slideAppearance(props: AppearanceProps): string;
|
|
23
|
+
export declare function spacingStyles(props: AppearanceProps): CSSProperties & Record<`--lesson-${string}`, AppearanceStyleValue>;
|
|
24
|
+
export declare function headingAppearance(props: AppearanceProps): string;
|
|
25
|
+
export {};
|