@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,434 @@
|
|
|
1
|
+
import { createElement as _createElement } from "react";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ReadableDropdownToggle } from './ReadableDropdownToggle.js';
|
|
4
|
+
import { ReadableDropdownSurface } from './ReadableDropdownSurface.js';
|
|
5
|
+
import { BootstrapProgressBlock } from "./BootstrapProgressGroup.js";
|
|
6
|
+
import { PracticeInputBlock } from "./PracticeInputBlock.js";
|
|
7
|
+
import { createContext, createElement, useContext, useCallback, useMemo, useEffect, useId, useRef, useState, } from "react";
|
|
8
|
+
import { Accordion, Breadcrumb, Button, ButtonGroup, Dropdown, Form, Modal, Nav, Offcanvas, OverlayTrigger, Popover, Ratio, Toast, Tooltip, } from "react-bootstrap";
|
|
9
|
+
import { safeBootstrapUrl } from "./BootstrapInlineText.js";
|
|
10
|
+
import { useContentRuntime } from "./ContentRuntime.js";
|
|
11
|
+
import { useCanvasThemeAttributes } from "./CanvasTheme.js";
|
|
12
|
+
export const INTERACTIVE_BLOCK_TYPES = [
|
|
13
|
+
"Group",
|
|
14
|
+
"Ratio",
|
|
15
|
+
"Accordion",
|
|
16
|
+
"AccordionItem",
|
|
17
|
+
"Tabs",
|
|
18
|
+
"Tab",
|
|
19
|
+
"Button",
|
|
20
|
+
"ButtonGroup",
|
|
21
|
+
"Reveal",
|
|
22
|
+
"Tooltip",
|
|
23
|
+
"Popover",
|
|
24
|
+
"Carousel",
|
|
25
|
+
"CarouselItem",
|
|
26
|
+
"Progress",
|
|
27
|
+
"Modal",
|
|
28
|
+
"Offcanvas",
|
|
29
|
+
"Dropdown",
|
|
30
|
+
"DropdownItem",
|
|
31
|
+
"Toast",
|
|
32
|
+
"FormControl",
|
|
33
|
+
"FormSelect",
|
|
34
|
+
"FormRange",
|
|
35
|
+
"PracticeInput",
|
|
36
|
+
"PracticeSelect",
|
|
37
|
+
"PracticeCheck",
|
|
38
|
+
"PracticeRange",
|
|
39
|
+
"Breadcrumb",
|
|
40
|
+
"BreadcrumbItem",
|
|
41
|
+
"Video",
|
|
42
|
+
"Audio",
|
|
43
|
+
"Embed",
|
|
44
|
+
];
|
|
45
|
+
export function isInteractiveBlock(block) {
|
|
46
|
+
const types = INTERACTIVE_BLOCK_TYPES;
|
|
47
|
+
return types.includes(block.type);
|
|
48
|
+
}
|
|
49
|
+
const CompoundContext = createContext({
|
|
50
|
+
selected: "",
|
|
51
|
+
register: () => () => undefined,
|
|
52
|
+
});
|
|
53
|
+
function useItem(id, eventKey, title, disabled = false) {
|
|
54
|
+
const parent = useContext(CompoundContext);
|
|
55
|
+
const register = parent.register;
|
|
56
|
+
useEffect(() => register({ id, key: eventKey, title, disabled }), [id, eventKey, title, disabled, register]);
|
|
57
|
+
return parent;
|
|
58
|
+
}
|
|
59
|
+
function appendUniqueItem(items, item) {
|
|
60
|
+
return items.some((existing) => existing.key === item.key) ? items : [...items, item];
|
|
61
|
+
}
|
|
62
|
+
function selectedItemKey(items, requestedKey) {
|
|
63
|
+
const requested = items.find((item) => item.key === requestedKey);
|
|
64
|
+
return requested?.key ?? items[0]?.key ?? "";
|
|
65
|
+
}
|
|
66
|
+
function carouselClassName(fade) {
|
|
67
|
+
return fade ? "carousel carousel-inner carousel-fade" : "carousel carousel-inner";
|
|
68
|
+
}
|
|
69
|
+
function useReducedMotion() {
|
|
70
|
+
const [reducedMotion, setReducedMotion] = useState(() => typeof matchMedia === "function" &&
|
|
71
|
+
matchMedia("(prefers-reduced-motion: reduce)").matches);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (typeof matchMedia !== "function")
|
|
74
|
+
return;
|
|
75
|
+
const query = matchMedia("(prefers-reduced-motion: reduce)");
|
|
76
|
+
const update = () => setReducedMotion(query.matches);
|
|
77
|
+
query.addEventListener("change", update);
|
|
78
|
+
return () => query.removeEventListener("change", update);
|
|
79
|
+
}, []);
|
|
80
|
+
return reducedMotion;
|
|
81
|
+
}
|
|
82
|
+
function CompoundBlock({ block, children, shared, }) {
|
|
83
|
+
const runtime = useContentRuntime();
|
|
84
|
+
const [registeredItems, setRegisteredItems] = useState([]);
|
|
85
|
+
const items = useMemo(() => [...registeredItems].sort((left, right) => runtime.blockOrder.indexOf(left.id) -
|
|
86
|
+
runtime.blockOrder.indexOf(right.id)), [registeredItems, runtime.blockOrder]);
|
|
87
|
+
const [paused, setPaused] = useState(false);
|
|
88
|
+
useEffect(() => setPaused(false), [runtime.revision]);
|
|
89
|
+
const reducedMotion = useReducedMotion();
|
|
90
|
+
const register = useCallback((item) => {
|
|
91
|
+
setRegisteredItems((current) => appendUniqueItem(current, item));
|
|
92
|
+
return () => setRegisteredItems((current) => current.filter((existing) => existing.key !== item.key));
|
|
93
|
+
}, []);
|
|
94
|
+
const availableItems = block.type === "Tabs" ? items.filter((item) => !item.disabled || (runtime.authoring && runtime.state[block.props.id]?.selected === item.key)) : items;
|
|
95
|
+
const requestedKey = runtime.state[block.props.id]?.selected ?? block.props.defaultActiveKey;
|
|
96
|
+
const selected = selectedItemKey(availableItems, requestedKey);
|
|
97
|
+
const compound = useMemo(() => ({ selected, register }), [selected, register]);
|
|
98
|
+
const select = (key) => runtime.update(block.props.id, { selected: key });
|
|
99
|
+
const move = (offset) => {
|
|
100
|
+
const index = items.findIndex((item) => item.key === selected);
|
|
101
|
+
const next = items[(index + offset + items.length) % items.length];
|
|
102
|
+
// Enabled controls require two items; registration produces a dense array.
|
|
103
|
+
select(next.key);
|
|
104
|
+
};
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (block.type !== "Carousel" ||
|
|
107
|
+
runtime.authoring ||
|
|
108
|
+
!runtime.playbackActive ||
|
|
109
|
+
paused ||
|
|
110
|
+
reducedMotion ||
|
|
111
|
+
!block.props.interval ||
|
|
112
|
+
items.length < 2)
|
|
113
|
+
return;
|
|
114
|
+
const timer = setInterval(() => {
|
|
115
|
+
const index = items.findIndex((item) => item.key === selected);
|
|
116
|
+
const next = items[(index + 1) % items.length];
|
|
117
|
+
// The timer captures the dense array only after its two-item guard.
|
|
118
|
+
runtime.update(block.props.id, { selected: next.key });
|
|
119
|
+
}, block.props.interval);
|
|
120
|
+
return () => clearInterval(timer);
|
|
121
|
+
}, [block, items, runtime, selected, paused, reducedMotion]);
|
|
122
|
+
return (_jsx(CompoundContext.Provider, { value: compound, children: _jsxs("div", { ...shared, children: [block.type === "Tabs" ? (_jsx(Nav, { activeKey: selected, "aria-label": block.props.ariaLabel || "Tabs", variant: block.props.variant, fill: block.props.fill, justify: block.props.justify, role: "tablist", onSelect: (key) => {
|
|
123
|
+
if (key)
|
|
124
|
+
select(key);
|
|
125
|
+
}, children: items.map((item) => (_jsx(Nav.Item, { children: _jsx(Nav.Link, { as: "button", type: "button", id: `${runtime.scopeId}-${block.props.id}-${item.key}-tab`, eventKey: item.key, role: "tab", "data-puck-overlay-portal": runtime.authoring || undefined, "data-content-edit-guide": runtime.authoring || undefined, "aria-selected": selected === item.key, "aria-controls": `${runtime.scopeId}-${block.props.id}-${item.key}`, disabled: item.disabled, active: selected === item.key, onClick: () => select(item.key), children: item.title }) }, item.key))) })) : null, _jsx("div", { className: block.type === "Carousel"
|
|
126
|
+
? carouselClassName(block.props.fade)
|
|
127
|
+
: "tab-content", children: children }), block.type === "Carousel" && !runtime.authoring ? (_jsxs(ButtonGroup, { "aria-label": "Carousel navigation", children: [(block.props.interval ?? 0) > 0 ? (_jsx(Button, { "aria-pressed": paused, onClick: () => setPaused((value) => !value), children: paused
|
|
128
|
+
? "Resume slideshow"
|
|
129
|
+
: "Pause slideshow" })) : null, block.props.controls ? (_jsxs(_Fragment, { children: [_jsx(Button, { onClick: () => move(-1), disabled: items.length < 2, "aria-label": "Previous slide", children: "Previous" }), _jsx(Button, { onClick: () => move(1), disabled: items.length < 2, "aria-label": "Next slide", children: "Next" })] })) : null, block.props.indicators
|
|
130
|
+
? items.map((item, index) => (_jsx(Button, { "aria-label": `Show slide ${index + 1}`, "aria-pressed": item.key === selected, onClick: () => select(item.key), children: index + 1 }, item.key)))
|
|
131
|
+
: null] })) : null] }) }));
|
|
132
|
+
}
|
|
133
|
+
function CompoundItem({ block, children, shared, }) {
|
|
134
|
+
const parent = useItem(block.props.id, block.props.eventKey, block.props.title ?? "", block.type === "Tab" && block.props.disabled);
|
|
135
|
+
const runtime = useContentRuntime();
|
|
136
|
+
const active = parent.selected === block.props.eventKey;
|
|
137
|
+
const visible = active || (runtime.authoring && block.type === "CarouselItem");
|
|
138
|
+
const attributes = {
|
|
139
|
+
...shared,
|
|
140
|
+
id: `${runtime.scopeId}-${block.props.parentId}-${block.props.eventKey}`,
|
|
141
|
+
hidden: !visible,
|
|
142
|
+
'aria-label': block.props.title,
|
|
143
|
+
className: `${shared.className ?? ""} ${block.type === "Tab" ? "tab-pane" : "carousel-item"} ${visible ? "active show" : ""}`,
|
|
144
|
+
};
|
|
145
|
+
const content = _jsxs(_Fragment, { children: [runtime.authoring && block.props.title ? _jsx("h3", { className: "h6", "data-content-edit-guide": runtime.authoring || undefined, children: block.props.title }) : null, children, block.type === "CarouselItem" && block.props.caption ? _jsx("p", { "data-content-edit-guide": runtime.authoring || undefined, children: block.props.caption }) : null] });
|
|
146
|
+
if (block.type === "Tab")
|
|
147
|
+
return _jsx("div", { ...attributes, role: "tabpanel", tabIndex: 0, "aria-labelledby": `${runtime.scopeId}-${block.props.parentId}-${block.props.eventKey}-tab`, children: content });
|
|
148
|
+
return _jsx("fieldset", { ...attributes, children: content });
|
|
149
|
+
}
|
|
150
|
+
// An authored trigger can be wider than the visible canvas. Keep its overlay
|
|
151
|
+
// reachable even when tethering to the trigger's off-screen edge is impossible.
|
|
152
|
+
const CANVAS_OVERLAY_POSITION = {
|
|
153
|
+
modifiers: [
|
|
154
|
+
{ name: 'preventOverflow', options: { rootBoundary: 'viewport', altAxis: true, tether: false, padding: 8 } },
|
|
155
|
+
{
|
|
156
|
+
name: 'canvasResize', enabled: true, phase: 'afterWrite',
|
|
157
|
+
fn: () => undefined,
|
|
158
|
+
effect: ({ state, instance }) => {
|
|
159
|
+
const reference = state.elements.reference;
|
|
160
|
+
if (typeof ResizeObserver === 'undefined' || !(reference instanceof Element))
|
|
161
|
+
return;
|
|
162
|
+
// Canvas presets and responsive containers can reflow a trigger
|
|
163
|
+
// without a browser-window resize or a scroll event.
|
|
164
|
+
const observer = new ResizeObserver(() => { void instance.update(); });
|
|
165
|
+
for (const element of [reference, reference.closest('.content-authoring-canvas'), reference.closest('.editor-canvas-scroll')]) {
|
|
166
|
+
if (element)
|
|
167
|
+
observer.observe(element);
|
|
168
|
+
}
|
|
169
|
+
return () => observer.disconnect();
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
};
|
|
174
|
+
function useOverlayPalette(enabled) {
|
|
175
|
+
const attributes = useCanvasThemeAttributes();
|
|
176
|
+
const theme = attributes['data-canvas-theme'];
|
|
177
|
+
const colorScheme = attributes['data-editor-color-scheme'];
|
|
178
|
+
const colorMode = attributes['data-bs-theme'];
|
|
179
|
+
const scoped = enabled && Boolean(theme);
|
|
180
|
+
const [container, setContainer] = useState(null);
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
if (!scoped)
|
|
183
|
+
return;
|
|
184
|
+
const element = document.createElement('div');
|
|
185
|
+
document.body.appendChild(element);
|
|
186
|
+
setContainer(element);
|
|
187
|
+
return () => { element.remove(); };
|
|
188
|
+
}, [scoped]);
|
|
189
|
+
useEffect(() => {
|
|
190
|
+
if (!container || !theme)
|
|
191
|
+
return;
|
|
192
|
+
container.className = `content-canvas-portal canvas-palette-${theme}`;
|
|
193
|
+
container.dataset.canvasTheme = theme;
|
|
194
|
+
container.dataset.bsTheme = colorMode ?? 'light';
|
|
195
|
+
container.dataset.editorColorScheme = colorScheme;
|
|
196
|
+
}, [container, theme, colorScheme, colorMode]);
|
|
197
|
+
return { ...attributes, className: 'content-canvas-overlay', container };
|
|
198
|
+
}
|
|
199
|
+
export function InteractiveBootstrapBlock({ block, children, shared, }) {
|
|
200
|
+
const runtime = useContentRuntime();
|
|
201
|
+
const { container, ...palette } = useOverlayPalette(['Tooltip', 'Popover', 'Modal', 'Offcanvas'].includes(block.type));
|
|
202
|
+
const controlId = useId();
|
|
203
|
+
const data = block.props;
|
|
204
|
+
const media = useRef(null);
|
|
205
|
+
const autoPlay = "autoPlay" in data && data.autoPlay === true;
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
const element = media.current;
|
|
208
|
+
if (!element || runtime.authoring)
|
|
209
|
+
return;
|
|
210
|
+
if (!runtime.playbackActive)
|
|
211
|
+
element.pause();
|
|
212
|
+
else if (autoPlay)
|
|
213
|
+
void element.play().catch(() => undefined);
|
|
214
|
+
}, [runtime.authoring, runtime.playbackActive, autoPlay]);
|
|
215
|
+
const open = runtime.state[data.id]?.open ??
|
|
216
|
+
("defaultOpen" in data ? data.defaultOpen : false);
|
|
217
|
+
const close = () => runtime.update(data.id, { open: false });
|
|
218
|
+
switch (block.type) {
|
|
219
|
+
case "Group":
|
|
220
|
+
case "Ratio":
|
|
221
|
+
case "Accordion":
|
|
222
|
+
case "AccordionItem":
|
|
223
|
+
case "Tabs":
|
|
224
|
+
case "Carousel":
|
|
225
|
+
case "Tab":
|
|
226
|
+
case "CarouselItem":
|
|
227
|
+
return renderStructureBlock({ block, children, shared, runtime });
|
|
228
|
+
case "Button":
|
|
229
|
+
case "DropdownItem":
|
|
230
|
+
case "ButtonGroup":
|
|
231
|
+
case "Reveal":
|
|
232
|
+
return renderActionBlock({ block, children, shared, runtime, open });
|
|
233
|
+
case "Tooltip":
|
|
234
|
+
case "Popover":
|
|
235
|
+
case "Progress":
|
|
236
|
+
return renderHintBlock({ block, children, shared, runtime, controlId, palette, container });
|
|
237
|
+
case "Modal":
|
|
238
|
+
case "Offcanvas":
|
|
239
|
+
case "Dropdown":
|
|
240
|
+
case "Toast":
|
|
241
|
+
return renderOverlayBlock({ block, children, shared, runtime, controlId, open, close, palette, container });
|
|
242
|
+
case "FormControl":
|
|
243
|
+
case "FormSelect":
|
|
244
|
+
case "FormRange":
|
|
245
|
+
case "PracticeInput":
|
|
246
|
+
case "PracticeSelect":
|
|
247
|
+
case "PracticeCheck":
|
|
248
|
+
case "PracticeRange":
|
|
249
|
+
return renderPracticeBlock({ block, children, shared, runtime, controlId });
|
|
250
|
+
case "Breadcrumb":
|
|
251
|
+
case "BreadcrumbItem":
|
|
252
|
+
case "Video":
|
|
253
|
+
case "Audio":
|
|
254
|
+
case "Embed":
|
|
255
|
+
return renderContentBlock({ block, children, shared, runtime, media });
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
function AccordionStructure({ block, children, shared }) {
|
|
259
|
+
const runtime = useContentRuntime();
|
|
260
|
+
const [active, setActive] = useState(() => block.props.alwaysOpen && block.props.defaultActiveKey ? [block.props.defaultActiveKey] : block.props.defaultActiveKey);
|
|
261
|
+
const revealed = runtime.authoring ? runtime.state[block.props.id]?.selected : undefined;
|
|
262
|
+
useEffect(() => {
|
|
263
|
+
if (revealed === undefined)
|
|
264
|
+
return;
|
|
265
|
+
setActive(current => block.props.alwaysOpen ? [...new Set([...(Array.isArray(current) ? current : current ? [current] : []), revealed])] : revealed);
|
|
266
|
+
}, [revealed, block.props.alwaysOpen]);
|
|
267
|
+
return _jsx(Accordion, { ...shared, alwaysOpen: block.props.alwaysOpen, flush: block.props.flush, activeKey: active, onSelect: key => setActive(key), children: children });
|
|
268
|
+
}
|
|
269
|
+
function renderStructureBlock({ block, children, shared, runtime }) {
|
|
270
|
+
switch (block.type) {
|
|
271
|
+
case "Group":
|
|
272
|
+
return createElement(block.props.element ?? "div", shared, children);
|
|
273
|
+
case "Ratio":
|
|
274
|
+
return (_jsx(Ratio, { ...shared, aspectRatio: block.props.aspectRatio, children: _jsx("div", { children: children }) }));
|
|
275
|
+
case "Accordion":
|
|
276
|
+
return _jsx(AccordionStructure, { block: block, shared: shared, children: children }, runtime.revision);
|
|
277
|
+
case "AccordionItem":
|
|
278
|
+
return _jsxs(Accordion.Item, { ...shared, eventKey: block.props.eventKey, children: [_jsx(Accordion.Header, { "data-puck-overlay-portal": runtime.authoring || undefined, "data-content-edit-guide": runtime.authoring || undefined, children: block.props.title }), _jsx(Accordion.Body, { children: children })] });
|
|
279
|
+
case "Tabs":
|
|
280
|
+
case "Carousel":
|
|
281
|
+
return (_jsx(CompoundBlock, { block: block, shared: shared, children: children }));
|
|
282
|
+
case "Tab":
|
|
283
|
+
case "CarouselItem":
|
|
284
|
+
return (_jsx(CompoundItem, { block: block, shared: shared, children: children }));
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function blockActionProps(props, runtime) {
|
|
288
|
+
const href = props.action === "link"
|
|
289
|
+
? safeBootstrapUrl(props.href ?? "")
|
|
290
|
+
: undefined;
|
|
291
|
+
return {
|
|
292
|
+
disabled: props.disabled ||
|
|
293
|
+
runtime.canExecute?.(props) === false,
|
|
294
|
+
onClick: () => runtime.execute(props),
|
|
295
|
+
"aria-controls": props.targetId
|
|
296
|
+
? `${runtime.scopeId}-${props.targetId}`
|
|
297
|
+
: undefined,
|
|
298
|
+
"aria-expanded": props.targetId &&
|
|
299
|
+
["toggle", "show", "hide"].includes(props.action ?? "none")
|
|
300
|
+
? (runtime.state[props.targetId]?.open ?? false)
|
|
301
|
+
: undefined,
|
|
302
|
+
href: runtime.authoring ? undefined : href,
|
|
303
|
+
target: props.newWindow ? "_blank" : undefined,
|
|
304
|
+
rel: props.newWindow ? "noopener noreferrer" : undefined,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
function renderActionBlock({ block, children, shared, runtime, open }) {
|
|
308
|
+
switch (block.type) {
|
|
309
|
+
case "Button":
|
|
310
|
+
case "DropdownItem": {
|
|
311
|
+
const props = block.props;
|
|
312
|
+
const actionProps = blockActionProps(props, runtime);
|
|
313
|
+
return block.type === "DropdownItem" ? (_jsx(Dropdown.Item, { ...shared, ...actionProps, eventKey: block.type === "DropdownItem" ? block.props.eventKey ?? undefined : undefined, children: props.text })) : (_jsx(Button, { ...shared, ...actionProps, variant: `${props.outline ? "outline-" : ""}${props.variant}`, size: props.size ?? undefined, active: props.active ?? false, children: props.text }));
|
|
314
|
+
}
|
|
315
|
+
case "ButtonGroup":
|
|
316
|
+
return (_jsx(ButtonGroup, { ...shared, vertical: block.props.vertical, size: block.props.size ?? undefined, "aria-label": block.props.ariaLabel ?? undefined, children: children }));
|
|
317
|
+
case "Reveal":
|
|
318
|
+
return (_jsx("div", { ...shared, hidden: !runtime.authoring && !open, children: children }));
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function renderHintBlock({ block, children, shared, runtime, controlId, palette, container }) {
|
|
322
|
+
switch (block.type) {
|
|
323
|
+
case "Tooltip":
|
|
324
|
+
case "Popover": {
|
|
325
|
+
const placement = overlayPlacement(block.props.placement);
|
|
326
|
+
const overlay = block.type === "Tooltip" ? (_jsx(Tooltip, { ...palette, id: `${controlId}-hint`, children: block.props.text })) : (_jsxs(Popover, { ...palette, id: `${controlId}-hint`, children: [_jsx(Popover.Header, { children: block.props.title }), _jsx(Popover.Body, { children: block.props.text })] }));
|
|
327
|
+
if (block.props.triggerText)
|
|
328
|
+
return _jsx(OverlayTrigger, { popperConfig: CANVAS_OVERLAY_POSITION, container: container, trigger: block.type === 'Tooltip' ? ['hover', 'focus'] : ['click'], placement: placement, overlay: overlay, rootClose: true, children: _jsx(Button, { ...shared, "data-puck-overlay-portal": runtime.authoring || undefined, variant: "secondary", children: block.props.triggerText }) });
|
|
329
|
+
return runtime.authoring ? (_jsxs("div", { ...shared, children: [children, _jsx("small", { "data-content-edit-guide": true, children: block.props.text })] })) : (_jsxs("div", { ...shared, children: [children, _jsx(OverlayTrigger, { container: container, popperConfig: CANVAS_OVERLAY_POSITION, trigger: block.type === "Tooltip"
|
|
330
|
+
? ["hover", "focus"]
|
|
331
|
+
: ["click"], rootClose: true, placement: placement, overlay: overlay, children: _jsx(Button, { variant: "link", children: block.type === "Popover"
|
|
332
|
+
? block.props.title || "More information"
|
|
333
|
+
: "More information" }) }, runtime.revision)] }));
|
|
334
|
+
}
|
|
335
|
+
case "Progress":
|
|
336
|
+
return _jsx(BootstrapProgressBlock, { block: block, shared: shared });
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
function renderOverlayBlock({ block, children, shared, runtime, controlId, open, close, palette, container }) {
|
|
340
|
+
switch (block.type) {
|
|
341
|
+
case "Modal":
|
|
342
|
+
if (block.props.inline)
|
|
343
|
+
return _jsx("div", { ...shared, className: `${shared.className ?? ''} modal-static`, children: _jsxs(Modal.Dialog, { children: [_jsx(Modal.Header, { closeButton: block.props.closeButton, "data-content-edit-guide": runtime.authoring || undefined, children: _jsx(Modal.Title, { as: "h5", children: block.props.title }) }), children] }) });
|
|
344
|
+
return runtime.authoring ? (_jsxs("section", { ...shared, "aria-label": block.props.title, children: [_jsx("h3", { className: "h6", "data-content-edit-guide": runtime.authoring || undefined, children: block.props.title }), children] })) : (_jsxs(Modal, { container: container, ...palette, className: `lesson-slides ${palette.className}`, show: open, onHide: close, size: block.props.size === "fullscreen"
|
|
345
|
+
? undefined
|
|
346
|
+
: block.props.size, fullscreen: block.props.size === "fullscreen" ? true : undefined, centered: block.props.centered, scrollable: block.props.scrollable, "aria-labelledby": `${controlId}-title`, children: [_jsx(Modal.Header, { closeButton: block.props.closeButton, "data-content-edit-guide": runtime.authoring || undefined, children: _jsx(Modal.Title, { id: `${controlId}-title`, children: block.props.title }) }), _jsx(Modal.Body, { ...shared, className: `${shared.className ?? ""} lesson-slide`, children: children })] }));
|
|
347
|
+
case "Offcanvas":
|
|
348
|
+
return runtime.authoring ? (_jsxs("section", { ...shared, "aria-label": block.props.title, children: [_jsx("h3", { className: "h6", "data-content-edit-guide": runtime.authoring || undefined, children: block.props.title }), children] })) : (_jsxs(Offcanvas, { container: container, ...palette, className: `lesson-slides ${palette.className}`, show: open, onHide: close, placement: block.props.placement, backdrop: block.props.backdrop, "aria-labelledby": `${controlId}-title`, children: [_jsx(Offcanvas.Header, { closeButton: block.props.closeButton, children: _jsx(Offcanvas.Title, { id: `${controlId}-title`, children: block.props.title }) }), _jsx(Offcanvas.Body, { ...shared, className: `${shared.className ?? ""} lesson-slide`, children: children })] }));
|
|
349
|
+
case "Dropdown":
|
|
350
|
+
return (_jsxs(Dropdown, { ...shared, "data-content-edit-guide-root": runtime.authoring || undefined, as: block.props.split ? ButtonGroup : 'div', className: `${shared.className ?? ''}${block.props.nav ? ' nav-item' : ''}`, onSelect: undefined, show: open, onToggle: show => runtime.update(block.props.id, { open: show }), children: [block.props.split && _jsx(Button, { "data-content-edit-guide": runtime.authoring || undefined, variant: block.props.variant, size: block.props.size ?? undefined, children: block.props.text }), _jsx(Dropdown.Toggle, { as: block.props.nav ? Nav.Link : ReadableDropdownToggle, id: controlId, split: block.props.split ?? undefined, variant: block.props.variant, size: block.props.size ?? undefined, "aria-label": block.props.split ? 'Toggle dropdown' : block.props.text || 'Toggle options', "data-puck-overlay-portal": runtime.authoring || undefined, "data-content-edit-guide": runtime.authoring || undefined, onClickCapture: event => { if (runtime.authoring) {
|
|
351
|
+
event.preventDefault();
|
|
352
|
+
event.stopPropagation();
|
|
353
|
+
runtime.update(block.props.id, { open: !open });
|
|
354
|
+
} }, onPointerDownCapture: event => { if (runtime.authoring)
|
|
355
|
+
event.stopPropagation(); }, onKeyDownCapture: event => { if (runtime.authoring && (event.key === ' ' || event.key === 'Enter')) {
|
|
356
|
+
event.preventDefault();
|
|
357
|
+
event.stopPropagation();
|
|
358
|
+
runtime.update(block.props.id, { open: !open });
|
|
359
|
+
} }, children: block.props.split ? _jsx("span", { className: "visually-hidden", children: "Toggle dropdown" }) : block.props.text }), _jsx(Dropdown.Menu, { as: ReadableDropdownSurface, renderOnMount: true, popperConfig: CANVAS_OVERLAY_POSITION, children: children })] }, runtime.revision));
|
|
360
|
+
case "Toast":
|
|
361
|
+
return (_jsxs(Toast, { ...shared, show: runtime.authoring || open, onClose: close, autohide: !runtime.authoring &&
|
|
362
|
+
runtime.playbackActive &&
|
|
363
|
+
block.props.autohide, delay: block.props.delay, children: [_jsxs(Toast.Header, { closeButton: !runtime.authoring, "data-content-edit-guide": runtime.authoring || undefined, children: [_jsx("strong", { className: "me-auto", children: block.props.title }), block.props.subtitle && _jsx("small", { children: block.props.subtitle })] }), _jsx(Toast.Body, { children: children })] }));
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
function renderPracticeBlock({ block, shared, runtime, controlId }) {
|
|
367
|
+
switch (block.type) {
|
|
368
|
+
case "FormControl":
|
|
369
|
+
case "PracticeInput":
|
|
370
|
+
return _jsx(PracticeInputBlock, { block: block, shared: shared, controlId: controlId, revision: runtime.revision });
|
|
371
|
+
case "FormSelect":
|
|
372
|
+
return _jsx(Form.Select, { ...shared, id: controlId, multiple: block.props.multiple ?? false, size: block.props.size ?? undefined, defaultValue: block.props.multiple ? [block.props.defaultValue ?? ''] : block.props.defaultValue, disabled: block.props.disabled, required: block.props.required, "aria-label": block.props.ariaLabel || block.props.label || 'Select', children: block.props.options?.map(option => _jsx("option", { value: option.value, disabled: option.disabled, children: option.label }, option.value)) });
|
|
373
|
+
case "FormRange":
|
|
374
|
+
return _jsx(Form.Range, { ...shared, id: controlId, min: block.props.min, max: block.props.max, step: block.props.step, defaultValue: block.props.defaultValue, disabled: block.props.disabled, "aria-label": block.props.ariaLabel || block.props.label || 'Range' });
|
|
375
|
+
case "PracticeSelect":
|
|
376
|
+
return (_jsxs(Form.Group, { ...shared, "data-content-edit-guide": runtime.authoring || undefined, controlId: controlId, children: [_jsx(Form.Label, { children: block.props.label }), _jsx(Form.Select, { defaultValue: block.props.multiple ? [block.props.defaultValue ?? ""] : block.props.defaultValue, multiple: block.props.multiple ?? false, size: block.props.size ?? undefined, required: block.props.required, disabled: block.props.disabled, children: (block.props.options ?? []).map((option) => (_jsx("option", { value: option.value, disabled: option.disabled, children: option.label }, option.value))) })] }, runtime.revision));
|
|
377
|
+
case "PracticeCheck":
|
|
378
|
+
if (block.props.cssClasses?.split(' ').includes('btn-check'))
|
|
379
|
+
return _jsxs(_Fragment, { children: [_jsx("input", { className: "btn-check", id: controlId, type: block.props.type === 'radio' ? 'radio' : 'checkbox', name: `${runtime.scopeId}-${block.props.name || block.props.id}`, defaultChecked: block.props.defaultChecked, disabled: block.props.disabled, autoComplete: "off" }), _jsx("label", { ...shared, className: block.props.cssClasses.split(' ').filter(name => name !== 'btn-check').join(' '), htmlFor: controlId, children: block.props.label })] });
|
|
380
|
+
return (_createElement("div", { ...shared, key: runtime.revision, tabIndex: -1, "data-content-edit-guide": runtime.authoring || undefined, className: ['form-check', block.props.type === 'switch' ? 'form-switch' : '', shared.className].filter(Boolean).join(' ') },
|
|
381
|
+
_jsx(Form.Check.Input, { id: controlId, type: block.props.type === 'radio' ? 'radio' : 'checkbox', role: block.props.type === 'switch' ? 'switch' : undefined, tabIndex: shared.tabIndex, "aria-label": shared['aria-label'], defaultChecked: block.props.defaultChecked, disabled: block.props.disabled, name: `${runtime.scopeId}-${block.props.name || block.props.id}` }),
|
|
382
|
+
_jsx(Form.Check.Label, { htmlFor: controlId, children: block.props.label })));
|
|
383
|
+
case "PracticeRange":
|
|
384
|
+
return (_jsxs(Form.Group, { ...shared, "data-content-edit-guide": runtime.authoring || undefined, controlId: controlId, children: [_jsx(Form.Label, { children: block.props.label }), _jsx(Form.Range, { min: block.props.min, max: block.props.max, step: block.props.step, defaultValue: block.props.defaultValue, disabled: block.props.disabled })] }, runtime.revision));
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
function renderContentBlock({ block, children, shared, runtime, media }) {
|
|
388
|
+
switch (block.type) {
|
|
389
|
+
case "Breadcrumb":
|
|
390
|
+
return _jsx(Breadcrumb, { ...shared, className: shared.className?.split(/\s+/).filter(name => name !== 'breadcrumb').join(' '), children: children });
|
|
391
|
+
case "BreadcrumbItem":
|
|
392
|
+
return (_jsx(Breadcrumb.Item, { ...shared, href: runtime.authoring
|
|
393
|
+
? undefined
|
|
394
|
+
: safeBootstrapUrl(block.props.href ?? ""), active: block.props.active, children: block.props.text }));
|
|
395
|
+
case "Video":
|
|
396
|
+
case "Audio": {
|
|
397
|
+
const MediaElement = block.type === "Video" ? "video" : "audio";
|
|
398
|
+
return (_jsx(MediaElement, { ...shared, className: `${shared.className ?? ""} lesson-slide-${MediaElement}`, ref: (node) => {
|
|
399
|
+
media.current = node;
|
|
400
|
+
shared.ref?.(node);
|
|
401
|
+
}, src: safeBootstrapUrl(block.props.src ?? "", false), poster: block.type === "Video"
|
|
402
|
+
? safeBootstrapUrl(block.props.poster ?? "", false)
|
|
403
|
+
: undefined, controls: block.props.controls, autoPlay: !runtime.authoring && runtime.playbackActive && block.props.autoPlay, muted: block.props.muted, loop: block.props.loop, preload: "metadata", "aria-label": block.props.ariaLabel || block.type, children: _jsx("track", { kind: "captions", src: safeBootstrapUrl(block.props.captionsSrc ?? "", false), srcLang: block.props.captionsLanguage, label: block.props.captionsLabel }) }, runtime.revision));
|
|
404
|
+
}
|
|
405
|
+
case "Embed":
|
|
406
|
+
return (_jsx("iframe", { ...shared, src: safeEmbedUrl(block.props.src ?? ""), title: block.props.title, allowFullScreen: block.props.allowFullScreen, sandbox: "allow-scripts allow-same-origin allow-presentation", referrerPolicy: "no-referrer", loading: "lazy" }));
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
function overlayPlacement(placement) {
|
|
410
|
+
if (placement === "start")
|
|
411
|
+
return "left";
|
|
412
|
+
if (placement === "end")
|
|
413
|
+
return "right";
|
|
414
|
+
return placement;
|
|
415
|
+
}
|
|
416
|
+
function safeEmbedUrl(value) {
|
|
417
|
+
try {
|
|
418
|
+
const url = new URL(value);
|
|
419
|
+
return !url.username &&
|
|
420
|
+
!url.password &&
|
|
421
|
+
!url.port &&
|
|
422
|
+
!url.hash &&
|
|
423
|
+
url.protocol === "https:" &&
|
|
424
|
+
((url.hostname === "www.youtube-nocookie.com" &&
|
|
425
|
+
url.pathname.startsWith("/embed/")) ||
|
|
426
|
+
(url.hostname === "player.vimeo.com" &&
|
|
427
|
+
url.pathname.startsWith("/video/")))
|
|
428
|
+
? url.href
|
|
429
|
+
: undefined;
|
|
430
|
+
}
|
|
431
|
+
catch {
|
|
432
|
+
return undefined;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
@import './editor-ui-colors.css';
|
|
2
|
+
/**
|
|
3
|
+
* JSONEditor defaults use blue (#3883fa) outer borders. When embedded in a Bootstrap-framed
|
|
4
|
+
* panel (e.g. graph editor Markup tab), match --bs-border-color and drop the top edge so the pane
|
|
5
|
+
* meets the tab strip without a double line.
|
|
6
|
+
*/
|
|
7
|
+
.json-editor-embedded-in-panel .jsoneditor {
|
|
8
|
+
border: none !important;
|
|
9
|
+
border-top: none !important;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.json-editor-embedded-in-panel .jsoneditor-menu {
|
|
13
|
+
border-top: none !important;
|
|
14
|
+
border-left: none !important;
|
|
15
|
+
border-right: none !important;
|
|
16
|
+
border-bottom: 1px solid var(--bs-border-color) !important;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.json-editor-embedded-in-panel .jsoneditor-navigation-bar {
|
|
20
|
+
border-top: none !important;
|
|
21
|
+
border-bottom-color: var(--bs-border-color) !important;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.json-editor-embedded-in-panel .jsoneditor-statusbar {
|
|
25
|
+
border-top-color: var(--bs-border-color) !important;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.json-editor-embedded-in-panel .jsoneditor-outer {
|
|
29
|
+
border: none !important;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.json-editor-embedded-in-panel .jsoneditor-tree table.jsoneditor-tree td.jsoneditor-separator {
|
|
33
|
+
border-color: var(--bs-border-color) !important;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.json-editor-embedded-in-panel .jsoneditor-search .jsoneditor-frame {
|
|
37
|
+
border-color: var(--bs-border-color) !important;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* The source surface follows the same Bootstrap theme as either authoring host. */
|
|
41
|
+
.json-text-editor .jsoneditor,
|
|
42
|
+
.json-text-editor .jsoneditor-tree,
|
|
43
|
+
.json-text-editor textarea.jsoneditor-text,
|
|
44
|
+
.json-text-editor .ace_editor,
|
|
45
|
+
.json-text-editor .ace_editor .ace_scroller {
|
|
46
|
+
background: var(--bs-body-bg);
|
|
47
|
+
color: var(--editor-json-text);
|
|
48
|
+
border-color: var(--bs-border-color);
|
|
49
|
+
}
|
|
50
|
+
/* JSONEditor's outer wrapper overlaps its floated menu through a negative margin.
|
|
51
|
+
* Keep it transparent so the content surface cannot paint over the toolbar. */
|
|
52
|
+
.json-text-editor .jsoneditor-outer { background: transparent; }
|
|
53
|
+
.json-text-editor {
|
|
54
|
+
--editor-json-text: var(--bs-body-color);
|
|
55
|
+
--editor-json-icon-filter: brightness(0);
|
|
56
|
+
}
|
|
57
|
+
[data-editor-color-scheme='dark'] .json-text-editor {
|
|
58
|
+
--editor-json-icon-filter: brightness(0) invert(1);
|
|
59
|
+
}
|
|
60
|
+
.json-text-editor div.jsoneditor { display: flex; flex-direction: column; }
|
|
61
|
+
.json-text-editor div.jsoneditor > div.jsoneditor-menu {
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-wrap: wrap;
|
|
64
|
+
align-items: center;
|
|
65
|
+
flex: none;
|
|
66
|
+
height: auto;
|
|
67
|
+
min-height: 35px;
|
|
68
|
+
background: var(--editor-ui-surface-subtle);
|
|
69
|
+
color: var(--editor-json-text);
|
|
70
|
+
border-color: var(--bs-border-color);
|
|
71
|
+
}
|
|
72
|
+
.json-text-editor div.jsoneditor > .jsoneditor-outer {
|
|
73
|
+
flex: 1;
|
|
74
|
+
min-height: 0;
|
|
75
|
+
height: auto;
|
|
76
|
+
margin: 0;
|
|
77
|
+
padding: 0;
|
|
78
|
+
}
|
|
79
|
+
.json-text-editor .jsoneditor-navigation-bar,
|
|
80
|
+
.json-text-editor .jsoneditor-statusbar { flex: none; }
|
|
81
|
+
.json-text-editor div.jsoneditor > .jsoneditor-menu > button {
|
|
82
|
+
filter: var(--editor-json-icon-filter);
|
|
83
|
+
flex: none;
|
|
84
|
+
}
|
|
85
|
+
.json-text-editor .jsoneditor-search {
|
|
86
|
+
position: static;
|
|
87
|
+
margin-left: auto;
|
|
88
|
+
max-width: 100%;
|
|
89
|
+
}
|
|
90
|
+
.json-text-editor .jsoneditor-search .jsoneditor-frame,
|
|
91
|
+
.json-text-editor .jsoneditor-search input {
|
|
92
|
+
background: var(--bs-body-bg);
|
|
93
|
+
color: var(--editor-json-text);
|
|
94
|
+
}
|
|
95
|
+
.json-text-editor .jsoneditor-search button,
|
|
96
|
+
.json-text-editor .jsoneditor-contextmenu .jsoneditor-icon {
|
|
97
|
+
filter: brightness(0);
|
|
98
|
+
}
|
|
99
|
+
[data-editor-color-scheme='dark'] .json-text-editor .jsoneditor-search button,
|
|
100
|
+
[data-editor-color-scheme='dark'] .json-text-editor .jsoneditor-contextmenu .jsoneditor-icon {
|
|
101
|
+
filter: brightness(0) invert(1);
|
|
102
|
+
}
|
|
103
|
+
.json-text-editor .jsoneditor-results { color: var(--editor-json-text); }
|
|
104
|
+
.json-text-editor div.jsoneditor > .jsoneditor-menu > .jsoneditor-modes > button,
|
|
105
|
+
.json-text-editor div.jsoneditor > .jsoneditor-menu > a {
|
|
106
|
+
color: var(--editor-json-text);
|
|
107
|
+
}
|
|
108
|
+
.json-text-editor div.jsoneditor > .jsoneditor-menu > a.jsoneditor-poweredBy {
|
|
109
|
+
position: static;
|
|
110
|
+
margin-left: auto;
|
|
111
|
+
}
|
|
112
|
+
.json-text-editor .jsoneditor-menu button:focus-visible {
|
|
113
|
+
outline: 2px solid var(--editor-json-text);
|
|
114
|
+
outline-offset: -2px;
|
|
115
|
+
}
|
|
116
|
+
.json-text-editor .jsoneditor-contextmenu .jsoneditor-menu {
|
|
117
|
+
background: var(--bs-body-bg);
|
|
118
|
+
color: var(--editor-json-text);
|
|
119
|
+
}
|
|
120
|
+
.json-text-editor .jsoneditor-contextmenu .jsoneditor-menu button {
|
|
121
|
+
color: var(--editor-json-text);
|
|
122
|
+
}
|
|
123
|
+
.json-text-editor .jsoneditor-contextmenu .jsoneditor-menu button:hover,
|
|
124
|
+
.json-text-editor .jsoneditor-contextmenu .jsoneditor-menu button:focus {
|
|
125
|
+
background-color: var(--editor-ui-surface-hover);
|
|
126
|
+
}
|
|
127
|
+
.json-text-editor .jsoneditor-navigation-bar,
|
|
128
|
+
.json-text-editor .jsoneditor-statusbar,
|
|
129
|
+
.json-text-editor .ace_editor .ace_gutter {
|
|
130
|
+
background: var(--editor-ui-surface-subtle);
|
|
131
|
+
color: var(--editor-json-text);
|
|
132
|
+
border-color: var(--bs-border-color);
|
|
133
|
+
}
|
|
134
|
+
.json-text-editor .ace_editor .ace_gutter-active-line,
|
|
135
|
+
.json-text-editor .ace_editor .ace_marker-layer .ace_active-line {
|
|
136
|
+
background: var(--editor-ui-surface-subtle);
|
|
137
|
+
}
|
|
138
|
+
.json-text-editor .ace_editor .ace_marker-layer .ace_selection {
|
|
139
|
+
background: color-mix(in srgb, var(--bs-body-bg) 75%, var(--bs-primary));
|
|
140
|
+
}
|
|
141
|
+
.json-text-editor .ace_editor .ace_cursor,
|
|
142
|
+
.json-text-editor .ace_editor .ace_punctuation,
|
|
143
|
+
.json-text-editor .ace_editor .ace_paren { color: var(--editor-json-text); }
|
|
144
|
+
.json-text-editor .ace_editor .ace_variable { color: var(--editor-ui-info-text); }
|
|
145
|
+
.json-text-editor .ace_editor .ace_string { color: var(--editor-ui-success-text); }
|
|
146
|
+
.json-text-editor .ace_editor .ace_constant.ace_numeric { color: var(--editor-ui-primary-text); }
|
|
147
|
+
.json-text-editor .ace_editor .ace_constant.ace_language { color: var(--editor-ui-warning-text); }
|
|
148
|
+
.json-text-editor .ace_editor .ace_invalid { color: var(--editor-ui-danger-text); background: var(--bs-danger-bg-subtle); }
|
|
149
|
+
.json-text-editor .jsoneditor-tree .jsoneditor-field,
|
|
150
|
+
.json-text-editor .jsoneditor-tree .jsoneditor-readonly,
|
|
151
|
+
.json-text-editor .jsoneditor-tree .jsoneditor-value { color: var(--editor-json-text); }
|
|
152
|
+
.json-text-editor .jsoneditor-tree .jsoneditor-value.jsoneditor-string { color: var(--editor-ui-success-text); }
|
|
153
|
+
.json-text-editor .jsoneditor-tree .jsoneditor-value.jsoneditor-number { color: var(--editor-ui-primary-text); }
|
|
154
|
+
.json-text-editor .jsoneditor-tree .jsoneditor-value.jsoneditor-boolean { color: var(--editor-ui-warning-text); }
|
|
155
|
+
.json-text-editor .jsoneditor-tree .jsoneditor-value.jsoneditor-null { color: var(--editor-json-text); }
|
|
156
|
+
.json-text-editor .jsoneditor-tree .jsoneditor-selected,
|
|
157
|
+
.json-text-editor .jsoneditor-tree .jsoneditor-highlight { background: var(--bs-primary-bg-subtle); }
|
|
158
|
+
:is([data-bs-theme='dark'], [data-editor-color-scheme='dark']) .json-text-editor .jsoneditor-tree button { filter: invert(1); }
|
|
159
|
+
|
|
160
|
+
/* Menu sprites are filtered as a whole, including their focus outline. */
|
|
161
|
+
.json-text-editor div.jsoneditor > .jsoneditor-menu > button:focus-visible {
|
|
162
|
+
outline-color: black;
|
|
163
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import './JsonEditor.css';
|
|
2
|
+
export interface JsonTextEditorProps {
|
|
3
|
+
value: string;
|
|
4
|
+
onChange: (text: string) => void;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
ariaLabel?: string;
|
|
7
|
+
describedBy?: string;
|
|
8
|
+
invalid?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** The existing JSONEditor library, with raw text preserved for incomplete drafts and array roots. */
|
|
11
|
+
export default function JsonTextEditor({ value, onChange, disabled, ariaLabel, describedBy, invalid, }: Readonly<JsonTextEditorProps>): import("react").JSX.Element;
|